[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / assume_attr.cpp
blobdbe76501377c0aabfc72eea146b78536d62d0bf0
1 // RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -x c++ -emit-pch -triple i386-linux-gnu -o %t %s
3 // RUN: %clang_cc1 -include-pch %t %s -triple i386-linux-gnu -emit-llvm -o - | FileCheck %s
4 // expected-no-diagnostics
6 #ifndef HEADER
7 #define HEADER
9 /// foo: declarations only
11 __attribute__((assume("foo:before1"))) void foo();
13 __attribute__((assume("foo:before2")))
14 __attribute__((assume("foo:before3"))) void
15 foo();
17 /// baz: static function declarations and a definition
19 __attribute__((assume("baz:before1"))) static void baz();
21 __attribute__((assume("baz:before2")))
22 __attribute__((assume("baz:before3"))) static void
23 baz();
25 // Definition
26 __attribute__((assume("baz:def1,baz:def2"))) static void baz() { foo(); }
28 __attribute__((assume("baz:after"))) static void baz();
30 /// bar: external function declarations and a definition
32 __attribute__((assume("bar:before1"))) void bar();
34 __attribute__((assume("bar:before2")))
35 __attribute__((assume("bar:before3"))) void
36 bar();
38 // Definition
39 __attribute__((assume("bar:def1,bar:def2"))) void bar() { baz(); }
41 __attribute__((assume("bar:after"))) void bar();
43 /// back to foo
45 __attribute__((assume("foo:after"))) void foo();
47 /// class tests
48 class C {
49 __attribute__((assume("C:private_method"))) void private_method();
50 __attribute__((assume("C:private_static"))) static void private_static();
52 public:
53 __attribute__((assume("C:public_method1"))) void public_method();
54 __attribute__((assume("C:public_static1"))) static void public_static();
57 __attribute__((assume("C:public_method2"))) void C::public_method() {
58 private_method();
61 __attribute__((assume("C:public_static2"))) void C::public_static() {
62 private_static();
65 /// template tests
66 template <typename T>
67 __attribute__((assume("template_func<T>"))) void template_func() {}
69 template <>
70 __attribute__((assume("template_func<float>"))) void template_func<float>() {}
72 template <>
73 void template_func<int>() {}
75 template <typename T>
76 struct S {
77 __attribute__((assume("S<T>::method"))) void method();
80 template <>
81 __attribute__((assume("S<float>::method"))) void S<float>::method() {}
83 template <>
84 void S<int>::method() {}
86 // CHECK: define{{.*}} void @_Z3barv() #0
87 // CHECK: define{{.*}} void @_ZL3bazv() #1
88 // CHECK: define{{.*}} void @_ZN1C13public_methodEv({{.*}}) #2
89 // CHECK: declare{{.*}} void @_ZN1C14private_methodEv({{.*}}) #3
90 // CHECK: define{{.*}} void @_ZN1C13public_staticEv() #4
91 // CHECK: declare{{.*}} void @_ZN1C14private_staticEv() #5
92 // CHECK: define{{.*}} void @_Z13template_funcIfEvv() #6
93 // CHECK: define{{.*}} void @_Z13template_funcIiEvv() #7
94 // CHECK: define{{.*}} void @_ZN1SIfE6methodEv({{.*}}) #8
95 // CHECK: define{{.*}} void @_ZN1SIiE6methodEv({{.*}}) #9
96 // CHECK: declare{{.*}} void @_Z3foov() #10
97 // CHECK: attributes #0
98 // CHECK-SAME: "llvm.assume"="bar:before1,bar:before2,bar:before3,bar:def1,bar:def2"
99 // CHECK: attributes #1
100 // CHECK-SAME: "llvm.assume"="baz:before1,baz:before2,baz:before3,baz:def1,baz:def2,baz:after"
101 // CHECK: attributes #2
102 // CHECK-SAME: "llvm.assume"="C:public_method1,C:public_method2"
103 // CHECK: attributes #3
104 // CHECK-SAME: "llvm.assume"="C:private_method"
105 // CHECK: attributes #4
106 // CHECK-SAME: "llvm.assume"="C:public_static1,C:public_static2"
107 // CHECK: attributes #5
108 // CHECK-SAME: "llvm.assume"="C:private_static"
109 // CHECK: attributes #6
110 // CHECK-SAME: "llvm.assume"="template_func<T>,template_func<float>"
111 // CHECK: attributes #7
112 // CHECK-SAME: "llvm.assume"="template_func<T>"
113 // CHECK: attributes #8
114 // CHECK-SAME: "llvm.assume"="S<T>::method,S<float>::method"
115 // CHECK: attributes #9
116 // CHECK-SAME: "llvm.assume"="S<T>::method"
117 // CHECK: attributes #10
118 // CHECK-SAME: "llvm.assume"="foo:before1,foo:before2,foo:before3"
120 #endif