Skip to content

Commit 6abd4a6

Browse files
committed
Swift: fix QL libraries
1 parent c578505 commit 6abd4a6

File tree

4 files changed

+70
-62
lines changed

4 files changed

+70
-62
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ private import internal.ControlFlowGraphImpl
66
private import internal.ControlFlowElements
77
private import CfgNodes
88
private import SuccessorTypes
9+
private import codeql.swift.generated.Db
10+
private import codeql.swift.generated.IpaTypes
911

1012
/**
1113
* A basic block, that is, a maximal straight-line sequence of control flow nodes
@@ -195,9 +197,12 @@ class ExitBasicBlock extends BasicBlock {
195197
}
196198

197199
private module JoinBlockPredecessors {
198-
private predicate id(AstNode x, AstNode y) { x = y }
200+
private predicate id(Db::AstNode x, Db::AstNode y) { x = y }
199201

200-
private predicate idOf(AstNode x, int y) = equivalenceRelation(id/2)(x, y)
202+
private predicate idOfDbAstNode(Db::AstNode x, int y) = equivalenceRelation(id/2)(x, y)
203+
204+
// TODO does not work if we use "ipa on" entities...
205+
private predicate idOf(AstNode x, int y) { idOfDbAstNode(Ipa::convertAstNodeToDb(x), y) }
201206

202207
private AstNode projctToAst(ControlFlowElement n) {
203208
result = n.asAstNode()

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
private import swift
3535
private import codeql.swift.controlflow.ControlFlowGraph
36+
private import codeql.swift.generated.IpaTypes
3637
private import Completion
3738
private import Scope
3839
import ControlFlowGraphImplShared
@@ -369,9 +370,9 @@ module Stmts {
369370
* Control-flow for loops.
370371
*/
371372
module Loops {
372-
class ConditionalLoop = @while_stmt or @repeat_while_stmt;
373+
class ConditionalLoop = Ipa::TWhileStmt or Ipa::TRepeatWhileStmt;
373374

374-
class LoopStmt = @for_each_stmt or ConditionalLoop;
375+
class LoopStmt = Ipa::TForEachStmt or ConditionalLoop;
375376

376377
abstract class LoopTree extends AstPreOrderTree {
377378
LoopTree() { ast instanceof ConditionalLoop }
@@ -1668,7 +1669,8 @@ module Exprs {
16681669
}
16691670

16701671
module Conversions {
1671-
class ConversionOrIdentity = @identity_expr or @explicit_cast_expr or @implicit_conversion_expr;
1672+
class ConversionOrIdentity =
1673+
Ipa::TIdentityExpr or Ipa::TExplicitCastExpr or Ipa::TImplicitConversionExpr;
16721674

16731675
abstract class ConversionOrIdentityTree extends AstStandardPostOrderTree {
16741676
ConversionOrIdentityTree() { ast instanceof ConversionOrIdentity }

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
private import swift
22
private import codeql.swift.generated.GetImmediateParent
3+
private import codeql.swift.generated.IpaTypes
34

45
module CallableBase {
5-
class TypeRange = @abstract_function_decl or @key_path_expr or @closure_expr;
6+
class TypeRange = Ipa::TAbstractFunctionDecl or Ipa::TKeyPathExpr or Ipa::TClosureExpr;
67

78
class Range extends Scope::Range, TypeRange { }
89
}

0 commit comments

Comments
 (0)