Introduce DataFlow::Node.getBasicBlock() and use it.

This commit is contained in:
Max Schaefer
2019-11-25 09:14:15 +00:00
parent 1ff032d11e
commit cdb843516a
3 changed files with 7 additions and 4 deletions

View File

@@ -27,7 +27,7 @@ where
cond.ensuresNeq(lenA, const) or
cond.ensuresLeq(const, lenA, _)
) and
cond.dominates(idx.asInstruction().getBasicBlock()) and
cond.dominates(idx.getBasicBlock()) and
// and that check happens inside the loop body
cond.getCondition().getParent+() = fs.getBody()
select cond.getCondition(),

View File

@@ -66,7 +66,7 @@ predicate elementRead(
) {
ea.reads(array.getAUse(), getAUse(index)) and
not array.getType().getUnderlyingType() instanceof MapType and
bb = ea.asInstruction().getBasicBlock()
bb = ea.getBasicBlock()
}
predicate isRegexpMethodCall(DataFlow::MethodCallNode c) {

View File

@@ -40,6 +40,9 @@ class Node extends TNode {
/** Gets a textual representation of the kind of this data-flow node. */
string getNodeKind() { none() } // overridden in subclasses
/** Gets the basic block to which this data-flow node belongs, if any. */
BasicBlock getBasicBlock() { result = asInstruction().getBasicBlock() }
/** Gets a textual representation of this element. */
string toString() { result = "data-flow node" } // overridden in subclasses
@@ -752,7 +755,7 @@ abstract class BarrierGuard extends Node {
result = var.getAUse()
|
guards(guard, nd, var) and
guard.dominates(result.asInstruction().getBasicBlock())
guard.dominates(result.getBasicBlock())
)
}
@@ -807,7 +810,7 @@ abstract class BarrierGuard extends Node {
guards(guard, arg) and
localFlow(inp.getExitNode(fd), arg) and
ret = outp.getEntryNode(fd) and
guard.dominates(ret.asInstruction().getBasicBlock())
guard.dominates(ret.getBasicBlock())
|
exists(boolean b |
onlyPossibleReturnOfBool(fd, outp, ret, b) and