-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathLinkage.qll
60 lines (52 loc) · 1.94 KB
/
Linkage.qll
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Provides the `LinkTarget` class representing linker invocations during the build process.
*/
import semmle.code.cpp.Class
import semmle.code.cpp.File
import semmle.code.cpp.Function
/**
* A linker call during the build process, typically resulting in an
* executable or a shared library.
*
* Note that if linkage information isn't captured as part of the snapshot,
* then everything is grouped together into a single dummy link target.
*/
class LinkTarget extends @link_target {
/**
* Gets the file which was built.
*/
File getBinary() { link_targets(this, unresolveElement(result)) }
/**
* Holds if this is the dummy link target: if linkage information isn't
* captured as part of the snapshot, then everything is grouped together
* into a single dummy link target.
*/
predicate isDummy() { this.getBinary().getAbsolutePath() = "" }
/** Gets a textual representation of this element. */
string toString() { result = this.getBinary().getAbsolutePath() }
/**
* Gets a function which was compiled into this link target, or had its
* declaration included by one of the translation units which contributed
* to this link target.
*/
Function getAFunction() { link_parent(unresolveElement(result), this) }
/**
* Gets a class which had its declaration included by one of the
* translation units which contributed to this link target.
*/
Class getAClass() { link_parent(unresolveElement(result), this) }
/**
* Gets a global or namespace variable which was compiled into this
* link target, or had its declaration included by one of the translation
* units which contributed to this link target.
*/
GlobalOrNamespaceVariable getAGlobalOrNamespaceVariable() {
link_parent(unresolveElement(result), this)
}
}
/**
* Holds if this database was created with the linker awareness feature
* switched on.
*/
cached
predicate isLinkerAwareExtracted() { exists(LinkTarget lt | not lt.isDummy()) }