11private import csharp
2- private import cil
3- private import dotnet
42private import DataFlowImplCommon as DataFlowImplCommon
53private import DataFlowPublic
64private import DataFlowPrivate
@@ -14,29 +12,12 @@ private import semmle.code.csharp.frameworks.system.collections.Generic
1412/**
1513 * Gets a source declaration of callable `c` that has a body or has
1614 * a flow summary.
17- *
18- * If the callable has both CIL and source code, return only the source
19- * code version.
2015 */
21- DotNet:: Callable getCallableForDataFlow ( DotNet:: Callable c ) {
22- exists ( DotNet:: Callable unboundDecl | unboundDecl = c .getUnboundDeclaration ( ) |
23- result .hasBody ( ) and
24- if unboundDecl .getFile ( ) .fromSource ( )
25- then
26- // C# callable with C# implementation in the database
27- result = unboundDecl
28- else
29- if unboundDecl instanceof CIL:: Callable
30- then
31- // CIL callable with C# implementation in the database
32- unboundDecl .matchesHandle ( result .( Callable ) )
33- or
34- // CIL callable without C# implementation in the database
35- not unboundDecl .matchesHandle ( any ( Callable k | k .hasBody ( ) ) ) and
36- result = unboundDecl
37- else
38- // C# callable without C# implementation in the database
39- unboundDecl .matchesHandle ( result .( CIL:: Callable ) )
16+ Callable getCallableForDataFlow ( Callable c ) {
17+ exists ( Callable unboundDecl | unboundDecl = c .getUnboundDeclaration ( ) |
18+ unboundDecl .hasBody ( ) and
19+ unboundDecl .getFile ( ) .fromSource ( ) and
20+ result = unboundDecl
4021 )
4122}
4223
@@ -67,7 +48,7 @@ private module Cached {
6748 */
6849 cached
6950 newtype TDataFlowCallable =
70- TDotNetCallable ( DotNet :: Callable c ) { c .isUnboundDeclaration ( ) } or
51+ TCallable ( Callable c ) { c .isUnboundDeclaration ( ) } or
7152 TSummarizedCallable ( DataFlowSummarizedCallable sc ) or
7253 TFieldOrPropertyCallable ( FieldOrProperty f ) or
7354 TCapturedVariableCallable ( LocalScopeVariable v ) { v .isCaptured ( ) }
@@ -81,10 +62,6 @@ private module Cached {
8162 TExplicitDelegateLikeCall ( ControlFlow:: Nodes:: ElementNode cfn , DelegateLikeCall dc ) {
8263 cfn .getAstNode ( ) = dc
8364 } or
84- TCilCall ( CIL:: Call call ) {
85- // No need to include calls that are compiled from source
86- not call .getImplementation ( ) .getMethod ( ) .compiledFromSource ( )
87- } or
8865 TSummaryCall ( FlowSummary:: SummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNode receiver ) {
8966 FlowSummaryImpl:: Private:: summaryCallbackRange ( c , receiver )
9067 }
@@ -197,7 +174,7 @@ class RefReturnKind extends OutRefReturnKind, TRefReturnKind {
197174/** A callable used for data flow. */
198175class DataFlowCallable extends TDataFlowCallable {
199176 /** Gets the underlying source code callable, if any. */
200- DotNet :: Callable asCallable ( ) { this = TDotNetCallable ( result ) }
177+ Callable asCallable ( ) { this = TCallable ( result ) }
201178
202179 /** Gets the underlying summarized callable, if any. */
203180 FlowSummary:: SummarizedCallable asSummarizedCallable ( ) { this = TSummarizedCallable ( result ) }
@@ -208,7 +185,7 @@ class DataFlowCallable extends TDataFlowCallable {
208185 LocalScopeVariable asCapturedVariable ( ) { this = TCapturedVariableCallable ( result ) }
209186
210187 /** Gets the underlying callable. */
211- DotNet :: Callable getUnderlyingCallable ( ) {
188+ Callable getUnderlyingCallable ( ) {
212189 result = this .asCallable ( ) or result = this .asSummarizedCallable ( )
213190 }
214191
@@ -235,8 +212,7 @@ class DataFlowCallable extends TDataFlowCallable {
235212abstract class DataFlowCall extends TDataFlowCall {
236213 /**
237214 * Gets a run-time target of this call. A target is always a source
238- * declaration, and if the callable has both CIL and source code, only
239- * the source code version is returned.
215+ * declaration.
240216 */
241217 abstract DataFlowCallable getARuntimeTarget ( ) ;
242218
@@ -250,7 +226,7 @@ abstract class DataFlowCall extends TDataFlowCall {
250226 abstract DataFlowCallable getEnclosingCallable ( ) ;
251227
252228 /** Gets the underlying expression, if any. */
253- final DotNet :: Expr getExpr ( ) { result = this .getNode ( ) .asExpr ( ) }
229+ final Expr getExpr ( ) { result = this .getNode ( ) .asExpr ( ) }
254230
255231 /** Gets the argument at position `pos` of this call. */
256232 final ArgumentNode getArgument ( ArgumentPosition pos ) { result .argumentOf ( this , pos ) }
@@ -348,33 +324,6 @@ class ExplicitDelegateLikeDataFlowCall extends DelegateDataFlowCall, TExplicitDe
348324 override Location getLocation ( ) { result = cfn .getLocation ( ) }
349325}
350326
351- /** A CIL call relevant for data flow. */
352- class CilDataFlowCall extends DataFlowCall , TCilCall {
353- private CIL:: Call call ;
354-
355- CilDataFlowCall ( ) { this = TCilCall ( call ) }
356-
357- /** Gets the underlying CIL call. */
358- CIL:: Call getCilCall ( ) { result = call }
359-
360- override DataFlowCallable getARuntimeTarget ( ) {
361- // There is no dispatch library for CIL, so do not consider overrides for now
362- result .getUnderlyingCallable ( ) = getCallableForDataFlow ( call .getTarget ( ) )
363- }
364-
365- override ControlFlow:: Nodes:: ElementNode getControlFlowNode ( ) { none ( ) }
366-
367- override DataFlow:: ExprNode getNode ( ) { result .getExpr ( ) = call }
368-
369- override DataFlowCallable getEnclosingCallable ( ) {
370- result .asCallable ( ) = call .getEnclosingCallable ( )
371- }
372-
373- override string toString ( ) { result = call .toString ( ) }
374-
375- override Location getLocation ( ) { result = call .getLocation ( ) }
376- }
377-
378327/**
379328 * A synthesized call inside a callable with a flow summary.
380329 *
0 commit comments