C++: Add FlowSummaryNode and test it.

This commit is contained in:
Geoffrey White
2024-02-14 10:21:51 +00:00
parent e187a4a7d6
commit 6e13b877bb
3 changed files with 59 additions and 1 deletions

View File

@@ -57,7 +57,8 @@ private newtype TIRDataFlowNode =
hasFinalParameterNode(_, p, indirectionIndex)
} or
TFinalGlobalValue(Ssa::GlobalUse globalUse) or
TInitialGlobalValue(Ssa::GlobalDef globalUse)
TInitialGlobalValue(Ssa::GlobalDef globalUse) or
TFlowSummaryNode(FlowSummaryImpl::Private::SummaryNode sn)
/**
* Holds if `(p, indirectionIndex)` should define a `TFinalParameterNode`
@@ -760,6 +761,31 @@ class InitialGlobalValue extends Node, TInitialGlobalValue {
override string toStringImpl() { result = globalDef.toString() }
}
/**
* A data-flow node used to model flow summaries.
*/
class FlowSummaryNode extends Node, TFlowSummaryNode {
FlowSummaryImpl::Private::SummaryNode getSummaryNode() { this = TFlowSummaryNode(result) }
/**
* TODO: QLDoc.
*/
FlowSummaryImpl::Public::SummarizedCallable getSummarizedCallable() {
result = this.getSummaryNode().getSummarizedCallable()
}
/**
* TODO: QLDoc.
*/
override DataFlowCallable getEnclosingCallable() {
none() //result.asSummarizedCallable() = this.getSummarizedCallable() TODO
}
override Location getLocationImpl() { result = this.getSummarizedCallable().getLocation() }
override string toStringImpl() { result = this.getSummaryNode().toString() }
}
/**
* INTERNAL: do not use.
*