summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-07-24 06:46:57 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-07-24 06:46:57 +0000
commit459dec0ca2a765fc7fa6bc24b662a5e10df18e97 (patch)
treeeacd841808eb3ec53909056748ac2af85fcbd208 /clang/lib
parent65f8732c146f92a6960f352e12959b613d32e848 (diff)
downloadbcm5719-llvm-459dec0ca2a765fc7fa6bc24b662a5e10df18e97.tar.gz
bcm5719-llvm-459dec0ca2a765fc7fa6bc24b662a5e10df18e97.zip
[OPENMP] Initial parsing and sema analysis for clause 'capture' in 'atomic' directive.
llvm-svn: 213842
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/StmtPrinter.cpp4
-rw-r--r--clang/lib/AST/StmtProfile.cpp2
-rw-r--r--clang/lib/Basic/OpenMPKinds.cpp2
-rw-r--r--clang/lib/Parse/ParseOpenMP.cpp3
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp38
-rw-r--r--clang/lib/Sema/TreeTransform.h7
-rw-r--r--clang/lib/Serialization/ASTReaderStmt.cpp5
-rw-r--r--clang/lib/Serialization/ASTWriterStmt.cpp2
8 files changed, 55 insertions, 8 deletions
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 8e5018d4fae..887f2017424 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -673,6 +673,10 @@ void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *) {
OS << "update";
}
+void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {
+ OS << "capture";
+}
+
template<typename T>
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
for (typename T::varlist_iterator I = Node->varlist_begin(),
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index e4fcbef2e74..6d6e319bd34 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -316,6 +316,8 @@ void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
+void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
+
template<typename T>
void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
for (auto *I : Node->varlists())
diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 4520e62254f..b125586ed1a 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -111,6 +111,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind,
case OMPC_read:
case OMPC_write:
case OMPC_update:
+ case OMPC_capture:
break;
}
llvm_unreachable("Invalid OpenMP simple clause kind");
@@ -173,6 +174,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
case OMPC_read:
case OMPC_write:
case OMPC_update:
+ case OMPC_capture:
break;
}
llvm_unreachable("Invalid OpenMP simple clause kind");
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 024b1abe37c..6c8fd640f97 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -343,7 +343,7 @@ bool Parser::ParseOpenMPSimpleVarList(OpenMPDirectiveKind Kind,
/// lastprivate-clause | reduction-clause | proc_bind-clause |
/// schedule-clause | copyin-clause | copyprivate-clause | untied-clause |
/// mergeable-clause | flush-clause | read-clause | write-clause |
-/// update-clause
+/// update-clause | capture-clause
///
OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
OpenMPClauseKind CKind, bool FirstClause) {
@@ -412,6 +412,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
case OMPC_read:
case OMPC_write:
case OMPC_update:
+ case OMPC_capture:
// OpenMP [2.7.1, Restrictions, p. 9]
// Only one ordered clause can appear on a loop directive.
// OpenMP [2.7.1, Restrictions, C/C++, p. 4]
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 9c05e9204e6..5bbed680113 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2392,7 +2392,8 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
SourceLocation AtomicKindLoc;
for (auto *C : Clauses) {
if (C->getClauseKind() == OMPC_read || C->getClauseKind() == OMPC_write ||
- C->getClauseKind() == OMPC_update) {
+ C->getClauseKind() == OMPC_update ||
+ C->getClauseKind() == OMPC_capture) {
if (AtomicKind != OMPC_unknown) {
Diag(C->getLocStart(), diag::err_omp_atomic_several_clauses)
<< SourceRange(C->getLocStart(), C->getLocEnd());
@@ -2404,25 +2405,36 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
}
}
}
+ auto Body = CS->getCapturedStmt();
if (AtomicKind == OMPC_read) {
- if (!isa<Expr>(CS->getCapturedStmt())) {
- Diag(CS->getCapturedStmt()->getLocStart(),
+ if (!isa<Expr>(Body)) {
+ Diag(Body->getLocStart(),
diag::err_omp_atomic_read_not_expression_statement);
return StmtError();
}
} else if (AtomicKind == OMPC_write) {
- if (!isa<Expr>(CS->getCapturedStmt())) {
- Diag(CS->getCapturedStmt()->getLocStart(),
+ if (!isa<Expr>(Body)) {
+ Diag(Body->getLocStart(),
diag::err_omp_atomic_write_not_expression_statement);
return StmtError();
}
} else if (AtomicKind == OMPC_update || AtomicKind == OMPC_unknown) {
- if (!isa<Expr>(CS->getCapturedStmt())) {
- Diag(CS->getCapturedStmt()->getLocStart(),
+ if (!isa<Expr>(Body)) {
+ Diag(Body->getLocStart(),
diag::err_omp_atomic_update_not_expression_statement)
<< (AtomicKind == OMPC_update);
return StmtError();
}
+ } else if (AtomicKind == OMPC_capture) {
+ if (isa<Expr>(Body) && !isa<BinaryOperator>(Body)) {
+ Diag(Body->getLocStart(),
+ diag::err_omp_atomic_capture_not_expression_statement);
+ return StmtError();
+ } else if (!isa<Expr>(Body) && !isa<CompoundStmt>(Body)) {
+ Diag(Body->getLocStart(),
+ diag::err_omp_atomic_capture_not_compound_statement);
+ return StmtError();
+ }
}
getCurFunction()->setHasBranchProtectedScope();
@@ -2472,6 +2484,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
case OMPC_read:
case OMPC_write:
case OMPC_update:
+ case OMPC_capture:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -2677,6 +2690,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
case OMPC_read:
case OMPC_write:
case OMPC_update:
+ case OMPC_capture:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -2795,6 +2809,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
case OMPC_read:
case OMPC_write:
case OMPC_update:
+ case OMPC_capture:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
@@ -2883,6 +2898,9 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
case OMPC_update:
Res = ActOnOpenMPUpdateClause(StartLoc, EndLoc);
break;
+ case OMPC_capture:
+ Res = ActOnOpenMPCaptureClause(StartLoc, EndLoc);
+ break;
case OMPC_if:
case OMPC_final:
case OMPC_num_threads:
@@ -2944,6 +2962,11 @@ OMPClause *Sema::ActOnOpenMPUpdateClause(SourceLocation StartLoc,
return new (Context) OMPUpdateClause(StartLoc, EndLoc);
}
+OMPClause *Sema::ActOnOpenMPCaptureClause(SourceLocation StartLoc,
+ SourceLocation EndLoc) {
+ return new (Context) OMPCaptureClause(StartLoc, EndLoc);
+}
+
OMPClause *Sema::ActOnOpenMPVarListClause(
OpenMPClauseKind Kind, ArrayRef<Expr *> VarList, Expr *TailExpr,
SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc,
@@ -3000,6 +3023,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(
case OMPC_read:
case OMPC_write:
case OMPC_update:
+ case OMPC_capture:
case OMPC_unknown:
llvm_unreachable("Clause is not allowed.");
}
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 16a424e90ab..95b027a71c8 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6782,6 +6782,13 @@ TreeTransform<Derived>::TransformOMPUpdateClause(OMPUpdateClause *C) {
template <typename Derived>
OMPClause *
+TreeTransform<Derived>::TransformOMPCaptureClause(OMPCaptureClause *C) {
+ // No need to rebuild this clause, no template-dependent parameters.
+ return C;
+}
+
+template <typename Derived>
+OMPClause *
TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {
llvm::SmallVector<Expr *, 16> Vars;
Vars.reserve(C->varlist_size());
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index 78a4441a091..90987fe7ae9 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -1724,6 +1724,9 @@ OMPClause *OMPClauseReader::readClause() {
case OMPC_update:
C = new (Context) OMPUpdateClause();
break;
+ case OMPC_capture:
+ C = new (Context) OMPCaptureClause();
+ break;
case OMPC_private:
C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);
break;
@@ -1824,6 +1827,8 @@ void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {}
void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {}
+void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
+
void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
unsigned NumVars = C->varlist_size();
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 3b8dbea1695..0ce5dfde832 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1741,6 +1741,8 @@ void OMPClauseWriter::VisitOMPWriteClause(OMPWriteClause *) {}
void OMPClauseWriter::VisitOMPUpdateClause(OMPUpdateClause *) {}
+void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}
+
void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {
Record.push_back(C->varlist_size());
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
OpenPOWER on IntegriCloud