r285178 - Bug 28065 - clang-format incorrectly aligns backslash.
Andi-Bogdan Postelnicu via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 26 00:44:52 PDT 2016
Author: abpostelnicu
Date: Wed Oct 26 02:44:51 2016
New Revision: 285178
URL: http://llvm.org/viewvc/llvm-project?rev=285178&view=rev
Log:
Bug 28065 - clang-format incorrectly aligns backslash.
Modified:
cfe/trunk/lib/Format/WhitespaceManager.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=285178&r1=285177&r2=285178&view=diff
==============================================================================
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Wed Oct 26 02:44:51 2016
@@ -432,7 +432,7 @@ void WhitespaceManager::alignTrailingCom
}
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;
}
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=285178&r1=285177&r2=285178&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Oct 26 02:44:51 2016
@@ -11597,6 +11597,17 @@ TEST_F(ReplacementTest, SortIncludesAfte
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
More information about the cfe-commits
mailing list