mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C++: Add isParameterDerefOrQualifierObject helper predicate to FunctionInput and FunctionOutput.
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user