diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 0760f35bbbc287c95ecc77fb6e856d02b88bd53f..c1fbf81e1199be1fe3ae2ba5fea9ade24acddd91 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -164,6 +164,8 @@ private: CurrentToken->Previous->Previous->isOneOf(tok::l_paren, tok::coloncolon)) MightBeFunctionType = true; + if (CurrentToken->Previous->Type == TT_BinaryOperator) + Contexts.back().IsExpression = true; if (CurrentToken->is(tok::r_paren)) { if (MightBeFunctionType && CurrentToken->Next && (CurrentToken->Next->is(tok::l_paren) || diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 11a42a51faffb5cdaa72e2a6ca6038c982947efd..75eea9827530114167ac12ae368eb7c611fcaf31 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4841,6 +4841,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyIndependentOfContext("MACRO(int *i);"); verifyIndependentOfContext("MACRO(auto *a);"); verifyIndependentOfContext("MACRO(const A *a);"); + verifyIndependentOfContext("MACRO('0' <= c && c <= '9');"); // FIXME: Is there a way to make this work? // verifyIndependentOfContext("MACRO(A *a);");