[llvm] [Dexter] Add label nodes for line references (PR #202544)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 15 02:40:58 PDT 2026
================
@@ -66,17 +112,49 @@ def add_where(self, where: Where):
"""Adds `where` to this Scope's chain."""
return Scope(where=where, parent_scope=self)
+ def get_known_file_for_where(self, where: Where) -> Optional[str]:
+ """For a `where` that exists directly in this Scope, determines whether there is a known file that `where`
+ expects - whether this is an explicitly-declared file, or implicitly the root scope file. There is no known file
+ for !where {function: ...} nodes, however."""
+ if where.file:
+ return where.file
+ if where.function:
+ return None
+ next_scope = self
+ while where.is_and:
+ assert (
+ next_scope.parent_scope and next_scope.where
+ ), "!and node at root scope?"
+ where = next_scope.where
+ if where.file:
+ return where.file
+ if where.function:
+ return None
+ next_scope = next_scope.parent_scope
+ while next_scope.file is None:
+ assert next_scope.parent_scope
+ next_scope = next_scope.parent_scope
+ return next_scope.file
----------------
OCHyams wrote:
Is it possible for the "root scope" be a `!where {function: ...}` (thus presumably hitting the assert)?
https://github.com/llvm/llvm-project/pull/202544
More information about the llvm-commits
mailing list