[clang-tools-extra] r336252 - [clangd] Avoid collecting symbols from broken TUs in global-symbol-builder.

Eric Liu via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 4 02:43:35 PDT 2018


Author: ioeric
Date: Wed Jul  4 02:43:35 2018
New Revision: 336252

URL: http://llvm.org/viewvc/llvm-project?rev=336252&view=rev
Log:
[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

Modified:
    clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp

Modified: clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=336252&r1=336251&r2=336252&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp Wed Jul  4 02:43:35 2018
@@ -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));




More information about the cfe-commits mailing list