clang-format incorrectly format layout/style/nsCSSPropAliasList.h

RESOLVED FIXED in Firefox 57

Status

defect
RESOLVED FIXED
2 years ago
Last year

People

(Reporter: sylvestre, Assigned: andi)

Tracking

(Blocks 1 bug)

Trunk
mozilla57
Dependency tree / graph

Firefox Tracking Flags

(firefox54 affected, firefox57 fixed)

Details

Attachments

(1 attachment)

Reporter

Description

2 years ago
-CSS_PROP_ALIAS(-moz-perspective-origin,
+CSS_PROP_ALIAS(-moz - perspective - origin,

Which is obviously breaking the build.
Reporter

Comment 1

2 years ago
the build fails with:
   File "/home/sylvestre/dev/mozilla/mozilla-central.else.change/other-licenses/ply/ply/yacc.py", line 263, in parse
     return self.parseopt(input,lexer,debug,tracking,tokenfunc)
   File "/home/sylvestre/dev/mozilla/mozilla-central.else.change/other-licenses/ply/ply/yacc.py", line 792, in parseopt
     tok = self.errorfunc(errtoken)
   File "/home/sylvestre/dev/mozilla/mozilla-central.else.change/dom/bindings/parser/WebIDL.py", line 6770, in p_error
     raise WebIDLError("invalid syntax", [Location(self.lexer, p.lineno, p.lexpos, self._filename)])
 WebIDL.WebIDLError: error: invalid syntax, /home/sylvestre/dev/mozilla/mozilla-central.else.change/obj-x86_64-pc-linux-gnu/dom/bindings/CSS2Properties.webidl line 5:90
   [Throws, TreatNullAs=EmptyString, BinaryName="alignContent"] attribute DOMString _align - content;
                                                                                           ^
 Makefile:55 : la recette pour la cible « codegen.pp » a échouée
Reporter

Comment 2

2 years ago
Reverting the indentation of layout/style/nsCSSPropAliasList.h & layout/style/nsCSSPropList.h
fixes the issue
Reporter

Comment 3

2 years ago
Test case
void foo() {
---
CSS_PROP_ALIAS(-moz-perspective-origin,
		"bar");

}
---
clang-format-5.0 foo.cpp

void foo() { CSS_PROP_ALIAS(-moz - perspective - origin, "bar"); }
Reporter

Comment 4

2 years ago
#define DO_PROP(name, method, id, flags, pref, proptype) \
  [ #name, #method, #id, PROP_STRINGIFY(flags), pref, proptype ]

#define CSS_PROP_ALIAS(name, id, method, pref) \
  DO_PROP(name, method, id, 0, pref, "alias")
Assignee

Updated

2 years ago
Assignee: nobody → bpostelnicu
Assignee

Comment 5

2 years ago
The problem here is that clang-format is built on a token stream based processing so it cannot distinguish a function call from a macro call, thus in this case it believes that:

>>CSS_PROP_ALIAS(-moz-perspective-origin,
>>		"bar");

It's a function call, and the first parameters is analysed as an expression that leads to the literal to be indented. 
Taking all of this into account I think the best approach would be to change the names of the variables/ literals involved.
Comment hidden (mozreview-request)
Assignee

Comment 7

2 years ago
mozreview-review
Comment on attachment 8898257 [details]
Bug 1342657 - clang-format: Ignore two files which are using some #define trick

https://reviewboard.mozilla.org/r/169628/#review175630

Thank you and sorry for the delay!
Attachment #8898257 - Flags: review?(bpostelnicu) → review+

Comment 8

2 years ago
Pushed by sledru@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2c00fbd09ddc
clang-format: Ignore two files which are using some #define trick r=andi
https://hg.mozilla.org/mozilla-central/rev/2c00fbd09ddc
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57

Updated

Last year
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.