| 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 |
| 5 |
|
| 6 |
#ifndef HEADER |
| 7 |
#define HEADER |
| 8 |
|
| 9 |
/// foo: declarations only |
| 10 |
|
| 11 |
[[omp::assume("foo:before1")]] void foo(); |
| 12 |
|
| 13 |
[[omp::assume("foo:before2")]] |
| 14 |
[[omp::assume("foo:before3")]] void |
| 15 |
foo(); |
| 16 |
|
| 17 |
/// baz: static function declarations and a definition |
| 18 |
|
| 19 |
[[omp::assume("baz:before1")]] static void baz(); |
| 20 |
|
| 21 |
[[omp::assume("baz:before2")]] |
| 22 |
[[omp::assume("baz:before3")]] static void |
| 23 |
baz(); |
| 24 |
|
| 25 |
// Definition |
| 26 |
[[omp::assume("baz:def1,baz:def2")]] static void baz() { foo(); } |
| 27 |
|
| 28 |
[[omp::assume("baz:after")]] static void baz(); |
| 29 |
|
| 30 |
/// bar: external function declarations and a definition |
| 31 |
|
| 32 |
[[omp::assume("bar:before1")]] void bar(); |
| 33 |
|
| 34 |
[[omp::assume("bar:before2")]] |
| 35 |
[[omp::assume("bar:before3")]] void |
| 36 |
bar(); |
| 37 |
|
| 38 |
// Definition |
| 39 |
[[omp::assume("bar:def1,bar:def2")]] void bar() { baz(); } |
| 40 |
|
| 41 |
[[omp::assume("bar:after")]] void bar(); |
| 42 |
|
| 43 |
/// back to foo |
| 44 |
|
| 45 |
[[omp::assume("foo:after")]] void foo(); |
| 46 |
|
| 47 |
/// class tests |
| 48 |
class C { |
| 49 |
[[omp::assume("C:private_method")]] void private_method(); |
| 50 |
[[omp::assume("C:private_static")]] static void private_static(); |
| 51 |
|
| 52 |
public: |
| 53 |
[[omp::assume("C:public_method1")]] void public_method(); |
| 54 |
[[omp::assume("C:public_static1")]] static void public_static(); |
| 55 |
}; |
| 56 |
|
| 57 |
[[omp::assume("C:public_method2")]] void C::public_method() { |
| 58 |
private_method(); |
| 59 |
} |
| 60 |
|
| 61 |
[[omp::assume("C:public_static2")]] void C::public_static() { |
| 62 |
private_static(); |
| 63 |
} |
| 64 |
|
| 65 |
/// template tests |
| 66 |
template <typename T> |
| 67 |
[[omp::assume("template_func<T>")]] void template_func() {} |
| 68 |
|
| 69 |
template <> |
| 70 |
[[omp::assume("template_func<float>")]] void template_func<float>() {} |
| 71 |
|
| 72 |
template <> |
| 73 |
void template_func<int>() {} |
| 74 |
|
| 75 |
template <typename T> |
| 76 |
struct S { |
| 77 |
[[omp::assume("S<T>::method")]] void method(); |
| 78 |
}; |
| 79 |
|
| 80 |
template <> |
| 81 |
[[omp::assume("S<float>::method")]] void S<float>::method() {} |
| 82 |
|
| 83 |
template <> |
| 84 |
void S<int>::method() {} |
| 85 |
|
| 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" |
| 119 |
|
| 120 |
#endif |