Index: include/clang/Driver/ToolChain.h =================================================================== --- include/clang/Driver/ToolChain.h +++ include/clang/Driver/ToolChain.h @@ -69,6 +69,7 @@ mutable std::unique_ptr Clang; mutable std::unique_ptr Assemble; mutable std::unique_ptr Link; + mutable std::unique_ptr CL; Tool *getClang() const; Tool *getAssemble() const; Tool *getLink() const; @@ -318,6 +319,9 @@ virtual bool AddFastMathRuntimeIfAvailable(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const; + + /// Get the MSVC compiler tool. + Tool *getCL() const; }; } // end namespace driver Index: lib/Driver/ToolChain.cpp =================================================================== --- lib/Driver/ToolChain.cpp +++ lib/Driver/ToolChain.cpp @@ -393,3 +393,9 @@ CmdArgs.push_back(Args.MakeArgString(Path)); return true; } + +Tool *ToolChain::getCL() const { + if (!CL) + CL.reset(new tools::visualstudio::Compile(*this)); + return CL.get(); +} Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4184,9 +4184,11 @@ 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); + + tools::visualstudio::Compile *CL = + static_cast(getToolChain().getCL()); + Command *CLCommand = CL->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.