C++: Use the new predicates in IR dataflow.

This commit is contained in:
Mathias Vorreiter Pedersen
2020-11-20 12:24:39 +01:00
parent f3b5d7b830
commit c7efc91676
2 changed files with 8 additions and 20 deletions

View File

@@ -29,9 +29,7 @@ private class PrimaryArgumentNode extends ArgumentNode {
PrimaryArgumentNode() { exists(CallInstruction call | op = call.getAnArgumentOperand()) }
override predicate argumentOf(DataFlowCall call, int pos) {
op = call.getPositionalArgumentOperand(pos)
or
op = call.getThisArgumentOperand() and pos = -1
op = call.getPositionalOrThisArgumentOperand(pos)
}
override string toString() {
@@ -110,10 +108,10 @@ class ReturnIndirectionNode extends ReturnNode {
override ReturnIndirectionInstruction primary;
override ReturnKind getKind() {
result = TIndirectReturnKind(-1) and
primary.isThisIndirection()
or
result = TIndirectReturnKind(primary.getParameter().getIndex())
exists(int index |
primary.isParameterOrThisIndirection(index) and
result = TIndirectReturnKind(index)
)
}
}

View File

@@ -266,10 +266,8 @@ class ParameterIndirectionNode extends ParameterNode {
override predicate isParameterOf(Function f, int pos) {
exists(int index |
f.getParameter(index) = instr.getParameter()
or
index = -1 and
instr.getIRVariable().(IRThisVariable).getEnclosingFunction() = f
instr.getEnclosingFunction() = f and
instr.isParameterOrQualifierIndex(index)
|
pos = getArgumentPosOfSideEffect(index)
)
@@ -476,16 +474,8 @@ class DefinitionByReferenceNode extends InstructionNode {
instr
.getPrimaryInstruction()
.(CallInstruction)
.getPositionalArgument(instr.getIndex())
.getPositionalOrThisArgument(instr.getIndex())
.getUnconvertedResultExpression()
or
result =
instr
.getPrimaryInstruction()
.(CallInstruction)
.getThisArgument()
.getUnconvertedResultExpression() and
instr.getIndex() = -1
}
/** Gets the parameter through which this value is assigned. */