This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Annotate template methods with visibility
AbandonedPublic

Authored by smeenai on Dec 5 2016, 3:09 PM.

Details

Summary

D25208 switches _LIBCPP_TYPE_VIS to expand to default visibility
instead of default type visibility, in order to ease building libc++
with hidden visibility. With that change made, any template methods of a
class marked _LIBCPP_TYPE_VIS will also get default visibility when
implicitly instantiated, which is not desirable for clients of libc++
headers who wish to control their visibility; a similar issue led to
PR30642. Annotate all problematic methods with an explicit visibility
specifier in order to avoid this issue.

The problematic methods were found by applying D25208 and then running
https://github.com/smeenai/bad-visibility-finder. The small methods were
marked for inlining; the larger ones marked hidden.

Event Timeline

smeenai updated this revision to Diff 80333.Dec 5 2016, 3:09 PM
smeenai retitled this revision from to [libc++] Annotate template methods with visibility.
smeenai updated this object.
smeenai added reviewers: EricWF, mclow.lists.
smeenai added subscribers: cfe-commits, thakis.
smeenai planned changes to this revision.Dec 12 2016, 6:04 PM

Hidden visibility also requires extern template declarations to expand to default visibility (as opposed to just default type visibility) to be feasible. Will fix annotations there and add those to this diff.

smeenai requested a review of this revision.Dec 19 2016, 7:54 PM

I think this actually stands well on its own. I'll do the extern template annotations in a different diff.

Also, ping :)

EricWF edited edge metadata.Dec 29 2016, 9:38 PM

Please put these attributes to the first declaration instead of the definition.

include/thread
392

We really should hide this using inline _LIBCPP_INLINE_VISIBILITY because it's a special C++03 symbol, so we don't even want a hidden definition omitted ideally.

Please put these attributes to the first declaration instead of the definition.

Sounds good to me for _LIBCPP_HIDDEN, but as far as I understand, for the inline _LIBCPP_INLINE_VISIBILITY cases, at least the inline needs to be at the definition itself, otherwise it won't have any effect. For those, do you want to keep the _LIBCPP_INLINE_VISIBILITY at the declaration and the inline at the definition?

include/thread
392

Will do.

Sounds good to me for _LIBCPP_HIDDEN, but as far as I understand, for the inline _LIBCPP_INLINE_VISIBILITY cases, at least the inline needs to be at the definition itself, otherwise it won't have any effect.

Err this might actually have just been me being stupid. Lemme confirm that first.

Sounds good to me for _LIBCPP_HIDDEN, but as far as I understand, for the inline _LIBCPP_INLINE_VISIBILITY cases, at least the inline needs to be at the definition itself, otherwise it won't have any effect.

Err this might actually have just been me being stupid. Lemme confirm that first.

Yup, I'm dumb; ignore me. I'll move everything to the declarations.

smeenai abandoned this revision.Jan 25 2017, 3:07 PM

Folded into D25208