[PATCH] D42036: [clang-format] Keep comments aligned to macros
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 18 07:25:31 PST 2018
krasimir added inline comments.
================
Comment at: lib/Format/TokenAnnotator.cpp:1710
+enum CommentAlignment { CA_None, CA_Code, CA_Preprocessor };
+
----------------
Please comment these.
================
Comment at: lib/Format/TokenAnnotator.cpp:1756
+ if (Alignment == CA_Preprocessor)
+ (*I)->LevelOffset = 1;
} else {
----------------
This feels a bit awkward: we're adding code that implicitly assumes the exact style the preprocessor directives and comments around them are handled. Maybe if this could become part of the level itself, it would feel less awkward.
================
Comment at: lib/Format/TokenAnnotator.h:41
AnnotatedLine(const UnwrappedLine &Line)
- : First(Line.Tokens.front().Tok), Level(Line.Level),
+ : First(Line.Tokens.front().Tok), Level(Line.Level), LevelOffset(0),
MatchingOpeningBlockLineIndex(Line.MatchingOpeningBlockLineIndex),
----------------
Is there a way to not introduce `LevelOffset`, but have it part of `Level`?
================
Comment at: unittests/Format/FormatTest.cpp:2619
+ "#endif\n"
+ "#endif";
+ EXPECT_EQ(Expected, format(ToFormat, Style));
----------------
I would like to see test including multiline `//`-comment sections before, inside and after preprocessor directives as well as `/**/`-style comments.
Repository:
rC Clang
https://reviews.llvm.org/D42036
More information about the cfe-commits
mailing list