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

Daniel Dunbar daniel at zuster.org
Tue Mar 17 14:21:27 PDT 2009


Author: ddunbar
Date: Tue Mar 17 16:21:26 2009
New Revision: 67105

URL: http://llvm.org/viewvc/llvm-project?rev=67105&view=rev
Log:
Driver: Pass HostInfo reference into ToolChain.

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

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

==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Mar 17 16:21:26 2009
@@ -17,18 +17,17 @@
 namespace driver {
   class ArgList;
   class Compilation;
-  class Driver;
+  class HostInfo;
   class JobAction;
   class Tool;
 
 /// ToolChain - Access to tools for a single platform.
 class ToolChain {
-  Driver &TheDriver;
-
+  const HostInfo &Host;
   std::string Arch, Platform, OS;
 
 protected:
-  ToolChain(Driver &D, const char *_Arch, const char *_Platform, 
+  ToolChain(const HostInfo &Host, const char *_Arch, const char *_Platform, 
             const char *_OS);
 
 public:
@@ -36,6 +35,7 @@
 
   // Accessors
 
+  const HostInfo &getHost() const { return Host; }
   const std::string &getArchName() const { return Arch; }
   const std::string &getPlatform() const { return Platform; }
   const std::string &getOS() const { return OS; }
@@ -44,7 +44,10 @@
 
   /// TranslateArgs - Create a new derived argument list for any
   /// argument translations this ToolChain may wish to perform.
-  virtual ArgList *TranslateArgs(const ArgList &Args) const = 0;
+  ///
+  /// The client implementation is free to return Args directly if no
+  /// translations need to be performed.
+  virtual ArgList *TranslateArgs(ArgList &Args) const = 0;
 
   /// SelectTool - Choose a tool to use to handle the action \arg JA.
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const = 0;

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

==============================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Mar 17 16:21:26 2009
@@ -11,12 +11,13 @@
 
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Driver/HostInfo.h"
 
 using namespace clang::driver;
 
-ToolChain::ToolChain(Driver &_TheDriver, const char *_Arch, 
+ToolChain::ToolChain(const HostInfo &_Host, const char *_Arch, 
                      const char *_Platform, const char *_OS) 
-  : TheDriver(_TheDriver), Arch(_Arch), Platform(_Platform), OS(_OS) {
+  : Host(_Host), Arch(_Arch), Platform(_Platform), OS(_OS) {
 }
 
 ToolChain::~ToolChain() {
@@ -24,38 +25,38 @@
 
 llvm::sys::Path ToolChain::GetFilePath(const Compilation &C, 
                                        const char *Name) const {
-  return TheDriver.GetFilePath(Name, this);
+  return Host.getDriver().GetFilePath(Name, this);
   
 }
 
 llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C, 
                                           const char *Name) const {
-  return TheDriver.GetProgramPath(Name, this);
+  return Host.getDriver().GetProgramPath(Name, this);
 }
 
 bool ToolChain::ShouldUseClangCompiler(const Compilation &C, 
                                        const JobAction &JA) const {
   // Check if user requested no clang, or clang doesn't understand
   // this type (we only handle single inputs for now).
-  if (TheDriver.CCCNoClang || JA.size() != 1 || 
+  if (Host.getDriver().CCCNoClang || JA.size() != 1 || 
       !types::isAcceptedByClang((*JA.begin())->getType()))
     return false;
 
   // Otherwise make sure this is an action clang undertands.
   if (isa<PreprocessJobAction>(JA)) {
-    if (TheDriver.CCCNoClangCPP)
+    if (Host.getDriver().CCCNoClangCPP)
       return false;
   } else if (!isa<PrecompileJobAction>(JA) && !isa<CompileJobAction>(JA))
     return false;
 
   // Avoid CXX if the user requested.
-  if (TheDriver.CCCNoClangCXX && types::isCXX((*JA.begin())->getType()))
+  if (Host.getDriver().CCCNoClangCXX && types::isCXX((*JA.begin())->getType()))
     return false;
 
   // Finally, don't use clang if this isn't one of the user specified
   // archs to build.
-  if (!TheDriver.CCCClangArchs.empty() && 
-      TheDriver.CCCClangArchs.count(getArchName()))
+  if (!Host.getDriver().CCCClangArchs.empty() && 
+      Host.getDriver().CCCClangArchs.count(getArchName()))
     return false;
 
   return true;





More information about the cfe-commits mailing list