account for non-existing locations

This commit is contained in:
Paolo Tranquilli
2021-11-23 14:49:05 +00:00
committed by GitHub
parent d626745ab1
commit 9538ac73e4
5 changed files with 45 additions and 15 deletions

View File

@@ -416,9 +416,15 @@ class ThisArgumentOperand extends ArgumentOperand {
// in most cases the def location makes more sense, but in some corner cases it
// does not have a location: in those cases we fall back to the use location
override Language::Location getLocation() {
if not this.getAnyDef().getLocation() instanceof Language::UnknownLocation
then result = this.getAnyDef().getLocation()
else result = this.getUse().getLocation()
result = selectLocation(this.getAnyDef().getLocation(), this.getUse().getLocation())
}
private Language::Location selectLocation(
Language::Location preferred, Language::Location fallback
) {
if not exists(preferred) or preferred instanceof Language::UnknownLocation
then result = fallback
else result = preferred
}
}

View File

@@ -416,9 +416,15 @@ class ThisArgumentOperand extends ArgumentOperand {
// in most cases the def location makes more sense, but in some corner cases it
// does not have a location: in those cases we fall back to the use location
override Language::Location getLocation() {
if not this.getAnyDef().getLocation() instanceof Language::UnknownLocation
then result = this.getAnyDef().getLocation()
else result = this.getUse().getLocation()
result = selectLocation(this.getAnyDef().getLocation(), this.getUse().getLocation())
}
private Language::Location selectLocation(
Language::Location preferred, Language::Location fallback
) {
if not exists(preferred) or preferred instanceof Language::UnknownLocation
then result = fallback
else result = preferred
}
}

View File

@@ -416,9 +416,15 @@ class ThisArgumentOperand extends ArgumentOperand {
// in most cases the def location makes more sense, but in some corner cases it
// does not have a location: in those cases we fall back to the use location
override Language::Location getLocation() {
if not this.getAnyDef().getLocation() instanceof Language::UnknownLocation
then result = this.getAnyDef().getLocation()
else result = this.getUse().getLocation()
result = selectLocation(this.getAnyDef().getLocation(), this.getUse().getLocation())
}
private Language::Location selectLocation(
Language::Location preferred, Language::Location fallback
) {
if not exists(preferred) or preferred instanceof Language::UnknownLocation
then result = fallback
else result = preferred
}
}