diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index c81bc0aeeba5c..2af4544f498cf 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -1352,6 +1352,10 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager, m_compiler->setSema(nullptr); adapter->EndSourceFile(); + // Creating persistent variables can trigger diagnostic emission. + // Make sure we reset the manager so we don't get asked to handle + // diagnostics after we finished parsing. + adapter->ResetManager(); unsigned num_errors = adapter->getNumErrors(); @@ -1367,8 +1371,6 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager, type_system_helper->CommitPersistentDecls(); } - adapter->ResetManager(); - return num_errors; }