Skip to content

Commit 3f22440

Browse files
committed
C/C++ overlay: Add overlay support for discarding functions
1 parent 4a1abc7 commit 3f22440

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

cpp/ql/lib/semmle/code/cpp/internal/Overlay.qll

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,27 @@ private string getLocationFilePath(@location_default loc) {
2020
*/
2121
overlay[local]
2222
private string getSingleLocationFilePath(@element e) {
23-
// @var_decl has a direct location in the var_decls relation
24-
exists(@location_default loc | var_decls(e, _, _, _, loc) | result = getLocationFilePath(loc))
25-
//TODO: add other kinds of elements with single locations
23+
exists(@location_default loc |
24+
var_decls(e, _, _, _, loc)
25+
or
26+
fun_decls(e, _, _, _, loc)
27+
|
28+
result = getLocationFilePath(loc)
29+
)
2630
}
2731

2832
/**
2933
* Gets the file path for an element with potentially multiple locations.
3034
*/
3135
overlay[local]
3236
private string getMultiLocationFilePath(@element e) {
33-
// @variable gets its location(s) from its @var_decl(s)
34-
exists(@var_decl vd, @location_default loc | var_decls(vd, e, _, _, loc) |
37+
exists(@location_default loc |
38+
exists(@var_decl vd | var_decls(vd, e, _, _, loc))
39+
or
40+
exists(@fun_decl fd | fun_decls(fd, e, _, _, loc))
41+
|
3542
result = getLocationFilePath(loc)
3643
)
37-
//TODO: add other kinds of elements with multiple locations
3844
}
3945

4046
/**

0 commit comments

Comments
 (0)