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

Skip to content

Commit 03d0d98

Browse files
committed
C++: Remove duplicate TDataFlowCallable's and fix three places where we assumed a source callable (two of them would have caused lost results).
1 parent a55f07a commit 03d0d98

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ private module IndirectInstructions {
330330
import IndirectInstructions
331331

332332
/** Gets the callable in which this node occurs. */
333-
DataFlowCallable nodeGetEnclosingCallable(Node n) { result.asSourceCallable() = n.getEnclosingCallable() }
333+
DataFlowCallable nodeGetEnclosingCallable(Node n) {
334+
result.getUnderlyingCallable() = n.getEnclosingCallable()
335+
}
334336

335337
/** Holds if `p` is a `ParameterNode` of `c` with position `pos`. */
336338
predicate isParameterNode(ParameterNode p, DataFlowCallable c, ParameterPosition pos) {
@@ -988,9 +990,9 @@ class CastNode extends Node {
988990

989991
cached
990992
newtype TDataFlowCallable =
991-
TSourceCallable(Cpp::Declaration decl) or
992-
/*{ not decl instanceof FlowSummaryImpl::Public::SummarizedCallable }*/ TSummarizedCallable(
993-
// TODO: figure this out
993+
TSourceCallable(Cpp::Declaration decl) { not decl instanceof FlowSummaryImpl::Public::SummarizedCallable }
994+
or
995+
TSummarizedCallable(
994996
FlowSummaryImpl::Public::SummarizedCallable c
995997
)
996998

@@ -1128,13 +1130,13 @@ private class NormalCall extends DataFlowCall, TNormalCall {
11281130
override CallTargetOperand getCallTargetOperand() { result = call.getCallTargetOperand() }
11291131

11301132
override DataFlowCallable getStaticCallTarget() {
1131-
result = TSourceCallable(call.getStaticCallTarget())
1133+
result.getUnderlyingCallable() = call.getStaticCallTarget()
11321134
}
11331135

11341136
override ArgumentOperand getArgumentOperand(int index) { result = call.getArgumentOperand(index) }
11351137

11361138
override DataFlowCallable getEnclosingCallable() {
1137-
result = TSourceCallable(call.getEnclosingFunction())
1139+
result.getUnderlyingCallable() = call.getEnclosingFunction()
11381140
}
11391141

11401142
override string toString() { result = call.toString() }

0 commit comments

Comments
 (0)