Fix a problem in ExpressionParser leading to trailing comments affecting indentation of an expression after a line break.
Summary:
E.g. the second line in
return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
b; //
is indented 4 characters more than in
return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
b;
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D984
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184078 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 85c5a36..c6b4919 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -151,7 +151,7 @@
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 @@
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 @@
}
void next() {
- if (Current != NULL)
+ if (Current)
+ Current = Current->Next;
+ while (Current && Current->isTrailingComment())
Current = Current->Next;
}