Skip to content

Commit 0128b17

Browse files
committed
C++: Fix "LHS-end = RHS-begin" FP
1 parent e7c1fad commit 0128b17

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

cpp/ql/src/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation.ql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ Expr normalizeExpr(Expr e) {
2020
else result = e
2121
}
2222

23-
from CommaExpr ce, Expr left, Expr right, int leftStartColumn, int rightStartColumn
23+
from CommaExpr ce, Expr left, Expr right, Location leftLoc, Location rightLoc
2424
where
2525
ce.fromSource() and
2626
not isFromMacroDefinition(ce) and
2727
left = normalizeExpr(ce.getLeftOperand()) and
2828
right = normalizeExpr(ce.getRightOperand()) and
29-
leftStartColumn = left.getLocation().getStartColumn() and
30-
rightStartColumn = right.getLocation().getStartColumn() and
31-
leftStartColumn > rightStartColumn
29+
leftLoc = left.getLocation() and
30+
rightLoc = right.getLocation() and
31+
leftLoc.getEndLine() < rightLoc.getStartLine() and
32+
leftLoc.getStartColumn() > rightLoc.getStartColumn()
3233
select right, "The indentation level after the comma can be misleading (for some tab sizes)."

cpp/ql/test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int test(int i, int j, int (*foo)(int), int (*bar)(int, int))
113113

114114
int k = (foo(
115115
i++
116-
), j++); // GOOD? [FALSE POSITIVE]
116+
), j++); // GOOD?
117117

118118
// Weird case:
119119

0 commit comments

Comments
 (0)