[PATCH] D56916: Fix crash due to ObjCPropertyDecl

David Goldman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 18 08:46:55 PST 2019


dgoldman created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, ioeric, ilya-biryukov.

With ObjCPropertyDecl, ASTNode.OrigD can be a ObjCPropertyImplDecl
which is not a NamedDecl, leading to a crash since the code
incorrectly assumes ASTNode.OrigD will always be a NamedDecl.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56916

Files:
  clangd/index/SymbolCollector.cpp


Index: clangd/index/SymbolCollector.cpp
===================================================================
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -369,6 +369,10 @@
   if (!ID)
     return true;
 
+  // ObjCPropertyDecl may have an OrigD of ObjCPropertyImplDecl, which is
+  // not a NamedDecl.
+  if (!isa<NamedDecl>(ASTNode.OrigD))
+    return true;
   const NamedDecl &OriginalDecl = *cast<NamedDecl>(ASTNode.OrigD);
   const Symbol *BasicSymbol = Symbols.find(*ID);
   if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56916.182531.patch
Type: text/x-patch
Size: 585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190118/5c8d75f3/attachment.bin>


More information about the cfe-commits mailing list