ObjCIvarRefExpr vs. DeclRefExpr


I have stumbled into this curios pattern today: ObjCIvarRefExpr is *not* a subclass of DeclRefExpr.
Does anyone know why is this the case? Anyone against changing this?


ObjCIvarRefExpr should not be a subclass of DeclRefExpr. DeclRefExpr is used to represent cases where a declaration is named directly; ObjCIvarRefExpr, like MemberExpr, is used to represent naming a decaration as a member / ivar of another object.

Perhaps ObjCIvarRefExpr and MemberExpr should have a comnon base class, for member-access-like things, but I can’t recall off-hand any places where that’d really save us much. And you could perhaps make a case that the “member name” portion of a MemberExpr or ObjCIvarRefExpr should be a DeclRefExpr, but at this point that would be a lot of churn for little benefit.

It would be fairly reasonable to make it a subclass of MemberExpr. DeclRefExpr seems inappropriate, though.


Thanks! I’m still trying to wrap my hand around how the inheritance hierarchy works.