Skip to content

Commit d723645

Browse files
authored
Merge pull request #22557 from aschackmull/cfg/inline-test
CFG: Add a new shared inline CFG test and apply it to unified/swift
2 parents bc141a7 + ef5067a commit d723645

8 files changed

Lines changed: 1692 additions & 3 deletions

File tree

shared/controlflow/codeql/controlflow/ControlFlowGraph.qll

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,13 +2208,21 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
22082208
}
22092209
}
22102210

2211-
module Cfg = BB::Make<Location, BbInput>;
2211+
private module Cfg_ = BB::Make<Location, BbInput>;
22122212

2213-
private module CfgAlias = Cfg;
2213+
module Cfg implements BB::CfgSig<Location>, TestCfg::CfgSig<Location> {
2214+
import Cfg_
22142215

2215-
import CfgAlias
2216+
class AstNode = Ast::AstNode;
2217+
2218+
class Callable = Ast::Callable;
2219+
}
2220+
2221+
import Cfg_
22162222
}
22172223

2224+
private import test.TestCfg as TestCfg
2225+
22182226
private module Additional {
22192227
/*
22202228
* CFG printing
@@ -2236,6 +2244,18 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
22362244

22372245
import Pp::PrintGraph<Location, PrintGraphInput>
22382246

2247+
/*
2248+
* CFG testing
2249+
*/
2250+
2251+
private module TestInput implements TestCfg::InputSig<AstNode, Callable> {
2252+
AstNode getParent(AstNode node) { node = getChild(result, _) }
2253+
2254+
predicate getEnclosingCallable = Ast::getEnclosingCallable/1;
2255+
}
2256+
2257+
module TestCfgInline = TestCfg::Make<Location, Cfg, TestInput>;
2258+
22392259
/** Provides a set of consistency queries. */
22402260
module Consistency {
22412261
/** Holds if the consistency query `query` has `results` results. */

0 commit comments

Comments
 (0)