r205011 - clang-format: Fix aligning of comments and escaped newlines in macros.
Daniel Jasper
djasper at google.com
Fri Mar 28 08:06:02 PDT 2014
Author: djasper
Date: Fri Mar 28 10:06:01 2014
New Revision: 205011
URL: http://llvm.org/viewvc/llvm-project?rev=205011&view=rev
Log:
clang-format: Fix aligning of comments and escaped newlines in macros.
Before:
#define A \
int i; /*a*/ \
int jjj; /*b*/
After:
#define A \
int i; /*a*/ \
int jjj; /*b*/
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=205011&r1=205010&r2=205011&view=diff
==============================================================================
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Fri Mar 28 10:06:01 2014
@@ -193,6 +193,10 @@ void WhitespaceManager::alignTrailingCom
if (Changes[i].IsTrailingComment) {
assert(Column >= Changes[i].StartOfTokenColumn);
Changes[i].Spaces += Column - Changes[i].StartOfTokenColumn;
+ if (i + 1 != End) {
+ Changes[i + 1].PreviousEndOfTokenColumn +=
+ Column - Changes[i].StartOfTokenColumn;
+ }
Changes[i].StartOfTokenColumn = Column;
}
}
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=205011&r1=205010&r2=205011&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Mar 28 10:06:01 2014
@@ -946,6 +946,11 @@ TEST_F(FormatTest, UnderstandsBlockComme
" /* parameter 3 */ aaaaaa,\n"
" /* parameter 4 */ aaaaaa);",
NoBinPacking);
+
+ // Aligning block comments in macros.
+ verifyGoogleFormat("#define A \\\n"
+ " int i; /*a*/ \\\n"
+ " int jjj; /*b*/");
}
TEST_F(FormatTest, AlignsBlockComments) {
More information about the cfe-commits
mailing list