[clang] [Clang] [Diagnostics] Simplify filenames that contain '..' (PR #143520)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 10 11:47:40 PDT 2025
================
@@ -738,12 +738,20 @@ void TextDiagnostic::printDiagnosticMessage(raw_ostream &OS,
}
void TextDiagnostic::emitFilename(StringRef Filename, const SourceManager &SM) {
-#ifdef _WIN32
- SmallString<4096> TmpFilename;
-#endif
- if (DiagOpts.AbsolutePath) {
- auto File = SM.getFileManager().getOptionalFileRef(Filename);
- if (File) {
+ auto File = SM.getFileManager().getOptionalFileRef(Filename);
+
+ // Try to simplify paths that contain '..' in any case since paths to
+ // standard library headers especially tend to get quite long otherwise.
+ // Only do that for local filesystems though to avoid slowing down
+ // compilation too much.
+ auto AlwaysSimplify = [&] {
+ return File->getName().contains("..") &&
+ llvm::sys::fs::is_local(File->getName());
+ };
----------------
AaronBallman wrote:
Without your patch, the average is consistently just shy of 7 seconds
With your patch, the average is kind of hard to trust; I've seen it as low as 5 seconds and as high as 9 seconds.
Overall, I think this means I'm either not testing what I think I'm testing or the performance changes aren't significant. If I was consistently getting 9 second times, I think that's demonstrate something tangible.
WDYT?
https://github.com/llvm/llvm-project/pull/143520
More information about the cfe-commits
mailing list