Skip to content

Commit 83caf01

Browse files
authored
Merge pull request github#11096 from atorralba/atorralba/swift/unit
Swift: Move the Unit class to its own file
2 parents 44b0f19 + 978ed03 commit 83caf01

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

swift/ql/lib/codeql/swift/Unit.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** Provides the `Unit` class. */
2+
3+
/** The unit type. */
4+
private newtype TUnit = TMkUnit()
5+
6+
/** The trivial type with a single element. */
7+
class Unit extends TUnit {
8+
/** Gets a textual representation of this element. */
9+
string toString() { result = "unit" }
10+
}

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImplSpecific.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
/**
22
* Provides Swift-specific definitions for use in the data flow library.
33
*/
4+
5+
// we need to export `Unit` for the DataFlowImpl* files
6+
private import swift as Swift
7+
48
module Private {
59
import DataFlowPrivate
610
import DataFlowDispatch
11+
12+
class Unit = Swift::Unit;
713
}
814

915
module Public {

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,15 +603,6 @@ int accessPathLimit() { result = 5 }
603603
*/
604604
predicate forceHighPrecision(Content c) { none() }
605605

606-
/** The unit type. */
607-
private newtype TUnit = TMkUnit()
608-
609-
/** The trivial type with a single element. */
610-
class Unit extends TUnit {
611-
/** Gets a textual representation of this element. */
612-
string toString() { result = "unit" }
613-
}
614-
615606
/**
616607
* Holds if the node `n` is unreachable when the call context is `call`.
617608
*/

swift/ql/lib/swift.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ import codeql.swift.elements.expr.ArithmeticOperation
55
import codeql.swift.elements.expr.LogicalOperation
66
import codeql.swift.elements.decl.MethodDecl
77
import codeql.swift.elements.decl.ClassOrStructDecl
8+
import codeql.swift.Unit

0 commit comments

Comments
 (0)