@@ -163,7 +163,7 @@ class IntegralConversion extends ArithmeticConversion {
163163 isIntegralOrEnum ( getExpr ( ) .getUnspecifiedType ( ) )
164164 }
165165
166- override string getCanonicalQLClass ( ) { result = "IntegralConversion" }
166+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "IntegralConversion" }
167167
168168 override string getSemanticConversionString ( ) {
169169 result = "integral conversion"
@@ -179,7 +179,7 @@ class FloatingPointConversion extends ArithmeticConversion {
179179 getExpr ( ) .getUnspecifiedType ( ) instanceof FloatingPointType
180180 }
181181
182- override string getCanonicalQLClass ( ) { result = "FloatingPointConversion" }
182+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "FloatingPointConversion" }
183183
184184 override string getSemanticConversionString ( ) {
185185 result = "floating point conversion"
@@ -195,7 +195,7 @@ class FloatingPointToIntegralConversion extends ArithmeticConversion {
195195 getExpr ( ) .getUnspecifiedType ( ) instanceof FloatingPointType
196196 }
197197
198- override string getCanonicalQLClass ( ) { result = "FloatingPointToIntegralConversion" }
198+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "FloatingPointToIntegralConversion" }
199199
200200 override string getSemanticConversionString ( ) {
201201 result = "floating point to integral conversion"
@@ -211,7 +211,7 @@ class IntegralToFloatingPointConversion extends ArithmeticConversion {
211211 isIntegralOrEnum ( getExpr ( ) .getUnspecifiedType ( ) )
212212 }
213213
214- override string getCanonicalQLClass ( ) { result = "IntegralToFloatingPointConversion" }
214+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "IntegralToFloatingPointConversion" }
215215
216216 override string getSemanticConversionString ( ) {
217217 result = "integral to floating point conversion"
@@ -231,7 +231,7 @@ class PointerConversion extends Cast {
231231 isPointerOrNullPointer ( getExpr ( ) .getUnspecifiedType ( ) )
232232 }
233233
234- override string getCanonicalQLClass ( ) { result = "PointerConversion" }
234+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "PointerConversion" }
235235
236236 override string getSemanticConversionString ( ) {
237237 result = "pointer conversion"
@@ -261,7 +261,7 @@ class PointerToMemberConversion extends Cast {
261261 )
262262 }
263263
264- override string getCanonicalQLClass ( ) { result = "PointerToMemberConversion" }
264+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "PointerToMemberConversion" }
265265
266266 override string getSemanticConversionString ( ) {
267267 result = "pointer-to-member conversion"
@@ -278,7 +278,7 @@ class PointerToIntegralConversion extends Cast {
278278 isPointerOrNullPointer ( getExpr ( ) .getUnspecifiedType ( ) )
279279 }
280280
281- override string getCanonicalQLClass ( ) { result = "PointerToIntegralConversion" }
281+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "PointerToIntegralConversion" }
282282
283283 override string getSemanticConversionString ( ) {
284284 result = "pointer to integral conversion"
@@ -295,7 +295,7 @@ class IntegralToPointerConversion extends Cast {
295295 isIntegralOrEnum ( getExpr ( ) .getUnspecifiedType ( ) )
296296 }
297297
298- override string getCanonicalQLClass ( ) { result = "IntegralToPointerConversion" }
298+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "IntegralToPointerConversion" }
299299
300300 override string getSemanticConversionString ( ) {
301301 result = "integral to pointer conversion"
@@ -311,7 +311,7 @@ class BoolConversion extends Cast {
311311 conversionkinds ( underlyingElement ( this ) , 1 )
312312 }
313313
314- override string getCanonicalQLClass ( ) { result = "BoolConversion" }
314+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "BoolConversion" }
315315
316316 override string getSemanticConversionString ( ) {
317317 result = "conversion to bool"
@@ -327,7 +327,7 @@ class VoidConversion extends Cast {
327327 getUnspecifiedType ( ) instanceof VoidType
328328 }
329329
330- override string getCanonicalQLClass ( ) { result = "VoidConversion" }
330+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "VoidConversion" }
331331
332332 override string getSemanticConversionString ( ) {
333333 result = "conversion to void"
@@ -398,7 +398,7 @@ class BaseClassConversion extends InheritanceConversion {
398398 conversionkinds ( underlyingElement ( this ) , 2 )
399399 }
400400
401- override string getCanonicalQLClass ( ) { result = "BaseClassConversion" }
401+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "BaseClassConversion" }
402402
403403 override string getSemanticConversionString ( ) {
404404 result = "base class conversion"
@@ -429,7 +429,7 @@ class DerivedClassConversion extends InheritanceConversion {
429429 conversionkinds ( underlyingElement ( this ) , 3 )
430430 }
431431
432- override string getCanonicalQLClass ( ) { result = "DerivedClassConversion" }
432+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "DerivedClassConversion" }
433433
434434 override string getSemanticConversionString ( ) {
435435 result = "derived class conversion"
@@ -453,7 +453,7 @@ class PointerToMemberBaseClassConversion extends Cast {
453453 conversionkinds ( underlyingElement ( this ) , 4 )
454454 }
455455
456- override string getCanonicalQLClass ( ) { result = "PointerToMemberBaseClassConversion" }
456+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "PointerToMemberBaseClassConversion" }
457457
458458 override string getSemanticConversionString ( ) {
459459 result = "pointer-to-member base class conversion"
@@ -469,7 +469,7 @@ class PointerToMemberDerivedClassConversion extends Cast {
469469 conversionkinds ( underlyingElement ( this ) , 5 )
470470 }
471471
472- override string getCanonicalQLClass ( ) { result = "PointerToMemberDerivedClassConversion" }
472+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "PointerToMemberDerivedClassConversion" }
473473
474474 override string getSemanticConversionString ( ) {
475475 result = "pointer-to-member derived class conversion"
@@ -486,7 +486,7 @@ class GlvalueConversion extends Cast {
486486 conversionkinds ( underlyingElement ( this ) , 6 )
487487 }
488488
489- override string getCanonicalQLClass ( ) { result = "GlvalueConversion" }
489+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "GlvalueConversion" }
490490
491491 override string getSemanticConversionString ( ) {
492492 result = "glvalue conversion"
@@ -512,7 +512,7 @@ class PrvalueAdjustmentConversion extends Cast {
512512 conversionkinds ( underlyingElement ( this ) , 7 )
513513 }
514514
515- override string getCanonicalQLClass ( ) { result = "PrvalueAdjustmentConversion" }
515+ override string getCanonicalQLClass ( ) { not exists ( qlCast ( this ) ) and result = "PrvalueAdjustmentConversion" }
516516
517517 override string getSemanticConversionString ( ) {
518518 result = "prvalue adjustment conversion"
@@ -741,3 +741,40 @@ class ArrayToPointerConversion extends Conversion, @array_to_pointer {
741741 none ( )
742742 }
743743}
744+
745+ /**
746+ * A node representing the Cast sub-class of entity `cast`.
747+ */
748+ string qlCast ( Cast cast ) {
749+ // NB: Take care and include only leaf QL classes
750+ cast instanceof CStyleCast and result = "CStyleCast" or
751+ cast instanceof StaticCast and result = "StaticCast" or
752+ cast instanceof DynamicCast and result = "DynamicCast" or
753+ cast instanceof ConstCast and result = "ConstCast" or
754+ cast instanceof ReinterpretCast and result = "ReinterpretCast"
755+ }
756+
757+ /**
758+ * A node representing the Conversion sub-class of entity `cast`.
759+ */
760+ string qlConversion ( Cast cast ) {
761+ // NB: Take care and include only leaf QL classes
762+ cast instanceof IntegralConversion and result = "IntegralConversion" or
763+ cast instanceof FloatingPointConversion and result = "FloatingPointConversion" or
764+ cast instanceof FloatingPointToIntegralConversion and result = "FloatingPointToIntegralConversion" or
765+ cast instanceof IntegralToFloatingPointConversion and result = "IntegralToFloatingPointConversion" or
766+ cast instanceof PointerConversion and result = "PointerConversion" or
767+ cast instanceof PointerToMemberConversion and result = "PointerToMemberConversion" or
768+ cast instanceof PointerToIntegralConversion and result = "PointerToIntegralConversion" or
769+ cast instanceof IntegralToPointerConversion and result = "IntegralToPointerConversion" or
770+ cast instanceof BoolConversion and result = "BoolConversion" or
771+ cast instanceof VoidConversion and result = "VoidConversion" or
772+ cast instanceof BaseClassConversion and result = "BaseClassConversion" or
773+ cast instanceof DerivedClassConversion and result = "DerivedClassConversion" or
774+ cast instanceof PointerToMemberBaseClassConversion and result = "PointerToMemberBaseClassConversion" or
775+ cast instanceof PointerToMemberDerivedClassConversion and result = "PointerToMemberDerivedClassConversion" or
776+ cast instanceof GlvalueConversion and result = "GlvalueConversion" or
777+ cast instanceof PrvalueAdjustmentConversion and result = "PrvalueAdjustmentConversion" or
778+ // treat dynamic_cast<...>(...) as a conversion
779+ cast instanceof DynamicCast and result = "DynamicCast"
780+ }
0 commit comments