Original file path from SourceLocation
#658
Unanswered
fabianschuiki
asked this question in
Q&A
Replies: 1 comment 2 replies
-
I don't mind a PR if you think it's necessary, but is it not sufficient to do something like call std::filesystem::canonical() on the result of getFileName? If not, or you want to avoid the extra call because you're doing that query a lot, you can store the absolute path in the FileData object directly, since we already know it in openCached at the time we do the read call. Also of note is that getFileName takes into account `line directives. I'm not sure how you want to handle those, but if you want to ignore them then you should use getRawFileName instead. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm experimenting with integrating slang into CIRCT, which is built around MLIR. Location information in MLIR diagnostics is expected to produce the exact path names as given by the user, without any modification.
Right now I'm using
sourceManager.getFileName(loc)
to get the path to report in the MLIR diagnostic. That function though returns the file name, which is either the proximate path or -- ifdisableProximatePaths
is on -- just the file name, but not the actual path itself.Is there any way to get the actual path as originally provided when populating the source manager? If not, could I contribute a PR that introduces a
sourceManager.getFilePath(loc)
function such that you can get the full path?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions