[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / attr-retain.cpp
blob3a56576d8163298fbbf9d0f50af3fea401987979
1 // RUN: %clang_cc1 -emit-llvm -triple x86_64 -Werror %s -o - | FileCheck %s
3 // CHECK: @llvm.used = appending global [7 x ptr]
4 // CHECK-SAME: @_ZN2X0C2Ev
5 // CHECK-SAME: @_ZN2X0C1Ev
6 // CHECK-SAME: @_ZN2X0D2Ev
7 // CHECK-SAME: @_ZN2X0D1Ev
8 // CHECK-SAME: @_ZN2X16Nested2f1Ev
9 // CHECK-SAME: @_ZN10merge_declL4funcEv
10 // CHECK-SAME: @_ZN18instantiate_member1SIiE1fEv
12 struct X0 {
13 // CHECK: define linkonce_odr{{.*}} @_ZN2X0C1Ev({{.*}}
14 __attribute__((used, retain)) X0() {}
15 // CHECK: define linkonce_odr{{.*}} @_ZN2X0D1Ev({{.*}}
16 __attribute__((used, retain)) ~X0() {}
19 struct X1 {
20 struct Nested {
21 // CHECK-NOT: 2f0Ev
22 // CHECK: define linkonce_odr{{.*}} @_ZN2X16Nested2f1Ev({{.*}}
23 void __attribute__((retain)) f0() {}
24 void __attribute__((used, retain)) f1() {}
28 // CHECK: define internal void @_ZN10merge_declL4funcEv(){{.*}}
29 namespace merge_decl {
30 static void func();
31 void bar() { void func() __attribute__((used, retain)); }
32 static void func() {}
33 } // namespace merge_decl
35 namespace instantiate_member {
36 template <typename T>
37 struct S {
38 void __attribute__((used, retain)) f() {}
41 void test() {
42 // CHECK: define linkonce_odr{{.*}} void @_ZN18instantiate_member1SIiE1fEv({{.*}}
43 S<int> a;
45 } // namespace instantiate_member