@@ -3,8 +3,7 @@ private import DataFlowUtil
33private import DataFlowImplCommon
44
55private newtype TReturnKind =
6- TSingleReturn ( ) or
7- TMultiReturn ( int i ) { exists ( SignatureType st | exists ( st .getResultType ( i ) ) ) }
6+ MkReturnKind ( int i ) { exists ( SignatureType st | exists ( st .getResultType ( i ) ) ) }
87
98/**
109 * A return kind. A return kind describes how a value can be returned
@@ -13,23 +12,14 @@ private newtype TReturnKind =
1312 */
1413class ReturnKind extends TReturnKind {
1514 /** Gets a textual representation of this return kind. */
16- string toString ( ) {
17- this = TSingleReturn ( ) and
18- result = "return"
19- or
20- exists ( int i | this = TMultiReturn ( i ) | result = "return[" + i + "]" )
21- }
15+ string toString ( ) { exists ( int i | this = MkReturnKind ( i ) | result = "return[" + i + "]" ) }
2216}
2317
2418/** A data flow node that represents returning a value from a function. */
2519class ReturnNode extends ResultNode {
2620 ReturnKind kind ;
2721
28- ReturnNode ( ) {
29- exists ( int nr | nr = fd .getType ( ) .getNumResult ( ) |
30- if nr = 1 then kind = TSingleReturn ( ) else kind = TMultiReturn ( i )
31- )
32- }
22+ ReturnNode ( ) { kind = MkReturnKind ( i ) }
3323
3424 /** Gets the kind of this returned value. */
3525 ReturnKind getKind ( ) { result = kind }
@@ -40,12 +30,7 @@ class OutNode extends DataFlow::Node {
4030 DataFlow:: CallNode call ;
4131 int i ;
4232
43- OutNode ( ) {
44- this = call .getResult ( ) and
45- i = - 1
46- or
47- this = call .getResult ( i )
48- }
33+ OutNode ( ) { this = call .getResult ( i ) }
4934
5035 /** Gets the underlying call. */
5136 DataFlowCall getCall ( ) { result = call .asExpr ( ) }
@@ -56,11 +41,8 @@ class OutNode extends DataFlow::Node {
5641 * `kind`.
5742 */
5843OutNode getAnOutNode ( DataFlowCall call , ReturnKind kind ) {
59- exists ( DataFlow:: CallNode c | c .asExpr ( ) = call |
60- kind = TSingleReturn ( ) and
61- result = c .getResult ( )
62- or
63- exists ( int i | kind = TMultiReturn ( i ) | result = c .getResult ( i ) )
44+ exists ( DataFlow:: CallNode c , int i | c .asExpr ( ) = call and kind = MkReturnKind ( i ) |
45+ result = c .getResult ( i )
6446 )
6547}
6648
0 commit comments