I checked that it is OK to merge check 4, 5 and 6 into a single check (I will 
fix this, thanks!). However, it will fail if merging any other two checks.

The current style is easier for people to read since all checks are close the 
source code. Otherwise, we need to move around some checks (e.g. checking types 
in the module).

Do you think we should move them?

Thanks!

Wei
 
-----Original Message-----
From: Jordan Rose [mailto:[email protected]] 
Sent: Friday, May 10, 2013 12:13 PM
To: Pan, Wei
Cc: [email protected]
Subject: Re: r181598 - Codegen tests for captured statements with templates

This isn't your fault, but is there any way we can avoid checking these 
separately? It seems silly to spin up N FileChecks to check N function bodies.

Maybe this is a more general problem in our tests, but I can't help thinking 
it'd be nice if we had a flag that guaranteed input-source-order output of LLVM 
IR.

Jordan


On May 10, 2013, at 7:15 , Wei Pan <[email protected]> wrote:

> Author: wpan
> Date: Fri May 10 09:15:18 2013
> New Revision: 181598
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=181598&view=rev
> Log:
> Codegen tests for captured statements with templates
> 
> Differential-revision: llvm-reviews.chandlerc.com/D778
> 
> 
> Modified:
>    cfe/trunk/test/CodeGenCXX/captured-statements.cpp
> 
> Modified: cfe/trunk/test/CodeGenCXX/captured-statements.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/captured
> -statements.cpp?rev=181598&r1=181597&r2=181598&view=diff
> ======================================================================
> ========
> --- cfe/trunk/test/CodeGenCXX/captured-statements.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/captured-statements.cpp Fri May 10 
> +++ 09:15:18 2013
> @@ -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>();
> +}
> 
> 
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to