Skip to content

Commit a87a943

Browse files
committed
Replace all definitions of Unit by import codeql.util.Unit
1 parent 110d666 commit a87a943

File tree

15 files changed

+17
-88
lines changed

15 files changed

+17
-88
lines changed

cpp/ql/lib/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ upgrades: upgrades
88
dependencies:
99
codeql/ssa: ${workspace}
1010
codeql/tutorial: ${workspace}
11+
codeql/util: ${workspace}

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ private import DataFlowUtil
33
private import DataFlowDispatch
44
private import FlowVar
55
private import DataFlowImplConsistency
6+
import codeql.util.Unit
67

78
/** Gets the callable in which this node occurs. */
89
DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() }
@@ -264,15 +265,6 @@ int accessPathLimit() { result = 5 }
264265
*/
265266
predicate forceHighPrecision(Content c) { none() }
266267

267-
/** The unit type. */
268-
private newtype TUnit = TMkUnit()
269-
270-
/** The trivial type with a single element. */
271-
class Unit extends TUnit {
272-
/** Gets a textual representation of this element. */
273-
string toString() { result = "unit" }
274-
}
275-
276268
/** Holds if `n` should be hidden from path explanations. */
277269
predicate nodeIsHidden(Node n) { none() }
278270

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ private import DataFlowImplConsistency
66
private import semmle.code.cpp.ir.internal.IRCppLanguage
77
private import SsaInternals as Ssa
88
private import DataFlowImplCommon as DataFlowImplCommon
9+
import codeql.util.Unit
910

1011
cached
1112
private module Cached {
@@ -799,15 +800,6 @@ int accessPathLimit() { result = 5 }
799800
*/
800801
predicate forceHighPrecision(Content c) { none() }
801802

802-
/** The unit type. */
803-
private newtype TUnit = TMkUnit()
804-
805-
/** The trivial type with a single element. */
806-
class Unit extends TUnit {
807-
/** Gets a textual representation of this element. */
808-
string toString() { result = "unit" }
809-
}
810-
811803
/** Holds if `n` should be hidden from path explanations. */
812804
predicate nodeIsHidden(Node n) {
813805
n instanceof OperandNode and

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ private import semmle.code.csharp.frameworks.system.Collections
1919
private import semmle.code.csharp.frameworks.system.threading.Tasks
2020
private import semmle.code.cil.Ssa::Ssa as CilSsa
2121
private import semmle.code.cil.internal.SsaImpl as CilSsaImpl
22+
import codeql.util.Unit
2223

2324
/** Gets the callable in which this node occurs. */
2425
DataFlowCallable nodeGetEnclosingCallable(NodeImpl n) { result = n.getEnclosingCallableImpl() }
@@ -2163,15 +2164,6 @@ int accessPathLimit() { result = 5 }
21632164
*/
21642165
predicate forceHighPrecision(Content c) { c instanceof ElementContent }
21652166

2166-
/** The unit type. */
2167-
private newtype TUnit = TMkUnit()
2168-
2169-
/** The trivial type with a single element. */
2170-
class Unit extends TUnit {
2171-
/** Gets a textual representation of this element. */
2172-
string toString() { result = "unit" }
2173-
}
2174-
21752167
class LambdaCallKind = Unit;
21762168

21772169
/** Holds if `creation` is an expression that creates a delegate for `c`. */
@@ -2183,7 +2175,7 @@ predicate lambdaCreation(ExprNode creation, LambdaCallKind kind, DataFlowCallabl
21832175
e.(AddressOfExpr).getOperand().(CallableAccess).getTarget().getUnboundDeclaration()
21842176
]
21852177
) and
2186-
kind = TMkUnit()
2178+
exists(kind)
21872179
}
21882180

21892181
private class LambdaConfiguration extends ControlFlowReachabilityConfiguration {
@@ -2214,7 +2206,7 @@ predicate lambdaCall(DataFlowCall call, LambdaCallKind kind, Node receiver) {
22142206
or
22152207
receiver = call.(SummaryCall).getReceiver()
22162208
) and
2217-
kind = TMkUnit()
2209+
exists(kind)
22182210
}
22192211

22202212
/** Extra data-flow steps needed for lambda flow analysis. */

go/ql/lib/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ library: true
77
upgrades: upgrades
88
dependencies:
99
codeql/tutorial: ${workspace}
10+
codeql/util: ${workspace}
1011
dataExtensions:
1112
- ext/*.model.yml

go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ private import DataFlowUtil
33
private import DataFlowImplCommon
44
private import ContainerFlow
55
private import FlowSummaryImpl as FlowSummaryImpl
6+
import codeql.util.Unit
67
import DataFlowNodes::Private
78

89
private newtype TReturnKind =
@@ -339,15 +340,6 @@ predicate forceHighPrecision(Content c) {
339340
c instanceof ArrayContent or c instanceof CollectionContent
340341
}
341342

342-
/** The unit type. */
343-
private newtype TUnit = TMkUnit()
344-
345-
/** The trivial type with a single element. */
346-
class Unit extends TUnit {
347-
/** Gets a textual representation of this element. */
348-
string toString() { result = "unit" }
349-
}
350-
351343
/**
352344
* Gets the `i`th argument of call `c`, where the receiver of a method call
353345
* counts as argument -1.

go/ql/lib/semmle/go/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
private import go
66
private import FlowSummaryImpl as FlowSummaryImpl
7+
private import codeql.util.Unit
78

89
/**
910
* Holds if taint can flow from `src` to `sink` in zero or more
@@ -66,14 +67,6 @@ predicate defaultImplicitTaintRead(DataFlow::Node node, DataFlow::Content c) {
6667
)
6768
}
6869

69-
private newtype TUnit = TMkUnit()
70-
71-
/** A singleton class containing a single dummy "unit" value. */
72-
private class Unit extends TUnit {
73-
/** Gets a textual representation of this element. */
74-
string toString() { result = "unit" }
75-
}
76-
7770
/**
7871
* A unit class for adding additional taint steps.
7972
*

java/ql/lib/semmle/code/Unit.qll

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
/** Provides the `Unit` class. */
22

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-
}
3+
import codeql.util.Unit

javascript/ql/lib/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ upgrades: upgrades
88
dependencies:
99
codeql/regex: ${workspace}
1010
codeql/tutorial: ${workspace}
11+
codeql/util: ${workspace}
1112
dataExtensions:
1213
- semmle/javascript/frameworks/**/model.yml
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
/** Provides the `Unit` class. */
22

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-
}
3+
import codeql.util.Unit

0 commit comments

Comments
 (0)