Skip to content

Commit 9299482

Browse files
committed
C++: Merge the location tables
1 parent a9ecb26 commit 9299482

File tree

33 files changed

+11412
-5961
lines changed

33 files changed

+11412
-5961
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
class Accessible extends @accessible {
2+
string toString() { none() }
3+
}
4+
5+
class Container extends @container {
6+
string toString() { none() }
7+
}
8+
9+
class Expr extends @expr {
10+
string toString() { none() }
11+
}
12+
13+
class Initialiser extends @initialiser {
14+
string toString() { none() }
15+
}
16+
17+
class Location extends @location_default {
18+
string toString() { none() }
19+
}
20+
21+
class Stmt extends @stmt {
22+
string toString() { none() }
23+
}
24+
25+
predicate isLocationDefault(Location l) {
26+
diagnostics(_, _, _, _, _, l)
27+
or
28+
macroinvocations(_, _, l, _)
29+
or
30+
fun_decls(_, _, _, _, l)
31+
or
32+
var_decls(_, _, _, _, l)
33+
or
34+
type_decls(_, _, l)
35+
or
36+
namespace_decls(_, _, l, _)
37+
or
38+
namespace_decls(_, _, _, l)
39+
or
40+
usings(_, _, l, _)
41+
or
42+
static_asserts(_, _, _, l, _)
43+
or
44+
enumconstants(_, _, _, _, _, l)
45+
or
46+
attributes(_, _, _, _, l)
47+
or
48+
attribute_args(_, _, _, _, l)
49+
or
50+
derivations(_, _, _, _, l)
51+
or
52+
frienddecls(_, _, _, l)
53+
or
54+
comments(_, _, l)
55+
or
56+
namequalifiers(_, _, _, l)
57+
or
58+
lambda_capture(_, _, _, _, _, _, l)
59+
or
60+
preprocdirects(_, _, l)
61+
or
62+
xmllocations(_, l)
63+
}
64+
65+
predicate isLocationExpr(Location l) {
66+
initialisers(_, _, _, l)
67+
or
68+
exprs(_, _, l)
69+
}
70+
71+
predicate isLocationStmt(Location l) { stmts(_, _, l) }
72+
73+
newtype TExprOrStmtLocation =
74+
TExprLocation(Location l, Container c, int startLine, int startColumn, int endLine, int endColumn) {
75+
isLocationExpr(l) and
76+
(isLocationDefault(l) or isLocationStmt(l)) and
77+
locations_default(l, c, startLine, startColumn, endLine, endColumn)
78+
} or
79+
TStmtLocation(Location l, Container c, int startLine, int startColumn, int endLine, int endColumn) {
80+
isLocationStmt(l) and
81+
(isLocationDefault(l) or isLocationExpr(l)) and
82+
locations_default(l, c, startLine, startColumn, endLine, endColumn)
83+
}
84+
85+
module Fresh = QlBuiltins::NewEntity<TExprOrStmtLocation>;
86+
87+
class NewLocationBase = @location_default or Fresh::EntityId;
88+
89+
class NewLocation extends NewLocationBase {
90+
string toString() { none() }
91+
}
92+
93+
query predicate new_locations_default(
94+
NewLocation l, Container c, int startLine, int startColumn, int endLine, int endColumn
95+
) {
96+
isLocationDefault(l) and
97+
locations_default(l, c, startLine, startColumn, endLine, endColumn)
98+
}
99+
100+
query predicate new_locations_expr(
101+
NewLocation l, Container c, int startLine, int startColumn, int endLine, int endColumn
102+
) {
103+
exists(Location l_old |
104+
isLocationExpr(l_old) and
105+
locations_default(l_old, c, startLine, startColumn, endLine, endColumn)
106+
|
107+
if not isLocationDefault(l_old) and not isLocationStmt(l)
108+
then l = l_old
109+
else l = Fresh::map(TExprLocation(l_old, c, startLine, startColumn, endLine, endColumn))
110+
)
111+
}
112+
113+
query predicate new_locations_stmt(
114+
NewLocation l, Container c, int startLine, int startColumn, int endLine, int endColumn
115+
) {
116+
exists(Location l_old |
117+
isLocationStmt(l_old) and
118+
locations_default(l_old, c, startLine, startColumn, endLine, endColumn)
119+
|
120+
if not isLocationDefault(l_old) and not isLocationExpr(l)
121+
then l = l_old
122+
else l = Fresh::map(TStmtLocation(l_old, c, startLine, startColumn, endLine, endColumn))
123+
)
124+
}
125+
126+
query predicate new_exprs(Expr e, int kind, NewLocation l) {
127+
exists(Location l_old, Container c, int startLine, int startColumn, int endLine, int endColumn |
128+
exprs(e, kind, l_old) and
129+
locations_default(l_old, c, startLine, startColumn, endLine, endColumn)
130+
|
131+
if not isLocationDefault(l_old) and not isLocationStmt(l)
132+
then l = l_old
133+
else l = Fresh::map(TExprLocation(l_old, c, startLine, startColumn, endLine, endColumn))
134+
)
135+
}
136+
137+
query predicate new_initialisers(Initialiser i, Accessible v, Expr e, NewLocation l) {
138+
exists(Location l_old, Container c, int startLine, int startColumn, int endLine, int endColumn |
139+
initialisers(i, v, e, l_old) and
140+
locations_default(l_old, c, startLine, startColumn, endLine, endColumn)
141+
|
142+
if not isLocationDefault(l_old) and not isLocationStmt(l)
143+
then l = l_old
144+
else l = Fresh::map(TExprLocation(l_old, c, startLine, startColumn, endLine, endColumn))
145+
)
146+
}
147+
148+
query predicate new_stmts(Stmt s, int kind, NewLocation l) {
149+
exists(Location l_old, Container c, int startLine, int startColumn, int endLine, int endColumn |
150+
stmts(s, kind, l_old) and
151+
locations_default(l_old, c, startLine, startColumn, endLine, endColumn)
152+
|
153+
if not isLocationDefault(l_old) and not isLocationExpr(l)
154+
then l = l_old
155+
else l = Fresh::map(TStmtLocation(l_old, c, startLine, startColumn, endLine, endColumn))
156+
)
157+
}

0 commit comments

Comments
 (0)