[PATCH] D56916: Fix crash due to ObjCPropertyDecl
David Goldman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 22 08:10:47 PST 2019
dgoldman updated this revision to Diff 182921.
dgoldman marked an inline comment as done.
dgoldman added a comment.
- use auto
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56916/new/
https://reviews.llvm.org/D56916
Files:
clangd/index/SymbolCollector.cpp
Index: clangd/index/SymbolCollector.cpp
===================================================================
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -369,19 +369,25 @@
if (!ID)
return true;
- const NamedDecl &OriginalDecl = *cast<NamedDecl>(ASTNode.OrigD);
+ // FIXME: ObjCPropertyDecl are not properly indexed here:
+ // - ObjCPropertyDecl may have an OrigD of ObjCPropertyImplDecl, which is
+ // not a NamedDecl.
+ auto *OriginalDecl = dyn_cast<NamedDecl>(ASTNode.OrigD);
+ if (!OriginalDecl)
+ return true;
+
const Symbol *BasicSymbol = Symbols.find(*ID);
if (!BasicSymbol) // Regardless of role, ND is the canonical declaration.
BasicSymbol = addDeclaration(*ND, std::move(*ID));
- else if (isPreferredDeclaration(OriginalDecl, Roles))
+ else if (isPreferredDeclaration(*OriginalDecl, Roles))
// If OriginalDecl is preferred, replace the existing canonical
// declaration (e.g. a class forward declaration). There should be at most
// one duplicate as we expect to see only one preferred declaration per
// TU, because in practice they are definitions.
- BasicSymbol = addDeclaration(OriginalDecl, std::move(*ID));
+ BasicSymbol = addDeclaration(*OriginalDecl, std::move(*ID));
if (Roles & static_cast<unsigned>(index::SymbolRole::Definition))
- addDefinition(OriginalDecl, *BasicSymbol);
+ addDefinition(*OriginalDecl, *BasicSymbol);
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56916.182921.patch
Type: text/x-patch
Size: 1465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190122/4e4d3ba6/attachment.bin>
More information about the cfe-commits
mailing list