|
18 | 18 | #include "clang/AST/Decl.h"
|
19 | 19 | #include "clang/AST/Expr.h"
|
20 | 20 | #include "clang/AST/ExternalASTSource.h"
|
| 21 | +#include "clang/AST/OpenMPClause.h" |
21 | 22 | #include "clang/AST/Type.h"
|
22 | 23 | #include "llvm/ADT/ArrayRef.h"
|
23 | 24 | #include "llvm/Support/TrailingObjects.h"
|
@@ -239,6 +240,76 @@ class OMPCapturedExprDecl final : public VarDecl {
|
239 | 240 | static bool classofKind(Kind K) { return K == OMPCapturedExpr; }
|
240 | 241 | };
|
241 | 242 |
|
| 243 | +/// This represents '#pragma omp requires...' directive. |
| 244 | +/// For example |
| 245 | +/// |
| 246 | +/// \code |
| 247 | +/// #pragma omp requires unified_address |
| 248 | +/// \endcode |
| 249 | +/// |
| 250 | +class OMPRequiresDecl final |
| 251 | + : public Decl, |
| 252 | + private llvm::TrailingObjects<OMPRequiresDecl, OMPClause *> { |
| 253 | + friend class ASTDeclReader; |
| 254 | + friend TrailingObjects; |
| 255 | + |
| 256 | + // Number of clauses associated with this requires declaration |
| 257 | + unsigned NumClauses = 0; |
| 258 | + |
| 259 | + virtual void anchor(); |
| 260 | + |
| 261 | + OMPRequiresDecl(Kind DK, DeclContext *DC, SourceLocation L) |
| 262 | + : Decl(DK, DC, L), NumClauses(0) {} |
| 263 | + |
| 264 | + /// Returns an array of immutable clauses associated with this requires |
| 265 | + /// declaration |
| 266 | + ArrayRef<const OMPClause *> getClauses() const { |
| 267 | + return llvm::makeArrayRef(getTrailingObjects<OMPClause *>(), NumClauses); |
| 268 | + } |
| 269 | + |
| 270 | + /// Returns an array of clauses associated with this requires declaration |
| 271 | + MutableArrayRef<OMPClause *> getClauses() { |
| 272 | + return MutableArrayRef<OMPClause *>(getTrailingObjects<OMPClause *>(), |
| 273 | + NumClauses); |
| 274 | + } |
| 275 | + |
| 276 | + /// Sets an array of clauses to this requires declaration |
| 277 | + void setClauses(ArrayRef<OMPClause *> CL); |
| 278 | + |
| 279 | +public: |
| 280 | + /// Create requires node. |
| 281 | + static OMPRequiresDecl *Create(ASTContext &C, DeclContext *DC, |
| 282 | + SourceLocation L, ArrayRef<OMPClause *> CL); |
| 283 | + /// Create deserialized requires node. |
| 284 | + static OMPRequiresDecl *CreateDeserialized(ASTContext &C, unsigned ID, |
| 285 | + unsigned N); |
| 286 | + |
| 287 | + using clauselist_iterator = MutableArrayRef<OMPClause *>::iterator; |
| 288 | + using clauselist_const_iterator = ArrayRef<const OMPClause *>::iterator; |
| 289 | + using clauselist_range = llvm::iterator_range<clauselist_iterator>; |
| 290 | + using clauselist_const_range = llvm::iterator_range<clauselist_const_iterator>; |
| 291 | + |
| 292 | + unsigned clauselist_size() const { return NumClauses; } |
| 293 | + bool clauselist_empty() const { return NumClauses == 0; } |
| 294 | + |
| 295 | + clauselist_range clauselists() { |
| 296 | + return clauselist_range(clauselist_begin(), clauselist_end()); |
| 297 | + } |
| 298 | + clauselist_const_range clauselists() const { |
| 299 | + return clauselist_const_range(clauselist_begin(), clauselist_end()); |
| 300 | + } |
| 301 | + clauselist_iterator clauselist_begin() { return getClauses().begin(); } |
| 302 | + clauselist_iterator clauselist_end() { return getClauses().end(); } |
| 303 | + clauselist_const_iterator clauselist_begin() const { |
| 304 | + return getClauses().begin(); |
| 305 | + } |
| 306 | + clauselist_const_iterator clauselist_end() const { |
| 307 | + return getClauses().end(); |
| 308 | + } |
| 309 | + |
| 310 | + static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 311 | + static bool classofKind(Kind K) { return K == OMPRequires; } |
| 312 | +}; |
242 | 313 | } // end namespace clang
|
243 | 314 |
|
244 | 315 | #endif
|
0 commit comments