Skip to content

Commit a85f3cd

Browse files
committed
C#: No need to special-case default arguments in nullness analysis
1 parent 588f942 commit a85f3cd

2 files changed

Lines changed: 1 addition & 5 deletions

File tree

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,6 @@ private predicate defMaybeNull(Ssa::Definition def, ControlFlowNode node, string
216216
else msg = "because of $@ potential null argument"
217217
)
218218
or
219-
isNullDefaultArgument(def, reason) and
220-
node = def.getControlFlowNode() and
221-
msg = "because the parameter has a null default value"
222-
or
223219
// If the source of a variable is `null` then the variable may be `null`
224220
exists(AssignableDefinition adef | adef = def.(Ssa::ExplicitDefinition).getADefinition() |
225221
adef.getSource() = maybeNullExpr(node.asExpr()) and

csharp/ql/test/query-tests/Nullness/NullMaybe.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
| E.cs:302:9:302:9 | access to local variable s | Variable $@ may be null at this access because of $@ assignment. | E.cs:301:13:301:13 | s | s | E.cs:301:13:301:27 | String s = ... | this |
5353
| E.cs:343:9:343:9 | access to local variable x | Variable $@ may be null at this access because of $@ assignment. | E.cs:342:13:342:13 | x | x | E.cs:342:13:342:32 | String x = ... | this |
5454
| E.cs:349:9:349:9 | access to local variable x | Variable $@ may be null at this access because of $@ assignment. | E.cs:348:17:348:17 | x | x | E.cs:348:17:348:36 | dynamic x = ... | this |
55-
| E.cs:366:41:366:41 | access to parameter s | Variable $@ may be null at this access because the parameter has a null default value. | E.cs:366:28:366:28 | s | s | E.cs:366:32:366:35 | null | this |
55+
| E.cs:366:41:366:41 | access to parameter s | Variable $@ may be null at this access because of $@ assignment. | E.cs:366:28:366:28 | s | s | E.cs:366:32:366:35 | null | this |
5656
| E.cs:375:20:375:20 | access to local variable s | Variable $@ may be null at this access because of $@ assignment. | E.cs:374:17:374:17 | s | s | E.cs:374:17:374:31 | String s = ... | this |
5757
| E.cs:417:34:417:34 | access to parameter i | Variable $@ may be null at this access because it has a nullable type. | E.cs:415:27:415:27 | i | i | E.cs:415:27:415:27 | i | this |
5858
| E.cs:423:38:423:38 | access to parameter i | Variable $@ may be null at this access because it has a nullable type. | E.cs:420:27:420:27 | i | i | E.cs:420:27:420:27 | i | this |

0 commit comments

Comments
 (0)