Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5787dcc

Browse files
committed
C++: Make getStaticCallTarget() return a DataFlowCallable.
1 parent 356214c commit 5787dcc

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module Input implements InputSig<DataFlowImplSpecific::CppDataFlow> {
6565
private import Make<DataFlowImplSpecific::CppDataFlow, Input> as Impl
6666

6767
private module StepsInput implements Impl::Private::StepsInputSig {
68-
DataFlowCall getACall(Public::SummarizedCallable sc) { result.getStaticCallTarget() = sc }
68+
DataFlowCall getACall(Public::SummarizedCallable sc) { result.getStaticCallTarget() = TSummarizedCallable(sc) }
6969
}
7070

7171
module SourceSinkInterpretationInput implements
@@ -125,7 +125,7 @@ module SourceSinkInterpretationInput implements
125125
}
126126

127127
/** Gets the target of this call, if any. */
128-
Element getCallTarget() { result = this.asCall().getStaticCallTarget() }
128+
Element getCallTarget() { result = this.asCall().getStaticCallTarget().asSourceCallable() } // TODO: summarized target???
129129

130130
/** Gets a textual representation of this node. */
131131
string toString() {

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowDispatch.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private import DataFlowImplCommon as DataFlowImplCommon
1414
cached
1515
DataFlowCallable defaultViableCallable(DataFlowCall call) {
1616
DataFlowImplCommon::forceCachingInSameStage() and
17-
result = TSourceCallable(call.getStaticCallTarget())
17+
result = call.getStaticCallTarget()
1818
or
1919
// If the target of the call does not have a body in the snapshot, it might
2020
// be because the target is just a header declaration, and the real target
@@ -80,7 +80,7 @@ private module VirtualDispatch {
8080
exists(DataFlowCall call, Position i |
8181
other
8282
.(DataFlow::ParameterNode)
83-
.isParameterOf(TSourceCallable(pragma[only_bind_into](call).getStaticCallTarget()), i) and
83+
.isParameterOf(pragma[only_bind_into](call).getStaticCallTarget(), i) and
8484
src.(ArgumentNode).argumentOf(call, pragma[only_bind_into](pragma[only_bind_out](i)))
8585
) and
8686
allowOtherFromArg = true and
@@ -89,7 +89,7 @@ private module VirtualDispatch {
8989
// Call return
9090
exists(DataFlowCall call, ReturnKind returnKind |
9191
other = getAnOutNode(call, returnKind) and
92-
returnNodeWithKindAndEnclosingCallable(src, returnKind, TSourceCallable(call.getStaticCallTarget()))
92+
returnNodeWithKindAndEnclosingCallable(src, returnKind, call.getStaticCallTarget())
9393
) and
9494
allowFromArg = false
9595
or
@@ -176,7 +176,7 @@ private module VirtualDispatch {
176176
/** Call to a virtual function. */
177177
private class DataSensitiveOverriddenFunctionCall extends DataSensitiveCall {
178178
DataSensitiveOverriddenFunctionCall() {
179-
exists(this.getStaticCallTarget().(VirtualFunction).getAnOverridingFunction())
179+
exists(this.getStaticCallTarget().asSourceCallable().(VirtualFunction).getAnOverridingFunction())
180180
}
181181

182182
override DataFlow::Node getDispatchValue() { result.asInstruction() = this.getArgument(-1) }
@@ -194,7 +194,7 @@ private module VirtualDispatch {
194194
*/
195195
pragma[noinline]
196196
private predicate overrideMayAffectCall(Class overridingClass, MemberFunction overridingFunction) {
197-
overridingFunction.getAnOverriddenFunction+() = this.getStaticCallTarget().(VirtualFunction) and
197+
overridingFunction.getAnOverriddenFunction+() = this.getStaticCallTarget().asSourceCallable().(VirtualFunction) and
198198
overridingFunction.getDeclaringType() = overridingClass
199199
}
200200

@@ -277,7 +277,7 @@ DataFlowCallable viableImplInCallContext(DataFlowCall call, DataFlowCall ctx) {
277277
result = viableCallable(call) and
278278
exists(int i, DataFlowCallable f |
279279
mayBenefitFromCallContext(pragma[only_bind_into](call), f, i) and
280-
f.asSourceCallable() = ctx.getStaticCallTarget() and
280+
f = ctx.getStaticCallTarget() and
281281
result = TSourceCallable(ctx.getArgument(i).getUnconvertedResultExpression().(FunctionAccess).getTarget())
282282
)
283283
}

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ class DataFlowCall extends TDataFlowCall {
10281028
/**
10291029
* Gets the `Function` that the call targets, if this is statically known.
10301030
*/
1031-
Function getStaticCallTarget() { none() } // TODO: should this return DataFlowCallable?
1031+
DataFlowCallable getStaticCallTarget() { none() } // TODO: should this return DataFlowCallable?
10321032

10331033
/**
10341034
* Gets the `index`'th argument operand. The qualifier is considered to have index `-1`.
@@ -1071,7 +1071,7 @@ private class NormalCall extends DataFlowCall, TNormalCall {
10711071

10721072
override CallTargetOperand getCallTargetOperand() { result = call.getCallTargetOperand() }
10731073

1074-
override Function getStaticCallTarget() { result = call.getStaticCallTarget() }
1074+
override DataFlowCallable getStaticCallTarget() { result = TSourceCallable(call.getStaticCallTarget()) }
10751075

10761076
override ArgumentOperand getArgumentOperand(int index) {
10771077
result = call.getArgumentOperand(index)
@@ -1095,8 +1095,8 @@ class SummaryCall extends DataFlowCall, TSummaryCall {
10951095

10961096
// override CallTargetOperand getCallTargetOperand() TODO
10971097

1098-
override Function getStaticCallTarget() { // TODO: should this return DataFlowCallable?
1099-
result = c
1098+
override DataFlowCallable getStaticCallTarget() {
1099+
result = TSummarizedCallable(c)
11001100
}
11011101

11021102
// override ArgumentOperand getArgumentOperand(int index) TODO

0 commit comments

Comments
 (0)