@@ -601,7 +601,9 @@ module API {
601
601
/** A use of an API member at the node `nd`. */
602
602
MkUse ( DataFlow:: Node nd ) { isUse ( nd ) } or
603
603
/** A value that escapes into an external library at the node `nd` */
604
- MkDef ( DataFlow:: Node nd ) { isDef ( nd ) }
604
+ MkDef ( DataFlow:: Node nd ) { isDef ( nd ) } or
605
+ /** A module object seen as a use node. */
606
+ MkModuleObject ( DataFlow:: ModuleNode mod )
605
607
606
608
private string resolveTopLevel ( ConstantReadAccess read ) {
607
609
result = read .getModule ( ) .getQualifiedName ( ) and
@@ -684,7 +686,14 @@ module API {
684
686
* Holds if `ref` is a use of node `nd`.
685
687
*/
686
688
cached
687
- predicate use ( TApiNode nd , DataFlow:: Node ref ) { nd = MkUse ( ref ) }
689
+ predicate use ( TApiNode nd , DataFlow:: Node ref ) {
690
+ nd = MkUse ( ref )
691
+ or
692
+ exists ( DataFlow:: ModuleNode mod |
693
+ nd = MkModuleObject ( mod ) and
694
+ ref = mod .getAnImmediateReference ( )
695
+ )
696
+ }
688
697
689
698
/**
690
699
* Holds if `rhs` is a RHS of node `nd`.
@@ -802,6 +811,14 @@ module API {
802
811
trackUseNode ( use ) .flowsTo ( call .getReceiver ( ) )
803
812
}
804
813
814
+ /**
815
+ * Holds if `superclass` is the superclass of `mod`.
816
+ */
817
+ pragma [ nomagic]
818
+ private predicate superclassNode ( DataFlow:: ModuleNode mod , DataFlow:: Node superclass ) {
819
+ superclass .asExpr ( ) .getExpr ( ) = mod .getADeclaration ( ) .( ClassDeclaration ) .getSuperclassExpr ( )
820
+ }
821
+
805
822
/**
806
823
* Holds if there is an edge from `pred` to `succ` in the API graph that is labeled with `lbl`.
807
824
*/
@@ -830,14 +847,11 @@ module API {
830
847
defStep ( lbl , trackDefNode ( predNode ) , succNode )
831
848
)
832
849
or
833
- // `pred` is a use of class A
834
- // `succ` is a use of class B
835
- // there exists a class declaration B < A
836
- exists ( ClassDeclaration c , DataFlow:: Node a , DataFlow:: Node b |
837
- use ( pred , a ) and
838
- use ( succ , b ) and
839
- b .asExpr ( ) .getExpr ( ) .( ConstantReadAccess ) .getAQualifiedName ( ) = c .getAQualifiedName ( ) and
840
- pragma [ only_bind_into ] ( c ) .getSuperclassExpr ( ) = a .asExpr ( ) .getExpr ( ) and
850
+ exists ( DataFlow:: Node predNode , DataFlow:: Node superclassNode , DataFlow:: ModuleNode mod |
851
+ use ( pred , predNode ) and
852
+ trackUseNode ( predNode ) .flowsTo ( superclassNode ) and
853
+ superclassNode ( mod , superclassNode ) and
854
+ succ = MkModuleObject ( mod ) and
841
855
lbl = Label:: subclass ( )
842
856
)
843
857
or
0 commit comments