visibility.cpp
1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// REQUIRES: x86-registered-target
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
// RUN: -fvisibility hidden %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
// RUN: -fvisibility hidden %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | \
// RUN: FileCheck --check-prefix=CHECK-CMD %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | \
// RUN: FileCheck --check-prefix=CHECK-CMD %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | \
// RUN: FileCheck --check-prefix=CHECK-CMD2 %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -o - -emit-interface-stubs %s | \
// RUN: FileCheck --check-prefix=CHECK-CMD2 %s
// RUN: %clang -target x86_64-unknown-linux-gnu -o - -c %s | llvm-readelf -s - 2>&1 | \
// RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
// Always Be Hidden:
// CHECK-CMD-HIDDEN-NOT: _Z6hiddenv
// CHECK-CMD2-NOT: _Z6hiddenv
__attribute__((visibility("hidden"))) void hidden() {}
// Always Be Visible:
// CHECK-CMD-HIDDEN: _Z9nothiddenv
// CHECK-CMD-DAG: _Z9nothiddenv
__attribute__((visibility("default"))) void nothidden() {}
// Do Whatever -fvisibility says:
// CHECK-CMD-HIDDEN-NOT: _Z10cmdVisiblev
// CHECK-CMD-DAG: _Z10cmdVisiblev
void cmdVisible() {}
// CHECK-SYMBOLS-DAG: DEFAULT {{.*}} _Z10cmdVisiblev
// CHECK-SYMBOLS-DAG: HIDDEN {{.*}} _Z6hiddenv
// CHECK-SYMBOLS-DAG: DEFAULT {{.*}} _Z9nothiddenv