ABataev created this revision.
ABataev added a reviewer: NoQ.
Herald added a subscriber: guansong.
Herald added a project: clang.

Added basic analysis of map clauses. Only map clauses with to and tofrom
map type must be analyzed since all other map types (alloc, delete, etc.) do 
not require to use the value of the initial variable, instead they create the 
new copy of the variable.


Repository:
  rC Clang

https://reviews.llvm.org/D66668

Files:
  include/clang/AST/OpenMPClause.h
  test/Analysis/cfg-openmp.cpp
  test/OpenMP/target_data_messages.c
  test/OpenMP/target_enter_data_map_messages.c
  test/OpenMP/target_map_messages.cpp
  test/OpenMP/target_parallel_for_map_messages.cpp
  test/OpenMP/target_parallel_for_simd_map_messages.cpp
  test/OpenMP/target_parallel_map_messages.cpp
  test/OpenMP/target_simd_map_messages.cpp
  test/OpenMP/target_teams_distribute_map_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
  test/OpenMP/target_teams_distribute_simd_map_messages.cpp
  test/OpenMP/target_teams_map_messages.cpp

Index: test/OpenMP/target_teams_map_messages.cpp
===================================================================
--- test/OpenMP/target_teams_map_messages.cpp
+++ test/OpenMP/target_teams_map_messages.cpp
@@ -21,6 +21,14 @@
   {}
 }
 #else
+
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target teams map(tofrom: map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
 template <typename T, int I>
 struct SA {
   static int ss;
Index: test/OpenMP/target_teams_distribute_simd_map_messages.cpp
===================================================================
--- test/OpenMP/target_teams_distribute_simd_map_messages.cpp
+++ test/OpenMP/target_teams_distribute_simd_map_messages.cpp
@@ -9,6 +9,13 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target teams distribute simd map(map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
 struct S1; // expected-note 2 {{declared here}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
===================================================================
--- test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
+++ test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
@@ -9,6 +9,13 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target teams distribute parallel for simd map(to: map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
 struct S1; // expected-note 2 {{declared here}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
===================================================================
--- test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
+++ test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
@@ -9,6 +9,13 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target teams distribute parallel for map(tofrom: map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
 struct S1; // expected-note 2 {{declared here}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/target_teams_distribute_map_messages.cpp
===================================================================
--- test/OpenMP/target_teams_distribute_map_messages.cpp
+++ test/OpenMP/target_teams_distribute_map_messages.cpp
@@ -9,6 +9,13 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target teams distribute map(map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
 struct S1; // expected-note 2 {{declared here}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/target_simd_map_messages.cpp
===================================================================
--- test/OpenMP/target_simd_map_messages.cpp
+++ test/OpenMP/target_simd_map_messages.cpp
@@ -9,6 +9,13 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target simd map(to: map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
 struct S1; // expected-note 2 {{declared here}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/target_parallel_map_messages.cpp
===================================================================
--- test/OpenMP/target_parallel_map_messages.cpp
+++ test/OpenMP/target_parallel_map_messages.cpp
@@ -9,6 +9,13 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target parallel map(tofrom: map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
 struct S1; // expected-note 2 {{declared here}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/target_parallel_for_simd_map_messages.cpp
===================================================================
--- test/OpenMP/target_parallel_for_simd_map_messages.cpp
+++ test/OpenMP/target_parallel_for_simd_map_messages.cpp
@@ -9,6 +9,13 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target parallel for simd map(map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
 struct S1; // expected-note 2 {{declared here}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/target_parallel_for_map_messages.cpp
===================================================================
--- test/OpenMP/target_parallel_for_map_messages.cpp
+++ test/OpenMP/target_parallel_for_map_messages.cpp
@@ -9,6 +9,13 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target parallel for map(tofrom: map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
 struct S1; // expected-note 2 {{declared here}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/target_map_messages.cpp
===================================================================
--- test/OpenMP/target_map_messages.cpp
+++ test/OpenMP/target_map_messages.cpp
@@ -20,6 +20,14 @@
 }
 #else
 
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target map(tofrom: map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
+
 struct SREF {
   int &a;
   int b;
Index: test/OpenMP/target_enter_data_map_messages.c
===================================================================
--- test/OpenMP/target_enter_data_map_messages.c
+++ test/OpenMP/target_enter_data_map_messages.c
@@ -4,6 +4,13 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -ferror-limit 100 -o - -x c++ %s -Wuninitialized
 
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target enter data map(to: map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
 int main(int argc, char **argv) {
 
   int r;
Index: test/OpenMP/target_data_messages.c
===================================================================
--- test/OpenMP/target_data_messages.c
+++ test/OpenMP/target_data_messages.c
@@ -4,6 +4,13 @@
 
 void foo() { }
 
+void xxx(int argc) {
+  int map; // expected-note {{initialize the variable 'map' to silence this warning}}
+#pragma omp target data map(map) // expected-warning {{variable 'map' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+    ;
+}
+
 int main(int argc, char **argv) {
   int a;
   #pragma omp target data // expected-error {{expected at least one 'map' or 'use_device_ptr' clause for '#pragma omp target data'}}
Index: test/Analysis/cfg-openmp.cpp
===================================================================
--- test/Analysis/cfg-openmp.cpp
+++ test/Analysis/cfg-openmp.cpp
@@ -9,7 +9,8 @@
 // CHECK-NEXT:   4: int rd;
 // CHECK-NEXT:   5: int lin;
 // CHECK-NEXT:   6: int step;
-  int x, cond, fp, rd, lin, step;
+// CHECK-NEXT:   7: int map;
+  int x, cond, fp, rd, lin, step, map;
 // CHECK-NEXT:   [[#ATOM:]]: x
 // CHECK-NEXT:   [[#ATOM+1]]: [B1.[[#ATOM]]] (ImplicitCastExpr, LValueToRValue, int)
 // CHECK-NEXT:   [[#ATOM+2]]: argc
@@ -219,10 +220,10 @@
                           : argc) if(cond) firstprivate(fp) reduction(-:rd)
   argc = x;
 // CHECK-NEXT:  [[#TPF:]]:
-// CHECK-SAME:  [B1.[[#TPF+13]]]
-// CHECK-NEXT:  [[#TPF+1]]: [B1.[[#TPF+13]]] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  [[#TPF+2]]: [B1.[[#TPF+12]]]
-// CHECK-NEXT:  [[#TPF+3]]: [B1.[[#TPF+12]]] = [B1.[[#TPF+1]]]
+// CHECK-SAME:  [B1.[[#TPF+14]]]
+// CHECK-NEXT:  [[#TPF+1]]: [B1.[[#TPF+14]]] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  [[#TPF+2]]: [B1.[[#TPF+13]]]
+// CHECK-NEXT:  [[#TPF+3]]: [B1.[[#TPF+13]]] = [B1.[[#TPF+1]]]
 // CHECK-NEXT:  [[#TPF+4]]: cond
 // CHECK-NEXT:  [[#TPF+5]]: [B1.[[#TPF+4]]] (ImplicitCastExpr, LValueToRValue, int)
 // CHECK-NEXT:  [[#TPF+6]]: [B1.[[#TPF+5]]] (ImplicitCastExpr, IntegralToBoolean, _Bool)
@@ -231,19 +232,20 @@
 // CHECK-NEXT:  [[#TPF+9]]: lin
 // CHECK-NEXT:  [[#TPF+10]]: step
 // CHECK-NEXT:  [[#TPF+11]]: [B1.[[#TPF+10]]] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  [[#TPF+12]]: argc
-// CHECK-NEXT:  [[#TPF+13]]: x
-// CHECK-NEXT:  [[#TPF+14]]: #pragma omp target parallel for if(parallel: cond) firstprivate(fp) reduction(max: rd) linear(lin: step)
+// CHECK-NEXT:  [[#TPF+12]]: map
+// CHECK-NEXT:  [[#TPF+13]]: argc
+// CHECK-NEXT:  [[#TPF+14]]: x
+// CHECK-NEXT:  [[#TPF+15]]: #pragma omp target parallel for if(parallel: cond) firstprivate(fp) reduction(max: rd) linear(lin: step) map(tofrom: map)
 // CHECK-NEXT:    for (int i = 0; i < 10; ++i)
 // CHECK-NEXT:        [B1.[[#TPF+3]]];
-#pragma omp target parallel for if(parallel:cond) firstprivate(fp) reduction(max:rd) linear(lin: step)
+#pragma omp target parallel for if(parallel:cond) firstprivate(fp) reduction(max:rd) linear(lin: step) map(map)
   for (int i = 0; i < 10; ++i)
     argc = x;
 // CHECK-NEXT:  [[#TPFS:]]:
-// CHECK-SAME:  [B1.[[#TPFS+13]]]
-// CHECK-NEXT:  [[#TPFS+1]]: [B1.[[#TPFS+13]]] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  [[#TPFS+2]]: [B1.[[#TPFS+12]]]
-// CHECK-NEXT:  [[#TPFS+3]]: [B1.[[#TPFS+12]]] = [B1.[[#TPFS+1]]]
+// CHECK-SAME:  [B1.[[#TPFS+14]]]
+// CHECK-NEXT:  [[#TPFS+1]]: [B1.[[#TPFS+14]]] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  [[#TPFS+2]]: [B1.[[#TPFS+13]]]
+// CHECK-NEXT:  [[#TPFS+3]]: [B1.[[#TPFS+13]]] = [B1.[[#TPFS+1]]]
 // CHECK-NEXT:  [[#TPFS+4]]: cond
 // CHECK-NEXT:  [[#TPFS+5]]: [B1.[[#TPFS+4]]] (ImplicitCastExpr, LValueToRValue, int)
 // CHECK-NEXT:  [[#TPFS+6]]: [B1.[[#TPFS+5]]] (ImplicitCastExpr, IntegralToBoolean, _Bool)
@@ -252,29 +254,31 @@
 // CHECK-NEXT:  [[#TPFS+9]]: lin
 // CHECK-NEXT:  [[#TPFS+10]]: step
 // CHECK-NEXT:  [[#TPFS+11]]: [B1.[[#TPFS+10]]] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  [[#TPFS+12]]: argc
-// CHECK-NEXT:  [[#TPFS+13]]: x
-// CHECK-NEXT:  [[#TPFS+14]]: #pragma omp target parallel for simd if(target: cond) firstprivate(fp) reduction(*: rd) linear(lin: step)
+// CHECK-NEXT:  [[#TPFS+12]]: map
+// CHECK-NEXT:  [[#TPFS+13]]: argc
+// CHECK-NEXT:  [[#TPFS+14]]: x
+// CHECK-NEXT:  [[#TPFS+15]]: #pragma omp target parallel for simd if(target: cond) firstprivate(fp) reduction(*: rd) linear(lin: step) map(tofrom: map)
 // CHECK-NEXT:    for (int i = 0; i < 10; ++i)
 // CHECK-NEXT:        [B1.[[#TPFS+3]]];
-#pragma omp target parallel for simd if(target:cond) firstprivate(fp) reduction(*:rd) linear(lin: step)
+#pragma omp target parallel for simd if(target:cond) firstprivate(fp) reduction(*:rd) linear(lin: step) map(tofrom:map)
   for (int i = 0; i < 10; ++i)
     argc = x;
 // CHECK-NEXT:  [[#TP:]]:
-// CHECK-SAME:  [B1.[[#TP+10]]]
-// CHECK-NEXT:  [[#TP+1]]: [B1.[[#TP+10]]] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  [[#TP+2]]: [B1.[[#TP+9]]]
-// CHECK-NEXT:  [[#TP+3]]: [B1.[[#TP+9]]] = [B1.[[#TP+1]]]
+// CHECK-SAME:  [B1.[[#TP+11]]]
+// CHECK-NEXT:  [[#TP+1]]: [B1.[[#TP+11]]] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  [[#TP+2]]: [B1.[[#TP+10]]]
+// CHECK-NEXT:  [[#TP+3]]: [B1.[[#TP+10]]] = [B1.[[#TP+1]]]
 // CHECK-NEXT:  [[#TP+4]]: cond
 // CHECK-NEXT:  [[#TP+5]]: [B1.[[#TP+4]]] (ImplicitCastExpr, LValueToRValue, int)
 // CHECK-NEXT:  [[#TP+6]]: [B1.[[#TP+5]]] (ImplicitCastExpr, IntegralToBoolean, _Bool)
 // CHECK-NEXT:  [[#TP+7]]: fp
 // CHECK-NEXT:  [[#TP+8]]: rd
-// CHECK-NEXT:  [[#TP+9]]: argc
-// CHECK-NEXT:  [[#TP+10]]: x
-// CHECK-NEXT:  [[#TP+11]]: #pragma omp target parallel if(cond) firstprivate(fp) reduction(+: rd)
+// CHECK-NEXT:  [[#TP+9]]: map
+// CHECK-NEXT:  [[#TP+10]]: argc
+// CHECK-NEXT:  [[#TP+11]]: x
+// CHECK-NEXT:  [[#TP+12]]: #pragma omp target parallel if(cond) firstprivate(fp) reduction(+: rd) map(to: map)
 // CHECK-NEXT:    [B1.[[#TP+3]]];
-#pragma omp target parallel if(cond) firstprivate(fp) reduction(+:rd)
+#pragma omp target parallel if(cond) firstprivate(fp) reduction(+:rd) map(to:map)
   argc = x;
 // CHECK-NEXT:  [[#TSIMD:]]:
 // CHECK-SAME:  [B1.[[#TSIMD+13]]]
@@ -291,10 +295,10 @@
 // CHECK-NEXT:  [[#TSIMD+11]]: [B1.[[#TSIMD+10]]] (ImplicitCastExpr, LValueToRValue, int)
 // CHECK-NEXT:  [[#TSIMD+12]]: argc
 // CHECK-NEXT:  [[#TSIMD+13]]: x
-// CHECK-NEXT:  [[#TSIMD+14]]: #pragma omp target simd if(cond) firstprivate(fp) reduction(+: rd) linear(lin: step)
+// CHECK-NEXT:  [[#TSIMD+14]]: #pragma omp target simd if(cond) firstprivate(fp) reduction(+: rd) linear(lin: step) map(alloc: map)
 // CHECK-NEXT:    for (int i = 0; i < 10; ++i)
 // CHECK-NEXT:        [B1.[[#TSIMD+3]]];
-#pragma omp target simd if(cond) firstprivate(fp) reduction(+:rd) linear(lin: step)
+#pragma omp target simd if(cond) firstprivate(fp) reduction(+:rd) linear(lin: step) map(alloc:map)
   for (int i = 0; i < 10; ++i)
     argc = x;
 // CHECK-NEXT:  [[#TTD:]]:
@@ -309,10 +313,10 @@
 // CHECK-NEXT:  [[#TTD+8]]: rd
 // CHECK-NEXT:  [[#TTD+9]]: argc
 // CHECK-NEXT:  [[#TTD+10]]: x
-// CHECK-NEXT:  [[#TTD+11]]: #pragma omp target teams distribute if(cond) firstprivate(fp) reduction(+: rd)
+// CHECK-NEXT:  [[#TTD+11]]: #pragma omp target teams distribute if(cond) firstprivate(fp) reduction(+: rd) map(release: map)
 // CHECK-NEXT:    for (int i = 0; i < 10; ++i)
 // CHECK-NEXT:        [B1.[[#TTD+3]]];
-#pragma omp target teams distribute if(cond) firstprivate(fp) reduction(+:rd)
+#pragma omp target teams distribute if(cond) firstprivate(fp) reduction(+:rd) map(release:map)
   for (int i = 0; i < 10; ++i)
     argc = x;
 // CHECK-NEXT:  [[#TTDPF:]]:
@@ -327,10 +331,10 @@
 // CHECK-NEXT:  [[#TTDPF+8]]: rd
 // CHECK-NEXT:  [[#TTDPF+9]]: argc
 // CHECK-NEXT:  [[#TTDPF+10]]: x
-// CHECK-NEXT:  [[#TTDPF+11]]: #pragma omp target teams distribute parallel for if(cond) firstprivate(fp) reduction(+: rd)
+// CHECK-NEXT:  [[#TTDPF+11]]: #pragma omp target teams distribute parallel for if(cond) firstprivate(fp) reduction(+: rd) map(delete: map)
 // CHECK-NEXT:    for (int i = 0; i < 10; ++i)
 // CHECK-NEXT:        [B1.[[#TTDPF+3]]];
-#pragma omp target teams distribute parallel for if(cond) firstprivate(fp) reduction(+:rd)
+#pragma omp target teams distribute parallel for if(cond) firstprivate(fp) reduction(+:rd) map(delete:map)
   for (int i = 0; i < 10; ++i)
     argc = x;
 // CHECK-NEXT:  [[#TTDPFS:]]:
@@ -345,45 +349,47 @@
 // CHECK-NEXT:  [[#TTDPFS+8]]: rd
 // CHECK-NEXT:  [[#TTDPFS+9]]: argc
 // CHECK-NEXT:  [[#TTDPFS+10]]: x
-// CHECK-NEXT:  [[#TTDPFS+11]]: #pragma omp target teams distribute parallel for simd if(parallel: cond) firstprivate(fp) reduction(+: rd)
+// CHECK-NEXT:  [[#TTDPFS+11]]: #pragma omp target teams distribute parallel for simd if(parallel: cond) firstprivate(fp) reduction(+: rd) map(from: map)
 // CHECK-NEXT:    for (int i = 0; i < 10; ++i)
 // CHECK-NEXT:        [B1.[[#TTDPFS+3]]];
-#pragma omp target teams distribute parallel for simd if(parallel:cond) firstprivate(fp) reduction(+:rd)
+#pragma omp target teams distribute parallel for simd if(parallel:cond) firstprivate(fp) reduction(+:rd) map(from:map)
   for (int i = 0; i < 10; ++i)
     argc = x;
 // CHECK-NEXT:  [[#TTDS:]]:
-// CHECK-SAME:  [B1.[[#TTDS+10]]]
-// CHECK-NEXT:  [[#TTDS+1]]: [B1.[[#TTDS+10]]] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  [[#TTDS+2]]: [B1.[[#TTDS+9]]]
-// CHECK-NEXT:  [[#TTDS+3]]: [B1.[[#TTDS+9]]] = [B1.[[#TTDS+1]]]
+// CHECK-SAME:  [B1.[[#TTDS+11]]]
+// CHECK-NEXT:  [[#TTDS+1]]: [B1.[[#TTDS+11]]] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  [[#TTDS+2]]: [B1.[[#TTDS+10]]]
+// CHECK-NEXT:  [[#TTDS+3]]: [B1.[[#TTDS+10]]] = [B1.[[#TTDS+1]]]
 // CHECK-NEXT:  [[#TTDS+4]]: cond
 // CHECK-NEXT:  [[#TTDS+5]]: [B1.[[#TTDS+4]]] (ImplicitCastExpr, LValueToRValue, int)
 // CHECK-NEXT:  [[#TTDS+6]]: [B1.[[#TTDS+5]]] (ImplicitCastExpr, IntegralToBoolean, _Bool)
 // CHECK-NEXT:  [[#TTDS+7]]: fp
 // CHECK-NEXT:  [[#TTDS+8]]: rd
-// CHECK-NEXT:  [[#TTDS+9]]: argc
-// CHECK-NEXT:  [[#TTDS+10]]: x
-// CHECK-NEXT:  [[#TTDS+11]]: #pragma omp target teams distribute simd if(cond) firstprivate(fp) reduction(+: rd)
+// CHECK-NEXT:  [[#TTDS+9]]: map
+// CHECK-NEXT:  [[#TTDS+10]]: argc
+// CHECK-NEXT:  [[#TTDS+11]]: x
+// CHECK-NEXT:  [[#TTDS+12]]: #pragma omp target teams distribute simd if(cond) firstprivate(fp) reduction(+: rd) map(tofrom: map)
 // CHECK-NEXT:    for (int i = 0; i < 10; ++i)
 // CHECK-NEXT:        [B1.[[#TTDS+3]]];
-#pragma omp target teams distribute simd if(cond) firstprivate(fp) reduction(+:rd)
+#pragma omp target teams distribute simd if(cond) firstprivate(fp) reduction(+:rd) map(map)
   for (int i = 0; i < 10; ++i)
     argc = x;
 // CHECK-NEXT:  [[#TT:]]:
-// CHECK-SAME:  [B1.[[#TT+10]]]
-// CHECK-NEXT:  [[#TT+1]]: [B1.[[#TT+10]]] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  [[#TT+2]]: [B1.[[#TT+9]]]
-// CHECK-NEXT:  [[#TT+3]]: [B1.[[#TT+9]]] = [B1.[[#TT+1]]]
+// CHECK-SAME:  [B1.[[#TT+11]]]
+// CHECK-NEXT:  [[#TT+1]]: [B1.[[#TT+11]]] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:  [[#TT+2]]: [B1.[[#TT+10]]]
+// CHECK-NEXT:  [[#TT+3]]: [B1.[[#TT+10]]] = [B1.[[#TT+1]]]
 // CHECK-NEXT:  [[#TT+4]]: cond
 // CHECK-NEXT:  [[#TT+5]]: [B1.[[#TT+4]]] (ImplicitCastExpr, LValueToRValue, int)
 // CHECK-NEXT:  [[#TT+6]]: [B1.[[#TT+5]]] (ImplicitCastExpr, IntegralToBoolean, _Bool)
 // CHECK-NEXT:  [[#TT+7]]: fp
 // CHECK-NEXT:  [[#TT+8]]: rd
-// CHECK-NEXT:  [[#TT+9]]: argc
-// CHECK-NEXT:  [[#TT+10]]: x
-// CHECK-NEXT:  [[#TT+11]]: #pragma omp target teams if(cond) firstprivate(fp) reduction(+: rd)
+// CHECK-NEXT:  [[#TT+9]]: map
+// CHECK-NEXT:  [[#TT+10]]: argc
+// CHECK-NEXT:  [[#TT+11]]: x
+// CHECK-NEXT:  [[#TT+12]]: #pragma omp target teams if(cond) firstprivate(fp) reduction(+: rd) map(tofrom: map)
 // CHECK-NEXT:    [B1.[[#TT+3]]];
-#pragma omp target teams if(cond) firstprivate(fp) reduction(+:rd)
+#pragma omp target teams if(cond) firstprivate(fp) reduction(+:rd) map(tofrom:map)
   argc = x;
 // CHECK-NEXT: [[#TU:]]: cond
 // CHECK-NEXT: [[#TU+1]]: [B1.[[#TU]]] (ImplicitCastExpr, LValueToRValue, int)
Index: include/clang/AST/OpenMPClause.h
===================================================================
--- include/clang/AST/OpenMPClause.h
+++ include/clang/AST/OpenMPClause.h
@@ -5025,12 +5025,17 @@
   }
 
   child_range used_children() {
+    if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_tofrom)
+      return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
+                         reinterpret_cast<Stmt **>(varlist_end()));
     return child_range(child_iterator(), child_iterator());
   }
   const_child_range used_children() const {
-    return const_child_range(const_child_iterator(), const_child_iterator());
+    auto Children = const_cast<OMPMapClause *>(this)->used_children();
+    return const_child_range(Children.begin(), Children.end());
   }
 
+
   static bool classof(const OMPClause *T) {
     return T->getClauseKind() == OMPC_map;
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to