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

Skip to content

Commit fc9f239

Browse files
author
Robert Marsh
committed
C++: make ConstructorCall df nodes the qualifier
This makes the dataflow node for a ConstructorCall be the outnode of the qualifier, which is the resulting constructed object. This should make `asExpr` on a ConstructorCall do the "right thing" rather than selecting the void-typed CallInstruction.
1 parent 3befa1c commit fc9f239

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,19 @@ private predicate exprNodeShouldBeIndirectOperand(IndirectOperand node, Expr e,
738738
not convertedExprMustBeOperand(e)
739739
}
740740

741+
private predicate exprNodeShouldBeIndirectOutNode(IndirectArgumentOutNode node, Expr e) {
742+
exists(CallInstruction call |
743+
e = call.getConvertedResultExpression() and
744+
call.getThisArgumentOperand() = node.getAddressOperand()
745+
)
746+
}
747+
741748
/** Holds if `node` should be an instruction node that maps `node.asExpr()` to `e`. */
742749
predicate exprNodeShouldBeInstruction(Node node, Expr e) {
743750
e = node.asInstruction().getConvertedResultExpression() and
744751
not exprNodeShouldBeOperand(_, e) and
745-
not exprNodeShouldBeIndirectOperand(_, e, _)
752+
not exprNodeShouldBeIndirectOperand(_, e, _) and
753+
not exprNodeShouldBeIndirectOutNode(_, e)
746754
}
747755

748756
private class ExprNodeBase extends Node {
@@ -792,6 +800,17 @@ private class IndirectOperandExprNode extends ExprNodeBase, IndirectOperand {
792800
final override string toStringImpl() { result = this.getConvertedExpr().toString() }
793801
}
794802

803+
private class IndirectArgumentOutExprNode extends ExprNodeBase, IndirectArgumentOutNode {
804+
805+
IndirectArgumentOutExprNode() { exprNodeShouldBeIndirectOutNode(this, _)}
806+
807+
final override Expr getConvertedExpr() { exprNodeShouldBeIndirectOutNode(this, result) }
808+
809+
final override Expr getExpr() { result = this.getConvertedExpr() }
810+
811+
final override string toStringImpl() { result = this.getConvertedExpr().toString() }
812+
}
813+
795814
/**
796815
* An expression, viewed as a node in a data flow graph.
797816
*/

0 commit comments

Comments
 (0)