mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 18:01:07 +01:00
Fix stack-use-after-scope issue by making LangOptions parameter non temporary (#5586)
The parameter is kept by reference. Added a test that accesses `LangOptions` and crashes without this fix. Part of #5176.
This commit is contained in:
@@ -84,11 +84,11 @@ class CarbonClangDiagnosticConsumer : public clang::DiagnosticConsumer {
|
||||
info.FormatDiagnostic(message);
|
||||
|
||||
RawStringOstream diagnostics_stream;
|
||||
// TODO: Consider allowing setting `LangOptions` or use
|
||||
// `ASTContext::getLangOptions()`.
|
||||
clang::LangOptions lang_options;
|
||||
clang::TextDiagnostic text_diagnostic(
|
||||
diagnostics_stream,
|
||||
// TODO: Consider allowing setting `LangOptions` or use
|
||||
// `ASTContext::getLangOptions()`.
|
||||
clang::LangOptions(),
|
||||
diagnostics_stream, lang_options,
|
||||
// TODO: Consider allowing setting `DiagnosticOptions` or use
|
||||
// `ASTUnit::getDiagnostics().::getLangOptions().getDiagnosticOptions()`.
|
||||
new clang::DiagnosticOptions());
|
||||
|
||||
Reference in New Issue
Block a user