Skip to content

Commit 3bd6429

Browse files
committed
Data flow: Sync files
1 parent 321b912 commit 3bd6429

File tree

18 files changed

+306
-288
lines changed

18 files changed

+306
-288
lines changed

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ abstract private class AccessPathFront extends TAccessPathFront {
14301430

14311431
abstract DataFlowType getType();
14321432

1433-
abstract boolean toBool();
1433+
abstract boolean toBoolNonEmpty();
14341434

14351435
predicate headUsesContent(Content f) { this = TFrontHead(f) }
14361436
}
@@ -1442,7 +1442,7 @@ private class AccessPathFrontNil extends AccessPathFront, TFrontNil {
14421442

14431443
override DataFlowType getType() { this = TFrontNil(result) }
14441444

1445-
override boolean toBool() { result = false }
1445+
override boolean toBoolNonEmpty() { result = false }
14461446
}
14471447

14481448
private class AccessPathFrontHead extends AccessPathFront, TFrontHead {
@@ -1452,7 +1452,7 @@ private class AccessPathFrontHead extends AccessPathFront, TFrontHead {
14521452
exists(Content head | this = TFrontHead(head) | result = head.getContainerType())
14531453
}
14541454

1455-
override boolean toBool() { result = true }
1455+
override boolean toBoolNonEmpty() { result = true }
14561456
}
14571457

14581458
/**
@@ -1477,6 +1477,16 @@ private predicate flowCandFwd0(
14771477
fromArg = false and
14781478
apf = TFrontNil(node.getErasedNodeTypeBound())
14791479
or
1480+
exists(NodeExt mid |
1481+
flowCandFwd(mid, fromArg, apf, config) and
1482+
localFlowBigStepExt(mid, node, true, _, config)
1483+
)
1484+
or
1485+
exists(NodeExt mid, AccessPathFrontNil nil |
1486+
flowCandFwd(mid, fromArg, nil, config) and
1487+
localFlowBigStepExt(mid, node, false, apf, config)
1488+
)
1489+
or
14801490
nodeCand2(node, unbind(config)) and
14811491
(
14821492
exists(NodeExt mid |
@@ -1518,16 +1528,6 @@ private predicate flowCandFwd0(
15181528
)
15191529
)
15201530
or
1521-
exists(NodeExt mid |
1522-
flowCandFwd(mid, fromArg, apf, config) and
1523-
localFlowBigStepExt(mid, node, true, _, config)
1524-
)
1525-
or
1526-
exists(NodeExt mid, AccessPathFrontNil nil |
1527-
flowCandFwd(mid, fromArg, nil, config) and
1528-
localFlowBigStepExt(mid, node, false, apf, config)
1529-
)
1530-
or
15311531
exists(NodeExt mid, Content f |
15321532
flowCandFwd(mid, fromArg, _, config) and
15331533
storeExtCand2(mid, f, node, config) and
@@ -1538,7 +1538,7 @@ private predicate flowCandFwd0(
15381538
exists(Content f |
15391539
flowCandFwdRead(f, node, fromArg, config) and
15401540
consCandFwd(f, apf, config) and
1541-
nodeCand2(node, _, unbindBool(apf.toBool()), unbind(config))
1541+
nodeCand2(node, _, unbindBool(apf.toBoolNonEmpty()), unbind(config))
15421542
)
15431543
}
15441544

@@ -1897,7 +1897,7 @@ private predicate flowFwdStore1(
18971897
flowFwdStore0(mid, f, node, apf0, config) and
18981898
consCand(f, apf0, config) and
18991899
apf.headUsesContent(f) and
1900-
flowCand(node, _, apf, config)
1900+
flowCand(node, _, apf, unbind(config))
19011901
}
19021902

19031903
pragma[nomagic]
@@ -2025,7 +2025,8 @@ private predicate readFwd(
20252025
) {
20262026
readExtCand2(node1, f, node2, config) and
20272027
flowFwdRead(node2, f, ap, _, config) and
2028-
ap0 = pop(f, ap)
2028+
ap0 = pop(f, ap) and
2029+
flowConsCandFwd(f, _, ap0, unbind(config))
20292030
}
20302031

20312032
pragma[nomagic]

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ abstract private class AccessPathFront extends TAccessPathFront {
14301430

14311431
abstract DataFlowType getType();
14321432

1433-
abstract boolean toBool();
1433+
abstract boolean toBoolNonEmpty();
14341434

14351435
predicate headUsesContent(Content f) { this = TFrontHead(f) }
14361436
}
@@ -1442,7 +1442,7 @@ private class AccessPathFrontNil extends AccessPathFront, TFrontNil {
14421442

14431443
override DataFlowType getType() { this = TFrontNil(result) }
14441444

1445-
override boolean toBool() { result = false }
1445+
override boolean toBoolNonEmpty() { result = false }
14461446
}
14471447

14481448
private class AccessPathFrontHead extends AccessPathFront, TFrontHead {
@@ -1452,7 +1452,7 @@ private class AccessPathFrontHead extends AccessPathFront, TFrontHead {
14521452
exists(Content head | this = TFrontHead(head) | result = head.getContainerType())
14531453
}
14541454

1455-
override boolean toBool() { result = true }
1455+
override boolean toBoolNonEmpty() { result = true }
14561456
}
14571457

14581458
/**
@@ -1477,6 +1477,16 @@ private predicate flowCandFwd0(
14771477
fromArg = false and
14781478
apf = TFrontNil(node.getErasedNodeTypeBound())
14791479
or
1480+
exists(NodeExt mid |
1481+
flowCandFwd(mid, fromArg, apf, config) and
1482+
localFlowBigStepExt(mid, node, true, _, config)
1483+
)
1484+
or
1485+
exists(NodeExt mid, AccessPathFrontNil nil |
1486+
flowCandFwd(mid, fromArg, nil, config) and
1487+
localFlowBigStepExt(mid, node, false, apf, config)
1488+
)
1489+
or
14801490
nodeCand2(node, unbind(config)) and
14811491
(
14821492
exists(NodeExt mid |
@@ -1518,16 +1528,6 @@ private predicate flowCandFwd0(
15181528
)
15191529
)
15201530
or
1521-
exists(NodeExt mid |
1522-
flowCandFwd(mid, fromArg, apf, config) and
1523-
localFlowBigStepExt(mid, node, true, _, config)
1524-
)
1525-
or
1526-
exists(NodeExt mid, AccessPathFrontNil nil |
1527-
flowCandFwd(mid, fromArg, nil, config) and
1528-
localFlowBigStepExt(mid, node, false, apf, config)
1529-
)
1530-
or
15311531
exists(NodeExt mid, Content f |
15321532
flowCandFwd(mid, fromArg, _, config) and
15331533
storeExtCand2(mid, f, node, config) and
@@ -1538,7 +1538,7 @@ private predicate flowCandFwd0(
15381538
exists(Content f |
15391539
flowCandFwdRead(f, node, fromArg, config) and
15401540
consCandFwd(f, apf, config) and
1541-
nodeCand2(node, _, unbindBool(apf.toBool()), unbind(config))
1541+
nodeCand2(node, _, unbindBool(apf.toBoolNonEmpty()), unbind(config))
15421542
)
15431543
}
15441544

@@ -1897,7 +1897,7 @@ private predicate flowFwdStore1(
18971897
flowFwdStore0(mid, f, node, apf0, config) and
18981898
consCand(f, apf0, config) and
18991899
apf.headUsesContent(f) and
1900-
flowCand(node, _, apf, config)
1900+
flowCand(node, _, apf, unbind(config))
19011901
}
19021902

19031903
pragma[nomagic]
@@ -2025,7 +2025,8 @@ private predicate readFwd(
20252025
) {
20262026
readExtCand2(node1, f, node2, config) and
20272027
flowFwdRead(node2, f, ap, _, config) and
2028-
ap0 = pop(f, ap)
2028+
ap0 = pop(f, ap) and
2029+
flowConsCandFwd(f, _, ap0, unbind(config))
20292030
}
20302031

20312032
pragma[nomagic]

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ abstract private class AccessPathFront extends TAccessPathFront {
14301430

14311431
abstract DataFlowType getType();
14321432

1433-
abstract boolean toBool();
1433+
abstract boolean toBoolNonEmpty();
14341434

14351435
predicate headUsesContent(Content f) { this = TFrontHead(f) }
14361436
}
@@ -1442,7 +1442,7 @@ private class AccessPathFrontNil extends AccessPathFront, TFrontNil {
14421442

14431443
override DataFlowType getType() { this = TFrontNil(result) }
14441444

1445-
override boolean toBool() { result = false }
1445+
override boolean toBoolNonEmpty() { result = false }
14461446
}
14471447

14481448
private class AccessPathFrontHead extends AccessPathFront, TFrontHead {
@@ -1452,7 +1452,7 @@ private class AccessPathFrontHead extends AccessPathFront, TFrontHead {
14521452
exists(Content head | this = TFrontHead(head) | result = head.getContainerType())
14531453
}
14541454

1455-
override boolean toBool() { result = true }
1455+
override boolean toBoolNonEmpty() { result = true }
14561456
}
14571457

14581458
/**
@@ -1477,6 +1477,16 @@ private predicate flowCandFwd0(
14771477
fromArg = false and
14781478
apf = TFrontNil(node.getErasedNodeTypeBound())
14791479
or
1480+
exists(NodeExt mid |
1481+
flowCandFwd(mid, fromArg, apf, config) and
1482+
localFlowBigStepExt(mid, node, true, _, config)
1483+
)
1484+
or
1485+
exists(NodeExt mid, AccessPathFrontNil nil |
1486+
flowCandFwd(mid, fromArg, nil, config) and
1487+
localFlowBigStepExt(mid, node, false, apf, config)
1488+
)
1489+
or
14801490
nodeCand2(node, unbind(config)) and
14811491
(
14821492
exists(NodeExt mid |
@@ -1518,16 +1528,6 @@ private predicate flowCandFwd0(
15181528
)
15191529
)
15201530
or
1521-
exists(NodeExt mid |
1522-
flowCandFwd(mid, fromArg, apf, config) and
1523-
localFlowBigStepExt(mid, node, true, _, config)
1524-
)
1525-
or
1526-
exists(NodeExt mid, AccessPathFrontNil nil |
1527-
flowCandFwd(mid, fromArg, nil, config) and
1528-
localFlowBigStepExt(mid, node, false, apf, config)
1529-
)
1530-
or
15311531
exists(NodeExt mid, Content f |
15321532
flowCandFwd(mid, fromArg, _, config) and
15331533
storeExtCand2(mid, f, node, config) and
@@ -1538,7 +1538,7 @@ private predicate flowCandFwd0(
15381538
exists(Content f |
15391539
flowCandFwdRead(f, node, fromArg, config) and
15401540
consCandFwd(f, apf, config) and
1541-
nodeCand2(node, _, unbindBool(apf.toBool()), unbind(config))
1541+
nodeCand2(node, _, unbindBool(apf.toBoolNonEmpty()), unbind(config))
15421542
)
15431543
}
15441544

@@ -1897,7 +1897,7 @@ private predicate flowFwdStore1(
18971897
flowFwdStore0(mid, f, node, apf0, config) and
18981898
consCand(f, apf0, config) and
18991899
apf.headUsesContent(f) and
1900-
flowCand(node, _, apf, config)
1900+
flowCand(node, _, apf, unbind(config))
19011901
}
19021902

19031903
pragma[nomagic]
@@ -2025,7 +2025,8 @@ private predicate readFwd(
20252025
) {
20262026
readExtCand2(node1, f, node2, config) and
20272027
flowFwdRead(node2, f, ap, _, config) and
2028-
ap0 = pop(f, ap)
2028+
ap0 = pop(f, ap) and
2029+
flowConsCandFwd(f, _, ap0, unbind(config))
20292030
}
20302031

20312032
pragma[nomagic]

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ abstract private class AccessPathFront extends TAccessPathFront {
14301430

14311431
abstract DataFlowType getType();
14321432

1433-
abstract boolean toBool();
1433+
abstract boolean toBoolNonEmpty();
14341434

14351435
predicate headUsesContent(Content f) { this = TFrontHead(f) }
14361436
}
@@ -1442,7 +1442,7 @@ private class AccessPathFrontNil extends AccessPathFront, TFrontNil {
14421442

14431443
override DataFlowType getType() { this = TFrontNil(result) }
14441444

1445-
override boolean toBool() { result = false }
1445+
override boolean toBoolNonEmpty() { result = false }
14461446
}
14471447

14481448
private class AccessPathFrontHead extends AccessPathFront, TFrontHead {
@@ -1452,7 +1452,7 @@ private class AccessPathFrontHead extends AccessPathFront, TFrontHead {
14521452
exists(Content head | this = TFrontHead(head) | result = head.getContainerType())
14531453
}
14541454

1455-
override boolean toBool() { result = true }
1455+
override boolean toBoolNonEmpty() { result = true }
14561456
}
14571457

14581458
/**
@@ -1477,6 +1477,16 @@ private predicate flowCandFwd0(
14771477
fromArg = false and
14781478
apf = TFrontNil(node.getErasedNodeTypeBound())
14791479
or
1480+
exists(NodeExt mid |
1481+
flowCandFwd(mid, fromArg, apf, config) and
1482+
localFlowBigStepExt(mid, node, true, _, config)
1483+
)
1484+
or
1485+
exists(NodeExt mid, AccessPathFrontNil nil |
1486+
flowCandFwd(mid, fromArg, nil, config) and
1487+
localFlowBigStepExt(mid, node, false, apf, config)
1488+
)
1489+
or
14801490
nodeCand2(node, unbind(config)) and
14811491
(
14821492
exists(NodeExt mid |
@@ -1518,16 +1528,6 @@ private predicate flowCandFwd0(
15181528
)
15191529
)
15201530
or
1521-
exists(NodeExt mid |
1522-
flowCandFwd(mid, fromArg, apf, config) and
1523-
localFlowBigStepExt(mid, node, true, _, config)
1524-
)
1525-
or
1526-
exists(NodeExt mid, AccessPathFrontNil nil |
1527-
flowCandFwd(mid, fromArg, nil, config) and
1528-
localFlowBigStepExt(mid, node, false, apf, config)
1529-
)
1530-
or
15311531
exists(NodeExt mid, Content f |
15321532
flowCandFwd(mid, fromArg, _, config) and
15331533
storeExtCand2(mid, f, node, config) and
@@ -1538,7 +1538,7 @@ private predicate flowCandFwd0(
15381538
exists(Content f |
15391539
flowCandFwdRead(f, node, fromArg, config) and
15401540
consCandFwd(f, apf, config) and
1541-
nodeCand2(node, _, unbindBool(apf.toBool()), unbind(config))
1541+
nodeCand2(node, _, unbindBool(apf.toBoolNonEmpty()), unbind(config))
15421542
)
15431543
}
15441544

@@ -1897,7 +1897,7 @@ private predicate flowFwdStore1(
18971897
flowFwdStore0(mid, f, node, apf0, config) and
18981898
consCand(f, apf0, config) and
18991899
apf.headUsesContent(f) and
1900-
flowCand(node, _, apf, config)
1900+
flowCand(node, _, apf, unbind(config))
19011901
}
19021902

19031903
pragma[nomagic]
@@ -2025,7 +2025,8 @@ private predicate readFwd(
20252025
) {
20262026
readExtCand2(node1, f, node2, config) and
20272027
flowFwdRead(node2, f, ap, _, config) and
2028-
ap0 = pop(f, ap)
2028+
ap0 = pop(f, ap) and
2029+
flowConsCandFwd(f, _, ap0, unbind(config))
20292030
}
20302031

20312032
pragma[nomagic]

0 commit comments

Comments
 (0)