Skip to content

Commit 343ed7f

Browse files
committed
TreeTransform: If/final/default instatiation
1 parent 59da0b4 commit 343ed7f

File tree

3 files changed

+103
-32
lines changed

3 files changed

+103
-32
lines changed

clang/lib/Sema/TreeTransform.h

+47-32
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,41 @@ class TreeTransform {
15401540
Kind, AStmt, StartLoc, EndLoc);
15411541
}
15421542

1543+
/// Build a new OmpSs 'if' clause.
1544+
///
1545+
/// By default, performs semantic analysis to build the new OmpSs clause.
1546+
/// Subclasses may override this routine to provide different behavior.
1547+
OSSClause *RebuildOSSIfClause(Expr *Condition, SourceLocation StartLoc,
1548+
SourceLocation LParenLoc,
1549+
SourceLocation EndLoc) {
1550+
return getSema().ActOnOmpSsIfClause(Condition, StartLoc, LParenLoc,
1551+
EndLoc);
1552+
}
1553+
1554+
/// Build a new OmpSs 'final' clause.
1555+
///
1556+
/// By default, performs semantic analysis to build the new OmpSs clause.
1557+
/// Subclasses may override this routine to provide different behavior.
1558+
OSSClause *RebuildOSSFinalClause(Expr *Condition, SourceLocation StartLoc,
1559+
SourceLocation LParenLoc,
1560+
SourceLocation EndLoc) {
1561+
return getSema().ActOnOmpSsFinalClause(Condition, StartLoc, LParenLoc,
1562+
EndLoc);
1563+
}
1564+
1565+
/// Build a new OmpSs 'depend' pseudo clause.
1566+
///
1567+
/// By default, performs semantic analysis to build the new OmpSs clause.
1568+
/// Subclasses may override this routine to provide different behavior.
1569+
OSSClause *
1570+
RebuildOSSDependClause(ArrayRef<OmpSsDependClauseKind> DepKinds, SourceLocation DepLoc,
1571+
SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
1572+
SourceLocation StartLoc, SourceLocation LParenLoc,
1573+
SourceLocation EndLoc) {
1574+
return getSema().ActOnOmpSsDependClause(DepKinds, DepLoc, ColonLoc, VarList,
1575+
StartLoc, LParenLoc, EndLoc);
1576+
}
1577+
15431578
/// Build a new OmpSs 'shared' clause.
15441579
///
15451580
/// By default, performs semantic analysis to build the new OmpSs clause.
@@ -1576,19 +1611,6 @@ class TreeTransform {
15761611
EndLoc);
15771612
}
15781613

1579-
/// Build a new OmpSs 'depend' pseudo clause.
1580-
///
1581-
/// By default, performs semantic analysis to build the new OmpSs clause.
1582-
/// Subclasses may override this routine to provide different behavior.
1583-
OSSClause *
1584-
RebuildOSSDependClause(ArrayRef<OmpSsDependClauseKind> DepKinds, SourceLocation DepLoc,
1585-
SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
1586-
SourceLocation StartLoc, SourceLocation LParenLoc,
1587-
SourceLocation EndLoc) {
1588-
return getSema().ActOnOmpSsDependClause(DepKinds, DepLoc, ColonLoc, VarList,
1589-
StartLoc, LParenLoc, EndLoc);
1590-
}
1591-
15921614
/// Build a new OpenMP executable directive.
15931615
///
15941616
/// By default, performs semantic analysis to build the new statement.
@@ -9359,24 +9381,20 @@ TreeTransform<Derived>::TransformOSSLastprivateClause(OSSLastprivateClause *C) {
93599381

93609382
template <typename Derived>
93619383
OSSClause *TreeTransform<Derived>::TransformOSSIfClause(OSSIfClause *C) {
9362-
// ExprResult Cond = getDerived().TransformExpr(C->getCondition());
9363-
// if (Cond.isInvalid())
9364-
// return nullptr;
9365-
// return getDerived().RebuildOSSIfClause(Cond.get(), C->getBeginLoc(),
9366-
// C->getLParenLoc(), C->getEndLoc());
9367-
llvm_unreachable("unsupported yet");
9368-
return nullptr;
9384+
ExprResult Cond = getDerived().TransformExpr(C->getCondition());
9385+
if (Cond.isInvalid())
9386+
return nullptr;
9387+
return getDerived().RebuildOSSIfClause(Cond.get(), C->getBeginLoc(),
9388+
C->getLParenLoc(), C->getEndLoc());
93699389
}
93709390

93719391
template <typename Derived>
93729392
OSSClause *TreeTransform<Derived>::TransformOSSFinalClause(OSSFinalClause *C) {
9373-
// ExprResult Cond = getDerived().TransformExpr(C->getCondition());
9374-
// if (Cond.isInvalid())
9375-
// return nullptr;
9376-
// return getDerived().RebuildOSSFinalClause(Cond.get(), C->getBeginLoc(),
9377-
// C->getLParenLoc(), C->getEndLoc());
9378-
llvm_unreachable("unsupported yet");
9379-
return nullptr;
9393+
ExprResult Cond = getDerived().TransformExpr(C->getCondition());
9394+
if (Cond.isInvalid())
9395+
return nullptr;
9396+
return getDerived().RebuildOSSFinalClause(Cond.get(), C->getBeginLoc(),
9397+
C->getLParenLoc(), C->getEndLoc());
93809398
}
93819399

93829400
template <typename Derived>
@@ -9410,11 +9428,8 @@ TreeTransform<Derived>::TransformOSSCollapseClause(OSSCollapseClause *C) {
94109428
template <typename Derived>
94119429
OSSClause *
94129430
TreeTransform<Derived>::TransformOSSDefaultClause(OSSDefaultClause *C) {
9413-
// return getDerived().RebuildOSSDefaultClause(
9414-
// C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getBeginLoc(),
9415-
// C->getLParenLoc(), C->getEndLoc());
9416-
llvm_unreachable("unsupported yet");
9417-
return nullptr;
9431+
// No need to rebuild this clause, no template-dependent parameters.
9432+
return C;
94189433
}
94199434

94209435
template <typename Derived>

clang/test/OmpSs/AST/task_final.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang_cc1 -x c++ -verify -fompss-2 -ast-dump -ferror-limit 100 %s | FileCheck %s
2+
// expected-no-diagnostics
3+
4+
template<typename T>
5+
T *foo(T *t) {
6+
#pragma oss task final(*t)
7+
{}
8+
return t;
9+
}
10+
11+
void bar() {
12+
float *p;
13+
float *j = foo(p);
14+
}
15+
16+
// CHECK: OSSTaskDirective {{[a-z0-9]+}} <line:6:11, col:29>
17+
// CHECK-NEXT: OSSFinalClause {{[a-z0-9]+}} <col:20, col:28>
18+
// CHECK-NEXT: UnaryOperator {{[a-z0-9]+}} <col:26, col:27> '<dependent type>' prefix '*' cannot overflow
19+
// CHECK-NEXT: DeclRefExpr {{[a-z0-9]+}} <col:27> 'T *' lvalue ParmVar {{[a-z0-9]+}} 't' 'T *'
20+
21+
// CHECK: OSSTaskDirective {{[a-z0-9]+}} <line:6:11, col:29>
22+
// CHECK-NEXT: OSSFinalClause {{[a-z0-9]+}} <col:20, col:28>
23+
// CHECK-NEXT: ImplicitCastExpr {{[a-z0-9]+}} <col:26, col:27> 'bool' <FloatingToBoolean>
24+
// CHECK-NEXT: ImplicitCastExpr {{[a-z0-9]+}} <col:26, col:27> 'float':'float' <LValueToRValue>
25+
// CHECK-NEXT: UnaryOperator {{[a-z0-9]+}} <col:26, col:27> 'float':'float' lvalue prefix '*' cannot overflow
26+
// CHECK-NEXT: ImplicitCastExpr {{[a-z0-9]+}} <col:27> 'float *' <LValueToRValue>
27+
// CHECK-NEXT: DeclRefExpr {{[a-z0-9]+}} <col:27> 'float *' lvalue ParmVar {{[a-z0-9]+}} 't' 'float *'
28+

clang/test/OmpSs/AST/task_if.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang_cc1 -x c++ -verify -fompss-2 -ast-dump -ferror-limit 100 %s | FileCheck %s
2+
// expected-no-diagnostics
3+
4+
template<typename T>
5+
T *foo(T *t) {
6+
#pragma oss task if(*t)
7+
{}
8+
return t;
9+
}
10+
11+
void bar() {
12+
float *p;
13+
float *j = foo(p);
14+
}
15+
16+
// CHECK: OSSTaskDirective {{[a-z0-9]+}} <line:6:11, col:26>
17+
// CHECK-NEXT: OSSIfClause {{[a-z0-9]+}} <col:20, col:25>
18+
// CHECK-NEXT: UnaryOperator {{[a-z0-9]+}} <col:23, col:24> '<dependent type>' prefix '*' cannot overflow
19+
// CHECK-NEXT: DeclRefExpr {{[a-z0-9]+}} <col:24> 'T *' lvalue ParmVar {{[a-z0-9]+}} 't' 'T *'
20+
21+
// CHECK: OSSTaskDirective {{[a-z0-9]+}} <line:6:11, col:26>
22+
// CHECK-NEXT: OSSIfClause {{[a-z0-9]+}} <col:20, col:25>
23+
// CHECK-NEXT: ImplicitCastExpr {{[a-z0-9]+}} <col:23, col:24> 'bool' <FloatingToBoolean>
24+
// CHECK-NEXT: ImplicitCastExpr {{[a-z0-9]+}} <col:23, col:24> 'float':'float' <LValueToRValue>
25+
// CHECK-NEXT: UnaryOperator {{[a-z0-9]+}} <col:23, col:24> 'float':'float' lvalue prefix '*' cannot overflow
26+
// CHECK-NEXT: ImplicitCastExpr {{[a-z0-9]+}} <col:24> 'float *' <LValueToRValue>
27+
// CHECK-NEXT: DeclRefExpr {{[a-z0-9]+}} <col:24> 'float *' lvalue ParmVar {{[a-z0-9]+}} 't' 'float *'
28+

0 commit comments

Comments
 (0)