mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
C++: Compute locations only for elements in result
This gains some performance by not computing locations for all expressions since we are only interested in calls and variable accesses. The `Top::hasLocationInfo` predicate goes from 2m28s to 1m32s on Chromium.
This commit is contained in:
@@ -30,7 +30,7 @@ class Top extends Element {
|
||||
predicate hasLocationInfo(string filepath,
|
||||
int startline, int startcolumn,
|
||||
int endline, int endcolumn) {
|
||||
this instanceof Element and
|
||||
interestingElement(this) and
|
||||
not this instanceof MacroAccess and
|
||||
not this instanceof Include and
|
||||
exists(Location l |
|
||||
@@ -76,6 +76,13 @@ predicate hasLocationInfo_Include(Include i, string path, int sl, int sc, int el
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if `e` is a source or a target of jump-to-definition. */
|
||||
predicate interestingElement(Element e) {
|
||||
exists(definitionOf(e, _))
|
||||
or
|
||||
e = definitionOf(_, _)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `f`, `line`, `column` indicate the start character
|
||||
* of `cc`.
|
||||
|
||||
Reference in New Issue
Block a user