Skip to content

Commit 6a5c0d0

Browse files
authored
Merge pull request swiftlang#63881 from rintaro/clangimporter-rdar105801504
[ClangImporter] Fix stack-use-after-scope in createClangInvocation
2 parents 27c1d49 + 1f3d671 commit 6a5c0d0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -995,11 +995,11 @@ std::unique_ptr<clang::CompilerInvocation> ClangImporter::createClangInvocation(
995995
// the diagnostic options here explicitly.
996996
std::unique_ptr<clang::DiagnosticOptions> clangDiagOpts =
997997
clang::CreateAndPopulateDiagOpts(invocationArgs);
998-
ClangDiagnosticConsumer diagClient{importer->Impl, *clangDiagOpts,
999-
importerOpts.DumpClangDiagnostics};
998+
auto *diagClient = new ClangDiagnosticConsumer(
999+
importer->Impl, *clangDiagOpts, importerOpts.DumpClangDiagnostics);
10001000
clangDiags = clang::CompilerInstance::createDiagnostics(
1001-
clangDiagOpts.release(), &diagClient,
1002-
/*owned*/ false);
1001+
clangDiagOpts.release(), diagClient,
1002+
/*owned*/ true);
10031003

10041004
// Finally, use the CC1 command-line and the diagnostic engine
10051005
// to instantiate our Invocation.
@@ -1019,11 +1019,11 @@ std::unique_ptr<clang::CompilerInvocation> ClangImporter::createClangInvocation(
10191019
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> tempDiagOpts{
10201020
new clang::DiagnosticOptions};
10211021

1022-
ClangDiagnosticConsumer tempDiagClient{importer->Impl, *tempDiagOpts,
1023-
importerOpts.DumpClangDiagnostics};
1022+
auto *tempDiagClient = new ClangDiagnosticConsumer(
1023+
importer->Impl, *tempDiagOpts, importerOpts.DumpClangDiagnostics);
10241024
clangDiags = clang::CompilerInstance::createDiagnostics(tempDiagOpts.get(),
1025-
&tempDiagClient,
1026-
/*owned*/ false);
1025+
tempDiagClient,
1026+
/*owned*/ true);
10271027
CI = clang::createInvocationFromCommandLine(invocationArgs, clangDiags, VFS,
10281028
false, CC1Args);
10291029
}

0 commit comments

Comments
 (0)