diff --git a/csharp/ql/src/Useless code/DefaultToString.ql b/csharp/ql/src/Useless code/DefaultToString.ql index 4bf9e3d92ec..656baac410c 100644 --- a/csharp/ql/src/Useless code/DefaultToString.ql +++ b/csharp/ql/src/Useless code/DefaultToString.ql @@ -72,7 +72,7 @@ class DefaultToStringType extends ValueOrRefType { result instanceof SourceLocation or not super.getLocation() instanceof SourceLocation and - result.hasLocationInfo("", 0, 0, 0, 0) + result instanceof EmptyLocation } } diff --git a/csharp/ql/src/semmle/code/csharp/ExprOrStmtParent.qll b/csharp/ql/src/semmle/code/csharp/ExprOrStmtParent.qll index 361e08d0975..602a2cadbb6 100644 --- a/csharp/ql/src/semmle/code/csharp/ExprOrStmtParent.qll +++ b/csharp/ql/src/semmle/code/csharp/ExprOrStmtParent.qll @@ -372,7 +372,7 @@ module ExprOrStmtParentCached { result = min(Location l | l = e.getALocation() | l order by l.getFile().toString()) or not exists(e.getALocation()) and - result.hasLocationInfo("", 0, 0, 0, 0) + result instanceof EmptyLocation } } private import ExprOrStmtParentCached diff --git a/csharp/ql/src/semmle/code/csharp/Location.qll b/csharp/ql/src/semmle/code/csharp/Location.qll index 220a92bfa83..c217e51a432 100644 --- a/csharp/ql/src/semmle/code/csharp/Location.qll +++ b/csharp/ql/src/semmle/code/csharp/Location.qll @@ -51,6 +51,9 @@ class Location extends @location { final int getEndColumn() { this.hasLocationInfo(_, _, _, _, result) } } +/** An empty location. */ +class EmptyLocation extends Location { EmptyLocation() { this.hasLocationInfo("", 0, 0, 0, 0) } } + /** * A location in source code, comprising of a source file and a segment of text * within the file.