-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathCallableExtents.ql
More file actions
37 lines (34 loc) · 1.09 KB
/
CallableExtents.ql
File metadata and controls
37 lines (34 loc) · 1.09 KB
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
/**
* @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://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
super.getLocation().hasLocationInfo(filepath, startline, startcolumn, _, _) and
(
this.getBlock().getLocation().hasLocationInfo(filepath, _, _, endline, endcolumn)
or
not exists(this.getBlock()) and endline = startline + 1 and endcolumn = 1
)
}
}
from RangeFunction f
where f.fromSource()
select f.getLocation(), f