C++: Fix "LHS-end = RHS-begin" FP

This commit is contained in:
Nora Dimitrijević
2022-09-28 15:36:01 +02:00
parent e7c1fadd94
commit 0128b1702e
2 changed files with 6 additions and 5 deletions

View File

@@ -20,13 +20,14 @@ Expr normalizeExpr(Expr e) {
else result = e
}
from CommaExpr ce, Expr left, Expr right, int leftStartColumn, int rightStartColumn
from CommaExpr ce, Expr left, Expr right, Location leftLoc, Location rightLoc
where
ce.fromSource() and
not isFromMacroDefinition(ce) and
left = normalizeExpr(ce.getLeftOperand()) and
right = normalizeExpr(ce.getRightOperand()) and
leftStartColumn = left.getLocation().getStartColumn() and
rightStartColumn = right.getLocation().getStartColumn() and
leftStartColumn > rightStartColumn
leftLoc = left.getLocation() and
rightLoc = right.getLocation() and
leftLoc.getEndLine() < rightLoc.getStartLine() and
leftLoc.getStartColumn() > rightLoc.getStartColumn()
select right, "The indentation level after the comma can be misleading (for some tab sizes)."

View File

@@ -113,7 +113,7 @@ int test(int i, int j, int (*foo)(int), int (*bar)(int, int))
int k = (foo(
i++
), j++); // GOOD? [FALSE POSITIVE]
), j++); // GOOD?
// Weird case: