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