зеркало из https://github.com/github/codeql.git
Merge pull request #16603 from aschackmull/dataflow/location
Dataflow/Go: Add getLocation to DataFlowCall and DataFlowCallable for easier debugging.
This commit is contained in:
Коммит
2f95851537
|
@ -311,6 +311,13 @@ class DataFlowCallable extends TDataFlowCallable {
|
|||
.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||
}
|
||||
|
||||
/** Gets the location of this callable. */
|
||||
Location getLocation() {
|
||||
result = getCallableLocation(this.asCallable()) or
|
||||
result = this.asFileScope().getLocation() or
|
||||
result = getCallableLocation(this.asSummarizedCallable())
|
||||
}
|
||||
|
||||
/** Gets a best-effort total ordering. */
|
||||
int totalorder() {
|
||||
this =
|
||||
|
@ -322,6 +329,13 @@ class DataFlowCallable extends TDataFlowCallable {
|
|||
}
|
||||
}
|
||||
|
||||
private Location getCallableLocation(Callable c) {
|
||||
exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
|
||||
c.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
|
||||
result.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||
)
|
||||
}
|
||||
|
||||
/** A function call relevant for data flow. */
|
||||
class DataFlowCall extends Expr {
|
||||
DataFlow::CallNode call;
|
||||
|
@ -344,6 +358,9 @@ class DataFlowCall extends Expr {
|
|||
not exists(this.getEnclosingFunction()) and result.asFileScope() = this.getFile()
|
||||
}
|
||||
|
||||
/** Gets the location of this call. */
|
||||
Location getLocation() { result = super.getLocation() }
|
||||
|
||||
/** Gets a best-effort total ordering. */
|
||||
int totalorder() {
|
||||
this =
|
||||
|
|
|
@ -72,6 +72,9 @@ signature module InputSig<LocationSig Location> {
|
|||
/** Gets a textual representation of this element. */
|
||||
string toString();
|
||||
|
||||
/** Gets the location of this call. */
|
||||
Location getLocation();
|
||||
|
||||
DataFlowCallable getEnclosingCallable();
|
||||
|
||||
/** Gets a best-effort total ordering. */
|
||||
|
@ -82,6 +85,9 @@ signature module InputSig<LocationSig Location> {
|
|||
/** Gets a textual representation of this element. */
|
||||
string toString();
|
||||
|
||||
/** Gets the location of this callable. */
|
||||
Location getLocation();
|
||||
|
||||
/** Gets a best-effort total ordering. */
|
||||
int totalorder();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче