1 //===--- OpenMPClause.cpp - Classes for OpenMP clauses --------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file implements the subclesses of Stmt class declared in OpenMPClause.h 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "clang/AST/OpenMPClause.h" 15 16 #include "clang/AST/ASTContext.h" 17 18 using namespace clang; 19 20 OMPClause::child_range OMPClause::children() { 21 switch (getClauseKind()) { 22 default: 23 break; 24 #define OPENMP_CLAUSE(Name, Class) \ 25 case OMPC_##Name: \ 26 return static_cast<Class *>(this)->children(); 27 #include "clang/Basic/OpenMPKinds.def" 28 } 29 llvm_unreachable("unknown OMPClause"); 30 } 31 32 OMPClauseWithPreInit *OMPClauseWithPreInit::get(OMPClause *C) { 33 auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C)); 34 return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr; 35 } 36 37 const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) { 38 switch (C->getClauseKind()) { 39 case OMPC_schedule: 40 return static_cast<const OMPScheduleClause *>(C); 41 case OMPC_dist_schedule: 42 return static_cast<const OMPDistScheduleClause *>(C); 43 case OMPC_firstprivate: 44 return static_cast<const OMPFirstprivateClause *>(C); 45 case OMPC_lastprivate: 46 return static_cast<const OMPLastprivateClause *>(C); 47 case OMPC_reduction: 48 return static_cast<const OMPReductionClause *>(C); 49 case OMPC_linear: 50 return static_cast<const OMPLinearClause *>(C); 51 case OMPC_default: 52 case OMPC_proc_bind: 53 case OMPC_if: 54 case OMPC_final: 55 case OMPC_num_threads: 56 case OMPC_safelen: 57 case OMPC_simdlen: 58 case OMPC_collapse: 59 case OMPC_private: 60 case OMPC_shared: 61 case OMPC_aligned: 62 case OMPC_copyin: 63 case OMPC_copyprivate: 64 case OMPC_ordered: 65 case OMPC_nowait: 66 case OMPC_untied: 67 case OMPC_mergeable: 68 case OMPC_threadprivate: 69 case OMPC_flush: 70 case OMPC_read: 71 case OMPC_write: 72 case OMPC_update: 73 case OMPC_capture: 74 case OMPC_seq_cst: 75 case OMPC_depend: 76 case OMPC_device: 77 case OMPC_threads: 78 case OMPC_simd: 79 case OMPC_map: 80 case OMPC_num_teams: 81 case OMPC_thread_limit: 82 case OMPC_priority: 83 case OMPC_grainsize: 84 case OMPC_nogroup: 85 case OMPC_num_tasks: 86 case OMPC_hint: 87 case OMPC_defaultmap: 88 case OMPC_unknown: 89 break; 90 } 91 92 return nullptr; 93 } 94 95 OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(OMPClause *C) { 96 auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C)); 97 return Res ? const_cast<OMPClauseWithPostUpdate *>(Res) : nullptr; 98 } 99 100 const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C) { 101 switch (C->getClauseKind()) { 102 case OMPC_lastprivate: 103 return static_cast<const OMPLastprivateClause *>(C); 104 case OMPC_reduction: 105 return static_cast<const OMPReductionClause *>(C); 106 case OMPC_linear: 107 return static_cast<const OMPLinearClause *>(C); 108 case OMPC_schedule: 109 case OMPC_dist_schedule: 110 case OMPC_firstprivate: 111 case OMPC_default: 112 case OMPC_proc_bind: 113 case OMPC_if: 114 case OMPC_final: 115 case OMPC_num_threads: 116 case OMPC_safelen: 117 case OMPC_simdlen: 118 case OMPC_collapse: 119 case OMPC_private: 120 case OMPC_shared: 121 case OMPC_aligned: 122 case OMPC_copyin: 123 case OMPC_copyprivate: 124 case OMPC_ordered: 125 case OMPC_nowait: 126 case OMPC_untied: 127 case OMPC_mergeable: 128 case OMPC_threadprivate: 129 case OMPC_flush: 130 case OMPC_read: 131 case OMPC_write: 132 case OMPC_update: 133 case OMPC_capture: 134 case OMPC_seq_cst: 135 case OMPC_depend: 136 case OMPC_device: 137 case OMPC_threads: 138 case OMPC_simd: 139 case OMPC_map: 140 case OMPC_num_teams: 141 case OMPC_thread_limit: 142 case OMPC_priority: 143 case OMPC_grainsize: 144 case OMPC_nogroup: 145 case OMPC_num_tasks: 146 case OMPC_hint: 147 case OMPC_defaultmap: 148 case OMPC_unknown: 149 break; 150 } 151 152 return nullptr; 153 } 154 155 void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) { 156 assert(VL.size() == varlist_size() && 157 "Number of private copies is not the same as the preallocated buffer"); 158 std::copy(VL.begin(), VL.end(), varlist_end()); 159 } 160 161 OMPPrivateClause * 162 OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc, 163 SourceLocation LParenLoc, SourceLocation EndLoc, 164 ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) { 165 // Allocate space for private variables and initializer expressions. 166 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size())); 167 OMPPrivateClause *Clause = 168 new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); 169 Clause->setVarRefs(VL); 170 Clause->setPrivateCopies(PrivateVL); 171 return Clause; 172 } 173 174 OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C, 175 unsigned N) { 176 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N)); 177 return new (Mem) OMPPrivateClause(N); 178 } 179 180 void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) { 181 assert(VL.size() == varlist_size() && 182 "Number of private copies is not the same as the preallocated buffer"); 183 std::copy(VL.begin(), VL.end(), varlist_end()); 184 } 185 186 void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) { 187 assert(VL.size() == varlist_size() && 188 "Number of inits is not the same as the preallocated buffer"); 189 std::copy(VL.begin(), VL.end(), getPrivateCopies().end()); 190 } 191 192 OMPFirstprivateClause * 193 OMPFirstprivateClause::Create(const ASTContext &C, SourceLocation StartLoc, 194 SourceLocation LParenLoc, SourceLocation EndLoc, 195 ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL, 196 ArrayRef<Expr *> InitVL, Stmt *PreInit) { 197 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size())); 198 OMPFirstprivateClause *Clause = 199 new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); 200 Clause->setVarRefs(VL); 201 Clause->setPrivateCopies(PrivateVL); 202 Clause->setInits(InitVL); 203 Clause->setPreInitStmt(PreInit); 204 return Clause; 205 } 206 207 OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C, 208 unsigned N) { 209 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N)); 210 return new (Mem) OMPFirstprivateClause(N); 211 } 212 213 void OMPLastprivateClause::setPrivateCopies(ArrayRef<Expr *> PrivateCopies) { 214 assert(PrivateCopies.size() == varlist_size() && 215 "Number of private copies is not the same as the preallocated buffer"); 216 std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end()); 217 } 218 219 void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) { 220 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " 221 "not the same as the " 222 "preallocated buffer"); 223 std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end()); 224 } 225 226 void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { 227 assert(DstExprs.size() == varlist_size() && "Number of destination " 228 "expressions is not the same as " 229 "the preallocated buffer"); 230 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); 231 } 232 233 void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { 234 assert(AssignmentOps.size() == varlist_size() && 235 "Number of assignment expressions is not the same as the preallocated " 236 "buffer"); 237 std::copy(AssignmentOps.begin(), AssignmentOps.end(), 238 getDestinationExprs().end()); 239 } 240 241 OMPLastprivateClause *OMPLastprivateClause::Create( 242 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, 243 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, 244 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps, Stmt *PreInit, 245 Expr *PostUpdate) { 246 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size())); 247 OMPLastprivateClause *Clause = 248 new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); 249 Clause->setVarRefs(VL); 250 Clause->setSourceExprs(SrcExprs); 251 Clause->setDestinationExprs(DstExprs); 252 Clause->setAssignmentOps(AssignmentOps); 253 Clause->setPreInitStmt(PreInit); 254 Clause->setPostUpdateExpr(PostUpdate); 255 return Clause; 256 } 257 258 OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(const ASTContext &C, 259 unsigned N) { 260 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N)); 261 return new (Mem) OMPLastprivateClause(N); 262 } 263 264 OMPSharedClause *OMPSharedClause::Create(const ASTContext &C, 265 SourceLocation StartLoc, 266 SourceLocation LParenLoc, 267 SourceLocation EndLoc, 268 ArrayRef<Expr *> VL) { 269 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); 270 OMPSharedClause *Clause = 271 new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size()); 272 Clause->setVarRefs(VL); 273 return Clause; 274 } 275 276 OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, unsigned N) { 277 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); 278 return new (Mem) OMPSharedClause(N); 279 } 280 281 void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) { 282 assert(PL.size() == varlist_size() && 283 "Number of privates is not the same as the preallocated buffer"); 284 std::copy(PL.begin(), PL.end(), varlist_end()); 285 } 286 287 void OMPLinearClause::setInits(ArrayRef<Expr *> IL) { 288 assert(IL.size() == varlist_size() && 289 "Number of inits is not the same as the preallocated buffer"); 290 std::copy(IL.begin(), IL.end(), getPrivates().end()); 291 } 292 293 void OMPLinearClause::setUpdates(ArrayRef<Expr *> UL) { 294 assert(UL.size() == varlist_size() && 295 "Number of updates is not the same as the preallocated buffer"); 296 std::copy(UL.begin(), UL.end(), getInits().end()); 297 } 298 299 void OMPLinearClause::setFinals(ArrayRef<Expr *> FL) { 300 assert(FL.size() == varlist_size() && 301 "Number of final updates is not the same as the preallocated buffer"); 302 std::copy(FL.begin(), FL.end(), getUpdates().end()); 303 } 304 305 OMPLinearClause *OMPLinearClause::Create( 306 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, 307 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, 308 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, 309 ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep, 310 Stmt *PreInit, Expr *PostUpdate) { 311 // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions 312 // (Step and CalcStep). 313 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2)); 314 OMPLinearClause *Clause = new (Mem) OMPLinearClause( 315 StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size()); 316 Clause->setVarRefs(VL); 317 Clause->setPrivates(PL); 318 Clause->setInits(IL); 319 // Fill update and final expressions with zeroes, they are provided later, 320 // after the directive construction. 321 std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(), 322 nullptr); 323 std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(), 324 nullptr); 325 Clause->setStep(Step); 326 Clause->setCalcStep(CalcStep); 327 Clause->setPreInitStmt(PreInit); 328 Clause->setPostUpdateExpr(PostUpdate); 329 return Clause; 330 } 331 332 OMPLinearClause *OMPLinearClause::CreateEmpty(const ASTContext &C, 333 unsigned NumVars) { 334 // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions 335 // (Step and CalcStep). 336 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2)); 337 return new (Mem) OMPLinearClause(NumVars); 338 } 339 340 OMPAlignedClause * 341 OMPAlignedClause::Create(const ASTContext &C, SourceLocation StartLoc, 342 SourceLocation LParenLoc, SourceLocation ColonLoc, 343 SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) { 344 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1)); 345 OMPAlignedClause *Clause = new (Mem) 346 OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size()); 347 Clause->setVarRefs(VL); 348 Clause->setAlignment(A); 349 return Clause; 350 } 351 352 OMPAlignedClause *OMPAlignedClause::CreateEmpty(const ASTContext &C, 353 unsigned NumVars) { 354 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1)); 355 return new (Mem) OMPAlignedClause(NumVars); 356 } 357 358 void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) { 359 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " 360 "not the same as the " 361 "preallocated buffer"); 362 std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end()); 363 } 364 365 void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { 366 assert(DstExprs.size() == varlist_size() && "Number of destination " 367 "expressions is not the same as " 368 "the preallocated buffer"); 369 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); 370 } 371 372 void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { 373 assert(AssignmentOps.size() == varlist_size() && 374 "Number of assignment expressions is not the same as the preallocated " 375 "buffer"); 376 std::copy(AssignmentOps.begin(), AssignmentOps.end(), 377 getDestinationExprs().end()); 378 } 379 380 OMPCopyinClause *OMPCopyinClause::Create( 381 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, 382 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, 383 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) { 384 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size())); 385 OMPCopyinClause *Clause = 386 new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size()); 387 Clause->setVarRefs(VL); 388 Clause->setSourceExprs(SrcExprs); 389 Clause->setDestinationExprs(DstExprs); 390 Clause->setAssignmentOps(AssignmentOps); 391 return Clause; 392 } 393 394 OMPCopyinClause *OMPCopyinClause::CreateEmpty(const ASTContext &C, unsigned N) { 395 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N)); 396 return new (Mem) OMPCopyinClause(N); 397 } 398 399 void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) { 400 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " 401 "not the same as the " 402 "preallocated buffer"); 403 std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end()); 404 } 405 406 void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { 407 assert(DstExprs.size() == varlist_size() && "Number of destination " 408 "expressions is not the same as " 409 "the preallocated buffer"); 410 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); 411 } 412 413 void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { 414 assert(AssignmentOps.size() == varlist_size() && 415 "Number of assignment expressions is not the same as the preallocated " 416 "buffer"); 417 std::copy(AssignmentOps.begin(), AssignmentOps.end(), 418 getDestinationExprs().end()); 419 } 420 421 OMPCopyprivateClause *OMPCopyprivateClause::Create( 422 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, 423 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, 424 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) { 425 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size())); 426 OMPCopyprivateClause *Clause = 427 new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); 428 Clause->setVarRefs(VL); 429 Clause->setSourceExprs(SrcExprs); 430 Clause->setDestinationExprs(DstExprs); 431 Clause->setAssignmentOps(AssignmentOps); 432 return Clause; 433 } 434 435 OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C, 436 unsigned N) { 437 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N)); 438 return new (Mem) OMPCopyprivateClause(N); 439 } 440 441 void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) { 442 assert(Privates.size() == varlist_size() && 443 "Number of private copies is not the same as the preallocated buffer"); 444 std::copy(Privates.begin(), Privates.end(), varlist_end()); 445 } 446 447 void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) { 448 assert( 449 LHSExprs.size() == varlist_size() && 450 "Number of LHS expressions is not the same as the preallocated buffer"); 451 std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end()); 452 } 453 454 void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) { 455 assert( 456 RHSExprs.size() == varlist_size() && 457 "Number of RHS expressions is not the same as the preallocated buffer"); 458 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end()); 459 } 460 461 void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) { 462 assert(ReductionOps.size() == varlist_size() && "Number of reduction " 463 "expressions is not the same " 464 "as the preallocated buffer"); 465 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end()); 466 } 467 468 OMPReductionClause *OMPReductionClause::Create( 469 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, 470 SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL, 471 NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, 472 ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs, 473 ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit, 474 Expr *PostUpdate) { 475 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size())); 476 OMPReductionClause *Clause = new (Mem) OMPReductionClause( 477 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo); 478 Clause->setVarRefs(VL); 479 Clause->setPrivates(Privates); 480 Clause->setLHSExprs(LHSExprs); 481 Clause->setRHSExprs(RHSExprs); 482 Clause->setReductionOps(ReductionOps); 483 Clause->setPreInitStmt(PreInit); 484 Clause->setPostUpdateExpr(PostUpdate); 485 return Clause; 486 } 487 488 OMPReductionClause *OMPReductionClause::CreateEmpty(const ASTContext &C, 489 unsigned N) { 490 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N)); 491 return new (Mem) OMPReductionClause(N); 492 } 493 494 OMPFlushClause *OMPFlushClause::Create(const ASTContext &C, 495 SourceLocation StartLoc, 496 SourceLocation LParenLoc, 497 SourceLocation EndLoc, 498 ArrayRef<Expr *> VL) { 499 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); 500 OMPFlushClause *Clause = 501 new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size()); 502 Clause->setVarRefs(VL); 503 return Clause; 504 } 505 506 OMPFlushClause *OMPFlushClause::CreateEmpty(const ASTContext &C, unsigned N) { 507 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); 508 return new (Mem) OMPFlushClause(N); 509 } 510 511 OMPDependClause * 512 OMPDependClause::Create(const ASTContext &C, SourceLocation StartLoc, 513 SourceLocation LParenLoc, SourceLocation EndLoc, 514 OpenMPDependClauseKind DepKind, SourceLocation DepLoc, 515 SourceLocation ColonLoc, ArrayRef<Expr *> VL) { 516 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); 517 OMPDependClause *Clause = 518 new (Mem) OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size()); 519 Clause->setVarRefs(VL); 520 Clause->setDependencyKind(DepKind); 521 Clause->setDependencyLoc(DepLoc); 522 Clause->setColonLoc(ColonLoc); 523 return Clause; 524 } 525 526 OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &C, unsigned N) { 527 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); 528 return new (Mem) OMPDependClause(N); 529 } 530 531 OMPMapClause *OMPMapClause::Create(const ASTContext &C, SourceLocation StartLoc, 532 SourceLocation LParenLoc, 533 SourceLocation EndLoc, ArrayRef<Expr *> VL, 534 OpenMPMapClauseKind TypeModifier, 535 OpenMPMapClauseKind Type, 536 bool TypeIsImplicit, 537 SourceLocation TypeLoc) { 538 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); 539 OMPMapClause *Clause = 540 new (Mem) OMPMapClause(TypeModifier, Type, TypeIsImplicit, TypeLoc, 541 StartLoc, LParenLoc, EndLoc, VL.size()); 542 Clause->setVarRefs(VL); 543 Clause->setMapTypeModifier(TypeModifier); 544 Clause->setMapType(Type); 545 Clause->setMapLoc(TypeLoc); 546 return Clause; 547 } 548 549 OMPMapClause *OMPMapClause::CreateEmpty(const ASTContext &C, unsigned N) { 550 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); 551 return new (Mem) OMPMapClause(N); 552 } 553