[cfe-commits] r81279 - in /cfe/trunk: include/clang/Driver/HostInfo.h lib/Driver/Driver.cpp lib/Driver/HostInfo.cpp

Daniel Dunbar daniel at zuster.org
Tue Sep 8 16:37:19 PDT 2009


Author: ddunbar
Date: Tue Sep  8 18:37:19 2009
New Revision: 81279

URL: http://llvm.org/viewvc/llvm-project?rev=81279&view=rev
Log:
Rename HostInfo::getToolChain to HostInfo::CreateToolChain, and don't recreate
the default tool chain when binding the default architecture.

Modified:
    cfe/trunk/include/clang/Driver/HostInfo.h
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/HostInfo.cpp

Modified: cfe/trunk/include/clang/Driver/HostInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/HostInfo.h?rev=81279&r1=81278&r2=81279&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/HostInfo.h (original)
+++ cfe/trunk/include/clang/Driver/HostInfo.h Tue Sep  8 18:37:19 2009
@@ -20,13 +20,13 @@
   class Driver;
   class ToolChain;
 
-/// HostInfo - Config information about a particular host which may
-/// interact with driver behavior.
+/// HostInfo - Config information about a particular host which may interact
+/// with driver behavior.
 /// 
-/// The host information is used for controlling the parts of the
-/// driver which interact with the platform the driver is ostensibly
-/// being run from. For testing purposes, the HostInfo used by the
-/// driver may differ from the actual host.
+/// The host information is used for controlling the parts of the driver which
+/// interact with the platform the driver is ostensibly being run from. For
+/// testing purposes, the HostInfo used by the driver may differ from the actual
+/// host.
 class HostInfo {
 protected:
   const Driver &TheDriver;
@@ -44,27 +44,28 @@
   std::string getPlatformName() const { return Triple.getVendorName(); }
   std::string getOSName() const { return Triple.getOSName(); }
 
-  /// useDriverDriver - Whether the driver should act as a driver
-  /// driver for this host and support -arch, -Xarch, etc.
+  /// useDriverDriver - Whether the driver should act as a driver driver for
+  /// this host and support -arch, -Xarch, etc.
   virtual bool useDriverDriver() const = 0;
 
-  /// lookupTypeForExtension - Return the default language type to use
-  /// for the given extension.
+  /// lookupTypeForExtension - Return the default language type to use for the
+  /// given extension.
   virtual types::ID lookupTypeForExtension(const char *Ext) const = 0;
 
-  /// getToolChain - Construct the toolchain to use for this host.
+  /// CreateToolChain - Construct the toolchain to use for this host (which the
+  /// host retains ownership of).
   ///
-  /// \param Args - The argument list, which may be used to alter the
-  /// default toolchain, for example in the presence of -m32 or -m64.
+  /// \param Args - The argument list, which may be used to alter the default
+  /// toolchain, for example in the presence of -m32 or -m64.
   ///
-  /// \param ArchName - The architecture to return a toolchain for, or
-  /// 0 if unspecified. This will only ever be non-zero for hosts
-  /// which support a driver driver.
+  /// \param ArchName - The architecture to return a toolchain for, or 0 if
+  /// unspecified. This will only ever be non-zero for hosts which support a
+  /// driver driver.
 
   // FIXME: Pin down exactly what the HostInfo is allowed to use Args
   // for here. Currently this is for -m32 / -m64 defaulting.
-  virtual ToolChain *getToolChain(const ArgList &Args, 
-                                  const char *ArchName=0) const = 0;
+  virtual ToolChain *CreateToolChain(const ArgList &Args, 
+                                     const char *ArchName=0) const = 0;
 };
 
 const HostInfo *createAuroraUXHostInfo(const Driver &D,

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=81279&r1=81278&r2=81279&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep  8 18:37:19 2009
@@ -207,7 +207,7 @@
   Host = GetHostInfo(HostTriple);
 
   // The compilation takes ownership of Args.
-  Compilation *C = new Compilation(*this, *Host->getToolChain(*Args), Args);
+  Compilation *C = new Compilation(*this, *Host->CreateToolChain(*Args), Args);
 
   // FIXME: This behavior shouldn't be here.
   if (CCCPrintOptions) {
@@ -1017,19 +1017,14 @@
   }
 
   if (const BindArchAction *BAA = dyn_cast<BindArchAction>(A)) {
-    const char *ArchName = BAA->getArchName();
+    const ToolChain *TC = &C.getDefaultToolChain();
+
     std::string Arch;
-    if (!ArchName) {
-      Arch = C.getDefaultToolChain().getArchName();
-      ArchName = Arch.c_str();
-    }
-    BuildJobsForAction(C,
-                       *BAA->begin(),
-                       Host->getToolChain(C.getArgs(), ArchName),
-                       CanAcceptPipe,
-                       AtTopLevel,
-                       LinkingOutput,
-                       Result);
+    if (BAA->getArchName())
+      TC = Host->CreateToolChain(C.getArgs(), BAA->getArchName());
+
+    BuildJobsForAction(C, *BAA->begin(), TC, CanAcceptPipe, AtTopLevel,
+                       LinkingOutput, Result);
     return;
   }
 

Modified: cfe/trunk/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=81279&r1=81278&r2=81279&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Tue Sep  8 18:37:19 2009
@@ -66,8 +66,8 @@
     return Ty;
   }
 
-  virtual ToolChain *getToolChain(const ArgList &Args,
-                                  const char *ArchName) const;
+  virtual ToolChain *CreateToolChain(const ArgList &Args,
+                                     const char *ArchName) const;
 };
 
 DarwinHostInfo::DarwinHostInfo(const Driver &D, const llvm::Triple& Triple)
@@ -104,8 +104,8 @@
   return true;
 }
 
-ToolChain *DarwinHostInfo::getToolChain(const ArgList &Args,
-                                        const char *ArchName) const {
+ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args,
+                                           const char *ArchName) const {
   std::string Arch;
   if (!ArchName) {
     // If we aren't looking for a specific arch, infer the default architecture
@@ -192,8 +192,8 @@
     return types::lookupTypeForExtension(Ext);
   }
 
-  virtual ToolChain *getToolChain(const ArgList &Args,
-                                  const char *ArchName) const;
+  virtual ToolChain *CreateToolChain(const ArgList &Args,
+                                     const char *ArchName) const;
 };
 
 UnknownHostInfo::UnknownHostInfo(const Driver &D, const llvm::Triple& Triple)
@@ -210,8 +210,8 @@
   return false;
 }
 
-ToolChain *UnknownHostInfo::getToolChain(const ArgList &Args,
-                                         const char *ArchName) const {
+ToolChain *UnknownHostInfo::CreateToolChain(const ArgList &Args,
+                                            const char *ArchName) const {
   assert(!ArchName &&
          "Unexpected arch name on platform without driver driver support.");
 
@@ -259,8 +259,8 @@
     return types::lookupTypeForExtension(Ext);
   }
 
-  virtual ToolChain *getToolChain(const ArgList &Args,
-                                  const char *ArchName) const;
+  virtual ToolChain *CreateToolChain(const ArgList &Args,
+                                     const char *ArchName) const;
 };
 
 OpenBSDHostInfo::~OpenBSDHostInfo() {
@@ -273,8 +273,8 @@
   return false;
 }
 
-ToolChain *OpenBSDHostInfo::getToolChain(const ArgList &Args,
-                                         const char *ArchName) const {
+ToolChain *OpenBSDHostInfo::CreateToolChain(const ArgList &Args,
+                                            const char *ArchName) const {
   assert(!ArchName &&
          "Unexpected arch name on platform without driver driver support.");
 
@@ -310,8 +310,8 @@
     return types::lookupTypeForExtension(Ext);
   }
 
-  virtual ToolChain *getToolChain(const ArgList &Args,
-                                  const char *ArchName) const;
+  virtual ToolChain *CreateToolChain(const ArgList &Args,
+                                     const char *ArchName) const;
 };
 
 AuroraUXHostInfo::~AuroraUXHostInfo() {
@@ -324,8 +324,8 @@
   return false;
 }
 
-ToolChain *AuroraUXHostInfo::getToolChain(const ArgList &Args,
-                                          const char *ArchName) const {
+ToolChain *AuroraUXHostInfo::CreateToolChain(const ArgList &Args,
+                                             const char *ArchName) const {
   assert(!ArchName &&
          "Unexpected arch name on platform without driver driver support.");
 
@@ -359,8 +359,8 @@
     return types::lookupTypeForExtension(Ext);
   }
 
-  virtual ToolChain *getToolChain(const ArgList &Args,
-                                  const char *ArchName) const;
+  virtual ToolChain *CreateToolChain(const ArgList &Args,
+                                     const char *ArchName) const;
 };
 
 FreeBSDHostInfo::~FreeBSDHostInfo() {
@@ -373,8 +373,8 @@
   return false;
 }
 
-ToolChain *FreeBSDHostInfo::getToolChain(const ArgList &Args,
-                                         const char *ArchName) const {
+ToolChain *FreeBSDHostInfo::CreateToolChain(const ArgList &Args,
+                                            const char *ArchName) const {
   bool Lib32 = false;
 
   assert(!ArchName &&
@@ -419,8 +419,8 @@
     return types::lookupTypeForExtension(Ext);
   }
 
-  virtual ToolChain *getToolChain(const ArgList &Args,
-                                  const char *ArchName) const;
+  virtual ToolChain *CreateToolChain(const ArgList &Args,
+                                     const char *ArchName) const;
 };
 
 DragonFlyHostInfo::~DragonFlyHostInfo() {
@@ -433,8 +433,8 @@
   return false;
 }
 
-ToolChain *DragonFlyHostInfo::getToolChain(const ArgList &Args,
-                                           const char *ArchName) const {
+ToolChain *DragonFlyHostInfo::CreateToolChain(const ArgList &Args,
+                                              const char *ArchName) const {
   assert(!ArchName &&
          "Unexpected arch name on platform without driver driver support.");
 
@@ -468,8 +468,8 @@
     return types::lookupTypeForExtension(Ext);
   }
 
-  virtual ToolChain *getToolChain(const ArgList &Args,
-                                  const char *ArchName) const;
+  virtual ToolChain *CreateToolChain(const ArgList &Args,
+                                     const char *ArchName) const;
 };
 
 LinuxHostInfo::~LinuxHostInfo() {
@@ -482,8 +482,8 @@
   return false;
 }
 
-ToolChain *LinuxHostInfo::getToolChain(const ArgList &Args,
-                                       const char *ArchName) const {
+ToolChain *LinuxHostInfo::CreateToolChain(const ArgList &Args,
+                                          const char *ArchName) const {
 
   assert(!ArchName &&
          "Unexpected arch name on platform without driver driver support.");





More information about the cfe-commits mailing list