-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathdecls.ql
More file actions
28 lines (23 loc) · 760 Bytes
/
decls.ql
File metadata and controls
28 lines (23 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import cpp
string qual(Declaration d) {
if exists(d.getQualifiedName()) then result = d.getQualifiedName() else result = "<none>"
}
newtype TMaybeNamespace =
SomeNamespace(Namespace ns) or
NoNamespace()
class MaybeNamespace extends TMaybeNamespace {
string toString() {
this = NoNamespace() and result = "<none>"
or
exists(Namespace ns | this = SomeNamespace(ns) and result = ns.toString())
}
Location getLocation() {
exists(Namespace ns | this = SomeNamespace(ns) and result = ns.getLocation())
}
}
from MaybeNamespace n, Declaration d
where
n = SomeNamespace(d.getNamespace())
or
n = NoNamespace() and not exists(d.getNamespace())
select n, d, qual(d), any(boolean b | if d.isTopLevel() then b = true else b = false)