@@ -23,6 +23,14 @@ private newtype TFunctionInput =
2323class FunctionInput extends TFunctionInput {
2424 abstract string toString ( ) ;
2525
26+ /**
27+ * INTERNAL: Do not use.
28+ *
29+ * Gets the `FunctionInput` that represents the indirection of this input,
30+ * if any.
31+ */
32+ FunctionInput getIndirectionInput ( ) { none ( ) }
33+
2634 /**
2735 * Holds if this is the input value of the parameter with index `index`.
2836 *
@@ -226,6 +234,8 @@ class InParameter extends FunctionInput, TInParameter {
226234 ParameterIndex getIndex ( ) { result = index }
227235
228236 override predicate isParameter ( ParameterIndex i ) { i = index }
237+
238+ override FunctionInput getIndirectionInput ( ) { result = TInParameterDeref ( index , 1 ) }
229239}
230240
231241/**
@@ -257,6 +267,10 @@ class InParameterDeref extends FunctionInput, TInParameterDeref {
257267 override predicate isParameterDeref ( ParameterIndex i , int indirection ) {
258268 i = index and indirectionIndex = indirection
259269 }
270+
271+ override FunctionInput getIndirectionInput ( ) {
272+ result = TInParameterDeref ( index , indirectionIndex + 1 )
273+ }
260274}
261275
262276/**
@@ -275,6 +289,8 @@ class InQualifierObject extends FunctionInput, TInQualifierObject {
275289 override string toString ( ) { result = "InQualifierObject" }
276290
277291 override predicate isQualifierObject ( ) { any ( ) }
292+
293+ override FunctionInput getIndirectionInput ( ) { none ( ) }
278294}
279295
280296/**
@@ -293,6 +309,8 @@ class InQualifierAddress extends FunctionInput, TInQualifierAddress {
293309 override string toString ( ) { result = "InQualifierAddress" }
294310
295311 override predicate isQualifierAddress ( ) { any ( ) }
312+
313+ override FunctionInput getIndirectionInput ( ) { result = TInQualifierObject ( ) }
296314}
297315
298316/**
@@ -321,6 +339,8 @@ class InReturnValueDeref extends FunctionInput, TInReturnValueDeref {
321339 override string toString ( ) { result = "InReturnValueDeref" }
322340
323341 override predicate isReturnValueDeref ( ) { any ( ) }
342+
343+ override FunctionInput getIndirectionInput ( ) { none ( ) }
324344}
325345
326346private newtype TFunctionOutput =
@@ -340,6 +360,14 @@ private newtype TFunctionOutput =
340360class FunctionOutput extends TFunctionOutput {
341361 abstract string toString ( ) ;
342362
363+ /**
364+ * INTERNAL: Do not use.
365+ *
366+ * Gets the `FunctionOutput` that represents the indirection of this output,
367+ * if any.
368+ */
369+ FunctionOutput getIndirectionOutput ( ) { none ( ) }
370+
343371 /**
344372 * Holds if this is the output value pointed to by a pointer parameter to a function, or the
345373 * output value referred to by a reference parameter to a function, where the parameter has
@@ -512,6 +540,10 @@ class OutParameterDeref extends FunctionOutput, TOutParameterDeref {
512540 override predicate isParameterDeref ( ParameterIndex i , int ind ) {
513541 i = index and ind = indirectionIndex
514542 }
543+
544+ override FunctionOutput getIndirectionOutput ( ) {
545+ result = TOutParameterDeref ( index , indirectionIndex + 1 )
546+ }
515547}
516548
517549/**
@@ -530,6 +562,8 @@ class OutQualifierObject extends FunctionOutput, TOutQualifierObject {
530562 override string toString ( ) { result = "OutQualifierObject" }
531563
532564 override predicate isQualifierObject ( ) { any ( ) }
565+
566+ override FunctionOutput getIndirectionOutput ( ) { none ( ) }
533567}
534568
535569/**
@@ -552,6 +586,8 @@ class OutReturnValue extends FunctionOutput, TOutReturnValue {
552586 override string toString ( ) { result = "OutReturnValue" }
553587
554588 override predicate isReturnValue ( ) { any ( ) }
589+
590+ override FunctionOutput getIndirectionOutput ( ) { result = TOutReturnValueDeref ( 1 ) }
555591}
556592
557593/**
@@ -571,11 +607,19 @@ class OutReturnValue extends FunctionOutput, TOutReturnValue {
571607 * of `getInt()` is neither a pointer nor a reference.
572608 */
573609class OutReturnValueDeref extends FunctionOutput , TOutReturnValueDeref {
610+ int indirectionIndex ;
611+
612+ OutReturnValueDeref ( ) { this = TOutReturnValueDeref ( indirectionIndex ) }
613+
574614 override string toString ( ) { result = "OutReturnValueDeref" }
575615
576616 override predicate isReturnValueDeref ( ) { any ( ) }
577617
578- override predicate isReturnValueDeref ( int indirectionIndex ) {
579- this = TOutReturnValueDeref ( indirectionIndex )
618+ override predicate isReturnValueDeref ( int indirectionIndex_ ) {
619+ indirectionIndex = indirectionIndex_
620+ }
621+
622+ override FunctionOutput getIndirectionOutput ( ) {
623+ result = TOutReturnValueDeref ( indirectionIndex + 1 )
580624 }
581625}
0 commit comments