[PATCH] Better block comment formatting.

Daniel Jasper djasper at google.com
Thu Mar 21 04:33:35 PDT 2013



================
Comment at: lib/Format/Format.cpp:169-172
@@ -166,4 +168,6 @@
                            unsigned Spaces, unsigned WhitespaceStartColumn) {
-    if (Tok.Type == TT_BlockComment)
-      indentBlockComment(Tok, Spaces, true);
+    if (Tok.Type == TT_BlockComment) {
+      int StartColumn = NewLines > 0 ? Spaces : WhitespaceStartColumn + Spaces;
+      indentBlockComment(Tok, Spaces, StartColumn, true);
+    }
 
----------------
It seems a bit weird to have the exact same block of code twice (only with s/true/false/). Probably not a big problem now, but if it grows any further, we should pull out a method.

Ideas:
- You could pass WhitespaceStartColumn and NewLines into indentBlockComment and calculate StartColumn there
- You could check for TT_BlockComment in indentBlockComment ("if (Tok.Type != TT_BlockComment) return")

Not sure that these make it better, but I hat duplication ;-)


http://llvm-reviews.chandlerc.com/D557

BRANCH
  svn

ARCANIST PROJECT
  clang



More information about the cfe-commits mailing list