Skip to content

Commit 3738e19

Browse files
committed
Swift: fix compilation failures outside CFG code
1 parent 0e5255e commit 3738e19

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

swift/ql/lib/codeql/swift/controlflow/BasicBlocks.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
private import swift
44
private import ControlFlowGraph
5-
private import internal.ControlFlowGraphImpl
5+
private import internal.ControlFlowGraphImpl as Impl
66
private import internal.ControlFlowElements
77
private import CfgNodes
88
private import SuccessorTypes
@@ -133,7 +133,7 @@ private module Cached {
133133
private predicate predBB(BasicBlock succ, BasicBlock pred) { succBB(pred, succ) }
134134

135135
/** Holds if `bb` is an exit basic block that represents normal exit. */
136-
private predicate normalExitBB(BasicBlock bb) { bb.getANode().(AnnotatedExitNode).isNormal() }
136+
private predicate normalExitBB(BasicBlock bb) { bb.getANode().(Impl::AnnotatedExitNode).isNormal() }
137137

138138
/** Holds if `dom` is an immediate post-dominator of `bb`. */
139139
cached
@@ -178,7 +178,7 @@ class AnnotatedExitBasicBlock extends BasicBlock {
178178
private boolean normal;
179179

180180
AnnotatedExitBasicBlock() {
181-
exists(AnnotatedExitNode n |
181+
exists(Impl::AnnotatedExitNode n |
182182
n = this.getANode() and
183183
if n.isNormal() then normal = true else normal = false
184184
)

swift/ql/lib/codeql/swift/controlflow/CfgNodes.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
private import swift
44
private import BasicBlocks
55
private import ControlFlowGraph
6-
private import internal.ControlFlowGraphImpl
6+
private import internal.ControlFlowGraphImpl as Impl
77
private import internal.ControlFlowElements
88
private import internal.Splitting
99

@@ -14,7 +14,7 @@ private import internal.Splitting
1414
* (dead) code or not important for control flow, and multiple when there are different
1515
* splits for the AST node.
1616
*/
17-
class CfgNode extends ControlFlowNode instanceof AstCfgNode {
17+
class CfgNode extends ControlFlowNode instanceof Impl::AstCfgNode {
1818
final override ControlFlowElement getNode() { result = this.getAstNode() }
1919

2020
/** Gets a split for this control flow node, if any. */
@@ -142,3 +142,7 @@ class KeyPathApplicationExprCfgNode extends ExprCfgNode {
142142
class KeyPathExprCfgNode extends ExprCfgNode {
143143
override KeyPathExpr e;
144144
}
145+
146+
class EntryNode = Impl::EntryNode;
147+
148+
class ExitNode = Impl::ExitNode;

swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ module Stmts {
240240
private class DiscardStmtTree extends AstStandardPostOrderTree {
241241
override DiscardStmt ast;
242242

243-
final override ControlFlowElement getChildElement(int i) {
243+
final override ControlFlowElement getChildNode(int i) {
244244
i = 0 and result.asAstNode() = ast.getSubExpr().getFullyUnresolved()
245245
}
246246
}
@@ -1429,7 +1429,7 @@ module Exprs {
14291429
private class SingleValueStmtExprTree extends AstStandardPostOrderTree {
14301430
override SingleValueStmtExpr ast;
14311431

1432-
final override ControlFlowElement getChildElement(int i) {
1432+
final override ControlFlowElement getChildNode(int i) {
14331433
i = 0 and result.asAstNode() = ast.getStmt()
14341434
}
14351435
}
@@ -1438,7 +1438,7 @@ module Exprs {
14381438
private class PackExpansionExprTree extends AstStandardPostOrderTree {
14391439
override PackExpansionExpr ast;
14401440

1441-
final override ControlFlowElement getChildElement(int i) {
1441+
final override ControlFlowElement getChildNode(int i) {
14421442
i = 0 and result.asAstNode() = ast.getPatternExpr().getFullyConverted()
14431443
}
14441444
}
@@ -1447,15 +1447,15 @@ module Exprs {
14471447
private class PackElementExprTree extends AstStandardPostOrderTree {
14481448
override PackElementExpr ast;
14491449

1450-
final override ControlFlowElement getChildElement(int i) {
1450+
final override ControlFlowElement getChildNode(int i) {
14511451
i = 0 and result.asAstNode() = ast.getSubExpr().getFullyUnresolved()
14521452
}
14531453
}
14541454

14551455
private class MaterializePackExprTree extends AstStandardPostOrderTree {
14561456
override MaterializePackExpr ast;
14571457

1458-
final override ControlFlowElement getChildElement(int i) {
1458+
final override ControlFlowElement getChildNode(int i) {
14591459
i = 0 and result.asAstNode() = ast.getSubExpr().getFullyUnresolved()
14601460
}
14611461
}
@@ -1464,7 +1464,7 @@ module Exprs {
14641464
private class CopyExprTree extends AstStandardPostOrderTree {
14651465
override CopyExpr ast;
14661466

1467-
final override ControlFlowElement getChildElement(int i) {
1467+
final override ControlFlowElement getChildNode(int i) {
14681468
i = 0 and result.asAstNode() = ast.getSubExpr().getFullyUnresolved()
14691469
}
14701470
}
@@ -1473,7 +1473,7 @@ module Exprs {
14731473
private class ConsumeExprTree extends AstStandardPostOrderTree {
14741474
override ConsumeExpr ast;
14751475

1476-
final override ControlFlowElement getChildElement(int i) {
1476+
final override ControlFlowElement getChildNode(int i) {
14771477
i = 0 and result.asAstNode() = ast.getSubExpr().getFullyUnresolved()
14781478
}
14791479
}

swift/ql/test/library-tests/controlflow/graph/Cfg.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import codeql.swift.controlflow.internal.ControlFlowGraphImpl::TestOutput
99
class MyRelevantNode extends RelevantNode {
1010
MyRelevantNode() { this.getScope().getLocation().getFile().getName().matches("%swift/ql/test%") }
1111

12-
private AstNode asAstNode() { result = this.getNode().asAstNode() }
12+
private AstNode asAstNode() { result = this.getAstNode().asAstNode() }
1313

1414
override string getOrderDisambiguation() {
1515
result = this.asAstNode().getPrimaryQlClasses()

0 commit comments

Comments
 (0)