[cfe-commits] [patch][3.2] Visibility cleanup and fixes

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Apr 17 21:27:40 PDT 2012


3.1 branched and so should this thread :-)

These are the proposed changes for 3.2, we can then discuss what
should be ported to 3.1. I have split the previous patch in two mostly
to make it easier to review. The first one is just a reorganization
that should be a nop with the current definition of mergeVisibility
and mergeVisibilityWithMin.  The second patch changes those functions
and remove old workarounds from Decl.cpp. With the second patch, the
visible changes are

* We give precedence to attributes in a decl, and produce a default symbol in

struct HIDDEN RECT {
  int top;
};
DEFAULT RECT data_rect = {0};

* In a similar way, the attribute in the method bar wins in both A<H>
and A<D> in the following cases:

   template <class T> struct HIDDEN A {
     static void DEFAULT bar();
   };
   struct HIDDEN H;
   struct DEFAULT D;

Currently clang produces a default symbol for A<D> and a hidden one
for A<H>. gcc 4.7 has the same problem:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52995.

Lastly, the patch also fixes mergeWithMinVisibility to be just that.
It is now only used for merging type parameters in templates, and in
this case we do want to make the type resulting from the template
instantiation hidden if any of the arguments are. For example, if
using -fvisibility=hidden we produce a hidden zed in

template<typename T>
class DEFAULT bar {
  void zed() {}
};
struct zed { };
template class bar<zed>;

In this we now agree with gcc 4.7

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: refactor.patch
Type: application/octet-stream
Size: 5277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120418/f1881b63/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fixes.patch
Type: application/octet-stream
Size: 6510 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120418/f1881b63/attachment-0001.obj>


More information about the cfe-commits mailing list