FieldDecl::getParent() not working in Objective C code?

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?

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.