]> granicus.if.org Git - clang/commitdiff
Frontend: Add -cxx-system-include option which can be used to specify an
authorDaniel Dunbar <daniel@zuster.org>
Thu, 9 Sep 2010 17:38:22 +0000 (17:38 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 9 Sep 2010 17:38:22 +0000 (17:38 +0000)
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

include/clang/Driver/CC1Options.td
include/clang/Frontend/HeaderSearchOptions.h
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/InitHeaderSearch.cpp

index fd40aa0c5f4b9c3fb2fe5bcd1cd94a1604eb2ac2..005f839bf534b429e8ce277e8c1ec451475c386d 100644 (file)
@@ -516,6 +516,8 @@ def iwithprefixbefore : JoinedOrSeparate<"-iwithprefixbefore">,
   HelpText<"Set directory to include search path with prefix">;
 def isysroot : JoinedOrSeparate<"-isysroot">, MetaVarName<"<dir>">,
   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">;
 
 //===----------------------------------------------------------------------===//
index 588d32bf736ef07585d12181c03e61edec321000..cbb4a57993b751c28034b8a0ee1bfce440e51a2e 100644 (file)
@@ -54,6 +54,9 @@ public:
   /// User specified include entries.
   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
   /// environment following the user specified includes (but prior to builtin
   /// and standard includes). This is parsed in the same manner as the CPATH
index 8c644833b20e0747a4309a6811086ffd0cfb32c6..36d8dad58f736b3721913a5bb85f452632e54e54 100644 (file)
@@ -443,6 +443,11 @@ static void HeaderSearchOptsToArgs(const HeaderSearchOptions &Opts,
     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.
   for (unsigned i = 0, e = Opts.UserEntries.size(); i != e; ++i) {
     const HeaderSearchOptions::Entry &E = Opts.UserEntries[i];
@@ -1143,6 +1148,7 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
 
 static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
   using namespace cc1options;
+  Opts.CXXSystemIncludes = Args.getAllArgValues(OPT_cxx_system_include);
   Opts.Sysroot = Args.getLastArgValue(OPT_isysroot, "/");
   Opts.Verbose = Args.hasArg(OPT_v);
   Opts.UseBuiltinIncludes = !Args.hasArg(OPT_nobuiltininc);
index 139e244a6c4ca13b21fb036d72bc91e5ab5deb5f..88f663cae435c199fe55ab9a945f979c0c72904d 100644 (file)
@@ -772,8 +772,13 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) {
 void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
                                                     const llvm::Triple &triple,
                                             const HeaderSearchOptions &HSOpts) {
-  if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes)
-    AddDefaultCPlusPlusIncludePaths(triple);
+  if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes) {
+    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);