Skip to content
Snippets Groups Projects
Commit 80c26f44 authored by Daniel Dunbar's avatar Daniel Dunbar
Browse files

Frontend: Add -cxx-system-include option which can be used to specify an

explicit list for the C++ system include directories at the -cc1 level, as an
alternative to the horrible AddDefaultCPlusPlusIncludePaths().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113505 91177308-0d34-0410-b5e6-96231b3b80d8
parent d11ee7f6
No related branches found
No related tags found
No related merge requests found
...@@ -516,6 +516,8 @@ def iwithprefixbefore : JoinedOrSeparate<"-iwithprefixbefore">, ...@@ -516,6 +516,8 @@ def iwithprefixbefore : JoinedOrSeparate<"-iwithprefixbefore">,
HelpText<"Set directory to include search path with prefix">; HelpText<"Set directory to include search path with prefix">;
def isysroot : JoinedOrSeparate<"-isysroot">, MetaVarName<"<dir>">, def isysroot : JoinedOrSeparate<"-isysroot">, MetaVarName<"<dir>">,
HelpText<"Set the system root directory (usually /)">; HelpText<"Set the system root directory (usually /)">;
def cxx_system_include : Separate<"-cxx-system-include">,
HelpText<"Add a system #include directory for the C++ standard library">;
def v : Flag<"-v">, HelpText<"Enable verbose output">; def v : Flag<"-v">, HelpText<"Enable verbose output">;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
......
...@@ -54,6 +54,9 @@ public: ...@@ -54,6 +54,9 @@ public:
/// User specified include entries. /// User specified include entries.
std::vector<Entry> UserEntries; std::vector<Entry> UserEntries;
/// If non-empty, the list of C++ standard include paths to use.
std::vector<std::string> CXXSystemIncludes;
/// A (system-path) delimited list of include paths to be added from the /// A (system-path) delimited list of include paths to be added from the
/// environment following the user specified includes (but prior to builtin /// environment following the user specified includes (but prior to builtin
/// and standard includes). This is parsed in the same manner as the CPATH /// and standard includes). This is parsed in the same manner as the CPATH
......
...@@ -443,6 +443,11 @@ static void HeaderSearchOptsToArgs(const HeaderSearchOptions &Opts, ...@@ -443,6 +443,11 @@ static void HeaderSearchOptsToArgs(const HeaderSearchOptions &Opts,
Res.push_back(Opts.Sysroot); Res.push_back(Opts.Sysroot);
} }
for (unsigned i = 0, e = Opts.CXXSystemIncludes.size(); i != e; ++i) {
Res.push_back("-cxx-system-include");
Res.push_back(Opts.CXXSystemIncludes[i]);
}
/// User specified include entries. /// User specified include entries.
for (unsigned i = 0, e = Opts.UserEntries.size(); i != e; ++i) { for (unsigned i = 0, e = Opts.UserEntries.size(); i != e; ++i) {
const HeaderSearchOptions::Entry &E = Opts.UserEntries[i]; const HeaderSearchOptions::Entry &E = Opts.UserEntries[i];
...@@ -1143,6 +1148,7 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0, ...@@ -1143,6 +1148,7 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) { static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
using namespace cc1options; using namespace cc1options;
Opts.CXXSystemIncludes = Args.getAllArgValues(OPT_cxx_system_include);
Opts.Sysroot = Args.getLastArgValue(OPT_isysroot, "/"); Opts.Sysroot = Args.getLastArgValue(OPT_isysroot, "/");
Opts.Verbose = Args.hasArg(OPT_v); Opts.Verbose = Args.hasArg(OPT_v);
Opts.UseBuiltinIncludes = !Args.hasArg(OPT_nobuiltininc); Opts.UseBuiltinIncludes = !Args.hasArg(OPT_nobuiltininc);
......
...@@ -772,8 +772,13 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) { ...@@ -772,8 +772,13 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) {
void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang, void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
const llvm::Triple &triple, const llvm::Triple &triple,
const HeaderSearchOptions &HSOpts) { const HeaderSearchOptions &HSOpts) {
if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes) if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes) {
AddDefaultCPlusPlusIncludePaths(triple); if (!HSOpts.CXXSystemIncludes.empty()) {
for (unsigned i = 0, e = HSOpts.CXXSystemIncludes.size(); i != e; ++i)
AddPath(HSOpts.CXXSystemIncludes[i], System, true, false, false);
} else
AddDefaultCPlusPlusIncludePaths(triple);
}
AddDefaultCIncludePaths(triple, HSOpts); AddDefaultCIncludePaths(triple, HSOpts);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment