forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCallableExtents.ql
More file actions
35 lines (32 loc) · 984 Bytes
/
Copy pathCallableExtents.ql
File metadata and controls
35 lines (32 loc) · 984 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
29
30
31
32
33
34
35
/**
* @name Extents of functions
* @kind extent
* @id cpp/callable-extents
* @metricType callable
*/
import cpp
/**
* A Function with location overridden to cover its entire range,
* including the body (if any), as opposed to the location of its name
* only.
*/
class RangeFunction extends Function {
/**
* Holds if this function is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
*/
predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
super.getLocation().hasLocationInfo(path, sl, sc, _, _) and
(
this.getBlock().getLocation().hasLocationInfo(path, _, _, el, ec)
or
not exists(this.getBlock()) and el = sl + 1 and ec = 1
)
}
}
from RangeFunction f
where f.fromSource()
select f.getLocation(), f