File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed
cpp/ql/src/semmle/code/cpp/exprs Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -453,19 +453,16 @@ class Expr extends StmtParent, @expr {
453453 * cast from B to C. Only (1) and (2) would be included.
454454 */
455455 Expr getExplicitlyConverted ( ) {
456- if this .hasConversion ( )
456+ // For performance, we avoid a full transitive closure over `getConversion`.
457+ // Since there can be several implicit conversions before and after an
458+ // explicit conversion, use `getImplicitlyConverted` to step over them
459+ // cheaply. Then, if there is an explicit conversion following the implict
460+ // conversion sequence, recurse to handle multiple explicit conversions.
461+ if this .getImplicitlyConverted ( ) .hasExplicitConversion ( )
457462 then
458- if this .hasExplicitConversion ( )
459- then
460- result = this .getConversion ( ) .getExplicitlyConverted ( )
463+ result = this .getImplicitlyConverted ( ) .getConversion ( ) .getExplicitlyConverted ( )
461464 else
462- if this .getImplicitlyConverted ( ) .hasExplicitConversion ( )
463- then
464- result = this .getImplicitlyConverted ( ) .getConversion ( ) .getExplicitlyConverted ( )
465- else
466- result = this
467- else
468- result = this
465+ result = this
469466 }
470467
471468 /**
You can’t perform that action at this time.
0 commit comments