summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-06-24 12:55:56 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-06-24 12:55:56 +0000
commit9f4aa8c03413adc6d5946f33c39697c6961680f2 (patch)
tree6b12709d74899ce060a15e5a0937d3a2067ecb35 /include
parentb6cd35729cd0372420dd3fad9adcd1314ea53cf8 (diff)
downloadclang-9f4aa8c03413adc6d5946f33c39697c6961680f2.tar.gz
clang-9f4aa8c03413adc6d5946f33c39697c6961680f2.tar.bz2
clang-9f4aa8c03413adc6d5946f33c39697c6961680f2.tar.xz
[OPENMP] Additional checking for 'collapse' clause.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211589 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/AST/StmtOpenMP.h43
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td5
2 files changed, 45 insertions, 3 deletions
diff --git a/include/clang/AST/StmtOpenMP.h b/include/clang/AST/StmtOpenMP.h
index f8ba48ab05..70a914f999 100644
--- a/include/clang/AST/StmtOpenMP.h
+++ b/include/clang/AST/StmtOpenMP.h
@@ -67,8 +67,9 @@ protected:
OMPExecutableDirective(const T *, StmtClass SC, OpenMPDirectiveKind K,
SourceLocation StartLoc, SourceLocation EndLoc,
unsigned NumClauses, unsigned NumChildren)
- : Stmt(SC), Kind(K), StartLoc(StartLoc), EndLoc(EndLoc),
- NumClauses(NumClauses), NumChildren(NumChildren),
+ : Stmt(SC), Kind(K), StartLoc(std::move(StartLoc)),
+ EndLoc(std::move(EndLoc)), NumClauses(NumClauses),
+ NumChildren(NumChildren),
ClausesOffset(llvm::RoundUpToAlignment(sizeof(T),
llvm::alignOf<OMPClause *>())) {}
@@ -85,6 +86,44 @@ protected:
void setAssociatedStmt(Stmt *S) { *child_begin() = S; }
public:
+ /// \brief Iterates over a filtered subrange of clauses applied to a
+ /// directive.
+ ///
+ /// This iterator visits only those declarations that meet some run-time
+ /// criteria.
+ template <class FilterPredicate> class filtered_clause_iterator {
+ ArrayRef<OMPClause *>::const_iterator Current;
+ ArrayRef<OMPClause *>::const_iterator End;
+ void SkipToNextClause() {
+ while (Current != End && !FilterPredicate()(*Current))
+ ++Current;
+ }
+
+ public:
+ typedef const OMPClause *value_type;
+ filtered_clause_iterator() : Current(), End() {}
+ explicit filtered_clause_iterator(ArrayRef<OMPClause *> Arr)
+ : Current(Arr.begin()), End(Arr.end()) {
+ SkipToNextClause();
+ }
+ value_type operator*() const { return *Current; }
+ value_type operator->() const { return *Current; }
+ filtered_clause_iterator &operator++() {
+ ++Current;
+ SkipToNextClause();
+ return *this;
+ }
+
+ filtered_clause_iterator operator++(int) {
+ filtered_clause_iterator tmp(*this);
+ ++(*this);
+ return tmp;
+ }
+
+ bool operator!() { return Current == End; }
+ operator bool() { return Current != End; }
+ };
+
/// \brief Returns starting location of directive kind.
SourceLocation getLocStart() const { return StartLoc; }
/// \brief Returns ending location of directive.
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 98745ca9b8..a189330d57 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7020,7 +7020,10 @@ def note_omp_predetermined_dsa : Note<
def err_omp_loop_var_dsa : Error<
"loop iteration variable may not be %0">;
def err_omp_not_for : Error<
- "statement after '#pragma omp %0' must be a for loop">;
+ "%select{statement after '#pragma omp %1' must be a for loop|"
+ "expected %2 for loops after '#pragma omp %1'%select{|, but found only %4}3}0">;
+def note_omp_collapse_expr : Note<
+ "as specified in 'collapse' clause">;
def err_omp_negative_expression_in_clause : Error<
"argument to '%0' clause must be a positive integer value">;
def err_omp_not_integral : Error<