diff --git a/cpp/ql/src/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation.ql b/cpp/ql/src/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation.ql index 8f1d994ec62..a54adc49cfe 100644 --- a/cpp/ql/src/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation.ql +++ b/cpp/ql/src/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation.ql @@ -13,10 +13,10 @@ import semmle.code.cpp.commons.Exclusions /** Gets the sub-expression of 'e' with the earliest-starting Location */ Expr normalizeExpr(Expr e) { - if forex(Expr q | q = e.(Call).getQualifier() | not q instanceof ThisExpr) + if forex(Expr q | q = e.(Call).getQualifier() | not q.(ThisExpr).isCompilerGenerated()) then result = normalizeExpr(e.(Call).getQualifier()) else - if forex(Expr q | q = e.(FieldAccess).getQualifier() | not q instanceof ThisExpr) + if forex(Expr q | q = e.(FieldAccess).getQualifier() | not q.(ThisExpr).isCompilerGenerated()) then result = normalizeExpr(e.(FieldAccess).getQualifier()) else if e.hasExplicitConversion() 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 b508d2e878e..e242bc23bbf 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 @@ -40,6 +40,10 @@ int Foo::test(int (*baz)(int)) (void)i, // GOOD (void)j; + if (i) + this->foo(i), // GOOD + foo(i); + if (i) (void)i, // BAD (void)j;