FrontendTool: fix a use-after-move on Windows

The order of evaluation of arguments is undefined by the language
specification.  Windows evaluates right to left rather than left to
right.  This means that the argument was getting moved away before
initializing the first formal argument.  Use a temporary to construct
the value to avoid the use-after-move.
This commit is contained in:
Saleem Abdulrasool
2018-11-21 14:22:19 -08:00
parent ab37099967
commit 19a76ea042

View File

@@ -1261,10 +1261,12 @@ static bool performCompileStepsPostSILGen(
std::unique_ptr<llvm::raw_fd_ostream> OptRecordFile =
createOptRecordFile(SILOpts.OptRecordFile, Instance.getDiags());
if (OptRecordFile)
SM->setOptRecordStream(llvm::make_unique<llvm::yaml::Output>(
*OptRecordFile, &Instance.getSourceMgr()),
std::move(OptRecordFile));
if (OptRecordFile) {
auto Output =
llvm::make_unique<llvm::yaml::Output>(*OptRecordFile,
&Instance.getSourceMgr());
SM->setOptRecordStream(std::move(Output), std::move(OptRecordFile));
}
if (performMandatorySILPasses(Invocation, SM.get(), observer))
return true;