[PATCH] Make ToolChain::SelectTool virtual.

Douglas Katzman dougk at google.com
Thu Jun 4 08:25:54 PDT 2015


Hi nlewycky,

This allows ToolChain to decide if Clang is not the right C compiler.
    
Also, removed comment in Driver::ShouldUseClangCompiler implying that there was an opt-out ability at that point - there isn't.

http://reviews.llvm.org/D10246

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp

Index: include/clang/Driver/ToolChain.h
===================================================================
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -164,7 +164,12 @@
   }
 
   /// Choose a tool to use to handle the action \p JA.
-  Tool *SelectTool(const JobAction &JA) const;
+  /// This is virtualized because there are scenarios where you want the
+  /// default driver in the default driver-mode not to pick Clang as
+  /// the right tool for a C program, at the discretion of the ToolChain.
+  /// GetTool is overridable, but it's also necessary to avoid inquiring with
+  /// Driver::ShouldUseClangCompiler() which says "yes" to C, usually.
+  virtual Tool *SelectTool(const JobAction &JA) const;
 
   // Helper methods
 
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -2118,13 +2118,12 @@
 }
 
 bool Driver::ShouldUseClangCompiler(const JobAction &JA) const {
-  // Check if user requested no clang, or clang doesn't understand this type (we
-  // only handle single inputs for now).
+  // Say "no" if there is not exactly one input of a type clang understands.
   if (JA.size() != 1 ||
       !types::isAcceptedByClang((*JA.begin())->getType()))
     return false;
 
-  // Otherwise make sure this is an action clang understands.
+  // And say "no" if this is not a kind of action clang understands.
   if (!isa<PreprocessJobAction>(JA) && !isa<PrecompileJobAction>(JA) &&
       !isa<CompileJobAction>(JA) && !isa<BackendJobAction>(JA))
     return false;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10246.27123.patch
Type: text/x-patch
Size: 1607 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150604/4a939184/attachment.bin>


More information about the cfe-commits mailing list