[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

Erik Nyquist via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 23 20:32:38 PDT 2017


enyquist added inline comments.


================
Comment at: lib/Format/WhitespaceManager.cpp:431
+
+              // Special case for AlignTokens: for all other alignment cases,
+              // the current sequence is ended when a comma or a scope change
----------------
djasper wrote:
> enyquist wrote:
> > djasper wrote:
> > > I am not yet sure I understand this. How is this different from:
> > > 
> > >   $ clang-format test.cc -style="{AlignConsecutiveDeclarations: true}"
> > >   map<int, int> m;
> > >   map<int>      m;
> > >   int           a;
> > I'm not sure exactly what you mean. Do you mean, why do I need this special case to ignore scope changes and commas? This was the only way I could get it to work, AlignTokens was bailing out as soon as a paren or a comma inside parens was seen.
> Yes, that's what I mean. The example I am writing above works correctly and structurally, the two should be the same, right? Maybe this is easier now that you can skip over the parameter list because of the correct MatchingParen?
Hmm... when I just set IgnoreScopeAndCommas to False, most of the tests fail (all the blocks with parens in them) seem to fail. Sample:

```
/home/enyquist/clang-llvm/llvm/tools/clang/unittests/Format/FormatTest.cpp:74: Failure
      Expected: Code.str()
      Which is: "#define a    3\n#define bbbb 4\n#define ccc  (5)"
To be equal to: format(test::messUp(Code), Style)
      Which is: "#define a 3\n#define bbbb 4\n#define ccc (5)"
With diff:
@@ -1,3 +1,3 @@
-#define a    3
+#define a 3
 #define bbbb 4
-#define ccc  (5)
+#define ccc (5)
```

Not sure exactly what's going on here, I'll look into it. Perhaps I don't need to worry about commas.


Repository:
  rL LLVM

https://reviews.llvm.org/D28462





More information about the cfe-commits mailing list