mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C#: Populate expression type nullability and nullable flow state.
This commit is contained in:
@@ -58,7 +58,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
|
||||
var initInfo = new ExpressionInfo(Context,
|
||||
new AnnotatedType(initializerType, Kinds.TypeAnnotation.NotAnnotated),
|
||||
new AnnotatedType(initializerType, NullableAnnotation.None),
|
||||
Context.Create(initializer.ThisOrBaseKeyword.GetLocation()),
|
||||
Kinds.ExprKind.CONSTRUCTOR_INIT,
|
||||
this,
|
||||
|
||||
@@ -46,6 +46,18 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
trapFile.expr_parent(this, Info.Child, Info.Parent);
|
||||
trapFile.expr_location(this, Location);
|
||||
|
||||
var annotatedType = Type.Symbol;
|
||||
if (!annotatedType.HasObliviousNullability())
|
||||
{
|
||||
var n = NullabilityEntity.Create(cx, Nullability.Create(annotatedType));
|
||||
trapFile.type_nullability(this, n);
|
||||
}
|
||||
|
||||
if(Info.FlowState != NullableFlowState.None)
|
||||
{
|
||||
trapFile.expr_flowstate(this, (int)Info.FlowState);
|
||||
}
|
||||
|
||||
if (Info.IsCompilerGenerated)
|
||||
trapFile.expr_compiler_generated(this);
|
||||
|
||||
@@ -344,6 +356,8 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// is null.
|
||||
/// </summary>
|
||||
string ExprValue { get; }
|
||||
|
||||
NullableFlowState FlowState { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -371,6 +385,9 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
ExprValue = value;
|
||||
IsCompilerGenerated = isCompilerGenerated;
|
||||
}
|
||||
|
||||
// Synthetic expressions don't have a flow state.
|
||||
public NullableFlowState FlowState => NullableFlowState.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -533,5 +550,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
return cachedSymbolInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public NullableFlowState FlowState => TypeInfo.Nullability.FlowState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
|
||||
var info = new ExpressionInfo(
|
||||
cx,
|
||||
new AnnotatedType(Entities.Type.Create(cx, cx.Compilation.GetSpecialType(Microsoft.CodeAnalysis.SpecialType.System_Int32)), Kinds.TypeAnnotation.NotAnnotated),
|
||||
new AnnotatedType(Entities.Type.Create(cx, cx.Compilation.GetSpecialType(Microsoft.CodeAnalysis.SpecialType.System_Int32)), NullableAnnotation.None),
|
||||
Location,
|
||||
ExprKind.INT_LITERAL,
|
||||
this,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Semmle.Extraction.Entities;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Semmle.Extraction.Kinds;
|
||||
|
||||
namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
@@ -7,8 +7,8 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
|
||||
{
|
||||
This(IExpressionInfo info) : base(info) { }
|
||||
|
||||
public static This CreateImplicit(Context cx, Type @class, Location loc, IExpressionParentEntity parent, int child) =>
|
||||
new This(new ExpressionInfo(cx, new AnnotatedType(@class, Kinds.TypeAnnotation.NotAnnotated), loc, Kinds.ExprKind.THIS_ACCESS, parent, child, true, null));
|
||||
public static This CreateImplicit(Context cx, Type @class, Extraction.Entities.Location loc, IExpressionParentEntity parent, int child) =>
|
||||
new This(new ExpressionInfo(cx, new AnnotatedType(@class, NullableAnnotation.None), loc, Kinds.ExprKind.THIS_ACCESS, parent, child, true, null));
|
||||
|
||||
public static This CreateExplicit(ExpressionNodeInfo info) => new This(info.SetKind(ExprKind.THIS_ACCESS));
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
Context.PopulateLater(() =>
|
||||
{
|
||||
var loc = Context.Create(initializer.GetLocation());
|
||||
var annotatedType = new AnnotatedType(type, TypeAnnotation.None);
|
||||
var annotatedType = new AnnotatedType(type, NullableAnnotation.None);
|
||||
var simpleAssignExpr = new Expression(new ExpressionInfo(Context, annotatedType, loc, ExprKind.SIMPLE_ASSIGN, this, child++, false, null));
|
||||
Expression.CreateFromNode(new ExpressionNodeInfo(Context, initializer.Value, simpleAssignExpr, 0));
|
||||
var access = new Expression(new ExpressionInfo(Context, annotatedType, Location, ExprKind.PROPERTY_ACCESS, simpleAssignExpr, 1, false, null));
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
return obj != null && obj.GetType() == typeof(NullType);
|
||||
}
|
||||
|
||||
public static AnnotatedType Create(Context cx) => new AnnotatedType(NullTypeFactory.Instance.CreateEntity(cx, null), Kinds.TypeAnnotation.None);
|
||||
public static AnnotatedType Create(Context cx) => new AnnotatedType(NullTypeFactory.Instance.CreateEntity(cx, null), NullableAnnotation.None);
|
||||
|
||||
class NullTypeFactory : ICachedEntityFactory<ITypeSymbol, NullType>
|
||||
{
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Semmle.Extraction.CSharp.Populators;
|
||||
using Semmle.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -14,14 +12,23 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// </summary>
|
||||
public struct AnnotatedType
|
||||
{
|
||||
public AnnotatedType(Type t, Kinds.TypeAnnotation a)
|
||||
public AnnotatedType(Type t, NullableAnnotation n)
|
||||
{
|
||||
Type = t;
|
||||
Annotation = a;
|
||||
annotation = n;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The underlying type.
|
||||
/// </summary>
|
||||
public Type Type;
|
||||
public Kinds.TypeAnnotation Annotation;
|
||||
|
||||
private NullableAnnotation annotation;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the annotated type symbol of this annotated type.
|
||||
/// </summary>
|
||||
public AnnotatedTypeSymbol Symbol => new AnnotatedTypeSymbol(Type.symbol, annotation);
|
||||
}
|
||||
|
||||
public abstract class Type : CachedSymbol<ITypeSymbol>
|
||||
@@ -274,7 +281,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
|
||||
public static AnnotatedType Create(Context cx, AnnotatedTypeSymbol type) =>
|
||||
new AnnotatedType(Create(cx, type.Symbol), type.Nullability.GetTypeAnnotation());
|
||||
new AnnotatedType(Create(cx, type.Symbol), type.Nullability);
|
||||
|
||||
public virtual int Dimension => 0;
|
||||
|
||||
|
||||
@@ -201,16 +201,6 @@ namespace Semmle.Extraction.CSharp
|
||||
trapFile.WriteTuple("explicitly_sized_array_creation", array);
|
||||
}
|
||||
|
||||
internal static void expr_compiler_generated(this TextWriter trapFile, Expression expr)
|
||||
{
|
||||
trapFile.WriteTuple("expr_compiler_generated", expr);
|
||||
}
|
||||
|
||||
internal static void expr_location(this TextWriter trapFile, Expression exprKey, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("expr_location", exprKey, location);
|
||||
}
|
||||
|
||||
internal static void expr_access(this TextWriter trapFile, Expression expr, IEntity access)
|
||||
{
|
||||
trapFile.WriteTuple("expr_access", expr, access);
|
||||
@@ -231,19 +221,34 @@ namespace Semmle.Extraction.CSharp
|
||||
trapFile.WriteTuple("expr_call", expr, target);
|
||||
}
|
||||
|
||||
internal static void expr_parent(this TextWriter trapFile, Expression exprKey, int child, IExpressionParentEntity parent)
|
||||
internal static void expr_compiler_generated(this TextWriter trapFile, Expression expr)
|
||||
{
|
||||
trapFile.WriteTuple("expr_parent", exprKey, child, parent);
|
||||
trapFile.WriteTuple("expr_compiler_generated", expr);
|
||||
}
|
||||
|
||||
internal static void expr_parent_top_level(this TextWriter trapFile, Expression exprKey, int child, IExpressionParentEntity parent)
|
||||
internal static void expr_flowstate(this TextWriter trapFile, Expression expr, int flowState)
|
||||
{
|
||||
trapFile.WriteTuple("expr_parent_top_level", exprKey, child, parent);
|
||||
trapFile.WriteTuple("expr_flowstate", expr, flowState);
|
||||
}
|
||||
|
||||
internal static void expr_value(this TextWriter trapFile, Expression exprKey, string value)
|
||||
internal static void expr_location(this TextWriter trapFile, Expression expr, Location location)
|
||||
{
|
||||
trapFile.WriteTuple("expr_value", exprKey, value);
|
||||
trapFile.WriteTuple("expr_location", expr, location);
|
||||
}
|
||||
|
||||
internal static void expr_parent(this TextWriter trapFile, Expression expr, int child, IExpressionParentEntity parent)
|
||||
{
|
||||
trapFile.WriteTuple("expr_parent", expr, child, parent);
|
||||
}
|
||||
|
||||
internal static void expr_parent_top_level(this TextWriter trapFile, Expression expr, int child, IExpressionParentEntity parent)
|
||||
{
|
||||
trapFile.WriteTuple("expr_parent_top_level", expr, child, parent);
|
||||
}
|
||||
|
||||
internal static void expr_value(this TextWriter trapFile, Expression expr, string value)
|
||||
{
|
||||
trapFile.WriteTuple("expr_value", expr, value);
|
||||
}
|
||||
|
||||
internal static void expressions(this TextWriter trapFile, Expression expr, ExprKind kind, Type exprType)
|
||||
|
||||
@@ -87,6 +87,12 @@ class Expr extends DotNet::Expr, ControlFlowElement, @expr {
|
||||
string getExplicitArgumentName() { expr_argument_name(this, result) }
|
||||
|
||||
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) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -483,7 +483,15 @@ case @nullability.kind of
|
||||
#keyset[parent, index]
|
||||
nullability_parent(int nullability: @nullability ref, int index: int ref, int parent: @nullability ref)
|
||||
|
||||
type_nullability(int id: @has_type_annotation ref, int nullability: @nullability ref)
|
||||
type_nullability(int id: @has_type_annotation ref, int nullability: @nullability ref);
|
||||
|
||||
/**
|
||||
* Thw nullable flow state of an expression, as determined by Roslyn.
|
||||
* 0 = none (default, not populated)
|
||||
* 1 = not null
|
||||
* 2 = maybe null
|
||||
*/
|
||||
expr_flowstate(unique int id: @expr ref, int state: int ref);
|
||||
|
||||
/** GENERICS **/
|
||||
|
||||
|
||||
@@ -222,3 +222,155 @@ annotatedTypeConstraints
|
||||
| NullableRefTypes.cs:58:20:58:21 | T1 | NullableRefTypes.cs:6:7:6:13 | MyClass! |
|
||||
| NullableRefTypes.cs:58:24:58:25 | T2 | NullableRefTypes.cs:54:11:54:33 | Generic<string?, T1?, IEnumerable<string?>!, MyClass!>! |
|
||||
typeNotAnnotated
|
||||
expressionTypes
|
||||
| NullableRefTypes.cs:13:19:13:22 | null | null |
|
||||
| NullableRefTypes.cs:14:18:14:21 | this access | MyClass! |
|
||||
| NullableRefTypes.cs:17:29:17:32 | null | null |
|
||||
| NullableRefTypes.cs:18:31:18:34 | this access | MyClass! |
|
||||
| NullableRefTypes.cs:19:33:19:36 | this access | MyClass! |
|
||||
| NullableRefTypes.cs:26:44:26:53 | throw ... | MyClass![]! |
|
||||
| NullableRefTypes.cs:26:50:26:53 | null | null |
|
||||
| NullableRefTypes.cs:27:44:27:53 | throw ... | MyClass![]! |
|
||||
| NullableRefTypes.cs:27:50:27:53 | null | null |
|
||||
| NullableRefTypes.cs:30:21:30:24 | null | null |
|
||||
| NullableRefTypes.cs:31:20:31:23 | this access | MyClass! |
|
||||
| NullableRefTypes.cs:37:17:37:17 | access to local variable a | MyClass! |
|
||||
| NullableRefTypes.cs:37:17:37:33 | MyClass a = ... | MyClass! |
|
||||
| NullableRefTypes.cs:37:21:37:33 | object creation of type MyClass | MyClass! |
|
||||
| NullableRefTypes.cs:38:18:38:18 | access to local variable b | MyClass! |
|
||||
| NullableRefTypes.cs:38:18:38:25 | MyClass b = ... | MyClass! |
|
||||
| NullableRefTypes.cs:38:22:38:25 | null | null |
|
||||
| NullableRefTypes.cs:39:21:39:21 | access to local variable c | null |
|
||||
| NullableRefTypes.cs:39:21:39:29 | MyClass c = ... | null |
|
||||
| NullableRefTypes.cs:39:25:39:29 | ref ... | MyClass |
|
||||
| NullableRefTypes.cs:39:29:39:29 | access to local variable b | MyClass? |
|
||||
| NullableRefTypes.cs:40:22:40:22 | access to local variable d | null |
|
||||
| NullableRefTypes.cs:40:22:40:30 | MyClass d = ... | null |
|
||||
| NullableRefTypes.cs:40:26:40:30 | ref ... | MyClass |
|
||||
| NullableRefTypes.cs:40:30:40:30 | access to local variable b | MyClass? |
|
||||
| NullableRefTypes.cs:51:44:51:47 | null | null |
|
||||
| NullableRefTypes.cs:73:18:73:18 | access to local variable x | MyClass! |
|
||||
| NullableRefTypes.cs:73:18:73:25 | MyClass x = ... | MyClass! |
|
||||
| NullableRefTypes.cs:73:22:73:25 | null | null |
|
||||
| NullableRefTypes.cs:74:9:74:20 | call to method GenericFn | Void! |
|
||||
| NullableRefTypes.cs:74:9:74:20 | this access | MyClass |
|
||||
| NullableRefTypes.cs:74:19:74:19 | access to local variable x | MyClass? |
|
||||
| NullableRefTypes.cs:75:9:75:12 | call to method Q | object! |
|
||||
| NullableRefTypes.cs:75:9:75:12 | this access | MyClass |
|
||||
| NullableRefTypes.cs:75:11:75:11 | access to local variable x | MyClass? |
|
||||
| NullableRefTypes.cs:76:16:76:32 | default(...) | MyStruct! |
|
||||
| NullableRefTypes.cs:76:24:76:31 | access to type MyStruct | MyStruct |
|
||||
| NullableRefTypes.cs:84:17:84:17 | access to local variable x | string! |
|
||||
| NullableRefTypes.cs:84:17:84:28 | String x = ... | string! |
|
||||
| NullableRefTypes.cs:84:21:84:28 | "source" | string! |
|
||||
| NullableRefTypes.cs:85:16:85:16 | access to local variable y | string! |
|
||||
| NullableRefTypes.cs:85:16:85:21 | String y = ... | string! |
|
||||
| NullableRefTypes.cs:85:20:85:20 | access to local variable x | string! |
|
||||
| NullableRefTypes.cs:85:20:85:21 | ...! | string! |
|
||||
| NullableRefTypes.cs:86:9:86:9 | access to local variable y | string! |
|
||||
| NullableRefTypes.cs:86:9:86:14 | ... = ... | string! |
|
||||
| NullableRefTypes.cs:86:13:86:13 | access to local variable x | string! |
|
||||
| NullableRefTypes.cs:86:13:86:14 | ...! | string! |
|
||||
| NullableRefTypes.cs:87:9:87:9 | access to local variable x | string? |
|
||||
| NullableRefTypes.cs:87:9:87:16 | ... = ... | string? |
|
||||
| NullableRefTypes.cs:87:13:87:16 | null | null |
|
||||
| NullableRefTypes.cs:88:9:88:9 | access to local variable y | string! |
|
||||
| NullableRefTypes.cs:88:9:88:14 | ... = ... | string! |
|
||||
| NullableRefTypes.cs:88:13:88:13 | access to local variable x | string! |
|
||||
| NullableRefTypes.cs:88:13:88:14 | ...! | string! |
|
||||
| NullableRefTypes.cs:93:17:93:17 | access to local variable x | string! |
|
||||
| NullableRefTypes.cs:93:17:93:28 | String x = ... | string! |
|
||||
| NullableRefTypes.cs:93:21:93:28 | "source" | string! |
|
||||
| NullableRefTypes.cs:94:13:94:13 | access to local variable y | string? |
|
||||
| NullableRefTypes.cs:94:13:94:25 | String y = ... | string? |
|
||||
| NullableRefTypes.cs:94:17:94:17 | access to local variable x | string! |
|
||||
| NullableRefTypes.cs:94:17:94:25 | ... ?? ... | string? |
|
||||
| NullableRefTypes.cs:94:22:94:25 | null | null |
|
||||
| NullableRefTypes.cs:95:16:95:16 | access to local variable z | string! |
|
||||
| NullableRefTypes.cs:95:16:95:20 | String z = ... | string! |
|
||||
| NullableRefTypes.cs:95:20:95:20 | access to local variable x | string? |
|
||||
| NullableRefTypes.cs:96:9:96:15 | access to type Console | Console! |
|
||||
| NullableRefTypes.cs:96:9:96:28 | call to method WriteLine | Void! |
|
||||
| NullableRefTypes.cs:96:27:96:27 | access to local variable x | string? |
|
||||
| NullableRefTypes.cs:103:48:103:52 | ref ... | MyClass |
|
||||
| NullableRefTypes.cs:103:52:103:52 | access to parameter r | MyClass! |
|
||||
| NullableRefTypes.cs:104:48:104:52 | ref ... | MyClass |
|
||||
| NullableRefTypes.cs:104:52:104:52 | access to parameter r | MyClass? |
|
||||
| NullableRefTypes.cs:105:57:105:61 | ref ... | MyClass |
|
||||
| NullableRefTypes.cs:105:61:105:61 | access to parameter r | MyClass? |
|
||||
| NullableRefTypes.cs:106:56:106:60 | ref ... | MyClass |
|
||||
| NullableRefTypes.cs:106:60:106:60 | access to parameter r | MyClass! |
|
||||
| NullableRefTypes.cs:107:55:107:59 | ref ... | MyClass |
|
||||
| NullableRefTypes.cs:107:59:107:59 | access to parameter r | MyClass! |
|
||||
| NullableRefTypes.cs:108:56:108:60 | ref ... | MyClass |
|
||||
| NullableRefTypes.cs:108:60:108:60 | access to parameter r | MyClass? |
|
||||
| NullableRefTypes.cs:110:58:110:67 | throw ... | null! |
|
||||
| NullableRefTypes.cs:110:64:110:67 | null | null |
|
||||
| NullableRefTypes.cs:113:32:113:44 | ref ... | MyClass |
|
||||
| NullableRefTypes.cs:113:36:113:43 | access to field Property | MyClass? |
|
||||
| NullableRefTypes.cs:113:36:113:43 | this access | RefTypes |
|
||||
| NullableRefTypes.cs:113:36:113:44 | ...! | MyClass? |
|
||||
| NullableRefTypes.cs:157:18:157:30 | object creation of type MyClass | MyClass! |
|
||||
| NullableRefTypes.cs:160:17:160:17 | access to local variable a | MyClass! |
|
||||
| NullableRefTypes.cs:160:17:160:21 | MyClass a = ... | MyClass! |
|
||||
| NullableRefTypes.cs:160:21:160:21 | access to parameter p | MyClass! |
|
||||
| NullableRefTypes.cs:161:16:161:16 | access to local variable a | MyClass! |
|
||||
exprMaybeNull
|
||||
| NullableRefTypes.cs:13:19:13:22 | null |
|
||||
| NullableRefTypes.cs:17:29:17:32 | null |
|
||||
| NullableRefTypes.cs:26:50:26:53 | null |
|
||||
| NullableRefTypes.cs:27:50:27:53 | null |
|
||||
| NullableRefTypes.cs:30:21:30:24 | null |
|
||||
| NullableRefTypes.cs:38:22:38:25 | null |
|
||||
| NullableRefTypes.cs:39:29:39:29 | access to local variable b |
|
||||
| NullableRefTypes.cs:40:30:40:30 | access to local variable b |
|
||||
| NullableRefTypes.cs:51:44:51:47 | null |
|
||||
| NullableRefTypes.cs:73:22:73:25 | null |
|
||||
| NullableRefTypes.cs:74:19:74:19 | access to local variable x |
|
||||
| NullableRefTypes.cs:75:11:75:11 | access to local variable x |
|
||||
| NullableRefTypes.cs:87:9:87:16 | ... = ... |
|
||||
| NullableRefTypes.cs:87:13:87:16 | null |
|
||||
| NullableRefTypes.cs:94:17:94:25 | ... ?? ... |
|
||||
| NullableRefTypes.cs:94:22:94:25 | null |
|
||||
| NullableRefTypes.cs:95:20:95:20 | access to local variable x |
|
||||
| NullableRefTypes.cs:96:27:96:27 | access to local variable x |
|
||||
| NullableRefTypes.cs:104:52:104:52 | access to parameter r |
|
||||
| NullableRefTypes.cs:105:61:105:61 | access to parameter r |
|
||||
| NullableRefTypes.cs:108:60:108:60 | access to parameter r |
|
||||
| NullableRefTypes.cs:110:64:110:67 | null |
|
||||
exprNotNull
|
||||
| NullableRefTypes.cs:14:18:14:21 | this access |
|
||||
| NullableRefTypes.cs:18:31:18:34 | this access |
|
||||
| NullableRefTypes.cs:19:33:19:36 | this access |
|
||||
| NullableRefTypes.cs:26:44:26:53 | throw ... |
|
||||
| NullableRefTypes.cs:27:44:27:53 | throw ... |
|
||||
| NullableRefTypes.cs:31:20:31:23 | this access |
|
||||
| NullableRefTypes.cs:37:21:37:33 | object creation of type MyClass |
|
||||
| NullableRefTypes.cs:74:9:74:20 | call to method GenericFn |
|
||||
| NullableRefTypes.cs:75:9:75:12 | call to method Q |
|
||||
| NullableRefTypes.cs:76:16:76:32 | default(...) |
|
||||
| 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 | ...! |
|
||||
| NullableRefTypes.cs:93:21:93:28 | "source" |
|
||||
| NullableRefTypes.cs:94:17:94:17 | access to local variable x |
|
||||
| NullableRefTypes.cs:96:9:96:15 | access to type Console |
|
||||
| NullableRefTypes.cs:96:9:96:28 | call to method WriteLine |
|
||||
| NullableRefTypes.cs:103:52:103:52 | access to parameter r |
|
||||
| NullableRefTypes.cs:106:60:106:60 | access to parameter r |
|
||||
| NullableRefTypes.cs:107:59:107:59 | access to parameter r |
|
||||
| NullableRefTypes.cs:110:58:110:67 | throw ... |
|
||||
| NullableRefTypes.cs:113:36:113:43 | access to field Property |
|
||||
| NullableRefTypes.cs:113:36:113:44 | ...! |
|
||||
| NullableRefTypes.cs:157:18:157:30 | object creation of type MyClass |
|
||||
| NullableRefTypes.cs:160:21:160:21 | access to parameter p |
|
||||
| NullableRefTypes.cs:161:16:161:16 | access to local variable a |
|
||||
|
||||
@@ -62,3 +62,18 @@ query predicate annotatedTypeConstraints(TypeParameter p, AnnotatedType t) {
|
||||
}
|
||||
|
||||
query predicate typeNotAnnotated(Type type) { not exists(AnnotatedType at | at.getType() = type) }
|
||||
|
||||
query predicate expressionTypes(Expr expr, string type) {
|
||||
type = expr.getAnnotatedType().toString() and
|
||||
expr.getFile().getBaseName() = "NullableRefTypes.cs"
|
||||
}
|
||||
|
||||
query predicate exprMaybeNull(Expr expr) {
|
||||
expr.getFile().getBaseName() = "NullableRefTypes.cs" and
|
||||
expr.hasMaybeNullFlowState()
|
||||
}
|
||||
|
||||
query predicate exprNotNull(Expr expr) {
|
||||
expr.getFile().getBaseName() = "NullableRefTypes.cs" and
|
||||
expr.hasNotNullFlowState()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user