OpenMP: Data-sharing attributes analysis and clause 'shared' (fixed test threadprivate_messages.cpp)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190183 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 5e56b53..b83bd7f5 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -1111,6 +1111,16 @@
return false;
}
+StmtRange OMPClause::children() {
+ switch(getClauseKind()) {
+ default : break;
+#define OPENMP_CLAUSE(Name, Class) \
+ case OMPC_ ## Name : return static_cast<Class *>(this)->children();
+#include "clang/Basic/OpenMPKinds.def"
+ }
+ llvm_unreachable("unknown OMPClause");
+}
+
OMPPrivateClause *OMPPrivateClause::Create(const ASTContext &C,
SourceLocation StartLoc,
SourceLocation LParenLoc,
@@ -1131,6 +1141,26 @@
return new (Mem) OMPPrivateClause(N);
}
+OMPSharedClause *OMPSharedClause::Create(const ASTContext &C,
+ SourceLocation StartLoc,
+ SourceLocation LParenLoc,
+ SourceLocation EndLoc,
+ ArrayRef<Expr *> VL) {
+ void *Mem = C.Allocate(sizeof(OMPSharedClause) + sizeof(Expr *) * VL.size(),
+ llvm::alignOf<OMPSharedClause>());
+ OMPSharedClause *Clause = new (Mem) OMPSharedClause(StartLoc, LParenLoc,
+ EndLoc, VL.size());
+ Clause->setVarRefs(VL);
+ return Clause;
+}
+
+OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C,
+ unsigned N) {
+ void *Mem = C.Allocate(sizeof(OMPSharedClause) + sizeof(Expr *) * N,
+ llvm::alignOf<OMPSharedClause>());
+ return new (Mem) OMPSharedClause(N);
+}
+
void OMPExecutableDirective::setClauses(ArrayRef<OMPClause *> Clauses) {
assert(Clauses.size() == this->Clauses.size() &&
"Number of clauses is not the same as the preallocated buffer");
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index d59475e..98b56bc 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -614,6 +614,14 @@
}
}
+void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) {
+ if (!Node->varlist_empty()) {
+ OS << "shared";
+ PROCESS_OMP_CLAUSE_LIST(OMPSharedClause, Node, '(')
+ OS << ")";
+ }
+}
+
#undef PROCESS_OMP_CLAUSE_LIST
}
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp
index eb93c1d..77c34c4 100644
--- a/lib/AST/StmtProfile.cpp
+++ b/lib/AST/StmtProfile.cpp
@@ -272,6 +272,9 @@
void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
PROCESS_OMP_CLAUSE_LIST(OMPPrivateClause, C)
}
+void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
+ PROCESS_OMP_CLAUSE_LIST(OMPSharedClause, C)
+}
#undef PROCESS_OMP_CLAUSE_LIST
}