[llvm-branch-commits] [cfe-branch] r143928 - in /cfe/branches/release_30: ./ lib/Driver/ToolChain.cpp lib/Driver/Tools.cpp

Chandler Carruth chandlerc at gmail.com
Mon Nov 7 02:13:50 PST 2011

Author: chandlerc
Date: Mon Nov  7 04:13:50 2011
New Revision: 143928

URL: http://llvm.org/viewvc/llvm-project?rev=143928&view=rev
Merging r143687:
r143687 | chandlerc | 2011-11-04 00:43:33 -0700 (Fri, 04 Nov 2011) | 16 lines

Sink the strange '-stdlib=...' flag handling into the C++ include
handling logic of the generic ToolChain. This flag, despite its name,
has *nothing* to do with the GCC flag '-nostdlib' that relates
(exclusively) to the linking behavior. It is a most unfortunate name in
that regard...

It is used to tell InitHeaderSearch.cpp *which* set of C++ standard
library header search paths to use -- those for libstdc++ from GCC's
installation, or those from a libc++ installation. As this logic is
hoisted out of the Frontend, and into the Driver as part of this
ToolChain, the generic method will be overridden for the platform, where
it can implement this logic directly. As such, hiding the CC1 option
passing in the generic space is a natural fit despite the odd naming.

Also, expand on the comments to clarify whats going on, and tidy up the
Tools.cpp code now that its simpler.

    cfe/branches/release_30/   (props changed)

Propchange: cfe/branches/release_30/
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov  7 04:13:50 2011
@@ -1,3 +1,3 @@

Modified: cfe/branches/release_30/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_30/lib/Driver/ToolChain.cpp?rev=143928&r1=143927&r2=143928&view=diff
--- cfe/branches/release_30/lib/Driver/ToolChain.cpp (original)
+++ cfe/branches/release_30/lib/Driver/ToolChain.cpp Mon Nov  7 04:13:50 2011
@@ -232,7 +232,16 @@
 void ToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &Args,
                                              ArgStringList &CmdArgs) const {
-  // Header search paths are handled by each of the subclasses.
+  // Header search paths should be handled by each of the subclasses.
+  // Historically, they have not been, and instead have been handled inside of
+  // the CC1-layer frontend. As the logic is hoisted out, this generic function
+  // will slowly stop being called.
+  //
+  // While it is being called, replicate a bit of a hack to propagate the
+  // '-stdlib=' flag down to CC1 so that it can in turn customize the C++
+  // header search paths with it. Once all systems are overriding this
+  // function, the CC1 flag and this line can be removed.
+  Args.AddAllArgs(CmdArgs, options::OPT_stdlib_EQ);
 void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,

Modified: cfe/branches/release_30/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_30/lib/Driver/Tools.cpp?rev=143928&r1=143927&r2=143928&view=diff
--- cfe/branches/release_30/lib/Driver/Tools.cpp (original)
+++ cfe/branches/release_30/lib/Driver/Tools.cpp Mon Nov  7 04:13:50 2011
@@ -423,11 +423,8 @@
   getToolChain().AddClangSystemIncludeArgs(Args, CmdArgs);
   // Add C++ include arguments, if needed.
-  types::ID InputType = Inputs[0].getType();
-  if (types::isCXX(InputType)) {
+  if (types::isCXX(Inputs[0].getType()))
     getToolChain().AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
-    Args.AddAllArgs(CmdArgs, options::OPT_stdlib_EQ);
-  }
 /// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting.

More information about the llvm-branch-commits mailing list