mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
C#: Add data flow test that illustrates issue with flow into phi nodes
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
failures
|
||||
| J.cs:125:21:125:40 | // ... | Missing result:hasValueFlow=10 |
|
||||
| J.cs:140:14:140:17 | (...) ... | Unexpected result: hasValueFlow=11 |
|
||||
edges
|
||||
| A.cs:5:17:5:28 | call to method Source<C> : C | A.cs:6:24:6:24 | access to local variable c : C |
|
||||
| A.cs:5:17:5:28 | call to method Source<C> : C | A.cs:6:24:6:24 | access to local variable c : C |
|
||||
@@ -918,6 +920,14 @@ edges
|
||||
| J.cs:106:14:106:15 | access to local variable a3 [property X] : Object | J.cs:106:14:106:17 | access to property X |
|
||||
| J.cs:107:14:107:15 | access to local variable a3 [property Y] : Object | J.cs:107:14:107:17 | access to property Y |
|
||||
| J.cs:107:14:107:15 | access to local variable a3 [property Y] : Object | J.cs:107:14:107:17 | access to property Y |
|
||||
| J.cs:133:13:133:13 | [post] access to local variable a [element] : Int32 | J.cs:140:14:140:14 | access to local variable a [element] : Int32 |
|
||||
| J.cs:133:13:133:13 | [post] access to local variable a [element] : Int32 | J.cs:140:14:140:14 | access to local variable a [element] : Int32 |
|
||||
| J.cs:133:19:133:33 | call to method Source<Int32> : Int32 | J.cs:133:13:133:13 | [post] access to local variable a [element] : Int32 |
|
||||
| J.cs:133:19:133:33 | call to method Source<Int32> : Int32 | J.cs:133:13:133:13 | [post] access to local variable a [element] : Int32 |
|
||||
| J.cs:140:14:140:14 | access to local variable a [element] : Int32 | J.cs:140:14:140:17 | access to indexer : Int32 |
|
||||
| J.cs:140:14:140:14 | access to local variable a [element] : Int32 | J.cs:140:14:140:17 | access to indexer : Int32 |
|
||||
| J.cs:140:14:140:17 | access to indexer : Int32 | J.cs:140:14:140:17 | (...) ... |
|
||||
| J.cs:140:14:140:17 | access to indexer : Int32 | J.cs:140:14:140:17 | (...) ... |
|
||||
nodes
|
||||
| A.cs:5:17:5:28 | call to method Source<C> : C | semmle.label | call to method Source<C> : C |
|
||||
| A.cs:5:17:5:28 | call to method Source<C> : C | semmle.label | call to method Source<C> : C |
|
||||
@@ -1925,6 +1935,16 @@ nodes
|
||||
| J.cs:107:14:107:15 | access to local variable a3 [property Y] : Object | semmle.label | access to local variable a3 [property Y] : Object |
|
||||
| J.cs:107:14:107:17 | access to property Y | semmle.label | access to property Y |
|
||||
| J.cs:107:14:107:17 | access to property Y | semmle.label | access to property Y |
|
||||
| J.cs:133:13:133:13 | [post] access to local variable a [element] : Int32 | semmle.label | [post] access to local variable a [element] : Int32 |
|
||||
| J.cs:133:13:133:13 | [post] access to local variable a [element] : Int32 | semmle.label | [post] access to local variable a [element] : Int32 |
|
||||
| J.cs:133:19:133:33 | call to method Source<Int32> : Int32 | semmle.label | call to method Source<Int32> : Int32 |
|
||||
| J.cs:133:19:133:33 | call to method Source<Int32> : Int32 | semmle.label | call to method Source<Int32> : Int32 |
|
||||
| J.cs:140:14:140:14 | access to local variable a [element] : Int32 | semmle.label | access to local variable a [element] : Int32 |
|
||||
| J.cs:140:14:140:14 | access to local variable a [element] : Int32 | semmle.label | access to local variable a [element] : Int32 |
|
||||
| J.cs:140:14:140:17 | (...) ... | semmle.label | (...) ... |
|
||||
| J.cs:140:14:140:17 | (...) ... | semmle.label | (...) ... |
|
||||
| J.cs:140:14:140:17 | access to indexer : Int32 | semmle.label | access to indexer : Int32 |
|
||||
| J.cs:140:14:140:17 | access to indexer : Int32 | semmle.label | access to indexer : Int32 |
|
||||
subpaths
|
||||
| A.cs:6:24:6:24 | access to local variable c : C | A.cs:147:32:147:32 | c : C | A.cs:149:20:149:27 | object creation of type B [field c] : C | A.cs:6:17:6:25 | call to method Make [field c] : C |
|
||||
| A.cs:6:24:6:24 | access to local variable c : C | A.cs:147:32:147:32 | c : C | A.cs:149:20:149:27 | object creation of type B [field c] : C | A.cs:6:17:6:25 | call to method Make [field c] : C |
|
||||
@@ -2101,3 +2121,4 @@ subpaths
|
||||
| J.cs:102:14:102:17 | access to property X | J.cs:97:17:97:33 | call to method Source<Object> : Object | J.cs:102:14:102:17 | access to property X | $@ | J.cs:97:17:97:33 | call to method Source<Object> : Object | call to method Source<Object> : Object |
|
||||
| J.cs:106:14:106:17 | access to property X | J.cs:97:17:97:33 | call to method Source<Object> : Object | J.cs:106:14:106:17 | access to property X | $@ | J.cs:97:17:97:33 | call to method Source<Object> : Object | call to method Source<Object> : Object |
|
||||
| J.cs:107:14:107:17 | access to property Y | J.cs:105:32:105:48 | call to method Source<Object> : Object | J.cs:107:14:107:17 | access to property Y | $@ | J.cs:105:32:105:48 | call to method Source<Object> : Object | call to method Source<Object> : Object |
|
||||
| J.cs:140:14:140:17 | (...) ... | J.cs:133:19:133:33 | call to method Source<Int32> : Int32 | J.cs:140:14:140:17 | (...) ... | $@ | J.cs:133:19:133:33 | call to method Source<Int32> : Int32 | call to method Source<Int32> : Int32 |
|
||||
|
||||
@@ -111,6 +111,35 @@ public class J
|
||||
Sink(a4.Y); // no flow
|
||||
}
|
||||
|
||||
private void M6(bool b)
|
||||
{
|
||||
var a = new int[1];
|
||||
if (b)
|
||||
{
|
||||
a[0] = Source<int>(10);
|
||||
}
|
||||
else
|
||||
{
|
||||
a = new int[1];
|
||||
}
|
||||
Sink(a[0]); // $ hasValueFlow=10
|
||||
}
|
||||
|
||||
private void M7(bool b)
|
||||
{
|
||||
var a = new System.Collections.Generic.List<int>();
|
||||
if (b)
|
||||
{
|
||||
a.Add(Source<int>(11));
|
||||
a.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
a = new System.Collections.Generic.List<int>();
|
||||
}
|
||||
Sink(a[0]);
|
||||
}
|
||||
|
||||
public static void Sink(object o) { }
|
||||
|
||||
static T Source<T>(object source) => throw null;
|
||||
|
||||
Reference in New Issue
Block a user