[AST] Fix an assertion violation in FieldDecl::getParent.
Summary: FieldDecl::getParent assumes that the FiledDecl::getDeclContext returns a RecordDecl, this is true for C/C++, but not for ObjCIvarDecl: The Decls hierarchy is like following FieldDecl <-- ObjCIvarDecl DeclContext <-- ObjCContainerDecl <-- ObjCInterfaceDecl ^ |----- TagDecl <-- RecordDecl calling getParent() on ObjCIvarDecl will: 1. invoke getDeclContext(), which returns a DeclContext*, which points to an ObjCInterfaceDecl; 2. then downcast the "DeclContext" pointer to a RecordDecl*, and we will hit the "is_a<RecordDecl>" assertion in llvm::cast (undefined behavior in release build without assertion enabled); Fixes https://github.com/clangd/clangd/issues/369 Reviewers: sammccall Reviewed By: sammccall Subscribers: rsmith, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D79627
Loading
Please register or sign in to comment