File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
csharp/ql/lib/semmle/code/csharp/dataflow/internal Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -83,13 +83,26 @@ newtype TReturnKind =
8383 )
8484 }
8585
86+ /**
87+ * Holds if the summary for `c` should be used for dataflow analysis.
88+ */
89+ predicate useFlowSummary ( FlowSummary:: SummarizedCallable c ) {
90+ not c .fromSource ( )
91+ or
92+ c .fromSource ( ) and not c .isAutoGenerated ( )
93+ }
94+
8695private module Cached {
96+ /**
97+ * The following heuristic is used to rank when to use source code or when to use summaries for DataFlowCallables.
98+ * 1. Use hand written summaries.
99+ * 2. Use source code.
100+ * 3. Use auto generated summaries.
101+ */
87102 cached
88103 newtype TDataFlowCallable =
89- TDotNetCallable ( DotNet:: Callable c ) {
90- c .isUnboundDeclaration ( ) and not c instanceof FlowSummary:: SummarizedCallable
91- } or
92- TSummarizedCallable ( FlowSummary:: SummarizedCallable c )
104+ TDotNetCallable ( DotNet:: Callable c ) { c .isUnboundDeclaration ( ) and not useFlowSummary ( c ) } or
105+ TSummarizedCallable ( FlowSummary:: SummarizedCallable c ) { useFlowSummary ( c ) }
93106
94107 cached
95108 newtype TDataFlowCall =
Original file line number Diff line number Diff line change @@ -743,9 +743,11 @@ private module Cached {
743743 FlowSummaryImpl:: Public:: SummarizedCallable c ,
744744 FlowSummaryImpl:: Private:: SummaryNodeState state
745745 ) {
746+ useFlowSummary ( c ) and
746747 FlowSummaryImpl:: Private:: summaryNodeRange ( c , state )
747748 } or
748749 TSummaryParameterNode ( FlowSummaryImpl:: Public:: SummarizedCallable c , ParameterPosition pos ) {
750+ useFlowSummary ( c ) and
749751 FlowSummaryImpl:: Private:: summaryParameterNodeRange ( c , pos )
750752 } or
751753 TParamsArgumentNode ( ControlFlow:: Node callCfn ) {
You can’t perform that action at this time.
0 commit comments