Add import context for locations. (#3807)

As discussed around #3792, identify the import a diagnostic message came
from prior to the diagnostic message itself. This occurs during location
translation so that the logic can be central.

I'd considered associating the parse node with ImportRef instructions,
but I realized about halfway through that because I need to store the
ImportDirectiveId on the ImportIR for cross-package imports, it's there
for use in location translation without extra work. That saves a fair
amount of stringing it through declarations, as well as an oddity where
ImportRef instructions would have a node that didn't really represent
them.
This commit is contained in:
Jon Ross-Perkins
2024-03-27 22:22:15 +00:00
committed by GitHub
parent 2a6c5255fb
commit 6c458ffe7e
29 changed files with 263 additions and 130 deletions
+2 -1
View File
@@ -12,7 +12,8 @@ namespace Carbon {
namespace {
struct FilenameConverter : DiagnosticConverter<llvm::StringRef> {
auto ConvertLocation(llvm::StringRef filename) const
auto ConvertLocation(llvm::StringRef filename,
ContextFnT /*context_fn*/) const
-> DiagnosticLocation override {
return {.filename = filename};
}