Correctly determine */& usage in more cases.
This fixes llvm.org/PR15248.
Before:
Test::Test(int b) : a(b *b) {}
for (int i = 0; i < a *a; ++i) {}
After:
Test::Test(int b) : a(b * b) {}
for (int i = 0; i < a * a; ++i) {}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175439 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 25b3a24..19582f2 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -503,6 +503,11 @@
CurrentToken = &CurrentToken->Children[0];
else
CurrentToken = NULL;
+
+ // Reset token type in case we have already looked at it and then recovered
+ // from an error (e.g. failure to find the matching >).
+ if (CurrentToken != NULL)
+ CurrentToken->Type = TT_Unknown;
}
/// \brief A struct to hold information valid in a specific context, e.g.
@@ -558,6 +563,9 @@
Previous && (Previous->is(tok::star) || Previous->is(tok::amp));
Previous = Previous->Parent)
Previous->Type = TT_PointerOrReference;
+ } else if (Current.Parent &&
+ Current.Parent->Type == TT_CtorInitializerColon) {
+ Contexts.back().IsExpression = true;
}
if (Current.Type == TT_Unknown) {