[cfe-dev] Question about class names

Reid Kleckner rnk at google.com
Thu Nov 7 11:30:17 PST 2013


I'm not sure.  We should add some way to do this if we don't like the
status quo.  I recall Manman used mangleCXXRTTI for debug info.  We could
expose mangleType() somehow instead.


On Thu, Nov 7, 2013 at 2:17 AM, Timur Iskhodzhanov <timurrrr at google.com>wrote:

> 2013/11/6 Reid Kleckner <rnk at google.com>:
> > The C++ name mangler already knows how to compute a unique string per
> class.
>
> How do you suggest to do that?
> It hits an assertion if I try to use mangleName/mangleCXXName to mangle a
> RD.
>
> > If you want a pretty string, probably the best way to get that is to
> mangle
> > a string and then demangle it.
> >
> >
> > On Wed, Nov 6, 2013 at 3:34 AM, Jesper Eskilson <jesper.eskilson at iar.com
> >
> > wrote:
> >>
> >>
> >> Hi,
> >>
> >> I'm trying to find a way to construct a string which uniquely identify a
> >> class such that different template instantiations yields a different
> string.
> >> Say thay I have a class template A:
> >>
> >> template<class T> class A;
> >> A *a = new A<int>();
> >>
> >> then if I start from the CXXConstructExpr:
> >>
> >> ctorExpr->getConstructor()->getQualifiedNameAsString()
> >>
> >> it will get be "A<int>::A".
> >>
> >> But say that I have another class B which inherits from A:
> >>
> >> class B : public A<int> {
> >> };
> >>
> >> B *b = new B;
> >>
> >> How do I find out how A is templatized? Ideally I would like to get out
> a
> >> string such as "A<int>", but the closest I get is to do
> >>
> >> CXXBaseSpecifier base = ;
> >> base.getType()->getAsCXXRecordDecl()->getQualifiedNameAsString();
> >>
> >> but this will only give me "A". How do I find out the template
> parameters
> >> used when instantiating A?
> >>
> >> --
> >> *Jesper Eskilson* /Development Engineer/
> >> IAR Systems AB
> >> Box 23051, Strandbodgatan 1
> >> SE-750 23 Uppsala, SWEDEN
> >> E-mail: jesper.eskilson at iar.com <mailto:jesper.eskilson at iar.com>
> >> Website: www.iar.com
> >> <http://www.iar.com> Twitter: www.twitter.com/iarsystems
> >> <http://www.twitter.com/iarsystems>
> >> _______________________________________________
> >> cfe-dev mailing list
> >> cfe-dev at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> >
> >
> >
> > _______________________________________________
> > 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/20131107/45a7c442/attachment.html>


More information about the cfe-dev mailing list