You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[clang-tidy] fix false-negative for macros in readability-math-missing-parentheses (llvm#90279)
When a binary operator is the last operand of a macro, the end location
that is past the `BinaryOperator` will be inside the macro and therefore
an
invalid location to insert a `FixIt` into, which is why the check bails
when encountering such a pattern.
However, the end location is only required for the `FixIt` and the
diagnostic can still be emitted, just without an attached fix.
Copy file name to clipboardExpand all lines: clang-tools-extra/test/clang-tidy/checkers/readability/math-missing-parentheses.cpp
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,13 @@ int bar(){
16
16
return4;
17
17
}
18
18
19
+
intsink(int);
20
+
#defineFUN(ARG) (sink(ARG))
21
+
#defineFUN2(ARG) sink((ARG))
22
+
#defineFUN3(ARG) sink(ARG)
23
+
#defineFUN4(ARG) sink(1 + ARG)
24
+
#defineFUN5(ARG) sink(4 * ARG)
25
+
19
26
classfun{
20
27
public:
21
28
int A;
@@ -117,4 +124,19 @@ void f(){
117
124
//CHECK-MESSAGES: :[[@LINE+2]]:94: warning: '/' has higher precedence than '-'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses]
//CHECK-MESSAGES: :[[@LINE+1]]:21: warning: '*' has higher precedence than '+'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses]
129
+
int r = FUN(0 + 1 * 2);
130
+
131
+
//CHECK-MESSAGES: :[[@LINE+1]]:22: warning: '*' has higher precedence than '+'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses]
132
+
int s = FUN2(0 + 1 * 2);
133
+
134
+
//CHECK-MESSAGES: :[[@LINE+1]]:22: warning: '*' has higher precedence than '+'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses]
135
+
int t = FUN3(0 + 1 * 2);
136
+
137
+
//CHECK-MESSAGES: :[[@LINE+1]]:18: warning: '*' has higher precedence than '+'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses]
138
+
int u = FUN4(1 * 2);
139
+
140
+
//CHECK-MESSAGES: :[[@LINE+1]]:13: warning: '*' has higher precedence than '+'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses]
0 commit comments