mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user