@@ -10,7 +10,8 @@ private newtype TFunctionInput =
1010 TInParameter ( ParameterIndex i ) or
1111 TInParameterDeref ( ParameterIndex i ) or
1212 TInQualifierObject ( ) or
13- TInQualifierAddress ( )
13+ TInQualifierAddress ( ) or
14+ TInReturnValueDeref ( )
1415
1516/**
1617 * An input to a function. This can be:
@@ -106,6 +107,31 @@ class FunctionInput extends TFunctionInput {
106107 * (with type `C const *`) on entry to the function.
107108 */
108109 predicate isQualifierAddress ( ) { none ( ) }
110+
111+ /**
112+ * Holds if this is the input value pointed to by the return value of a
113+ * function, if the function returns a pointer, or the input value referred
114+ * to by the return value of a function, if the function returns a reference.
115+ *
116+ * Example:
117+ * ```
118+ * char* getPointer();
119+ * float& getReference();
120+ * int getInt();
121+ * ```
122+ * - `isReturnValueDeref()` holds for the `FunctionInput` that represents the
123+ * value of `*getPointer()` (with type `char`).
124+ * - `isReturnValueDeref()` holds for the `FunctionInput` that represents the
125+ * value of `getReference()` (with type `float`).
126+ * - There is no `FunctionInput` of `getInt()` for which
127+ * `isReturnValueDeref()` holds because the return type of `getInt()` is
128+ * neither a pointer nor a reference.
129+ *
130+ * Note that data flows in through function return values are relatively
131+ * rare, but they do occur when a function returns a reference to itself,
132+ * part of itself, or one of its other inputs.
133+ */
134+ predicate isReturnValueDeref ( ) { none ( ) }
109135}
110136
111137/**
@@ -199,6 +225,34 @@ class InQualifierAddress extends FunctionInput, TInQualifierAddress {
199225 override predicate isQualifierAddress ( ) { any ( ) }
200226}
201227
228+ /**
229+ * The input value pointed to by the return value of a function, if the
230+ * function returns a pointer, or the input value referred to by the return
231+ * value of a function, if the function returns a reference.
232+ *
233+ * Example:
234+ * ```
235+ * char* getPointer();
236+ * float& getReference();
237+ * int getInt();
238+ * ```
239+ * - `InReturnValueDeref` represents the value of `*getPointer()` (with type
240+ * `char`).
241+ * - `InReturnValueDeref` represents the value of `getReference()` (with type
242+ * `float`).
243+ * - `InReturnValueDeref` does not represent the return value of `getInt()`
244+ * because the return type of `getInt()` is neither a pointer nor a reference.
245+ *
246+ * Note that data flows in through function return values are relatively
247+ * rare, but they do occur when a function returns a reference to itself,
248+ * part of itself, or one of its other inputs.
249+ */
250+ class InReturnValueDeref extends FunctionInput , TInReturnValueDeref {
251+ override string toString ( ) { result = "InReturnValueDeref" }
252+
253+ override predicate isReturnValueDeref ( ) { any ( ) }
254+ }
255+
202256private newtype TFunctionOutput =
203257 TOutParameterDeref ( ParameterIndex i ) or
204258 TOutQualifierObject ( ) or
0 commit comments