]> granicus.if.org Git - clang/commitdiff
Remove the TargetTriple object that I added to the Driver recently. This
authorChandler Carruth <chandlerc@gmail.com>
Wed, 25 Jan 2012 08:49:21 +0000 (08:49 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 25 Jan 2012 08:49:21 +0000 (08:49 +0000)
helped stage the refactoring of things a bit, but really isn't the right
place for it. The driver may be responsible for compilations with many
different targets. In those cases, having a target triple in the driver
is actively misleading because for many of those compilations that is
not actually the triple being targeted.

This moves the last remaining users of the Driver's target triple to
instead use the ToolChain's target triple. The toolchain has a single,
concrete target it operates over, making this a more stable and natural
home for it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148942 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Driver.h
lib/Driver/Driver.cpp

index b9cbeaac7b75b40a272f653fa3096d1e556f632c..067f080f740eb18572c18881a4c2f7e65ff02c5c 100644 (file)
@@ -102,11 +102,6 @@ public:
   /// Information about the host which can be overridden by the user.
   std::string HostBits, HostMachine, HostSystem, HostRelease;
 
-  /// \brief Target triple.
-  /// Represents which platforms this driver will target at each stage of the
-  /// compilation.
-  llvm::Triple TargetTriple;
-
   /// The file to log CC_PRINT_OPTIONS output to, if enabled.
   const char *CCPrintOptionsFilename;
 
index 217df02b7fd2c33b2d7eada0aa7840cbbb469b75..f44fe279b023993762b2384c99fae9cdfcfe2d0a 100644 (file)
@@ -57,7 +57,6 @@ Driver::Driver(StringRef ClangExecutable,
     DefaultImageName(DefaultImageName),
     DriverTitle("clang \"gcc-compatible\" driver"),
     Host(0),
-    TargetTriple(llvm::Triple::normalize(DefaultTargetTriple)),
     CCPrintOptionsFilename(0), CCPrintHeadersFilename(0),
     CCLogDiagnosticsFilename(0), CCCIsCXX(false),
     CCCIsCPP(false),CCCEcho(false), CCCPrintBindings(false),
@@ -330,16 +329,18 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
   if (Args->hasArg(options::OPT_nostdlib))
     UseStdLib = false;
 
-  // Recompute the target triple based on the args.
-  TargetTriple = computeTargetTriple(DefaultTargetTriple, *Args);
-  Host = GetHostInfo(TargetTriple);
+  // Compute the target triple based on the args, and build a Host out of it.
+  // FIXME: Yes, this makes no sense. HostInfo has little to do with the host.
+  Host = GetHostInfo(computeTargetTriple(DefaultTargetTriple, *Args));
 
   // Perform the default argument translations.
   DerivedArgList *TranslatedArgs = TranslateInputArgs(*Args);
 
+  // Owned by the host.
+  const ToolChain &TC = *Host->CreateToolChain(*Args);
+
   // The compilation takes ownership of Args.
-  Compilation *C = new Compilation(*this, *Host->CreateToolChain(*Args), Args,
-                                   TranslatedArgs);
+  Compilation *C = new Compilation(*this, TC, Args, TranslatedArgs);
 
   // FIXME: This behavior shouldn't be here.
   if (CCCPrintOptions) {
@@ -356,7 +357,7 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
 
   // Construct the list of abstract actions to perform for this compilation. On
   // Darwin target OSes this uses the driver-driver and universal actions.
-  if (TargetTriple.isOSDarwin())
+  if (TC.getTriple().isOSDarwin())
     BuildUniversalActions(C->getDefaultToolChain(), C->getArgs(),
                           Inputs, C->getActions());
   else
@@ -446,12 +447,11 @@ void Driver::generateCompilationDiagnostics(Compilation &C,
 
   // Construct the list of abstract actions to perform for this compilation. On
   // Darwin OSes this uses the driver-driver and builds universal actions.
-  if (TargetTriple.isOSDarwin())
-    BuildUniversalActions(C.getDefaultToolChain(), C.getArgs(),
-                          Inputs, C.getActions());
+  const ToolChain &TC = C.getDefaultToolChain();
+  if (TC.getTriple().isOSDarwin())
+    BuildUniversalActions(TC, C.getArgs(), Inputs, C.getActions());
   else
-    BuildActions(C.getDefaultToolChain(), C.getArgs(), Inputs,
-                 C.getActions());
+    BuildActions(TC, C.getArgs(), Inputs, C.getActions());
 
   BuildJobs(C);