Fix comment alignment close to the column limit.
authorDaniel Jasper <djasper@google.com>
Wed, 13 Feb 2013 19:25:54 +0000 (19:25 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 13 Feb 2013 19:25:54 +0000 (19:25 +0000)
Due to an error in one of the expressions, we used to not align comments
although it would have been possible.

llvm-svn: 175068

clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

index d66271c..d8c02e2 100644 (file)
@@ -127,7 +127,7 @@ public:
         else
           Comments.back().MinColumn = Spaces;
         Comments.back().MaxColumn =
-            Style.ColumnLimit - Spaces - Tok.FormatTok.TokenLength;
+            Style.ColumnLimit - Tok.FormatTok.TokenLength;
         return;
       }
     }
index 354654b..8fb4b2a 100644 (file)
@@ -465,6 +465,9 @@ TEST_F(FormatTest, UnderstandsSingleLineComments) {
       "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
       "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaaa;");
 
+  verifyFormat("int aaaa; // aaaaa\n"
+               "int aa;   // aaaaaaa", getLLVMStyleWithColumns(20));
+
   EXPECT_EQ("void f() { // This does something ..\n"
             "}\n"
             "int a; // This is unrelated",