File tree Expand file tree Collapse file tree 5 files changed +45
-15
lines changed
cpp/ql/lib/semmle/code/cpp/ir/implementation
csharp/ql/src/experimental/ir/implementation Expand file tree Collapse file tree 5 files changed +45
-15
lines changed Original file line number Diff line number Diff line change @@ -416,9 +416,15 @@ class ThisArgumentOperand extends ArgumentOperand {
416416 // in most cases the def location makes more sense, but in some corner cases it
417417 // does not have a location: in those cases we fall back to the use location
418418 override Language:: Location getLocation ( ) {
419- if not this .getAnyDef ( ) .getLocation ( ) instanceof Language:: UnknownLocation
420- then result = this .getAnyDef ( ) .getLocation ( )
421- else result = this .getUse ( ) .getLocation ( )
419+ result = selectLocation ( this .getAnyDef ( ) .getLocation ( ) , this .getUse ( ) .getLocation ( ) )
420+ }
421+
422+ private Language:: Location selectLocation (
423+ Language:: Location preferred , Language:: Location fallback
424+ ) {
425+ if not exists ( preferred ) or preferred instanceof Language:: UnknownLocation
426+ then result = fallback
427+ else result = preferred
422428 }
423429}
424430
Original file line number Diff line number Diff line change @@ -416,9 +416,15 @@ class ThisArgumentOperand extends ArgumentOperand {
416416 // in most cases the def location makes more sense, but in some corner cases it
417417 // does not have a location: in those cases we fall back to the use location
418418 override Language:: Location getLocation ( ) {
419- if not this .getAnyDef ( ) .getLocation ( ) instanceof Language:: UnknownLocation
420- then result = this .getAnyDef ( ) .getLocation ( )
421- else result = this .getUse ( ) .getLocation ( )
419+ result = selectLocation ( this .getAnyDef ( ) .getLocation ( ) , this .getUse ( ) .getLocation ( ) )
420+ }
421+
422+ private Language:: Location selectLocation (
423+ Language:: Location preferred , Language:: Location fallback
424+ ) {
425+ if not exists ( preferred ) or preferred instanceof Language:: UnknownLocation
426+ then result = fallback
427+ else result = preferred
422428 }
423429}
424430
Original file line number Diff line number Diff line change @@ -416,9 +416,15 @@ class ThisArgumentOperand extends ArgumentOperand {
416416 // in most cases the def location makes more sense, but in some corner cases it
417417 // does not have a location: in those cases we fall back to the use location
418418 override Language:: Location getLocation ( ) {
419- if not this .getAnyDef ( ) .getLocation ( ) instanceof Language:: UnknownLocation
420- then result = this .getAnyDef ( ) .getLocation ( )
421- else result = this .getUse ( ) .getLocation ( )
419+ result = selectLocation ( this .getAnyDef ( ) .getLocation ( ) , this .getUse ( ) .getLocation ( ) )
420+ }
421+
422+ private Language:: Location selectLocation (
423+ Language:: Location preferred , Language:: Location fallback
424+ ) {
425+ if not exists ( preferred ) or preferred instanceof Language:: UnknownLocation
426+ then result = fallback
427+ else result = preferred
422428 }
423429}
424430
Original file line number Diff line number Diff line change @@ -416,9 +416,15 @@ class ThisArgumentOperand extends ArgumentOperand {
416416 // in most cases the def location makes more sense, but in some corner cases it
417417 // does not have a location: in those cases we fall back to the use location
418418 override Language:: Location getLocation ( ) {
419- if not this .getAnyDef ( ) .getLocation ( ) instanceof Language:: UnknownLocation
420- then result = this .getAnyDef ( ) .getLocation ( )
421- else result = this .getUse ( ) .getLocation ( )
419+ result = selectLocation ( this .getAnyDef ( ) .getLocation ( ) , this .getUse ( ) .getLocation ( ) )
420+ }
421+
422+ private Language:: Location selectLocation (
423+ Language:: Location preferred , Language:: Location fallback
424+ ) {
425+ if not exists ( preferred ) or preferred instanceof Language:: UnknownLocation
426+ then result = fallback
427+ else result = preferred
422428 }
423429}
424430
Original file line number Diff line number Diff line change @@ -416,9 +416,15 @@ class ThisArgumentOperand extends ArgumentOperand {
416416 // in most cases the def location makes more sense, but in some corner cases it
417417 // does not have a location: in those cases we fall back to the use location
418418 override Language:: Location getLocation ( ) {
419- if not this .getAnyDef ( ) .getLocation ( ) instanceof Language:: UnknownLocation
420- then result = this .getAnyDef ( ) .getLocation ( )
421- else result = this .getUse ( ) .getLocation ( )
419+ result = selectLocation ( this .getAnyDef ( ) .getLocation ( ) , this .getUse ( ) .getLocation ( ) )
420+ }
421+
422+ private Language:: Location selectLocation (
423+ Language:: Location preferred , Language:: Location fallback
424+ ) {
425+ if not exists ( preferred ) or preferred instanceof Language:: UnknownLocation
426+ then result = fallback
427+ else result = preferred
422428 }
423429}
424430
You can’t perform that action at this time.
0 commit comments