Merge pull request #16603 from aschackmull/dataflow/location

Dataflow/Go: Add getLocation to DataFlowCall and DataFlowCallable for easier debugging.
This commit is contained in:
Anders Schack-Mulligen 2024-05-29 08:58:22 +02:00 коммит произвёл GitHub
Родитель 06fd16bbf5 3b12f69dd9
Коммит 2f95851537
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -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();
}