Codegen tests for captured statements with templates

Differential-revision: llvm-reviews.chandlerc.com/D778
llvm-svn: 181598
This commit is contained in:
Wei Pan 2013-05-10 14:15:18 +00:00
parent a5d59333b3
commit 655d3fa3c1
1 changed files with 80 additions and 0 deletions

View File

@ -3,6 +3,8 @@
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-4
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-5
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-6
struct Foo {
int x;
@ -95,3 +97,81 @@ void test4() {
// CHECK-4: store i32 5, i32*
// CHECK-4: call {{.*}}FooD1Ev
}
template <typename T, int id>
void touch(const T &) {}
template <typename T, unsigned id>
void template_capture_var() {
T x;
#pragma clang __debug captured
{
touch<T, id>(x);
}
}
template <typename T, int id>
class Val {
T v;
public:
void set() {
#pragma clang __debug captured
{
touch<T, id>(v);
}
}
template <typename U, int id2>
void foo(U u) {
#pragma clang __debug captured
{
touch<U, id + id2>(u);
}
}
};
void test_capture_var() {
// CHECK-5: define {{.*}} void @_Z20template_capture_varIiLj201EEvv
// CHECK-5-NOT: }
// CHECK-5: store i32*
// CHECK-5: call void @__captured_stmt
// CHECK-5-NEXT: ret void
template_capture_var<int, 201>();
// CHECK-5: define {{.*}} void @_ZN3ValIfLi202EE3setEv
// CHECK-5-NOT: }
// CHECK-5: store %class.Val*
// CHECK-5: call void @__captured_stmt
// CHECK-5-NEXT: ret void
Val<float, 202> Obj;
Obj.set();
// CHECK-5: define {{.*}} void @_ZN3ValIfLi202EE3fooIdLi203EEEvT_
// CHECK-5-NOT: }
// CHECK-5: store %class.Val*
// CHECK-5: store double
// CHECK-5: call void @__captured_stmt
// CHECK-5-NEXT: ret void
Obj.foo<double, 203>(1.0);
}
template <typename T>
void template_capture_lambda() {
T x, y;
[=, &y]() {
#pragma clang __debug captured
{
y += x;
}
}();
}
void test_capture_lambda() {
// CHECK-6: define {{.*}} void @_ZZ23template_capture_lambdaIiEvvENKS_IiEUlvE_clEv
// CHECK-6-NOT: }
// CHECK-6: store i32*
// CHECK-6: store i32*
// CHECK-6: call void @__captured_stmt
// CHECK-6-NEXT: ret void
template_capture_lambda<int>();
}