Skip to content

Commit b2f7b0a

Browse files
authored
Merge pull request #63882 from rintaro/5.8-clangimporter-rdar105801504
[5.8][ClangImporter] Fix stack-use-after-scope in createClangInvocation
2 parents b9562e1 + cfb693e commit b2f7b0a

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
@@ -1001,11 +1001,11 @@ std::unique_ptr<clang::CompilerInvocation> ClangImporter::createClangInvocation(
10011001
// the diagnostic options here explicitly.
10021002
std::unique_ptr<clang::DiagnosticOptions> clangDiagOpts =
10031003
clang::CreateAndPopulateDiagOpts(invocationArgs);
1004-
ClangDiagnosticConsumer diagClient{importer->Impl, *clangDiagOpts,
1005-
importerOpts.DumpClangDiagnostics};
1004+
auto *diagClient = new ClangDiagnosticConsumer(
1005+
importer->Impl, *clangDiagOpts, importerOpts.DumpClangDiagnostics);
10061006
clangDiags = clang::CompilerInstance::createDiagnostics(
1007-
clangDiagOpts.release(), &diagClient,
1008-
/*owned*/ false);
1007+
clangDiagOpts.release(), diagClient,
1008+
/*owned*/ true);
10091009

10101010
// Finally, use the CC1 command-line and the diagnostic engine
10111011
// to instantiate our Invocation.
@@ -1025,11 +1025,11 @@ std::unique_ptr<clang::CompilerInvocation> ClangImporter::createClangInvocation(
10251025
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> tempDiagOpts{
10261026
new clang::DiagnosticOptions};
10271027

1028-
ClangDiagnosticConsumer tempDiagClient{importer->Impl, *tempDiagOpts,
1029-
importerOpts.DumpClangDiagnostics};
1028+
auto *tempDiagClient = new ClangDiagnosticConsumer(
1029+
importer->Impl, *tempDiagOpts, importerOpts.DumpClangDiagnostics);
10301030
clangDiags = clang::CompilerInstance::createDiagnostics(tempDiagOpts.get(),
1031-
&tempDiagClient,
1032-
/*owned*/ false);
1031+
tempDiagClient,
1032+
/*owned*/ true);
10331033
CI = clang::createInvocationFromCommandLine(invocationArgs, clangDiags, VFS,
10341034
false, CC1Args);
10351035
}

0 commit comments

Comments
 (0)