Skip to content

Commit 2b909fb

Browse files
committed
A5-2-6: Avoid reporting cases with the same operator
1 parent 2a805c0 commit 2b909fb

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A5-2-6` - `OperandsOfAlogicalAndOrNotParenthesized.ql`:
2+
- Remove false positives where the operator is identical.

cpp/autosar/src/rules/A5-2-6/OperandsOfALogicalAndOrNotParenthesized.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ from BinaryLogicalOperation op, BinaryOperation binop
2121
where
2222
not isExcluded(op, OrderOfEvaluationPackage::operandsOfALogicalAndOrNotParenthesizedQuery()) and
2323
op.getAnOperand() = binop and
24+
// Ignore cases with the same operator
25+
not op.getOperator() = binop.getOperator() and
2426
not exists(ParenthesisExpr p | p = binop.getFullyConverted()) and
2527
// Exclude binary operations expanded by a macro.
2628
not binop.isInMacroExpansion()

cpp/autosar/test/rules/A5-2-6/test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ void f2(int p1, int p2) {
2525
f1();
2626
}
2727

28+
(p1 > 0) && (p2 > 0) && (p1 > p2); // COMPLIANT - no ambiguity
29+
2830
Sample *sample_ptr = &sample;
2931

3032
if ((p1 > 0) || sample_ptr->x) { // COMPLIANT: struct member accessors with

0 commit comments

Comments
 (0)