11private import cpp
22private import semmle.code.cpp.ir.IR
3- private import semmle.code.cpp.ir.dataflow.DataFlow
43private import DataFlowPrivate
54private import DataFlowUtil
65private import DataFlowImplCommon as DataFlowImplCommon
@@ -60,7 +59,7 @@ private module VirtualDispatch {
6059 * `resolve` predicate to stitch that information together and resolve the
6160 * call.
6261 */
63- abstract DataFlow :: Node getDispatchValue ( ) ;
62+ abstract Node getDispatchValue ( ) ;
6463
6564 /** Gets a candidate target for this call. */
6665 abstract Function resolve ( ) ;
@@ -72,17 +71,13 @@ private module VirtualDispatch {
7271 * parameter is true when the search is allowed to continue backwards into
7372 * a parameter; non-recursive callers should pass `_` for `allowFromArg`.
7473 */
75- predicate flowsFrom ( DataFlow :: Node src , boolean allowFromArg ) {
74+ predicate flowsFrom ( Node src , boolean allowFromArg ) {
7675 src = this .getDispatchValue ( ) and allowFromArg = true
7776 or
78- exists ( DataFlow:: Node other , boolean allowOtherFromArg |
79- this .flowsFrom ( other , allowOtherFromArg )
80- |
77+ exists ( Node other , boolean allowOtherFromArg | this .flowsFrom ( other , allowOtherFromArg ) |
8178 // Call argument
8279 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
8681 src .( ArgumentNode ) .argumentOf ( call , pragma [ only_bind_into ] ( pragma [ only_bind_out ] ( i ) ) )
8782 ) and
8883 allowOtherFromArg = true and
@@ -96,7 +91,7 @@ private module VirtualDispatch {
9691 allowFromArg = false
9792 or
9893 // Local flow
99- DataFlow :: localFlowStep ( src , other ) and
94+ localFlowStep ( src , other ) and
10095 allowFromArg = allowOtherFromArg
10196 or
10297 // Flow from global variable to load.
@@ -159,11 +154,11 @@ private module VirtualDispatch {
159154 private class DataSensitiveExprCall extends DataSensitiveCall {
160155 DataSensitiveExprCall ( ) { not exists ( this .getStaticCallTarget ( ) ) }
161156
162- override DataFlow :: Node getDispatchValue ( ) { result .asOperand ( ) = this .getCallTargetOperand ( ) }
157+ override Node getDispatchValue ( ) { result .asOperand ( ) = this .getCallTargetOperand ( ) }
163158
164159 override Function resolve ( ) {
165160 exists ( FunctionInstruction fi |
166- this .flowsFrom ( DataFlow :: instructionNode ( fi ) , _) and
161+ this .flowsFrom ( instructionNode ( fi ) , _) and
167162 result = fi .getFunctionSymbol ( )
168163 ) and
169164 (
@@ -186,7 +181,7 @@ private module VirtualDispatch {
186181 )
187182 }
188183
189- override DataFlow :: Node getDispatchValue ( ) { result .asInstruction ( ) = this .getArgument ( - 1 ) }
184+ override Node getDispatchValue ( ) { result .asInstruction ( ) = this .getArgument ( - 1 ) }
190185
191186 override MemberFunction resolve ( ) {
192187 exists ( Class overridingClass |
@@ -213,7 +208,7 @@ private module VirtualDispatch {
213208 pragma [ noinline]
214209 private predicate hasFlowFromCastFrom ( Class derivedClass ) {
215210 exists ( ConvertToBaseInstruction toBase |
216- this .flowsFrom ( DataFlow :: instructionNode ( toBase ) , _) and
211+ this .flowsFrom ( instructionNode ( toBase ) , _) and
217212 derivedClass = toBase .getDerivedClass ( )
218213 )
219214 }
@@ -270,7 +265,7 @@ private predicate mayBenefitFromCallContext(
270265 exists ( InitializeParameterInstruction init |
271266 not exists ( call .getStaticCallTarget ( ) ) and
272267 init .getEnclosingFunction ( ) = f .getUnderlyingCallable ( ) and
273- call .flowsFrom ( DataFlow :: instructionNode ( init ) , _) and
268+ call .flowsFrom ( instructionNode ( init ) , _) and
274269 init .getParameter ( ) .getIndex ( ) = arg
275270 )
276271}
0 commit comments