22
33import csharp
44private import internal.FlowSummaryImpl as Impl
5- private import internal.DataFlowDispatch
5+ private import internal.DataFlowDispatch as DataFlowDispatch
6+
7+ class ParameterPosition = DataFlowDispatch:: ParameterPosition ;
8+
9+ class ArgumentPosition = DataFlowDispatch:: ArgumentPosition ;
610
711// import all instances below
812private module Summaries {
@@ -14,7 +18,27 @@ class SummaryComponent = Impl::Public::SummaryComponent;
1418
1519/** Provides predicates for constructing summary components. */
1620module SummaryComponent {
17- import Impl:: Public:: SummaryComponent
21+ private import Impl:: Public:: SummaryComponent as SummaryComponentInternal
22+
23+ predicate content = SummaryComponentInternal:: content / 1 ;
24+
25+ /** Gets a summary component for parameter `i`. */
26+ SummaryComponent parameter ( int i ) {
27+ exists ( ArgumentPosition pos |
28+ result = SummaryComponentInternal:: parameter ( pos ) and
29+ i = pos .getPosition ( )
30+ )
31+ }
32+
33+ /** Gets a summary component for argument `i`. */
34+ SummaryComponent argument ( int i ) {
35+ exists ( ParameterPosition pos |
36+ result = SummaryComponentInternal:: argument ( pos ) and
37+ i = pos .getPosition ( )
38+ )
39+ }
40+
41+ predicate return = SummaryComponentInternal:: return / 1 ;
1842
1943 /** Gets a summary component that represents a qualifier. */
2044 SummaryComponent qualifier ( ) { result = argument ( - 1 ) }
@@ -33,14 +57,14 @@ module SummaryComponent {
3357 }
3458
3559 /** Gets a summary component that represents the return value of a call. */
36- SummaryComponent return ( ) { result = return ( any ( NormalReturnKind rk ) ) }
60+ SummaryComponent return ( ) { result = return ( any ( DataFlowDispatch :: NormalReturnKind rk ) ) }
3761
3862 /** Gets a summary component that represents a jump to `c`. */
3963 SummaryComponent jump ( Callable c ) {
4064 result =
41- return ( any ( JumpReturnKind jrk |
65+ return ( any ( DataFlowDispatch :: JumpReturnKind jrk |
4266 jrk .getTarget ( ) = c .getUnboundDeclaration ( ) and
43- jrk .getTargetReturnKind ( ) instanceof NormalReturnKind
67+ jrk .getTargetReturnKind ( ) instanceof DataFlowDispatch :: NormalReturnKind
4468 ) )
4569 }
4670}
@@ -49,7 +73,16 @@ class SummaryComponentStack = Impl::Public::SummaryComponentStack;
4973
5074/** Provides predicates for constructing stacks of summary components. */
5175module SummaryComponentStack {
52- import Impl:: Public:: SummaryComponentStack
76+ private import Impl:: Public:: SummaryComponentStack as SummaryComponentStackInternal
77+
78+ predicate singleton = SummaryComponentStackInternal:: singleton / 1 ;
79+
80+ predicate push = SummaryComponentStackInternal:: push / 2 ;
81+
82+ /** Gets a singleton stack for argument `i`. */
83+ SummaryComponentStack argument ( int i ) { result = singleton ( SummaryComponent:: argument ( i ) ) }
84+
85+ predicate return = SummaryComponentStackInternal:: return / 1 ;
5386
5487 /** Gets a singleton stack representing a qualifier. */
5588 SummaryComponentStack qualifier ( ) { result = singleton ( SummaryComponent:: qualifier ( ) ) }
@@ -84,12 +117,12 @@ private class SummarizedCallableDefaultClearsContent extends Impl::Public::Summa
84117 }
85118
86119 // By default, we assume that all stores into arguments are definite
87- override predicate clearsContent ( int i , DataFlow:: Content content ) {
120+ override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
88121 exists ( SummaryComponentStack output |
89122 this .propagatesFlow ( _, output , _) and
90123 output .drop ( _) =
91124 SummaryComponentStack:: push ( SummaryComponent:: content ( content ) ,
92- SummaryComponentStack:: argument ( i ) ) and
125+ SummaryComponentStack:: argument ( pos . getPosition ( ) ) ) and
93126 not content instanceof DataFlow:: ElementContent
94127 )
95128 }
0 commit comments