Skip to content

Commit f746c65

Browse files
committed
C++: Add overlay support for discarding functions
1 parent cd6429a commit f746c65

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,31 @@ 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_decl has a direct location in the var_decls relation
25+
var_decls(e, _, _, _, loc)
26+
or
27+
// @fun_decl has a direct location in the fun_decls relation
28+
fun_decls(e, _, _, _, loc)
29+
|
30+
result = getLocationFilePath(loc)
31+
)
2632
}
2733

2834
/**
2935
* Gets the file path for an element with potentially multiple locations.
3036
*/
3137
overlay[local]
3238
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) |
39+
exists(@location_default loc |
40+
// @variable gets its location(s) from its @var_decl(s)
41+
exists(@var_decl vd | var_decls(vd, e, _, _, loc))
42+
or
43+
// @function gets its location(s) from its @fun_decl(s)
44+
exists(@fun_decl fd | fun_decls(fd, e, _, _, loc))
45+
|
3546
result = getLocationFilePath(loc)
3647
)
37-
//TODO: add other kinds of elements with multiple locations
3848
}
3949

4050
/**

0 commit comments

Comments
 (0)