Skip to content

[ClangImporter] Fix stack-use-after-scope in createClangInvocation #63881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,11 +995,11 @@ std::unique_ptr<clang::CompilerInvocation> ClangImporter::createClangInvocation(
// the diagnostic options here explicitly.
std::unique_ptr<clang::DiagnosticOptions> clangDiagOpts =
clang::CreateAndPopulateDiagOpts(invocationArgs);
ClangDiagnosticConsumer diagClient{importer->Impl, *clangDiagOpts,
importerOpts.DumpClangDiagnostics};
auto *diagClient = new ClangDiagnosticConsumer(
importer->Impl, *clangDiagOpts, importerOpts.DumpClangDiagnostics);
clangDiags = clang::CompilerInstance::createDiagnostics(
clangDiagOpts.release(), &diagClient,
/*owned*/ false);
clangDiagOpts.release(), diagClient,
/*owned*/ true);

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

ClangDiagnosticConsumer tempDiagClient{importer->Impl, *tempDiagOpts,
importerOpts.DumpClangDiagnostics};
auto *tempDiagClient = new ClangDiagnosticConsumer(
importer->Impl, *tempDiagOpts, importerOpts.DumpClangDiagnostics);
clangDiags = clang::CompilerInstance::createDiagnostics(tempDiagOpts.get(),
&tempDiagClient,
/*owned*/ false);
tempDiagClient,
/*owned*/ true);
CI = clang::createInvocationFromCommandLine(invocationArgs, clangDiags, VFS,
false, CC1Args);
}
Expand Down