mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
C++: Make getStaticCallTarget() return a DataFlowCallable.
This commit is contained in:
@@ -65,7 +65,7 @@ module Input implements InputSig<DataFlowImplSpecific::CppDataFlow> {
|
||||
private import Make<DataFlowImplSpecific::CppDataFlow, Input> as Impl
|
||||
|
||||
private module StepsInput implements Impl::Private::StepsInputSig {
|
||||
DataFlowCall getACall(Public::SummarizedCallable sc) { result.getStaticCallTarget() = sc }
|
||||
DataFlowCall getACall(Public::SummarizedCallable sc) { result.getStaticCallTarget() = TSummarizedCallable(sc) }
|
||||
}
|
||||
|
||||
module SourceSinkInterpretationInput implements
|
||||
@@ -125,7 +125,7 @@ module SourceSinkInterpretationInput implements
|
||||
}
|
||||
|
||||
/** Gets the target of this call, if any. */
|
||||
Element getCallTarget() { result = this.asCall().getStaticCallTarget() }
|
||||
Element getCallTarget() { result = this.asCall().getStaticCallTarget().asSourceCallable() } // TODO: summarized target???
|
||||
|
||||
/** Gets a textual representation of this node. */
|
||||
string toString() {
|
||||
|
||||
@@ -14,7 +14,7 @@ private import DataFlowImplCommon as DataFlowImplCommon
|
||||
cached
|
||||
DataFlowCallable defaultViableCallable(DataFlowCall call) {
|
||||
DataFlowImplCommon::forceCachingInSameStage() and
|
||||
result = TSourceCallable(call.getStaticCallTarget())
|
||||
result = call.getStaticCallTarget()
|
||||
or
|
||||
// If the target of the call does not have a body in the snapshot, it might
|
||||
// be because the target is just a header declaration, and the real target
|
||||
@@ -80,7 +80,7 @@ private module VirtualDispatch {
|
||||
exists(DataFlowCall call, Position i |
|
||||
other
|
||||
.(DataFlow::ParameterNode)
|
||||
.isParameterOf(TSourceCallable(pragma[only_bind_into](call).getStaticCallTarget()), i) and
|
||||
.isParameterOf(pragma[only_bind_into](call).getStaticCallTarget(), i) and
|
||||
src.(ArgumentNode).argumentOf(call, pragma[only_bind_into](pragma[only_bind_out](i)))
|
||||
) and
|
||||
allowOtherFromArg = true and
|
||||
@@ -89,7 +89,7 @@ private module VirtualDispatch {
|
||||
// Call return
|
||||
exists(DataFlowCall call, ReturnKind returnKind |
|
||||
other = getAnOutNode(call, returnKind) and
|
||||
returnNodeWithKindAndEnclosingCallable(src, returnKind, TSourceCallable(call.getStaticCallTarget()))
|
||||
returnNodeWithKindAndEnclosingCallable(src, returnKind, call.getStaticCallTarget())
|
||||
) and
|
||||
allowFromArg = false
|
||||
or
|
||||
@@ -176,7 +176,7 @@ private module VirtualDispatch {
|
||||
/** Call to a virtual function. */
|
||||
private class DataSensitiveOverriddenFunctionCall extends DataSensitiveCall {
|
||||
DataSensitiveOverriddenFunctionCall() {
|
||||
exists(this.getStaticCallTarget().(VirtualFunction).getAnOverridingFunction())
|
||||
exists(this.getStaticCallTarget().asSourceCallable().(VirtualFunction).getAnOverridingFunction())
|
||||
}
|
||||
|
||||
override DataFlow::Node getDispatchValue() { result.asInstruction() = this.getArgument(-1) }
|
||||
@@ -194,7 +194,7 @@ private module VirtualDispatch {
|
||||
*/
|
||||
pragma[noinline]
|
||||
private predicate overrideMayAffectCall(Class overridingClass, MemberFunction overridingFunction) {
|
||||
overridingFunction.getAnOverriddenFunction+() = this.getStaticCallTarget().(VirtualFunction) and
|
||||
overridingFunction.getAnOverriddenFunction+() = this.getStaticCallTarget().asSourceCallable().(VirtualFunction) and
|
||||
overridingFunction.getDeclaringType() = overridingClass
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ DataFlowCallable viableImplInCallContext(DataFlowCall call, DataFlowCall ctx) {
|
||||
result = viableCallable(call) and
|
||||
exists(int i, DataFlowCallable f |
|
||||
mayBenefitFromCallContext(pragma[only_bind_into](call), f, i) and
|
||||
f.asSourceCallable() = ctx.getStaticCallTarget() and
|
||||
f = ctx.getStaticCallTarget() and
|
||||
result = TSourceCallable(ctx.getArgument(i).getUnconvertedResultExpression().(FunctionAccess).getTarget())
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1028,7 +1028,7 @@ class DataFlowCall extends TDataFlowCall {
|
||||
/**
|
||||
* Gets the `Function` that the call targets, if this is statically known.
|
||||
*/
|
||||
Function getStaticCallTarget() { none() } // TODO: should this return DataFlowCallable?
|
||||
DataFlowCallable getStaticCallTarget() { none() } // TODO: should this return DataFlowCallable?
|
||||
|
||||
/**
|
||||
* Gets the `index`'th argument operand. The qualifier is considered to have index `-1`.
|
||||
@@ -1071,7 +1071,7 @@ private class NormalCall extends DataFlowCall, TNormalCall {
|
||||
|
||||
override CallTargetOperand getCallTargetOperand() { result = call.getCallTargetOperand() }
|
||||
|
||||
override Function getStaticCallTarget() { result = call.getStaticCallTarget() }
|
||||
override DataFlowCallable getStaticCallTarget() { result = TSourceCallable(call.getStaticCallTarget()) }
|
||||
|
||||
override ArgumentOperand getArgumentOperand(int index) {
|
||||
result = call.getArgumentOperand(index)
|
||||
@@ -1095,8 +1095,8 @@ class SummaryCall extends DataFlowCall, TSummaryCall {
|
||||
|
||||
// override CallTargetOperand getCallTargetOperand() TODO
|
||||
|
||||
override Function getStaticCallTarget() { // TODO: should this return DataFlowCallable?
|
||||
result = c
|
||||
override DataFlowCallable getStaticCallTarget() {
|
||||
result = TSummarizedCallable(c)
|
||||
}
|
||||
|
||||
// override ArgumentOperand getArgumentOperand(int index) TODO
|
||||
|
||||
Reference in New Issue
Block a user