C++: Add isParameterDerefOrQualifierObject helper predicate to FunctionInput and FunctionOutput.

This commit is contained in:
Mathias Vorreiter Pedersen
2020-11-17 16:12:39 +01:00
parent dea16d4d62
commit 4cb25d8e18
2 changed files with 22 additions and 2 deletions

View File

@@ -132,6 +132,16 @@ class FunctionInput extends TFunctionInput {
* part of itself, or one of its other inputs.
*/
predicate isReturnValueDeref() { none() }
/**
* Holds if `i >= 0` and `isParameterDeref(i)` holds for this is value, or
* if `i = -1` and `isQualifierObject()` holds for this value.
*/
final predicate isParameterDerefOrQualifierObject(ParameterIndex i) {
i >= 0 and this.isParameterDeref(i)
or
i = -1 and this.isQualifierObject()
}
}
/**
@@ -370,6 +380,16 @@ class FunctionOutput extends TFunctionOutput {
* DEPRECATED: Use `isReturnValueDeref()` instead.
*/
deprecated final predicate isOutReturnPointer() { isReturnValueDeref() }
/**
* Holds if `i >= 0` and `isParameterDeref(i)` holds for this is the value, or
* if `i = -1` and `isQualifierObject()` holds for this value.
*/
final predicate isParameterDerefOrQualifierObject(ParameterIndex i) {
i >= 0 and this.isParameterDeref(i)
or
i = -1 and this.isQualifierObject()
}
}
/**

View File

@@ -46,7 +46,7 @@ private class RemoteParameterSource extends RemoteFlowSource {
asInstruction() = instr and
instr.getPrimaryInstruction().(CallInstruction).getStaticCallTarget() = func and
func.hasRemoteFlowSource(output, sourceType) and
output.isParameterDeref(instr.getIndex())
output.isParameterDerefOrQualifierObject(instr.getIndex())
)
}
@@ -80,7 +80,7 @@ private class LocalParameterSource extends LocalFlowSource {
asInstruction() = instr and
instr.getPrimaryInstruction().(CallInstruction).getStaticCallTarget() = func and
func.hasLocalFlowSource(output, sourceType) and
output.isParameterDeref(instr.getIndex())
output.isParameterDerefOrQualifierObject(instr.getIndex())
)
}