mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
C++: Fix FP: bad Location for FieldAccess exprs
This commit is contained in:
@@ -16,9 +16,12 @@ Expr normalizeExpr(Expr e) {
|
||||
if exists(e.(Call).getQualifier())
|
||||
then result = normalizeExpr(e.(Call).getQualifier())
|
||||
else
|
||||
if e.hasExplicitConversion()
|
||||
then result = normalizeExpr(e.getFullyConverted())
|
||||
else result = e
|
||||
if exists(e.(FieldAccess).getQualifier())
|
||||
then result = normalizeExpr(e.(FieldAccess).getQualifier())
|
||||
else
|
||||
if e.hasExplicitConversion()
|
||||
then result = normalizeExpr(e.getFullyConverted())
|
||||
else result = e
|
||||
}
|
||||
|
||||
predicate isInLoopHead(CommaExpr ce) {
|
||||
@@ -45,4 +48,4 @@ where
|
||||
not isInDecltypeOrSizeof(ce) and // <- Removes arguable FPs since, like function calls (and loop heads), these Exprs have clear delimiters.
|
||||
leftLoc.getEndLine() < rightLoc.getStartLine() and
|
||||
leftLoc.getStartColumn() > rightLoc.getStartColumn()
|
||||
select right, "The indentation after the comma may be misleading (for some tab sizes)."
|
||||
select right, "The indentation level may be misleading (for some tab sizes)."
|
||||
|
||||
@@ -122,7 +122,7 @@ int test(int i, int j, int (*foo)(int), int (*bar)(int, int))
|
||||
i++
|
||||
), j++); // GOOD?
|
||||
|
||||
// Weird case:
|
||||
// Weird cases:
|
||||
|
||||
if (foo(j))
|
||||
return i++
|
||||
@@ -130,7 +130,18 @@ int test(int i, int j, int (*foo)(int), int (*bar)(int, int))
|
||||
? 1
|
||||
: 2;
|
||||
|
||||
return 0;
|
||||
struct {
|
||||
struct {
|
||||
void tutu() {}
|
||||
long toto() { return 42; }
|
||||
} titi;
|
||||
} *tata;
|
||||
|
||||
int quux =
|
||||
(tata->titi.tutu(),
|
||||
foo(tata->titi.toto())); // GOOD
|
||||
|
||||
return quux;
|
||||
}
|
||||
|
||||
// Comma in variadic template splice:
|
||||
|
||||
Reference in New Issue
Block a user