Skip to content

Commit fbe3401

Browse files
committed
C++/C#/Java: AccessPath class names reflect length
One -> ConsNil Two -> ConsCons
1 parent e8006bb commit fbe3401

File tree

19 files changed

+361
-399
lines changed

19 files changed

+361
-399
lines changed

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,8 @@ private predicate consCand(Content f, AccessPathFront apf, Configuration config)
12171217

12181218
private newtype TAccessPath =
12191219
TNil(DataFlowType t) or
1220-
TOne(Content f, DataFlowType t) { consCand(f, TFrontNil(t), _) } or
1221-
TTwo(Content f1, Content f2, int len) { consCand(f1, TFrontHead(f2), _) and len in [2 .. 5] }
1220+
TConsNil(Content f, DataFlowType t) { consCand(f, TFrontNil(t), _) } or
1221+
TConsCons(Content f1, Content f2, int len) { consCand(f1, TFrontHead(f2), _) and len in [2 .. 5] }
12221222

12231223
/**
12241224
* Conceptually a list of `Content`s followed by a `Type`, but only the first
@@ -1231,17 +1231,17 @@ private class AccessPath extends TAccessPath {
12311231
abstract string toString();
12321232

12331233
Content getHead() {
1234-
this = TOne(result, _)
1234+
this = TConsNil(result, _)
12351235
or
1236-
this = TTwo(result, _, _)
1236+
this = TConsCons(result, _, _)
12371237
}
12381238

12391239
int len() {
12401240
this = TNil(_) and result = 0
12411241
or
1242-
this = TOne(_, _) and result = 1
1242+
this = TConsNil(_, _) and result = 1
12431243
or
1244-
this = TTwo(_, _, result)
1244+
this = TConsCons(_, _, result)
12451245
}
12461246

12471247
DataFlowType getType() {
@@ -1268,47 +1268,45 @@ private class AccessPathNil extends AccessPath, TNil {
12681268
override predicate pop(Content head, AccessPath tail) { none() }
12691269
}
12701270

1271-
private class AccessPathOne extends AccessPath, TOne {
1271+
private class AccessPathConsNil extends AccessPath, TConsNil {
12721272
override string toString() {
1273-
exists(Content f, DataFlowType t | this = TOne(f, t) |
1273+
exists(Content f, DataFlowType t | this = TConsNil(f, t) |
12741274
result = f.toString() + " : " + ppReprType(t)
12751275
)
12761276
}
12771277

12781278
override AccessPathFront getFront() {
1279-
exists(Content f | this = TOne(f, _) | result = TFrontHead(f))
1279+
exists(Content f | this = TConsNil(f, _) | result = TFrontHead(f))
12801280
}
12811281

12821282
override predicate pop(Content head, AccessPath tail) {
1283-
exists(DataFlowType t | this = TOne(head, t) and tail = TNil(t))
1283+
exists(DataFlowType t | this = TConsNil(head, t) and tail = TNil(t))
12841284
}
12851285
}
12861286

1287-
private class AccessPathTwo extends AccessPath, TTwo {
1287+
private class AccessPathConsCons extends AccessPath, TConsCons {
12881288
override string toString() {
1289-
exists(Content f1, Content f2, int len | this = TTwo(f1, f2, len) |
1289+
exists(Content f1, Content f2, int len | this = TConsCons(f1, f2, len) |
12901290
result = f1.toString() + ", " + f2.toString() + ", ... (" + len.toString() + ")"
12911291
)
12921292
}
12931293

12941294
override AccessPathFront getFront() {
1295-
exists(Content f | this = TTwo(f, _, _) | result = TFrontHead(f))
1295+
exists(Content f | this = TConsCons(f, _, _) | result = TFrontHead(f))
12961296
}
12971297

12981298
override predicate pop(Content head, AccessPath tail) {
1299-
exists(int len, Content next | this = TTwo(head, next, len) |
1300-
tail = TTwo(next, _, len - 1)
1299+
exists(int len, Content next | this = TConsCons(head, next, len) |
1300+
tail = TConsCons(next, _, len - 1)
13011301
or
13021302
len = 2 and
1303-
tail = TOne(next, _)
1303+
tail = TConsNil(next, _)
13041304
)
13051305
}
13061306
}
13071307

13081308
/** Holds if `ap0` corresponds to the cons of `f` and `ap`. */
1309-
private predicate pop(AccessPath ap0, Content f, AccessPath ap) {
1310-
ap0.pop(f, ap)
1311-
}
1309+
private predicate pop(AccessPath ap0, Content f, AccessPath ap) { ap0.pop(f, ap) }
13121310

13131311
/** Holds if `ap0` corresponds to the cons of `f` and `ap` and `apf` is the front of `ap`. */
13141312
pragma[noinline]
@@ -1851,9 +1849,9 @@ private predicate pathIntoArg(
18511849
|
18521850
ap instanceof AccessPathNil and emptyAp = true
18531851
or
1854-
ap instanceof AccessPathOne and emptyAp = false
1852+
ap instanceof AccessPathConsNil and emptyAp = false
18551853
or
1856-
ap instanceof AccessPathTwo and emptyAp = false
1854+
ap instanceof AccessPathConsCons and emptyAp = false
18571855
)
18581856
}
18591857

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,8 @@ private predicate consCand(Content f, AccessPathFront apf, Configuration config)
12171217

12181218
private newtype TAccessPath =
12191219
TNil(DataFlowType t) or
1220-
TOne(Content f, DataFlowType t) { consCand(f, TFrontNil(t), _) } or
1221-
TTwo(Content f1, Content f2, int len) { consCand(f1, TFrontHead(f2), _) and len in [2 .. 5] }
1220+
TConsNil(Content f, DataFlowType t) { consCand(f, TFrontNil(t), _) } or
1221+
TConsCons(Content f1, Content f2, int len) { consCand(f1, TFrontHead(f2), _) and len in [2 .. 5] }
12221222

12231223
/**
12241224
* Conceptually a list of `Content`s followed by a `Type`, but only the first
@@ -1231,17 +1231,17 @@ private class AccessPath extends TAccessPath {
12311231
abstract string toString();
12321232

12331233
Content getHead() {
1234-
this = TOne(result, _)
1234+
this = TConsNil(result, _)
12351235
or
1236-
this = TTwo(result, _, _)
1236+
this = TConsCons(result, _, _)
12371237
}
12381238

12391239
int len() {
12401240
this = TNil(_) and result = 0
12411241
or
1242-
this = TOne(_, _) and result = 1
1242+
this = TConsNil(_, _) and result = 1
12431243
or
1244-
this = TTwo(_, _, result)
1244+
this = TConsCons(_, _, result)
12451245
}
12461246

12471247
DataFlowType getType() {
@@ -1268,47 +1268,45 @@ private class AccessPathNil extends AccessPath, TNil {
12681268
override predicate pop(Content head, AccessPath tail) { none() }
12691269
}
12701270

1271-
private class AccessPathOne extends AccessPath, TOne {
1271+
private class AccessPathConsNil extends AccessPath, TConsNil {
12721272
override string toString() {
1273-
exists(Content f, DataFlowType t | this = TOne(f, t) |
1273+
exists(Content f, DataFlowType t | this = TConsNil(f, t) |
12741274
result = f.toString() + " : " + ppReprType(t)
12751275
)
12761276
}
12771277

12781278
override AccessPathFront getFront() {
1279-
exists(Content f | this = TOne(f, _) | result = TFrontHead(f))
1279+
exists(Content f | this = TConsNil(f, _) | result = TFrontHead(f))
12801280
}
12811281

12821282
override predicate pop(Content head, AccessPath tail) {
1283-
exists(DataFlowType t | this = TOne(head, t) and tail = TNil(t))
1283+
exists(DataFlowType t | this = TConsNil(head, t) and tail = TNil(t))
12841284
}
12851285
}
12861286

1287-
private class AccessPathTwo extends AccessPath, TTwo {
1287+
private class AccessPathConsCons extends AccessPath, TConsCons {
12881288
override string toString() {
1289-
exists(Content f1, Content f2, int len | this = TTwo(f1, f2, len) |
1289+
exists(Content f1, Content f2, int len | this = TConsCons(f1, f2, len) |
12901290
result = f1.toString() + ", " + f2.toString() + ", ... (" + len.toString() + ")"
12911291
)
12921292
}
12931293

12941294
override AccessPathFront getFront() {
1295-
exists(Content f | this = TTwo(f, _, _) | result = TFrontHead(f))
1295+
exists(Content f | this = TConsCons(f, _, _) | result = TFrontHead(f))
12961296
}
12971297

12981298
override predicate pop(Content head, AccessPath tail) {
1299-
exists(int len, Content next | this = TTwo(head, next, len) |
1300-
tail = TTwo(next, _, len - 1)
1299+
exists(int len, Content next | this = TConsCons(head, next, len) |
1300+
tail = TConsCons(next, _, len - 1)
13011301
or
13021302
len = 2 and
1303-
tail = TOne(next, _)
1303+
tail = TConsNil(next, _)
13041304
)
13051305
}
13061306
}
13071307

13081308
/** Holds if `ap0` corresponds to the cons of `f` and `ap`. */
1309-
private predicate pop(AccessPath ap0, Content f, AccessPath ap) {
1310-
ap0.pop(f, ap)
1311-
}
1309+
private predicate pop(AccessPath ap0, Content f, AccessPath ap) { ap0.pop(f, ap) }
13121310

13131311
/** Holds if `ap0` corresponds to the cons of `f` and `ap` and `apf` is the front of `ap`. */
13141312
pragma[noinline]
@@ -1851,9 +1849,9 @@ private predicate pathIntoArg(
18511849
|
18521850
ap instanceof AccessPathNil and emptyAp = true
18531851
or
1854-
ap instanceof AccessPathOne and emptyAp = false
1852+
ap instanceof AccessPathConsNil and emptyAp = false
18551853
or
1856-
ap instanceof AccessPathTwo and emptyAp = false
1854+
ap instanceof AccessPathConsCons and emptyAp = false
18571855
)
18581856
}
18591857

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,8 @@ private predicate consCand(Content f, AccessPathFront apf, Configuration config)
12171217

12181218
private newtype TAccessPath =
12191219
TNil(DataFlowType t) or
1220-
TOne(Content f, DataFlowType t) { consCand(f, TFrontNil(t), _) } or
1221-
TTwo(Content f1, Content f2, int len) { consCand(f1, TFrontHead(f2), _) and len in [2 .. 5] }
1220+
TConsNil(Content f, DataFlowType t) { consCand(f, TFrontNil(t), _) } or
1221+
TConsCons(Content f1, Content f2, int len) { consCand(f1, TFrontHead(f2), _) and len in [2 .. 5] }
12221222

12231223
/**
12241224
* Conceptually a list of `Content`s followed by a `Type`, but only the first
@@ -1231,17 +1231,17 @@ private class AccessPath extends TAccessPath {
12311231
abstract string toString();
12321232

12331233
Content getHead() {
1234-
this = TOne(result, _)
1234+
this = TConsNil(result, _)
12351235
or
1236-
this = TTwo(result, _, _)
1236+
this = TConsCons(result, _, _)
12371237
}
12381238

12391239
int len() {
12401240
this = TNil(_) and result = 0
12411241
or
1242-
this = TOne(_, _) and result = 1
1242+
this = TConsNil(_, _) and result = 1
12431243
or
1244-
this = TTwo(_, _, result)
1244+
this = TConsCons(_, _, result)
12451245
}
12461246

12471247
DataFlowType getType() {
@@ -1268,47 +1268,45 @@ private class AccessPathNil extends AccessPath, TNil {
12681268
override predicate pop(Content head, AccessPath tail) { none() }
12691269
}
12701270

1271-
private class AccessPathOne extends AccessPath, TOne {
1271+
private class AccessPathConsNil extends AccessPath, TConsNil {
12721272
override string toString() {
1273-
exists(Content f, DataFlowType t | this = TOne(f, t) |
1273+
exists(Content f, DataFlowType t | this = TConsNil(f, t) |
12741274
result = f.toString() + " : " + ppReprType(t)
12751275
)
12761276
}
12771277

12781278
override AccessPathFront getFront() {
1279-
exists(Content f | this = TOne(f, _) | result = TFrontHead(f))
1279+
exists(Content f | this = TConsNil(f, _) | result = TFrontHead(f))
12801280
}
12811281

12821282
override predicate pop(Content head, AccessPath tail) {
1283-
exists(DataFlowType t | this = TOne(head, t) and tail = TNil(t))
1283+
exists(DataFlowType t | this = TConsNil(head, t) and tail = TNil(t))
12841284
}
12851285
}
12861286

1287-
private class AccessPathTwo extends AccessPath, TTwo {
1287+
private class AccessPathConsCons extends AccessPath, TConsCons {
12881288
override string toString() {
1289-
exists(Content f1, Content f2, int len | this = TTwo(f1, f2, len) |
1289+
exists(Content f1, Content f2, int len | this = TConsCons(f1, f2, len) |
12901290
result = f1.toString() + ", " + f2.toString() + ", ... (" + len.toString() + ")"
12911291
)
12921292
}
12931293

12941294
override AccessPathFront getFront() {
1295-
exists(Content f | this = TTwo(f, _, _) | result = TFrontHead(f))
1295+
exists(Content f | this = TConsCons(f, _, _) | result = TFrontHead(f))
12961296
}
12971297

12981298
override predicate pop(Content head, AccessPath tail) {
1299-
exists(int len, Content next | this = TTwo(head, next, len) |
1300-
tail = TTwo(next, _, len - 1)
1299+
exists(int len, Content next | this = TConsCons(head, next, len) |
1300+
tail = TConsCons(next, _, len - 1)
13011301
or
13021302
len = 2 and
1303-
tail = TOne(next, _)
1303+
tail = TConsNil(next, _)
13041304
)
13051305
}
13061306
}
13071307

13081308
/** Holds if `ap0` corresponds to the cons of `f` and `ap`. */
1309-
private predicate pop(AccessPath ap0, Content f, AccessPath ap) {
1310-
ap0.pop(f, ap)
1311-
}
1309+
private predicate pop(AccessPath ap0, Content f, AccessPath ap) { ap0.pop(f, ap) }
13121310

13131311
/** Holds if `ap0` corresponds to the cons of `f` and `ap` and `apf` is the front of `ap`. */
13141312
pragma[noinline]
@@ -1851,9 +1849,9 @@ private predicate pathIntoArg(
18511849
|
18521850
ap instanceof AccessPathNil and emptyAp = true
18531851
or
1854-
ap instanceof AccessPathOne and emptyAp = false
1852+
ap instanceof AccessPathConsNil and emptyAp = false
18551853
or
1856-
ap instanceof AccessPathTwo and emptyAp = false
1854+
ap instanceof AccessPathConsCons and emptyAp = false
18571855
)
18581856
}
18591857

0 commit comments

Comments
 (0)