C++: Add DataFlow::instructionNode

This is for symmetry with `exprNode` etc., and it should be handy for
the same reasons. I found one caller of `asInstruction` that got simpler
by using the new predicate instead.
This commit is contained in:
Jonas Jensen
2019-09-12 11:44:17 +02:00
parent 10076a6b2b
commit c7e6081079
2 changed files with 6 additions and 4 deletions

View File

@@ -22,10 +22,7 @@ private predicate predictable(Expr expr) {
// TODO: remove when `predictable` has an `Instruction` parameter instead of `Expr`.
private predicate predictableInstruction(Instruction instr) {
exists(DataFlow::Node node |
node.asInstruction() = instr and
predictable(node.asExpr())
)
predictable(DataFlow::instructionNode(instr).asExpr())
}
private class DefaultTaintTrackingCfg extends DataFlow::Configuration {

View File

@@ -156,6 +156,11 @@ abstract class PostUpdateNode extends Node {
abstract Node getPreUpdateNode();
}
/**
* Gets the node corresponding to `instr`.
*/
Node instructionNode(Instruction instr) { result.asInstruction() = instr }
/**
* Gets a `Node` corresponding to `e` or any of its conversions. There is no
* result if `e` is a `Conversion`.