[clang] [Clang] [Diagnostics] Simplify filenames that contain '..' (PR #143520)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 10 09:57:37 PDT 2025


Sirraide wrote:

> The downside to it being in `TextDiagnostic` is that consumers then all have to normalize the path themselves (some file system APIs on some systems are better about relative paths than others). If the paths are always equivalent, it might be kinder to pass the resolved path. WDYT?

I mean, that’s also true I suppose; the only thing is then that we’d be normalising them twice if `-fdiagnostics-absolute-paths` is passed—unless we move the handling for that elsewhere as well, but now that’s dependent on the diagnostic options, so it probably shouldn’t be in `FileManager`—which leaves `DiagnosticsEngine`? But consumers don’t generally have access to the `DiagnosticsEngine`, so it’d have to be in the `FileManager` after all. 

I guess we could *always* compute both the absolute and the ‘short’ path for a file whenever `FileManager` opens one so that they’re always available. But that might have some impact on performance (though I guess this is a `perf/` branch already so we can try and see how it goes)?

@AaronBallman Thoughts?

https://github.com/llvm/llvm-project/pull/143520


More information about the cfe-commits mailing list