In C++ interop, stop referring to the diagnostics consumer before deleting it (#5149)

Part of #4666
This commit is contained in:
Boaz Brickner
2025-03-20 18:37:25 +00:00
committed by GitHub
parent a62a8cfd84
commit 3a5e18b1a1
+3
View File
@@ -70,6 +70,9 @@ static auto GenerateAst(Context& context, llvm::StringRef importing_file_path,
"clang-tool", std::make_shared<clang::PCHContainerOperations>(),
clang::tooling::getClangStripDependencyFileAdjuster(),
clang::tooling::FileContentMappings(), &diagnostics_consumer, fs);
// Remove link to the diagnostics consumer before its deletion.
ast->getDiagnostics().setClient(nullptr);
// TODO: Implement and use a DynamicRecursiveASTVisitor to traverse the AST.
int num_errors = diagnostics_consumer.getNumErrors();
int num_warnings = diagnostics_consumer.getNumWarnings();