summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-07-23 02:27:21 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-07-23 02:27:21 +0000
commitf98b00c33e83cb507c21107e8c56961a4b043509 (patch)
treeb8df40845ba99247ce32566d7297478b0830225b /clang/lib/Sema/SemaOpenMP.cpp
parent6310757568fa3e6433435206102bf2d0cc4300e2 (diff)
downloadbcm5719-llvm-f98b00c33e83cb507c21107e8c56961a4b043509.tar.gz
bcm5719-llvm-f98b00c33e83cb507c21107e8c56961a4b043509.zip
[OPENMP] Initial parsing and sema analysis for 'read' clause in 'atomic' directive.
llvm-svn: 213717
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp46
1 files changed, 42 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index c7c76542501..7ec0d2b944a 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -92,15 +92,16 @@ private:
Scope *CurScope;
SourceLocation ConstructLoc;
bool OrderedRegion;
+ SourceLocation AtomicClauseLoc;
SharingMapTy(OpenMPDirectiveKind DKind, DeclarationNameInfo Name,
Scope *CurScope, SourceLocation Loc)
: SharingMap(), AlignedMap(), DefaultAttr(DSA_unspecified),
Directive(DKind), DirectiveName(std::move(Name)), CurScope(CurScope),
- ConstructLoc(Loc), OrderedRegion(false) {}
+ ConstructLoc(Loc), OrderedRegion(false), AtomicClauseLoc() {}
SharingMapTy()
: SharingMap(), AlignedMap(), DefaultAttr(DSA_unspecified),
Directive(OMPD_unknown), DirectiveName(), CurScope(nullptr),
- ConstructLoc(), OrderedRegion(false) {}
+ ConstructLoc(), OrderedRegion(false), AtomicClauseLoc() {}
};
typedef SmallVector<SharingMapTy, 64> StackTy;
@@ -207,6 +208,22 @@ public:
return false;
}
+ /// \brief Checks if the 'atomic' construct has explicitly specified 'read',
+ /// 'update', 'write' or 'capture' clause.
+ bool hasAtomicClause() const {
+ return Stack.back().AtomicClauseLoc.isValid();
+ }
+ /// \brief Gets location of explicitly specified clause for 'atomic'
+ /// construct.
+ SourceLocation getAtomicClauseLoc() const {
+ return Stack.back().AtomicClauseLoc;
+ }
+ /// \brief Sets location of explicitly specified clause for 'atomic'
+ /// directive.
+ void setAtomicClauseLoc(SourceLocation Loc) {
+ Stack.back().AtomicClauseLoc = Loc;
+ }
+
Scope *getCurScope() const { return Stack.back().CurScope; }
Scope *getCurScope() { return Stack.back().CurScope; }
SourceLocation getConstructLoc() { return Stack.back().ConstructLoc; }
@@ -2379,12 +2396,22 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
SourceLocation StartLoc,
SourceLocation EndLoc) {
assert(AStmt && isa<CapturedStmt>(AStmt) && "Captured statement expected");
+ auto CS = cast<CapturedStmt>(AStmt);
// 1.2.2 OpenMP Language Terminology
// Structured block - An executable statement with a single entry at the
// top and a single exit at the bottom.
// The point of exit cannot be a branch out of the structured block.
// longjmp() and throw() must not violate the entry/exit criteria.
// TODO further analysis of associated statements and clauses.
+ for (auto *C : Clauses) {
+ if (C->getClauseKind() == OMPC_read) {
+ if (!isa<Expr>(CS->getCapturedStmt())) {
+ Diag(CS->getCapturedStmt()->getLocStart(),
+ diag::err_omp_atomic_read_not_expression_statement);
+ return StmtError();
+ }
+ }
+ }
getCurFunction()->setHasBranchProtectedScope();
@@ -2430,6 +2457,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
case OMPC_mergeable:
case OMPC_threadprivate:
case OMPC_flush:
+ case OMPC_read:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -2633,6 +2661,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
case OMPC_mergeable:
case OMPC_threadprivate:
case OMPC_flush:
+ case OMPC_read:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -2748,6 +2777,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
case OMPC_mergeable:
case OMPC_threadprivate:
case OMPC_flush:
+ case OMPC_read:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -2827,6 +2857,9 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
case OMPC_mergeable:
Res = ActOnOpenMPMergeableClause(StartLoc, EndLoc);
break;
+ case OMPC_read:
+ Res = ActOnOpenMPReadClause(StartLoc, EndLoc);
+ break;
case OMPC_if:
case OMPC_final:
case OMPC_num_threads:
@@ -2873,6 +2906,12 @@ OMPClause *Sema::ActOnOpenMPMergeableClause(SourceLocation StartLoc,
return new (Context) OMPMergeableClause(StartLoc, EndLoc);
}
+OMPClause *Sema::ActOnOpenMPReadClause(SourceLocation StartLoc,
+ SourceLocation EndLoc) {
+ DSAStack->setAtomicClauseLoc(StartLoc);
+ return new (Context) OMPReadClause(StartLoc, EndLoc);
+}
+
OMPClause *Sema::ActOnOpenMPVarListClause(
OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr,
SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc,
@@ -2926,6 +2965,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(
case OMPC_untied:
case OMPC_mergeable:
case OMPC_threadprivate:
+ case OMPC_read:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -4226,5 +4266,3 @@ OMPClause *Sema::ActOnOpenMPFlushClause(ArrayRef<Expr *> VarList,
return OMPFlushClause::Create(Context, StartLoc, LParenLoc, EndLoc, VarList);
}
-
-#undef DSAStack
OpenPOWER on IntegriCloud