[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / visibility.c
blobee760ec77879e7ab644b68b3569bdc563a7adc41
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
5 // CHECK-DEFAULT: @g_def ={{.*}} global i32 0
6 // CHECK-DEFAULT: @g_com ={{.*}} 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 = 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 = 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";
22 // CHECK-DEFAULT: @test4 = hidden global i32 10
23 // CHECK-PROTECTED: @test4 = hidden global i32 10
24 // CHECK-HIDDEN: @test4 = hidden global i32 10
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()
36 extern void f_ext(void);
38 static void f_deferred(void) {
41 int f_def(void) {
42 f_ext();
43 f_deferred();
44 return g_com + g_def + g_ext + g_deferred[0];
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; };
52 void __attribute__((visibility("default"))) test1(struct Test1 *v) { }
54 // CHECK-DEFAULT-LABEL: define{{.*}} void @test2()
55 // CHECK-PROTECTED-LABEL: define{{.*}} void @test2()
56 // CHECK-HIDDEN-LABEL: define{{.*}} void @test2()
57 void test2(void);
58 void __attribute__((visibility("default"))) test2(void) {}
60 // CHECK-DEFAULT-LABEL: define hidden void @test3()
61 // CHECK-PROTECTED-LABEL: define hidden void @test3()
62 // CHECK-HIDDEN-LABEL: define hidden void @test3()
63 extern void test3(void);
64 __private_extern__ void test3(void) {}
66 // Top of file.
67 extern int test4;
68 __private_extern__ int test4 = 10;
70 // CHECK-DEFAULT-LABEL: define hidden void @test5()
71 // CHECK-PROTECTED-LABEL: define hidden void @test5()
72 // CHECK-HIDDEN-LABEL: define hidden void @test5()
73 __attribute__((availability(macosx,introduced=10.5,deprecated=10.6)))
74 __private_extern__ void test5(void) {}