Files
codeql/cpp/ql/src/Metrics/Internal/CallableExtents.ql
Jonas Jensen 4ef5c9af62 C++: Autoformat everything
Some files that will change in #1736 have been spared.

    ./build -j4 target/jars/qlformat
    find ql/cpp/ql -name "*.ql"  -print0 | xargs -0 target/jars/qlformat --input
    find ql/cpp/ql -name "*.qll" -print0 | xargs -0 target/jars/qlformat --input
    (cd ql && git checkout 'cpp/ql/src/semmle/code/cpp/ir/implementation/**/*SSA*.qll')
    buildutils-internal/scripts/pr-checks/sync-identical-files.py --latest
2019-09-09 11:25:53 +02:00

36 lines
984 B
Plaintext

/**
* @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