| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | #ifndef LLVM_CLANG_AST_DECLOPENMP_H |
| 15 | #define LLVM_CLANG_AST_DECLOPENMP_H |
| 16 | |
| 17 | #include "clang/AST/Decl.h" |
| 18 | #include "clang/AST/Expr.h" |
| 19 | #include "clang/AST/ExternalASTSource.h" |
| 20 | #include "clang/AST/OpenMPClause.h" |
| 21 | #include "clang/AST/Type.h" |
| 22 | #include "llvm/ADT/ArrayRef.h" |
| 23 | #include "llvm/Support/TrailingObjects.h" |
| 24 | |
| 25 | namespace clang { |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | class OMPThreadPrivateDecl final |
| 40 | : public Decl, |
| 41 | private llvm::TrailingObjects<OMPThreadPrivateDecl, Expr *> { |
| 42 | friend class ASTDeclReader; |
| 43 | friend TrailingObjects; |
| 44 | |
| 45 | unsigned NumVars; |
| 46 | |
| 47 | virtual void anchor(); |
| 48 | |
| 49 | OMPThreadPrivateDecl(Kind DK, DeclContext *DC, SourceLocation L) : |
| 50 | Decl(DK, DC, L), NumVars(0) { } |
| 51 | |
| 52 | ArrayRef<const Expr *> getVars() const { |
| 53 | return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumVars); |
| 54 | } |
| 55 | |
| 56 | MutableArrayRef<Expr *> getVars() { |
| 57 | return MutableArrayRef<Expr *>(getTrailingObjects<Expr *>(), NumVars); |
| 58 | } |
| 59 | |
| 60 | void setVars(ArrayRef<Expr *> VL); |
| 61 | |
| 62 | public: |
| 63 | static OMPThreadPrivateDecl *Create(ASTContext &C, DeclContext *DC, |
| 64 | SourceLocation L, |
| 65 | ArrayRef<Expr *> VL); |
| 66 | static OMPThreadPrivateDecl *CreateDeserialized(ASTContext &C, |
| 67 | unsigned ID, unsigned N); |
| 68 | |
| 69 | typedef MutableArrayRef<Expr *>::iterator varlist_iterator; |
| 70 | typedef ArrayRef<const Expr *>::iterator varlist_const_iterator; |
| 71 | typedef llvm::iterator_range<varlist_iterator> varlist_range; |
| 72 | typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range; |
| 73 | |
| 74 | unsigned varlist_size() const { return NumVars; } |
| 75 | bool varlist_empty() const { return NumVars == 0; } |
| 76 | |
| 77 | varlist_range varlists() { |
| 78 | return varlist_range(varlist_begin(), varlist_end()); |
| 79 | } |
| 80 | varlist_const_range varlists() const { |
| 81 | return varlist_const_range(varlist_begin(), varlist_end()); |
| 82 | } |
| 83 | varlist_iterator varlist_begin() { return getVars().begin(); } |
| 84 | varlist_iterator varlist_end() { return getVars().end(); } |
| 85 | varlist_const_iterator varlist_begin() const { return getVars().begin(); } |
| 86 | varlist_const_iterator varlist_end() const { return getVars().end(); } |
| 87 | |
| 88 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 89 | static bool classofKind(Kind K) { return K == OMPThreadPrivate; } |
| 90 | }; |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | class OMPDeclareReductionDecl final : public ValueDecl, public DeclContext { |
| 103 | |
| 104 | |
| 105 | public: |
| 106 | enum InitKind { |
| 107 | CallInit, |
| 108 | DirectInit, |
| 109 | CopyInit |
| 110 | }; |
| 111 | |
| 112 | private: |
| 113 | friend class ASTDeclReader; |
| 114 | |
| 115 | Expr *Combiner = nullptr; |
| 116 | |
| 117 | Expr *Initializer = nullptr; |
| 118 | |
| 119 | Expr *In = nullptr; |
| 120 | |
| 121 | Expr *Out = nullptr; |
| 122 | |
| 123 | Expr *Priv = nullptr; |
| 124 | |
| 125 | Expr *Orig = nullptr; |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | LazyDeclPtr PrevDeclInScope; |
| 131 | |
| 132 | virtual void anchor(); |
| 133 | |
| 134 | OMPDeclareReductionDecl(Kind DK, DeclContext *DC, SourceLocation L, |
| 135 | DeclarationName Name, QualType Ty, |
| 136 | OMPDeclareReductionDecl *PrevDeclInScope); |
| 137 | |
| 138 | void setPrevDeclInScope(OMPDeclareReductionDecl *Prev) { |
| 139 | PrevDeclInScope = Prev; |
| 140 | } |
| 141 | |
| 142 | public: |
| 143 | |
| 144 | static OMPDeclareReductionDecl * |
| 145 | Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, |
| 146 | QualType T, OMPDeclareReductionDecl *PrevDeclInScope); |
| 147 | |
| 148 | static OMPDeclareReductionDecl *CreateDeserialized(ASTContext &C, |
| 149 | unsigned ID); |
| 150 | |
| 151 | |
| 152 | Expr *getCombiner() { return Combiner; } |
| 153 | const Expr *getCombiner() const { return Combiner; } |
| 154 | |
| 155 | Expr *getCombinerIn() { return In; } |
| 156 | const Expr *getCombinerIn() const { return In; } |
| 157 | |
| 158 | Expr *getCombinerOut() { return Out; } |
| 159 | const Expr *getCombinerOut() const { return Out; } |
| 160 | |
| 161 | void setCombiner(Expr *E) { Combiner = E; } |
| 162 | |
| 163 | void setCombinerData(Expr *InE, Expr *OutE) { |
| 164 | In = InE; |
| 165 | Out = OutE; |
| 166 | } |
| 167 | |
| 168 | |
| 169 | |
| 170 | Expr *getInitializer() { return Initializer; } |
| 171 | const Expr *getInitializer() const { return Initializer; } |
| 172 | |
| 173 | InitKind getInitializerKind() const { |
| 174 | return static_cast<InitKind>(OMPDeclareReductionDeclBits.InitializerKind); |
| 175 | } |
| 176 | |
| 177 | Expr *getInitOrig() { return Orig; } |
| 178 | const Expr *getInitOrig() const { return Orig; } |
| 179 | |
| 180 | Expr *getInitPriv() { return Priv; } |
| 181 | const Expr *getInitPriv() const { return Priv; } |
| 182 | |
| 183 | void setInitializer(Expr *E, InitKind IK) { |
| 184 | Initializer = E; |
| 185 | OMPDeclareReductionDeclBits.InitializerKind = IK; |
| 186 | } |
| 187 | |
| 188 | void setInitializerData(Expr *OrigE, Expr *PrivE) { |
| 189 | Orig = OrigE; |
| 190 | Priv = PrivE; |
| 191 | } |
| 192 | |
| 193 | |
| 194 | |
| 195 | OMPDeclareReductionDecl *getPrevDeclInScope(); |
| 196 | const OMPDeclareReductionDecl *getPrevDeclInScope() const; |
| 197 | |
| 198 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 199 | static bool classofKind(Kind K) { return K == OMPDeclareReduction; } |
| 200 | static DeclContext *castToDeclContext(const OMPDeclareReductionDecl *D) { |
| 201 | return static_cast<DeclContext *>(const_cast<OMPDeclareReductionDecl *>(D)); |
| 202 | } |
| 203 | static OMPDeclareReductionDecl *castFromDeclContext(const DeclContext *DC) { |
| 204 | return static_cast<OMPDeclareReductionDecl *>( |
| 205 | const_cast<DeclContext *>(DC)); |
| 206 | } |
| 207 | }; |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | class OMPDeclareMapperDecl final : public ValueDecl, public DeclContext { |
| 218 | friend class ASTDeclReader; |
| 219 | |
| 220 | |
| 221 | MutableArrayRef<OMPClause *> Clauses; |
| 222 | |
| 223 | |
| 224 | Expr *MapperVarRef = nullptr; |
| 225 | |
| 226 | |
| 227 | DeclarationName VarName; |
| 228 | |
| 229 | LazyDeclPtr PrevDeclInScope; |
| 230 | |
| 231 | virtual void anchor(); |
| 232 | |
| 233 | OMPDeclareMapperDecl(Kind DK, DeclContext *DC, SourceLocation L, |
| 234 | DeclarationName Name, QualType Ty, |
| 235 | DeclarationName VarName, |
| 236 | OMPDeclareMapperDecl *PrevDeclInScope) |
| 237 | : ValueDecl(DK, DC, L, Name, Ty), DeclContext(DK), VarName(VarName), |
| 238 | PrevDeclInScope(PrevDeclInScope) {} |
| 239 | |
| 240 | void setPrevDeclInScope(OMPDeclareMapperDecl *Prev) { |
| 241 | PrevDeclInScope = Prev; |
| 242 | } |
| 243 | |
| 244 | |
| 245 | void setClauses(ArrayRef<OMPClause *> CL); |
| 246 | |
| 247 | public: |
| 248 | |
| 249 | static OMPDeclareMapperDecl *Create(ASTContext &C, DeclContext *DC, |
| 250 | SourceLocation L, DeclarationName Name, |
| 251 | QualType T, DeclarationName VarName, |
| 252 | OMPDeclareMapperDecl *PrevDeclInScope); |
| 253 | |
| 254 | static OMPDeclareMapperDecl *CreateDeserialized(ASTContext &C, unsigned ID, |
| 255 | unsigned N); |
| 256 | |
| 257 | |
| 258 | |
| 259 | void CreateClauses(ASTContext &C, ArrayRef<OMPClause *> CL); |
| 260 | |
| 261 | using clauselist_iterator = MutableArrayRef<OMPClause *>::iterator; |
| 262 | using clauselist_const_iterator = ArrayRef<const OMPClause *>::iterator; |
| 263 | using clauselist_range = llvm::iterator_range<clauselist_iterator>; |
| 264 | using clauselist_const_range = |
| 265 | llvm::iterator_range<clauselist_const_iterator>; |
| 266 | |
| 267 | unsigned clauselist_size() const { return Clauses.size(); } |
| 268 | bool clauselist_empty() const { return Clauses.empty(); } |
| 269 | |
| 270 | clauselist_range clauselists() { |
| 271 | return clauselist_range(clauselist_begin(), clauselist_end()); |
| 272 | } |
| 273 | clauselist_const_range clauselists() const { |
| 274 | return clauselist_const_range(clauselist_begin(), clauselist_end()); |
| 275 | } |
| 276 | clauselist_iterator clauselist_begin() { return Clauses.begin(); } |
| 277 | clauselist_iterator clauselist_end() { return Clauses.end(); } |
| 278 | clauselist_const_iterator clauselist_begin() const { return Clauses.begin(); } |
| 279 | clauselist_const_iterator clauselist_end() const { return Clauses.end(); } |
| 280 | |
| 281 | |
| 282 | Expr *getMapperVarRef() { return MapperVarRef; } |
| 283 | const Expr *getMapperVarRef() const { return MapperVarRef; } |
| 284 | |
| 285 | void setMapperVarRef(Expr *MapperVarRefE) { MapperVarRef = MapperVarRefE; } |
| 286 | |
| 287 | |
| 288 | DeclarationName getVarName() { return VarName; } |
| 289 | |
| 290 | |
| 291 | |
| 292 | OMPDeclareMapperDecl *getPrevDeclInScope(); |
| 293 | const OMPDeclareMapperDecl *getPrevDeclInScope() const; |
| 294 | |
| 295 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 296 | static bool classofKind(Kind K) { return K == OMPDeclareMapper; } |
| 297 | static DeclContext *castToDeclContext(const OMPDeclareMapperDecl *D) { |
| 298 | return static_cast<DeclContext *>(const_cast<OMPDeclareMapperDecl *>(D)); |
| 299 | } |
| 300 | static OMPDeclareMapperDecl *castFromDeclContext(const DeclContext *DC) { |
| 301 | return static_cast<OMPDeclareMapperDecl *>(const_cast<DeclContext *>(DC)); |
| 302 | } |
| 303 | }; |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | class OMPCapturedExprDecl final : public VarDecl { |
| 313 | friend class ASTDeclReader; |
| 314 | void anchor() override; |
| 315 | |
| 316 | OMPCapturedExprDecl(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, |
| 317 | QualType Type, TypeSourceInfo *TInfo, |
| 318 | SourceLocation StartLoc) |
| 319 | : VarDecl(OMPCapturedExpr, C, DC, StartLoc, StartLoc, Id, Type, TInfo, |
| 320 | SC_None) { |
| 321 | setImplicit(); |
| 322 | } |
| 323 | |
| 324 | public: |
| 325 | static OMPCapturedExprDecl *Create(ASTContext &C, DeclContext *DC, |
| 326 | IdentifierInfo *Id, QualType T, |
| 327 | SourceLocation StartLoc); |
| 328 | |
| 329 | static OMPCapturedExprDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
| 330 | |
| 331 | SourceRange getSourceRange() const override LLVM_READONLY; |
| 332 | |
| 333 | |
| 334 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 335 | static bool classofKind(Kind K) { return K == OMPCapturedExpr; } |
| 336 | }; |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | class OMPRequiresDecl final |
| 346 | : public Decl, |
| 347 | private llvm::TrailingObjects<OMPRequiresDecl, OMPClause *> { |
| 348 | friend class ASTDeclReader; |
| 349 | friend TrailingObjects; |
| 350 | |
| 351 | |
| 352 | unsigned NumClauses = 0; |
| 353 | |
| 354 | virtual void anchor(); |
| 355 | |
| 356 | OMPRequiresDecl(Kind DK, DeclContext *DC, SourceLocation L) |
| 357 | : Decl(DK, DC, L), NumClauses(0) {} |
| 358 | |
| 359 | |
| 360 | |
| 361 | ArrayRef<const OMPClause *> getClauses() const { |
| 362 | return llvm::makeArrayRef(getTrailingObjects<OMPClause *>(), NumClauses); |
| 363 | } |
| 364 | |
| 365 | |
| 366 | MutableArrayRef<OMPClause *> getClauses() { |
| 367 | return MutableArrayRef<OMPClause *>(getTrailingObjects<OMPClause *>(), |
| 368 | NumClauses); |
| 369 | } |
| 370 | |
| 371 | |
| 372 | void setClauses(ArrayRef<OMPClause *> CL); |
| 373 | |
| 374 | public: |
| 375 | |
| 376 | static OMPRequiresDecl *Create(ASTContext &C, DeclContext *DC, |
| 377 | SourceLocation L, ArrayRef<OMPClause *> CL); |
| 378 | |
| 379 | static OMPRequiresDecl *CreateDeserialized(ASTContext &C, unsigned ID, |
| 380 | unsigned N); |
| 381 | |
| 382 | using clauselist_iterator = MutableArrayRef<OMPClause *>::iterator; |
| 383 | using clauselist_const_iterator = ArrayRef<const OMPClause *>::iterator; |
| 384 | using clauselist_range = llvm::iterator_range<clauselist_iterator>; |
| 385 | using clauselist_const_range = llvm::iterator_range<clauselist_const_iterator>; |
| 386 | |
| 387 | unsigned clauselist_size() const { return NumClauses; } |
| 388 | bool clauselist_empty() const { return NumClauses == 0; } |
| 389 | |
| 390 | clauselist_range clauselists() { |
| 391 | return clauselist_range(clauselist_begin(), clauselist_end()); |
| 392 | } |
| 393 | clauselist_const_range clauselists() const { |
| 394 | return clauselist_const_range(clauselist_begin(), clauselist_end()); |
| 395 | } |
| 396 | clauselist_iterator clauselist_begin() { return getClauses().begin(); } |
| 397 | clauselist_iterator clauselist_end() { return getClauses().end(); } |
| 398 | clauselist_const_iterator clauselist_begin() const { |
| 399 | return getClauses().begin(); |
| 400 | } |
| 401 | clauselist_const_iterator clauselist_end() const { |
| 402 | return getClauses().end(); |
| 403 | } |
| 404 | |
| 405 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 406 | static bool classofKind(Kind K) { return K == OMPRequires; } |
| 407 | }; |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | class OMPAllocateDecl final |
| 423 | : public Decl, |
| 424 | private llvm::TrailingObjects<OMPAllocateDecl, Expr *, OMPClause *> { |
| 425 | friend class ASTDeclReader; |
| 426 | friend TrailingObjects; |
| 427 | |
| 428 | |
| 429 | unsigned NumVars = 0; |
| 430 | |
| 431 | unsigned NumClauses = 0; |
| 432 | |
| 433 | size_t numTrailingObjects(OverloadToken<Expr *>) const { |
| 434 | return NumVars; |
| 435 | } |
| 436 | size_t numTrailingObjects(OverloadToken<OMPClause *>) const { |
| 437 | return NumClauses; |
| 438 | } |
| 439 | |
| 440 | virtual void anchor(); |
| 441 | |
| 442 | OMPAllocateDecl(Kind DK, DeclContext *DC, SourceLocation L) |
| 443 | : Decl(DK, DC, L) {} |
| 444 | |
| 445 | ArrayRef<const Expr *> getVars() const { |
| 446 | return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumVars); |
| 447 | } |
| 448 | |
| 449 | MutableArrayRef<Expr *> getVars() { |
| 450 | return MutableArrayRef<Expr *>(getTrailingObjects<Expr *>(), NumVars); |
| 451 | } |
| 452 | |
| 453 | void setVars(ArrayRef<Expr *> VL); |
| 454 | |
| 455 | |
| 456 | ArrayRef<OMPClause *> getClauses() const { |
| 457 | return llvm::makeArrayRef(getTrailingObjects<OMPClause *>(), NumClauses); |
| 458 | } |
| 459 | |
| 460 | |
| 461 | MutableArrayRef<OMPClause *> getClauses() { |
| 462 | return MutableArrayRef<OMPClause *>(getTrailingObjects<OMPClause *>(), |
| 463 | NumClauses); |
| 464 | } |
| 465 | |
| 466 | |
| 467 | void setClauses(ArrayRef<OMPClause *> CL); |
| 468 | |
| 469 | public: |
| 470 | static OMPAllocateDecl *Create(ASTContext &C, DeclContext *DC, |
| 471 | SourceLocation L, ArrayRef<Expr *> VL, |
| 472 | ArrayRef<OMPClause *> CL); |
| 473 | static OMPAllocateDecl *CreateDeserialized(ASTContext &C, unsigned ID, |
| 474 | unsigned NVars, unsigned NClauses); |
| 475 | |
| 476 | typedef MutableArrayRef<Expr *>::iterator varlist_iterator; |
| 477 | typedef ArrayRef<const Expr *>::iterator varlist_const_iterator; |
| 478 | typedef llvm::iterator_range<varlist_iterator> varlist_range; |
| 479 | typedef llvm::iterator_range<varlist_const_iterator> varlist_const_range; |
| 480 | using clauselist_iterator = MutableArrayRef<OMPClause *>::iterator; |
| 481 | using clauselist_const_iterator = ArrayRef<const OMPClause *>::iterator; |
| 482 | using clauselist_range = llvm::iterator_range<clauselist_iterator>; |
| 483 | using clauselist_const_range = llvm::iterator_range<clauselist_const_iterator>; |
| 484 | |
| 485 | |
| 486 | unsigned varlist_size() const { return NumVars; } |
| 487 | bool varlist_empty() const { return NumVars == 0; } |
| 488 | unsigned clauselist_size() const { return NumClauses; } |
| 489 | bool clauselist_empty() const { return NumClauses == 0; } |
| 490 | |
| 491 | varlist_range varlists() { |
| 492 | return varlist_range(varlist_begin(), varlist_end()); |
| 493 | } |
| 494 | varlist_const_range varlists() const { |
| 495 | return varlist_const_range(varlist_begin(), varlist_end()); |
| 496 | } |
| 497 | varlist_iterator varlist_begin() { return getVars().begin(); } |
| 498 | varlist_iterator varlist_end() { return getVars().end(); } |
| 499 | varlist_const_iterator varlist_begin() const { return getVars().begin(); } |
| 500 | varlist_const_iterator varlist_end() const { return getVars().end(); } |
| 501 | |
| 502 | clauselist_range clauselists() { |
| 503 | return clauselist_range(clauselist_begin(), clauselist_end()); |
| 504 | } |
| 505 | clauselist_const_range clauselists() const { |
| 506 | return clauselist_const_range(clauselist_begin(), clauselist_end()); |
| 507 | } |
| 508 | clauselist_iterator clauselist_begin() { return getClauses().begin(); } |
| 509 | clauselist_iterator clauselist_end() { return getClauses().end(); } |
| 510 | clauselist_const_iterator clauselist_begin() const { |
| 511 | return getClauses().begin(); |
| 512 | } |
| 513 | clauselist_const_iterator clauselist_end() const { |
| 514 | return getClauses().end(); |
| 515 | } |
| 516 | |
| 517 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 518 | static bool classofKind(Kind K) { return K == OMPAllocate; } |
| 519 | }; |
| 520 | |
| 521 | } |
| 522 | |
| 523 | #endif |
| 524 | |