mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Merge pull request #881 from hvitved/csharp/remove-get-url
C#: Remove `getUrl()` predicate
This commit is contained in:
@@ -58,33 +58,22 @@ predicate alwaysDefaultToString(ValueOrRefType t) {
|
||||
((t.isAbstract() or t instanceof Interface) implies not t.isEffectivelyPublic())
|
||||
}
|
||||
|
||||
newtype TDefaultToStringType = TDefaultToStringType0(ValueOrRefType t) { alwaysDefaultToString(t) }
|
||||
|
||||
class DefaultToStringType extends TDefaultToStringType {
|
||||
ValueOrRefType t;
|
||||
|
||||
DefaultToStringType() { this = TDefaultToStringType0(t) }
|
||||
|
||||
ValueOrRefType getType() { result = t }
|
||||
|
||||
string toString() { result = t.toString() }
|
||||
class DefaultToStringType extends ValueOrRefType {
|
||||
DefaultToStringType() { alwaysDefaultToString(this) }
|
||||
|
||||
// A workaround for generating empty URLs for non-source locations, because qltest
|
||||
// does not support non-source locations
|
||||
string getURL() {
|
||||
exists(Location l | l = t.getLocation() |
|
||||
if l instanceof SourceLocation
|
||||
then
|
||||
exists(string path, int a, int b, int c, int d | l.hasLocationInfo(path, a, b, c, d) |
|
||||
toUrl(path, a, b, c, d, result)
|
||||
)
|
||||
else result = ""
|
||||
)
|
||||
override Location getLocation() {
|
||||
result = super.getLocation() and
|
||||
result instanceof SourceLocation
|
||||
or
|
||||
not super.getLocation() instanceof SourceLocation and
|
||||
result instanceof EmptyLocation
|
||||
}
|
||||
}
|
||||
|
||||
from Expr e, DefaultToStringType t
|
||||
where invokesToString(e, t.getType())
|
||||
where invokesToString(e, t)
|
||||
select e,
|
||||
"Default 'ToString()': $@ inherits 'ToString()' from 'Object', and so is not suitable for printing.",
|
||||
t, t.getType().getName()
|
||||
t, t.getName()
|
||||
|
||||
Reference in New Issue
Block a user