[cfe-commits] [patch] Template instantiation and visibility

Rafael Espíndola rafael.espindola at gmail.com
Sun Apr 22 11:49:37 PDT 2012


Now with the patch :-(


2012/4/22 Rafael Espíndola <rafael.espindola at gmail.com>:
> Given
>
> namespace t1 {
>  template<typename T>
>  class DEFAULT foo {
>    void bar() {}
>  };
>  struct HIDDEN zed {
>  };
>  template class DEFAULT foo<zed>;
> }
> namespace t2 {
>  template<typename T>
>  class DEFAULT foo {
>    void bar() {}
>  };
>  struct HIDDEN zed {
>  };
>  template class foo<zed>;
> }
>
> gcc 4.7 produces a default symbol for the first test and a hidden one
> for the second one. This requires differentiating attributes in a
> template and attributes in an instantiation. Clang currently doesn't
> do that for any attributes, but Jeff tells me that "C++11 just says
> that attributes appertain to particular things, not how they propagate
> from templates to instantiations" so this looks like a valid c++
> extension by gcc.
>
> The attached patch:
>
> * Avoids cloning the visibility attribute during instantiations.
> * Avoids considering visibility info in a template when the
> instantiation has an attribute. This lets us get the first testcase
> right.
> * Goes back to selecting the minimum visibility in cases where we
> should look at the template visibility. This lets us get the second
> testcase right.
>
> The summary is that this fixes cases where where we were being
> unnecessary conservative in producing a default visibility but avoids
> breaking chrome's build.
>
> Cheers,
> Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 4842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120422/bd36b5eb/attachment.obj>


More information about the cfe-commits mailing list