diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h --- a/clang/include/clang/AST/StmtOpenMP.h +++ b/clang/include/clang/AST/StmtOpenMP.h @@ -460,17 +460,22 @@ /// directive). Returns nullptr if no clause of this kind is associated with /// the directive. template - const SpecificClause *getSingleClause() const { - auto Clauses = getClausesOfKind(); + static const SpecificClause *getSingleClause(ArrayRef Clauses) { + auto ClausesOfKind = getClausesOfKind(Clauses); - if (Clauses.begin() != Clauses.end()) { - assert(std::next(Clauses.begin()) == Clauses.end() && + if (ClausesOfKind.begin() != ClausesOfKind.end()) { + assert(std::next(ClausesOfKind.begin()) == ClausesOfKind.end() && "There are at least 2 clauses of the specified kind"); - return *Clauses.begin(); + return *ClausesOfKind.begin(); } return nullptr; } + template + const SpecificClause *getSingleClause() const { + return getSingleClause(clauses()); + } + /// Returns true if the current directive has one or more clauses of a /// specific kind. template