diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 11 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 7 |
2 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 85c5a36a0a7..c6b491914b3 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -151,7 +151,7 @@ private: if (!CurrentToken) return false; - // A '[' could be an index subscript (after an indentifier or after + // A '[' could be an index subscript (after an identifier or after // ')' or ']'), it could be the start of an Objective-C method // expression, or it could the the start of an Objective-C array literal. FormatToken *Left = CurrentToken->Previous; @@ -792,11 +792,6 @@ public: if (Precedence > prec::PointerToMember || Current == NULL) return; - // Eagerly consume trailing comments. - while (Current && Current->isTrailingComment()) { - next(); - } - FormatToken *Start = Current; bool OperatorFound = false; @@ -862,7 +857,9 @@ private: } void next() { - if (Current != NULL) + if (Current) + Current = Current->Next; + while (Current && Current->isTrailingComment()) Current = Current->Next; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index a26bf607214..8454af32ed5 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2150,6 +2150,13 @@ TEST_F(FormatTest, ExpressionIndentation) { "} else if (aaaaa && bbbbb > // break\n" " ccccc) {\n" "}"); + + // Presence of a trailing comment used to change indentation of b. + verifyFormat("return aaaaaaaaaaaaaaaaaaa +\n" + " b;\n" + "return aaaaaaaaaaaaaaaaaaa +\n" + " b; //", + getLLVMStyleWithColumns(30)); } TEST_F(FormatTest, ConstructorInitializers) { |