Skip to content

Commit 19a76ea

Browse files
committed
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.
1 parent ab37099 commit 19a76ea

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,10 +1261,12 @@ static bool performCompileStepsPostSILGen(
12611261

12621262
std::unique_ptr<llvm::raw_fd_ostream> OptRecordFile =
12631263
createOptRecordFile(SILOpts.OptRecordFile, Instance.getDiags());
1264-
if (OptRecordFile)
1265-
SM->setOptRecordStream(llvm::make_unique<llvm::yaml::Output>(
1266-
*OptRecordFile, &Instance.getSourceMgr()),
1267-
std::move(OptRecordFile));
1264+
if (OptRecordFile) {
1265+
auto Output =
1266+
llvm::make_unique<llvm::yaml::Output>(*OptRecordFile,
1267+
&Instance.getSourceMgr());
1268+
SM->setOptRecordStream(std::move(Output), std::move(OptRecordFile));
1269+
}
12681270

12691271
if (performMandatorySILPasses(Invocation, SM.get(), observer))
12701272
return true;

0 commit comments

Comments
 (0)