summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-06-25 11:44:49 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-06-25 11:44:49 +0000
commit71f61a886646fca18a9dbed747ff34b0faa0dc98 (patch)
tree9cf6bd28790e4ce856530984d227bf1f316c5e71 /include
parentab6dc444704d6f49ebc9ed60cc9fec0ec034b384 (diff)
downloadclang-71f61a886646fca18a9dbed747ff34b0faa0dc98.tar.gz
clang-71f61a886646fca18a9dbed747ff34b0faa0dc98.tar.bz2
clang-71f61a886646fca18a9dbed747ff34b0faa0dc98.tar.xz
[OPENMP] Initial support for 'sections' directive.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211685 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang-c/Index.h6
-rw-r--r--include/clang/AST/DataRecursiveASTVisitor.h5
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h5
-rw-r--r--include/clang/AST/StmtOpenMP.h58
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--include/clang/Basic/OpenMPKinds.def12
-rw-r--r--include/clang/Basic/StmtNodes.td1
-rw-r--r--include/clang/Sema/Sema.h7
-rw-r--r--include/clang/Serialization/ASTBitCodes.h1
9 files changed, 95 insertions, 2 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 4deb60b1a5..567522e044 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -2143,7 +2143,11 @@ enum CXCursorKind {
*/
CXCursor_OMPForDirective = 234,
- CXCursor_LastStmt = CXCursor_OMPForDirective,
+ /** \brief OpenMP sections directive.
+ */
+ CXCursor_OMPSectionsDirective = 235,
+
+ CXCursor_LastStmt = CXCursor_OMPSectionsDirective,
/**
* \brief Cursor that represents the translation unit itself.
diff --git a/include/clang/AST/DataRecursiveASTVisitor.h b/include/clang/AST/DataRecursiveASTVisitor.h
index 9b902267ce..93a9d1d0d2 100644
--- a/include/clang/AST/DataRecursiveASTVisitor.h
+++ b/include/clang/AST/DataRecursiveASTVisitor.h
@@ -2290,6 +2290,11 @@ DEF_TRAVERSE_STMT(OMPForDirective, {
return false;
})
+DEF_TRAVERSE_STMT(OMPSectionsDirective, {
+ if (!TraverseOMPExecutableDirective(S))
+ return false;
+})
+
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index dcc5caf9ba..c9de9e318f 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -2312,6 +2312,11 @@ DEF_TRAVERSE_STMT(OMPForDirective, {
return false;
})
+DEF_TRAVERSE_STMT(OMPSectionsDirective, {
+ if (!TraverseOMPExecutableDirective(S))
+ return false;
+})
+
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
diff --git a/include/clang/AST/StmtOpenMP.h b/include/clang/AST/StmtOpenMP.h
index 7bf74eed8c..aca0274192 100644
--- a/include/clang/AST/StmtOpenMP.h
+++ b/include/clang/AST/StmtOpenMP.h
@@ -365,6 +365,64 @@ public:
}
};
+/// \brief This represents '#pragma omp sections' directive.
+///
+/// \code
+/// #pragma omp sections private(a,b) reduction(+:c,d)
+/// \endcode
+/// In this example directive '#pragma omp sections' has clauses 'private' with
+/// the variables 'a' and 'b' and 'reduction' with operator '+' and variables
+/// 'c' and 'd'.
+///
+class OMPSectionsDirective : public OMPExecutableDirective {
+ friend class ASTStmtReader;
+ /// \brief Build directive with the given start and end location.
+ ///
+ /// \param StartLoc Starting location of the directive kind.
+ /// \param EndLoc Ending location of the directive.
+ /// \param NumClauses Number of clauses.
+ ///
+ OMPSectionsDirective(SourceLocation StartLoc, SourceLocation EndLoc,
+ unsigned NumClauses)
+ : OMPExecutableDirective(this, OMPSectionsDirectiveClass, OMPD_sections,
+ StartLoc, EndLoc, NumClauses, 1) {}
+
+ /// \brief Build an empty directive.
+ ///
+ /// \param NumClauses Number of clauses.
+ ///
+ explicit OMPSectionsDirective(unsigned NumClauses)
+ : OMPExecutableDirective(this, OMPSectionsDirectiveClass, OMPD_sections,
+ SourceLocation(), SourceLocation(), NumClauses,
+ 1) {}
+
+public:
+ /// \brief Creates directive with a list of \a Clauses.
+ ///
+ /// \param C AST context.
+ /// \param StartLoc Starting location of the directive kind.
+ /// \param EndLoc Ending Location of the directive.
+ /// \param Clauses List of clauses.
+ /// \param AssociatedStmt Statement, associated with the directive.
+ ///
+ static OMPSectionsDirective *
+ Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
+ ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt);
+
+ /// \brief Creates an empty directive with the place for \a NumClauses
+ /// clauses.
+ ///
+ /// \param C AST context.
+ /// \param NumClauses Number of clauses.
+ ///
+ static OMPSectionsDirective *CreateEmpty(const ASTContext &C,
+ unsigned NumClauses, EmptyShell);
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == OMPSectionsDirectiveClass;
+ }
+};
+
} // end namespace clang
#endif
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index a189330d57..b240295e9c 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7104,6 +7104,8 @@ def err_omp_prohibited_region : Error<
"%select{|; perhaps you forget to enclose 'omp %3' directive into a parallel region?}2">;
def err_omp_prohibited_region_simd : Error<
"OpenMP constructs may not be nested inside a simd region">;
+def err_omp_sections_not_compound_stmt : Error<
+ "the statement for '#pragma omp sections' must be a compound statement">;
} // end of OpenMP category
let CategoryName = "Related Result Type Issue" in {
diff --git a/include/clang/Basic/OpenMPKinds.def b/include/clang/Basic/OpenMPKinds.def
index f6c213b759..312b975f26 100644
--- a/include/clang/Basic/OpenMPKinds.def
+++ b/include/clang/Basic/OpenMPKinds.def
@@ -27,6 +27,9 @@
#ifndef OPENMP_FOR_CLAUSE
# define OPENMP_FOR_CLAUSE(Name)
#endif
+#ifndef OPENMP_SECTIONS_CLAUSE
+# define OPENMP_SECTIONS_CLAUSE(Name)
+#endif
#ifndef OPENMP_DEFAULT_KIND
# define OPENMP_DEFAULT_KIND(Name)
#endif
@@ -43,6 +46,7 @@ OPENMP_DIRECTIVE(parallel)
OPENMP_DIRECTIVE(task)
OPENMP_DIRECTIVE(simd)
OPENMP_DIRECTIVE(for)
+OPENMP_DIRECTIVE(sections)
// OpenMP clauses.
OPENMP_CLAUSE(if, OMPIfClause)
@@ -92,6 +96,13 @@ OPENMP_FOR_CLAUSE(schedule)
OPENMP_FOR_CLAUSE(ordered)
OPENMP_FOR_CLAUSE(nowait)
+// Clauses allowed for OpenMP directive 'omp sections'.
+OPENMP_SECTIONS_CLAUSE(private)
+OPENMP_SECTIONS_CLAUSE(lastprivate)
+OPENMP_SECTIONS_CLAUSE(firstprivate)
+OPENMP_SECTIONS_CLAUSE(reduction)
+OPENMP_SECTIONS_CLAUSE(nowait)
+
// Static attributes for 'default' clause.
OPENMP_DEFAULT_KIND(none)
OPENMP_DEFAULT_KIND(shared)
@@ -113,6 +124,7 @@ OPENMP_SCHEDULE_KIND(runtime)
#undef OPENMP_DEFAULT_KIND
#undef OPENMP_DIRECTIVE
#undef OPENMP_CLAUSE
+#undef OPENMP_SECTIONS_CLAUSE
#undef OPENMP_PARALLEL_CLAUSE
#undef OPENMP_SIMD_CLAUSE
#undef OPENMP_FOR_CLAUSE
diff --git a/include/clang/Basic/StmtNodes.td b/include/clang/Basic/StmtNodes.td
index d04ba597a6..f4ff3ef20f 100644
--- a/include/clang/Basic/StmtNodes.td
+++ b/include/clang/Basic/StmtNodes.td
@@ -180,3 +180,4 @@ def OMPExecutableDirective : Stmt<1>;
def OMPParallelDirective : DStmt<OMPExecutableDirective>;
def OMPSimdDirective : DStmt<OMPExecutableDirective>;
def OMPForDirective : DStmt<OMPExecutableDirective>;
+def OMPSectionsDirective : DStmt<OMPExecutableDirective>;
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index fb1fe36304..cec318d055 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -7297,7 +7297,7 @@ public:
SourceLocation Loc,
ArrayRef<Expr *> VarList);
- // brief Initialization of captured region for OpenMP parallel region.
+ // brief Initialization of captured region for OpenMP region.
void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, SourceLocation Loc,
Scope *CurScope);
StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind,
@@ -7322,6 +7322,11 @@ public:
StmtResult ActOnOpenMPForDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
SourceLocation StartLoc,
SourceLocation EndLoc);
+ /// \brief Called on well-formed '\#pragma omp sections' after parsing
+ /// of the associated statement.
+ StmtResult ActOnOpenMPSectionsDirective(ArrayRef<OMPClause *> Clauses,
+ Stmt *AStmt, SourceLocation StartLoc,
+ SourceLocation EndLoc);
OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
Expr *Expr,
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h
index cd579ce1df..828672e3d6 100644
--- a/include/clang/Serialization/ASTBitCodes.h
+++ b/include/clang/Serialization/ASTBitCodes.h
@@ -1342,6 +1342,7 @@ namespace clang {
STMT_OMP_PARALLEL_DIRECTIVE,
STMT_OMP_SIMD_DIRECTIVE,
STMT_OMP_FOR_DIRECTIVE,
+ STMT_OMP_SECTIONS_DIRECTIVE,
// ARC
EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr