1
1
private import cpp
2
2
private import semmle.code.cpp.ir.IR
3
- private import semmle.code.cpp.ir.dataflow.DataFlow
4
3
private import DataFlowPrivate
5
4
private import DataFlowUtil
6
5
private import DataFlowImplCommon as DataFlowImplCommon
@@ -60,7 +59,7 @@ private module VirtualDispatch {
60
59
* `resolve` predicate to stitch that information together and resolve the
61
60
* call.
62
61
*/
63
- abstract DataFlow :: Node getDispatchValue ( ) ;
62
+ abstract Node getDispatchValue ( ) ;
64
63
65
64
/** Gets a candidate target for this call. */
66
65
abstract Function resolve ( ) ;
@@ -72,17 +71,13 @@ private module VirtualDispatch {
72
71
* parameter is true when the search is allowed to continue backwards into
73
72
* a parameter; non-recursive callers should pass `_` for `allowFromArg`.
74
73
*/
75
- predicate flowsFrom ( DataFlow :: Node src , boolean allowFromArg ) {
74
+ predicate flowsFrom ( Node src , boolean allowFromArg ) {
76
75
src = this .getDispatchValue ( ) and allowFromArg = true
77
76
or
78
- exists ( DataFlow:: Node other , boolean allowOtherFromArg |
79
- this .flowsFrom ( other , allowOtherFromArg )
80
- |
77
+ exists ( Node other , boolean allowOtherFromArg | this .flowsFrom ( other , allowOtherFromArg ) |
81
78
// Call argument
82
79
exists ( DataFlowCall call , Position i |
83
- other
84
- .( DataFlow:: ParameterNode )
85
- .isParameterOf ( pragma [ only_bind_into ] ( call ) .getStaticCallTarget ( ) , i ) and
80
+ other .( ParameterNode ) .isParameterOf ( pragma [ only_bind_into ] ( call ) .getStaticCallTarget ( ) , i ) and
86
81
src .( ArgumentNode ) .argumentOf ( call , pragma [ only_bind_into ] ( pragma [ only_bind_out ] ( i ) ) )
87
82
) and
88
83
allowOtherFromArg = true and
@@ -96,7 +91,7 @@ private module VirtualDispatch {
96
91
allowFromArg = false
97
92
or
98
93
// Local flow
99
- DataFlow :: localFlowStep ( src , other ) and
94
+ localFlowStep ( src , other ) and
100
95
allowFromArg = allowOtherFromArg
101
96
or
102
97
// Flow from global variable to load.
@@ -159,11 +154,11 @@ private module VirtualDispatch {
159
154
private class DataSensitiveExprCall extends DataSensitiveCall {
160
155
DataSensitiveExprCall ( ) { not exists ( this .getStaticCallTarget ( ) ) }
161
156
162
- override DataFlow :: Node getDispatchValue ( ) { result .asOperand ( ) = this .getCallTargetOperand ( ) }
157
+ override Node getDispatchValue ( ) { result .asOperand ( ) = this .getCallTargetOperand ( ) }
163
158
164
159
override Function resolve ( ) {
165
160
exists ( FunctionInstruction fi |
166
- this .flowsFrom ( DataFlow :: instructionNode ( fi ) , _) and
161
+ this .flowsFrom ( instructionNode ( fi ) , _) and
167
162
result = fi .getFunctionSymbol ( )
168
163
) and
169
164
(
@@ -186,7 +181,7 @@ private module VirtualDispatch {
186
181
)
187
182
}
188
183
189
- override DataFlow :: Node getDispatchValue ( ) { result .asInstruction ( ) = this .getArgument ( - 1 ) }
184
+ override Node getDispatchValue ( ) { result .asInstruction ( ) = this .getArgument ( - 1 ) }
190
185
191
186
override MemberFunction resolve ( ) {
192
187
exists ( Class overridingClass |
@@ -213,7 +208,7 @@ private module VirtualDispatch {
213
208
pragma [ noinline]
214
209
private predicate hasFlowFromCastFrom ( Class derivedClass ) {
215
210
exists ( ConvertToBaseInstruction toBase |
216
- this .flowsFrom ( DataFlow :: instructionNode ( toBase ) , _) and
211
+ this .flowsFrom ( instructionNode ( toBase ) , _) and
217
212
derivedClass = toBase .getDerivedClass ( )
218
213
)
219
214
}
@@ -270,7 +265,7 @@ private predicate mayBenefitFromCallContext(
270
265
exists ( InitializeParameterInstruction init |
271
266
not exists ( call .getStaticCallTarget ( ) ) and
272
267
init .getEnclosingFunction ( ) = f .getUnderlyingCallable ( ) and
273
- call .flowsFrom ( DataFlow :: instructionNode ( init ) , _) and
268
+ call .flowsFrom ( instructionNode ( init ) , _) and
274
269
init .getParameter ( ) .getIndex ( ) = arg
275
270
)
276
271
}
0 commit comments