[PATCH] clang-cl: Don't store the cl compiler Tool on the stack (PR20131)

Hans Wennborg hans at chromium.org
Thu Jun 26 12:52:00 PDT 2014


Make the cl tool a member of the Clang tool instead.

http://reviews.llvm.org/D4314

Files:
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h

Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4184,9 +4184,8 @@
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
       Output.getType() == types::TY_Object &&
       (InputType == types::TY_C || InputType == types::TY_CXX)) {
-    tools::visualstudio::Compile CL(getToolChain());
-    Command *CLCommand = CL.GetCommand(C, JA, Output, Inputs, Args,
-                                       LinkingOutput);
+    Command *CLCommand = getCLFallback()->GetCommand(C, JA, Output, Inputs,
+                                                     Args, LinkingOutput);
     // RTTI support in clang-cl is a work in progress.  Fall back to MSVC early
     // if we are using 'clang-cl /fallback /GR'.
     // FIXME: Remove this when RTTI is finished.
@@ -4450,6 +4449,12 @@
   }
 }
 
+visualstudio::Compile *Clang::getCLFallback() const {
+  if (!CLFallback)
+    CLFallback.reset(new visualstudio::Compile(getToolChain()));
+  return CLFallback.get();
+}
+
 void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
                            const InputInfo &Output,
                            const InputInfoList &Inputs,
Index: lib/Driver/Tools.h
===================================================================
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -29,6 +29,11 @@
 }
 
 namespace tools {
+
+namespace visualstudio {
+  class Compile;  
+};
+
 using llvm::opt::ArgStringList;
 
   /// \brief Clang compiler tool.
@@ -78,6 +83,10 @@
     void AddClangCLArgs(const llvm::opt::ArgList &Args,
                         llvm::opt::ArgStringList &CmdArgs) const;
 
+    visualstudio::Compile *getCLFallback() const;
+
+    mutable std::unique_ptr<visualstudio::Compile> CLFallback;
+
   public:
     Clang(const ToolChain &TC) : Tool("clang", "clang frontend", TC) {}
 
@@ -563,7 +572,7 @@
   };
 } // end namespace dragonfly
 
-  /// Visual studio tools.
+/// Visual studio tools.
 namespace visualstudio {
   class LLVM_LIBRARY_VISIBILITY Link : public Tool {
   public:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4314.10900.patch
Type: text/x-patch
Size: 2089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140626/c26cba1e/attachment.bin>


More information about the cfe-commits mailing list