Skip to content

Commit 133f087

Browse files
committed
C++: Eliminate dead code, uncertain is always false.
1 parent e8e9403 commit 133f087

File tree

1 file changed

+9
-35
lines changed

1 file changed

+9
-35
lines changed

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

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,15 +1879,6 @@ module IteratorFlow {
18791879
phi.definesAt(sv, bb2, i2, _)
18801880
)
18811881
}
1882-
1883-
cached
1884-
Node getAPriorDefinition(IteratorSsa::DefinitionExt next) {
1885-
exists(IRBlock bb, int i, SourceVariable sv, IteratorSsa::DefinitionExt def |
1886-
IteratorSsa::lastRefRedefExt(pragma[only_bind_into](def), pragma[only_bind_into](sv),
1887-
pragma[only_bind_into](bb), pragma[only_bind_into](i), next) and
1888-
nodeToDefOrUse(result, sv, bb, i, _)
1889-
)
1890-
}
18911882
}
18921883

18931884
/** The set of nodes necessary for iterator flow. */
@@ -1912,25 +1903,19 @@ module IteratorFlow {
19121903

19131904
private import IteratorSsaCached
19141905

1915-
private predicate defToNode(Node node, Def def, boolean uncertain) {
1916-
(
1917-
nodeHasOperand(node, def.getValue().asOperand(), def.getIndirectionIndex())
1918-
or
1919-
nodeHasInstruction(node, def.getValue().asInstruction(), def.getIndirectionIndex())
1920-
) and
1921-
uncertain = false
1906+
private predicate defToNode(Node node, Def def) {
1907+
nodeHasOperand(node, def.getValue().asOperand(), def.getIndirectionIndex())
1908+
or
1909+
nodeHasInstruction(node, def.getValue().asInstruction(), def.getIndirectionIndex())
19221910
}
19231911

1924-
private predicate nodeToDefOrUse(
1925-
Node node, SourceVariable sv, IRBlock bb, int i, boolean uncertain
1926-
) {
1912+
private predicate nodeToDefOrUse(Node node, SourceVariable sv, IRBlock bb, int i) {
19271913
exists(Def def |
19281914
def.hasIndexInBlock(bb, i, sv) and
1929-
defToNode(node, def, uncertain)
1915+
defToNode(node, def)
19301916
)
19311917
or
1932-
useToNode(bb, i, sv, node) and
1933-
uncertain = false
1918+
useToNode(bb, i, sv, node)
19341919
}
19351920

19361921
private predicate useToNode(IRBlock bb, int i, SourceVariable sv, Node nodeTo) {
@@ -1949,21 +1934,10 @@ module IteratorFlow {
19491934
* Holds if `nodeFrom` flows to `nodeTo` in a single step.
19501935
*/
19511936
predicate localFlowStep(Node nodeFrom, Node nodeTo) {
1952-
exists(
1953-
Node nFrom, SourceVariable sv, IRBlock bb1, int i1, IRBlock bb2, int i2, boolean uncertain
1954-
|
1937+
exists(SourceVariable sv, IRBlock bb1, int i1, IRBlock bb2, int i2 |
19551938
adjacentDefRead(bb1, i1, sv, bb2, i2) and
1956-
nodeToDefOrUse(nFrom, sv, bb1, i1, uncertain) and
1939+
nodeToDefOrUse(nodeFrom, sv, bb1, i1) and
19571940
useToNode(bb2, i2, sv, nodeTo)
1958-
|
1959-
if uncertain = true
1960-
then
1961-
nodeFrom =
1962-
[
1963-
nFrom,
1964-
getAPriorDefinition(any(IteratorSsa::DefinitionExt next | next.definesAt(sv, bb1, i1, _)))
1965-
]
1966-
else nFrom = nodeFrom
19671941
)
19681942
}
19691943
}

0 commit comments

Comments
 (0)