Skip to content

Commit dd465e7

Browse files
hvitvedtamasvajk
authored andcommitted
Code review suggestion
1 parent 36c9130 commit dd465e7

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ private import dotnet
44
private import DataFlowImplCommon as DataFlowImplCommon
55
private import DataFlowPublic
66
private import DataFlowPrivate
7-
private import semmle.code.csharp.controlflow.internal.Splitting
87
private import FlowSummaryImpl as FlowSummaryImpl
98
private import semmle.code.csharp.dataflow.FlowSummary as FlowSummary
109
private import semmle.code.csharp.dataflow.ExternalFlow
@@ -22,7 +21,13 @@ private import semmle.code.csharp.frameworks.system.collections.Generic
2221
*/
2322
DotNet::Callable getCallableForDataFlow(DotNet::Callable c) {
2423
exists(DotNet::Callable unboundDecl | unboundDecl = c.getUnboundDeclaration() |
25-
result.hasBody() and
24+
(
25+
result.hasBody()
26+
or
27+
// take synthesized bodies into account, e.g. implicit constructors
28+
// with field initializer assignments
29+
result = any(ControlFlow::Nodes::ElementNode n).getEnclosingCallable()
30+
) and
2631
if unboundDecl.getFile().fromSource()
2732
then
2833
// C# callable with C# implementation in the database
@@ -40,16 +45,6 @@ DotNet::Callable getCallableForDataFlow(DotNet::Callable c) {
4045
// C# callable without C# implementation in the database
4146
unboundDecl.matchesHandle(result.(CIL::Callable))
4247
)
43-
or
44-
result = c.getUnboundDeclaration() and
45-
isDefaultConstructorWithMemberInit(result)
46-
}
47-
48-
private predicate isDefaultConstructorWithMemberInit(InstanceConstructor c) {
49-
c.isUnboundDeclaration() and
50-
c.getFile().fromSource() and
51-
not c.hasBody() and
52-
InitializerSplitting::constructorInitializes(c, _)
5348
}
5449

5550
/**

0 commit comments

Comments
 (0)