@@ -483,6 +483,8 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
483483 * by subsequent instatiation of `Make2`.
484484 */
485485 module Make1< InputSig1 Input1> {
486+ private import codeql.util.DenseRank
487+
486488 /**
487489 * Holds if `n` is executed in post-order or in-order. This means that an
488490 * additional node is created to represent `n` in the control flow graph.
@@ -687,15 +689,20 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
687689 n = callableGetBody ( c ) or n = Input1:: callableGetBodyPart ( c , _, _)
688690 }
689691
690- private AstNode getRankedBodyPart ( Callable c , Input1:: CallableBodyPartContext ctx , int rnk ) {
691- result =
692- rank [ rnk ] ( AstNode child , int ix |
693- child = Input1:: callableGetBodyPart ( c , ctx , ix )
694- |
695- child order by ix
696- )
692+ private module BodyPartDenseRankInput implements DenseRankInputSig2 {
693+ class C1 = Callable ;
694+
695+ class C2 = Input1:: CallableBodyPartContext ;
696+
697+ class Ranked = AstNode ;
698+
699+ int getRank ( C1 c , C2 ctx , Ranked child ) {
700+ child = Input1:: callableGetBodyPart ( c , ctx , result )
701+ }
697702 }
698703
704+ private predicate getRankedBodyPart = DenseRank2< BodyPartDenseRankInput > :: denseRank / 3 ;
705+
699706 private AstNode getBodyEntry ( Callable c ) {
700707 result = callableGetBody ( c ) and
701708 not exists ( getRankedBodyPart ( c , _, _) )
@@ -1247,10 +1254,16 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
12471254 )
12481255 }
12491256
1250- private Case getRankedCaseCfgOrder ( Switch s , int rnk ) {
1251- result = rank [ rnk ] ( Case c , int i | getCaseControlFlowOrder ( s , c ) = i | c order by i )
1257+ private module CaseDenseRankInput implements DenseRankInputSig1 {
1258+ class C = Switch ;
1259+
1260+ class Ranked = Case ;
1261+
1262+ predicate getRank = getCaseControlFlowOrder / 2 ;
12521263 }
12531264
1265+ private predicate getRankedCaseCfgOrder = DenseRank1< CaseDenseRankInput > :: denseRank / 2 ;
1266+
12541267 private int numberOfStmts ( Switch s ) { result = strictcount ( s .getStmt ( _) ) }
12551268
12561269 private predicate caseIndex ( Switch s , Case c , int caseIdx , int caseStmtPos ) {
@@ -1685,11 +1698,19 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
16851698 not explicitStep ( any ( PreControlFlowNode n | n .isBefore ( ast ) ) , _)
16861699 }
16871700
1688- private AstNode getRankedChild ( AstNode parent , int rnk ) {
1689- defaultCfg ( parent ) and
1690- result = rank [ rnk ] ( AstNode c , int ix | c = getChild ( parent , ix ) | c order by ix )
1701+ private module ChildDenseRankInput implements DenseRankInputSig1 {
1702+ class C = AstNode ;
1703+
1704+ class Ranked = AstNode ;
1705+
1706+ int getRank ( C parent , Ranked child ) {
1707+ defaultCfg ( parent ) and
1708+ child = getChild ( parent , result )
1709+ }
16911710 }
16921711
1712+ private predicate getRankedChild = DenseRank1< ChildDenseRankInput > :: denseRank / 2 ;
1713+
16931714 /**
16941715 * Holds if `n1` to `n2` is a default left-to-right evaluation step for
16951716 * an `AstNode` that does not otherwise have explicitly defined control
0 commit comments