[PATCH] D42036: [clang-format] Keep comments aligned to macros
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 22 09:11:25 PST 2018
krasimir added inline comments.
================
Comment at: lib/Format/TokenAnnotator.cpp:1725
+ NextNonComment.Type == LT_ImportStatement) &&
+ NextNonComment.Level > 0 && !Comment.InPPDirective)
+ return NextNonComment.First->Next &&
----------------
Why are we checking `NextNonComment.Level > 0` here? We could be aligned with the next preprocessor directive even at level 0.
================
Comment at: lib/Format/TokenAnnotator.cpp:1729
+ NextNonComment.First->Next->OriginalColumn)
+ ? CA_Directive
+ : CA_None;
----------------
I think this should be enabled only if preprocessor indentation has been enabled.
================
Comment at: lib/Format/TokenAnnotator.cpp:1761
+ if (Alignment == CA_Directive)
+ (*I)->LevelOffset = 1;
} else {
----------------
Could you add a comment that this `1` comes from the `#` in the preprocessor directive?
================
Comment at: unittests/Format/FormatTest.cpp:2629
+ "# define B 0\n"
+ " // Trailing aligned comment\n"
+ "#endif\n"
----------------
I would expect this comment to be aligned with the `#endif` on the next line.
================
Comment at: unittests/Format/FormatTest.cpp:2657
+ " * Trailing aligned comment\n"
+ " */\n"
+ "#endif\n"
----------------
Same here.
Repository:
rC Clang
https://reviews.llvm.org/D42036
More information about the cfe-commits
mailing list