Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f2ca18

Browse files
michaelnebelhvitved
authored andcommitted
C#: Update dependencies.
1 parent e70a283 commit 2f2ca18

14 files changed

Lines changed: 112 additions & 78 deletions

csharp/ql/lib/semmle/code/csharp/dataflow/ExternalFlow.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,7 @@ Element interpretElement(
515515
/**
516516
* Holds if `c` has a `generated` summary.
517517
*/
518-
predicate hasSummary(DataFlowCallable c, boolean generated) {
519-
summaryElement(c, _, _, _, generated)
520-
}
518+
predicate hasSummary(Callable c, boolean generated) { summaryElement(c, _, _, _, generated) }
521519

522520
cached
523521
private module Cached {

csharp/ql/lib/semmle/code/csharp/dataflow/FlowSummary.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module SummaryComponent {
6868
SummaryComponent jump(Callable c) {
6969
result =
7070
return(any(DataFlowDispatch::JumpReturnKind jrk |
71-
jrk.getTarget() = c.getUnboundDeclaration() and
71+
jrk.getTarget().asCallable() = c.getUnboundDeclaration() and
7272
jrk.getTargetReturnKind() instanceof DataFlowDispatch::NormalReturnKind
7373
))
7474
}

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

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ private import semmle.code.csharp.frameworks.system.Collections
1313
private import semmle.code.csharp.frameworks.system.collections.Generic
1414

1515
private predicate summarizedCallable(DataFlowCallable c) {
16-
c instanceof FlowSummary::SummarizedCallable
16+
exists(c.asSummarizedCallable())
1717
or
1818
FlowSummaryImpl::Private::summaryReturnNode(_, TJumpReturnKind(c, _))
1919
or
20-
c = interpretElement(_, _, _, _, _, _)
20+
c.asCallable() = interpretElement(_, _, _, _, _, _)
2121
}
2222

2323
/**
@@ -29,7 +29,7 @@ private predicate summarizedCallable(DataFlowCallable c) {
2929
*/
3030
DotNet::Callable getCallableForDataFlow(DotNet::Callable c) {
3131
exists(DotNet::Callable unboundDecl | unboundDecl = c.getUnboundDeclaration() |
32-
summarizedCallable(unboundDecl) and
32+
summarizedCallable(TDotNetCallable(unboundDecl)) and
3333
result = unboundDecl
3434
or
3535
result.hasBody() and
@@ -84,11 +84,11 @@ newtype TReturnKind =
8484
TJumpReturnKind(DataFlowCallable target, ReturnKind rk) {
8585
rk instanceof NormalReturnKind and
8686
(
87-
target instanceof Constructor or
88-
not target.getReturnType() instanceof VoidType
87+
target.asCallable() instanceof Constructor or
88+
not target.asCallable().getReturnType() instanceof VoidType
8989
)
9090
or
91-
exists(target.getParameter(rk.(OutRefReturnKind).getPosition()))
91+
exists(target.asCallable().getParameter(rk.(OutRefReturnKind).getPosition()))
9292
}
9393

9494
private module Cached {
@@ -108,7 +108,7 @@ private module Cached {
108108
// No need to include calls that are compiled from source
109109
not call.getImplementation().getMethod().compiledFromSource()
110110
} or
111-
TSummaryCall(FlowSummary::SummarizedCallable c, Node receiver) {
111+
TSummaryCall(FlowSummaryImpl::Public::SummarizedCallable c, Node receiver) {
112112
FlowSummaryImpl::Private::summaryCallbackRange(c, receiver)
113113
}
114114

@@ -145,7 +145,7 @@ private module DispatchImpl {
145145
* the enclosing callable `c` (including the implicit `this` parameter).
146146
*/
147147
predicate mayBenefitFromCallContext(NonDelegateDataFlowCall call, Callable c) {
148-
c = call.getEnclosingCallable() and
148+
c = call.getEnclosingCallable().asCallable() and
149149
call.getDispatchCall().mayBenefitFromCallContext()
150150
}
151151

@@ -154,7 +154,7 @@ private module DispatchImpl {
154154
* restricted to those `call`s for which a context might make a difference.
155155
*/
156156
DataFlowCallable viableImplInCallContext(NonDelegateDataFlowCall call, DataFlowCall ctx) {
157-
result =
157+
result.asCallable() =
158158
call.getDispatchCall()
159159
.getADynamicTargetInCallContext(ctx.(NonDelegateDataFlowCall).getDispatchCall())
160160
.getUnboundDeclaration()
@@ -256,7 +256,7 @@ newtype TDataFlowCallable =
256256

257257
class DataFlowCallable extends TDataFlowCallable {
258258
/** Get the underlying source code callable, if any. */
259-
Callable asCallable() { this = TDotNetCallable(result) }
259+
DotNet::Callable asCallable() { this = TDotNetCallable(result) }
260260

261261
/** Get the underlying summarized callable, if any. */
262262
FlowSummary::SummarizedCallable asSummarizedCallable() { this = TSummarizedCallable(result) }
@@ -327,18 +327,20 @@ class NonDelegateDataFlowCall extends DataFlowCall, TNonDelegateCall {
327327
DispatchCall getDispatchCall() { result = dc }
328328

329329
override DataFlowCallable getARuntimeTarget() {
330-
result = getCallableForDataFlow(dc.getADynamicTarget())
330+
result.asCallable() = getCallableForDataFlow(dc.getADynamicTarget())
331331
or
332-
result = dc.getAStaticTarget().getUnboundDeclaration() and
332+
result.asCallable() = dc.getAStaticTarget().getUnboundDeclaration() and
333333
summarizedCallable(result) and
334-
not result instanceof RuntimeCallable
334+
not result.asCallable() instanceof RuntimeCallable
335335
}
336336

337337
override ControlFlow::Nodes::ElementNode getControlFlowNode() { result = cfn }
338338

339339
override DataFlow::ExprNode getNode() { result.getControlFlowNode() = cfn }
340340

341-
override DataFlowCallable getEnclosingCallable() { result = cfn.getEnclosingCallable() }
341+
override DataFlowCallable getEnclosingCallable() {
342+
result.asCallable() = cfn.getEnclosingCallable()
343+
}
342344

343345
override string toString() { result = cfn.toString() }
344346

@@ -366,7 +368,9 @@ class ExplicitDelegateLikeDataFlowCall extends DelegateDataFlowCall, TExplicitDe
366368

367369
override DataFlow::ExprNode getNode() { result.getControlFlowNode() = cfn }
368370

369-
override DataFlowCallable getEnclosingCallable() { result = cfn.getEnclosingCallable() }
371+
override DataFlowCallable getEnclosingCallable() {
372+
result.asCallable() = cfn.getEnclosingCallable()
373+
}
370374

371375
override string toString() { result = cfn.toString() }
372376

@@ -384,13 +388,15 @@ class TransitiveCapturedDataFlowCall extends DataFlowCall, TTransitiveCapturedCa
384388

385389
TransitiveCapturedDataFlowCall() { this = TTransitiveCapturedCall(cfn, target) }
386390

387-
override DataFlowCallable getARuntimeTarget() { result = target }
391+
override DataFlowCallable getARuntimeTarget() { result.asCallable() = target }
388392

389393
override ControlFlow::Nodes::ElementNode getControlFlowNode() { result = cfn }
390394

391395
override DataFlow::ExprNode getNode() { none() }
392396

393-
override DataFlowCallable getEnclosingCallable() { result = cfn.getEnclosingCallable() }
397+
override DataFlowCallable getEnclosingCallable() {
398+
result.asCallable() = cfn.getEnclosingCallable()
399+
}
394400

395401
override string toString() { result = "[transitive] " + cfn.toString() }
396402

@@ -405,14 +411,16 @@ class CilDataFlowCall extends DataFlowCall, TCilCall {
405411

406412
override DataFlowCallable getARuntimeTarget() {
407413
// There is no dispatch library for CIL, so do not consider overrides for now
408-
result = getCallableForDataFlow(call.getTarget())
414+
result.asCallable() = getCallableForDataFlow(call.getTarget())
409415
}
410416

411417
override ControlFlow::Nodes::ElementNode getControlFlowNode() { none() }
412418

413419
override DataFlow::ExprNode getNode() { result.getExpr() = call }
414420

415-
override DataFlowCallable getEnclosingCallable() { result = call.getEnclosingCallable() }
421+
override DataFlowCallable getEnclosingCallable() {
422+
result.asCallable() = call.getEnclosingCallable()
423+
}
416424

417425
override string toString() { result = call.toString() }
418426

@@ -427,7 +435,7 @@ class CilDataFlowCall extends DataFlowCall, TCilCall {
427435
* the method `Select`.
428436
*/
429437
class SummaryCall extends DelegateDataFlowCall, TSummaryCall {
430-
private FlowSummary::SummarizedCallable c;
438+
private FlowSummaryImpl::Public::SummarizedCallable c;
431439
private Node receiver;
432440

433441
SummaryCall() { this = TSummaryCall(c, receiver) }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ private module Cached {
698698
*/
699699
pragma[nomagic]
700700
private predicate mayBenefitFromCallContextExt(DataFlowCall call, DataFlowCallable callable) {
701-
mayBenefitFromCallContext(call, callable)
701+
mayBenefitFromCallContext(call, callable.asCallable())
702702
or
703703
callEnclosingCallable(call, callable) and
704704
exists(viableCallableLambda(call, TDataFlowCallSome(_)))

0 commit comments

Comments
 (0)