mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C++: Eliminate dead code, uncertain is always false.
This commit is contained in:
@@ -1879,15 +1879,6 @@ module IteratorFlow {
|
|||||||
phi.definesAt(sv, bb2, i2, _)
|
phi.definesAt(sv, bb2, i2, _)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
Node getAPriorDefinition(IteratorSsa::DefinitionExt next) {
|
|
||||||
exists(IRBlock bb, int i, SourceVariable sv, IteratorSsa::DefinitionExt def |
|
|
||||||
IteratorSsa::lastRefRedefExt(pragma[only_bind_into](def), pragma[only_bind_into](sv),
|
|
||||||
pragma[only_bind_into](bb), pragma[only_bind_into](i), next) and
|
|
||||||
nodeToDefOrUse(result, sv, bb, i, _)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The set of nodes necessary for iterator flow. */
|
/** The set of nodes necessary for iterator flow. */
|
||||||
@@ -1912,25 +1903,19 @@ module IteratorFlow {
|
|||||||
|
|
||||||
private import IteratorSsaCached
|
private import IteratorSsaCached
|
||||||
|
|
||||||
private predicate defToNode(Node node, Def def, boolean uncertain) {
|
private predicate defToNode(Node node, Def def) {
|
||||||
(
|
nodeHasOperand(node, def.getValue().asOperand(), def.getIndirectionIndex())
|
||||||
nodeHasOperand(node, def.getValue().asOperand(), def.getIndirectionIndex())
|
or
|
||||||
or
|
nodeHasInstruction(node, def.getValue().asInstruction(), def.getIndirectionIndex())
|
||||||
nodeHasInstruction(node, def.getValue().asInstruction(), def.getIndirectionIndex())
|
|
||||||
) and
|
|
||||||
uncertain = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private predicate nodeToDefOrUse(
|
private predicate nodeToDefOrUse(Node node, SourceVariable sv, IRBlock bb, int i) {
|
||||||
Node node, SourceVariable sv, IRBlock bb, int i, boolean uncertain
|
|
||||||
) {
|
|
||||||
exists(Def def |
|
exists(Def def |
|
||||||
def.hasIndexInBlock(bb, i, sv) and
|
def.hasIndexInBlock(bb, i, sv) and
|
||||||
defToNode(node, def, uncertain)
|
defToNode(node, def)
|
||||||
)
|
)
|
||||||
or
|
or
|
||||||
useToNode(bb, i, sv, node) and
|
useToNode(bb, i, sv, node)
|
||||||
uncertain = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private predicate useToNode(IRBlock bb, int i, SourceVariable sv, Node nodeTo) {
|
private predicate useToNode(IRBlock bb, int i, SourceVariable sv, Node nodeTo) {
|
||||||
@@ -1949,21 +1934,10 @@ module IteratorFlow {
|
|||||||
* Holds if `nodeFrom` flows to `nodeTo` in a single step.
|
* Holds if `nodeFrom` flows to `nodeTo` in a single step.
|
||||||
*/
|
*/
|
||||||
predicate localFlowStep(Node nodeFrom, Node nodeTo) {
|
predicate localFlowStep(Node nodeFrom, Node nodeTo) {
|
||||||
exists(
|
exists(SourceVariable sv, IRBlock bb1, int i1, IRBlock bb2, int i2 |
|
||||||
Node nFrom, SourceVariable sv, IRBlock bb1, int i1, IRBlock bb2, int i2, boolean uncertain
|
|
||||||
|
|
|
||||||
adjacentDefRead(bb1, i1, sv, bb2, i2) and
|
adjacentDefRead(bb1, i1, sv, bb2, i2) and
|
||||||
nodeToDefOrUse(nFrom, sv, bb1, i1, uncertain) and
|
nodeToDefOrUse(nodeFrom, sv, bb1, i1) and
|
||||||
useToNode(bb2, i2, sv, nodeTo)
|
useToNode(bb2, i2, sv, nodeTo)
|
||||||
|
|
|
||||||
if uncertain = true
|
|
||||||
then
|
|
||||||
nodeFrom =
|
|
||||||
[
|
|
||||||
nFrom,
|
|
||||||
getAPriorDefinition(any(IteratorSsa::DefinitionExt next | next.definesAt(sv, bb1, i1, _)))
|
|
||||||
]
|
|
||||||
else nFrom = nodeFrom
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user