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.
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) {
TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
verifyFormat("int *f(int *a) {}");
verifyFormat("int main(int argc, char **argv) {}");
+ verifyFormat("Test::Test(int b) : a(b * b) {}");
verifyIndependentOfContext("f(a, *a);");
verifyIndependentOfContext("f(*a);");
verifyIndependentOfContext("int a = b * 10;");
" for (const int &v : Values) {\n"
" }\n"
"}");
+ verifyFormat("for (int i = a * a; i < 10; ++i) {\n}");
+ verifyFormat("for (int i = 0; i < a * a; ++i) {\n}");
verifyIndependentOfContext("A = new SomeType *[Length]();");
verifyGoogleFormat("A = new SomeType* [Length]();");