[cfe-dev] typeinfo visibility for pointer to incomplete type

Douwe Gelling via cfe-dev cfe-dev at lists.llvm.org
Sun Jan 22 05:52:38 PST 2017


I've reproduced it both on the system clang:

Apple LLVM version 8.0.0 (clang-800.0.42.1)

and on a newer clang installed with homebrew:

clang version 3.9.1 (tags/RELEASE_391/final)
Target: x86_64-apple-darwin16.3.0

In llvm ir, it's marked internal constant with both compilers as well

On Fri, Jan 20, 2017 at 6:23 PM Vedant Kumar <vsk at apple.com> wrote:

> What version of clang are you using?
>
> I tried referring to the typeid of SomeClass* from two different
> compilation
> units and ended up with just one copy of __ZTSP9SomeClass in my binary. The
> symbol is marked as 'linkonce_odr constant' in LLVM IR, which checks out.
>
> $ nm -m t | grep ZTSP9SomeClass
> 0000000100001f60 (__TEXT,__const) weak external __ZTSP9SomeClass
>
> best,
> vedant
>
> > On Jan 20, 2017, at 5:15 AM, Douwe Gelling via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
> >
> > Hi all,
> >
> > When taking the typeinfo of a pointer to incomplete type, clang++ emits
> type info for the pointer in the resulting binary, but makes that typeinfo
> non-external (on osx at least). Is this intended? I'd have expected it to
> be weak external so that when the type is defined in other compilation
> units, the typeinfo isn't defined multiple times.
> >
> > sample code:
> >
> > #include <typeinfo>
> > #include <iostream>
> > class SomeClass;
> >
> > int main()
> > {
> >   std::cout << typeid(SomeClass*).name() << std::endl;
> > }
> >
> > when running nm -m on the resulting binary, it contains:
> >
> > 0000000000000414 (__TEXT,__const) non-external __ZTSP9SomeClass
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170122/e4c13c4d/attachment.html>


More information about the cfe-dev mailing list