diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll index 3e33807991a9..7fe4522360d1 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll @@ -1186,8 +1186,6 @@ module Internal { or e instanceof ArrayCreation or - e.hasNotNullFlowState() - or e.hasValue() and exists(Expr stripped | stripped = e.stripCasts() | not stripped instanceof NullLiteral and diff --git a/csharp/ql/lib/semmle/code/csharp/exprs/Expr.qll b/csharp/ql/lib/semmle/code/csharp/exprs/Expr.qll index ada010652588..bf3b9c873f6a 100644 --- a/csharp/ql/lib/semmle/code/csharp/exprs/Expr.qll +++ b/csharp/ql/lib/semmle/code/csharp/exprs/Expr.qll @@ -108,12 +108,6 @@ class Expr extends ControlFlowElement, @expr { * that uses the result of this expression. */ override Element getParent() { result = ControlFlowElement.super.getParent() } - - /** Holds if the nullable flow state of this expression is not null. */ - predicate hasNotNullFlowState() { expr_flowstate(this, 1) } - - /** Holds if the nullable flow state of this expression may be null. */ - predicate hasMaybeNullFlowState() { expr_flowstate(this, 2) } } /** diff --git a/csharp/ql/test/library-tests/controlflow/guards/AbstractValue.expected b/csharp/ql/test/library-tests/controlflow/guards/AbstractValue.expected index b6059d487728..97d3e9cfbcfe 100644 --- a/csharp/ql/test/library-tests/controlflow/guards/AbstractValue.expected +++ b/csharp/ql/test/library-tests/controlflow/guards/AbstractValue.expected @@ -91,285 +91,77 @@ abstractValue | non-empty | Collections.cs:88:26:88:32 | { ..., ... } | | non-empty | Collections.cs:89:22:89:28 | { ..., ... } | | non-null | Assert.cs:9:31:9:32 | "" | -| non-null | Assert.cs:10:9:10:13 | access to type Debug | -| non-null | Assert.cs:11:9:11:15 | access to type Console | -| non-null | Assert.cs:11:27:11:27 | access to local variable s | | non-null | Assert.cs:16:31:16:32 | "" | -| non-null | Assert.cs:17:9:17:14 | access to type Assert | -| non-null | Assert.cs:18:9:18:15 | access to type Console | | non-null | Assert.cs:23:31:23:32 | "" | -| non-null | Assert.cs:24:9:24:14 | access to type Assert | -| non-null | Assert.cs:25:9:25:15 | access to type Console | | non-null | Assert.cs:30:31:30:32 | "" | -| non-null | Assert.cs:31:9:31:14 | access to type Assert | -| non-null | Assert.cs:32:9:32:15 | access to type Console | | non-null | Assert.cs:37:31:37:32 | "" | -| non-null | Assert.cs:38:9:38:14 | access to type Assert | -| non-null | Assert.cs:39:9:39:15 | access to type Console | | non-null | Assert.cs:44:31:44:32 | "" | -| non-null | Assert.cs:45:9:45:14 | access to type Assert | -| non-null | Assert.cs:46:9:46:15 | access to type Console | | non-null | Assert.cs:51:31:51:32 | "" | -| non-null | Assert.cs:52:9:52:14 | access to type Assert | -| non-null | Assert.cs:53:9:53:15 | access to type Console | | non-null | Assert.cs:58:31:58:32 | "" | -| non-null | Assert.cs:59:9:59:14 | access to type Assert | -| non-null | Assert.cs:60:9:60:15 | access to type Console | | non-null | Assert.cs:65:31:65:32 | "" | -| non-null | Assert.cs:66:9:66:14 | access to type Assert | -| non-null | Assert.cs:67:9:67:15 | access to type Console | | non-null | Assert.cs:72:31:72:32 | "" | -| non-null | Assert.cs:73:9:73:14 | access to type Assert | -| non-null | Assert.cs:74:9:74:15 | access to type Console | | non-null | Assert.cs:79:31:79:32 | "" | -| non-null | Assert.cs:80:9:80:14 | access to type Assert | -| non-null | Assert.cs:81:9:81:15 | access to type Console | | non-null | Assert.cs:93:9:93:35 | this access | -| non-null | Collections.cs:11:17:11:20 | access to parameter args | -| non-null | Collections.cs:12:13:12:16 | access to parameter args | -| non-null | Collections.cs:13:13:13:16 | access to parameter args | -| non-null | Collections.cs:14:13:14:16 | access to parameter args | -| non-null | Collections.cs:15:13:15:16 | access to parameter args | -| non-null | Collections.cs:16:13:16:16 | access to parameter args | -| non-null | Collections.cs:17:13:17:16 | access to parameter args | -| non-null | Collections.cs:22:17:22:20 | access to parameter args | -| non-null | Collections.cs:23:13:23:16 | access to parameter args | -| non-null | Collections.cs:24:13:24:16 | access to parameter args | -| non-null | Collections.cs:25:13:25:16 | access to parameter args | -| non-null | Collections.cs:26:13:26:16 | access to parameter args | -| non-null | Collections.cs:27:13:27:16 | access to parameter args | -| non-null | Collections.cs:28:13:28:16 | access to parameter args | -| non-null | Collections.cs:33:17:33:20 | access to parameter args | -| non-null | Collections.cs:34:13:34:16 | access to parameter args | -| non-null | Collections.cs:35:13:35:16 | access to parameter args | -| non-null | Collections.cs:36:13:36:16 | access to parameter args | -| non-null | Collections.cs:37:13:37:16 | access to parameter args | -| non-null | Collections.cs:38:13:38:16 | access to parameter args | -| non-null | Collections.cs:39:13:39:16 | access to parameter args | -| non-null | Collections.cs:44:17:44:20 | access to parameter args | -| non-null | Collections.cs:49:13:49:16 | access to parameter args | -| non-null | Collections.cs:51:17:51:20 | access to parameter args | -| non-null | Collections.cs:51:17:51:30 | call to method ToArray | -| non-null | Collections.cs:52:9:52:12 | access to parameter args | -| non-null | Collections.cs:53:9:53:9 | access to local variable x | -| non-null | Collections.cs:53:9:53:26 | ... = ... | -| non-null | Collections.cs:53:13:53:16 | access to parameter args | -| non-null | Collections.cs:53:13:53:26 | call to method ToArray | -| non-null | Collections.cs:54:9:54:9 | access to local variable x | | non-null | Collections.cs:54:9:54:42 | ... = ... | | non-null | Collections.cs:54:13:54:42 | array creation of type String[] | | non-null | Collections.cs:54:28:54:30 | "a" | | non-null | Collections.cs:54:33:54:35 | "b" | | non-null | Collections.cs:54:38:54:40 | "c" | -| non-null | Collections.cs:55:9:55:9 | access to local variable x | | non-null | Collections.cs:55:9:55:13 | ... = ... | | non-null | Collections.cs:55:13:55:13 | access to local variable x | -| non-null | Collections.cs:56:9:56:9 | access to local variable x | | non-null | Collections.cs:56:9:56:25 | ... = ... | | non-null | Collections.cs:56:13:56:25 | array creation of type String[] | -| non-null | Collections.cs:57:9:57:9 | access to local variable x | | non-null | Collections.cs:57:9:57:13 | ... = ... | | non-null | Collections.cs:57:13:57:13 | access to local variable x | | non-null | Collections.cs:62:17:62:46 | array creation of type String[] | -| non-null | Collections.cs:62:17:62:55 | call to method ToList | | non-null | Collections.cs:62:32:62:34 | "a" | | non-null | Collections.cs:62:37:62:39 | "b" | | non-null | Collections.cs:62:42:62:44 | "c" | -| non-null | Collections.cs:63:9:63:9 | access to local variable x | -| non-null | Collections.cs:64:13:64:13 | access to local variable x | -| non-null | Collections.cs:66:13:66:13 | access to local variable x | | non-null | Collections.cs:66:19:66:21 | "a" | -| non-null | Collections.cs:67:13:67:13 | access to local variable x | | non-null | Collections.cs:67:19:67:21 | "b" | -| non-null | Collections.cs:73:35:73:35 | access to parameter s | | non-null | Collections.cs:73:40:73:41 | "" | -| non-null | Collections.cs:74:17:74:20 | access to parameter args | -| non-null | Collections.cs:74:26:74:32 | access to local function IsEmpty | -| non-null | Collections.cs:74:26:74:32 | delegate creation of type Func | | non-null | Collections.cs:74:26:74:32 | this access | -| non-null | Collections.cs:75:13:75:16 | access to parameter args | -| non-null | Collections.cs:75:24:75:30 | access to local function IsEmpty | -| non-null | Collections.cs:75:24:75:30 | delegate creation of type Func | | non-null | Collections.cs:75:24:75:30 | this access | -| non-null | Collections.cs:76:13:76:16 | access to parameter args | -| non-null | Collections.cs:76:24:76:30 | access to local function IsEmpty | -| non-null | Collections.cs:76:24:76:30 | delegate creation of type Func | | non-null | Collections.cs:76:24:76:30 | this access | -| non-null | Collections.cs:77:13:77:16 | access to parameter args | -| non-null | Collections.cs:77:24:77:30 | access to local function IsEmpty | -| non-null | Collections.cs:77:24:77:30 | delegate creation of type Func | | non-null | Collections.cs:77:24:77:30 | this access | -| non-null | Collections.cs:78:13:78:16 | access to parameter args | -| non-null | Collections.cs:78:24:78:30 | access to local function IsEmpty | -| non-null | Collections.cs:78:24:78:30 | delegate creation of type Func | | non-null | Collections.cs:78:24:78:30 | this access | -| non-null | Collections.cs:79:13:79:16 | access to parameter args | -| non-null | Collections.cs:79:24:79:30 | access to local function IsEmpty | -| non-null | Collections.cs:79:24:79:30 | delegate creation of type Func | | non-null | Collections.cs:79:24:79:30 | this access | -| non-null | Collections.cs:80:13:80:16 | access to parameter args | -| non-null | Collections.cs:80:24:80:30 | access to local function IsEmpty | -| non-null | Collections.cs:80:24:80:30 | delegate creation of type Func | | non-null | Collections.cs:80:24:80:30 | this access | -| non-null | Collections.cs:81:13:81:16 | access to parameter args | -| non-null | Collections.cs:81:24:81:30 | access to local function IsEmpty | -| non-null | Collections.cs:81:24:81:30 | delegate creation of type Func | | non-null | Collections.cs:81:24:81:30 | this access | | non-null | Collections.cs:86:17:86:32 | array creation of type String[] | | non-null | Collections.cs:87:22:87:24 | array creation of type String[] | -| non-null | Collections.cs:88:9:88:9 | access to local variable x | | non-null | Collections.cs:88:9:88:32 | ... = ... | | non-null | Collections.cs:88:13:88:32 | array creation of type String[] | | non-null | Collections.cs:88:28:88:30 | "a" | | non-null | Collections.cs:89:22:89:28 | array creation of type String[] | | non-null | Collections.cs:89:24:89:26 | "a" | -| non-null | Collections.cs:94:29:94:32 | access to parameter args | -| non-null | Collections.cs:95:13:95:19 | access to type Console | -| non-null | Collections.cs:95:31:95:34 | access to parameter args | -| non-null | Collections.cs:100:29:100:32 | access to parameter args | -| non-null | Collections.cs:102:9:102:15 | access to type Console | -| non-null | Collections.cs:102:27:102:30 | access to parameter args | -| non-null | Guards.cs:12:13:12:13 | access to parameter s | -| non-null | Guards.cs:14:13:14:19 | access to type Console | -| non-null | Guards.cs:14:31:14:31 | access to parameter s | -| non-null | Guards.cs:18:13:18:19 | access to type Console | | non-null | Guards.cs:18:31:18:46 | "" | -| non-null | Guards.cs:26:13:26:19 | access to type Console | -| non-null | Guards.cs:26:31:26:31 | access to parameter s | -| non-null | Guards.cs:32:14:32:19 | access to type String | -| non-null | Guards.cs:33:13:33:19 | access to type Console | | non-null | Guards.cs:33:31:33:35 | ... + ... | -| non-null | Guards.cs:36:14:36:20 | access to type Console | -| non-null | Guards.cs:36:32:36:32 | access to parameter x | | non-null | Guards.cs:36:32:36:36 | ... + ... | -| non-null | Guards.cs:36:36:36:36 | access to parameter y | -| non-null | Guards.cs:39:13:39:19 | access to type Console | -| non-null | Guards.cs:39:31:39:31 | access to parameter x | | non-null | Guards.cs:39:31:39:35 | ... + ... | -| non-null | Guards.cs:39:35:39:35 | access to parameter y | -| non-null | Guards.cs:42:14:42:20 | access to type Console | -| non-null | Guards.cs:42:32:42:32 | access to parameter x | | non-null | Guards.cs:42:32:42:36 | ... + ... | -| non-null | Guards.cs:42:36:42:36 | access to parameter y | | non-null | Guards.cs:44:13:44:17 | this access | -| non-null | Guards.cs:45:13:45:19 | access to type Console | | non-null | Guards.cs:45:31:45:42 | object creation of type Guards | | non-null | Guards.cs:47:13:47:17 | this access | -| non-null | Guards.cs:48:13:48:19 | access to type Console | | non-null | Guards.cs:48:31:48:34 | this access | -| non-null | Guards.cs:48:31:48:40 | access to field Field | -| non-null | Guards.cs:53:13:53:13 | access to parameter g | -| non-null | Guards.cs:55:9:55:15 | access to type Console | -| non-null | Guards.cs:55:27:55:27 | access to parameter g | -| non-null | Guards.cs:55:27:55:33 | access to field Field | -| non-null | Guards.cs:60:13:60:13 | access to parameter g | | non-null | Guards.cs:61:19:61:33 | object creation of type Exception | -| non-null | Guards.cs:62:9:62:15 | access to type Console | -| non-null | Guards.cs:62:27:62:27 | access to parameter g | -| non-null | Guards.cs:62:27:62:36 | access to property Property | -| non-null | Guards.cs:62:27:62:45 | access to property Property | -| non-null | Guards.cs:62:27:62:51 | access to field Field | -| non-null | Guards.cs:63:9:63:15 | access to type Console | -| non-null | Guards.cs:63:27:63:27 | access to parameter g | -| non-null | Guards.cs:63:27:63:36 | access to property Property | -| non-null | Guards.cs:70:13:70:19 | access to type Console | -| non-null | Guards.cs:70:31:70:31 | access to parameter s | -| non-null | Guards.cs:71:13:71:13 | access to parameter s | -| non-null | Guards.cs:72:13:72:19 | access to type Console | | non-null | Guards.cs:78:26:78:26 | (...) ... | -| non-null | Guards.cs:79:13:79:19 | access to type Console | -| non-null | Guards.cs:79:31:79:31 | access to parameter s | | non-null | Guards.cs:80:25:80:25 | (...) ... | -| non-null | Guards.cs:81:13:81:19 | access to type Console | -| non-null | Guards.cs:81:31:81:31 | access to parameter s | | non-null | Guards.cs:82:26:82:26 | (...) ... | -| non-null | Guards.cs:83:13:83:19 | access to type Console | -| non-null | Guards.cs:83:31:83:31 | access to parameter s | | non-null | Guards.cs:84:25:84:26 | (...) ... | -| non-null | Guards.cs:85:13:85:19 | access to type Console | -| non-null | Guards.cs:85:31:85:31 | access to parameter s | | non-null | Guards.cs:86:26:86:27 | (...) ... | -| non-null | Guards.cs:87:13:87:19 | access to type Console | -| non-null | Guards.cs:87:31:87:31 | access to parameter s | -| non-null | Guards.cs:89:13:89:19 | access to type Console | -| non-null | Guards.cs:89:31:89:31 | access to parameter s | -| non-null | Guards.cs:91:13:91:19 | access to type Console | | non-null | Guards.cs:92:25:92:25 | (...) ... | | non-null | Guards.cs:92:30:92:30 | (...) ... | -| non-null | Guards.cs:93:13:93:19 | access to type Console | -| non-null | Guards.cs:95:13:95:19 | access to type Console | | non-null | Guards.cs:96:18:96:19 | "" | -| non-null | Guards.cs:97:13:97:19 | access to type Console | -| non-null | Guards.cs:97:31:97:31 | access to parameter s | -| non-null | Guards.cs:99:13:99:19 | access to type Console | -| non-null | Guards.cs:104:13:104:13 | access to parameter g | | non-null | Guards.cs:105:19:105:33 | object creation of type Exception | -| non-null | Guards.cs:106:9:106:9 | access to parameter g | -| non-null | Guards.cs:106:9:106:18 | access to property Property | -| non-null | Guards.cs:107:9:107:15 | access to type Console | -| non-null | Guards.cs:107:27:107:27 | access to parameter g | -| non-null | Guards.cs:108:9:108:15 | access to type Console | -| non-null | Guards.cs:108:27:108:27 | access to parameter g | -| non-null | Guards.cs:108:27:108:36 | access to property Property | -| non-null | Guards.cs:113:21:113:21 | access to parameter g | -| non-null | Guards.cs:114:14:114:14 | access to parameter g | -| non-null | Guards.cs:114:14:114:23 | access to property Property | -| non-null | Guards.cs:114:14:114:32 | access to property Property | -| non-null | Guards.cs:115:9:115:55 | ... = ... | -| non-null | Guards.cs:115:17:115:17 | access to parameter g | -| non-null | Guards.cs:115:17:115:26 | access to property Property | -| non-null | Guards.cs:115:17:115:35 | access to property Property | -| non-null | Guards.cs:115:17:115:55 | ... ?? ... | -| non-null | Guards.cs:115:46:115:55 | throw ... | -| non-null | Guards.cs:116:9:116:15 | access to type Console | -| non-null | Guards.cs:116:27:116:27 | access to parameter g | -| non-null | Guards.cs:116:27:116:36 | access to property Property | -| non-null | Guards.cs:116:27:116:45 | access to property Property | -| non-null | Guards.cs:116:27:116:51 | access to field Field | -| non-null | Guards.cs:117:9:117:9 | access to parameter g | -| non-null | Guards.cs:117:9:117:18 | access to property Property | -| non-null | Guards.cs:118:9:118:15 | access to type Console | -| non-null | Guards.cs:118:27:118:27 | access to parameter g | -| non-null | Guards.cs:119:9:119:15 | access to type Console | -| non-null | Guards.cs:119:27:119:27 | access to parameter g | -| non-null | Guards.cs:119:27:119:36 | access to property Property | -| non-null | Guards.cs:125:18:125:19 | access to parameter s1 | -| non-null | Guards.cs:125:29:125:30 | access to parameter s1 | -| non-null | Guards.cs:132:16:132:16 | access to parameter s | -| non-null | Guards.cs:138:20:138:20 | access to parameter s | -| non-null | Guards.cs:145:20:145:20 | access to local variable s | -| non-null | Guards.cs:154:24:154:24 | access to parameter o | -| non-null | Guards.cs:156:24:156:24 | access to local variable a | -| non-null | Guards.cs:158:24:158:24 | access to parameter o | -| non-null | Guards.cs:162:24:162:24 | access to parameter o | -| non-null | Guards.cs:168:14:168:19 | access to type String | -| non-null | Guards.cs:169:13:169:19 | access to type Console | -| non-null | Guards.cs:169:31:169:31 | access to parameter x | | non-null | Guards.cs:183:38:183:49 | this access | | non-null | Guards.cs:189:14:189:25 | this access | -| non-null | Guards.cs:190:13:190:19 | access to type Console | | non-null | Guards.cs:191:14:191:25 | this access | -| non-null | Guards.cs:192:13:192:19 | access to type Console | | non-null | Guards.cs:193:14:193:25 | this access | -| non-null | Guards.cs:194:13:194:19 | access to type Console | | non-null | Guards.cs:195:13:195:27 | this access | -| non-null | Guards.cs:196:13:196:19 | access to type Console | | non-null | Guards.cs:197:14:197:29 | this access | -| non-null | Guards.cs:198:13:198:19 | access to type Console | -| non-null | Guards.cs:205:13:205:13 | access to parameter o | -| non-null | Guards.cs:206:33:206:36 | access to parameter args | -| non-null | Guards.cs:208:17:208:17 | access to parameter o | | non-null | Guards.cs:268:30:268:41 | call to method GetType | -| non-null | Guards.cs:269:13:269:14 | access to parameter o1 | -| non-null | Guards.cs:270:30:270:31 | access to parameter o2 | -| non-null | Guards.cs:279:17:279:17 | access to parameter o | -| non-null | Guards.cs:281:17:281:17 | access to local variable a | -| non-null | Guards.cs:283:17:283:17 | access to parameter o | -| non-null | Guards.cs:287:17:287:17 | access to parameter o | | non-null | Guards.cs:341:31:341:32 | "" | -| non-null | Guards.cs:343:13:343:19 | access to type Console | -| non-null | Guards.cs:343:31:343:31 | access to local variable s | -| non-null | Guards.cs:349:13:349:13 | access to parameter o | | null | Assert.cs:9:24:9:27 | null | | null | Assert.cs:10:27:10:30 | null | | null | Assert.cs:16:24:16:27 | null | diff --git a/csharp/ql/test/library-tests/controlflow/guards/Implications.expected b/csharp/ql/test/library-tests/controlflow/guards/Implications.expected index 9a9bdd82aa93..463e814616c4 100644 --- a/csharp/ql/test/library-tests/controlflow/guards/Implications.expected +++ b/csharp/ql/test/library-tests/controlflow/guards/Implications.expected @@ -209,7 +209,6 @@ | Collections.cs:67:13:67:13 | access to local variable x | non-null | Collections.cs:62:17:62:55 | call to method ToList | non-null | | Collections.cs:67:13:67:13 | access to local variable x | null | Collections.cs:62:17:62:55 | call to method ToList | null | | Collections.cs:73:35:73:41 | ... == ... | true | Collections.cs:73:35:73:35 | access to parameter s | non-null | -| Collections.cs:73:35:73:41 | ... == ... | true | Collections.cs:73:40:73:41 | "" | non-null | | Collections.cs:74:17:74:33 | call to method Any | true | Collections.cs:74:17:74:20 | access to parameter args | non-empty | | Collections.cs:75:13:75:36 | ... == ... | false | Collections.cs:75:13:75:16 | access to parameter args | non-empty | | Collections.cs:76:13:76:36 | ... == ... | true | Collections.cs:76:13:76:16 | access to parameter args | non-empty | @@ -244,8 +243,6 @@ | Guards.cs:35:26:35:34 | ... == ... | true | Guards.cs:35:26:35:26 | access to parameter y | null | | Guards.cs:36:32:36:36 | ... + ... | non-null | Guards.cs:36:32:36:32 | access to parameter x | non-null | | Guards.cs:36:32:36:36 | ... + ... | non-null | Guards.cs:36:36:36:36 | access to parameter y | non-null | -| Guards.cs:36:32:36:36 | ... + ... | null | Guards.cs:36:32:36:32 | access to parameter x | null | -| Guards.cs:36:32:36:36 | ... + ... | null | Guards.cs:36:36:36:36 | access to parameter y | null | | Guards.cs:38:13:38:37 | !... | false | Guards.cs:38:15:38:36 | ... \|\| ... | true | | Guards.cs:38:13:38:37 | !... | true | Guards.cs:38:15:38:36 | ... \|\| ... | false | | Guards.cs:38:15:38:23 | ... == ... | false | Guards.cs:38:15:38:15 | access to parameter x | non-null | @@ -256,8 +253,6 @@ | Guards.cs:38:28:38:36 | ... == ... | true | Guards.cs:38:28:38:28 | access to parameter y | null | | Guards.cs:39:31:39:35 | ... + ... | non-null | Guards.cs:39:31:39:31 | access to parameter x | non-null | | Guards.cs:39:31:39:35 | ... + ... | non-null | Guards.cs:39:35:39:35 | access to parameter y | non-null | -| Guards.cs:39:31:39:35 | ... + ... | null | Guards.cs:39:31:39:31 | access to parameter x | null | -| Guards.cs:39:31:39:35 | ... + ... | null | Guards.cs:39:35:39:35 | access to parameter y | null | | Guards.cs:41:13:41:39 | !... | false | Guards.cs:41:14:41:39 | !... | true | | Guards.cs:41:13:41:39 | !... | true | Guards.cs:41:14:41:39 | !... | false | | Guards.cs:41:14:41:39 | !... | false | Guards.cs:41:15:41:39 | !... | true | @@ -272,8 +267,6 @@ | Guards.cs:41:30:41:38 | ... != ... | true | Guards.cs:41:30:41:30 | access to parameter y | non-null | | Guards.cs:42:32:42:36 | ... + ... | non-null | Guards.cs:42:32:42:32 | access to parameter x | non-null | | Guards.cs:42:32:42:36 | ... + ... | non-null | Guards.cs:42:36:42:36 | access to parameter y | non-null | -| Guards.cs:42:32:42:36 | ... + ... | null | Guards.cs:42:32:42:32 | access to parameter x | null | -| Guards.cs:42:32:42:36 | ... + ... | null | Guards.cs:42:36:42:36 | access to parameter y | null | | Guards.cs:44:13:44:25 | ... != ... | false | Guards.cs:44:13:44:17 | access to field Field | null | | Guards.cs:44:13:44:25 | ... != ... | true | Guards.cs:44:13:44:17 | access to field Field | non-null | | Guards.cs:47:13:47:25 | ... != ... | false | Guards.cs:47:13:47:17 | access to field Field | null | @@ -330,8 +323,6 @@ | Guards.cs:119:27:119:36 | access to property Property | null | Guards.cs:117:22:117:25 | null | null | | Guards.cs:125:18:125:31 | call to method Equals | non-null | Guards.cs:125:18:125:19 | access to parameter s1 | non-null | | Guards.cs:125:18:125:31 | call to method Equals | null | Guards.cs:125:18:125:19 | access to parameter s1 | null | -| Guards.cs:125:18:125:31 | call to method Equals | true | Guards.cs:125:18:125:19 | access to parameter s1 | non-null | -| Guards.cs:125:18:125:31 | call to method Equals | true | Guards.cs:125:29:125:30 | access to parameter s1 | non-null | | Guards.cs:130:13:130:21 | ... is ... | false | Guards.cs:130:13:130:13 | access to parameter s | non-null | | Guards.cs:130:13:130:21 | ... is ... | true | Guards.cs:130:13:130:13 | access to parameter s | null | | Guards.cs:137:13:137:25 | ... is ... | false | Guards.cs:137:13:137:13 | access to parameter s | null | diff --git a/csharp/ql/test/library-tests/csharp8/NullableRefTypes.expected b/csharp/ql/test/library-tests/csharp8/NullableRefTypes.expected index 6ad47e73d01a..dbdc6829d348 100644 --- a/csharp/ql/test/library-tests/csharp8/NullableRefTypes.expected +++ b/csharp/ql/test/library-tests/csharp8/NullableRefTypes.expected @@ -44,14 +44,10 @@ nonNullExpressions | NullableRefTypes.cs:84:21:84:28 | "source" | | NullableRefTypes.cs:85:20:85:20 | access to local variable x | | NullableRefTypes.cs:85:20:85:21 | ...! | -| NullableRefTypes.cs:86:9:86:9 | access to local variable y | | NullableRefTypes.cs:86:9:86:14 | ... = ... | | NullableRefTypes.cs:86:13:86:13 | access to local variable x | | NullableRefTypes.cs:86:13:86:14 | ...! | -| NullableRefTypes.cs:87:9:87:9 | access to local variable x | -| NullableRefTypes.cs:88:9:88:9 | access to local variable y | | NullableRefTypes.cs:88:9:88:14 | ... = ... | -| NullableRefTypes.cs:88:13:88:13 | access to local variable x | | NullableRefTypes.cs:88:13:88:14 | ...! | assignableTypes | NullableRefTypes.cs:9:14:9:14 | A | NullableRefTypes.cs:6:7:6:13 | MyClass? | ? | @@ -404,93 +400,3 @@ expressionTypes | NullableRefTypes.cs:220:20:220:28 | call to method GetSelf | TestNullableFlowStates? | | NullableRefTypes.cs:220:20:220:28 | this access | TestNullableFlowStates | | NullableRefTypes.cs:220:20:220:34 | access to field Field | string! | -exprFlowState -| NullableRefTypes.cs:13:19:13:22 | null | Maybe null | -| NullableRefTypes.cs:14:18:14:21 | this access | Not null | -| NullableRefTypes.cs:17:29:17:32 | null | Maybe null | -| NullableRefTypes.cs:18:31:18:34 | this access | Not null | -| NullableRefTypes.cs:19:33:19:36 | this access | Not null | -| NullableRefTypes.cs:26:44:26:53 | throw ... | Not null | -| NullableRefTypes.cs:26:50:26:53 | null | Maybe null | -| NullableRefTypes.cs:27:44:27:53 | throw ... | Not null | -| NullableRefTypes.cs:27:50:27:53 | null | Maybe null | -| NullableRefTypes.cs:30:21:30:24 | null | Maybe null | -| NullableRefTypes.cs:31:20:31:23 | this access | Not null | -| NullableRefTypes.cs:37:21:37:33 | object creation of type MyClass | Not null | -| NullableRefTypes.cs:38:22:38:25 | null | Maybe null | -| NullableRefTypes.cs:39:29:39:29 | access to local variable b | Maybe null | -| NullableRefTypes.cs:40:30:40:30 | access to local variable b | Maybe null | -| NullableRefTypes.cs:51:44:51:47 | null | Maybe null | -| NullableRefTypes.cs:73:22:73:25 | null | Maybe null | -| NullableRefTypes.cs:74:9:74:20 | call to method GenericFn | Not null | -| NullableRefTypes.cs:74:19:74:19 | access to local variable x | Maybe null | -| NullableRefTypes.cs:75:9:75:12 | call to method Q | Not null | -| NullableRefTypes.cs:75:11:75:11 | access to local variable x | Maybe null | -| NullableRefTypes.cs:76:16:76:32 | default(...) | Not null | -| NullableRefTypes.cs:84:21:84:28 | "source" | Not null | -| NullableRefTypes.cs:85:20:85:20 | access to local variable x | Not null | -| NullableRefTypes.cs:85:20:85:21 | ...! | Not null | -| NullableRefTypes.cs:86:9:86:9 | access to local variable y | Not null | -| NullableRefTypes.cs:86:9:86:14 | ... = ... | Not null | -| NullableRefTypes.cs:86:13:86:13 | access to local variable x | Not null | -| NullableRefTypes.cs:86:13:86:14 | ...! | Not null | -| NullableRefTypes.cs:87:9:87:9 | access to local variable x | Not null | -| NullableRefTypes.cs:87:9:87:16 | ... = ... | Maybe null | -| NullableRefTypes.cs:87:13:87:16 | null | Maybe null | -| NullableRefTypes.cs:88:9:88:9 | access to local variable y | Not null | -| NullableRefTypes.cs:88:9:88:14 | ... = ... | Not null | -| NullableRefTypes.cs:88:13:88:13 | access to local variable x | Not null | -| NullableRefTypes.cs:88:13:88:14 | ...! | Not null | -| NullableRefTypes.cs:93:21:93:28 | "source" | Not null | -| NullableRefTypes.cs:94:17:94:17 | access to local variable x | Not null | -| NullableRefTypes.cs:94:17:94:25 | ... ?? ... | Maybe null | -| NullableRefTypes.cs:94:22:94:25 | null | Maybe null | -| NullableRefTypes.cs:95:20:95:20 | access to local variable x | Maybe null | -| NullableRefTypes.cs:96:9:96:15 | access to type Console | Not null | -| NullableRefTypes.cs:96:9:96:28 | call to method WriteLine | Not null | -| NullableRefTypes.cs:96:27:96:27 | access to local variable x | Maybe null | -| NullableRefTypes.cs:103:52:103:52 | access to parameter r | Not null | -| NullableRefTypes.cs:104:52:104:52 | access to parameter r | Maybe null | -| NullableRefTypes.cs:105:61:105:61 | access to parameter r | Maybe null | -| NullableRefTypes.cs:106:60:106:60 | access to parameter r | Not null | -| NullableRefTypes.cs:107:59:107:59 | access to parameter r | Not null | -| NullableRefTypes.cs:108:60:108:60 | access to parameter r | Maybe null | -| NullableRefTypes.cs:110:58:110:67 | throw ... | Not null | -| NullableRefTypes.cs:110:64:110:67 | null | Maybe null | -| NullableRefTypes.cs:113:36:113:43 | access to field Property | Not null | -| NullableRefTypes.cs:113:36:113:44 | ...! | Not null | -| NullableRefTypes.cs:181:21:181:31 | call to method MaybeNull | Maybe null | -| NullableRefTypes.cs:183:9:183:16 | call to method Check | Not null | -| NullableRefTypes.cs:183:15:183:15 | access to local variable x | Maybe null | -| NullableRefTypes.cs:185:22:185:22 | 0 | Not null | -| NullableRefTypes.cs:185:25:185:25 | access to local variable i | Not null | -| NullableRefTypes.cs:185:25:185:30 | ... < ... | Not null | -| NullableRefTypes.cs:185:29:185:30 | 10 | Not null | -| NullableRefTypes.cs:185:33:185:35 | ++... | Not null | -| NullableRefTypes.cs:185:35:185:35 | access to local variable i | Not null | -| NullableRefTypes.cs:187:13:187:13 | access to local variable x | Maybe null | -| NullableRefTypes.cs:187:13:187:35 | ... = ... | Not null | -| NullableRefTypes.cs:187:17:187:35 | "not null any more" | Not null | -| NullableRefTypes.cs:190:9:190:16 | call to method Check | Not null | -| NullableRefTypes.cs:190:15:190:15 | access to local variable x | Maybe null | -| NullableRefTypes.cs:195:21:195:31 | call to method MaybeNull | Maybe null | -| NullableRefTypes.cs:199:19:199:41 | object creation of type ArgumentException | Not null | -| NullableRefTypes.cs:203:13:203:13 | access to local variable y | Maybe null | -| NullableRefTypes.cs:203:13:203:26 | ... = ... | Not null | -| NullableRefTypes.cs:203:17:203:26 | "not null" | Not null | -| NullableRefTypes.cs:206:9:206:16 | call to method Check | Not null | -| NullableRefTypes.cs:206:15:206:15 | access to local variable y | Not null | -| NullableRefTypes.cs:211:17:211:17 | access to parameter o | Maybe null | -| NullableRefTypes.cs:211:17:211:28 | call to method GetType | Maybe null | -| NullableRefTypes.cs:212:16:212:16 | access to local variable t | Maybe null | -| NullableRefTypes.cs:212:16:212:27 | call to method ToString | Not null | -| NullableRefTypes.cs:217:21:217:29 | call to method GetSelf | Maybe null | -| NullableRefTypes.cs:217:21:217:36 | access to field Field | Maybe null | -| NullableRefTypes.cs:218:21:218:24 | access to parameter list | Maybe null | -| NullableRefTypes.cs:218:21:218:28 | access to indexer | Maybe null | -| NullableRefTypes.cs:218:27:218:27 | 0 | Not null | -| NullableRefTypes.cs:219:20:219:23 | access to parameter list | Maybe null | -| NullableRefTypes.cs:219:20:219:26 | access to indexer | Not null | -| NullableRefTypes.cs:219:25:219:25 | 0 | Not null | -| NullableRefTypes.cs:220:20:220:28 | call to method GetSelf | Maybe null | -| NullableRefTypes.cs:220:20:220:34 | access to field Field | Not null | diff --git a/csharp/ql/test/library-tests/csharp8/NullableRefTypes.ql b/csharp/ql/test/library-tests/csharp8/NullableRefTypes.ql index f519f9a14e83..c5fbe9e0d966 100644 --- a/csharp/ql/test/library-tests/csharp8/NullableRefTypes.ql +++ b/csharp/ql/test/library-tests/csharp8/NullableRefTypes.ql @@ -67,12 +67,3 @@ query predicate expressionTypes(Expr expr, string type) { type = expr.getAnnotatedType().toString() and expr.getFile().getBaseName() = "NullableRefTypes.cs" } - -query predicate exprFlowState(Expr expr, string state) { - expr.getFile().getBaseName() = "NullableRefTypes.cs" and - ( - expr.hasMaybeNullFlowState() and state = "Maybe null" - or - expr.hasNotNullFlowState() and state = "Not null" - ) -}