From c72c57c9e9b69944e3e009cd5e209634839581d3 Mon Sep 17 00:00:00 2001 From: dim Date: Mon, 8 Apr 2013 18:45:10 +0000 Subject: Vendor import of clang trunk r178860: http://llvm.org/svn/llvm-project/cfe/trunk@178860 --- test/CodeGenCXX/visibility.cpp | 217 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 191 insertions(+), 26 deletions(-) (limited to 'test/CodeGenCXX/visibility.cpp') diff --git a/test/CodeGenCXX/visibility.cpp b/test/CodeGenCXX/visibility.cpp index 0145039..87add44 100644 --- a/test/CodeGenCXX/visibility.cpp +++ b/test/CodeGenCXX/visibility.cpp @@ -47,7 +47,7 @@ namespace test29 { struct RECT { int top; }; - __attribute__ ((visibility ("default"))) extern RECT data_rect; + DEFAULT extern RECT data_rect; RECT data_rect = { -1}; #pragma GCC visibility pop // CHECK: @_ZN6test299data_rectE = global @@ -70,7 +70,7 @@ namespace test41 { // Unlike gcc we propagate the information that foo not only is hidden, but // has been explicitly marked as so. This lets us produce a hidden undefined // reference to bar. - struct __attribute__((visibility("hidden"))) foo {}; + struct HIDDEN foo {}; extern foo bar; foo *zed() { return &bar; @@ -119,7 +119,7 @@ namespace test48 { namespace test27 { template class C { - class __attribute__((visibility("default"))) D { + class DEFAULT D { void f(); }; }; @@ -526,7 +526,7 @@ namespace Test20 { namespace test21 { enum En { en }; template struct A { - __attribute__((visibility("default"))) void foo() {} + DEFAULT void foo() {} }; // CHECK: define weak_odr void @_ZN6test211AILNS_2EnE0EE3fooEv( @@ -580,9 +580,7 @@ namespace PR10113 { }; template class foo::bar; // CHECK: define weak_odr void @_ZN7PR101133foo3barINS_3zedEE3zedEv - - // FIXME: This should be hidden as zed is hidden. - // CHECK-HIDDEN: define weak_odr void @_ZN7PR101133foo3barINS_3zedEE3zedEv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN7PR101133foo3barINS_3zedEE3zedEv } namespace PR11690 { @@ -613,9 +611,7 @@ namespace PR11690_2 { }; template class foo::zed; // CHECK: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv - - // FIXME: This should be hidden as baz is hidden. - // CHECK-HIDDEN: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv } namespace test23 { @@ -670,7 +666,7 @@ namespace test24 { namespace test26 { template class C { - __attribute__((visibility("default"))) void f(); + DEFAULT void f(); }; template<> @@ -729,10 +725,10 @@ namespace test34 { namespace test35 { // This is a really ugly testcase. GCC propagates the DEFAULT in zed's - // definition. What we do instead is be conservative about merging - // implicit visibilities. - // FIXME: Maybe the best thing to do here is error? The test at least - // makes sure we don't produce a hidden symbol for foo::bar. + // definition. It's not really clear what we can do here, because we + // produce the symbols before even seeing the DEFAULT definition of zed. + // FIXME: Maybe the best thing to do here is error? It's certainly hard + // to argue that this ought to be valid. template struct DEFAULT foo { void bar() {} @@ -742,7 +738,7 @@ namespace test35 { class DEFAULT zed { }; // CHECK: define weak_odr void @_ZN6test353fooINS_3zedEE3barEv - // CHECK-HIDDEN: define weak_odr void @_ZN6test353fooINS_3zedEE3barEv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test353fooINS_3zedEE3barEv } namespace test36 { @@ -821,8 +817,8 @@ namespace test42 { }; void bar::zed() { } - // CHECK: define hidden void @_ZN6test423barINS_3fooEE3zedEv - // CHECK-HIDDEN: define hidden void @_ZN6test423barINS_3fooEE3zedEv + // CHECK: define void @_ZN6test423barINS_3fooEE3zedEv + // CHECK-HIDDEN: define void @_ZN6test423barINS_3fooEE3zedEv } namespace test43 { @@ -834,8 +830,8 @@ namespace test43 { template <> DEFAULT void bar() { } - // CHECK: define hidden void @_ZN6test433barINS_3fooEEEvv - // CHECK-HIDDEN: define hidden void @_ZN6test433barINS_3fooEEEvv + // CHECK: define void @_ZN6test433barINS_3fooEEEvv + // CHECK-HIDDEN: define void @_ZN6test433barINS_3fooEEEvv } namespace test44 { @@ -893,7 +889,7 @@ namespace test47 { namespace { struct zed; } - template __attribute__((visibility("default"))) void foo::bar(); + template DEFAULT void foo::bar(); void baz() { foo::bar(); } @@ -1021,7 +1017,7 @@ namespace test54 { namespace test55 { template - struct __attribute__((visibility("hidden"))) foo { + struct HIDDEN foo { static void bar(); }; template struct foo; @@ -1035,7 +1031,7 @@ namespace test55 { namespace test56 { template struct foo; template - struct __attribute__((visibility("hidden"))) foo { + struct HIDDEN foo { static void bar(); }; void foobar() { @@ -1066,7 +1062,7 @@ namespace test58 { #pragma GCC visibility push(hidden) struct foo; template - struct __attribute__((visibility("default"))) bar { + struct DEFAULT bar { static void zed() { } }; @@ -1097,9 +1093,9 @@ namespace test59 { namespace test60 { template - class __attribute__((visibility("hidden"))) a {}; + class HIDDEN a {}; template - class __attribute__((visibility("default"))) b {}; + class DEFAULT b {}; template class x, template class y> void test() {} void use() { @@ -1112,3 +1108,172 @@ namespace test60 { // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test604testINS_1bENS_1aEEEvv } } + +namespace test61 { + template + struct Class1 + { + void f1() { f2(); } + inline void f2(); + }; + template<> + inline void Class1::f2() + { + } + void g(Class1 *x) { + x->f1(); + } +} +namespace test61 { + // Just test that we don't crash. Currently we apply this attribute. Current + // gcc issues a warning about it being unused since "the type is already + // defined". We should probably do the same. + template class HIDDEN Class1; +} + +namespace test62 { + template + struct Class1 + { + void f1() { f2(); } + inline void f2() {} + }; + template<> + inline void Class1::f2() + { + } + void g(Class1 *x) { + x->f2(); + } +} +namespace test62 { + template class HIDDEN Class1; + // Just test that we don't crash. Currently we apply this attribute. Current + // gcc issues a warning about it being unused since "the type is already + // defined". We should probably do the same. +} + +namespace test63 { + enum HIDDEN E { E0 }; + struct A { + template static void foo() {} + + template struct B { + static void foo() {} + }; + }; + + void test() { + A::foo(); + A::B::foo(); + } + // CHECK: define linkonce_odr hidden void @_ZN6test631A3fooILNS_1EE0EEEvv() + // CHECK: define linkonce_odr hidden void @_ZN6test631A1BILNS_1EE0EE3fooEv() +} + +// Don't ignore the visibility of template arguments just because we +// explicitly instantiated something. +namespace test64 { + struct HIDDEN A {}; + template struct B { + static DEFAULT void foo() {} + }; + + template class B; + // CHECK: define weak_odr hidden void @_ZN6test641BINS_1AEE3fooEv() +} + +namespace test65 { + class HIDDEN A {}; + template struct B { + static void func(); + template static void funcT1(); + template static void funcT2(); + class Inner {}; + template class InnerT {}; + }; + template