r186085 - Fix indentation problem for comments in call chains
Daniel Jasper
djasper at google.com
Thu Jul 11 06:48:16 PDT 2013
Author: djasper
Date: Thu Jul 11 08:48:16 2013
New Revision: 186085
URL: http://llvm.org/viewvc/llvm-project?rev=186085&view=rev
Log:
Fix indentation problem for comments in call chains
Before:
SomeObject
// Calling someFunction on SomeObject
.someFunction();
After:
SomeObject
// Calling someFunction on SomeObject
.someFunction();
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=186085&r1=186084&r2=186085&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Jul 11 08:48:16 2013
@@ -589,7 +589,8 @@ private:
State.Column, Line.InPPDirective);
}
- State.Stack.back().LastSpace = State.Column;
+ if (!Current.isTrailingComment())
+ State.Stack.back().LastSpace = State.Column;
if (Current.isOneOf(tok::arrow, tok::period) &&
Current.Type != TT_DesignatedInitializerPeriod)
State.Stack.back().LastSpace += Current.CodePointCount;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=186085&r1=186084&r2=186085&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jul 11 08:48:16 2013
@@ -576,6 +576,9 @@ TEST_F(FormatTest, UnderstandsSingleLine
verifyFormat("void f() {\n"
" // Doesn't do anything\n"
"}");
+ verifyFormat("SomeObject\n"
+ " // Calling someFunction on SomeObject\n"
+ " .someFunction();");
verifyFormat("void f(int i, // some comment (probably for i)\n"
" int j, // some comment (probably for j)\n"
" int k); // some comment (probably for k)");
More information about the cfe-commits
mailing list