[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / assume_serialize_deserialize_tmpl.cpp
blobdb0b47210bd41c4f58e80885e764f7232a8cc1e6
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3 // RUN: cd %t
5 // RUN: %clang_cc1 -std=c++20 -fopenmp -triple x86_64-unknown-linux-gnu %t/AssumeMod.cppm -emit-module-interface -o %t/AssumeMod.pcm
6 // RUN: %clang_cc1 -std=c++20 -fopenmp -triple x86_64-unknown-linux-gnu %t/UseAssumeMod.cpp -fmodule-file=AssumeMod=%t/AssumeMod.pcm -ast-dump-all | FileCheck %t/AssumeMod.cppm
8 // expected-no-diagnostics
10 //--- AssumeMod.cppm
11 module;
12 export module AssumeMod;
13 export template<int N> int foo(int y) {
14 int x = -1;
15 #pragma omp assume holds(y == N)
17 x = y;
19 return x;
22 export template<bool B> void bar(int *z) {
23 if constexpr (B) {
24 #pragma omp assume no_openmp
26 z[0]++;
28 } else {
29 #pragma omp assume contains(target, parallel) absent(loop)
31 z[1] += 2;
36 // CHECK: FunctionTemplateDecl 0x{{.*}}
37 // CHECK: OMPAssumeDirective 0x{{.*}} <line:5:1, col:33>
38 // CHECK-NEXT: OMPHoldsClause 0x{{.*}} <col:20, col:32>
40 // CHECK: FunctionDecl 0x{{.*}} implicit_instantiation
41 // CHECK: OMPAssumeDirective 0x{{.*}} <line:5:1, col:33>
42 // CHECK-NEXT: OMPHoldsClause 0x{{.*}} <col:20, col:32>
44 // CHECK: FunctionTemplateDecl 0x{{.*}}
45 // CHECK: OMPAssumeDirective 0x{{.*}} <line:14:1, col:29>
46 // CHECK-NEXT: OMPNo_openmpClause 0x{{.*}} <col:20, col:29>
47 // CHECK: OMPAssumeDirective 0x{{.*}} <line:19:1, col:59>
48 // CHECK-NEXT: OMPContainsClause 0x{{.*}} <col:20, col:45>
49 // CHECK-NEXT: OMPAbsentClause 0x{{.*}} <col:47, col:58>
51 // CHECK: FunctionDecl 0x{{.*}} implicit_instantiation
52 // CHECK: OMPAssumeDirective 0x{{.*}} <line:14:1, col:29>
53 // CHECK-NEXT: OMPNo_openmpClause 0x{{.*}} <col:20, col:29>
55 // CHECK: FunctionDecl 0x{{.*}} implicit_instantiation
56 // CHECK: OMPAssumeDirective 0x{{.*}} <line:19:1, col:59>
57 // CHECK-NEXT: OMPContainsClause 0x{{.*}} <col:20, col:45>
58 // CHECK-NEXT: OMPAbsentClause 0x{{.*}} <col:47, col:58>
60 //--- UseAssumeMod.cpp
61 import AssumeMod;
63 extern "C" int printf(const char* fmt, ...);
65 int main() {
66 printf ("foo(5)=%d\n", foo<5> (5));
67 int arr[2] = { 0, 0 };
68 bar<true>(arr);
69 bar<false>(arr);
70 printf ("arr[0]=%d, arr[1]=%d\n", arr[0], arr[1]);
71 return 0;