[clangd] Avoid collecting symbols from broken TUs in global-symbol-builder.

Summary:
For example, template parameter might not be resolved in a broken TU,
which can result in wrong USR/SymbolID.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, cfe-commits

Differential Revision: https://reviews.llvm.org/D48881

llvm-svn: 336252
This commit is contained in:
Eric Liu 2018-07-04 09:43:35 +00:00
parent 98a7a31d1e
commit bd225cff89

View File

@ -82,6 +82,14 @@ public:
void EndSourceFileAction() override {
WrapperFrontendAction::EndSourceFileAction();
const auto &CI = getCompilerInstance();
if (CI.hasDiagnostics() &&
(CI.getDiagnosticClient().getNumErrors() > 0)) {
llvm::errs() << "Found errors in the translation unit. Igoring "
"collected symbols...\n";
return;
}
auto Symbols = Collector->takeSymbols();
for (const auto &Sym : Symbols) {
Ctx->reportResult(Sym.ID.str(), SymbolToYAML(Sym));