https://bugs.llvm.org/show_bug.cgi?id=36810

            Bug ID: 36810
           Summary: c++ visibility for specialization is not correct
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: steve...@apple.com
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org

Here is a reproducer:

$ cat test.ii

namespace std {
template <class>
class __attribute__((__type_visibility__("default"))) shared_ptr {
  template <class> friend class shared_ptr;
};
} // namespace std
struct dict;
std::shared_ptr<dict> g; // comment out this line will change the visibility
for foo
class __attribute__((visibility("default"))) Bar;
template <class = std::shared_ptr<Bar>>
class __attribute__((visibility("default"))) i {
  std::shared_ptr<int> foo() const;
};
template <> std::shared_ptr<int> i<>::foo() const {
  return std::shared_ptr<int>();
}

$ clang -x c++ -fvisibility=hidden test.ii -emit-llvm -S -o test.ll && grep foo
test.ll
define hidden void @_ZNK1iISt10shared_ptrI3BarEE3fooEv(%class.i* %this)

After commenting out the declaration for 'g':
define void @_ZNK1iISt10shared_ptrI3BarEE3fooEv(%class.i* %this)

It seems that when LinkageComputer try to compute the visibility for foo(), it
try to get the TemplateDecl specialized by shared_ptr<Bar>, it gets the
TemplateDecl for friend class shared_ptr which doesn't have type_visibility.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to