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

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 3 07:03:16 PDT 2018


ioeric created this revision.
ioeric added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, jkorous, MaskRay.

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


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D48881

Files:
  clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp


Index: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
===================================================================
--- clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
+++ clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
@@ -82,6 +82,14 @@
       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));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48881.153910.patch
Type: text/x-patch
Size: 839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180703/10dbd9ae/attachment-0001.bin>


More information about the cfe-commits mailing list