[PATCH] D52674: [AST] Add Obj-C discriminator to MS ABI RTTI

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 4 15:03:13 PDT 2018


smeenai added a comment.

In https://reviews.llvm.org/D52674#1253408, @rjmccall wrote:

> In https://reviews.llvm.org/D52674#1253401, @smeenai wrote:
>
> > Actually, I take that back ... I just misread the stack trace.
> >
> > There are a bunch of hops between the `mangleCXXRTTI` call and the ultimate mangling function:
> >
> >   MicrosoftMangleContextImpl::mangleCXXRTTI(QualType, raw_ostream &)
> >   MicrosoftCXXNameMangler::mangleType(QualType, SourceRange, QualifierMangleMode)
> >   MicrosoftCXXNameMangler::mangleType(const ObjCObjectPointerType *, Qualifiers, SourceRange)
> >   MicrosoftCXXNameMangler::mangleType(QualType, SourceRange, QualifierMangleMode)
> >   MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *, Qualifiers, SourceRange)
> >
> >
> > (the last one will be `ObjCInterfaceType` instead of `ObjCObjectType` if catching anything other than `id`)
> >
> > Threading a `ForRTTI` flag or similar all the way to the final call seems pretty tricky. I can add an optional paramater to `mangleType(QualType, SourceRange, QualifierMangleMode)`, but that function uses a generated switch case <https://reviews.llvm.org/diffusion/L/browse/cfe/trunk/lib/AST/MicrosoftMangle.cpp;343652$1833-1847> to call the specific `mangleType` functions, and I don't know how to special-case certain types in that switch case (to pass the extra parameter along) without doing something super ugly. Adding the extra parameter to every single `mangleType` overload seems highly non-ideal, which is why I was thinking of maintaining some internal state instead.
>
>
> Well, that's why I was talking about how the pointee type of an `ObjCObjectPointerType` is always an `ObjCObjectType` (of which `ObjCInterfaceType` is a subclass) — the implication being that you don't actually have to do the `switch` to dispatch to one of those two cases.


The intermediate `mangleType(QualType, SourceRange, QualifierMangleMode)` calls have a bunch of logic <https://reviews.llvm.org/diffusion/L/browse/cfe/trunk/lib/AST/MicrosoftMangle.cpp;343705$1782-1829> in them; it's not just a direct dispatch to the actual mangling function, so I don't think we can skip over it. I think it's hard to discuss this in the abstract though (and it's also entirely possible I'm missing your point completely), so I'll just actually try out the parameter approach and put up the resulting patch and we can see how it turns out.


Repository:
  rC Clang

https://reviews.llvm.org/D52674





More information about the cfe-commits mailing list