Add -resource-dir to clang -cc1, this allows the base directory for compiler
resources (e.g., /usr/lib/clang/1.1) to be passed on the command line instead of
computed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91370 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index f6cb170..48296c7 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -327,10 +327,8 @@
(const char**) CCArgs.data()+CCArgs.size(),
Diags);
- // Set the builtin include path.
- llvm::sys::Path P(ResourceFilesPath);
- P.appendComponent("include");
- CI.getHeaderSearchOpts().BuiltinIncludePath = P.str();
+ // Override the resources path.
+ CI.getHeaderSearchOpts().ResourceDir = ResourceFilesPath;
CI.getFrontendOpts().DisableFree = UseBumpAllocator;
return LoadFromCompilerInvocation(CI, Diags, OnlyLocalDecls);
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 102bbe2..7a3388f 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -409,8 +409,9 @@
// FIXME: Provide an option for this, and move env detection to driver.
llvm::llvm_report_error("Not yet implemented!");
}
- if (!Opts.BuiltinIncludePath.empty()) {
- // FIXME: Provide an option for this, and move to driver.
+ if (!Opts.ResourceDir.empty()) {
+ Res.push_back("-resource-dir");
+ Res.push_back(Opts.ResourceDir);
}
if (!Opts.UseStandardIncludes)
Res.push_back("-nostdinc");
@@ -951,8 +952,8 @@
return DashX;
}
-std::string CompilerInvocation::GetBuiltinIncludePath(const char *Argv0,
- void *MainAddr) {
+std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
+ void *MainAddr) {
llvm::sys::Path P = llvm::sys::Path::GetMainExecutable(Argv0, MainAddr);
if (!P.isEmpty()) {
@@ -963,7 +964,6 @@
P.appendComponent("lib");
P.appendComponent("clang");
P.appendComponent(CLANG_VERSION_STRING);
- P.appendComponent("include");
}
return P.str();
@@ -975,10 +975,7 @@
Opts.Verbose = Args.hasArg(OPT_v);
Opts.UseBuiltinIncludes = !Args.hasArg(OPT_nobuiltininc);
Opts.UseStandardIncludes = !Args.hasArg(OPT_nostdinc);
- // Filled in by clients.
- //
- // FIXME: Elimate this.
- Opts.BuiltinIncludePath = "";
+ Opts.ResourceDir = getLastArgValue(Args, OPT_resource_dir);
// Add -I... and -F... options in order.
for (arg_iterator it = Args.filtered_begin(OPT_I, OPT_F),
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
index f5c9c74..b4ea257 100644
--- a/lib/Frontend/InitHeaderSearch.cpp
+++ b/lib/Frontend/InitHeaderSearch.cpp
@@ -733,8 +733,9 @@
if (HSOpts.UseBuiltinIncludes) {
// Ignore the sys root, we *always* look for clang headers relative to
// supplied path.
- Init.AddPath(HSOpts.BuiltinIncludePath, System,
- false, false, false, /*IgnoreSysRoot=*/ true);
+ llvm::sys::Path P(HSOpts.ResourceDir);
+ P.appendComponent("include");
+ Init.AddPath(P.str(), System, false, false, false, /*IgnoreSysRoot=*/ true);
}
if (HSOpts.UseStandardIncludes)