Skip to content

Commit 3e91f0f

Browse files
committed
Expand range of callables requiring nodes to include unbound declarations of generic instantiations, static targets, and methods that have a body even if not flagged fromSource
1 parent 349268c commit 3e91f0f

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -998,20 +998,34 @@ private class InstanceCallable extends Callable {
998998
/**
999999
* A callable which is either itself defined in source or which is the target
10001000
* of some call in source, and therefore ought to have dataflow nodes created.
1001+
*
1002+
* Note that for library methods these are always unbound declarations, since
1003+
* generic instantiations never have dataflow nodes constructed.
10011004
*/
10021005
private class CallableUsedInSource extends Callable {
10031006
CallableUsedInSource() {
1007+
// Should generate nodes even for abstract methods declared in source
10041008
this.fromSource()
10051009
or
1006-
// Note that getARuntimeTarget cannot be used here, because the
1007-
// DelegateLikeCall case depends on lambda-flow, which in turn
1008-
// uses the dataflow library; hence this would introduce recursion
1009-
// into the definition of data-flow nodes.
1010-
exists(Call c, DispatchCall dc | c.fromSource() and c = dc.getCall() |
1011-
this = dc.getADynamicTarget()
1012-
)
1010+
// Should generate nodes even for synthetic methods derived from source
1011+
this.hasBody()
10131012
or
1014-
this = any(CallableAccess ca | ca.fromSource()).getTarget()
1013+
exists(Callable target |
1014+
exists(Call c | c.fromSource() |
1015+
// Note that getADynamicTarget does not always include getTarget.
1016+
target = c.getTarget()
1017+
or
1018+
// Note that getARuntimeTarget cannot be used here, because the
1019+
// DelegateLikeCall case depends on lambda-flow, which in turn
1020+
// uses the dataflow library; hence this would introduce recursion
1021+
// into the definition of data-flow nodes.
1022+
exists(DispatchCall dc | c = dc.getCall() | target = dc.getADynamicTarget())
1023+
)
1024+
or
1025+
target = any(CallableAccess ca | ca.fromSource()).getTarget()
1026+
|
1027+
this = target.getUnboundDeclaration()
1028+
)
10151029
}
10161030
}
10171031

0 commit comments

Comments
 (0)