|
1 | 1 | private import csharp |
2 | 2 | private import cil |
3 | 3 | private import dotnet |
| 4 | +private import DataFlowImplCommon as DataFlowImplCommon |
4 | 5 | private import DataFlowPublic |
5 | 6 | private import DataFlowPrivate |
6 | 7 | private import FlowSummaryImpl as FlowSummaryImpl |
7 | | -private import semmle.code.csharp.Caching |
8 | 8 | private import semmle.code.csharp.dataflow.FlowSummary |
9 | 9 | private import semmle.code.csharp.dispatch.Dispatch |
10 | 10 | private import semmle.code.csharp.frameworks.system.Collections |
@@ -68,31 +68,30 @@ private predicate transitiveCapturedCallTarget(ControlFlow::Nodes::ElementNode c |
68 | 68 | ) |
69 | 69 | } |
70 | 70 |
|
71 | | -cached |
72 | | -private module Cached { |
73 | | - cached |
74 | | - newtype TReturnKind = |
75 | | - TNormalReturnKind() { Stages::DataFlowStage::forceCachingInSameStage() } or |
76 | | - TOutReturnKind(int i) { i = any(Parameter p | p.isOut()).getPosition() } or |
77 | | - TRefReturnKind(int i) { i = any(Parameter p | p.isRef()).getPosition() } or |
78 | | - TImplicitCapturedReturnKind(LocalScopeVariable v) { |
79 | | - exists(Ssa::ExplicitDefinition def | def.isCapturedVariableDefinitionFlowOut(_, _) | |
80 | | - v = def.getSourceVariable().getAssignable() |
81 | | - ) |
82 | | - } or |
83 | | - TJumpReturnKind(DataFlowCallable target, ReturnKind rk) { |
84 | | - rk instanceof NormalReturnKind and |
85 | | - ( |
86 | | - target instanceof Constructor or |
87 | | - not target.getReturnType() instanceof VoidType |
88 | | - ) |
89 | | - or |
90 | | - exists(target.getParameter(rk.(OutRefReturnKind).getPosition())) |
91 | | - } |
| 71 | +newtype TReturnKind = |
| 72 | + TNormalReturnKind() or |
| 73 | + TOutReturnKind(int i) { i = any(Parameter p | p.isOut()).getPosition() } or |
| 74 | + TRefReturnKind(int i) { i = any(Parameter p | p.isRef()).getPosition() } or |
| 75 | + TImplicitCapturedReturnKind(LocalScopeVariable v) { |
| 76 | + exists(Ssa::ExplicitDefinition def | def.isCapturedVariableDefinitionFlowOut(_, _) | |
| 77 | + v = def.getSourceVariable().getAssignable() |
| 78 | + ) |
| 79 | + } or |
| 80 | + TJumpReturnKind(DataFlowCallable target, ReturnKind rk) { |
| 81 | + rk instanceof NormalReturnKind and |
| 82 | + ( |
| 83 | + target instanceof Constructor or |
| 84 | + not target.getReturnType() instanceof VoidType |
| 85 | + ) |
| 86 | + or |
| 87 | + exists(target.getParameter(rk.(OutRefReturnKind).getPosition())) |
| 88 | + } |
92 | 89 |
|
| 90 | +private module Cached { |
93 | 91 | cached |
94 | 92 | newtype TDataFlowCall = |
95 | 93 | TNonDelegateCall(ControlFlow::Nodes::ElementNode cfn, DispatchCall dc) { |
| 94 | + DataFlowImplCommon::forceCachingInSameStage() and |
96 | 95 | cfn.getElement() = dc.getCall() |
97 | 96 | } or |
98 | 97 | TExplicitDelegateLikeCall(ControlFlow::Nodes::ElementNode cfn, DelegateLikeCall dc) { |
@@ -246,7 +245,6 @@ abstract class DataFlowCall extends TDataFlowCall { |
246 | 245 | abstract DataFlow::Node getNode(); |
247 | 246 |
|
248 | 247 | /** Gets the enclosing callable of this call. */ |
249 | | - cached |
250 | 248 | abstract DataFlowCallable getEnclosingCallable(); |
251 | 249 |
|
252 | 250 | /** Gets the underlying expression, if any. */ |
@@ -280,10 +278,7 @@ class NonDelegateDataFlowCall extends DataFlowCall, TNonDelegateCall { |
280 | 278 |
|
281 | 279 | override DataFlow::ExprNode getNode() { result.getControlFlowNode() = cfn } |
282 | 280 |
|
283 | | - override DataFlowCallable getEnclosingCallable() { |
284 | | - Stages::DataFlowStage::forceCachingInSameStage() and |
285 | | - result = cfn.getEnclosingCallable() |
286 | | - } |
| 281 | + override DataFlowCallable getEnclosingCallable() { result = cfn.getEnclosingCallable() } |
287 | 282 |
|
288 | 283 | override string toString() { result = cfn.toString() } |
289 | 284 |
|
|
0 commit comments