[PATCH] D29300: [clang-format] Refactor WhitespaceManager and friends

Manuel Klimek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 31 01:23:24 PST 2017


klimek added a comment.

Generally looks like the right direction, minus that I'm not sure yet what the plan for things broken in BreakableToken are.



================
Comment at: lib/Format/TokenAnnotator.cpp:1843
+        Current->MatchingParen->opensBlockOrBlockTypeList(Style))
+      --IndentLevel;
+    Current->IndentLevel = IndentLevel;
----------------
Perhaps add an assert that we don't underflow.


================
Comment at: lib/Format/UnwrappedLineFormatter.cpp:904-907
+void UnwrappedLineFormatter::formatFirstToken(const AnnotatedLine &Line,
                                               const AnnotatedLine *PreviousLine,
-                                              unsigned IndentLevel,
-                                              unsigned Indent,
-                                              bool InPPDirective) {
+                                              unsigned Indent) {
+  FormatToken& RootToken = *Line.First;
----------------
I'm not sure I understand the change in the function signature. Given that we really only need InPPDirective and FirstToken, it seems unnecessary to hand in the whole line? (in the spirit of minimal interfaces)


================
Comment at: lib/Format/WhitespaceManager.h:109-110
+    // this change inserts whitespace.
+    // FIXME: Currently this is not set correctly for breaks inside comments, as
+    // the \c BreakableToken is still doing its own alignment.
+    const FormatToken *Tok;
----------------
What's the proposed fix?


https://reviews.llvm.org/D29300





More information about the cfe-commits mailing list