Skip to content

Commit 4be138d

Browse files
author
Robert Marsh
committed
C++: Improve performance of getExplicitlyConverted
1 parent b7774b2 commit 4be138d

File tree

1 file changed

+13
-6
lines changed
  • cpp/ql/src/semmle/code/cpp/exprs

1 file changed

+13
-6
lines changed

cpp/ql/src/semmle/code/cpp/exprs/Expr.qll

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,19 @@ class Expr extends StmtParent, @expr {
453453
* cast from B to C. Only (1) and (2) would be included.
454454
*/
455455
Expr getExplicitlyConverted() {
456-
// result is this or one of its conversions
457-
result = this.getConversion*() and
458-
// result is not an implicit conversion - it's either the expr or an explicit cast
459-
(result = this or not result.(Cast).isImplicit()) and
460-
// there is no further explicit conversion after result
461-
not exists(Cast other | other = result.getConversion+() and not other.isImplicit())
456+
if this.hasConversion()
457+
then
458+
if this.hasExplicitConversion()
459+
then
460+
result = this.getConversion().getExplicitlyConverted()
461+
else
462+
if this.getImplicitlyConverted().hasExplicitConversion()
463+
then
464+
result = this.getImplicitlyConverted().getConversion().getExplicitlyConverted()
465+
else
466+
result = this
467+
else
468+
result = this
462469
}
463470

464471
/**

0 commit comments

Comments
 (0)