[clang] [Clang] [Driver] Canoncalise `-internal-isystem` include paths (PR #148745)
James Y Knight via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 15 10:47:39 PDT 2025
================
@@ -1370,19 +1370,47 @@ ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
return *cxxStdlibType;
}
+static void ResolveAndAddSystemIncludePath(const ArgList &DriverArgs,
+ ArgStringList &CC1Args,
+ const Twine &Path) {
+ bool Canonicalize =
+ DriverArgs.hasFlag(options::OPT_canonical_prefixes,
+ options::OPT_no_canonical_prefixes, true);
+
+ if (!Canonicalize) {
+ CC1Args.push_back(DriverArgs.MakeArgString(Path));
+ return;
+ }
+
+ // We canonicalise system include paths that were added automatically if
+ // that yields a shorter path since those can end up quite long otherwise.
+ //
+ // While we would ideally prefer to use FileManager for this, there doesn't
----------------
jyknight wrote:
I think we do NOT prefer that -- at least not for this function in isolation. All of the rest of the code in this file is working with llvm::sys::fs functions directly, to find search paths on the filesystem.
So, concretely here, I'd actually recommend not using `vfs::getRealFileSystem()`, and instead call `llvm::sys::fs::real_path` directly.
https://github.com/llvm/llvm-project/pull/148745
More information about the cfe-commits
mailing list