summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-07-11 13:48:16 +0000
committerDaniel Jasper <djasper@google.com>2013-07-11 13:48:16 +0000
commit185de2499b9ff5cf0fa9df3010565373a4089cb8 (patch)
tree1c0bbea8da39f9c8000d235d5087568278801f68 /clang
parenta7f6913c08bd9a2639da2273428feae04e04063f (diff)
downloadbcm5719-llvm-185de2499b9ff5cf0fa9df3010565373a4089cb8.tar.gz
bcm5719-llvm-185de2499b9ff5cf0fa9df3010565373a4089cb8.zip
Fix indentation problem for comments in call chains
Before: SomeObject // Calling someFunction on SomeObject .someFunction(); After: SomeObject // Calling someFunction on SomeObject .someFunction(); llvm-svn: 186085
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/Format.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp3
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index ad390c23dcd..0dd47fe4a99 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -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;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 8435c94a0fe..42cd89cc8b7 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -576,6 +576,9 @@ TEST_F(FormatTest, UnderstandsSingleLineComments) {
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)");
OpenPOWER on IntegriCloud