[llvm-branch-commits] [cfe-branch] r143931 - in /cfe/branches/release_30: ./ include/clang/Driver/CC1Options.td include/clang/Frontend/HeaderSearchOptions.h lib/Driver/ToolChains.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/InitHeaderSearch.cpp

Chandler Carruth chandlerc at gmail.com
Mon Nov 7 02:19:00 PST 2011


Author: chandlerc
Date: Mon Nov  7 04:18:59 2011
New Revision: 143931

URL: http://llvm.org/viewvc/llvm-project?rev=143931&view=rev
Log:
Merging r143798:
------------------------------------------------------------------------
r143798 | chandlerc | 2011-11-05 01:30:29 -0700 (Sat, 05 Nov 2011) | 16 lines

Add two flags to the CC1 layer that I was hoping to avoid. We need to
encode the *exact* semantics which the header search paths internally
built by the Frontend layer have had, which is both non-user-provided,
and at times adding the implicit extern "C" bit to the directory entry.

There are lots of CC1 options that are very close, but none do quite
this, and they are all already overloaded for other purposes. In some
senses this makes the command lines more clean as it clearly indicates
which flags are exclusively used to implement internal detection of
"standard" header search paths.

Lots of the implementation of this is really crufty, due to the
surrounding cruft. It doesn't seem worth investing lots of time cleaning
this up as it isn't new, and hopefully *lots* of this code will melt
away as header search inside of the frontend becomes increasingly
trivial.
------------------------------------------------------------------------

Modified:
    cfe/branches/release_30/   (props changed)
    cfe/branches/release_30/include/clang/Driver/CC1Options.td
    cfe/branches/release_30/include/clang/Frontend/HeaderSearchOptions.h
    cfe/branches/release_30/lib/Driver/ToolChains.cpp
    cfe/branches/release_30/lib/Frontend/CompilerInvocation.cpp
    cfe/branches/release_30/lib/Frontend/InitHeaderSearch.cpp

Propchange: cfe/branches/release_30/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov  7 04:18:59 2011
@@ -1,3 +1,3 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:142113,142133-142134,142187,142349,142474,142476,142918,143344-143345,143684,143686-143687,143751-143752
+/cfe/trunk:142113,142133-142134,142187,142349,142474,142476,142918,143344-143345,143684,143686-143687,143751-143752,143798
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_30/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_30/include/clang/Driver/CC1Options.td?rev=143931&r1=143930&r2=143931&view=diff
==============================================================================
--- cfe/branches/release_30/include/clang/Driver/CC1Options.td (original)
+++ cfe/branches/release_30/include/clang/Driver/CC1Options.td Mon Nov  7 04:18:59 2011
@@ -642,6 +642,17 @@
 def iwithsysroot : JoinedOrSeparate<"-iwithsysroot">,MetaVarName<"<directory>">,
   HelpText<"Add directory to SYSTEM include search path, "
            "absolute paths are relative to -isysroot">;
+def internal_isystem : JoinedOrSeparate<"-internal-isystem">,
+  MetaVarName<"<directory>">,
+  HelpText<"Add directory to the internal system include search path; these "
+           "are assumed to not be user-provided and are used to model system "
+           "and standard headers' paths.">;
+def internal_externc_isystem : JoinedOrSeparate<"-internal-externc-isystem">,
+  MetaVarName<"<directory>">,
+  HelpText<"Add directory to the internal system include search path with "
+           "implicit extern \"C\" semantics; these are assumed to not be "
+           "user-provided and are used to model system and standard headers' "
+           "paths.">;
 def iprefix : JoinedOrSeparate<"-iprefix">, MetaVarName<"<prefix>">,
   HelpText<"Set the -iwithprefix/-iwithprefixbefore prefix">;
 def iwithprefix : JoinedOrSeparate<"-iwithprefix">, MetaVarName<"<dir>">,

Modified: cfe/branches/release_30/include/clang/Frontend/HeaderSearchOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_30/include/clang/Frontend/HeaderSearchOptions.h?rev=143931&r1=143930&r2=143931&view=diff
==============================================================================
--- cfe/branches/release_30/include/clang/Frontend/HeaderSearchOptions.h (original)
+++ cfe/branches/release_30/include/clang/Frontend/HeaderSearchOptions.h Mon Nov  7 04:18:59 2011
@@ -49,10 +49,24 @@
     /// path.
     unsigned IgnoreSysRoot : 1;
 
+    /// \brief True if this entry is an internal search path.
+    ///
+    /// This typically indicates that users didn't directly provide it, but
+    /// instead it was provided by a compatibility layer for a particular
+    /// system. This isn't redundant with IsUserSupplied (even though perhaps
+    /// it should be) because that is false for user provided '-iwithprefix'
+    /// header search entries.
+    unsigned IsInternal : 1;
+
+    /// \brief True if this entry's headers should be wrapped in extern "C".
+    unsigned ImplicitExternC : 1;
+
     Entry(StringRef path, frontend::IncludeDirGroup group,
-          bool isUserSupplied, bool isFramework, bool ignoreSysRoot)
+          bool isUserSupplied, bool isFramework, bool ignoreSysRoot,
+          bool isInternal, bool implicitExternC)
       : Path(path), Group(group), IsUserSupplied(isUserSupplied),
-        IsFramework(isFramework), IgnoreSysRoot(ignoreSysRoot) {}
+        IsFramework(isFramework), IgnoreSysRoot(ignoreSysRoot),
+        IsInternal(isInternal), ImplicitExternC(implicitExternC) {}
   };
 
   /// If non-empty, the directory to use as a "virtual system root" for include
@@ -98,9 +112,10 @@
 
   /// AddPath - Add the \arg Path path to the specified \arg Group list.
   void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
-               bool IsUserSupplied, bool IsFramework, bool IgnoreSysRoot) {
+               bool IsUserSupplied, bool IsFramework, bool IgnoreSysRoot,
+               bool IsInternal = false, bool ImplicitExternC = false) {
     UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework,
-                                IgnoreSysRoot));
+                                IgnoreSysRoot, IsInternal, ImplicitExternC));
   }
 };
 

Modified: cfe/branches/release_30/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_30/lib/Driver/ToolChains.cpp?rev=143931&r1=143930&r2=143931&view=diff
==============================================================================
--- cfe/branches/release_30/lib/Driver/ToolChains.cpp (original)
+++ cfe/branches/release_30/lib/Driver/ToolChains.cpp Mon Nov  7 04:18:59 2011
@@ -2242,7 +2242,7 @@
 // it.
 static void addSystemInclude(const ArgList &DriverArgs, ArgStringList &CC1Args,
                              const Twine &Path) {
-  CC1Args.push_back("-isystem");
+  CC1Args.push_back("-internal-isystem");
   CC1Args.push_back(DriverArgs.MakeArgString(Path));
 }
 
@@ -2254,7 +2254,7 @@
                               ArrayRef<StringRef> Paths) {
   for (ArrayRef<StringRef>::iterator I = Paths.begin(), E = Paths.end();
        I != E; ++I) {
-    CC1Args.push_back("-isystem");
+    CC1Args.push_back("-internal-isystem");
     CC1Args.push_back(DriverArgs.MakeArgString(*I));
   }
 }

Modified: cfe/branches/release_30/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_30/lib/Frontend/CompilerInvocation.cpp?rev=143931&r1=143930&r2=143931&view=diff
==============================================================================
--- cfe/branches/release_30/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/branches/release_30/lib/Frontend/CompilerInvocation.cpp Mon Nov  7 04:18:59 2011
@@ -569,10 +569,16 @@
         break;
       }
     } else {
-      if (E.Group != frontend::Angled && E.Group != frontend::System)
-        llvm::report_fatal_error("Invalid option set!");
-      Res.push_back(E.Group == frontend::Angled ? "-iwithprefixbefore" :
-                    "-iwithprefix");
+      if (E.IsInternal) {
+        assert(E.Group == frontend::System && "Unexpected header search group");
+        Res.push_back(E.ImplicitExternC ? "-internal-externc-isystem"
+                                        : "-internal-isystem");
+      } else {
+        if (E.Group != frontend::Angled && E.Group != frontend::System)
+          llvm::report_fatal_error("Invalid option set!");
+        Res.push_back(E.Group == frontend::Angled ? "-iwithprefixbefore" :
+                      "-iwithprefix");
+      }
     }
     Res.push_back(E.Path);
   }
@@ -1462,6 +1468,15 @@
        ie = Args.filtered_end(); it != ie; ++it)
     Opts.AddPath((*it)->getValue(Args), frontend::ObjCXXSystem, true, false,
                  true);
+
+  // Add the internal paths from a driver that detects standard include paths.
+  for (arg_iterator I = Args.filtered_begin(OPT_internal_isystem,
+                                            OPT_internal_externc_isystem),
+                    E = Args.filtered_end();
+       I != E; ++I)
+    Opts.AddPath((*I)->getValue(Args), frontend::System,
+                 false, false, false, /*IsInternal=*/true,
+                 (*I)->getOption().matches(OPT_internal_externc_isystem));
 }
 
 void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,

Modified: cfe/branches/release_30/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_30/lib/Frontend/InitHeaderSearch.cpp?rev=143931&r1=143930&r2=143931&view=diff
==============================================================================
--- cfe/branches/release_30/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/branches/release_30/lib/Frontend/InitHeaderSearch.cpp Mon Nov  7 04:18:59 2011
@@ -917,8 +917,8 @@
   // Add the user defined entries.
   for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) {
     const HeaderSearchOptions::Entry &E = HSOpts.UserEntries[i];
-    Init.AddPath(E.Path, E.Group, false, E.IsUserSupplied, E.IsFramework,
-                 E.IgnoreSysRoot);
+    Init.AddPath(E.Path, E.Group, !E.ImplicitExternC, E.IsUserSupplied,
+                 E.IsFramework, E.IgnoreSysRoot);
   }
 
   Init.AddDefaultIncludePaths(Lang, Triple, HSOpts);





More information about the llvm-branch-commits mailing list