Skip to content

Commit a78dd7a

Browse files
committed
Generalize exclusion to macro expanded code
1 parent e49c8b9 commit a78dd7a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cpp/autosar/src/rules/M5-0-2/InsufficientUseOfParentheses.ql

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import semmle.code.cpp.commons.Assertions
2020

2121
class InsufficientlyParenthesizedExpr extends Expr {
2222
InsufficientlyParenthesizedExpr() {
23-
// Exclude assertions because if the child is the expression being asserted it
24-
// is not necessary to add parenthesis.
25-
not any(Assertion a).getAsserted() = this and
23+
// Exclude expressions affected by macros, including assertions, because
24+
// it is unclear that the expression must be parenthesized since it seems
25+
// to be the top-level expression instead of an operand of a binary or ternary operation.
26+
not this.isAffectedByMacro() and
2627
(
2728
exists(BinaryOperation root, BinaryOperation child | child = this |
2829
root.getAnOperand() = child and

0 commit comments

Comments
 (0)