brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.2 KiB · eecdb4e Raw
137 lines · cpp
1// REQUIRES: x86-registered-target2 3//// Test that -fvisibility-from-dllstorageclass maps DLL storage class to visibility4//// and that it overrides the effect of visibility options and annotations.5 6// RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \7// RUN:     -fvisibility=hidden \8// RUN:     -fapply-global-visibility-to-externs \9// RUN:     -fvisibility-from-dllstorageclass \10// RUN:     -x c++ %s -emit-llvm -o - | \11// RUN:   FileCheck %s --check-prefixes=DEFAULTS12 13// RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \14// RUN:     -fvisibility=hidden \15// RUN:     -fapply-global-visibility-to-externs \16// RUN:     -fvisibility-from-dllstorageclass \17// RUN:     -fvisibility-dllexport=hidden \18// RUN:     -fvisibility-nodllstorageclass=protected \19// RUN:     -fvisibility-externs-dllimport=hidden \20// RUN:     -fvisibility-externs-nodllstorageclass=protected \21// RUN:     -x c++  %s -emit-llvm -o - | \22// RUN:   FileCheck %s --check-prefixes=EXPLICIT23 24// RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \25// RUN:     -fvisibility=hidden \26// RUN:     -fapply-global-visibility-to-externs \27// RUN:     -fvisibility-from-dllstorageclass \28// RUN:     -fvisibility-dllexport=default \29// RUN:     -fvisibility-nodllstorageclass=default \30// RUN:     -fvisibility-externs-dllimport=default \31// RUN:     -fvisibility-externs-nodllstorageclass=default \32// RUN:     -x c++  %s -emit-llvm -o - | \33// RUN:   FileCheck %s --check-prefixes=ALL_DEFAULT34 35// RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \36// RUN:     -fvisibility=hidden \37// RUN:     -fapply-global-visibility-to-externs \38// RUN:     -fvisibility-from-dllstorageclass \39// RUN:     -fvisibility-dllexport=keep \40// RUN:     -fvisibility-nodllstorageclass=keep \41// RUN:     -fvisibility-externs-dllimport=keep \42// RUN:     -fvisibility-externs-nodllstorageclass=keep \43// RUN:     -x c++  %s -emit-llvm -o - | \44// RUN:   FileCheck %s --check-prefixes=ALL_KEEP45 46// Local47static void l() {}48void use_locals(){l();}49// DEFAULTS-DAG: define internal void @_ZL1lv()50// EXPLICIT-DAG: define internal void @_ZL1lv()51// ALL_DEFAULT-DAG: define internal void @_ZL1lv()52// ALL_KEEP-DAG: define internal void @_ZL1lv()53 54// Function55void f() {}56void __declspec(dllexport) exported_f() {}57// DEFAULTS-DAG: define hidden void @_Z1fv()58// DEFAULTS-DAG: define void @_Z10exported_fv()59// EXPLICIT-DAG: define protected void @_Z1fv()60// EXPLICIT-DAG: define hidden void @_Z10exported_fv()61// ALL_DEFAULT-DAG: define void @_Z1fv()62// ALL_DEFAULT-DAG: define void @_Z10exported_fv()63// ALL_KEEP-DAG: define hidden void @_Z1fv()64// ALL_KEEP-DAG: define hidden void @_Z10exported_fv()65 66// Variable67int d = 123;68__declspec(dllexport) int exported_d = 123;69// DEFAULTS-DAG: @d = hidden global70// DEFAULTS-DAG: @exported_d = global71// EXPLICIT-DAG: @d = protected global72// EXPLICIT-DAG: @exported_d = hidden global73// ALL_DEFAULT-DAG: @d = global74// ALL_DEFAULT-DAG: @exported_d = global75// ALL_KEEP-DAG: @d = hidden global76// ALL_KEEP-DAG: @exported_d = hidden global77 78// Alias79extern "C" void aliased() {}80void a() __attribute__((alias("aliased")));81void __declspec(dllexport) a_exported() __attribute__((alias("aliased")));82// DEFAULTS-DAG: @_Z1av = hidden alias83// DEFAULTS-DAG: @_Z10a_exportedv = alias84// EXPLICIT-DAG: @_Z1av = protected alias85// EXPLICIT-DAG: @_Z10a_exportedv = hidden alias86// ALL_DEFAULT-DAG: @_Z1av = alias87// ALL_DEFAULT-DAG: @_Z10a_exportedv = alias88// ALL_KEEP-DAG: @_Z1av = hidden alias89// ALL_KEEP-DAG: @_Z10a_exportedv = dso_local alias90 91// Declaration92extern void e();93extern void __declspec(dllimport) imported_e();94// DEFAULTS-DAG: declare hidden void @_Z1ev()95// DEFAULTS-DAG: declare void @_Z10imported_ev()96// EXPLICIT-DAG: declare protected void @_Z1ev()97// EXPLICIT-DAG: declare hidden void @_Z10imported_ev()98// ALL_DEFAULT-DAG: declare void @_Z1ev()99// ALL_DEFAULT-DAG: declare void @_Z10imported_ev()100// ALL_KEEP-DAG: declare hidden void @_Z1ev()101// ALL_KEEP-DAG: declare void @_Z10imported_ev()102 103// Weak Declaration104__attribute__((weak))105extern void w();106__attribute__((weak))107extern void __declspec(dllimport) imported_w();108// DEFAULTS-DAG: declare extern_weak hidden void @_Z1wv()109// DEFAULTS-DAG: declare extern_weak void @_Z10imported_wv()110// EXPLICIT-DAG: declare extern_weak protected void @_Z1wv()111// EXPLICIT-DAG: declare extern_weak hidden void @_Z10imported_wv()112// ALL_DEFAULT-DAG: declare extern_weak void @_Z1wv()113// ALL_DEFAULT-DAG: declare extern_weak void @_Z10imported_wv()114// ALL_KEEP-DAG: declare extern_weak hidden void @_Z1wv()115// ALL_KEEP-DAG: declare extern_weak void @_Z10imported_wv()116 117void use_declarations(){e(); imported_e(); w(); imported_w();}118 119// Show that -fvisibility-from-dllstorageclass overrides the effect of visibility annotations.120 121struct __attribute__((type_visibility("protected"))) t {122  virtual void foo();123};124void t::foo() {}125// DEFAULTS-DAG: @_ZTV1t = hidden unnamed_addr constant126// ALL_KEEP-DAG: @_ZTV1t = protected unnamed_addr constant127 128int v __attribute__ ((__visibility__ ("protected"))) = 123;129// DEFAULTS-DAG: @v = hidden global130// ALL_KEEP-DAG: @v = protected global131 132#pragma GCC visibility push(protected)133int p = 345;134#pragma GCC visibility pop135// DEFAULTS-DAG: @p = hidden global136// ALL_KEEP-DAG: @p = protected global137