mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
C#: Take phi nodes into account in Steps::getARead()
This commit is contained in:
@@ -6,18 +6,17 @@ import csharp
|
||||
* Provides functionality for performing simple data flow analysis.
|
||||
* This library is used by the dispatch library, which in turn is used by the
|
||||
* SSA library, so we cannot make use of the SSA library in this library.
|
||||
* Instead, this library relies on a self-contained, minimalistic SSA-like
|
||||
* implementation.
|
||||
* Instead, this library relies on the `BaseSsa` library.
|
||||
*/
|
||||
module Steps {
|
||||
private import semmle.code.csharp.dataflow.internal.BaseSSA
|
||||
|
||||
/**
|
||||
* Gets a read that is guaranteed to read the value assigned at definition `def`.
|
||||
* Gets a read that may read the value assigned at definition `def`.
|
||||
*/
|
||||
private AssignableRead getARead(AssignableDefinition def) {
|
||||
exists(BaseSsa::Definition ssaDef |
|
||||
ssaDef.getDefinition() = def and
|
||||
ssaDef.getAnUltimateDefinition().getDefinition() = def and
|
||||
result = ssaDef.getARead()
|
||||
)
|
||||
or
|
||||
|
||||
@@ -278,7 +278,7 @@ public class Captured
|
||||
|
||||
void M10(bool b)
|
||||
{
|
||||
var x = ""; // GOOD [FALSE POSITIVE]
|
||||
var x = ""; // GOOD
|
||||
Action action;
|
||||
if (b)
|
||||
action = () => System.Console.WriteLine(x);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
| DeadStoreOfLocal.cs:142:26:142:27 | Exception ex | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.cs:142:26:142:27 | ex | ex |
|
||||
| DeadStoreOfLocal.cs:246:17:246:24 | Int32 y = ... | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.cs:246:17:246:17 | y | y |
|
||||
| DeadStoreOfLocal.cs:261:17:261:21 | Int32 x = ... | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.cs:261:17:261:17 | x | x |
|
||||
| DeadStoreOfLocal.cs:281:13:281:18 | String x = ... | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.cs:281:13:281:13 | x | x |
|
||||
| DeadStoreOfLocal.cs:300:23:300:28 | Object v1 | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.cs:300:27:300:28 | v1 | v1 |
|
||||
| DeadStoreOfLocal.cs:314:18:314:23 | Object v2 | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.cs:314:22:314:23 | v2 | v2 |
|
||||
| DeadStoreOfLocal.cs:331:9:331:32 | ... = ... | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.cs:327:23:327:23 | b | b |
|
||||
|
||||
Reference in New Issue
Block a user