forked from OSchip/llvm-project
clang-format: Improve expression heuristics.
Upon encountering a binary operator inside parentheses, assume that the parentheses contain an expression. Before: MACRO('0' <= c&& c <= '9'); After: MACRO('0' <= c && c <= '9'); llvm-svn: 212040
This commit is contained in:
parent
ae82987cf8
commit
91beebd04a
|
@ -164,6 +164,8 @@ private:
|
||||||
CurrentToken->Previous->Previous->isOneOf(tok::l_paren,
|
CurrentToken->Previous->Previous->isOneOf(tok::l_paren,
|
||||||
tok::coloncolon))
|
tok::coloncolon))
|
||||||
MightBeFunctionType = true;
|
MightBeFunctionType = true;
|
||||||
|
if (CurrentToken->Previous->Type == TT_BinaryOperator)
|
||||||
|
Contexts.back().IsExpression = true;
|
||||||
if (CurrentToken->is(tok::r_paren)) {
|
if (CurrentToken->is(tok::r_paren)) {
|
||||||
if (MightBeFunctionType && CurrentToken->Next &&
|
if (MightBeFunctionType && CurrentToken->Next &&
|
||||||
(CurrentToken->Next->is(tok::l_paren) ||
|
(CurrentToken->Next->is(tok::l_paren) ||
|
||||||
|
|
|
@ -4841,6 +4841,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
|
||||||
verifyIndependentOfContext("MACRO(int *i);");
|
verifyIndependentOfContext("MACRO(int *i);");
|
||||||
verifyIndependentOfContext("MACRO(auto *a);");
|
verifyIndependentOfContext("MACRO(auto *a);");
|
||||||
verifyIndependentOfContext("MACRO(const A *a);");
|
verifyIndependentOfContext("MACRO(const A *a);");
|
||||||
|
verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
|
||||||
// FIXME: Is there a way to make this work?
|
// FIXME: Is there a way to make this work?
|
||||||
// verifyIndependentOfContext("MACRO(A *a);");
|
// verifyIndependentOfContext("MACRO(A *a);");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue