@@ -42,9 +42,14 @@ class Node extends TIRDataFlowNode {
4242 Operand asOperand ( ) { result = this .( OperandNode ) .getOperand ( ) }
4343
4444 /**
45- * Gets the non-conversion expression corresponding to this node, if any. If
46- * this node strictly (in the sense of `asConvertedExpr`) corresponds to a
47- * `Conversion`, then the result is that `Conversion`'s non-`Conversion` base
45+ * Gets the non-conversion expression corresponding to this node, if any.
46+ * This predicate only has a result on nodes that represent the value of
47+ * evaluating the expression. For data flowing _out of_ an expression, like
48+ * when an argument is passed by reference, use `asDefiningArgument` instead
49+ * of `asExpr`.
50+ *
51+ * If this node strictly (in the sense of `asConvertedExpr`) corresponds to
52+ * a `Conversion`, then the result is the underlying non-`Conversion` base
4853 * expression.
4954 */
5055 Expr asExpr ( ) { result = this .( ExprNode ) .getExpr ( ) }
@@ -55,7 +60,13 @@ class Node extends TIRDataFlowNode {
5560 */
5661 Expr asConvertedExpr ( ) { result = this .( ExprNode ) .getConvertedExpr ( ) }
5762
58- /** Gets the argument that defines this `DefinitionByReferenceNode`, if any. */
63+ /**
64+ * Gets the argument that defines this `DefinitionByReferenceNode`, if any.
65+ * This predicate should be used instead of `asExpr` when referring to the
66+ * value of a reference argument _after_ the call has returned. For example,
67+ * in `f(&x)`, this predicate will have `&x` as its result for the `Node`
68+ * that represents the new value of `x`.
69+ */
5970 Expr asDefiningArgument ( ) { result = this .( DefinitionByReferenceNode ) .getArgument ( ) }
6071
6172 /** Gets the positional parameter corresponding to this node, if any. */
@@ -378,7 +389,7 @@ private class ExplicitSingleFieldStoreQualifierNode extends PartialDefinitionNod
378389class DefinitionByReferenceNode extends InstructionNode {
379390 override WriteSideEffectInstruction instr ;
380391
381- /** Gets the argument corresponding to this node. */
392+ /** Gets the unconverted argument corresponding to this node. */
382393 Expr getArgument ( ) {
383394 result =
384395 instr
@@ -462,20 +473,26 @@ class VariableNode extends Node, TVariableNode {
462473InstructionNode instructionNode ( Instruction instr ) { result .getInstruction ( ) = instr }
463474
464475/**
476+ * DEPRECATED: use `definitionByReferenceNodeFromArgument` instead.
477+ *
465478 * Gets the `Node` corresponding to a definition by reference of the variable
466479 * that is passed as `argument` of a call.
467480 */
468- DefinitionByReferenceNode definitionByReferenceNode ( Expr e ) { result .getArgument ( ) = e }
481+ deprecated DefinitionByReferenceNode definitionByReferenceNode ( Expr e ) { result .getArgument ( ) = e }
469482
470483/**
471- * Gets a `Node` corresponding to `e` or any of its conversions. There is no
472- * result if `e` is a `Conversion`.
484+ * Gets the `Node` corresponding to the value of evaluating `e` or any of its
485+ * conversions. There is no result if `e` is a `Conversion`. For data flowing
486+ * _out of_ an expression, like when an argument is passed by reference, use
487+ * `definitionByReferenceNodeFromArgument` instead.
473488 */
474489ExprNode exprNode ( Expr e ) { result .getExpr ( ) = e }
475490
476491/**
477- * Gets the `Node` corresponding to `e`, if any. Here, `e` may be a
478- * `Conversion`.
492+ * Gets the `Node` corresponding to the value of evaluating `e`. Here, `e` may
493+ * be a `Conversion`. For data flowing _out of_ an expression, like when an
494+ * argument is passed by reference, use
495+ * `definitionByReferenceNodeFromArgument` instead.
479496 */
480497ExprNode convertedExprNode ( Expr e ) { result .getConvertedExpr ( ) = e }
481498
@@ -484,6 +501,14 @@ ExprNode convertedExprNode(Expr e) { result.getConvertedExpr() = e }
484501 */
485502ExplicitParameterNode parameterNode ( Parameter p ) { result .getParameter ( ) = p }
486503
504+ /**
505+ * Gets the `Node` corresponding to a definition by reference of the variable
506+ * that is passed as unconverted `argument` of a call.
507+ */
508+ DefinitionByReferenceNode definitionByReferenceNodeFromArgument ( Expr argument ) {
509+ result .getArgument ( ) = argument
510+ }
511+
487512/** Gets the `VariableNode` corresponding to the variable `v`. */
488513VariableNode variableNode ( Variable v ) { result .getVariable ( ) = v }
489514
0 commit comments