[cfe-dev] FieldDecl::getParent() not working in Objective C code?

Reid Kleckner rnk at google.com
Tue Apr 28 13:22:36 PDT 2015


Sounds like an obj-c bug. The FieldDecl is probably actually an
ObjCIvarDecl, and you probably want to use getContainingInterface() instead
if it is. ObjCInterfaceDecl don't inherit from RecordDecl, so getParent()
can't work as written.


On Tue, Apr 28, 2015 at 9:21 AM, Stephan Bergmann <sbergman at redhat.com>
wrote:

> At least on recent trunk, FieldDecl::getParent() does
>
>   return cast<RecordDecl>(getDeclContext());
>
> and I noticed some plugin calling it crashing with a failed assertion
>
>   (isa<X>(Val) && "cast<Ty>() argument of incompatible type!")
>
> when getDeclContext() happened to be an ObjCInterfaceDecl.
>
> Is FieldDecl::getParent() known to only be callable under certain
> circumstances (i.e., the plugin broken), or is something else broken?
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150428/84171513/attachment.html>


More information about the cfe-dev mailing list