diff --git a/cpp/ql/lib/qlpack.yml b/cpp/ql/lib/qlpack.yml index 12ad778c119..aa4f7c79fef 100644 --- a/cpp/ql/lib/qlpack.yml +++ b/cpp/ql/lib/qlpack.yml @@ -8,3 +8,4 @@ upgrades: upgrades dependencies: codeql/ssa: ${workspace} codeql/tutorial: ${workspace} + codeql/util: ${workspace} diff --git a/cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowPrivate.qll b/cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowPrivate.qll index f54e3b9a9cb..c08e05b767d 100644 --- a/cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowPrivate.qll +++ b/cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowPrivate.qll @@ -3,6 +3,7 @@ private import DataFlowUtil private import DataFlowDispatch private import FlowVar private import DataFlowImplConsistency +import codeql.util.Unit /** Gets the callable in which this node occurs. */ DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() } @@ -264,15 +265,6 @@ int accessPathLimit() { result = 5 } */ predicate forceHighPrecision(Content c) { none() } -/** The unit type. */ -private newtype TUnit = TMkUnit() - -/** The trivial type with a single element. */ -class Unit extends TUnit { - /** Gets a textual representation of this element. */ - string toString() { result = "unit" } -} - /** Holds if `n` should be hidden from path explanations. */ predicate nodeIsHidden(Node n) { none() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll index 9d69856e20b..331eb6241a5 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll @@ -6,6 +6,7 @@ private import DataFlowImplConsistency private import semmle.code.cpp.ir.internal.IRCppLanguage private import SsaInternals as Ssa private import DataFlowImplCommon as DataFlowImplCommon +import codeql.util.Unit cached private module Cached { @@ -799,15 +800,6 @@ int accessPathLimit() { result = 5 } */ predicate forceHighPrecision(Content c) { none() } -/** The unit type. */ -private newtype TUnit = TMkUnit() - -/** The trivial type with a single element. */ -class Unit extends TUnit { - /** Gets a textual representation of this element. */ - string toString() { result = "unit" } -} - /** Holds if `n` should be hidden from path explanations. */ predicate nodeIsHidden(Node n) { n instanceof OperandNode and diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll index a7fc72d0c17..9bcddf7c6c2 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll @@ -19,6 +19,7 @@ private import semmle.code.csharp.frameworks.system.Collections private import semmle.code.csharp.frameworks.system.threading.Tasks private import semmle.code.cil.Ssa::Ssa as CilSsa private import semmle.code.cil.internal.SsaImpl as CilSsaImpl +import codeql.util.Unit /** Gets the callable in which this node occurs. */ DataFlowCallable nodeGetEnclosingCallable(NodeImpl n) { result = n.getEnclosingCallableImpl() } @@ -2163,15 +2164,6 @@ int accessPathLimit() { result = 5 } */ predicate forceHighPrecision(Content c) { c instanceof ElementContent } -/** The unit type. */ -private newtype TUnit = TMkUnit() - -/** The trivial type with a single element. */ -class Unit extends TUnit { - /** Gets a textual representation of this element. */ - string toString() { result = "unit" } -} - class LambdaCallKind = Unit; /** Holds if `creation` is an expression that creates a delegate for `c`. */ @@ -2183,7 +2175,7 @@ predicate lambdaCreation(ExprNode creation, LambdaCallKind kind, DataFlowCallabl e.(AddressOfExpr).getOperand().(CallableAccess).getTarget().getUnboundDeclaration() ] ) and - kind = TMkUnit() + exists(kind) } private class LambdaConfiguration extends ControlFlowReachabilityConfiguration { @@ -2214,7 +2206,7 @@ predicate lambdaCall(DataFlowCall call, LambdaCallKind kind, Node receiver) { or receiver = call.(SummaryCall).getReceiver() ) and - kind = TMkUnit() + exists(kind) } /** Extra data-flow steps needed for lambda flow analysis. */ diff --git a/go/ql/lib/qlpack.yml b/go/ql/lib/qlpack.yml index a8601ec94b7..db88dfdbcd7 100644 --- a/go/ql/lib/qlpack.yml +++ b/go/ql/lib/qlpack.yml @@ -7,5 +7,6 @@ library: true upgrades: upgrades dependencies: codeql/tutorial: ${workspace} + codeql/util: ${workspace} dataExtensions: - ext/*.model.yml diff --git a/go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll b/go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll index f6cb63c1c75..d57adbe5d69 100644 --- a/go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll +++ b/go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll @@ -3,6 +3,7 @@ private import DataFlowUtil private import DataFlowImplCommon private import ContainerFlow private import FlowSummaryImpl as FlowSummaryImpl +import codeql.util.Unit import DataFlowNodes::Private private newtype TReturnKind = @@ -339,15 +340,6 @@ predicate forceHighPrecision(Content c) { c instanceof ArrayContent or c instanceof CollectionContent } -/** The unit type. */ -private newtype TUnit = TMkUnit() - -/** The trivial type with a single element. */ -class Unit extends TUnit { - /** Gets a textual representation of this element. */ - string toString() { result = "unit" } -} - /** * Gets the `i`th argument of call `c`, where the receiver of a method call * counts as argument -1. diff --git a/go/ql/lib/semmle/go/dataflow/internal/TaintTrackingUtil.qll b/go/ql/lib/semmle/go/dataflow/internal/TaintTrackingUtil.qll index 6dfc0dbdcff..38e03f62b44 100644 --- a/go/ql/lib/semmle/go/dataflow/internal/TaintTrackingUtil.qll +++ b/go/ql/lib/semmle/go/dataflow/internal/TaintTrackingUtil.qll @@ -4,6 +4,7 @@ private import go private import FlowSummaryImpl as FlowSummaryImpl +private import codeql.util.Unit /** * 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) { ) } -private newtype TUnit = TMkUnit() - -/** A singleton class containing a single dummy "unit" value. */ -private class Unit extends TUnit { - /** Gets a textual representation of this element. */ - string toString() { result = "unit" } -} - /** * A unit class for adding additional taint steps. * diff --git a/java/ql/lib/semmle/code/Unit.qll b/java/ql/lib/semmle/code/Unit.qll index e9611ed3df4..83a4a03321d 100644 --- a/java/ql/lib/semmle/code/Unit.qll +++ b/java/ql/lib/semmle/code/Unit.qll @@ -1,10 +1,3 @@ /** Provides the `Unit` class. */ -/** The unit type. */ -private newtype TUnit = TMkUnit() - -/** The trivial type with a single element. */ -class Unit extends TUnit { - /** Gets a textual representation of this element. */ - string toString() { result = "unit" } -} +import codeql.util.Unit diff --git a/javascript/ql/lib/qlpack.yml b/javascript/ql/lib/qlpack.yml index 5c650164c39..99f044a6431 100644 --- a/javascript/ql/lib/qlpack.yml +++ b/javascript/ql/lib/qlpack.yml @@ -8,5 +8,6 @@ upgrades: upgrades dependencies: codeql/regex: ${workspace} codeql/tutorial: ${workspace} + codeql/util: ${workspace} dataExtensions: - semmle/javascript/frameworks/**/model.yml diff --git a/javascript/ql/lib/semmle/javascript/Unit.qll b/javascript/ql/lib/semmle/javascript/Unit.qll index dbc59f541e6..83a4a03321d 100644 --- a/javascript/ql/lib/semmle/javascript/Unit.qll +++ b/javascript/ql/lib/semmle/javascript/Unit.qll @@ -1,10 +1,3 @@ /** Provides the `Unit` class. */ -/** The unit type. */ -private newtype TUnit = TMkUnit() - -/** The trivial type with a single element. */ -class Unit extends TUnit { - /** Gets a textual representation of this element. */ - string toString() { result = "Unit" } -} +import codeql.util.Unit diff --git a/python/ql/lib/qlpack.yml b/python/ql/lib/qlpack.yml index f40f7e10b4f..bc1863e7214 100644 --- a/python/ql/lib/qlpack.yml +++ b/python/ql/lib/qlpack.yml @@ -7,7 +7,7 @@ library: true upgrades: upgrades dependencies: codeql/regex: ${workspace} - codeql/util: ${workspace} codeql/tutorial: ${workspace} + codeql/util: ${workspace} dataExtensions: - semmle/python/frameworks/**/model.yml diff --git a/python/ql/lib/semmle/python/Unit.qll b/python/ql/lib/semmle/python/Unit.qll index e9611ed3df4..83a4a03321d 100644 --- a/python/ql/lib/semmle/python/Unit.qll +++ b/python/ql/lib/semmle/python/Unit.qll @@ -1,10 +1,3 @@ /** Provides the `Unit` class. */ -/** The unit type. */ -private newtype TUnit = TMkUnit() - -/** The trivial type with a single element. */ -class Unit extends TUnit { - /** Gets a textual representation of this element. */ - string toString() { result = "unit" } -} +import codeql.util.Unit diff --git a/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll b/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll index cd84298c41a..bcff6df309a 100644 --- a/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll +++ b/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll @@ -9,6 +9,7 @@ private import SsaImpl as SsaImpl private import FlowSummaryImpl as FlowSummaryImpl private import FlowSummaryImplSpecific as FlowSummaryImplSpecific private import codeql.ruby.frameworks.data.ModelsAsData +import codeql.util.Unit /** Gets the callable in which this node occurs. */ DataFlowCallable nodeGetEnclosingCallable(NodeImpl n) { result = n.getEnclosingCallable() } @@ -1350,15 +1351,6 @@ int accessPathLimit() { result = 5 } */ predicate forceHighPrecision(Content c) { c instanceof Content::ElementContent } -/** The unit type. */ -private newtype TUnit = TMkUnit() - -/** The trivial type with a single element. */ -class Unit extends TUnit { - /** Gets a textual representation of this element. */ - string toString() { result = "unit" } -} - /** * Holds if the node `n` is unreachable when the call context is `call`. */ diff --git a/swift/ql/lib/codeql/swift/Unit.qll b/swift/ql/lib/codeql/swift/Unit.qll index e9611ed3df4..83a4a03321d 100644 --- a/swift/ql/lib/codeql/swift/Unit.qll +++ b/swift/ql/lib/codeql/swift/Unit.qll @@ -1,10 +1,3 @@ /** Provides the `Unit` class. */ -/** The unit type. */ -private newtype TUnit = TMkUnit() - -/** The trivial type with a single element. */ -class Unit extends TUnit { - /** Gets a textual representation of this element. */ - string toString() { result = "unit" } -} +import codeql.util.Unit diff --git a/swift/ql/lib/qlpack.yml b/swift/ql/lib/qlpack.yml index 66c3bc0094d..3d3f00eb029 100644 --- a/swift/ql/lib/qlpack.yml +++ b/swift/ql/lib/qlpack.yml @@ -8,3 +8,4 @@ library: true dependencies: codeql/ssa: ${workspace} codeql/tutorial: ${workspace} + codeql/util: ${workspace}