@@ -15,9 +15,9 @@ private import semmle.code.csharp.dispatch.Dispatch
1515private import semmle.code.csharp.frameworks.system.linq.Expressions
1616
1717/** A source of flow for a delegate or function pointer expression. */
18- private class DelegateLikeFlowSource extends DataFlow:: ExprNode {
18+ abstract private class DelegateLikeFlowSource extends DataFlow:: ExprNode {
1919 /** Gets the callable that is referenced in this delegate or function pointer flow source. */
20- Callable getCallable ( ) { none ( ) }
20+ abstract Callable getCallable ( ) ;
2121}
2222
2323/** A source of flow for a delegate expression. */
@@ -41,10 +41,13 @@ private class FunctionPointerFlowSource extends DelegateLikeFlowSource {
4141 Callable c ;
4242
4343 FunctionPointerFlowSource ( ) {
44- this .getExpr ( ) =
45- any ( Expr e |
46- c = e .( AddressOfExpr ) .getOperand ( ) .( CallableAccess ) .getTarget ( ) .getUnboundDeclaration ( )
47- )
44+ c =
45+ this .getExpr ( )
46+ .( AddressOfExpr )
47+ .getOperand ( )
48+ .( CallableAccess )
49+ .getTarget ( )
50+ .getUnboundDeclaration ( )
4851 }
4952
5053 /** Gets the callable that is referenced in this function pointer flow source. */
@@ -115,28 +118,12 @@ abstract private class DelegateLikeFlowSink extends DataFlow::Node {
115118
116119/** A delegate or function pointer call expression. */
117120class DelegateLikeCallExpr extends DelegateLikeFlowSink , DataFlow:: ExprNode {
118- /** Gets the delegate or function pointer call that this expression belongs to. */
119- DelegateLikeCall getCall ( ) { none ( ) }
120- }
121-
122- /** A delegate call expression. */
123- class DelegateCallExpr extends DelegateLikeCallExpr {
124- DelegateCall dc ;
121+ DelegateLikeCall dc ;
125122
126- DelegateCallExpr ( ) { this .getExpr ( ) = dc .getExpr ( ) }
123+ DelegateLikeCallExpr ( ) { this .getExpr ( ) = dc .getExpr ( ) }
127124
128- /** Gets the delegate call that this expression belongs to. */
129- override DelegateCall getCall ( ) { result = dc }
130- }
131-
132- /** A function pointer call expression. */
133- class FunctionPointerCallExpr extends DelegateLikeCallExpr {
134- FunctionPointerCall fptrc ;
135-
136- FunctionPointerCallExpr ( ) { this .getExpr ( ) = fptrc .getExpr ( ) }
137-
138- /** Gets the function pointer call that this expression belongs to. */
139- override FunctionPointerCall getCall ( ) { result = fptrc }
125+ /** Gets the delegate or function pointer call that this expression belongs to. */
126+ DelegateLikeCall getCall ( ) { result = dc }
140127}
141128
142129/** A parameter of delegate type belonging to a callable with a flow summary. */
0 commit comments