]> granicus.if.org Git - clang/commitdiff
Bug 28065 - clang-format incorrectly aligns backslash.
authorAndi-Bogdan Postelnicu <andi@mozilla.com>
Wed, 26 Oct 2016 07:44:51 +0000 (07:44 +0000)
committerAndi-Bogdan Postelnicu <andi@mozilla.com>
Wed, 26 Oct 2016 07:44:51 +0000 (07:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285178 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/WhitespaceManager.cpp
unittests/Format/FormatTest.cpp

index 8ca307bd1658ed915767a1f66cc6c56e23daef2f..ebc72a9d458117a1d353d0e1c768ee759c3ea06d 100644 (file)
@@ -432,7 +432,7 @@ void WhitespaceManager::alignTrailingComments(unsigned Start, unsigned End,
     }
     assert(Shift >= 0);
     Changes[i].Spaces += Shift;
-    if (i + 1 != End)
+    if (i + 1 != Changes.size())
       Changes[i + 1].PreviousEndOfTokenColumn += Shift;
     Changes[i].StartOfTokenColumn += Shift;
   }
index f04f5e5dc0decd7cc2cfb5650ae688696d1e63d6..ee08121c5ad80f10df9ad8a318fc27f871bd526f 100644 (file)
@@ -11597,6 +11597,17 @@ TEST_F(ReplacementTest, SortIncludesAfterReplacement) {
   EXPECT_EQ(Expected, *Result);
 }
 
+TEST_F(FormatTest, AllignTrailingComments) {
+  EXPECT_EQ("#define MACRO(V)                       \\\n"
+            "  V(Rt2) /* one more char */           \\\n"
+            "  V(Rs)  /* than here  */              \\\n"
+            "/* comment 3 */\n",
+            format("#define MACRO(V)\\\n"
+                   "V(Rt2)  /* one more char */ \\\n"
+                   "V(Rs) /* than here  */    \\\n"
+                   "/* comment 3 */         \\\n",
+                   getLLVMStyleWithColumns(40)));
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang