]> granicus.if.org Git - clang/commitdiff
Move ToolChain::ShouldUseClangCompiler to
authorDaniel Dunbar <daniel@zuster.org>
Tue, 24 Mar 2009 18:57:02 +0000 (18:57 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 24 Mar 2009 18:57:02 +0000 (18:57 +0000)
Driver::ShouldUseClangCompiler.
 - No functionality change.

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

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

index 7a52498364b0a8027f934098217be78a143f9240..d1df4d87514c9a14adaec922ada75f1e52aef61b 100644 (file)
@@ -77,6 +77,7 @@ public:
   /// Only print tool bindings, don't build any jobs.
   bool CCCPrintBindings : 1;
 
+private:
   /// Don't use clang for any tasks.
   bool CCCNoClang : 1;
 
@@ -227,6 +228,11 @@ public:
   /// host triple.
   const HostInfo *GetHostInfo(const char *HostTriple) const;
 
+  /// ShouldUseClangCompilar - Should the clang compiler be used to
+  /// handle this action.
+  bool ShouldUseClangCompiler(const Compilation &C, const JobAction &JA, 
+                              const std::string &ArchName) const;
+
   /// @}
 };
 
index f917eb6da4966645e908e6cc69decd91faabaf78..99d9bcb3cb5eba86030305aee9a896bed3b2a294 100644 (file)
@@ -76,10 +76,6 @@ public:
   llvm::sys::Path GetFilePath(const Compilation &C, const char *Name) const;
   llvm::sys::Path GetProgramPath(const Compilation &C, const char *Name) const;
 
-  /// ShouldUseClangCompilar - Should the clang compiler be used to
-  /// handle this action.
-  bool ShouldUseClangCompiler(const Compilation &C, const JobAction &JA) const;
-
   // Platform defaults information
 
   /// IsMathErrnoDefault - Does this tool chain set -fmath-errno by
index df71c97215afa7f2082dd285a5394eec61b3818e..1e10ac5c8f9d5266ac0c11ed2e06580da1beb18e 100644 (file)
@@ -981,3 +981,30 @@ const HostInfo *Driver::GetHostInfo(const char *Triple) const {
   return createUnknownHostInfo(*this, Arch.c_str(), Platform.c_str(), 
                                OS.c_str());
 }
+
+bool Driver::ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
+                                    const std::string &ArchName) const {
+  // Check if user requested no clang, or clang doesn't understand
+  // this type (we only handle single inputs for now).
+  if (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 (CCCNoClangCPP)
+      return false;
+  } else if (!isa<PrecompileJobAction>(JA) && !isa<CompileJobAction>(JA))
+    return false;
+
+  // Avoid CXX if the user requested.
+  if (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 (!CCCClangArchs.empty() && !CCCClangArchs.count(ArchName))
+    return false;
+
+  return true;
+}
index 87b169e7e9c55c70e6b5126a1016b7d9f5bb8f25..aed58c94221ae3e9d04d60719916a60a5bae3416 100644 (file)
@@ -33,31 +33,3 @@ llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C,
                                           const char *Name) const {
   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 (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 (Host.getDriver().CCCNoClangCPP)
-      return false;
-  } else if (!isa<PrecompileJobAction>(JA) && !isa<CompileJobAction>(JA))
-    return false;
-
-  // Avoid CXX if the user requested.
-  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 (!Host.getDriver().CCCClangArchs.empty() &&
-      !Host.getDriver().CCCClangArchs.count(getArchName()))
-    return false;
-
-  return true;
-}
index d4e8e93e2aa65fb2c5e4fe3dd024d65f5751680d..c8df6c09e59bbf56f623fa6dc9146a934bf4e473 100644 (file)
@@ -91,7 +91,7 @@ Darwin_X86::~Darwin_X86() {
 Tool &Darwin_X86::SelectTool(const Compilation &C, 
                               const JobAction &JA) const {
   Action::ActionClass Key;
-  if (ShouldUseClangCompiler(C, JA))
+  if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName()))
     Key = Action::AnalyzeJobClass;
   else
     Key = JA.getKind();
@@ -172,7 +172,7 @@ Generic_GCC::~Generic_GCC() {
 Tool &Generic_GCC::SelectTool(const Compilation &C, 
                               const JobAction &JA) const {
   Action::ActionClass Key;
-  if (ShouldUseClangCompiler(C, JA))
+  if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getArchName()))
     Key = Action::AnalyzeJobClass;
   else
     Key = JA.getKind();