[cfe-commits] r91370 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Frontend/CompilerInvocation.h include/clang/Frontend/HeaderSearchOptions.h lib/Frontend/ASTUnit.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/InitHeaderSearch.cpp tools/driver/cc1_main.cpp tools/index-test/index-test.cpp
Daniel Dunbar
daniel at zuster.org
Mon Dec 14 16:06:46 PST 2009
Author: ddunbar
Date: Mon Dec 14 18:06:45 2009
New Revision: 91370
URL: http://llvm.org/viewvc/llvm-project?rev=91370&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
cfe/trunk/tools/driver/cc1_main.cpp
cfe/trunk/tools/index-test/index-test.cpp
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=91370&r1=91369&r2=91370&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Dec 14 18:06:45 2009
@@ -223,6 +223,8 @@
HelpText<"Load the named plugin (dynamic shared object)">;
def plugin : Separate<"-plugin">,
HelpText<"Use the named plugin action (use \"help\" to list available options)">;
+def resource_dir : Separate<"-resource-dir">,
+ HelpText<"The directory which holds the compiler resource files">;
def version : Flag<"-version">,
HelpText<"Print the compiler version">;
def _version : Flag<"--version">, Alias<version>;
Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=91370&r1=91369&r2=91370&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Mon Dec 14 18:06:45 2009
@@ -94,7 +94,7 @@
/// compiler path.
/// \param MainAddr - The address of main (or some other function in the main
/// executable), for finding the builtin compiler path.
- static std::string GetBuiltinIncludePath(const char *Argv0, void *MainAddr);
+ static std::string GetResourcesPath(const char *Argv0, void *MainAddr);
/// toArgs - Convert the CompilerInvocation to a list of strings suitable for
/// passing to CreateFromArgs.
Modified: cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h?rev=91370&r1=91369&r2=91370&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h Mon Dec 14 18:06:45 2009
@@ -61,9 +61,9 @@
std::string CXXEnvIncPath;
std::string ObjCXXEnvIncPath;
- /// If non-empty, the path to the compiler builtin include directory, which
- /// will be searched following the user and environment includes.
- std::string BuiltinIncludePath;
+ /// The directory which holds the compiler resource files (builtin includes,
+ /// etc.).
+ std::string ResourceDir;
/// Include the compiler builtin includes.
unsigned UseBuiltinIncludes : 1;
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=91370&r1=91369&r2=91370&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Dec 14 18:06:45 2009
@@ -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);
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=91370&r1=91369&r2=91370&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Dec 14 18:06:45 2009
@@ -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),
Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=91370&r1=91369&r2=91370&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Mon Dec 14 18:06:45 2009
@@ -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)
Modified: cfe/trunk/tools/driver/cc1_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1_main.cpp?rev=91370&r1=91369&r2=91370&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1_main.cpp Mon Dec 14 18:06:45 2009
@@ -211,9 +211,9 @@
// Infer the builtin include path if unspecified.
if (Clang.getInvocation().getHeaderSearchOpts().UseBuiltinIncludes &&
- Clang.getInvocation().getHeaderSearchOpts().BuiltinIncludePath.empty())
- Clang.getInvocation().getHeaderSearchOpts().BuiltinIncludePath =
- CompilerInvocation::GetBuiltinIncludePath(Argv0, MainAddr);
+ Clang.getInvocation().getHeaderSearchOpts().ResourceDir.empty())
+ Clang.getInvocation().getHeaderSearchOpts().ResourceDir =
+ CompilerInvocation::GetResourcesPath(Argv0, MainAddr);
// Honor -help.
if (Clang.getInvocation().getFrontendOpts().ShowHelp) {
Modified: cfe/trunk/tools/index-test/index-test.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/index-test/index-test.cpp?rev=91370&r1=91369&r2=91370&view=diff
==============================================================================
--- cfe/trunk/tools/index-test/index-test.cpp (original)
+++ cfe/trunk/tools/index-test/index-test.cpp Mon Dec 14 18:06:45 2009
@@ -224,11 +224,10 @@
Args.push_back(CompilerArgs[i].c_str());
void *MainAddr = (void*) (intptr_t) CreateFromSource;
- llvm::sys::Path ResourcesPath(
- CompilerInvocation::GetBuiltinIncludePath(Argv0, MainAddr));
- ResourcesPath.eraseComponent();
+ std::string ResourceDir =
+ CompilerInvocation::GetResourcesPath(Argv0, MainAddr);
return ASTUnit::LoadFromCommandLine(Args.data(), Args.data() + Args.size(),
- Diags, ResourcesPath.str());
+ Diags, ResourceDir);
}
int main(int argc, char **argv) {
More information about the cfe-commits
mailing list