C++: Remove duplicate TDataFlowCallable's and fix three places where we assumed a source callable (two of them would have caused lost results).

This commit is contained in:
Geoffrey White
2024-03-27 18:03:05 +00:00
parent a55f07ac68
commit 03d0d984e3

View File

@@ -330,7 +330,9 @@ private module IndirectInstructions {
import IndirectInstructions
/** Gets the callable in which this node occurs. */
DataFlowCallable nodeGetEnclosingCallable(Node n) { result.asSourceCallable() = n.getEnclosingCallable() }
DataFlowCallable nodeGetEnclosingCallable(Node n) {
result.getUnderlyingCallable() = n.getEnclosingCallable()
}
/** Holds if `p` is a `ParameterNode` of `c` with position `pos`. */
predicate isParameterNode(ParameterNode p, DataFlowCallable c, ParameterPosition pos) {
@@ -988,9 +990,9 @@ class CastNode extends Node {
cached
newtype TDataFlowCallable =
TSourceCallable(Cpp::Declaration decl) or
/*{ not decl instanceof FlowSummaryImpl::Public::SummarizedCallable }*/ TSummarizedCallable(
// TODO: figure this out
TSourceCallable(Cpp::Declaration decl) { not decl instanceof FlowSummaryImpl::Public::SummarizedCallable }
or
TSummarizedCallable(
FlowSummaryImpl::Public::SummarizedCallable c
)
@@ -1128,13 +1130,13 @@ private class NormalCall extends DataFlowCall, TNormalCall {
override CallTargetOperand getCallTargetOperand() { result = call.getCallTargetOperand() }
override DataFlowCallable getStaticCallTarget() {
result = TSourceCallable(call.getStaticCallTarget())
result.getUnderlyingCallable() = call.getStaticCallTarget()
}
override ArgumentOperand getArgumentOperand(int index) { result = call.getArgumentOperand(index) }
override DataFlowCallable getEnclosingCallable() {
result = TSourceCallable(call.getEnclosingFunction())
result.getUnderlyingCallable() = call.getEnclosingFunction()
}
override string toString() { result = call.toString() }