C++: Fix FP: bad Location for FieldAccess exprs

This commit is contained in:
Nora Dimitrijević
2022-09-28 20:37:22 +02:00
parent 6d5df14547
commit 96c73bcb19
2 changed files with 20 additions and 6 deletions

View File

@@ -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)."

View File

@@ -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: