mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
C++: Exclude commas in if-conditions.
This commit is contained in:
@@ -42,6 +42,8 @@ predicate isParenthesized(CommaExpr ce) {
|
||||
isInDecltypeOrSizeof(ce)
|
||||
or
|
||||
ce.getParent*().(Expr).isParenthesised()
|
||||
or
|
||||
ce.getParent*() = any(IfStmt i).getCondition()
|
||||
}
|
||||
|
||||
from CommaExpr ce, Expr left, Expr right, Location leftLoc, Location rightLoc
|
||||
|
||||
@@ -137,6 +137,12 @@ int Foo::test(int (*baz)(int))
|
||||
j = 1; i < 10; i += 2, // GOOD? Currently ignoring loop heads.
|
||||
j++) {}
|
||||
|
||||
// Comma in if-conditions:
|
||||
|
||||
if (i = foo(j++),
|
||||
i == j) // GOOD(?) -- Currently ignoring if-conditions for the same reason as other parenthesized commas.
|
||||
i = 0;
|
||||
|
||||
// Mixed tabs and spaces (ugly case):
|
||||
|
||||
for (i = 0, // GOOD if tab >= 4 spaces else BAD -- Currently ignoring loop heads.
|
||||
|
||||
Reference in New Issue
Block a user