diff --git a/cpp/ql/src/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation.ql b/cpp/ql/src/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation.ql index 900b08994c7..a786f4aec33 100644 --- a/cpp/ql/src/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation.ql +++ b/cpp/ql/src/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation.ql @@ -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)." diff --git a/cpp/ql/test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation/test.cpp b/cpp/ql/test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation/test.cpp index 8aae39668f6..642161f6549 100644 --- a/cpp/ql/test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation/test.cpp +++ b/cpp/ql/test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation/test.cpp @@ -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: