Skip to content

Commit 8877b1e

Browse files
committed
Fixup - we only need to handle out parameter writes.
1 parent 82f0404 commit 8877b1e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ module Expressions {
430430
not this instanceof ArrayCreation and
431431
not this instanceof QualifiedWriteAccess and
432432
not this instanceof QualifiedAccessorWrite and
433-
not this instanceof QualifiedWriteAccessOutRef and
433+
not this instanceof QualifiedWriteAccessOutParam and
434434
not this instanceof NoNodeExpr and
435435
not this instanceof SwitchExpr and
436436
not this instanceof SwitchCaseExpr and
@@ -493,9 +493,12 @@ module Expressions {
493493
}
494494

495495
/**
496-
* An expression that writes via an accessor in an out/ref parameter, for example `s = M(out x.Field)`,
496+
* An expression that writes via an accessor in an `out` parameter, for example `s = M(out x.Field)`,
497497
* where `Field` is a field.
498498
*
499+
* Note that `ref` parameters are not included here as they are considered reads before the call.
500+
* Ideally, we would model `ref` parameters as both reads and writes, but that is not currently supported.
501+
*
499502
* Accessor writes need special attention, because we need to model that the
500503
* access is written after the method call.
501504
*
@@ -505,10 +508,10 @@ module Expressions {
505508
* x -> call M -> x.Field -> s = M(out x.Field)
506509
* ```
507510
*/
508-
private class QualifiedWriteAccessOutRef extends PostOrderTree instanceof Expr {
511+
private class QualifiedWriteAccessOutParam extends PostOrderTree instanceof Expr {
509512
final override predicate propagatesAbnormal(AstNode child) { child = getExprChild(this, _) }
510513

511-
QualifiedWriteAccessOutRef() {
514+
QualifiedWriteAccessOutParam() {
512515
exists(AssignableDefinitions::OutRefDefinition def |
513516
def.getExpr() = this and
514517
def.getTargetAccess() instanceof QualifiableExpr and

0 commit comments

Comments
 (0)