Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Clang's 'type_visibility' attribute do, and when should one use it?

It is used in libc++ on many template types such as tuple_element, tuple, etc.

As far as I can tell there is no public documentation of what it does other than the commit message introducing it and this unit test in the clang project.

like image 932
Adam Midvidy Avatar asked Feb 10 '15 17:02

Adam Midvidy


1 Answers

This attribute allows the ELF visibility of a type and (presumably) its vague linkage objects (vtable, typeinfos) to be controlled separately from the visibility of functions and data members of the type.

This allows typeinfos and the vtable for, say, explicit instantiations of a templated polymorphic type to be located centrally without forcing default visibility on for the type's private static data members as well -- exporting symbols for things that nobody will ever actually access across a library boundary is wasteful of runtime and symbol table space when working with shared libraries.

like image 120
LThode Avatar answered Nov 19 '22 04:11

LThode