r177368 - Finish refactoring the tool selection logic.

Benyei, Guy guy.benyei at intel.com
Tue Mar 19 04:37:07 PDT 2013


Hi Rafael,
Apparently this change breaks the Windows build: the test Driver\inhibit-downstream-commands.c runs into the unreachable you've added in the WindowsToolChain.cpp.
I guess the test should be fixed, please check on this.

Thanks
    Guy

-----Original Message-----
From: cfe-commits-bounces at cs.uiuc.edu [mailto:cfe-commits-bounces at cs.uiuc.edu] On Behalf Of Rafael Espindola
Sent: Tuesday, March 19, 2013 02:37
To: cfe-commits at cs.uiuc.edu
Subject: r177368 - Finish refactoring the tool selection logic.

Author: rafael
Date: Mon Mar 18 19:36:57 2013
New Revision: 177368

URL: http://llvm.org/viewvc/llvm-project?rev=177368&view=rev
Log:
Finish refactoring the tool selection logic.

The general pattern now is that Foobar::constructTool only creates tools defined in the tools::foobar namespace and then delegates to the parent.

The remaining duplicated code is now in the tools themselves.

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

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=177368&r1=177367&r2=177368&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Mar 18 19:36:57 2013
@@ -63,7 +63,7 @@ private:
 protected:
   ToolChain(const Driver &D, const llvm::Triple &T, const ArgList &Args);
 
-  virtual Tool *constructTool(Action::ActionClass AC) const = 0;
+  virtual Tool *constructTool(Action::ActionClass AC) const;
 
   /// \name Utilities for implementing subclasses.
   ///@{

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=177368&r1=177367&r2=177368&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Mar 18 19:36:57 2013
@@ -63,6 +63,26 @@ bool ToolChain::IsUnwindTablesDefault()
   return false;
 }
 
+Tool *ToolChain::constructTool(Action::ActionClass AC) const {
+  switch (AC) {
+  case Action::InputClass:
+  case Action::BindArchClass:
+  case Action::AssembleJobClass:
+  case Action::LinkJobClass:
+  case Action::LipoJobClass:
+  case Action::DsymutilJobClass:
+  case Action::VerifyJobClass:
+    llvm_unreachable("Invalid tool kind.");
+
+  case Action::CompileJobClass:
+  case Action::PrecompileJobClass:
+  case Action::PreprocessJobClass:
+  case Action::AnalyzeJobClass:
+  case Action::MigrateJobClass:
+    return new tools::Clang(*this);
+  }
+}
+
 Tool &ToolChain::SelectTool(const JobAction &JA) const {
   Action::ActionClass Key;
   if (getDriver().ShouldUseClangCompiler(JA))

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=177368&r1=177367&r2=177368&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Mar 18 19:36:57 2013
@@ -174,15 +174,6 @@ void Generic_ELF::anchor() {}
 
 Tool *Darwin::constructTool(Action::ActionClass AC) const {
   switch (AC) {
-  case Action::InputClass:
-  case Action::BindArchClass:
-    llvm_unreachable("Invalid tool kind.");
-  case Action::PreprocessJobClass:
-  case Action::AnalyzeJobClass:
-  case Action::MigrateJobClass:
-  case Action::PrecompileJobClass:
-  case Action::CompileJobClass:
-    return new tools::Clang(*this);
   case Action::AssembleJobClass:
     return new tools::darwin::Assemble(*this);
   case Action::LinkJobClass:
@@ -193,6 +184,8 @@ Tool *Darwin::constructTool(Action::Acti
     return new tools::darwin::Dsymutil(*this);
   case Action::VerifyJobClass:
     return new tools::darwin::VerifyDebug(*this);
+  default:
+    return ToolChain::constructTool(AC);
   }
 }
 
@@ -1359,31 +1352,18 @@ Generic_GCC::~Generic_GCC() {
 
 Tool *Generic_GCC::constructTool(Action::ActionClass AC) const {
   switch (AC) {
-  case Action::InputClass:
-  case Action::BindArchClass:
-    llvm_unreachable("Invalid tool kind.");
   case Action::PreprocessJobClass:
     return new tools::gcc::Preprocess(*this);
   case Action::PrecompileJobClass:
     return new tools::gcc::Precompile(*this);
-  case Action::AnalyzeJobClass:
-  case Action::MigrateJobClass:
-    return new tools::Clang(*this);
   case Action::CompileJobClass:
     return new tools::gcc::Compile(*this);
   case Action::AssembleJobClass:
     return new tools::gcc::Assemble(*this);
   case Action::LinkJobClass:
     return new tools::gcc::Link(*this);
-
-    // This is a bit ungeneric, but the only platform using a driver
-    // driver is Darwin.
-  case Action::LipoJobClass:
-    return new tools::darwin::Lipo(*this);
-  case Action::DsymutilJobClass:
-    return new tools::darwin::Dsymutil(*this);
-  case Action::VerifyJobClass:
-    return new tools::darwin::VerifyDebug(*this);
+  default:
+    return ToolChain::constructTool(AC);
   }
 }
 
@@ -1518,7 +1498,6 @@ Tool *Hexagon_TC::constructTool(Action::
   case Action::LinkJobClass:
     return new tools::hexagon::Link(*this);
   default:
-    assert(false && "Unsupported action for Hexagon target.");
     return Linux::constructTool(AC);
   }
 }
@@ -1637,17 +1616,6 @@ bool TCEToolChain::isPICDefaultForced()
   return false;
 }
 
-Tool *TCEToolChain::constructTool(Action::ActionClass AC) const {
-  switch (AC) {
-  case Action::PreprocessJobClass:
-    return new tools::gcc::Preprocess(*this);
-  case Action::AnalyzeJobClass:
-    return new tools::Clang(*this);
-  default:
-    llvm_unreachable("Unsupported action for TCE target.");
-  }
-}
-
 /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
 
 OpenBSD::OpenBSD(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=177368&r1=177367&r2=177368&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Mon Mar 18 19:36:57 2013
@@ -528,7 +528,6 @@ public:
                const ArgList &Args);
   ~TCEToolChain();
 
-  virtual Tool *constructTool(Action::ActionClass AC) const;
   bool IsMathErrnoDefault() const;
   bool isPICDefault() const;
   bool isPICDefaultForced() const;

Modified: cfe/trunk/lib/Driver/WindowsToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/WindowsToolChain.cpp?rev=177368&r1=177367&r2=177368&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/WindowsToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/WindowsToolChain.cpp Mon Mar 18 19:36:57 2013
@@ -38,17 +38,6 @@ Windows::Windows(const Driver &D, const
 
 Tool *Windows::constructTool(Action::ActionClass AC) const {
   switch (AC) {
-  case Action::InputClass:
-  case Action::BindArchClass:
-  case Action::LipoJobClass:
-  case Action::DsymutilJobClass:
-  case Action::VerifyJobClass:
-  case Action::PreprocessJobClass:
-  case Action::PrecompileJobClass:
-  case Action::AnalyzeJobClass:
-  case Action::MigrateJobClass:
-  case Action::CompileJobClass:
-    return new tools::Clang(*this);
   case Action::AssembleJobClass:
     if (getTriple().getEnvironment() == llvm::Triple::MachO)
       return new tools::darwin::Assemble(*this); @@ -56,6 +45,8 @@ Tool *Windows::constructTool(Action::Act
     break;
   case Action::LinkJobClass:
     return new tools::visualstudio::Link(*this);
+  default:
+    return ToolChain::constructTool(AC);
   }
 }
 


_______________________________________________
cfe-commits mailing list
cfe-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.





More information about the cfe-commits mailing list