Hi rnk, hansw,
The Command will refer back to the Tool as its source, so it has to outlive the
Command.
Having the Tool on the stack would cause us to crash when using "clang-cl -GR
-fallback", because if the Command fails, Driver::ExecuteCompilation tries to
peek at the Command's source.
http://reviews.llvm.org/D4314
Files:
include/clang/Driver/ToolChain.h
lib/Driver/ToolChain.cpp
lib/Driver/Tools.cpp
Index: include/clang/Driver/ToolChain.h
===================================================================
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -69,6 +69,7 @@
mutable std::unique_ptr<Tool> Clang;
mutable std::unique_ptr<Tool> Assemble;
mutable std::unique_ptr<Tool> Link;
+ mutable std::unique_ptr<Tool> 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<tools::visualstudio::Compile*>(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.
Index: include/clang/Driver/ToolChain.h
===================================================================
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -69,6 +69,7 @@
mutable std::unique_ptr<Tool> Clang;
mutable std::unique_ptr<Tool> Assemble;
mutable std::unique_ptr<Tool> Link;
+ mutable std::unique_ptr<Tool> 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<tools::visualstudio::Compile*>(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.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits