• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility default -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT
2 // RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility protected -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-PROTECTED
3 // RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
4 
5 // CHECK-DEFAULT: @g_def = global i32 0
6 // CHECK-DEFAULT: @g_com = common global i32 0
7 // CHECK-DEFAULT: @g_ext = external global i32
8 // CHECK-DEFAULT: @g_deferred = internal global
9 // CHECK-PROTECTED: @g_def = protected global i32 0
10 // CHECK-PROTECTED: @g_com = common protected global i32 0
11 // CHECK-PROTECTED: @g_ext = external global i32
12 // CHECK-PROTECTED: @g_deferred = internal global
13 // CHECK-HIDDEN: @g_def = hidden global i32 0
14 // CHECK-HIDDEN: @g_com = common hidden global i32 0
15 // CHECK-HIDDEN: @g_ext = external global i32
16 // CHECK-HIDDEN: @g_deferred = internal global
17 int g_com;
18 int g_def = 0;
19 extern int g_ext;
20 static char g_deferred[] = "hello";
21 
22 // CHECK-DEFAULT: @test4 = hidden global i32 10
23 // CHECK-PROTECTED: @test4 = hidden global i32 10
24 // CHECK-HIDDEN: @test4 = hidden global i32 10
25 
26 // CHECK-DEFAULT-LABEL: define i32 @f_def()
27 // CHECK-DEFAULT: declare void @f_ext()
28 // CHECK-DEFAULT-LABEL: define internal void @f_deferred()
29 // CHECK-PROTECTED-LABEL: define protected i32 @f_def()
30 // CHECK-PROTECTED: declare void @f_ext()
31 // CHECK-PROTECTED-LABEL: define internal void @f_deferred()
32 // CHECK-HIDDEN-LABEL: define hidden i32 @f_def()
33 // CHECK-HIDDEN: declare void @f_ext()
34 // CHECK-HIDDEN-LABEL: define internal void @f_deferred()
35 
36 extern void f_ext(void);
37 
f_deferred(void)38 static void f_deferred(void) {
39 }
40 
f_def(void)41 int f_def(void) {
42   f_ext();
43   f_deferred();
44   return g_com + g_def + g_ext + g_deferred[0];
45 }
46 
47 // PR8457
48 // CHECK-DEFAULT-LABEL: define void @test1(
49 // CHECK-PROTECTED-LABEL: define void @test1(
50 // CHECK-HIDDEN-LABEL: define void @test1(
51 struct Test1 { int field; };
test1(struct Test1 * v)52 void  __attribute__((visibility("default"))) test1(struct Test1 *v) { }
53 
54 // rdar://problem/8595231
55 // CHECK-DEFAULT-LABEL: define void @test2()
56 // CHECK-PROTECTED-LABEL: define void @test2()
57 // CHECK-HIDDEN-LABEL: define void @test2()
58 void test2(void);
test2(void)59 void __attribute__((visibility("default"))) test2(void) {}
60 
61 // CHECK-DEFAULT-LABEL: define hidden void @test3()
62 // CHECK-PROTECTED-LABEL: define hidden void @test3()
63 // CHECK-HIDDEN-LABEL: define hidden void @test3()
64 extern void test3(void);
test3(void)65 __private_extern__ void test3(void) {}
66 
67 // Top of file.
68 extern int test4;
69 __private_extern__ int test4 = 10;
70 
71 // rdar://12399248
72 // CHECK-DEFAULT-LABEL: define hidden void @test5()
73 // CHECK-PROTECTED-LABEL: define hidden void @test5()
74 // CHECK-HIDDEN-LABEL: define hidden void @test5()
75 __attribute__((availability(macosx,introduced=10.5,deprecated=10.6)))
test5(void)76 __private_extern__ void test5(void) {}
77