1 //===----- SemaOpenMP.h -- Semantic Analysis for OpenMP constructs -------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 /// \file 9 /// This file declares semantic analysis for OpenMP constructs and 10 /// clauses. 11 /// 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_CLANG_SEMA_SEMAOPENMP_H 15 #define LLVM_CLANG_SEMA_SEMAOPENMP_H 16 17 #include "clang/AST/ASTFwd.h" 18 #include "clang/AST/Attr.h" 19 #include "clang/AST/DeclarationName.h" 20 #include "clang/AST/ExprOpenMP.h" 21 #include "clang/AST/OpenMPClause.h" 22 #include "clang/AST/StmtOpenMP.h" 23 #include "clang/Basic/IdentifierTable.h" 24 #include "clang/Basic/LLVM.h" 25 #include "clang/Basic/OpenMPKinds.h" 26 #include "clang/Basic/SourceLocation.h" 27 #include "clang/Basic/Specifiers.h" 28 #include "clang/Sema/DeclSpec.h" 29 #include "clang/Sema/Ownership.h" 30 #include "clang/Sema/SemaBase.h" 31 #include "llvm/ADT/DenseMap.h" 32 #include "llvm/Frontend/OpenMP/OMP.h.inc" 33 #include "llvm/Frontend/OpenMP/OMPConstants.h" 34 #include <optional> 35 #include <string> 36 #include <utility> 37 38 namespace clang { 39 namespace sema { 40 class FunctionScopeInfo; 41 } // namespace sema 42 43 class DeclContext; 44 class DeclGroupRef; 45 class ParsedAttr; 46 class Scope; 47 48 class SemaOpenMP : public SemaBase { 49 public: 50 SemaOpenMP(Sema &S); 51 52 friend class Parser; 53 friend class Sema; 54 55 using DeclGroupPtrTy = OpaquePtr<DeclGroupRef>; 56 using CapturedParamNameType = std::pair<StringRef, QualType>; 57 58 /// Creates a SemaDiagnosticBuilder that emits the diagnostic if the current 59 /// context is "used as device code". 60 /// 61 /// - If CurContext is a `declare target` function or it is known that the 62 /// function is emitted for the device, emits the diagnostics immediately. 63 /// - If CurContext is a non-`declare target` function and we are compiling 64 /// for the device, creates a diagnostic which is emitted if and when we 65 /// realize that the function will be codegen'ed. 66 /// 67 /// Example usage: 68 /// 69 /// // Variable-length arrays are not allowed in NVPTX device code. 70 /// if (diagIfOpenMPDeviceCode(Loc, diag::err_vla_unsupported)) 71 /// return ExprError(); 72 /// // Otherwise, continue parsing as normal. 73 SemaDiagnosticBuilder diagIfOpenMPDeviceCode(SourceLocation Loc, 74 unsigned DiagID, 75 const FunctionDecl *FD); 76 77 /// Creates a SemaDiagnosticBuilder that emits the diagnostic if the current 78 /// context is "used as host code". 79 /// 80 /// - If CurContext is a `declare target` function or it is known that the 81 /// function is emitted for the host, emits the diagnostics immediately. 82 /// - If CurContext is a non-host function, just ignore it. 83 /// 84 /// Example usage: 85 /// 86 /// // Variable-length arrays are not allowed in NVPTX device code. 87 /// if (diagIfOpenMPHostode(Loc, diag::err_vla_unsupported)) 88 /// return ExprError(); 89 /// // Otherwise, continue parsing as normal. 90 SemaDiagnosticBuilder diagIfOpenMPHostCode(SourceLocation Loc, 91 unsigned DiagID, 92 const FunctionDecl *FD); 93 94 /// The declarator \p D defines a function in the scope \p S which is nested 95 /// in an `omp begin/end declare variant` scope. In this method we create a 96 /// declaration for \p D and rename \p D according to the OpenMP context 97 /// selector of the surrounding scope. Return all base functions in \p Bases. 98 void ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope( 99 Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, 100 SmallVectorImpl<FunctionDecl *> &Bases); 101 102 /// Register \p D as specialization of all base functions in \p Bases in the 103 /// current `omp begin/end declare variant` scope. 104 void ActOnFinishedFunctionDefinitionInOpenMPDeclareVariantScope( 105 Decl *D, SmallVectorImpl<FunctionDecl *> &Bases); 106 107 /// Act on \p D, a function definition inside of an `omp [begin/end] assumes`. 108 void ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(Decl *D); 109 110 /// Can we exit an OpenMP declare variant scope at the moment. 111 bool isInOpenMPDeclareVariantScope() const { 112 return !OMPDeclareVariantScopes.empty(); 113 } 114 115 ExprResult 116 VerifyPositiveIntegerConstantInClause(Expr *Op, OpenMPClauseKind CKind, 117 bool StrictlyPositive = true, 118 bool SuppressExprDiags = false); 119 120 /// Given the potential call expression \p Call, determine if there is a 121 /// specialization via the OpenMP declare variant mechanism available. If 122 /// there is, return the specialized call expression, otherwise return the 123 /// original \p Call. 124 ExprResult ActOnOpenMPCall(ExprResult Call, Scope *Scope, 125 SourceLocation LParenLoc, MultiExprArg ArgExprs, 126 SourceLocation RParenLoc, Expr *ExecConfig); 127 128 /// Handle a `omp begin declare variant`. 129 void ActOnOpenMPBeginDeclareVariant(SourceLocation Loc, OMPTraitInfo &TI); 130 131 /// Handle a `omp end declare variant`. 132 void ActOnOpenMPEndDeclareVariant(); 133 134 /// Function tries to capture lambda's captured variables in the OpenMP region 135 /// before the original lambda is captured. 136 void tryCaptureOpenMPLambdas(ValueDecl *V); 137 138 /// Return true if the provided declaration \a VD should be captured by 139 /// reference. 140 /// \param Level Relative level of nested OpenMP construct for that the check 141 /// is performed. 142 /// \param OpenMPCaptureLevel Capture level within an OpenMP construct. 143 bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level, 144 unsigned OpenMPCaptureLevel) const; 145 146 /// Check if the specified variable is used in one of the private 147 /// clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP 148 /// constructs. 149 VarDecl *isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo = false, 150 unsigned StopAt = 0); 151 152 /// The member expression(this->fd) needs to be rebuilt in the template 153 /// instantiation to generate private copy for OpenMP when default 154 /// clause is used. The function will return true if default 155 /// cluse is used. 156 bool isOpenMPRebuildMemberExpr(ValueDecl *D); 157 158 ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK, 159 ExprObjectKind OK, SourceLocation Loc); 160 161 /// If the current region is a loop-based region, mark the start of the loop 162 /// construct. 163 void startOpenMPLoop(); 164 165 /// If the current region is a range loop-based region, mark the start of the 166 /// loop construct. 167 void startOpenMPCXXRangeFor(); 168 169 /// Check if the specified variable is used in 'private' clause. 170 /// \param Level Relative level of nested OpenMP construct for that the check 171 /// is performed. 172 OpenMPClauseKind isOpenMPPrivateDecl(ValueDecl *D, unsigned Level, 173 unsigned CapLevel) const; 174 175 /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.) 176 /// for \p FD based on DSA for the provided corresponding captured declaration 177 /// \p D. 178 void setOpenMPCaptureKind(FieldDecl *FD, const ValueDecl *D, unsigned Level); 179 180 /// Check if the specified variable is captured by 'target' directive. 181 /// \param Level Relative level of nested OpenMP construct for that the check 182 /// is performed. 183 bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level, 184 unsigned CaptureLevel) const; 185 186 /// Check if the specified global variable must be captured by outer capture 187 /// regions. 188 /// \param Level Relative level of nested OpenMP construct for that 189 /// the check is performed. 190 bool isOpenMPGlobalCapturedDecl(ValueDecl *D, unsigned Level, 191 unsigned CaptureLevel) const; 192 193 ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc, 194 Expr *Op); 195 /// Called on start of new data sharing attribute block. 196 void StartOpenMPDSABlock(OpenMPDirectiveKind K, 197 const DeclarationNameInfo &DirName, Scope *CurScope, 198 SourceLocation Loc); 199 /// Start analysis of clauses. 200 void StartOpenMPClause(OpenMPClauseKind K); 201 /// End analysis of clauses. 202 void EndOpenMPClause(); 203 /// Called on end of data sharing attribute block. 204 void EndOpenMPDSABlock(Stmt *CurDirective); 205 206 /// Check if the current region is an OpenMP loop region and if it is, 207 /// mark loop control variable, used in \p Init for loop initialization, as 208 /// private by default. 209 /// \param Init First part of the for loop. 210 void ActOnOpenMPLoopInitialization(SourceLocation ForLoc, Stmt *Init); 211 212 /// Called on well-formed '\#pragma omp metadirective' after parsing 213 /// of the associated statement. 214 StmtResult ActOnOpenMPMetaDirective(ArrayRef<OMPClause *> Clauses, 215 Stmt *AStmt, SourceLocation StartLoc, 216 SourceLocation EndLoc); 217 218 // OpenMP directives and clauses. 219 /// Called on correct id-expression from the '#pragma omp 220 /// threadprivate'. 221 ExprResult ActOnOpenMPIdExpression(Scope *CurScope, CXXScopeSpec &ScopeSpec, 222 const DeclarationNameInfo &Id, 223 OpenMPDirectiveKind Kind); 224 /// Called on well-formed '#pragma omp threadprivate'. 225 DeclGroupPtrTy ActOnOpenMPThreadprivateDirective(SourceLocation Loc, 226 ArrayRef<Expr *> VarList); 227 /// Builds a new OpenMPThreadPrivateDecl and checks its correctness. 228 OMPThreadPrivateDecl *CheckOMPThreadPrivateDecl(SourceLocation Loc, 229 ArrayRef<Expr *> VarList); 230 /// Called on well-formed '#pragma omp allocate'. 231 DeclGroupPtrTy ActOnOpenMPAllocateDirective(SourceLocation Loc, 232 ArrayRef<Expr *> VarList, 233 ArrayRef<OMPClause *> Clauses, 234 DeclContext *Owner = nullptr); 235 236 /// Called on well-formed '#pragma omp [begin] assume[s]'. 237 void ActOnOpenMPAssumesDirective(SourceLocation Loc, 238 OpenMPDirectiveKind DKind, 239 ArrayRef<std::string> Assumptions, 240 bool SkippedClauses); 241 242 /// Check if there is an active global `omp begin assumes` directive. 243 bool isInOpenMPAssumeScope() const { return !OMPAssumeScoped.empty(); } 244 245 /// Check if there is an active global `omp assumes` directive. 246 bool hasGlobalOpenMPAssumes() const { return !OMPAssumeGlobal.empty(); } 247 248 /// Called on well-formed '#pragma omp end assumes'. 249 void ActOnOpenMPEndAssumesDirective(); 250 251 /// Called on well-formed '#pragma omp requires'. 252 DeclGroupPtrTy ActOnOpenMPRequiresDirective(SourceLocation Loc, 253 ArrayRef<OMPClause *> ClauseList); 254 /// Check restrictions on Requires directive 255 OMPRequiresDecl *CheckOMPRequiresDecl(SourceLocation Loc, 256 ArrayRef<OMPClause *> Clauses); 257 /// Check if the specified type is allowed to be used in 'omp declare 258 /// reduction' construct. 259 QualType ActOnOpenMPDeclareReductionType(SourceLocation TyLoc, 260 TypeResult ParsedType); 261 /// Called on start of '#pragma omp declare reduction'. 262 DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveStart( 263 Scope *S, DeclContext *DC, DeclarationName Name, 264 ArrayRef<std::pair<QualType, SourceLocation>> ReductionTypes, 265 AccessSpecifier AS, Decl *PrevDeclInScope = nullptr); 266 /// Initialize declare reduction construct initializer. 267 void ActOnOpenMPDeclareReductionCombinerStart(Scope *S, Decl *D); 268 /// Finish current declare reduction construct initializer. 269 void ActOnOpenMPDeclareReductionCombinerEnd(Decl *D, Expr *Combiner); 270 /// Initialize declare reduction construct initializer. 271 /// \return omp_priv variable. 272 VarDecl *ActOnOpenMPDeclareReductionInitializerStart(Scope *S, Decl *D); 273 /// Finish current declare reduction construct initializer. 274 void ActOnOpenMPDeclareReductionInitializerEnd(Decl *D, Expr *Initializer, 275 VarDecl *OmpPrivParm); 276 /// Called at the end of '#pragma omp declare reduction'. 277 DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveEnd( 278 Scope *S, DeclGroupPtrTy DeclReductions, bool IsValid); 279 280 /// Check variable declaration in 'omp declare mapper' construct. 281 TypeResult ActOnOpenMPDeclareMapperVarDecl(Scope *S, Declarator &D); 282 /// Check if the specified type is allowed to be used in 'omp declare 283 /// mapper' construct. 284 QualType ActOnOpenMPDeclareMapperType(SourceLocation TyLoc, 285 TypeResult ParsedType); 286 /// Called on start of '#pragma omp declare mapper'. 287 DeclGroupPtrTy ActOnOpenMPDeclareMapperDirective( 288 Scope *S, DeclContext *DC, DeclarationName Name, QualType MapperType, 289 SourceLocation StartLoc, DeclarationName VN, AccessSpecifier AS, 290 Expr *MapperVarRef, ArrayRef<OMPClause *> Clauses, 291 Decl *PrevDeclInScope = nullptr); 292 /// Build the mapper variable of '#pragma omp declare mapper'. 293 ExprResult ActOnOpenMPDeclareMapperDirectiveVarDecl(Scope *S, 294 QualType MapperType, 295 SourceLocation StartLoc, 296 DeclarationName VN); 297 void ActOnOpenMPIteratorVarDecl(VarDecl *VD); 298 bool isOpenMPDeclareMapperVarDeclAllowed(const VarDecl *VD) const; 299 const ValueDecl *getOpenMPDeclareMapperVarName() const; 300 301 struct DeclareTargetContextInfo { 302 struct MapInfo { 303 OMPDeclareTargetDeclAttr::MapTypeTy MT; 304 SourceLocation Loc; 305 }; 306 /// Explicitly listed variables and functions in a 'to' or 'link' clause. 307 llvm::DenseMap<NamedDecl *, MapInfo> ExplicitlyMapped; 308 309 /// The 'device_type' as parsed from the clause. 310 OMPDeclareTargetDeclAttr::DevTypeTy DT = OMPDeclareTargetDeclAttr::DT_Any; 311 312 /// The directive kind, `begin declare target` or `declare target`. 313 OpenMPDirectiveKind Kind; 314 315 /// The directive with indirect clause. 316 std::optional<Expr *> Indirect; 317 318 /// The directive location. 319 SourceLocation Loc; 320 321 DeclareTargetContextInfo(OpenMPDirectiveKind Kind, SourceLocation Loc) 322 : Kind(Kind), Loc(Loc) {} 323 }; 324 325 /// Called on the start of target region i.e. '#pragma omp declare target'. 326 bool ActOnStartOpenMPDeclareTargetContext(DeclareTargetContextInfo &DTCI); 327 328 /// Called at the end of target region i.e. '#pragma omp end declare target'. 329 const DeclareTargetContextInfo ActOnOpenMPEndDeclareTargetDirective(); 330 331 /// Called once a target context is completed, that can be when a 332 /// '#pragma omp end declare target' was encountered or when a 333 /// '#pragma omp declare target' without declaration-definition-seq was 334 /// encountered. 335 void ActOnFinishedOpenMPDeclareTargetContext(DeclareTargetContextInfo &DTCI); 336 337 /// Report unterminated 'omp declare target' or 'omp begin declare target' at 338 /// the end of a compilation unit. 339 void DiagnoseUnterminatedOpenMPDeclareTarget(); 340 341 /// Searches for the provided declaration name for OpenMP declare target 342 /// directive. 343 NamedDecl *lookupOpenMPDeclareTargetName(Scope *CurScope, 344 CXXScopeSpec &ScopeSpec, 345 const DeclarationNameInfo &Id); 346 347 /// Called on correct id-expression from the '#pragma omp declare target'. 348 void ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc, 349 OMPDeclareTargetDeclAttr::MapTypeTy MT, 350 DeclareTargetContextInfo &DTCI); 351 352 /// Check declaration inside target region. 353 void 354 checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, 355 SourceLocation IdLoc = SourceLocation()); 356 357 /// Adds OMPDeclareTargetDeclAttr to referenced variables in declare target 358 /// directive. 359 void ActOnOpenMPDeclareTargetInitializer(Decl *D); 360 361 /// Finishes analysis of the deferred functions calls that may be declared as 362 /// host/nohost during device/host compilation. 363 void finalizeOpenMPDelayedAnalysis(const FunctionDecl *Caller, 364 const FunctionDecl *Callee, 365 SourceLocation Loc); 366 367 /// Return true if currently in OpenMP task with untied clause context. 368 bool isInOpenMPTaskUntiedContext() const; 369 370 /// Return true inside OpenMP declare target region. 371 bool isInOpenMPDeclareTargetContext() const { 372 return !DeclareTargetNesting.empty(); 373 } 374 /// Return true inside OpenMP target region. 375 bool isInOpenMPTargetExecutionDirective() const; 376 377 /// Return the number of captured regions created for an OpenMP directive. 378 static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind); 379 380 /// Initialization of captured region for OpenMP region. 381 void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope); 382 383 /// Called for syntactical loops (ForStmt or CXXForRangeStmt) associated to 384 /// an OpenMP loop directive. 385 StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt); 386 387 /// Process a canonical OpenMP loop nest that can either be a canonical 388 /// literal loop (ForStmt or CXXForRangeStmt), or the generated loop of an 389 /// OpenMP loop transformation construct. 390 StmtResult ActOnOpenMPLoopnest(Stmt *AStmt); 391 392 /// End of OpenMP region. 393 /// 394 /// \param S Statement associated with the current OpenMP region. 395 /// \param Clauses List of clauses for the current OpenMP region. 396 /// 397 /// \returns Statement for finished OpenMP region. 398 StmtResult ActOnOpenMPRegionEnd(StmtResult S, ArrayRef<OMPClause *> Clauses); 399 StmtResult ActOnOpenMPExecutableDirective( 400 OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, 401 OpenMPDirectiveKind CancelRegion, ArrayRef<OMPClause *> Clauses, 402 Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc); 403 /// Process an OpenMP informational directive. 404 /// 405 /// \param Kind The directive kind. 406 /// \param DirName Declaration name info. 407 /// \param Clauses Array of clauses for directive. 408 /// \param AStmt The associated statement. 409 /// \param StartLoc The start location. 410 /// \param EndLoc The end location. 411 StmtResult ActOnOpenMPInformationalDirective( 412 OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, 413 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 414 SourceLocation EndLoc); 415 /// Process an OpenMP assume directive. 416 /// 417 /// \param Clauses Array of clauses for directive. 418 /// \param AStmt The associated statement. 419 /// \param StartLoc The start location. 420 /// \param EndLoc The end location. 421 StmtResult ActOnOpenMPAssumeDirective(ArrayRef<OMPClause *> Clauses, 422 Stmt *AStmt, SourceLocation StartLoc, 423 SourceLocation EndLoc); 424 425 /// Called on well-formed '\#pragma omp parallel' after parsing 426 /// of the associated statement. 427 StmtResult ActOnOpenMPParallelDirective(ArrayRef<OMPClause *> Clauses, 428 Stmt *AStmt, SourceLocation StartLoc, 429 SourceLocation EndLoc); 430 using VarsWithInheritedDSAType = 431 llvm::SmallDenseMap<const ValueDecl *, const Expr *, 4>; 432 /// Called on well-formed '\#pragma omp simd' after parsing 433 /// of the associated statement. 434 StmtResult 435 ActOnOpenMPSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, 436 SourceLocation StartLoc, SourceLocation EndLoc, 437 VarsWithInheritedDSAType &VarsWithImplicitDSA); 438 /// Called on well-formed '#pragma omp tile' after parsing of its clauses and 439 /// the associated statement. 440 StmtResult ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses, 441 Stmt *AStmt, SourceLocation StartLoc, 442 SourceLocation EndLoc); 443 /// Called on well-formed '#pragma omp unroll' after parsing of its clauses 444 /// and the associated statement. 445 StmtResult ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses, 446 Stmt *AStmt, SourceLocation StartLoc, 447 SourceLocation EndLoc); 448 /// Called on well-formed '#pragma omp reverse'. 449 StmtResult ActOnOpenMPReverseDirective(Stmt *AStmt, SourceLocation StartLoc, 450 SourceLocation EndLoc); 451 /// Called on well-formed '#pragma omp interchange' after parsing of its 452 /// clauses and the associated statement. 453 StmtResult ActOnOpenMPInterchangeDirective(ArrayRef<OMPClause *> Clauses, 454 Stmt *AStmt, 455 SourceLocation StartLoc, 456 SourceLocation EndLoc); 457 /// Called on well-formed '\#pragma omp for' after parsing 458 /// of the associated statement. 459 StmtResult 460 ActOnOpenMPForDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, 461 SourceLocation StartLoc, SourceLocation EndLoc, 462 VarsWithInheritedDSAType &VarsWithImplicitDSA); 463 /// Called on well-formed '\#pragma omp for simd' after parsing 464 /// of the associated statement. 465 StmtResult 466 ActOnOpenMPForSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, 467 SourceLocation StartLoc, SourceLocation EndLoc, 468 VarsWithInheritedDSAType &VarsWithImplicitDSA); 469 /// Called on well-formed '\#pragma omp sections' after parsing 470 /// of the associated statement. 471 StmtResult ActOnOpenMPSectionsDirective(ArrayRef<OMPClause *> Clauses, 472 Stmt *AStmt, SourceLocation StartLoc, 473 SourceLocation EndLoc); 474 /// Called on well-formed '\#pragma omp section' after parsing of the 475 /// associated statement. 476 StmtResult ActOnOpenMPSectionDirective(Stmt *AStmt, SourceLocation StartLoc, 477 SourceLocation EndLoc); 478 /// Called on well-formed '\#pragma omp scope' after parsing of the 479 /// associated statement. 480 StmtResult ActOnOpenMPScopeDirective(ArrayRef<OMPClause *> Clauses, 481 Stmt *AStmt, SourceLocation StartLoc, 482 SourceLocation EndLoc); 483 /// Called on well-formed '\#pragma omp single' after parsing of the 484 /// associated statement. 485 StmtResult ActOnOpenMPSingleDirective(ArrayRef<OMPClause *> Clauses, 486 Stmt *AStmt, SourceLocation StartLoc, 487 SourceLocation EndLoc); 488 /// Called on well-formed '\#pragma omp master' after parsing of the 489 /// associated statement. 490 StmtResult ActOnOpenMPMasterDirective(Stmt *AStmt, SourceLocation StartLoc, 491 SourceLocation EndLoc); 492 /// Called on well-formed '\#pragma omp critical' after parsing of the 493 /// associated statement. 494 StmtResult ActOnOpenMPCriticalDirective(const DeclarationNameInfo &DirName, 495 ArrayRef<OMPClause *> Clauses, 496 Stmt *AStmt, SourceLocation StartLoc, 497 SourceLocation EndLoc); 498 /// Called on well-formed '\#pragma omp parallel for' after parsing 499 /// of the associated statement. 500 StmtResult ActOnOpenMPParallelForDirective( 501 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 502 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 503 /// Called on well-formed '\#pragma omp parallel for simd' after 504 /// parsing of the associated statement. 505 StmtResult ActOnOpenMPParallelForSimdDirective( 506 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 507 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 508 /// Called on well-formed '\#pragma omp parallel master' after 509 /// parsing of the associated statement. 510 StmtResult ActOnOpenMPParallelMasterDirective(ArrayRef<OMPClause *> Clauses, 511 Stmt *AStmt, 512 SourceLocation StartLoc, 513 SourceLocation EndLoc); 514 /// Called on well-formed '\#pragma omp parallel masked' after 515 /// parsing of the associated statement. 516 StmtResult ActOnOpenMPParallelMaskedDirective(ArrayRef<OMPClause *> Clauses, 517 Stmt *AStmt, 518 SourceLocation StartLoc, 519 SourceLocation EndLoc); 520 /// Called on well-formed '\#pragma omp parallel sections' after 521 /// parsing of the associated statement. 522 StmtResult ActOnOpenMPParallelSectionsDirective(ArrayRef<OMPClause *> Clauses, 523 Stmt *AStmt, 524 SourceLocation StartLoc, 525 SourceLocation EndLoc); 526 /// Called on well-formed '\#pragma omp task' after parsing of the 527 /// associated statement. 528 StmtResult ActOnOpenMPTaskDirective(ArrayRef<OMPClause *> Clauses, 529 Stmt *AStmt, SourceLocation StartLoc, 530 SourceLocation EndLoc); 531 /// Called on well-formed '\#pragma omp taskyield'. 532 StmtResult ActOnOpenMPTaskyieldDirective(SourceLocation StartLoc, 533 SourceLocation EndLoc); 534 /// Called on well-formed '\#pragma omp error'. 535 /// Error direcitive is allowed in both declared and excutable contexts. 536 /// Adding InExContext to identify which context is called from. 537 StmtResult ActOnOpenMPErrorDirective(ArrayRef<OMPClause *> Clauses, 538 SourceLocation StartLoc, 539 SourceLocation EndLoc, 540 bool InExContext = true); 541 /// Called on well-formed '\#pragma omp barrier'. 542 StmtResult ActOnOpenMPBarrierDirective(SourceLocation StartLoc, 543 SourceLocation EndLoc); 544 /// Called on well-formed '\#pragma omp taskwait'. 545 StmtResult ActOnOpenMPTaskwaitDirective(ArrayRef<OMPClause *> Clauses, 546 SourceLocation StartLoc, 547 SourceLocation EndLoc); 548 /// Called on well-formed '\#pragma omp taskgroup'. 549 StmtResult ActOnOpenMPTaskgroupDirective(ArrayRef<OMPClause *> Clauses, 550 Stmt *AStmt, SourceLocation StartLoc, 551 SourceLocation EndLoc); 552 /// Called on well-formed '\#pragma omp flush'. 553 StmtResult ActOnOpenMPFlushDirective(ArrayRef<OMPClause *> Clauses, 554 SourceLocation StartLoc, 555 SourceLocation EndLoc); 556 /// Called on well-formed '\#pragma omp depobj'. 557 StmtResult ActOnOpenMPDepobjDirective(ArrayRef<OMPClause *> Clauses, 558 SourceLocation StartLoc, 559 SourceLocation EndLoc); 560 /// Called on well-formed '\#pragma omp scan'. 561 StmtResult ActOnOpenMPScanDirective(ArrayRef<OMPClause *> Clauses, 562 SourceLocation StartLoc, 563 SourceLocation EndLoc); 564 /// Called on well-formed '\#pragma omp ordered' after parsing of the 565 /// associated statement. 566 StmtResult ActOnOpenMPOrderedDirective(ArrayRef<OMPClause *> Clauses, 567 Stmt *AStmt, SourceLocation StartLoc, 568 SourceLocation EndLoc); 569 /// Called on well-formed '\#pragma omp atomic' after parsing of the 570 /// associated statement. 571 StmtResult ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses, 572 Stmt *AStmt, SourceLocation StartLoc, 573 SourceLocation EndLoc); 574 /// Called on well-formed '\#pragma omp target' after parsing of the 575 /// associated statement. 576 StmtResult ActOnOpenMPTargetDirective(ArrayRef<OMPClause *> Clauses, 577 Stmt *AStmt, SourceLocation StartLoc, 578 SourceLocation EndLoc); 579 /// Called on well-formed '\#pragma omp target data' after parsing of 580 /// the associated statement. 581 StmtResult ActOnOpenMPTargetDataDirective(ArrayRef<OMPClause *> Clauses, 582 Stmt *AStmt, 583 SourceLocation StartLoc, 584 SourceLocation EndLoc); 585 /// Called on well-formed '\#pragma omp target enter data' after 586 /// parsing of the associated statement. 587 StmtResult ActOnOpenMPTargetEnterDataDirective(ArrayRef<OMPClause *> Clauses, 588 SourceLocation StartLoc, 589 SourceLocation EndLoc, 590 Stmt *AStmt); 591 /// Called on well-formed '\#pragma omp target exit data' after 592 /// parsing of the associated statement. 593 StmtResult ActOnOpenMPTargetExitDataDirective(ArrayRef<OMPClause *> Clauses, 594 SourceLocation StartLoc, 595 SourceLocation EndLoc, 596 Stmt *AStmt); 597 /// Called on well-formed '\#pragma omp target parallel' after 598 /// parsing of the associated statement. 599 StmtResult ActOnOpenMPTargetParallelDirective(ArrayRef<OMPClause *> Clauses, 600 Stmt *AStmt, 601 SourceLocation StartLoc, 602 SourceLocation EndLoc); 603 /// Called on well-formed '\#pragma omp target parallel for' after 604 /// parsing of the associated statement. 605 StmtResult ActOnOpenMPTargetParallelForDirective( 606 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 607 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 608 /// Called on well-formed '\#pragma omp teams' after parsing of the 609 /// associated statement. 610 StmtResult ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses, 611 Stmt *AStmt, SourceLocation StartLoc, 612 SourceLocation EndLoc); 613 /// Called on well-formed '\#pragma omp teams loop' after parsing of the 614 /// associated statement. 615 StmtResult ActOnOpenMPTeamsGenericLoopDirective( 616 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 617 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 618 /// Called on well-formed '\#pragma omp target teams loop' after parsing of 619 /// the associated statement. 620 StmtResult ActOnOpenMPTargetTeamsGenericLoopDirective( 621 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 622 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 623 /// Called on well-formed '\#pragma omp parallel loop' after parsing of the 624 /// associated statement. 625 StmtResult ActOnOpenMPParallelGenericLoopDirective( 626 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 627 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 628 /// Called on well-formed '\#pragma omp target parallel loop' after parsing 629 /// of the associated statement. 630 StmtResult ActOnOpenMPTargetParallelGenericLoopDirective( 631 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 632 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 633 /// Called on well-formed '\#pragma omp cancellation point'. 634 StmtResult 635 ActOnOpenMPCancellationPointDirective(SourceLocation StartLoc, 636 SourceLocation EndLoc, 637 OpenMPDirectiveKind CancelRegion); 638 /// Called on well-formed '\#pragma omp cancel'. 639 StmtResult ActOnOpenMPCancelDirective(ArrayRef<OMPClause *> Clauses, 640 SourceLocation StartLoc, 641 SourceLocation EndLoc, 642 OpenMPDirectiveKind CancelRegion); 643 /// Called on well-formed '\#pragma omp taskloop' after parsing of the 644 /// associated statement. 645 StmtResult 646 ActOnOpenMPTaskLoopDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, 647 SourceLocation StartLoc, SourceLocation EndLoc, 648 VarsWithInheritedDSAType &VarsWithImplicitDSA); 649 /// Called on well-formed '\#pragma omp taskloop simd' after parsing of 650 /// the associated statement. 651 StmtResult ActOnOpenMPTaskLoopSimdDirective( 652 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 653 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 654 /// Called on well-formed '\#pragma omp master taskloop' after parsing of the 655 /// associated statement. 656 StmtResult ActOnOpenMPMasterTaskLoopDirective( 657 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 658 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 659 /// Called on well-formed '\#pragma omp master taskloop simd' after parsing of 660 /// the associated statement. 661 StmtResult ActOnOpenMPMasterTaskLoopSimdDirective( 662 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 663 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 664 /// Called on well-formed '\#pragma omp parallel master taskloop' after 665 /// parsing of the associated statement. 666 StmtResult ActOnOpenMPParallelMasterTaskLoopDirective( 667 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 668 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 669 /// Called on well-formed '\#pragma omp parallel master taskloop simd' after 670 /// parsing of the associated statement. 671 StmtResult ActOnOpenMPParallelMasterTaskLoopSimdDirective( 672 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 673 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 674 /// Called on well-formed '\#pragma omp masked taskloop' after parsing of the 675 /// associated statement. 676 StmtResult ActOnOpenMPMaskedTaskLoopDirective( 677 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 678 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 679 /// Called on well-formed '\#pragma omp masked taskloop simd' after parsing of 680 /// the associated statement. 681 StmtResult ActOnOpenMPMaskedTaskLoopSimdDirective( 682 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 683 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 684 /// Called on well-formed '\#pragma omp parallel masked taskloop' after 685 /// parsing of the associated statement. 686 StmtResult ActOnOpenMPParallelMaskedTaskLoopDirective( 687 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 688 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 689 /// Called on well-formed '\#pragma omp parallel masked taskloop simd' after 690 /// parsing of the associated statement. 691 StmtResult ActOnOpenMPParallelMaskedTaskLoopSimdDirective( 692 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 693 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 694 /// Called on well-formed '\#pragma omp distribute' after parsing 695 /// of the associated statement. 696 StmtResult 697 ActOnOpenMPDistributeDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, 698 SourceLocation StartLoc, SourceLocation EndLoc, 699 VarsWithInheritedDSAType &VarsWithImplicitDSA); 700 /// Called on well-formed '\#pragma omp target update'. 701 StmtResult ActOnOpenMPTargetUpdateDirective(ArrayRef<OMPClause *> Clauses, 702 SourceLocation StartLoc, 703 SourceLocation EndLoc, 704 Stmt *AStmt); 705 /// Called on well-formed '\#pragma omp distribute parallel for' after 706 /// parsing of the associated statement. 707 StmtResult ActOnOpenMPDistributeParallelForDirective( 708 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 709 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 710 /// Called on well-formed '\#pragma omp distribute parallel for simd' 711 /// after parsing of the associated statement. 712 StmtResult ActOnOpenMPDistributeParallelForSimdDirective( 713 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 714 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 715 /// Called on well-formed '\#pragma omp distribute simd' after 716 /// parsing of the associated statement. 717 StmtResult ActOnOpenMPDistributeSimdDirective( 718 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 719 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 720 /// Called on well-formed '\#pragma omp target parallel for simd' after 721 /// parsing of the associated statement. 722 StmtResult ActOnOpenMPTargetParallelForSimdDirective( 723 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 724 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 725 /// Called on well-formed '\#pragma omp target simd' after parsing of 726 /// the associated statement. 727 StmtResult 728 ActOnOpenMPTargetSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, 729 SourceLocation StartLoc, SourceLocation EndLoc, 730 VarsWithInheritedDSAType &VarsWithImplicitDSA); 731 /// Called on well-formed '\#pragma omp teams distribute' after parsing of 732 /// the associated statement. 733 StmtResult ActOnOpenMPTeamsDistributeDirective( 734 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 735 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 736 /// Called on well-formed '\#pragma omp teams distribute simd' after parsing 737 /// of the associated statement. 738 StmtResult ActOnOpenMPTeamsDistributeSimdDirective( 739 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 740 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 741 /// Called on well-formed '\#pragma omp teams distribute parallel for simd' 742 /// after parsing of the associated statement. 743 StmtResult ActOnOpenMPTeamsDistributeParallelForSimdDirective( 744 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 745 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 746 /// Called on well-formed '\#pragma omp teams distribute parallel for' 747 /// after parsing of the associated statement. 748 StmtResult ActOnOpenMPTeamsDistributeParallelForDirective( 749 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 750 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 751 /// Called on well-formed '\#pragma omp target teams' after parsing of the 752 /// associated statement. 753 StmtResult ActOnOpenMPTargetTeamsDirective(ArrayRef<OMPClause *> Clauses, 754 Stmt *AStmt, 755 SourceLocation StartLoc, 756 SourceLocation EndLoc); 757 /// Called on well-formed '\#pragma omp target teams distribute' after parsing 758 /// of the associated statement. 759 StmtResult ActOnOpenMPTargetTeamsDistributeDirective( 760 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 761 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 762 /// Called on well-formed '\#pragma omp target teams distribute parallel for' 763 /// after parsing of the associated statement. 764 StmtResult ActOnOpenMPTargetTeamsDistributeParallelForDirective( 765 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 766 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 767 /// Called on well-formed '\#pragma omp target teams distribute parallel for 768 /// simd' after parsing of the associated statement. 769 StmtResult ActOnOpenMPTargetTeamsDistributeParallelForSimdDirective( 770 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 771 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 772 /// Called on well-formed '\#pragma omp target teams distribute simd' after 773 /// parsing of the associated statement. 774 StmtResult ActOnOpenMPTargetTeamsDistributeSimdDirective( 775 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 776 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 777 /// Called on well-formed '\#pragma omp interop'. 778 StmtResult ActOnOpenMPInteropDirective(ArrayRef<OMPClause *> Clauses, 779 SourceLocation StartLoc, 780 SourceLocation EndLoc); 781 /// Called on well-formed '\#pragma omp dispatch' after parsing of the 782 // /associated statement. 783 StmtResult ActOnOpenMPDispatchDirective(ArrayRef<OMPClause *> Clauses, 784 Stmt *AStmt, SourceLocation StartLoc, 785 SourceLocation EndLoc); 786 /// Called on well-formed '\#pragma omp masked' after parsing of the 787 // /associated statement. 788 StmtResult ActOnOpenMPMaskedDirective(ArrayRef<OMPClause *> Clauses, 789 Stmt *AStmt, SourceLocation StartLoc, 790 SourceLocation EndLoc); 791 792 /// Called on well-formed '\#pragma omp loop' after parsing of the 793 /// associated statement. 794 StmtResult ActOnOpenMPGenericLoopDirective( 795 ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, 796 SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); 797 798 /// Checks correctness of linear modifiers. 799 bool CheckOpenMPLinearModifier(OpenMPLinearClauseKind LinKind, 800 SourceLocation LinLoc); 801 /// Checks that the specified declaration matches requirements for the linear 802 /// decls. 803 bool CheckOpenMPLinearDecl(const ValueDecl *D, SourceLocation ELoc, 804 OpenMPLinearClauseKind LinKind, QualType Type, 805 bool IsDeclareSimd = false); 806 807 /// Called on well-formed '\#pragma omp declare simd' after parsing of 808 /// the associated method/function. 809 DeclGroupPtrTy ActOnOpenMPDeclareSimdDirective( 810 DeclGroupPtrTy DG, OMPDeclareSimdDeclAttr::BranchStateTy BS, 811 Expr *Simdlen, ArrayRef<Expr *> Uniforms, ArrayRef<Expr *> Aligneds, 812 ArrayRef<Expr *> Alignments, ArrayRef<Expr *> Linears, 813 ArrayRef<unsigned> LinModifiers, ArrayRef<Expr *> Steps, SourceRange SR); 814 815 /// Checks '\#pragma omp declare variant' variant function and original 816 /// functions after parsing of the associated method/function. 817 /// \param DG Function declaration to which declare variant directive is 818 /// applied to. 819 /// \param VariantRef Expression that references the variant function, which 820 /// must be used instead of the original one, specified in \p DG. 821 /// \param TI The trait info object representing the match clause. 822 /// \param NumAppendArgs The number of omp_interop_t arguments to account for 823 /// in checking. 824 /// \returns std::nullopt, if the function/variant function are not compatible 825 /// with the pragma, pair of original function/variant ref expression 826 /// otherwise. 827 std::optional<std::pair<FunctionDecl *, Expr *>> 828 checkOpenMPDeclareVariantFunction(DeclGroupPtrTy DG, Expr *VariantRef, 829 OMPTraitInfo &TI, unsigned NumAppendArgs, 830 SourceRange SR); 831 832 /// Called on well-formed '\#pragma omp declare variant' after parsing of 833 /// the associated method/function. 834 /// \param FD Function declaration to which declare variant directive is 835 /// applied to. 836 /// \param VariantRef Expression that references the variant function, which 837 /// must be used instead of the original one, specified in \p DG. 838 /// \param TI The context traits associated with the function variant. 839 /// \param AdjustArgsNothing The list of 'nothing' arguments. 840 /// \param AdjustArgsNeedDevicePtr The list of 'need_device_ptr' arguments. 841 /// \param AppendArgs The list of 'append_args' arguments. 842 /// \param AdjustArgsLoc The Location of an 'adjust_args' clause. 843 /// \param AppendArgsLoc The Location of an 'append_args' clause. 844 /// \param SR The SourceRange of the 'declare variant' directive. 845 void ActOnOpenMPDeclareVariantDirective( 846 FunctionDecl *FD, Expr *VariantRef, OMPTraitInfo &TI, 847 ArrayRef<Expr *> AdjustArgsNothing, 848 ArrayRef<Expr *> AdjustArgsNeedDevicePtr, 849 ArrayRef<OMPInteropInfo> AppendArgs, SourceLocation AdjustArgsLoc, 850 SourceLocation AppendArgsLoc, SourceRange SR); 851 852 OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, 853 SourceLocation StartLoc, 854 SourceLocation LParenLoc, 855 SourceLocation EndLoc); 856 /// Called on well-formed 'allocator' clause. 857 OMPClause *ActOnOpenMPAllocatorClause(Expr *Allocator, 858 SourceLocation StartLoc, 859 SourceLocation LParenLoc, 860 SourceLocation EndLoc); 861 /// Called on well-formed 'if' clause. 862 OMPClause *ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier, 863 Expr *Condition, SourceLocation StartLoc, 864 SourceLocation LParenLoc, 865 SourceLocation NameModifierLoc, 866 SourceLocation ColonLoc, 867 SourceLocation EndLoc); 868 /// Called on well-formed 'final' clause. 869 OMPClause *ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, 870 SourceLocation LParenLoc, 871 SourceLocation EndLoc); 872 /// Called on well-formed 'num_threads' clause. 873 OMPClause *ActOnOpenMPNumThreadsClause(Expr *NumThreads, 874 SourceLocation StartLoc, 875 SourceLocation LParenLoc, 876 SourceLocation EndLoc); 877 /// Called on well-formed 'align' clause. 878 OMPClause *ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, 879 SourceLocation LParenLoc, 880 SourceLocation EndLoc); 881 /// Called on well-formed 'safelen' clause. 882 OMPClause *ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, 883 SourceLocation LParenLoc, 884 SourceLocation EndLoc); 885 /// Called on well-formed 'simdlen' clause. 886 OMPClause *ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc, 887 SourceLocation LParenLoc, 888 SourceLocation EndLoc); 889 /// Called on well-form 'sizes' clause. 890 OMPClause *ActOnOpenMPSizesClause(ArrayRef<Expr *> SizeExprs, 891 SourceLocation StartLoc, 892 SourceLocation LParenLoc, 893 SourceLocation EndLoc); 894 /// Called on well-form 'permutation' clause after parsing its arguments. 895 OMPClause *ActOnOpenMPPermutationClause(ArrayRef<Expr *> PermExprs, 896 SourceLocation StartLoc, 897 SourceLocation LParenLoc, 898 SourceLocation EndLoc); 899 /// Called on well-form 'full' clauses. 900 OMPClause *ActOnOpenMPFullClause(SourceLocation StartLoc, 901 SourceLocation EndLoc); 902 /// Called on well-form 'partial' clauses. 903 OMPClause *ActOnOpenMPPartialClause(Expr *FactorExpr, SourceLocation StartLoc, 904 SourceLocation LParenLoc, 905 SourceLocation EndLoc); 906 /// Called on well-formed 'collapse' clause. 907 OMPClause *ActOnOpenMPCollapseClause(Expr *NumForLoops, 908 SourceLocation StartLoc, 909 SourceLocation LParenLoc, 910 SourceLocation EndLoc); 911 /// Called on well-formed 'ordered' clause. 912 OMPClause * 913 ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, 914 SourceLocation LParenLoc = SourceLocation(), 915 Expr *NumForLoops = nullptr); 916 /// Called on well-formed 'grainsize' clause. 917 OMPClause *ActOnOpenMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, 918 Expr *Size, SourceLocation StartLoc, 919 SourceLocation LParenLoc, 920 SourceLocation ModifierLoc, 921 SourceLocation EndLoc); 922 /// Called on well-formed 'num_tasks' clause. 923 OMPClause *ActOnOpenMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, 924 Expr *NumTasks, SourceLocation StartLoc, 925 SourceLocation LParenLoc, 926 SourceLocation ModifierLoc, 927 SourceLocation EndLoc); 928 /// Called on well-formed 'hint' clause. 929 OMPClause *ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc, 930 SourceLocation LParenLoc, 931 SourceLocation EndLoc); 932 /// Called on well-formed 'detach' clause. 933 OMPClause *ActOnOpenMPDetachClause(Expr *Evt, SourceLocation StartLoc, 934 SourceLocation LParenLoc, 935 SourceLocation EndLoc); 936 937 OMPClause *ActOnOpenMPSimpleClause(OpenMPClauseKind Kind, unsigned Argument, 938 SourceLocation ArgumentLoc, 939 SourceLocation StartLoc, 940 SourceLocation LParenLoc, 941 SourceLocation EndLoc); 942 /// Called on well-formed 'when' clause. 943 OMPClause *ActOnOpenMPWhenClause(OMPTraitInfo &TI, SourceLocation StartLoc, 944 SourceLocation LParenLoc, 945 SourceLocation EndLoc); 946 /// Called on well-formed 'default' clause. 947 OMPClause *ActOnOpenMPDefaultClause(llvm::omp::DefaultKind Kind, 948 SourceLocation KindLoc, 949 SourceLocation StartLoc, 950 SourceLocation LParenLoc, 951 SourceLocation EndLoc); 952 /// Called on well-formed 'proc_bind' clause. 953 OMPClause *ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind, 954 SourceLocation KindLoc, 955 SourceLocation StartLoc, 956 SourceLocation LParenLoc, 957 SourceLocation EndLoc); 958 /// Called on well-formed 'order' clause. 959 OMPClause *ActOnOpenMPOrderClause(OpenMPOrderClauseModifier Modifier, 960 OpenMPOrderClauseKind Kind, 961 SourceLocation StartLoc, 962 SourceLocation LParenLoc, 963 SourceLocation MLoc, SourceLocation KindLoc, 964 SourceLocation EndLoc); 965 /// Called on well-formed 'update' clause. 966 OMPClause *ActOnOpenMPUpdateClause(OpenMPDependClauseKind Kind, 967 SourceLocation KindLoc, 968 SourceLocation StartLoc, 969 SourceLocation LParenLoc, 970 SourceLocation EndLoc); 971 /// Called on well-formed 'holds' clause. 972 OMPClause *ActOnOpenMPHoldsClause(Expr *E, SourceLocation StartLoc, 973 SourceLocation LParenLoc, 974 SourceLocation EndLoc); 975 /// Called on well-formed 'absent' or 'contains' clauses. 976 OMPClause *ActOnOpenMPDirectivePresenceClause( 977 OpenMPClauseKind CK, llvm::ArrayRef<OpenMPDirectiveKind> DKVec, 978 SourceLocation Loc, SourceLocation LLoc, SourceLocation RLoc); 979 OMPClause *ActOnOpenMPNullaryAssumptionClause(OpenMPClauseKind CK, 980 SourceLocation Loc, 981 SourceLocation RLoc); 982 983 OMPClause *ActOnOpenMPSingleExprWithArgClause( 984 OpenMPClauseKind Kind, ArrayRef<unsigned> Arguments, Expr *Expr, 985 SourceLocation StartLoc, SourceLocation LParenLoc, 986 ArrayRef<SourceLocation> ArgumentsLoc, SourceLocation DelimLoc, 987 SourceLocation EndLoc); 988 /// Called on well-formed 'schedule' clause. 989 OMPClause *ActOnOpenMPScheduleClause( 990 OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, 991 OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, 992 SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, 993 SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc); 994 995 OMPClause *ActOnOpenMPClause(OpenMPClauseKind Kind, SourceLocation StartLoc, 996 SourceLocation EndLoc); 997 /// Called on well-formed 'nowait' clause. 998 OMPClause *ActOnOpenMPNowaitClause(SourceLocation StartLoc, 999 SourceLocation EndLoc); 1000 /// Called on well-formed 'untied' clause. 1001 OMPClause *ActOnOpenMPUntiedClause(SourceLocation StartLoc, 1002 SourceLocation EndLoc); 1003 /// Called on well-formed 'mergeable' clause. 1004 OMPClause *ActOnOpenMPMergeableClause(SourceLocation StartLoc, 1005 SourceLocation EndLoc); 1006 /// Called on well-formed 'read' clause. 1007 OMPClause *ActOnOpenMPReadClause(SourceLocation StartLoc, 1008 SourceLocation EndLoc); 1009 /// Called on well-formed 'write' clause. 1010 OMPClause *ActOnOpenMPWriteClause(SourceLocation StartLoc, 1011 SourceLocation EndLoc); 1012 /// Called on well-formed 'update' clause. 1013 OMPClause *ActOnOpenMPUpdateClause(SourceLocation StartLoc, 1014 SourceLocation EndLoc); 1015 /// Called on well-formed 'capture' clause. 1016 OMPClause *ActOnOpenMPCaptureClause(SourceLocation StartLoc, 1017 SourceLocation EndLoc); 1018 /// Called on well-formed 'compare' clause. 1019 OMPClause *ActOnOpenMPCompareClause(SourceLocation StartLoc, 1020 SourceLocation EndLoc); 1021 /// Called on well-formed 'fail' clause. 1022 OMPClause *ActOnOpenMPFailClause(SourceLocation StartLoc, 1023 SourceLocation EndLoc); 1024 OMPClause *ActOnOpenMPFailClause(OpenMPClauseKind Kind, 1025 SourceLocation KindLoc, 1026 SourceLocation StartLoc, 1027 SourceLocation LParenLoc, 1028 SourceLocation EndLoc); 1029 1030 /// Called on well-formed 'seq_cst' clause. 1031 OMPClause *ActOnOpenMPSeqCstClause(SourceLocation StartLoc, 1032 SourceLocation EndLoc); 1033 /// Called on well-formed 'acq_rel' clause. 1034 OMPClause *ActOnOpenMPAcqRelClause(SourceLocation StartLoc, 1035 SourceLocation EndLoc); 1036 /// Called on well-formed 'acquire' clause. 1037 OMPClause *ActOnOpenMPAcquireClause(SourceLocation StartLoc, 1038 SourceLocation EndLoc); 1039 /// Called on well-formed 'release' clause. 1040 OMPClause *ActOnOpenMPReleaseClause(SourceLocation StartLoc, 1041 SourceLocation EndLoc); 1042 /// Called on well-formed 'relaxed' clause. 1043 OMPClause *ActOnOpenMPRelaxedClause(SourceLocation StartLoc, 1044 SourceLocation EndLoc); 1045 /// Called on well-formed 'weak' clause. 1046 OMPClause *ActOnOpenMPWeakClause(SourceLocation StartLoc, 1047 SourceLocation EndLoc); 1048 1049 /// Called on well-formed 'init' clause. 1050 OMPClause * 1051 ActOnOpenMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, 1052 SourceLocation StartLoc, SourceLocation LParenLoc, 1053 SourceLocation VarLoc, SourceLocation EndLoc); 1054 1055 /// Called on well-formed 'use' clause. 1056 OMPClause *ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, 1057 SourceLocation LParenLoc, 1058 SourceLocation VarLoc, SourceLocation EndLoc); 1059 1060 /// Called on well-formed 'destroy' clause. 1061 OMPClause *ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, 1062 SourceLocation LParenLoc, 1063 SourceLocation VarLoc, 1064 SourceLocation EndLoc); 1065 /// Called on well-formed 'novariants' clause. 1066 OMPClause *ActOnOpenMPNovariantsClause(Expr *Condition, 1067 SourceLocation StartLoc, 1068 SourceLocation LParenLoc, 1069 SourceLocation EndLoc); 1070 /// Called on well-formed 'nocontext' clause. 1071 OMPClause *ActOnOpenMPNocontextClause(Expr *Condition, 1072 SourceLocation StartLoc, 1073 SourceLocation LParenLoc, 1074 SourceLocation EndLoc); 1075 /// Called on well-formed 'filter' clause. 1076 OMPClause *ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, 1077 SourceLocation LParenLoc, 1078 SourceLocation EndLoc); 1079 /// Called on well-formed 'threads' clause. 1080 OMPClause *ActOnOpenMPThreadsClause(SourceLocation StartLoc, 1081 SourceLocation EndLoc); 1082 /// Called on well-formed 'simd' clause. 1083 OMPClause *ActOnOpenMPSIMDClause(SourceLocation StartLoc, 1084 SourceLocation EndLoc); 1085 /// Called on well-formed 'nogroup' clause. 1086 OMPClause *ActOnOpenMPNogroupClause(SourceLocation StartLoc, 1087 SourceLocation EndLoc); 1088 /// Called on well-formed 'unified_address' clause. 1089 OMPClause *ActOnOpenMPUnifiedAddressClause(SourceLocation StartLoc, 1090 SourceLocation EndLoc); 1091 1092 /// Called on well-formed 'unified_address' clause. 1093 OMPClause *ActOnOpenMPUnifiedSharedMemoryClause(SourceLocation StartLoc, 1094 SourceLocation EndLoc); 1095 1096 /// Called on well-formed 'reverse_offload' clause. 1097 OMPClause *ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc, 1098 SourceLocation EndLoc); 1099 1100 /// Called on well-formed 'dynamic_allocators' clause. 1101 OMPClause *ActOnOpenMPDynamicAllocatorsClause(SourceLocation StartLoc, 1102 SourceLocation EndLoc); 1103 1104 /// Called on well-formed 'atomic_default_mem_order' clause. 1105 OMPClause *ActOnOpenMPAtomicDefaultMemOrderClause( 1106 OpenMPAtomicDefaultMemOrderClauseKind Kind, SourceLocation KindLoc, 1107 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); 1108 1109 /// Called on well-formed 'at' clause. 1110 OMPClause *ActOnOpenMPAtClause(OpenMPAtClauseKind Kind, 1111 SourceLocation KindLoc, 1112 SourceLocation StartLoc, 1113 SourceLocation LParenLoc, 1114 SourceLocation EndLoc); 1115 1116 /// Called on well-formed 'severity' clause. 1117 OMPClause *ActOnOpenMPSeverityClause(OpenMPSeverityClauseKind Kind, 1118 SourceLocation KindLoc, 1119 SourceLocation StartLoc, 1120 SourceLocation LParenLoc, 1121 SourceLocation EndLoc); 1122 1123 /// Called on well-formed 'message' clause. 1124 /// passing string for message. 1125 OMPClause *ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, 1126 SourceLocation LParenLoc, 1127 SourceLocation EndLoc); 1128 1129 /// Data used for processing a list of variables in OpenMP clauses. 1130 struct OpenMPVarListDataTy final { 1131 Expr *DepModOrTailExpr = nullptr; 1132 Expr *IteratorExpr = nullptr; 1133 SourceLocation ColonLoc; 1134 SourceLocation RLoc; 1135 CXXScopeSpec ReductionOrMapperIdScopeSpec; 1136 DeclarationNameInfo ReductionOrMapperId; 1137 int ExtraModifier = -1; ///< Additional modifier for linear, map, depend or 1138 ///< lastprivate clause. 1139 SmallVector<OpenMPMapModifierKind, NumberOfOMPMapClauseModifiers> 1140 MapTypeModifiers; 1141 SmallVector<SourceLocation, NumberOfOMPMapClauseModifiers> 1142 MapTypeModifiersLoc; 1143 SmallVector<OpenMPMotionModifierKind, NumberOfOMPMotionModifiers> 1144 MotionModifiers; 1145 SmallVector<SourceLocation, NumberOfOMPMotionModifiers> MotionModifiersLoc; 1146 bool IsMapTypeImplicit = false; 1147 SourceLocation ExtraModifierLoc; 1148 SourceLocation OmpAllMemoryLoc; 1149 SourceLocation 1150 StepModifierLoc; /// 'step' modifier location for linear clause 1151 SmallVector<OpenMPAllocateClauseModifier, 1152 NumberOfOMPAllocateClauseModifiers> 1153 AllocClauseModifiers; 1154 SmallVector<SourceLocation, NumberOfOMPAllocateClauseModifiers> 1155 AllocClauseModifiersLoc; 1156 Expr *AllocateAlignment = nullptr; 1157 }; 1158 1159 OMPClause *ActOnOpenMPVarListClause(OpenMPClauseKind Kind, 1160 ArrayRef<Expr *> Vars, 1161 const OMPVarListLocTy &Locs, 1162 OpenMPVarListDataTy &Data); 1163 /// Called on well-formed 'inclusive' clause. 1164 OMPClause *ActOnOpenMPInclusiveClause(ArrayRef<Expr *> VarList, 1165 SourceLocation StartLoc, 1166 SourceLocation LParenLoc, 1167 SourceLocation EndLoc); 1168 /// Called on well-formed 'exclusive' clause. 1169 OMPClause *ActOnOpenMPExclusiveClause(ArrayRef<Expr *> VarList, 1170 SourceLocation StartLoc, 1171 SourceLocation LParenLoc, 1172 SourceLocation EndLoc); 1173 /// Called on well-formed 'allocate' clause. 1174 OMPClause * 1175 ActOnOpenMPAllocateClause(Expr *Allocator, Expr *Alignment, 1176 OpenMPAllocateClauseModifier FirstModifier, 1177 SourceLocation FirstModifierLoc, 1178 OpenMPAllocateClauseModifier SecondModifier, 1179 SourceLocation SecondModifierLoc, 1180 ArrayRef<Expr *> VarList, SourceLocation StartLoc, 1181 SourceLocation ColonLoc, SourceLocation LParenLoc, 1182 SourceLocation EndLoc); 1183 /// Called on well-formed 'private' clause. 1184 OMPClause *ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList, 1185 SourceLocation StartLoc, 1186 SourceLocation LParenLoc, 1187 SourceLocation EndLoc); 1188 /// Called on well-formed 'firstprivate' clause. 1189 OMPClause *ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList, 1190 SourceLocation StartLoc, 1191 SourceLocation LParenLoc, 1192 SourceLocation EndLoc); 1193 /// Called on well-formed 'lastprivate' clause. 1194 OMPClause *ActOnOpenMPLastprivateClause( 1195 ArrayRef<Expr *> VarList, OpenMPLastprivateModifier LPKind, 1196 SourceLocation LPKindLoc, SourceLocation ColonLoc, 1197 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); 1198 /// Called on well-formed 'shared' clause. 1199 OMPClause *ActOnOpenMPSharedClause(ArrayRef<Expr *> VarList, 1200 SourceLocation StartLoc, 1201 SourceLocation LParenLoc, 1202 SourceLocation EndLoc); 1203 /// Called on well-formed 'reduction' clause. 1204 OMPClause *ActOnOpenMPReductionClause( 1205 ArrayRef<Expr *> VarList, OpenMPReductionClauseModifier Modifier, 1206 SourceLocation StartLoc, SourceLocation LParenLoc, 1207 SourceLocation ModifierLoc, SourceLocation ColonLoc, 1208 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, 1209 const DeclarationNameInfo &ReductionId, 1210 ArrayRef<Expr *> UnresolvedReductions = {}); 1211 /// Called on well-formed 'task_reduction' clause. 1212 OMPClause *ActOnOpenMPTaskReductionClause( 1213 ArrayRef<Expr *> VarList, SourceLocation StartLoc, 1214 SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, 1215 CXXScopeSpec &ReductionIdScopeSpec, 1216 const DeclarationNameInfo &ReductionId, 1217 ArrayRef<Expr *> UnresolvedReductions = {}); 1218 /// Called on well-formed 'in_reduction' clause. 1219 OMPClause *ActOnOpenMPInReductionClause( 1220 ArrayRef<Expr *> VarList, SourceLocation StartLoc, 1221 SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, 1222 CXXScopeSpec &ReductionIdScopeSpec, 1223 const DeclarationNameInfo &ReductionId, 1224 ArrayRef<Expr *> UnresolvedReductions = {}); 1225 /// Called on well-formed 'linear' clause. 1226 OMPClause *ActOnOpenMPLinearClause( 1227 ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc, 1228 SourceLocation LParenLoc, OpenMPLinearClauseKind LinKind, 1229 SourceLocation LinLoc, SourceLocation ColonLoc, 1230 SourceLocation StepModifierLoc, SourceLocation EndLoc); 1231 /// Called on well-formed 'aligned' clause. 1232 OMPClause *ActOnOpenMPAlignedClause(ArrayRef<Expr *> VarList, Expr *Alignment, 1233 SourceLocation StartLoc, 1234 SourceLocation LParenLoc, 1235 SourceLocation ColonLoc, 1236 SourceLocation EndLoc); 1237 /// Called on well-formed 'copyin' clause. 1238 OMPClause *ActOnOpenMPCopyinClause(ArrayRef<Expr *> VarList, 1239 SourceLocation StartLoc, 1240 SourceLocation LParenLoc, 1241 SourceLocation EndLoc); 1242 /// Called on well-formed 'copyprivate' clause. 1243 OMPClause *ActOnOpenMPCopyprivateClause(ArrayRef<Expr *> VarList, 1244 SourceLocation StartLoc, 1245 SourceLocation LParenLoc, 1246 SourceLocation EndLoc); 1247 /// Called on well-formed 'flush' pseudo clause. 1248 OMPClause *ActOnOpenMPFlushClause(ArrayRef<Expr *> VarList, 1249 SourceLocation StartLoc, 1250 SourceLocation LParenLoc, 1251 SourceLocation EndLoc); 1252 /// Called on well-formed 'depobj' pseudo clause. 1253 OMPClause *ActOnOpenMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, 1254 SourceLocation LParenLoc, 1255 SourceLocation EndLoc); 1256 /// Called on well-formed 'depend' clause. 1257 OMPClause *ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, 1258 Expr *DepModifier, 1259 ArrayRef<Expr *> VarList, 1260 SourceLocation StartLoc, 1261 SourceLocation LParenLoc, 1262 SourceLocation EndLoc); 1263 /// Called on well-formed 'device' clause. 1264 OMPClause *ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier, 1265 Expr *Device, SourceLocation StartLoc, 1266 SourceLocation LParenLoc, 1267 SourceLocation ModifierLoc, 1268 SourceLocation EndLoc); 1269 /// Called on well-formed 'map' clause. 1270 OMPClause *ActOnOpenMPMapClause( 1271 Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers, 1272 ArrayRef<SourceLocation> MapTypeModifiersLoc, 1273 CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, 1274 OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, 1275 SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList, 1276 const OMPVarListLocTy &Locs, bool NoDiagnose = false, 1277 ArrayRef<Expr *> UnresolvedMappers = {}); 1278 /// Called on well-formed 'num_teams' clause. 1279 OMPClause *ActOnOpenMPNumTeamsClause(ArrayRef<Expr *> VarList, 1280 SourceLocation StartLoc, 1281 SourceLocation LParenLoc, 1282 SourceLocation EndLoc); 1283 /// Called on well-formed 'thread_limit' clause. 1284 OMPClause *ActOnOpenMPThreadLimitClause(ArrayRef<Expr *> VarList, 1285 SourceLocation StartLoc, 1286 SourceLocation LParenLoc, 1287 SourceLocation EndLoc); 1288 /// Called on well-formed 'priority' clause. 1289 OMPClause *ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc, 1290 SourceLocation LParenLoc, 1291 SourceLocation EndLoc); 1292 /// Called on well-formed 'dist_schedule' clause. 1293 OMPClause *ActOnOpenMPDistScheduleClause( 1294 OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, 1295 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, 1296 SourceLocation CommaLoc, SourceLocation EndLoc); 1297 /// Called on well-formed 'defaultmap' clause. 1298 OMPClause *ActOnOpenMPDefaultmapClause( 1299 OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, 1300 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, 1301 SourceLocation KindLoc, SourceLocation EndLoc); 1302 /// Called on well-formed 'to' clause. 1303 OMPClause * 1304 ActOnOpenMPToClause(ArrayRef<OpenMPMotionModifierKind> MotionModifiers, 1305 ArrayRef<SourceLocation> MotionModifiersLoc, 1306 CXXScopeSpec &MapperIdScopeSpec, 1307 DeclarationNameInfo &MapperId, SourceLocation ColonLoc, 1308 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs, 1309 ArrayRef<Expr *> UnresolvedMappers = {}); 1310 /// Called on well-formed 'from' clause. 1311 OMPClause * 1312 ActOnOpenMPFromClause(ArrayRef<OpenMPMotionModifierKind> MotionModifiers, 1313 ArrayRef<SourceLocation> MotionModifiersLoc, 1314 CXXScopeSpec &MapperIdScopeSpec, 1315 DeclarationNameInfo &MapperId, SourceLocation ColonLoc, 1316 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs, 1317 ArrayRef<Expr *> UnresolvedMappers = {}); 1318 /// Called on well-formed 'use_device_ptr' clause. 1319 OMPClause *ActOnOpenMPUseDevicePtrClause(ArrayRef<Expr *> VarList, 1320 const OMPVarListLocTy &Locs); 1321 /// Called on well-formed 'use_device_addr' clause. 1322 OMPClause *ActOnOpenMPUseDeviceAddrClause(ArrayRef<Expr *> VarList, 1323 const OMPVarListLocTy &Locs); 1324 /// Called on well-formed 'is_device_ptr' clause. 1325 OMPClause *ActOnOpenMPIsDevicePtrClause(ArrayRef<Expr *> VarList, 1326 const OMPVarListLocTy &Locs); 1327 /// Called on well-formed 'has_device_addr' clause. 1328 OMPClause *ActOnOpenMPHasDeviceAddrClause(ArrayRef<Expr *> VarList, 1329 const OMPVarListLocTy &Locs); 1330 /// Called on well-formed 'nontemporal' clause. 1331 OMPClause *ActOnOpenMPNontemporalClause(ArrayRef<Expr *> VarList, 1332 SourceLocation StartLoc, 1333 SourceLocation LParenLoc, 1334 SourceLocation EndLoc); 1335 1336 /// Data for list of allocators. 1337 struct UsesAllocatorsData { 1338 /// Allocator. 1339 Expr *Allocator = nullptr; 1340 /// Allocator traits. 1341 Expr *AllocatorTraits = nullptr; 1342 /// Locations of '(' and ')' symbols. 1343 SourceLocation LParenLoc, RParenLoc; 1344 }; 1345 /// Called on well-formed 'uses_allocators' clause. 1346 OMPClause *ActOnOpenMPUsesAllocatorClause(SourceLocation StartLoc, 1347 SourceLocation LParenLoc, 1348 SourceLocation EndLoc, 1349 ArrayRef<UsesAllocatorsData> Data); 1350 /// Called on well-formed 'affinity' clause. 1351 OMPClause *ActOnOpenMPAffinityClause(SourceLocation StartLoc, 1352 SourceLocation LParenLoc, 1353 SourceLocation ColonLoc, 1354 SourceLocation EndLoc, Expr *Modifier, 1355 ArrayRef<Expr *> Locators); 1356 /// Called on a well-formed 'bind' clause. 1357 OMPClause *ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, 1358 SourceLocation KindLoc, 1359 SourceLocation StartLoc, 1360 SourceLocation LParenLoc, 1361 SourceLocation EndLoc); 1362 1363 /// Called on a well-formed 'ompx_dyn_cgroup_mem' clause. 1364 OMPClause *ActOnOpenMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, 1365 SourceLocation LParenLoc, 1366 SourceLocation EndLoc); 1367 1368 /// Called on well-formed 'doacross' clause. 1369 OMPClause * 1370 ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, 1371 SourceLocation DepLoc, SourceLocation ColonLoc, 1372 ArrayRef<Expr *> VarList, SourceLocation StartLoc, 1373 SourceLocation LParenLoc, SourceLocation EndLoc); 1374 1375 /// Called on a well-formed 'ompx_attribute' clause. 1376 OMPClause *ActOnOpenMPXAttributeClause(ArrayRef<const Attr *> Attrs, 1377 SourceLocation StartLoc, 1378 SourceLocation LParenLoc, 1379 SourceLocation EndLoc); 1380 1381 /// Called on a well-formed 'ompx_bare' clause. 1382 OMPClause *ActOnOpenMPXBareClause(SourceLocation StartLoc, 1383 SourceLocation EndLoc); 1384 1385 ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, 1386 Expr *LowerBound, 1387 SourceLocation ColonLocFirst, 1388 SourceLocation ColonLocSecond, 1389 Expr *Length, Expr *Stride, 1390 SourceLocation RBLoc); 1391 ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, 1392 SourceLocation RParenLoc, 1393 ArrayRef<Expr *> Dims, 1394 ArrayRef<SourceRange> Brackets); 1395 1396 /// Data structure for iterator expression. 1397 struct OMPIteratorData { 1398 IdentifierInfo *DeclIdent = nullptr; 1399 SourceLocation DeclIdentLoc; 1400 ParsedType Type; 1401 OMPIteratorExpr::IteratorRange Range; 1402 SourceLocation AssignLoc; 1403 SourceLocation ColonLoc; 1404 SourceLocation SecColonLoc; 1405 }; 1406 1407 ExprResult ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc, 1408 SourceLocation LLoc, SourceLocation RLoc, 1409 ArrayRef<OMPIteratorData> Data); 1410 1411 void handleOMPAssumeAttr(Decl *D, const ParsedAttr &AL); 1412 1413 private: 1414 void *VarDataSharingAttributesStack; 1415 1416 /// Number of nested '#pragma omp declare target' directives. 1417 SmallVector<DeclareTargetContextInfo, 4> DeclareTargetNesting; 1418 1419 /// Initialization of data-sharing attributes stack. 1420 void InitDataSharingAttributesStack(); 1421 void DestroyDataSharingAttributesStack(); 1422 1423 /// Returns OpenMP nesting level for current directive. 1424 unsigned getOpenMPNestingLevel() const; 1425 1426 /// Adjusts the function scopes index for the target-based regions. 1427 void adjustOpenMPTargetScopeIndex(unsigned &FunctionScopesIndex, 1428 unsigned Level) const; 1429 1430 /// Returns the number of scopes associated with the construct on the given 1431 /// OpenMP level. 1432 int getNumberOfConstructScopes(unsigned Level) const; 1433 1434 /// Push new OpenMP function region for non-capturing function. 1435 void pushOpenMPFunctionRegion(); 1436 1437 /// Pop OpenMP function region for non-capturing function. 1438 void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI); 1439 1440 /// Analyzes and checks a loop nest for use by a loop transformation. 1441 /// 1442 /// \param Kind The loop transformation directive kind. 1443 /// \param NumLoops How many nested loops the directive is expecting. 1444 /// \param AStmt Associated statement of the transformation directive. 1445 /// \param LoopHelpers [out] The loop analysis result. 1446 /// \param Body [out] The body code nested in \p NumLoops loop. 1447 /// \param OriginalInits [out] Collection of statements and declarations that 1448 /// must have been executed/declared before entering the 1449 /// loop. 1450 /// 1451 /// \return Whether there was any error. 1452 bool checkTransformableLoopNest( 1453 OpenMPDirectiveKind Kind, Stmt *AStmt, int NumLoops, 1454 SmallVectorImpl<OMPLoopBasedDirective::HelperExprs> &LoopHelpers, 1455 Stmt *&Body, SmallVectorImpl<SmallVector<Stmt *, 0>> &OriginalInits); 1456 1457 /// Helper to keep information about the current `omp begin/end declare 1458 /// variant` nesting. 1459 struct OMPDeclareVariantScope { 1460 /// The associated OpenMP context selector. 1461 OMPTraitInfo *TI; 1462 1463 /// The associated OpenMP context selector mangling. 1464 std::string NameSuffix; 1465 1466 OMPDeclareVariantScope(OMPTraitInfo &TI); 1467 }; 1468 1469 /// Return the OMPTraitInfo for the surrounding scope, if any. 1470 OMPTraitInfo *getOMPTraitInfoForSurroundingScope() { 1471 return OMPDeclareVariantScopes.empty() ? nullptr 1472 : OMPDeclareVariantScopes.back().TI; 1473 } 1474 1475 /// The current `omp begin/end declare variant` scopes. 1476 SmallVector<OMPDeclareVariantScope, 4> OMPDeclareVariantScopes; 1477 1478 /// The current `omp begin/end assumes` scopes. 1479 SmallVector<OMPAssumeAttr *, 4> OMPAssumeScoped; 1480 1481 /// All `omp assumes` we encountered so far. 1482 SmallVector<OMPAssumeAttr *, 4> OMPAssumeGlobal; 1483 }; 1484 1485 } // namespace clang 1486 1487 #endif // LLVM_CLANG_SEMA_SEMAOPENMP_H 1488