Skip to content

Commit f02513e

Browse files
committed
C++: Exclude UnknownLocation results from getLocation if there is a location that's known
1 parent 23ca363 commit f02513e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

cpp/ql/src/semmle/code/cpp/ir/internal/ASTValueNumbering.qll

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,18 @@ class GVN extends TValueNumber {
6464
final string getDebugString() { result = strictconcat(getAnExpr().toString(), ", ") }
6565

6666
final Location getLocation() {
67-
result =
68-
min(Location l |
69-
l = getAnExpr().getLocation()
70-
|
71-
l
72-
order by
73-
l.getFile().getAbsolutePath(), l.getStartLine(), l.getStartColumn(), l.getEndLine(),
74-
l.getEndColumn()
75-
)
67+
if exists(Expr e | e = getAnExpr() and not e.getLocation() instanceof UnknownLocation)
68+
then
69+
result =
70+
min(Location l |
71+
l = getAnExpr().getLocation() and not l instanceof UnknownLocation
72+
|
73+
l
74+
order by
75+
l.getFile().getAbsolutePath(), l.getStartLine(), l.getStartColumn(), l.getEndLine(),
76+
l.getEndColumn()
77+
)
78+
else result instanceof UnknownDefaultLocation
7679
}
7780

7881
final string getKind() {

0 commit comments

Comments
 (0)