r202940 - [OPNEMP] Fixed instantiation of 'if' clause
Alexey Bataev
a.bataev at hotmail.com
Tue Mar 4 22:45:14 PST 2014
Author: abataev
Date: Wed Mar 5 00:45:14 2014
New Revision: 202940
URL: http://llvm.org/viewvc/llvm-project?rev=202940&view=rev
Log:
[OPNEMP] Fixed instantiation of 'if' clause
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/OpenMP/parallel_ast_print.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=202940&r1=202939&r2=202940&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Mar 5 00:45:14 2014
@@ -6309,7 +6309,10 @@ TreeTransform<Derived>::TransformOMPSimd
template<typename Derived>
OMPClause *
TreeTransform<Derived>::TransformOMPIfClause(OMPIfClause *C) {
- return getDerived().RebuildOMPIfClause(C->getCondition(), C->getLocStart(),
+ ExprResult Cond = getDerived().TransformExpr(C->getCondition());
+ if (Cond.isInvalid())
+ return 0;
+ return getDerived().RebuildOMPIfClause(Cond.take(), C->getLocStart(),
C->getLParenLoc(), C->getLocEnd());
}
Modified: cfe/trunk/test/OpenMP/parallel_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_ast_print.cpp?rev=202940&r1=202939&r2=202940&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_ast_print.cpp Wed Mar 5 00:45:14 2014
@@ -9,7 +9,7 @@
void foo() {}
-template <typename T>
+template <typename T, int C>
T tmain(T argc, T *argv) {
T b = argc, c, d, e, f, g;
static T a;
@@ -17,29 +17,37 @@ T tmain(T argc, T *argv) {
a=2;
#pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared (d) if (argc > 0)
foo();
+#pragma omp parallel if (C)
+ foo();
return 0;
}
-// CHECK: template <typename T = int> int tmain(int argc, int *argv) {
+// CHECK: template <typename T = int, int C = 2> int tmain(int argc, int *argv) {
// CHECK-NEXT: int b = argc, c, d, e, f, g;
// CHECK-NEXT: static int a;
// CHECK-NEXT: #pragma omp parallel
// CHECK-NEXT: a = 2;
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0)
// CHECK-NEXT: foo()
-// CHECK: template <typename T = float> float tmain(float argc, float *argv) {
+// CHECK-NEXT: #pragma omp parallel if(2)
+// CHECK-NEXT: foo()
+// CHECK: template <typename T = float, int C = 0> float tmain(float argc, float *argv) {
// CHECK-NEXT: float b = argc, c, d, e, f, g;
// CHECK-NEXT: static float a;
// CHECK-NEXT: #pragma omp parallel
// CHECK-NEXT: a = 2;
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0)
// CHECK-NEXT: foo()
-// CHECK: template <typename T> T tmain(T argc, T *argv) {
+// CHECK-NEXT: #pragma omp parallel if(0)
+// CHECK-NEXT: foo()
+// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
// CHECK-NEXT: T b = argc, c, d, e, f, g;
// CHECK-NEXT: static T a;
// CHECK-NEXT: #pragma omp parallel
// CHECK-NEXT: a = 2;
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0)
// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp parallel if(C)
+// CHECK-NEXT: foo()
int main (int argc, char **argv) {
float x;
@@ -54,7 +62,7 @@ int main (int argc, char **argv) {
// CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) if(argc > 0)
foo();
// CHECK-NEXT: foo();
- return tmain(b, &b) + tmain(x, &x);
+ return tmain<int, 2>(b, &b) + tmain<float, 0>(x, &x);
}
#endif
More information about the cfe-commits
mailing list