From 42f458d164cbbee23e55e874b6cee7026ca721ca Mon Sep 17 00:00:00 2001
From: Daniel Jasper <djasper@google.com>
Date: Wed, 13 Feb 2013 19:25:54 +0000
Subject: [PATCH] Fix comment alignment close to the column limit.

Due to an error in one of the expressions, we used to not align comments
although it would have been possible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175068 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Format/Format.cpp           | 2 +-
 unittests/Format/FormatTest.cpp | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index d66271ce61d..d8c02e2e18b 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -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;
       }
     }
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 354654b1e28..8fb4b2acd5e 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -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",
-- 
GitLab