diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/CodeGen/visibility.c | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/CodeGen/visibility.c')
-rw-r--r-- | clang/test/CodeGen/visibility.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/clang/test/CodeGen/visibility.c b/clang/test/CodeGen/visibility.c new file mode 100644 index 0000000..fa4b599 --- /dev/null +++ b/clang/test/CodeGen/visibility.c @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility default -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT +// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility protected -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-PROTECTED +// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN + +// CHECK-DEFAULT: @g_def = global i32 0 +// CHECK-DEFAULT: @g_com = common global i32 0 +// CHECK-DEFAULT: @g_ext = external global i32 +// CHECK-DEFAULT: @g_deferred = internal global +// CHECK-PROTECTED: @g_def = protected global i32 0 +// CHECK-PROTECTED: @g_com = common protected global i32 0 +// CHECK-PROTECTED: @g_ext = external global i32 +// CHECK-PROTECTED: @g_deferred = internal global +// CHECK-HIDDEN: @g_def = hidden global i32 0 +// CHECK-HIDDEN: @g_com = common hidden global i32 0 +// CHECK-HIDDEN: @g_ext = external global i32 +// CHECK-HIDDEN: @g_deferred = internal global +int g_com; +int g_def = 0; +extern int g_ext; +static char g_deferred[] = "hello"; + +// CHECK-DEFAULT: @test4 = hidden global i32 10 +// CHECK-PROTECTED: @test4 = hidden global i32 10 +// CHECK-HIDDEN: @test4 = hidden global i32 10 + +// CHECK-DEFAULT: define i32 @f_def() +// CHECK-DEFAULT: declare void @f_ext() +// CHECK-DEFAULT: define internal void @f_deferred() +// CHECK-PROTECTED: define protected i32 @f_def() +// CHECK-PROTECTED: declare void @f_ext() +// CHECK-PROTECTED: define internal void @f_deferred() +// CHECK-HIDDEN: define hidden i32 @f_def() +// CHECK-HIDDEN: declare void @f_ext() +// CHECK-HIDDEN: define internal void @f_deferred() + +extern void f_ext(void); + +static void f_deferred(void) { +} + +int f_def(void) { + f_ext(); + f_deferred(); + return g_com + g_def + g_ext + g_deferred[0]; +} + +// PR8457 +// CHECK-DEFAULT: define void @test1( +// CHECK-PROTECTED: define void @test1( +// CHECK-HIDDEN: define void @test1( +struct Test1 { int field; }; +void __attribute__((visibility("default"))) test1(struct Test1 *v) { } + +// rdar://problem/8595231 +// CHECK-DEFAULT: define void @test2() +// CHECK-PROTECTED: define void @test2() +// CHECK-HIDDEN: define void @test2() +void test2(void); +void __attribute__((visibility("default"))) test2(void) {} + +// CHECK-DEFAULT: define hidden void @test3() +// CHECK-PROTECTED: define hidden void @test3() +// CHECK-HIDDEN: define hidden void @test3() +extern void test3(void); +__private_extern__ void test3(void) {} + +// Top of file. +extern int test4; +__private_extern__ int test4 = 10; |