================ @@ -2403,3 +2403,75 @@ SourceManagerForFile::SourceManagerForFile(StringRef FileName, assert(ID.isValid()); SourceMgr->setMainFileID(ID); } + +StringRef +SourceManager::getNameForDiagnostic(StringRef Filename, + const DiagnosticOptions &Opts) const { + OptionalFileEntryRef File = getFileManager().getOptionalFileRef(Filename); + if (!File) + return Filename; + + bool SimplifyPath = [&] { + if (Opts.AbsolutePath) + return true; + + // 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. + if (!File->getName().contains("..")) + return false; + + // If we're not on Windows, check if we're on a network file system and + // avoid simplifying the path in that case since that can be slow. On + // Windows, the check for a local filesystem is already slow, so skip it. +#ifndef _WIN32 + if (!llvm::sys::fs::is_local(File->getName())) + return false; +#endif + + return true; + }(); + + if (!SimplifyPath) + return Filename; ---------------- Sirraide wrote:
Hmm, not sure. This is a `perf/` branch anyway so when I’m done fixing the tests (I think it’s just a clang-tidy test that’s left at this point?) we can just check if there are any regressions and try doing this instead if so. https://github.com/llvm/llvm-project/pull/143520 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits