Add handling of post-constructor-call nodes

This commit is contained in:
Pavel Avgustinov
2019-07-11 11:11:46 +01:00
committed by Jonas Jensen
parent 9e6c240ee2
commit dccc0f4db1

View File

@@ -10,6 +10,7 @@ cached
private newtype TNode = private newtype TNode =
TExprNode(Expr e) or TExprNode(Expr e) or
TPartialDefNode(PartialDefinition pd) or TPartialDefNode(PartialDefinition pd) or
TPostConstructorCallNode(ConstructorCall call) or
TExplicitParameterNode(Parameter p) { exists(p.getFunction().getBlock()) } or TExplicitParameterNode(Parameter p) { exists(p.getFunction().getBlock()) } or
TInstanceParameterNode(MemberFunction f) { exists(f.getBlock()) and not f.isStatic() } or TInstanceParameterNode(MemberFunction f) { exists(f.getBlock()) and not f.isStatic() } or
TDefinitionByReferenceNode(VariableAccess va, Expr argument) { TDefinitionByReferenceNode(VariableAccess va, Expr argument) {
@@ -233,13 +234,19 @@ class PartialDefNode extends PostUpdateNode, TPartialDefNode {
override Node getPreUpdateNode() { result.asExpr() = pd.getDefinedExpr() } override Node getPreUpdateNode() { result.asExpr() = pd.getDefinedExpr() }
override string toString() { result = pd.toString() }
override Location getLocation() { result = pd.getLocation() } override Location getLocation() { result = pd.getLocation() }
PartialDefinition getPartialDefinition() { result = pd } PartialDefinition getPartialDefinition() { result = pd }
} }
class PostConstructorCallNode extends PostUpdateNode, TPostConstructorCallNode {
ConstructorCall call;
PostConstructorCallNode() { this = TPostConstructorCallNode(call) }
override Node getPreUpdateNode() { result.asExpr() = call }
}
/** /**
* Gets the `Node` corresponding to `e`. * Gets the `Node` corresponding to `e`.
*/ */
@@ -310,6 +317,8 @@ predicate localFlowStep(Node nodeFrom, Node nodeTo) {
// Expr -> Expr // Expr -> Expr
exprToExprStep_nocfg(nodeFrom.asExpr(), nodeTo.asExpr()) exprToExprStep_nocfg(nodeFrom.asExpr(), nodeTo.asExpr())
or or
exprToExprStep_nocfg(nodeFrom.(PostUpdateNode).getPreUpdateNode().asExpr(), nodeTo.asExpr())
or
// Node -> FlowVar -> VariableAccess // Node -> FlowVar -> VariableAccess
exists(FlowVar var | exists(FlowVar var |
( (