Skip to content

Commit 40a07de

Browse files
committed
Type tracking: Parameterize consistency checks
1 parent 75f42f4 commit 40a07de

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

shared/typetracking/codeql/typetracking/TypeTracking.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ private import internal.TypeTrackingImpl as Impl
124124
module TypeTracking<TypeTrackingInput I> {
125125
private module MkImpl = Impl::TypeTracking<I>;
126126

127-
deprecated module ConsistencyChecks = MkImpl::ConsistencyChecks;
127+
private module ConsistencyChecksInput implements MkImpl::ConsistencyChecksInputSig { }
128+
129+
deprecated module ConsistencyChecks = MkImpl::ConsistencyChecks<ConsistencyChecksInput>;
128130

129131
class TypeTracker = MkImpl::TypeTracker;
130132

shared/typetracking/codeql/typetracking/internal/TypeTrackingImpl.qll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@ private import codeql.typetracking.TypeTracking
1717
module TypeTracking<TypeTrackingInput I> {
1818
private import I
1919

20+
signature module ConsistencyChecksInputSig {
21+
/** Holds if `n` should be excluded from the consistency test `unreachableNode`. */
22+
default predicate unreachableNodeExclude(Node n) { none() }
23+
24+
/** Holds if `n` should be excluded from the consistency test `nonSourceStoreTarget`. */
25+
default predicate nonSourceStoreTargetExclude(Node n) { none() }
26+
}
27+
2028
/** Provides consistency checks for the type-tracker step relations. */
21-
module ConsistencyChecks {
29+
module ConsistencyChecks<ConsistencyChecksInputSig ConsistencyChecksInput> {
2230
private predicate stepEntry(Node n, string kind) {
2331
simpleLocalSmallStep(n, _) and kind = "simpleLocalSmallStep"
2432
or
@@ -34,6 +42,7 @@ module TypeTracking<TypeTrackingInput I> {
3442
* `LocalSourceNode`.
3543
*/
3644
query predicate unreachableNode(Node n, string msg) {
45+
not ConsistencyChecksInput::unreachableNodeExclude(n) and
3746
exists(string kind |
3847
stepEntry(n, kind) and
3948
not flowsTo(_, n) and
@@ -46,6 +55,7 @@ module TypeTracking<TypeTrackingInput I> {
4655
* backtracking store target feature isn't enabled.
4756
*/
4857
query predicate nonSourceStoreTarget(Node n, string msg) {
58+
not ConsistencyChecksInput::nonSourceStoreTargetExclude(n) and
4959
not hasFeatureBacktrackStoreTarget() and
5060
not n instanceof LocalSourceNode and
5161
(storeStep(_, n, _) or loadStoreStep(_, n, _, _)) and

0 commit comments

Comments
 (0)