[ImportVerilog] Fix file locations for auto-discovered files #8840
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The ImportVerilog conversion currently uses a hacky
bufferFilePaths
table to map fromslang::BufferID
s to the corresponding file path. This only works for files that we explicitly add to the source manager. Files discovered automatically by Slang, e.g. through the-y
flag, have no entry in that table. As a result, any errors in such files will report their file path as-
, which is not very helpful.This commit fixes this by using whatever Slang's own
SourceManager::getFileName
returns for a given location. This removes the need for thatbufferFilePaths
table. As a result, errors in files discovered via-y
will now properly show the file name.While we're at it, also attach the include file stack as a note to any reported diagnostic. This makes it easier to understand how the compiler arrived at an error location.