mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C#: Fix CFG for unknown expressions, and add a test that also covers object initializer lists fixed by the extractor.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
// semmle-extractor-options: --standalone
|
||||
|
||||
using System;
|
||||
|
||||
class Cfg
|
||||
{
|
||||
void F()
|
||||
{
|
||||
var v = new InvalidType();
|
||||
Debug.Assert(v.a.b, "This is true");
|
||||
|
||||
new CounterCreationData() { CounterHelp = string.Empty, CounterType = v.Type };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
| ControlFlow.cs:7:10:7:10 | enter F | ControlFlow.cs:8:5:13:5 | {...} |
|
||||
| ControlFlow.cs:8:5:13:5 | {...} | ControlFlow.cs:9:9:9:34 | ... ...; |
|
||||
| ControlFlow.cs:9:9:9:34 | ... ...; | ControlFlow.cs:9:13:9:13 | access to local variable v |
|
||||
| ControlFlow.cs:10:9:10:13 | Expression | ControlFlow.cs:10:22:10:22 | access to local variable v |
|
||||
| ControlFlow.cs:10:9:10:43 | Call to unknown method | ControlFlow.cs:12:9:12:87 | ...; |
|
||||
| ControlFlow.cs:10:9:10:44 | ...; | ControlFlow.cs:10:9:10:13 | Expression |
|
||||
| ControlFlow.cs:10:22:10:22 | access to local variable v | ControlFlow.cs:10:22:10:24 | Expression |
|
||||
| ControlFlow.cs:10:22:10:24 | Expression | ControlFlow.cs:10:22:10:26 | Expression |
|
||||
| ControlFlow.cs:10:22:10:26 | Expression | ControlFlow.cs:10:29:10:42 | "This is true" |
|
||||
| ControlFlow.cs:10:29:10:42 | "This is true" | ControlFlow.cs:10:9:10:43 | Call to unknown method |
|
||||
| ControlFlow.cs:12:35:12:86 | { ..., ... } | ControlFlow.cs:7:10:7:10 | exit F |
|
||||
| ControlFlow.cs:12:37:12:47 | Expression | ControlFlow.cs:12:51:12:62 | access to field Empty |
|
||||
| ControlFlow.cs:12:37:12:62 | ... = ... | ControlFlow.cs:12:65:12:75 | Expression |
|
||||
| ControlFlow.cs:12:51:12:62 | access to field Empty | ControlFlow.cs:12:37:12:62 | ... = ... |
|
||||
| ControlFlow.cs:12:65:12:75 | Expression | ControlFlow.cs:12:79:12:79 | access to local variable v |
|
||||
| ControlFlow.cs:12:65:12:84 | ... = ... | ControlFlow.cs:12:35:12:86 | { ..., ... } |
|
||||
| ControlFlow.cs:12:79:12:79 | access to local variable v | ControlFlow.cs:12:79:12:84 | Expression |
|
||||
| ControlFlow.cs:12:79:12:84 | Expression | ControlFlow.cs:12:65:12:84 | ... = ... |
|
||||
18
csharp/ql/test/library-tests/standalone/controlflow/cfg.ql
Normal file
18
csharp/ql/test/library-tests/standalone/controlflow/cfg.ql
Normal file
@@ -0,0 +1,18 @@
|
||||
import csharp
|
||||
import semmle.code.csharp.controlflow.ControlFlowGraph
|
||||
|
||||
/**
|
||||
* A method call where the target is unknown.
|
||||
* The purpose of this is to ensure that all MethodCall expressions
|
||||
* have a valid `toString()`.
|
||||
*/
|
||||
class UnknownCall extends MethodCall
|
||||
{
|
||||
UnknownCall() { not exists(this.getTarget()) }
|
||||
|
||||
override string toString() { result = "Call to unknown method" }
|
||||
}
|
||||
|
||||
query predicate edges(ControlFlowNode n1, ControlFlowNode n2) {
|
||||
n2 = n1.getASuccessor()
|
||||
}
|
||||
Reference in New Issue
Block a user