Dataflow: Add support for C#/Python/Ruby/Swift.

This commit is contained in:
Anders Schack-Mulligen
2022-10-13 14:29:27 +02:00
parent 69bf13b1d4
commit f1634d3dca
8 changed files with 24 additions and 1 deletions

View File

@@ -1581,6 +1581,8 @@ predicate jumpStep(Node pred, Node succ) {
jrk.getTarget() = call.getATarget(_) and
succ = getAnOutNode(call, jrk.getTargetReturnKind())
)
or
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred, succ)
}
private class StoreStepConfiguration extends ControlFlowReachabilityConfiguration {

View File

@@ -91,6 +91,12 @@ DataFlowType getCallbackReturnType(DataFlowType t, ReturnKind rk) {
)
}
/** Gets the type of synthetic global `sg`. */
DataFlowType getSyntheticGlobalType(SummaryComponent::SyntheticGlobal sg) {
exists(sg) and
result = Gvn::getGlobalValueNumber(any(ObjectType t))
}
bindingset[provenance]
private boolean isGenerated(string provenance) {
provenance = "generated" and result = true

View File

@@ -453,6 +453,8 @@ predicate jumpStep(Node nodeFrom, Node nodeTo) {
jumpStepSharedWithTypeTracker(nodeFrom, nodeTo)
or
jumpStepNotSharedWithTypeTracker(nodeFrom, nodeTo)
or
FlowSummaryImpl::Private::Steps::summaryJumpStep(nodeFrom, nodeTo)
}
/**

View File

@@ -73,6 +73,9 @@ DataFlowType getCallbackParameterType(DataFlowType t, int i) { any() }
*/
DataFlowType getCallbackReturnType(DataFlowType t, ReturnKind rk) { any() }
/** Gets the type of synthetic global `sg`. */
DataFlowType getSyntheticGlobalType(SummaryComponent::SyntheticGlobal sg) { any() }
/**
* Holds if an external flow summary exists for `c` with input specification
* `input`, output specification `output`, kind `kind`, and a flag `generated`

View File

@@ -1003,6 +1003,8 @@ predicate jumpStep(Node pred, Node succ) {
succ.(SsaDefinitionNode).getDefinition())
or
succ.asExpr().getExpr().(ConstantReadAccess).getValue() = pred.asExpr().getExpr()
or
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred, succ)
}
private ContentSet getKeywordContent(string name) {

View File

@@ -44,6 +44,9 @@ DataFlowType getCallbackParameterType(DataFlowType t, ArgumentPosition pos) { an
*/
DataFlowType getCallbackReturnType(DataFlowType t, ReturnKind rk) { any() }
/** Gets the type of synthetic global `sg`. */
DataFlowType getSyntheticGlobalType(SummaryComponent::SyntheticGlobal sg) { any() }
/**
* Holds if an external flow summary exists for `c` with input specification
* `input`, output specification `output`, kind `kind`, and a flag `generated`

View File

@@ -486,7 +486,9 @@ private module OutNodes {
import OutNodes
predicate jumpStep(Node pred, Node succ) { none() }
predicate jumpStep(Node pred, Node succ) {
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred, succ)
}
predicate storeStep(Node node1, ContentSet c, Node node2) {
exists(MemberRefExpr ref, AssignExpr assign |

View File

@@ -51,6 +51,9 @@ DataFlowType getCallbackReturnType(DataFlowType t, ReturnKind rk) {
any() // TODO once we have type pruning
}
/** Gets the type of synthetic global `sg`. */
DataFlowType getSyntheticGlobalType(SummaryComponent::SyntheticGlobal sg) { any() }
/**
* Holds if an external flow summary exists for `c` with input specification
* `input`, output specification `output`, kind `kind`, and a flag `generated`