mirror of
https://github.com/intel/llvm.git
synced 2026-02-05 04:46:27 +08:00
clang-format: Fix incorrect &&-detection in macros.
Before: #define A(a, b) (a &&b) After: #define A(a, b) (a && b) This fixes llvm.org/PR19343. llvm-svn: 206165
This commit is contained in:
@@ -110,6 +110,9 @@ private:
|
||||
Left->Previous->Type == TT_BinaryOperator)) {
|
||||
// static_assert, if and while usually contain expressions.
|
||||
Contexts.back().IsExpression = true;
|
||||
} else if (Line.InPPDirective &&
|
||||
(!Left->Previous || Left->Previous->isNot(tok::identifier))) {
|
||||
Contexts.back().IsExpression = true;
|
||||
} else if (Left->Previous && Left->Previous->is(tok::r_square) &&
|
||||
Left->Previous->MatchingParen &&
|
||||
Left->Previous->MatchingParen->Type == TT_LambdaLSquare) {
|
||||
|
||||
@@ -4647,6 +4647,7 @@ TEST_F(FormatTest, UnderstandsRvalueReferences) {
|
||||
"};");
|
||||
verifyGoogleFormat("#define IF(a, b, c) if (a && (b == c))");
|
||||
verifyGoogleFormat("#define WHILE(a, b, c) while (a && (b == c))");
|
||||
verifyFormat("#define A(a, b) (a && b)");
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, FormatsBinaryOperatorsPrecedingEquals) {
|
||||
|
||||
Reference in New Issue
Block a user