Lines Matching defs:SemaRef

59     Sema &SemaRef, Expr *E,
240 Sema &SemaRef;
345 explicit DSAStackTy(Sema &S) : SemaRef(S) {}
473 const FunctionScopeInfo *CurFnScope = SemaRef.getCurFunction();
486 for (const FunctionScopeInfo *FSI : llvm::reverse(SemaRef.FunctionScopes)) {
681 SemaRef.Diag(CNew->getBeginLoc(),
684 SemaRef.Diag(CPrev->getBeginLoc(),
1521 static VarDecl *buildVarDecl(Sema &SemaRef, SourceLocation Loc, QualType Type,
1524 DeclContext *DC = SemaRef.CurContext;
1525 IdentifierInfo *II = &SemaRef.PP.getIdentifierTable().get(Name);
1526 TypeSourceInfo *TInfo = SemaRef.Context.getTrivialTypeSourceInfo(Type, Loc);
1528 VarDecl::Create(SemaRef.Context, DC, Loc, Loc, II, Type, TInfo, SC_None);
1537 OMPReferencedVarAttr::CreateImplicit(SemaRef.Context, OrigRef));
1570 VarDecl *VD = buildVarDecl(SemaRef, SR.getBegin(),
1571 SemaRef.Context.VoidPtrTy, ".task_red.");
1573 buildDeclRefExpr(SemaRef, VD, SemaRef.Context.VoidPtrTy, SR.getBegin());
1595 VarDecl *VD = buildVarDecl(SemaRef, SR.getBegin(),
1596 SemaRef.Context.VoidPtrTy, ".task_red.");
1598 buildDeclRefExpr(SemaRef, VD, SemaRef.Context.VoidPtrTy, SR.getBegin());
1677 static bool isConstNotMutableType(Sema &SemaRef, QualType Type,
1680 ASTContext &Context = SemaRef.getASTContext();
1684 const CXXRecordDecl *RD = AcceptIfMutable && SemaRef.getLangOpts().CPlusPlus
1692 return IsConstant && !(SemaRef.getLangOpts().CPlusPlus && RD &&
1696 static bool rejectConstNotMutableType(Sema &SemaRef, const ValueDecl *D,
1701 ASTContext &Context = SemaRef.getASTContext();
1703 if (isConstNotMutableType(SemaRef, Type, AcceptIfMutable, &IsClassType)) {
1707 SemaRef.Diag(ELoc, Diag) << getOpenMPClauseName(CKind);
1712 SemaRef.Diag(D->getLocation(),
1736 SemaRef, VD, D->getType().getNonReferenceType(),
1747 SemaRef.getLangOpts().OpenMPUseTLS &&
1748 SemaRef.getASTContext().getTargetInfo().isTLSSupported())) ||
1752 SemaRef, VD, D->getType().getNonReferenceType(), D->getLocation());
1757 if (SemaRef.getLangOpts().OpenMPCUDAMode && VD &&
1769 buildDeclRefExpr(SemaRef, VD, D->getType().getNonReferenceType(),
1784 if (!SemaRef.OpenMP().isOpenMPCapturedByRef(
1788 buildDeclRefExpr(SemaRef, VD, D->getType().getNonReferenceType(),
1836 if (SemaRef.LangOpts.OpenMP <= 31) {
1841 if (isConstNotMutableType(SemaRef, D->getType())) {
1995 VarDataSharingAttributesStack = new DSAStackTy(SemaRef);
2029 Sema::FunctionEmissionStatus FES = SemaRef.getEmissionStatus(FD);
2042 Kind = isOpenMPDeviceDelayedContext(SemaRef)
2056 return SemaDiagnosticBuilder(Kind, Loc, DiagID, FD, SemaRef);
2067 Sema::FunctionEmissionStatus FES = SemaRef.getEmissionStatus(FD);
2083 return SemaDiagnosticBuilder(Kind, Loc, DiagID, FD, SemaRef);
2344 (SemaRef.getCurCapturedRegion() || SemaRef.getCurBlock() ||
2345 SemaRef.getCurLambda())) {
2358 llvm::reverse(SemaRef.FunctionScopes),
2359 CheckScopeInfo ? (SemaRef.FunctionScopes.size() - (StopAt + 1))
2389 FunctionScopeInfo *FSI = SemaRef.FunctionScopes[I - 1];
2454 if (SemaRef.getCurrentThisType().isNull())
2456 Expr *ThisExpr = SemaRef.BuildCXXThisExpr(SourceLocation(),
2457 SemaRef.getCurrentThisType(),
2460 Expr *ME = SemaRef.BuildMemberExpr(
2467 SemaRef, FD->getIdentifier(), ME, DVarPrivate.CKind != OMPC_private,
2468 SemaRef.CurContext->getParent(), /*AsExpression=*/false);
2470 SemaRef, CD, CD->getType().getNonReferenceType(), SourceLocation());
2759 SemaRef.PushExpressionEvaluationContext(
2769 SemaRef.CleanupVarDeclMarking();
2848 static void reportOriginalDsa(Sema &SemaRef, const DSAStackTy *Stack,
2884 SemaRef, DE->getExprLoc(), Type.getUnqualifiedType(), VD->getName(),
2886 SemaRef.ActOnUninitializedDecl(VDPrivate);
2892 SemaRef, VDPrivate, DE->getType(), DE->getExprLoc()));
2905 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
2957 reportOriginalDsa(SemaRef, DSAStack, VD, DVar);
2976 if (!SemaRef.CurContext->isDependentContext())
2977 checkAllocateClauses(SemaRef, DSAStack, D->clauses());
2978 checkReductionClauses(SemaRef, DSAStack, D->clauses());
2982 SemaRef.DiscardCleanupsInEvaluationContext();
2983 SemaRef.PopExpressionEvaluationContext();
2987 Expr *NumIterations, Sema &SemaRef,
2990 static bool finishLinearClauses(Sema &SemaRef, ArrayRef<OMPClause *> Clauses,
2993 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
2996 if (SemaRef.CurContext->isDependentContext())
3005 B.NumIterations, SemaRef,
3006 SemaRef.getCurScope(), Stack))
3017 Sema &SemaRef;
3020 explicit VarDeclFilterCCC(Sema &S) : SemaRef(S) {}
3025 SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
3026 SemaRef.getCurScope());
3038 Sema &SemaRef;
3041 explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
3046 return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
3047 SemaRef.getCurScope());
3064 LookupResult Lookup(SemaRef, Id, Sema::LookupOrdinaryName);
3065 SemaRef.LookupParsedName(Lookup, CurScope, &ScopeSpec,
3074 VarDeclFilterCCC CCC(SemaRef);
3076 SemaRef.CorrectTypo(Id, Sema::LookupOrdinaryName, CurScope, nullptr,
3078 SemaRef.diagnoseTypo(
3080 SemaRef.PDiag(Lookup.empty() ? diag::err_undeclared_var_use_suggest
3116 !SemaRef.getCurLexicalContext()->isTranslationUnit()) {
3131 !CanonicalVD->getDeclContext()->Equals(SemaRef.getCurLexicalContext())) {
3146 (!SemaRef.getCurLexicalContext()->isFileContext() ||
3147 !SemaRef.getCurLexicalContext()->Encloses(
3162 !SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(), CurScope)) {
3194 SemaRef.CurContext->addDecl(D);
3203 Sema &SemaRef;
3209 SemaRef.Diag(E->getBeginLoc(),
3212 SemaRef.Diag(VD->getLocation(), diag::note_defined_here)
3226 explicit LocalVarRefChecker(Sema &SemaRef) : SemaRef(SemaRef) {}
3253 if (SemaRef.RequireCompleteType(
3292 LocalVarRefChecker Checker(SemaRef);
3306 D = OMPThreadPrivateDecl::Create(Context, SemaRef.getCurLexicalContext(),
3426 SemaRef.targetDiag(Loc, diag::err_expected_allocator_clause);
3437 getAllocatorKind(SemaRef, DSAStack, Allocator);
3452 if (checkPreviousOMPAllocateAttribute(SemaRef, DSAStack, RefExpr, VD,
3475 applyOMPAllocateAttribute(SemaRef, VD, AllocatorKind, Allocator, Alignment,
3481 Owner = SemaRef.getCurLexicalContext();
3492 if (!SemaRef.CurContext->isFileContext()) {
3497 SemaRef.CurContext->addDecl(D);
3533 auto *Ctx = SemaRef.CurContext;
3607 getASTContext(), SemaRef.getCurLexicalContext(), Loc, ClauseList);
3611 static void reportOriginalDsa(Sema &SemaRef, const DSAStackTy *Stack,
3616 SemaRef.Diag(DVar.RefExpr->getExprLoc(), diag::note_omp_explicit_dsa)
3652 else if (D->getType().isConstant(SemaRef.getASTContext()))
3659 SemaRef.Diag(ReportLoc, diag::note_omp_predetermined_dsa)
3663 SemaRef.Diag(DVar.ImplicitDSALoc, diag::note_omp_implicit_dsa)
3726 Sema &SemaRef;
3857 getVariableCategoryFromDecl(SemaRef.getLangOpts(), VD);
3858 if (SemaRef.getLangOpts().OpenMP >= 50) {
3880 if (SemaRef.getLangOpts().OpenMP > 50) {
3899 if (SemaRef.LangOpts.OpenMP >= 50)
3954 SemaRef.Diag(ELoc, diag::err_omp_reduction_in_task);
3955 reportOriginalDsa(SemaRef, Stack, VD, DVar);
4025 getVariableCategoryFromDecl(SemaRef.getLangOpts(), FD);
4049 SemaRef.Diag(ELoc, diag::err_omp_reduction_in_task);
4050 reportOriginalDsa(SemaRef, Stack, FD, DVar);
4069 if (!checkMapClauseExpressionBase(SemaRef, E, CurComponents, OMPC_map,
4179 SemaRef, VD, VD->getType().getNonLValueExprType(SemaRef.Context),
4190 DSAAttrChecker(DSAStackTy *S, Sema &SemaRef, CapturedStmt *CS)
4191 : Stack(S), SemaRef(SemaRef), ErrorFound(false), CS(CS) {
4220 getParallelRegionParams(Sema &SemaRef, bool LoopBoundSharing) {
4221 ASTContext &Context = SemaRef.getASTContext();
4242 getTeamsRegionParams(Sema &SemaRef) {
4243 return getParallelRegionParams(SemaRef, /*LoopBoundSharing=*/false);
4247 getTaskRegionParams(Sema &SemaRef) {
4248 ASTContext &Context = SemaRef.getASTContext();
4271 getTargetRegionParams(Sema &SemaRef) {
4272 ASTContext &Context = SemaRef.getASTContext();
4274 if (SemaRef.getLangOpts().OpenMPIsTargetDevice) {
4284 getUnknownRegionParams(Sema &SemaRef) {
4292 getTaskloopRegionParams(Sema &SemaRef) {
4293 ASTContext &Context = SemaRef.getASTContext();
4325 static void processCapturedRegions(Sema &SemaRef, OpenMPDirectiveKind DKind,
4334 SemaRef.getASTContext(), {}, AlwaysInlineAttr::Keyword_forceinline));
4342 SemaRef.ActOnCapturedRegionStart(
4344 getParallelRegionParams(SemaRef, LoopBoundSharing), Level);
4347 SemaRef.ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP,
4348 getTeamsRegionParams(SemaRef), Level);
4351 SemaRef.ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP,
4352 getTaskRegionParams(SemaRef), Level);
4355 MarkAsInlined(SemaRef.getCurCapturedRegion());
4358 SemaRef.ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP,
4359 getTaskloopRegionParams(SemaRef), Level);
4362 MarkAsInlined(SemaRef.getCurCapturedRegion());
4365 SemaRef.ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP,
4366 getTargetRegionParams(SemaRef), Level);
4369 SemaRef.ActOnCapturedRegionStart(Loc, CurScope, CR_OpenMP,
4370 getUnknownRegionParams(SemaRef));
4395 processCapturedRegions(SemaRef, DKind, CurScope,
4400 DSAStack->setContext(SemaRef.CurContext);
4511 if (!SemaRef.CurContext->isDependentContext() &&
4531 if (!VDC->Encloses(SemaRef.CurContext))
4533 SemaRef.MarkVariableReferenced(LC.getLocation(), VD);
4535 QualType ThisTy = SemaRef.getCurrentThisType();
4538 SemaRef.CheckCXXThisCapture(LC.getLocation());
4587 SemaRef, ErrorFound, DSAStack->getCurrentDirective());
4610 SemaRef.MarkDeclarationsReferencedInExpr(E);
4621 SemaRef.MarkDeclarationsReferencedInExpr(E);
4631 SemaRef.MarkDeclarationsReferencedInExpr(E);
4643 SemaRef.MarkDeclarationsReferencedInExpr(E);
4665 if (checkOrderedOrderSpecified(SemaRef, Clauses))
4702 SemaRef.MarkVariableReferenced(D->getLocation(),
4717 SemaRef.MarkDeclarationsReferencedInExpr(E);
4732 SemaRef.MarkDeclarationsReferencedInExpr(E);
4736 SemaRef.MarkDeclarationsReferencedInExpr(E);
4742 SR = SemaRef.ActOnCapturedRegionEnd(SR.get());
4747 static bool checkCancelRegion(Sema &SemaRef, OpenMPDirectiveKind CurrentRegion,
4758 SemaRef.Diag(StartLoc, diag::err_omp_wrong_cancel_region)
4763 static bool checkNestingOfRegions(Sema &SemaRef, const DSAStackTy *Stack,
4791 if (SemaRef.LangOpts.OpenMP >= 51 && Stack->isParentOrderConcurrent() &&
4795 SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_order)
4800 ((SemaRef.LangOpts.OpenMP <= 45 && CurrentRegion != OMPD_ordered) ||
4801 (SemaRef.LangOpts.OpenMP >= 50 && CurrentRegion != OMPD_ordered &&
4816 SemaRef.Diag(StartLoc, (CurrentRegion != OMPD_simd)
4819 << (SemaRef.LangOpts.OpenMP >= 50 ? 1 : 0);
4825 SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_atomic);
4834 SemaRef.Diag(StartLoc, diag::err_omp_orphaned_section_directive)
4851 if (SemaRef.LangOpts.OpenMP >= 50 && CurrentRegion == OMPD_loop &&
4856 SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
4877 (SemaRef.getLangOpts().OpenMP < 50 ||
4911 SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_critical_same_name)
4914 SemaRef.Diag(PreviousCriticalLoc,
4964 (SemaRef.LangOpts.OpenMP <= 45 && EnclosingConstruct != OMPD_target) ||
4965 (SemaRef.LangOpts.OpenMP >= 50 && EnclosingConstruct != OMPD_unknown &&
4970 if (SemaRef.LangOpts.OpenMP >= 50) {
4998 !(SemaRef.getLangOpts().OpenMPExtensions &&
5039 SemaRef.Diag(StartLoc, diag::err_omp_orphaned_device_directive)
5042 SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
5705 SemaRef.BuildUnaryOp(nullptr, {}, UO_Minus, IncBin->getRHS()));
5723 SemaRef.BuildUnaryOp(nullptr, {}, UO_Minus, CondCXXOp->getArg(1)));
5732 buildDistanceFunc(SemaRef, LogicalTy, CondRel, LHS, RHS, Step);
5734 SemaRef, LVTy, LogicalTy, CounterRef, Step, isa<CXXForRangeStmt>(AStmt));
5736 SemaRef.BuildDeclRefExpr(LUVDecl, LUVDecl->getType(), VK_LValue, {},
5755 static ExprResult buildUserDefinedMapperRef(Sema &SemaRef, Scope *S,
5900 Sema &SemaRef;
5932 IsOpenMPAPI || SemaRef.getLangOpts().OpenMPNoNestedParallelism;
5954 explicit TeamsLoopChecker(Sema &SemaRef)
5955 : SemaRef(SemaRef), TeamsLoopCanBeParallelFor(true) {}
5962 static bool teamsLoopCanBeParallelFor(Stmt *AStmt, Sema &SemaRef) {
5963 TeamsLoopChecker Checker(SemaRef);
6023 if (checkCancelRegion(SemaRef, Kind, CancelRegion, StartLoc) ||
6024 checkNestingOfRegions(SemaRef, DSAStack, Kind, DirName, CancelRegion,
6038 if (AStmt && !SemaRef.CurContext->isDependentContext() &&
6043 DSAAttrChecker DSAChecker(DSAStack, SemaRef, cast<CapturedStmt>(AStmt));
6169 processImplicitMapsWithDefaultMappers(SemaRef, DSAStack,
6510 DSAAttrChecker DSAChecker(DSAStack, SemaRef, nullptr);
6652 ErrorFound = checkIfClauses(SemaRef, Kind, Clauses, AllowedNameModifiers) ||
6658 if (!SemaRef.CurContext->isDependentContext() &&
6906 NewStep = SemaRef
6980 if (!SemaRef.inTemplateInstantiation()) {
7007 LookupResult Lookup(SemaRef, DeclarationName(BaseII), D.getIdentifierLoc(),
7009 SemaRef.LookupParsedName(Lookup, S, &D.getCXXScopeSpec(),
7012 TypeSourceInfo *TInfo = SemaRef.GetTypeForDeclarator(D);
7057 Decl *BaseD = SemaRef.HandleDeclarator(S, D, TemplateParamLists);
7080 SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);
7136 SemaRef.getCurFunctionDecl(),
7182 Sema::TentativeAnalysisScope Trap(SemaRef);
7191 NewCall = SemaRef.BuildCallExpr(Scope, BestExpr, LParenLoc, ArgExprs,
7321 LookupResult Result(SemaRef, &Context.Idents.get("omp_interop_t"),
7323 if (SemaRef.LookupName(Result, SemaRef.getCurScope())) {
7357 Sema::TentativeAnalysisScope Trap(SemaRef);
7358 ER = SemaRef.CreateBuiltinUnaryOp(VariantRef->getBeginLoc(), UO_AddrOf,
7372 ImplicitConversionSequence ICS = SemaRef.TryImplicitConversion(
7386 VariantRefCast = SemaRef.PerformImplicitConversion(
7401 ExprResult ER = SemaRef.CheckPlaceholderExpr(VariantRefCast.get());
7443 setPrototype(SemaRef, FD, NewFD, NewType);
7445 setPrototype(SemaRef, NewFD, FD, NewType);
7508 if (SemaRef.areMultiversionVariantFunctionsCompatible(
7514 SemaRef.PDiag(diag::err_omp_declare_variant_doesnt_support)),
7516 SemaRef.PDiag(diag::err_omp_declare_variant_diff)
7594 setBranchProtectedScope(Sema &SemaRef, OpenMPDirectiveKind DKind, Stmt *AStmt) {
7604 for (int ThisCaptureLevel = SemaRef.OpenMP().getOpenMPCaptureLevels(DKind);
7614 SemaRef.setFunctionHasBranchProtectedScope();
7625 setBranchProtectedScope(SemaRef, OMPD_parallel, AStmt);
7732 Sema &SemaRef;
7787 Sema &SemaRef, bool SupportsNonRectangular, DSAStackTy &Stack,
7790 : SemaRef(SemaRef), SupportsNonRectangular(SupportsNonRectangular),
7930 ExprResult Val = SemaRef.OpenMP().PerformOpenMPImplicitIntegerConversion(
7948 NewStep->getIntegerConstantExpr(SemaRef.Context);
7962 SemaRef.Diag(NewStep->getExprLoc(),
7965 SemaRef.Diag(ConditionLoc,
7972 SemaRef.CreateBuiltinUnaryOp(NewStep->getExprLoc(), UO_Minus, NewStep)
7988 Sema &SemaRef;
7998 SemaRef.Diag(E->getExprLoc(), diag::err_omp_stmt_depends_on_loop_counter)
8009 VD->getNameForDiagnostic(OS, SemaRef.getPrintingPolicy(),
8011 SemaRef.Diag(E->getExprLoc(),
8014 SemaRef.Diag(VD->getLocation(), diag::note_previous_decl) << VD;
8018 SemaRef.Diag(E->getExprLoc(), diag::err_omp_invariant_dependency);
8028 DepDecl->getNameForDiagnostic(OS, SemaRef.getPrintingPolicy(),
8030 SemaRef.Diag(E->getExprLoc(),
8063 explicit LoopCounterRefChecker(Sema &SemaRef, DSAStackTy &Stack,
8067 : SemaRef(SemaRef), Stack(Stack), CurLCDecl(CurLCDecl),
8085 LoopCounterRefChecker LoopStmtChecker(SemaRef, Stack, LCDecl, IsInitializer,
8105 SemaRef.Diag(DefaultLoc, diag::err_omp_loop_not_canonical_init);
8117 SemaRef.Diag(Range.getBegin(), diag::err_omp_loop_bad_collapse_var)
8149 SemaRef.Diag(S->getBeginLoc(),
8154 buildDeclRefExpr(SemaRef, Var,
8180 if (dependent() || SemaRef.CurContext->isDependentContext())
8183 SemaRef.Diag(S->getBeginLoc(), diag::err_omp_loop_not_canonical_init)
8218 bool IneqCondIsCanonical = SemaRef.getLangOpts().OpenMP >= 50;
8220 SemaRef.Diag(DefaultLoc, diag::err_omp_loop_not_canonical_cond)
8231 SemaRef.Diag(Range.getBegin(), diag::err_omp_loop_bad_collapse_var)
8275 if (dependent() || SemaRef.CurContext->isDependentContext())
8277 SemaRef.Diag(CondLoc, diag::err_omp_loop_not_canonical_cond)
8306 if (dependent() || SemaRef.CurContext->isDependentContext())
8308 SemaRef.Diag(RHS->getBeginLoc(), diag::err_omp_loop_not_canonical_incr)
8328 SemaRef.Diag(DefaultLoc, diag::err_omp_loop_not_canonical_incr) << LCDecl;
8339 SemaRef.Diag(Range.getBegin(), diag::err_omp_loop_bad_collapse_var)
8350 return setStep(SemaRef
8374 return setStep(SemaRef
8394 if (dependent() || SemaRef.CurContext->isDependentContext())
8396 SemaRef.Diag(S->getBeginLoc(), diag::err_omp_loop_not_canonical_incr)
8402 tryBuildCapture(Sema &SemaRef, Expr *Capture,
8405 if (SemaRef.CurContext->isDependentContext() || Capture->containsErrors())
8407 if (Capture->isEvaluatable(SemaRef.Context, Expr::SE_AllowSideEffects))
8408 return SemaRef.PerformImplicitConversion(Capture->IgnoreImpCasts(),
8414 return buildCapture(SemaRef, Capture, I->second, Name);
8416 ExprResult Res = buildCapture(SemaRef, Capture, Ref, Name);
8424 calculateNumIters(Sema &SemaRef, Scope *S, SourceLocation DefaultLoc,
8428 ExprResult NewStep = tryBuildCapture(SemaRef, Step, Captures, ".new_step");
8434 Lower->getIntegerConstantExpr(SemaRef.Context)) {
8439 Step->getIntegerConstantExpr(SemaRef.Context)) {
8478 Upper->getIntegerConstantExpr(SemaRef.Context)) {
8501 uint64_t LowerSize = SemaRef.Context.getTypeSize(LowerTy);
8502 uint64_t UpperSize = SemaRef.Context.getTypeSize(UpperTy);
8505 QualType CastType = SemaRef.Context.getIntTypeForBitwidth(
8508 SemaRef
8510 SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, Upper).get(),
8513 Lower = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, Lower).get();
8514 NewStep = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, NewStep.get());
8529 SemaRef.BuildBinOp(S, DefaultLoc, BO_Sub, Diff.get(), NewStep.get());
8536 Diff = SemaRef.BuildBinOp(
8538 SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get());
8542 Diff = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, Diff.get());
8547 Diff = SemaRef.BuildBinOp(S, DefaultLoc, BO_Sub, Upper, Diff.get());
8551 Diff = SemaRef.BuildBinOp(S, DefaultLoc, BO_Sub, Upper, Lower);
8556 SemaRef.Diag(Upper->getBeginLoc(), diag::err_omp_loop_diff_cxx)
8566 Diff = SemaRef.BuildBinOp(
8568 SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get());
8575 SemaRef.BuildBinOp(S, DefaultLoc, BO_Add, Diff.get(), NewStep.get());
8582 Diff = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, Diff.get());
8587 Diff = SemaRef.BuildBinOp(S, DefaultLoc, BO_Div, Diff.get(), NewStep.get());
8600 !SemaRef.getLangOpts().CPlusPlus)
8612 SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, IS.MinValue);
8616 ExprResult LBMinVal = SemaRef.BuildBinOp(S, DefaultLoc, BO_Assign,
8622 SemaRef.BuildBinOp(S, DefaultLoc, BO_Comma, LBMinVal.get(), LBVal);
8626 LBMinVal = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, LBMinVal.get());
8632 SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, IS.MaxValue);
8636 ExprResult LBMaxVal = SemaRef.BuildBinOp(S, DefaultLoc, BO_Assign,
8642 SemaRef.BuildBinOp(S, DefaultLoc, BO_Comma, LBMaxVal.get(), LBVal);
8646 LBMaxVal = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, LBMaxVal.get());
8651 tryBuildCapture(SemaRef, LBMinVal.get(), Captures, ".lb_min").get();
8653 tryBuildCapture(SemaRef, LBMaxVal.get(), Captures, ".lb_max").get();
8658 SemaRef.BuildBinOp(S, DefaultLoc, BO_LT, LBMin, LBMax);
8662 tryBuildCapture(SemaRef, MinLessMaxRes.get(), Captures, ".min_less_max")
8669 ExprResult MinLB = SemaRef.ActOnConditionalOp(DefaultLoc, DefaultLoc,
8677 ExprResult MaxLB = SemaRef.ActOnConditionalOp(DefaultLoc, DefaultLoc,
8685 SemaRef.BuildBinOp(S, DefaultLoc, BO_Assign, IS.CounterVar, LBVal);
8698 SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, IS.MinValue);
8702 ExprResult UBMinVal = SemaRef.BuildBinOp(S, DefaultLoc, BO_Assign,
8708 SemaRef.BuildBinOp(S, DefaultLoc, BO_Comma, UBMinVal.get(), UBVal);
8712 UBMinVal = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, UBMinVal.get());
8718 SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, IS.MaxValue);
8722 ExprResult UBMaxVal = SemaRef.BuildBinOp(S, DefaultLoc, BO_Assign,
8728 SemaRef.BuildBinOp(S, DefaultLoc, BO_Comma, UBMaxVal.get(), UBVal);
8732 UBMaxVal = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, UBMaxVal.get());
8737 tryBuildCapture(SemaRef, UBMinVal.get(), Captures, ".ub_min").get();
8739 tryBuildCapture(SemaRef, UBMaxVal.get(), Captures, ".ub_max").get();
8744 SemaRef.BuildBinOp(S, DefaultLoc, BO_GT, UBMin, UBMax);
8747 Expr *MinGreaterMax = tryBuildCapture(SemaRef, MinGreaterMaxRes.get(),
8755 ExprResult MaxUB = SemaRef.ActOnConditionalOp(
8763 ExprResult MinUB = SemaRef.ActOnConditionalOp(
8772 Expr *Upper = tryBuildCapture(SemaRef, UBExpr, Captures, ".upper").get();
8773 Expr *Lower = tryBuildCapture(SemaRef, LBExpr, Captures, ".lower").get();
8777 ExprResult Diff = calculateNumIters(SemaRef, S, DefaultLoc, Lower, Upper,
8785 ASTContext &C = SemaRef.Context;
8794 if (!SemaRef.Context.hasSameType(Diff.get()->getType(), Type)) {
8795 Diff = SemaRef.PerformImplicitConversion(Diff.get(), Type,
8807 SemaRef.Diag(DefaultLoc, diag::warn_omp_loop_64_bit_var)
8813 if (!SemaRef.Context.hasSameType(Diff.get()->getType(), NewType)) {
8814 Diff = SemaRef.PerformImplicitConversion(Diff.get(), NewType,
8843 LBNonRect ? LBExpr : tryBuildCapture(SemaRef, LBExpr, Captures).get();
8845 UBNonRect ? UBExpr : tryBuildCapture(SemaRef, UBExpr, Captures).get();
8857 ExprResult Diff = calculateNumIters(SemaRef, S, DefaultLoc, Lower, Upper,
8865 Diff = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, Diff.get());
8869 ExprResult NewStep = tryBuildCapture(SemaRef, Step, Captures, ".new_step");
8872 Diff = SemaRef.BuildBinOp(S, DefaultLoc, BO_Mul, Diff.get(), NewStep.get());
8877 Diff = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, Diff.get());
8883 !SemaRef.Context.hasSameType(
8885 SemaRef.Context.getUnsignedPointerDiffType())) {
8886 Diff = SemaRef.PerformImplicitConversion(
8887 Diff.get(), SemaRef.Context.getUnsignedPointerDiffType(),
8896 Diff = SemaRef.BuildBinOp(
8898 SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, Lower).get(),
8905 Diff = SemaRef.BuildBinOp(
8907 SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, Upper).get(),
8914 if (SemaRef.Context.hasSameType(Diff.get()->getType(), VarType))
8915 Diff = SemaRef.PerformImplicitConversion(Diff.get(), VarType,
8921 Sema::TentativeAnalysisScope Trap(SemaRef);
8922 Diff = SemaRef.ActOnFinishFullExpr(Diff.get(), /*DiscardedValue=*/false);
8948 return SemaRef
8950 SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get(),
8951 SemaRef.Context.BoolTy, /*Action=*/AssignmentAction::Casting,
8956 Sema::TentativeAnalysisScope Trap(SemaRef);
8958 ExprResult NewLB = tryBuildCapture(SemaRef, LB, Captures);
8959 ExprResult NewUB = tryBuildCapture(SemaRef, UB, Captures);
8964 SemaRef.BuildBinOp(S, DefaultLoc,
8969 if (!SemaRef.Context.hasSameUnqualifiedType(CondExpr.get()->getType(),
8970 SemaRef.Context.BoolTy))
8971 CondExpr = SemaRef.PerformImplicitConversion(
8972 CondExpr.get(), SemaRef.Context.BoolTy,
8987 VD = SemaRef.OpenMP().isOpenMPCapturedDecl(LCDecl);
8989 SemaRef, VD, VD->getType().getNonReferenceType(), DefaultLoc);
9005 SemaRef, DefaultLoc, Type, LCDecl->getName(),
9008 ? buildDeclRefExpr(SemaRef, cast<VarDecl>(LCDecl), Type, DefaultLoc)
9012 return buildDeclRefExpr(SemaRef, PrivateVar, Type, DefaultLoc);
9027 Expr *Cnt = SemaRef.DefaultLvalueConversion(Counter).get();
9034 Cnt = SemaRef.BuildBinOp(S, Loc, BOK, Cnt, Inc).get();
9040 !SemaRef.getLangOpts().CPlusPlus)
9044 *TestIsLessOp ? Cnt : tryBuildCapture(SemaRef, LB, Captures).get();
9046 *TestIsLessOp ? tryBuildCapture(SemaRef, LB, Captures).get() : Cnt;
9051 SemaRef, S, DefaultLoc, Lower, Upper, Step, VarType,
9071 OpenMPIterationSpaceChecker ISC(SemaRef, /*SupportsNonRectangular=*/true,
9081 PrivateRef = buildCapture(SemaRef, D, ISC.getLoopDeclRefExpr(),
9091 SemaRef.MarkDeclarationsReferencedInExpr(buildDeclRefExpr(
9092 SemaRef, const_cast<VarDecl *>(Var),
9130 reportOriginalDsa(SemaRef, DSAStack, D, DVar, /*IsLoopIterVar=*/true);
9163 OpenMPDirectiveKind DKind, Stmt *S, Sema &SemaRef, DSAStackTy &DSA,
9180 if (!For && (SemaRef.LangOpts.OpenMP <= 45 || !CXXFor)) {
9181 SemaRef.Diag(S->getBeginLoc(), diag::err_omp_not_for)
9187 SemaRef.Diag(DSA.getConstructLoc(),
9192 SemaRef.Diag(CollapseLoopCountExpr->getExprLoc(),
9196 SemaRef.Diag(OrderedLoopCountExpr->getExprLoc(),
9205 if (CXXFor && SemaRef.CurContext->isDependentContext())
9208 OpenMPIterationSpaceChecker ISC(SemaRef, SupportsNonRectangular, DSA,
9229 !(SemaRef.getLangOpts().CPlusPlus && VarType->isOverloadableType())) {
9230 SemaRef.Diag(Init->getBeginLoc(), diag::err_omp_loop_variable_type)
9231 << SemaRef.getLangOpts().CPlusPlus;
9255 if (ISC.dependent() || SemaRef.CurContext->isDependentContext() || HasErrors)
9346 Expr *Cnt = SemaRef
9354 SemaRef.ActOnIntegerConstant(DoacrossC->getColonLoc(), /*Val=*/1)
9378 buildCounterInit(Sema &SemaRef, Scope *S, SourceLocation Loc, ExprResult VarRef,
9384 : tryBuildCapture(SemaRef, Start.get(), Captures);
9387 if (!SemaRef.Context.hasSameType(NewStart.get()->getType(),
9389 NewStart = SemaRef.PerformImplicitConversion(
9397 SemaRef.BuildBinOp(S, Loc, BO_Assign, VarRef.get(), NewStart.get());
9403 Sema &SemaRef, Scope *S, SourceLocation Loc, ExprResult VarRef,
9408 Iter = SemaRef.ActOnParenExpr(Loc, Loc, Iter.get());
9415 NewStep = tryBuildCapture(SemaRef, Step.get(), *Captures);
9419 SemaRef.BuildBinOp(S, Loc, BO_Mul, Iter.get(), NewStep.get());
9427 ExprResult NewStart = SemaRef.ActOnParenExpr(Loc, Loc, Start.get());
9431 NewStart = tryBuildCapture(SemaRef, Start.get(), *Captures);
9441 Sema::TentativeAnalysisScope Trap(SemaRef);
9444 SemaRef.BuildBinOp(S, Loc, BO_Assign, VarRef.get(), NewStart.get());
9447 SemaRef.BuildBinOp(S, Loc, Subtract ? BO_SubAssign : BO_AddAssign,
9450 Update = SemaRef.CreateBuiltinBinOp(Loc, BO_Comma, Update.get(),
9458 Update = SemaRef.BuildBinOp(S, Loc, Subtract ? BO_Sub : BO_Add,
9463 if (!SemaRef.Context.hasSameType(Update.get()->getType(),
9465 Update = SemaRef.PerformImplicitConversion(
9472 Update = SemaRef.BuildBinOp(S, Loc, BO_Assign, VarRef.get(), Update.get());
9479 static ExprResult widenIterationCount(unsigned Bits, Expr *E, Sema &SemaRef) {
9482 ASTContext &C = SemaRef.Context;
9489 return SemaRef.PerformImplicitConversion(
9495 static bool fitsInto(unsigned Bits, bool Signed, const Expr *E, Sema &SemaRef) {
9499 E->getIntegerConstantExpr(SemaRef.Context))
9616 Expr *OrderedLoopCountExpr, Stmt *AStmt, Sema &SemaRef,
9621 bool SupportsNonPerfectlyNested = (SemaRef.LangOpts.OpenMP >= 50) &&
9629 CollapseLoopCountExpr->EvaluateAsInt(Result, SemaRef.getASTContext())) {
9645 SemaRef.getASTContext())) {
9648 SemaRef.Diag(OrderedLoopCountExpr->getExprLoc(),
9651 SemaRef.Diag(CollapseLoopCountExpr->getExprLoc(),
9669 [DKind, &SemaRef, &DSA, NumLoops, NestedLoopCount,
9674 DKind, CurStmt, SemaRef, DSA, Cnt, NestedLoopCount,
9689 [&SemaRef, &Captures](OMPLoopTransformationDirective *Transform) {
9703 SemaRef, D, D->getType().getNonReferenceType(),
9714 if (SemaRef.CurContext->isDependentContext())
9752 SemaRef
9757 SemaRef);
9760 SemaRef
9765 SemaRef);
9770 ASTContext &C = SemaRef.Context;
9777 SemaRef.BuildBinOp(CurScope, PreCond.get()->getExprLoc(), BO_LAnd,
9784 LastIteration32 = SemaRef.BuildBinOp(
9786 SemaRef
9792 LastIteration64 = SemaRef.BuildBinOp(
9794 SemaRef
9803 if (SemaRef.getLangOpts().OpenMPOptimisticCollapse ||
9810 LastIteration64.get(), SemaRef))))
9817 SemaRef.Context.getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/0);
9819 SemaRef.Context.getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/1);
9828 LastIteration = SemaRef.BuildBinOp(
9831 SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get());
9838 bool IsConstant = LastIteration.get()->isIntegerConstantExpr(SemaRef.Context);
9842 tryBuildCapture(SemaRef, LastIteration.get(), Captures);
9846 NumIterations = SemaRef.BuildBinOp(
9848 SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get());
9862 VarDecl *LBDecl = buildVarDecl(SemaRef, InitLoc, VType, ".omp.lb");
9863 LB = buildDeclRefExpr(SemaRef, LBDecl, VType, InitLoc);
9864 SemaRef.AddInitializerToDecl(LBDecl,
9865 SemaRef.ActOnIntegerConstant(InitLoc, 0).get(),
9869 VarDecl *UBDecl = buildVarDecl(SemaRef, InitLoc, VType, ".omp.ub");
9870 UB = buildDeclRefExpr(SemaRef, UBDecl, VType, InitLoc);
9871 SemaRef.AddInitializerToDecl(UBDecl, LastIteration.get(),
9876 QualType Int32Ty = SemaRef.Context.getIntTypeForBitwidth(32, true);
9877 VarDecl *ILDecl = buildVarDecl(SemaRef, InitLoc, Int32Ty, ".omp.is_last");
9878 IL = buildDeclRefExpr(SemaRef, ILDecl, Int32Ty, InitLoc);
9879 SemaRef.AddInitializerToDecl(ILDecl,
9880 SemaRef.ActOnIntegerConstant(InitLoc, 0).get(),
9885 buildVarDecl(SemaRef, InitLoc, StrideVType, ".omp.stride");
9886 ST = buildDeclRefExpr(SemaRef, STDecl, StrideVType, InitLoc);
9887 SemaRef.AddInitializerToDecl(STDecl,
9888 SemaRef.ActOnIntegerConstant(InitLoc, 1).get(),
9893 ExprResult IsUBGreater = SemaRef.BuildBinOp(CurScope, InitLoc, BO_GT,
9895 ExprResult CondOp = SemaRef.ActOnConditionalOp(
9898 EUB = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, UB.get(),
9900 EUB = SemaRef.ActOnFinishFullExpr(EUB.get(), /*DiscardedValue=*/false);
9909 buildVarDecl(SemaRef, InitLoc, VType, ".omp.comb.lb");
9910 CombLB = buildDeclRefExpr(SemaRef, CombLBDecl, VType, InitLoc);
9911 SemaRef.AddInitializerToDecl(
9912 CombLBDecl, SemaRef.ActOnIntegerConstant(InitLoc, 0).get(),
9917 buildVarDecl(SemaRef, InitLoc, VType, ".omp.comb.ub");
9918 CombUB = buildDeclRefExpr(SemaRef, CombUBDecl, VType, InitLoc);
9919 SemaRef.AddInitializerToDecl(CombUBDecl, LastIteration.get(),
9922 ExprResult CombIsUBGreater = SemaRef.BuildBinOp(
9925 SemaRef.ActOnConditionalOp(InitLoc, InitLoc, CombIsUBGreater.get(),
9927 CombEUB = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, CombUB.get(),
9930 SemaRef.ActOnFinishFullExpr(CombEUB.get(), /*DiscardedValue=*/false);
9946 buildDeclRefExpr(SemaRef, PrevLBDecl, PrevLBDecl->getType(), InitLoc);
9948 buildDeclRefExpr(SemaRef, PrevUBDecl, PrevUBDecl->getType(), InitLoc);
9956 VarDecl *IVDecl = buildVarDecl(SemaRef, InitLoc, RealVType, ".omp.iv");
9957 IV = buildDeclRefExpr(SemaRef, IVDecl, RealVType, InitLoc);
9964 : SemaRef.ActOnIntegerConstant(SourceLocation(), 0).get();
9965 Init = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, IV.get(), RHS);
9966 Init = SemaRef.ActOnFinishFullExpr(Init.get(), /*DiscardedValue=*/false);
9975 : SemaRef.ActOnIntegerConstant(SourceLocation(), 0).get();
9977 SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, IV.get(), CombRHS);
9979 SemaRef.ActOnFinishFullExpr(CombInit.get(), /*DiscardedValue=*/false);
9994 SemaRef
9996 SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get())
9999 SemaRef.ActOnFinishFullExpr(BoundUB, /*DiscardedValue=*/false).get();
10006 ? SemaRef.BuildBinOp(CurScope, CondLoc,
10009 : SemaRef.BuildBinOp(CurScope, CondLoc, BO_LT, IV.get(),
10013 CombDistCond = SemaRef.BuildBinOp(CurScope, CondLoc, BO_LT, IV.get(),
10022 SemaRef
10025 SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get())
10028 SemaRef.ActOnFinishFullExpr(BoundCombUB, /*DiscardedValue=*/false)
10032 SemaRef.BuildBinOp(CurScope, CondLoc, UseStrictCompare ? BO_LT : BO_LE,
10038 SemaRef.BuildBinOp(CurScope, IncLoc, BO_Add, IV.get(),
10039 SemaRef.ActOnIntegerConstant(IncLoc, 1).get());
10042 Inc = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, IV.get(), Inc.get());
10043 Inc = SemaRef.ActOnFinishFullExpr(Inc.get(), /*DiscardedValue=*/false);
10057 NextLB = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Add, LB.get(), ST.get());
10062 SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, LB.get(), NextLB.get());
10064 SemaRef.ActOnFinishFullExpr(NextLB.get(), /*DiscardedValue=*/false);
10068 NextUB = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Add, UB.get(), ST.get());
10073 SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, UB.get(), NextUB.get());
10075 SemaRef.ActOnFinishFullExpr(NextUB.get(), /*DiscardedValue=*/false);
10080 SemaRef.BuildBinOp(CurScope, IncLoc, BO_Add, CombLB.get(), ST.get());
10084 CombNextLB = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, CombLB.get(),
10086 CombNextLB = SemaRef.ActOnFinishFullExpr(CombNextLB.get(),
10092 SemaRef.BuildBinOp(CurScope, IncLoc, BO_Add, CombUB.get(), ST.get());
10096 CombNextUB = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, CombUB.get(),
10098 CombNextUB = SemaRef.ActOnFinishFullExpr(CombNextUB.get(),
10112 DistCond = SemaRef.BuildBinOp(
10117 SemaRef.BuildBinOp(CurScope, DistIncLoc, BO_Add, IV.get(), ST.get());
10119 DistInc = SemaRef.BuildBinOp(CurScope, DistIncLoc, BO_Assign, IV.get(),
10122 SemaRef.ActOnFinishFullExpr(DistInc.get(), /*DiscardedValue=*/false);
10129 if (!SemaRef.Context.hasSameType(UB.get()->getType(),
10131 NewPrevUB = SemaRef.BuildCStyleCastExpr(
10133 SemaRef.Context.getTrivialTypeSourceInfo(UB.get()->getType()),
10138 ExprResult IsUBGreater = SemaRef.BuildBinOp(CurScope, DistEUBLoc, BO_GT,
10140 ExprResult CondOp = SemaRef.ActOnConditionalOp(
10142 PrevEUB = SemaRef.BuildBinOp(CurScope, DistIncLoc, BO_Assign, UB.get(),
10145 SemaRef.ActOnFinishFullExpr(PrevEUB.get(), /*DiscardedValue=*/false);
10153 SemaRef
10156 SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get())
10159 SemaRef.ActOnFinishFullExpr(BoundPrevUB, /*DiscardedValue=*/false)
10163 SemaRef.BuildBinOp(CurScope, CondLoc, UseStrictCompare ? BO_LT : BO_LE,
10199 ExprResult Prod = SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get();
10201 Prod = SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Mul, Prod.get(),
10209 SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Div, Acc.get(), Prod.get());
10222 Prod = SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Mul, Iter.get(),
10226 Acc = SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Sub, Acc.get(), Prod.get());
10231 SemaRef, VD, IS.CounterVar->getType(), IS.CounterVar->getExprLoc(),
10234 buildCounterInit(SemaRef, CurScope, UpdLoc, CounterVar,
10241 SemaRef, CurScope, UpdLoc, CounterVar, IS.CounterInit, Iter,
10250 buildCounterUpdate(SemaRef, CurScope, UpdLoc, CounterVar,
10286 Built.CalcLastIteration = SemaRef
10385 CapturedStmt *CS = setBranchProtectedScope(SemaRef, OMPD_simd, AStmt);
10393 CS, SemaRef, *DSAStack, VarsWithImplicitDSA, B);
10397 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
10400 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
10420 AStmt, SemaRef, *DSAStack, VarsWithImplicitDSA, B);
10424 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
10439 CapturedStmt *CS = setBranchProtectedScope(SemaRef, OMPD_for_simd, AStmt);
10447 getOrderedNumberExpr(Clauses), CS, SemaRef, *DSAStack,
10452 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
10455 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
10462 static bool checkSectionsDirective(Sema &SemaRef, OpenMPDirectiveKind DKind,
10480 SemaRef.Diag(SectionStmt->getBeginLoc(),
10489 SemaRef.Diag(AStmt->getBeginLoc(), diag::err_omp_sections_not_compound_stmt)
10500 if (checkSectionsDirective(SemaRef, OMPD_sections, AStmt, DSAStack))
10503 SemaRef.setFunctionHasBranchProtectedScope();
10516 SemaRef.setFunctionHasBranchProtectedScope();
10547 if (!SemaRef.CurContext->isDependentContext()) {
10575 SemaRef.setFunctionHasBranchProtectedScope();
10615 if (checkGenericLoopLastprivate(SemaRef, Clauses, OMPD_loop, DSAStack))
10618 setBranchProtectedScope(SemaRef, OMPD_loop, AStmt);
10624 AStmt, SemaRef, *DSAStack, VarsWithImplicitDSA, B);
10628 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
10644 if (checkGenericLoopLastprivate(SemaRef, Clauses, OMPD_teams_loop, DSAStack))
10647 CapturedStmt *CS = setBranchProtectedScope(SemaRef, OMPD_teams_loop, AStmt);
10653 /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
10658 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
10676 if (checkGenericLoopLastprivate(SemaRef, Clauses, OMPD_target_teams_loop,
10681 setBranchProtectedScope(SemaRef, OMPD_target_teams_loop, AStmt);
10687 /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
10692 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
10697 teamsLoopCanBeParallelFor(AStmt, SemaRef));
10709 if (checkGenericLoopLastprivate(SemaRef, Clauses, OMPD_parallel_loop,
10714 setBranchProtectedScope(SemaRef, OMPD_parallel_loop, AStmt);
10720 /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
10725 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
10741 if (checkGenericLoopLastprivate(SemaRef, Clauses, OMPD_target_parallel_loop,
10746 setBranchProtectedScope(SemaRef, OMPD_target_parallel_loop, AStmt);
10752 /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
10757 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
10773 SemaRef.setFunctionHasBranchProtectedScope();
10802 SemaRef.setFunctionHasBranchProtectedScope();
10814 SemaRef.setFunctionHasBranchProtectedScope();
10868 SemaRef.setFunctionHasBranchProtectedScope();
10883 setBranchProtectedScope(SemaRef, OMPD_parallel_for, AStmt);
10890 getOrderedNumberExpr(Clauses), AStmt, SemaRef, *DSAStack,
10895 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
10910 setBranchProtectedScope(SemaRef, OMPD_parallel_for_simd, AStmt);
10917 getOrderedNumberExpr(Clauses), CS, SemaRef, *DSAStack,
10922 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
10925 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
10938 setBranchProtectedScope(SemaRef, OMPD_parallel_master, AStmt);
10951 setBranchProtectedScope(SemaRef, OMPD_parallel_masked, AStmt);
10961 if (checkSectionsDirective(SemaRef, OMPD_parallel_sections, AStmt, DSAStack))
10964 SemaRef.setFunctionHasBranchProtectedScope();
11004 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
11008 setBranchProtectedScope(SemaRef, OMPD_task, AStmt);
11082 SemaRef.setFunctionHasBranchProtectedScope();
11290 SemaRef.setFunctionHasBranchProtectedScope();
11328 Sema &SemaRef;
11349 OpenMPAtomicUpdateChecker(Sema &SemaRef)
11350 : SemaRef(SemaRef), X(nullptr), E(nullptr), UpdateExpr(nullptr),
11401 X->IgnoreParenImpCasts()->Profile(XId, SemaRef.getASTContext(),
11403 LHS->IgnoreParenImpCasts()->Profile(LHSId, SemaRef.getASTContext(),
11405 RHS->IgnoreParenImpCasts()->Profile(RHSId, SemaRef.getASTContext(),
11440 SemaRef.Diag(ErrorLoc, DiagId) << ErrorRange;
11441 SemaRef.Diag(NoteLoc, NoteId) << ErrorFound << NoteRange;
11444 if (SemaRef.CurContext->isDependentContext())
11488 E = SemaRef.ActOnIntegerConstant(OpLoc, /*uint64_t Val=*/1).get();
11517 SemaRef.Diag(ErrorLoc, DiagId) << ErrorRange;
11518 SemaRef.Diag(NoteLoc, NoteId) << ErrorFound << NoteRange;
11521 if (SemaRef.CurContext->isDependentContext())
11527 auto *OVEX = new (SemaRef.getASTContext())
11529 auto *OVEExpr = new (SemaRef.getASTContext())
11532 SemaRef.CreateBuiltinBinOp(OpLoc, Op, IsXLHSInRHSPart ? OVEX : OVEExpr,
11536 Update = SemaRef.PerformImplicitConversion(Update.get(), X->getType(),
12559 if (SemaRef.CurContext->isDependentContext())
12621 if (SemaRef.CurContext->isDependentContext())
12632 OpenMPAtomicUpdateChecker Checker(SemaRef);
12640 if (!SemaRef.CurContext->isDependentContext()) {
12670 OpenMPAtomicUpdateChecker Checker(SemaRef);
12695 if (SemaRef.CurContext->isDependentContext())
12724 OpenMPAtomicUpdateChecker Checker(SemaRef);
12731 if (IsUpdateExprFound && !SemaRef.CurContext->isDependentContext()) {
12762 !SemaRef.CurContext->isDependentContext()) {
12859 if (SemaRef.CurContext->isDependentContext())
12864 OpenMPAtomicCompareCaptureChecker Checker(SemaRef);
12884 OpenMPAtomicCompareChecker Checker(SemaRef);
12922 SemaRef.setFunctionHasBranchProtectedScope();
12936 CapturedStmt *CS = setBranchProtectedScope(SemaRef, OMPD_target, AStmt);
12987 setBranchProtectedScope(SemaRef, OMPD_target_parallel, AStmt);
13001 setBranchProtectedScope(SemaRef, OMPD_target_parallel_for, AStmt);
13008 getOrderedNumberExpr(Clauses), CS, SemaRef, *DSAStack,
13013 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13079 SemaRef.setFunctionHasBranchProtectedScope();
13091 setBranchProtectedScope(SemaRef, OMPD_target_enter_data, AStmt);
13111 setBranchProtectedScope(SemaRef, OMPD_target_exit_data, AStmt);
13131 setBranchProtectedScope(SemaRef, OMPD_target_update, AStmt);
13150 static bool checkNumExprsInClause(SemaBase &SemaRef,
13159 SemaRef.Diag(VarList[MaxNum]->getBeginLoc(), Diag)
13183 setBranchProtectedScope(SemaRef, OMPD_teams, AStmt);
13261 /*OrderedLoopCountExpr=*/nullptr, AStmt, SemaRef,
13266 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
13272 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
13278 if (checkReductionClauseWithNogroup(SemaRef, Clauses))
13281 SemaRef.setFunctionHasBranchProtectedScope();
13294 setBranchProtectedScope(SemaRef, OMPD_taskloop_simd, AStmt);
13302 /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
13307 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13313 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
13319 if (checkReductionClauseWithNogroup(SemaRef, Clauses))
13321 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
13340 /*OrderedLoopCountExpr=*/nullptr, AStmt, SemaRef,
13345 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
13351 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
13357 if (checkReductionClauseWithNogroup(SemaRef, Clauses))
13360 SemaRef.setFunctionHasBranchProtectedScope();
13378 /*OrderedLoopCountExpr=*/nullptr, AStmt, SemaRef,
13383 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
13389 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
13395 if (checkReductionClauseWithNogroup(SemaRef, Clauses))
13398 SemaRef.setFunctionHasBranchProtectedScope();
13411 setBranchProtectedScope(SemaRef, OMPD_master_taskloop_simd, AStmt);
13419 /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
13424 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13430 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
13436 if (checkReductionClauseWithNogroup(SemaRef, Clauses))
13438 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
13452 setBranchProtectedScope(SemaRef, OMPD_masked_taskloop_simd, AStmt);
13460 /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
13465 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13471 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
13477 if (checkReductionClauseWithNogroup(SemaRef, Clauses))
13479 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
13493 setBranchProtectedScope(SemaRef, OMPD_parallel_master_taskloop, AStmt);
13500 /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
13505 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
13511 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
13517 if (checkReductionClauseWithNogroup(SemaRef, Clauses))
13532 setBranchProtectedScope(SemaRef, OMPD_parallel_masked_taskloop, AStmt);
13539 /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
13544 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
13550 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
13556 if (checkReductionClauseWithNogroup(SemaRef, Clauses))
13571 SemaRef, OMPD_parallel_master_taskloop_simd, AStmt);
13578 /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
13583 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13589 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
13595 if (checkReductionClauseWithNogroup(SemaRef, Clauses))
13597 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
13611 SemaRef, OMPD_parallel_masked_taskloop_simd, AStmt);
13618 /*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
13623 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13629 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
13635 if (checkReductionClauseWithNogroup(SemaRef, Clauses))
13637 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
13657 SemaRef, *DSAStack, VarsWithImplicitDSA, B);
13661 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
13664 SemaRef.setFunctionHasBranchProtectedScope();
13677 setBranchProtectedScope(SemaRef, OMPD_distribute_parallel_for, AStmt);
13684 nullptr /*ordered not a clause on distribute*/, CS, SemaRef, *DSAStack,
13689 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
13704 SemaRef, OMPD_distribute_parallel_for_simd, AStmt);
13711 nullptr /*ordered not a clause on distribute*/, CS, SemaRef, *DSAStack,
13716 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13719 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
13733 setBranchProtectedScope(SemaRef, OMPD_distribute_simd, AStmt);
13741 SemaRef, *DSAStack, VarsWithImplicitDSA, B);
13745 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13748 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
13762 setBranchProtectedScope(SemaRef, OMPD_target_parallel_for_simd, AStmt);
13769 getOrderedNumberExpr(Clauses), CS, SemaRef, *DSAStack,
13774 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13777 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
13790 CapturedStmt *CS = setBranchProtectedScope(SemaRef, OMPD_target_simd, AStmt);
13797 getOrderedNumberExpr(Clauses), CS, SemaRef, *DSAStack,
13802 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13805 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
13819 setBranchProtectedScope(SemaRef, OMPD_teams_distribute, AStmt);
13827 SemaRef, *DSAStack, VarsWithImplicitDSA, B);
13831 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
13847 setBranchProtectedScope(SemaRef, OMPD_teams_distribute_simd, AStmt);
13854 nullptr /*ordered not a clause on distribute*/, CS, SemaRef, *DSAStack,
13859 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13862 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
13878 SemaRef, OMPD_teams_distribute_parallel_for_simd, AStmt);
13885 nullptr /*ordered not a clause on distribute*/, CS, SemaRef, *DSAStack,
13890 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
13893 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
13909 SemaRef, OMPD_teams_distribute_parallel_for, AStmt);
13916 nullptr /*ordered not a clause on distribute*/, CS, SemaRef, *DSAStack,
13922 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
13938 setBranchProtectedScope(SemaRef, OMPD_target_teams, AStmt);
13980 setBranchProtectedScope(SemaRef, OMPD_target_teams_distribute, AStmt);
13987 nullptr /*ordered not a clause on distribute*/, CS, SemaRef, *DSAStack,
13992 assert((SemaRef.CurContext->isDependentContext() || B.builtAll()) &&
14012 SemaRef, OMPD_target_teams_distribute_parallel_for, AStmt);
14019 nullptr /*ordered not a clause on distribute*/, CS, SemaRef, *DSAStack,
14024 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
14045 SemaRef, OMPD_target_teams_distribute_parallel_for_simd, AStmt);
14054 SemaRef, *DSAStack, VarsWithImplicitDSA, B);
14058 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
14061 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
14081 SemaRef, OMPD_target_teams_distribute_simd, AStmt);
14088 nullptr /*ordered not a clause on distribute*/, CS, SemaRef, *DSAStack,
14093 if (finishLinearClauses(SemaRef, Clauses, B, DSAStack))
14096 if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
14114 checkOpenMPLoop(Kind, nullptr, nullptr, CurStmt, SemaRef, *DSAStack,
14213 Scope *CurScope = SemaRef.getCurScope();
14235 if (SemaRef.CurContext->isDependentContext())
14251 CaptureVars CopyTransformer(SemaRef);
14273 buildVarDecl(SemaRef, {}, CntTy, FloorCntName, nullptr, OrigCntVar);
14287 &SemaRef.PP.getIdentifierTable().get(TileCntName));
14298 auto MakeDimTileSize = [&SemaRef = this->SemaRef, &CopyTransformer, &Context,
14326 Expr *Cond = AssertSuccess(SemaRef.BuildBinOp(
14347 auto MakeTileIVRef = [&SemaRef = this->SemaRef, &TileIndVars, I, IVTy,
14349 return buildDeclRefExpr(SemaRef, TileIndVars[I], IVTy,
14352 auto MakeFloorIVRef = [&SemaRef = this->SemaRef, &FloorIndVars, I, IVTy,
14354 return buildDeclRefExpr(SemaRef, FloorIndVars[I], IVTy,
14359 SemaRef.AddInitializerToDecl(
14360 TileIndVars[I], SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(),
14372 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add,
14377 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
14381 ExprResult MinTileAndIterSpace = SemaRef.ActOnConditionalOp(
14387 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
14393 ExprResult IncrStmt = SemaRef.BuildUnaryOp(
14437 auto MakeFloorIVRef = [&SemaRef = this->SemaRef, &FloorIndVars, I, IVTy,
14439 return buildDeclRefExpr(SemaRef, FloorIndVars[I], IVTy,
14444 SemaRef.AddInitializerToDecl(
14446 SemaRef.ActOnIntegerConstant(LoopHelper.Init->getExprLoc(), 0).get(),
14457 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
14464 SemaRef.BuildBinOp(CurScope, LoopHelper.Inc->getExprLoc(), BO_AddAssign,
14485 Scope *CurScope = SemaRef.getCurScope();
14490 if (checkMutuallyExclusiveClauses(SemaRef, Clauses,
14513 if (SemaRef.CurContext->isDependentContext())
14629 buildVarDecl(SemaRef, {}, IVTy, OuterIVName, nullptr, OrigVar);
14631 return buildDeclRefExpr(SemaRef, OuterIVDecl, IVTy, OrigVarLoc);
14637 InnerIVDecl->setDeclName(&SemaRef.PP.getIdentifierTable().get(InnerIVName));
14639 return buildDeclRefExpr(SemaRef, InnerIVDecl, IVTy, OrigVarLoc);
14644 CaptureVars CopyTransformer(SemaRef);
14651 ExprResult LValueConv = SemaRef.DefaultLvalueConversion(MakeOuterRef());
14652 SemaRef.AddInitializerToDecl(InnerIVDecl, LValueConv.get(),
14667 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add,
14672 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
14677 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
14682 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LAnd,
14688 ExprResult InnerIncr = SemaRef.BuildUnaryOp(
14726 SemaRef.AddInitializerToDecl(
14728 SemaRef.ActOnIntegerConstant(LoopHelper.Init->getExprLoc(), 0).get(),
14737 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
14744 SemaRef.BuildBinOp(CurScope, LoopHelper.Inc->getExprLoc(), BO_AddAssign,
14764 Scope *CurScope = SemaRef.getCurScope();
14781 if (SemaRef.CurContext->isDependentContext())
14852 CaptureVars CopyTransformer(SemaRef);
14860 buildVarDecl(SemaRef, {}, IVTy, ForwardIVName, nullptr, OrigVar);
14861 auto MakeForwardRef = [&SemaRef = this->SemaRef, ForwardIVDecl, IVTy,
14863 return buildDeclRefExpr(SemaRef, ForwardIVDecl, IVTy, OrigVarLoc);
14870 &SemaRef.PP.getIdentifierTable().get(ReversedIVName));
14878 SemaRef.AddInitializerToDecl(ForwardIVDecl, Zero, /*DirectInit=*/false);
14889 SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
14898 ExprResult Incr = SemaRef.BuildUnaryOp(CurScope, LoopHelper.Inc->getExprLoc(),
14909 ExprResult Minus = SemaRef.BuildBinOp(CurScope, TransformLoc, BO_Sub,
14913 Minus = SemaRef.BuildBinOp(CurScope, TransformLoc, BO_Sub, Minus.get(),
14921 SemaRef.AddInitializerToDecl(ReversedIVDecl, Minus.get(),
14951 DeclContext *CurContext = SemaRef.CurContext;
14952 Scope *CurScope = SemaRef.getCurScope();
15048 CaptureVars CopyTransformer(SemaRef);
15086 &SemaRef.PP.getIdentifierTable().get(PermutedCntName));
15089 return buildDeclRefExpr(SemaRef, PermutedCntDecl, IVTy, OrigVarLoc);
15096 ExprResult Zero = SemaRef.ActOnIntegerConstant(OrigVarLoc, 0);
15099 SemaRef.AddInitializerToDecl(PermutedCntDecl, Zero.get(),
15112 SemaRef.BuildBinOp(CurScope, SourceHelper.Cond->getExprLoc(), BO_LT,
15121 ExprResult IncrStmt = SemaRef.BuildUnaryOp(
15413 ExprResult Val = SemaRef.CheckBooleanCondition(StartLoc, Condition);
15423 !SemaRef.CurContext->isDependentContext()) {
15424 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
15426 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
15446 ExprResult Val = SemaRef.CheckBooleanCondition(StartLoc, Condition);
15450 ValExpr = SemaRef.MakeFullExpr(Val.get()).get();
15456 !SemaRef.CurContext->isDependentContext()) {
15457 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
15459 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
15510 return SemaRef.PerformContextualImplicitConversion(Loc, Op, ConvertDiagnoser);
15514 isNonNegativeIntegerValue(Expr *&ValExpr, Sema &SemaRef, OpenMPClauseKind CKind,
15523 SemaRef.OpenMP().PerformOpenMPImplicitIntegerConversion(Loc, ValExpr);
15530 ValExpr->getIntegerConstantExpr(SemaRef.Context)) {
15534 SemaRef.Diag(Loc, diag::err_omp_negative_expression_in_clause)
15543 getOpenMPCaptureRegionForClause(DKind, CKind, SemaRef.LangOpts.OpenMP);
15545 !SemaRef.CurContext->isDependentContext()) {
15546 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
15548 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
15549 *HelperValStmt = buildPreInits(SemaRef.Context, Captures);
15564 if (!isNonNegativeIntegerValue(ValExpr, SemaRef, OMPC_num_threads,
15572 !SemaRef.CurContext->isDependentContext()) {
15573 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
15575 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
15604 ICE = SemaRef.VerifyIntegerConstantExpression(E, &Result, Diagnoser,
15607 ICE = SemaRef.VerifyIntegerConstantExpression(E, &Result,
15724 if (!findOMPAllocatorHandleT(SemaRef, A->getExprLoc(), DSAStack))
15727 ExprResult Allocator = SemaRef.DefaultLvalueConversion(A);
15730 Allocator = SemaRef.PerformImplicitConversion(
16119 bool IsValid = isNonNegativeIntegerValue(SizeExpr, SemaRef, OMPC_sizes,
16176 ExprResult PermEvalExpr = SemaRef.VerifyIntegerConstantExpression(
16406 if (checkScheduleModifiers(SemaRef, M1, M2, M1Loc, M2Loc) ||
16407 checkScheduleModifiers(SemaRef, M2, M1, M2Loc, M1Loc))
16476 !SemaRef.CurContext->isDependentContext()) {
16477 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
16479 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
16827 DeclResult = getPrivateItem(SemaRef, E, ELoc, ERange);
16830 DeclResult = getPrivateItem(SemaRef, E, ELoc, ERange);
16833 DeclResult = getPrivateItem(SemaRef, E, ELoc, ERange);
16849 static bool isValidInteropVariable(Sema &SemaRef, Expr *InteropVarExpr,
16856 getPrivateItem(SemaRef, RefExpr, ELoc, ERange,
16870 LookupResult Result(SemaRef, &SemaRef.Context.Idents.get("omp_interop_t"),
16872 if (SemaRef.LookupName(Result, SemaRef.getCurScope())) {
16884 SemaRef.Diag(VarLoc, diag::err_omp_implied_type_not_found)
16890 if (!SemaRef.Context.hasSameType(InteropType, VarType)) {
16891 SemaRef.Diag(VarLoc, diag::err_omp_interop_variable_wrong_type);
16898 isConstNotMutableType(SemaRef, InteropVarExpr->getType())) {
16899 SemaRef.Diag(VarLoc, diag::err_omp_interop_variable_expected)
16910 if (!isValidInteropVariable(SemaRef, InteropVar, VarLoc, OMPC_init))
16937 if (!isValidInteropVariable(SemaRef, InteropVar, VarLoc, OMPC_use))
16957 !isValidInteropVariable(SemaRef, InteropVar, VarLoc, OMPC_destroy))
16974 ExprResult Val = SemaRef.CheckBooleanCondition(StartLoc, Condition);
16978 ValExpr = SemaRef.MakeFullExpr(Val.get()).get();
16984 !SemaRef.CurContext->isDependentContext()) {
16985 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
16987 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
17006 ExprResult Val = SemaRef.CheckBooleanCondition(StartLoc, Condition);
17010 ValExpr = SemaRef.MakeFullExpr(Val.get()).get();
17016 !SemaRef.CurContext->isDependentContext()) {
17017 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
17019 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
17039 !SemaRef.CurContext->isDependentContext()) {
17040 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
17042 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
17268 ExprResult Res = SemaRef.BuildDeclRefExpr(
17273 Res = SemaRef.CreateBuiltinUnaryOp(Loc, UO_Deref, Res.get());
17278 Res = SemaRef.DefaultLvalueConversion(Res.get());
17298 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
17314 if (SemaRef.RequireCompleteType(ELoc, Type,
17327 if (rejectConstNotMutableType(SemaRef, D, Type, OMPC_private, ELoc))
17341 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
17383 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
17399 buildVarDecl(SemaRef, ELoc, Type, D->getName(),
17402 SemaRef.ActOnUninitializedDecl(VDPrivate);
17406 SemaRef, VDPrivate, RefExpr->getType().getUnqualifiedType(), ELoc);
17409 if (!VD && !SemaRef.CurContext->isDependentContext()) {
17413 Ref = buildDeclRefExpr(SemaRef, VD, VD->getType().getNonReferenceType(),
17416 Ref = buildCapture(SemaRef, D, SimpleRefExpr, /*WithInit=*/false);
17420 Vars.push_back((VD || SemaRef.CurContext->isDependentContext())
17450 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
17468 if (SemaRef.RequireCompleteType(ELoc, Type,
17502 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
17522 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
17553 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
17586 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
17615 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
17637 buildVarDecl(SemaRef, ELoc, Type, D->getName(),
17650 buildVarDecl(SemaRef, RefExpr->getExprLoc(), ElemType, D->getName());
17651 VDInitRefExpr = buildDeclRefExpr(SemaRef, VDInit, ElemType, ELoc);
17652 Expr *Init = SemaRef.DefaultLvalueConversion(VDInitRefExpr).get();
17654 VarDecl *VDInitTemp = buildVarDecl(SemaRef, RefExpr->getExprLoc(),
17660 InitializationSequence InitSeq(SemaRef, Entity, Kind, Init);
17661 ExprResult Result = InitSeq.Perform(SemaRef, Entity, Kind, Init);
17669 VarDecl *VDInit = buildVarDecl(SemaRef, RefExpr->getExprLoc(), Type,
17671 VDInitRefExpr = buildDeclRefExpr(SemaRef, VDInit, RefExpr->getType(),
17673 SemaRef.AddInitializerToDecl(
17674 VDPrivate, SemaRef.DefaultLvalueConversion(VDInitRefExpr).get(),
17684 SemaRef.CurContext->addDecl(VDPrivate);
17686 SemaRef, VDPrivate, RefExpr->getType().getUnqualifiedType(),
17689 if (!VD && !SemaRef.CurContext->isDependentContext()) {
17697 buildDeclRefExpr(SemaRef, VD, VD->getType().getNonReferenceType(),
17700 Ref = buildCapture(SemaRef, D, SimpleRefExpr, /*WithInit=*/true);
17707 Vars.push_back((VD || SemaRef.CurContext->isDependentContext())
17746 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
17764 if (SemaRef.RequireCompleteType(ELoc, Type,
17777 if (rejectConstNotMutableType(SemaRef, D, Type, OMPC_lastprivate, ELoc))
17810 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
17829 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
17843 VarDecl *SrcVD = buildVarDecl(SemaRef, ERange.getBegin(),
17847 buildDeclRefExpr(SemaRef, SrcVD, Type.getUnqualifiedType(), ELoc);
17849 buildVarDecl(SemaRef, ERange.getBegin(), Type, ".lastprivate.dst",
17851 DeclRefExpr *PseudoDstExpr = buildDeclRefExpr(SemaRef, DstVD, Type, ELoc);
17854 ExprResult AssignmentOp = SemaRef.BuildBinOp(/*S=*/nullptr, ELoc, BO_Assign,
17858 AssignmentOp = SemaRef.ActOnFinishFullExpr(AssignmentOp.get(), ELoc,
17864 if (!VD && !SemaRef.CurContext->isDependentContext()) {
17868 Ref = buildCapture(SemaRef, D, SimpleRefExpr, /*WithInit=*/false);
17875 ExprResult RefRes = SemaRef.DefaultLvalueConversion(Ref);
17879 SemaRef.BuildBinOp(DSAStack->getCurScope(), ELoc, BO_Assign,
17884 SemaRef.IgnoredValueConversions(PostUpdateRes.get()).get());
17888 Vars.push_back((VD || SemaRef.CurContext->isDependentContext())
17903 buildPostUpdate(SemaRef, ExprPostUpdates));
17916 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
17938 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
17944 !SemaRef.CurContext->isDependentContext())
17945 Ref = buildCapture(SemaRef, D, SimpleRefExpr, /*WithInit=*/true);
17947 Vars.push_back((VD || !Ref || SemaRef.CurContext->isDependentContext())
18002 TransformExprToCaptures(Sema &SemaRef, ValueDecl *FieldDecl)
18003 : BaseTransform(SemaRef), Field(FieldDecl), CapturedExpr(nullptr) {}
18008 CapturedExpr = buildCapture(SemaRef, Field, E, /*WithInit=*/false);
18029 static NamedDecl *findAcceptableDecl(Sema &SemaRef, NamedDecl *D) {
18030 assert(!LookupResult::isVisible(SemaRef, D) && "not in slow case");
18038 if (LookupResult::isVisible(SemaRef, ND))
18046 argumentDependentLookup(Sema &SemaRef, const DeclarationNameInfo &Id,
18054 SemaRef.FindAssociatedClassesAndNamespaces(Loc, &OVE, AssociatedNamespaces,
18090 if (!SemaRef.isVisible(D)) {
18091 D = findAcceptableDecl(SemaRef, D);
18104 buildDeclareReductionRef(Sema &SemaRef, SourceLocation Loc, SourceRange Range,
18112 LookupResult Lookup(SemaRef, ReductionId, Sema::LookupOMPReductionName);
18114 while (S && SemaRef.LookupParsedName(Lookup, S, &ReductionIdScopeSpec,
18138 if (SemaRef.CurContext->isDependentContext() || Ty->isDependentType() ||
18156 SemaRef.Context, /*NamingClass=*/nullptr,
18157 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), ReductionId,
18174 LookupResult Lookup(SemaRef, ReductionId, Sema::LookupOMPReductionName);
18179 if (SemaRef.isCompleteType(Loc, Ty) || TyRec->isBeingDefined() ||
18182 SemaRef.LookupQualifiedName(Lookup, TyRec->getDecl());
18190 if (SemaRef.getLangOpts().CPlusPlus)
18191 argumentDependentLookup(SemaRef, ReductionId, Loc, Ty, Lookups);
18193 Lookups, [&SemaRef, Ty](ValueDecl *D) -> ValueDecl * {
18195 SemaRef.Context.hasSameType(D->getType(), Ty))
18199 return SemaRef.BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(),
18201 if (SemaRef.getLangOpts().CPlusPlus) {
18203 Lookups, [&SemaRef, Ty, Loc](ValueDecl *D) -> ValueDecl * {
18205 SemaRef.IsDerivedFrom(Loc, Ty, D->getType()) &&
18207 SemaRef.getASTContext()))
18213 if (SemaRef.IsDerivedFrom(Loc, Ty, VD->getType(), Paths)) {
18214 if (!Paths.isAmbiguous(SemaRef.Context.getCanonicalType(
18216 if (SemaRef.CheckBaseClassAccess(
18219 SemaRef.BuildBasePathArray(Paths, BasePath);
18220 return SemaRef.BuildDeclRefExpr(
18228 SemaRef.Diag(Loc, diag::err_omp_not_resolved_reduction_identifier)
19161 if (actOnOMPReductionKindClause(SemaRef, DSAStack, OMPC_reduction, VarList,
19174 buildPostUpdate(SemaRef, RD.ExprPostUpdates));
19183 if (actOnOMPReductionKindClause(SemaRef, DSAStack, OMPC_task_reduction,
19194 buildPostUpdate(SemaRef, RD.ExprPostUpdates));
19203 if (actOnOMPReductionKindClause(SemaRef, DSAStack, OMPC_in_reduction, VarList,
19214 buildPostUpdate(SemaRef, RD.ExprPostUpdates));
19233 if (SemaRef.RequireCompleteType(ELoc, Type,
19250 rejectConstNotMutableType(SemaRef, D, Type, OMPC_linear, ELoc))
19294 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
19316 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
19326 buildVarDecl(SemaRef, ELoc, Type, D->getName(),
19329 DeclRefExpr *PrivateRef = buildDeclRefExpr(SemaRef, Private, Type, ELoc);
19331 VarDecl *Init = buildVarDecl(SemaRef, ELoc, Type, ".linear.start");
19334 if (!VD && !SemaRef.CurContext->isDependentContext()) {
19335 Ref = buildCapture(SemaRef, D, SimpleRefExpr, /*WithInit=*/false);
19339 ExprResult RefRes = SemaRef.DefaultLvalueConversion(Ref);
19343 SemaRef.BuildBinOp(DSAStack->getCurScope(), ELoc, BO_Assign,
19348 SemaRef.IgnoredValueConversions(PostUpdateRes.get()).get());
19356 SemaRef.AddInitializerToDecl(
19357 Init, SemaRef.DefaultLvalueConversion(InitExpr).get(),
19359 DeclRefExpr *InitRef = buildDeclRefExpr(SemaRef, Init, Type, ELoc);
19362 Vars.push_back((VD || SemaRef.CurContext->isDependentContext())
19385 buildVarDecl(SemaRef, StepLoc, StepExpr->getType(), ".linear.step");
19387 buildDeclRefExpr(SemaRef, SaveVar, StepExpr->getType(), StepLoc);
19388 ExprResult CalcStep = SemaRef.BuildBinOp(
19389 SemaRef.getCurScope(), StepLoc, BO_Assign, SaveRef.get(), StepExpr);
19391 SemaRef.ActOnFinishFullExpr(CalcStep.get(), /*DiscardedValue=*/false);
19411 buildPostUpdate(SemaRef, ExprPostUpdates));
19415 Expr *NumIterations, Sema &SemaRef,
19426 Step = SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get();
19437 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
19451 SemaRef.Diag(ELoc,
19467 buildDeclRefExpr(SemaRef, cast<VarDecl>(DE->getDecl()),
19475 SemaRef, S, RefExpr->getExprLoc(), *CurPrivate, InitExpr, IV, Step,
19479 Update = SemaRef.ActOnFinishFullExpr(Update.get(), DE->getBeginLoc(),
19485 Final = SemaRef.BuildBinOp(
19487 SemaRef.DefaultLvalueConversion(*CurPrivate).get());
19490 Final = SemaRef.ActOnFinishFullExpr(Final.get(), DE->getBeginLoc(),
19526 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
19566 Ref = buildCapture(SemaRef, D, SimpleRefExpr, /*WithInit=*/true);
19567 Vars.push_back(SemaRef
19652 buildVarDecl(SemaRef, DE->getBeginLoc(), ElemType.getUnqualifiedType(),
19655 SemaRef, SrcVD, ElemType.getUnqualifiedType(), DE->getExprLoc());
19657 buildVarDecl(SemaRef, DE->getBeginLoc(), ElemType, ".copyin.dst",
19660 buildDeclRefExpr(SemaRef, DstVD, ElemType, DE->getExprLoc());
19664 SemaRef.BuildBinOp(/*S=*/nullptr, DE->getExprLoc(), BO_Assign,
19669 SemaRef.ActOnFinishFullExpr(AssignmentOp.get(), DE->getExprLoc(),
19701 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
19727 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
19740 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
19767 buildVarDecl(SemaRef, RefExpr->getBeginLoc(), Type, ".copyprivate.src",
19769 DeclRefExpr *PseudoSrcExpr = buildDeclRefExpr(SemaRef, SrcVD, Type, ELoc);
19771 buildVarDecl(SemaRef, RefExpr->getBeginLoc(), Type, ".copyprivate.dst",
19773 DeclRefExpr *PseudoDstExpr = buildDeclRefExpr(SemaRef, DstVD, Type, ELoc);
19774 ExprResult AssignmentOp = SemaRef.BuildBinOp(
19778 AssignmentOp = SemaRef.ActOnFinishFullExpr(AssignmentOp.get(), ELoc,
19788 : buildCapture(SemaRef, D, SimpleRefExpr, /*WithInit=*/false));
19837 bool OMPDependTFound = findOMPDependT(SemaRef, StartLoc, DSAStack);
19872 ProcessOpenMPDoacrossClauseCommon(Sema &SemaRef, bool IsSource,
19883 TotalDepCount = OrderedCountExpr->EvaluateKnownConstInt(SemaRef.Context);
19900 SemaRef.Diag(ELoc, diag::err_omp_depend_sink_unexpected_expr);
19912 if (SemaRef.CurContext->isDependentContext()) {
19943 auto Res = getPrivateItem(SemaRef, LHS, ELoc, ERange);
19953 SemaRef.Diag(OOLoc, diag::err_omp_depend_sink_expected_plus_minus);
19958 SemaRef.OpenMP().VerifyPositiveIntegerConstantInClause(
19963 if (!SemaRef.CurContext->isDependentContext() &&
19969 SemaRef.Diag(ELoc, diag::err_omp_depend_sink_expected_loop_iteration)
19972 SemaRef.Diag(ELoc, diag::err_omp_depend_sink_expected_loop_iteration)
19980 if (!SemaRef.CurContext->isDependentContext() && !IsSource &&
19984 SemaRef.Diag(EndLoc, diag::err_omp_depend_sink_expected_loop_iteration)
20048 SemaRef, DepKind == OMPC_DEPEND_source, VarList, DSAStack, EndLoc);
20066 OMPDependTFound = findOMPDependT(SemaRef, StartLoc, DSAStack,
20150 Sema::TentativeAnalysisScope Trap(SemaRef);
20151 Res = SemaRef.CreateBuiltinUnaryOp(ELoc, UO_AddrOf,
20204 ErrorFound = !isNonNegativeIntegerValue(ValExpr, SemaRef, OMPC_device,
20215 SemaRef.targetDiag(
20226 !SemaRef.CurContext->isDependentContext()) {
20227 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
20229 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
20238 static bool checkTypeMappable(SourceLocation SL, SourceRange SR, Sema &SemaRef,
20241 if (SemaRef.RequireCompleteType(SL, QTy, diag::err_incomplete_type))
20243 if (FullCheck && !SemaRef.CurContext->isDependentContext() &&
20244 !QTy.isTriviallyCopyableType(SemaRef.Context))
20245 SemaRef.Diag(SL, diag::warn_omp_non_trivial_type_mapped) << QTy << SR;
20252 static bool checkArrayExpressionDoesNotReferToWholeSize(Sema &SemaRef,
20276 if (!LowerBound->EvaluateAsInt(Result, SemaRef.getASTContext()))
20300 if (!Length->EvaluateAsInt(Result, SemaRef.getASTContext()))
20310 static bool checkArrayExpressionDoesNotReferToUnitySize(Sema &SemaRef,
20336 if (!Length->EvaluateAsInt(Result, SemaRef.getASTContext()))
20380 Sema &SemaRef;
20395 if (SemaRef.getLangOpts().OpenMP < 50) {
20396 SemaRef.Diag(ELoc,
20400 SemaRef.Diag(ELoc, diag::err_omp_non_lvalue_in_map_or_motion_clauses)
20432 SemaRef.Diag(ELoc, diag::err_omp_expected_access_to_data_field)
20448 SemaRef.Diag(ELoc, diag::err_omp_bit_fields_forbidden_in_clause)
20468 SemaRef.Diag(ELoc, diag::err_omp_union_type_not_allowed)
20495 SemaRef.Diag(ELoc, diag::err_omp_expected_base_var_name)
20505 if (checkArrayExpressionDoesNotReferToWholeSize(SemaRef, AE, E->getType()))
20511 AE->getIdx()->EvaluateAsInt(Result, SemaRef.getASTContext()) &&
20513 SemaRef.Diag(AE->getIdx()->getExprLoc(),
20515 SemaRef.Diag(AE->getIdx()->getExprLoc(),
20531 assert(!(SemaRef.getLangOpts().OpenMP < 50 && NoDiagnose) &&
20546 SemaRef.Diag(ELoc, diag::err_omp_expected_base_var_name)
20552 checkArrayExpressionDoesNotReferToWholeSize(SemaRef, OASE, CurType);
20554 checkArrayExpressionDoesNotReferToUnitySize(SemaRef, OASE, CurType);
20566 SemaRef.getLangOpts().OpenMP >= 50) {
20568 SemaRef.Diag(ELoc, diag::err_omp_section_length_undefined)
20577 SemaRef.Diag(ELoc,
20590 OASE->getLength()->EvaluateAsInt(ResultR, SemaRef.getASTContext()) &&
20592 SemaRef.Diag(OASE->getLength()->getExprLoc(),
20594 SemaRef.Diag(OASE->getLength()->getExprLoc(),
20599 SemaRef.getASTContext()) &&
20601 SemaRef.Diag(OASE->getLowerBound()->getExprLoc(),
20603 SemaRef.Diag(OASE->getLowerBound()->getExprLoc(),
20624 if (SemaRef.getLangOpts().OpenMP < 50 || !UO->isLValue() ||
20636 if (SemaRef.getLangOpts().OpenMP < 50 || !BO->getType()->isPointerType()) {
20680 Sema &SemaRef, OpenMPClauseKind CKind, OpenMPDirectiveKind DKind,
20683 : SemaRef(SemaRef), CKind(CKind), DKind(DKind), Components(Components),
20693 Sema &SemaRef, Expr *E,
20698 MapBaseChecker Checker(SemaRef, CKind, DKind, CurComponents, NoDiagnose, ELoc,
20702 if (SemaRef.getLangOpts().OpenMP >= 50 && !CurComponents.empty() &&
20713 SemaRef.Diag(ELoc, diag::err_array_section_does_not_specify_length)
20725 Sema &SemaRef, DSAStackTy *DSAS, const ValueDecl *VD, const Expr *E,
20747 [&IsEnclosedByDataEnvironmentExpr, &SemaRef, VD, CurrentRegionOnly, ELoc,
20752 if (CKind == Kind && SemaRef.LangOpts.OpenMP >= 50)
20783 SemaRef.Diag(CI->getAssociatedExpression()->getExprLoc(),
20786 SemaRef.Diag(SI->getAssociatedExpression()->getExprLoc(),
20819 SemaRef, SI->getAssociatedExpression(), Type))
20832 SemaRef.Diag(ELoc, diag::err_omp_map_shared_storage) << ERange;
20835 SemaRef.Diag(ELoc, diag::err_omp_once_referenced_in_target_update)
20838 SemaRef.Diag(RE->getExprLoc(), diag::note_used_here)
20871 SemaRef.Diag(
20875 SemaRef.Diag(RE->getExprLoc(), diag::note_used_here)
20884 SemaRef.Diag(DerivedLoc, diag::err_omp_same_pointer_dereferenced)
20886 SemaRef.Diag(RE->getExprLoc(), diag::note_used_here)
20919 SemaRef.Diag(ELoc, diag::err_omp_map_shared_storage) << ERange;
20922 SemaRef.Diag(ELoc, diag::err_omp_once_referenced_in_target_update)
20925 SemaRef.Diag(RE->getExprLoc(), diag::note_used_here)
20958 SemaRef.Diag(ELoc,
20961 SemaRef.Diag(EnclosingExpr->getExprLoc(), diag::note_used_here)
20971 static ExprResult buildUserDefinedMapperRef(Sema &SemaRef, Scope *S,
20985 LookupResult Lookup(SemaRef, MapperId, Sema::LookupOMPMapperName);
20988 while (S && SemaRef.LookupParsedName(Lookup, S, &MapperIdScopeSpec,
21010 if (SemaRef.CurContext->isDependentContext() || Type->isDependentType() ||
21026 SemaRef.Context, /*NamingClass=*/nullptr,
21027 MapperIdScopeSpec.getWithLocInContext(SemaRef.Context), MapperId,
21036 SemaRef.Diag(Loc, diag::err_omp_mapper_wrong_type);
21040 if (SemaRef.getLangOpts().CPlusPlus && !MapperIdScopeSpec.isSet())
21041 argumentDependentLookup(SemaRef, MapperId, Loc, Type, Lookups);
21044 Lookups, [&SemaRef, Type](ValueDecl *D) -> ValueDecl * {
21046 SemaRef.Context.hasSameType(D->getType(), Type))
21050 return SemaRef.BuildDeclRefExpr(VD, Type, VK_LValue, Loc);
21054 Lookups, [&SemaRef, Type, Loc](ValueDecl *D) -> ValueDecl * {
21056 SemaRef.IsDerivedFrom(Loc, Type, D->getType()) &&
21058 SemaRef.getASTContext()))
21064 if (SemaRef.IsDerivedFrom(Loc, Type, VD->getType(), Paths)) {
21065 if (!Paths.isAmbiguous(SemaRef.Context.getCanonicalType(
21067 if (SemaRef.CheckBaseClassAccess(
21070 return SemaRef.BuildDeclRefExpr(VD, Type, VK_LValue, Loc);
21077 SemaRef.Diag(Loc, diag::err_omp_invalid_mapper)
21182 static bool hasUserDefinedMapper(Sema &SemaRef, Scope *S,
21188 LookupResult Lookup(SemaRef, MapperId, Sema::LookupOMPMapperName);
21190 while (S && SemaRef.LookupParsedName(Lookup, S, &MapperIdScopeSpec,
21201 if (SemaRef.CurContext->isDependentContext() || Type->isDependentType() ||
21213 if (SemaRef.getLangOpts().CPlusPlus && !MapperIdScopeSpec.isSet())
21214 argumentDependentLookup(SemaRef, MapperId, Loc, Type, Lookups);
21216 Lookups, [&SemaRef, Type](ValueDecl *D) -> ValueDecl * {
21218 SemaRef.Context.hasSameType(D->getType(), Type))
21226 Lookups, [&SemaRef, Type, Loc](ValueDecl *D) -> ValueDecl * {
21228 SemaRef.IsDerivedFrom(Loc, Type, D->getType()) &&
21229 !Type.isMoreQualifiedThan(D->getType(), SemaRef.getASTContext()))
21237 if (SemaRef.IsDerivedFrom(Loc, Type, VD->getType(), Paths)) {
21239 SemaRef.Context.getCanonicalType(VD->getType().getUnqualifiedType()));
21242 if (SemaRef.CheckBaseClassAccess(Loc, VD->getType(), Type, Paths.front(),
21312 Sema &SemaRef, DSAStackTy *DSAS, OpenMPClauseKind CKind,
21328 auto &DeclNames = SemaRef.getASTContext().DeclarationNames;
21330 &SemaRef.getASTContext().Idents.get("default")));
21370 SemaRef, DSAS->getCurScope(), MapperIdScopeSpec, MapperId,
21384 if (SemaRef.getLangOpts().OpenMP < 50) {
21385 SemaRef.Diag(
21389 SemaRef.Diag(ELoc, diag::err_omp_non_lvalue_in_map_or_motion_clauses)
21401 checkMapClauseExpressionBase(SemaRef, SimpleExpr, CurComponents, CKind,
21414 SemaRef, DSAS->getCurScope(), MapperIdScopeSpec, MapperId,
21451 SemaRef.Diag(ELoc, diag::err_omp_threadprivate_in_clause)
21453 reportOriginalDsa(SemaRef, DSAS, VD, DVar);
21465 if (checkMapConflicts(SemaRef, DSAS, CurDeclaration, SimpleExpr,
21469 (SemaRef.getLangOpts().OpenMP <= 45 || StartLoc.isValid()) &&
21470 checkMapConflicts(SemaRef, DSAS, CurDeclaration, SimpleExpr,
21509 if (!checkTypeMappable(VE->getExprLoc(), VE->getSourceRange(), SemaRef,
21522 SemaRef.getLangOpts().OpenMP >= 52)) {
21523 SemaRef.Diag(StartLoc, diag::err_omp_invalid_map_type_for_directive)
21537 MapType == OMPC_MAP_delete || SemaRef.getLangOpts().OpenMP >= 52)) {
21538 SemaRef.Diag(StartLoc, diag::err_omp_invalid_map_type_for_directive)
21552 SemaRef.Diag(StartLoc,
21568 SemaRef.Diag(StartLoc, diag::err_omp_invalid_map_type_for_directive)
21583 if (VD && ((SemaRef.LangOpts.OpenMP <= 45 &&
21588 SemaRef.Diag(ELoc, diag::err_omp_variable_in_given_clause_and_dsa)
21592 reportOriginalDsa(SemaRef, DSAS, CurDeclaration, DVar);
21600 SemaRef, DSAS->getCurScope(), MapperIdScopeSpec, MapperId,
21618 isImplicitMapperNeeded(SemaRef, DSAS, BaseType, VE)) {
21619 ER = buildImplicitMapper(SemaRef, BaseType, DSAS);
21678 checkMappableExpressionList(SemaRef, DSAStack, OMPC_map, MVLI, Locs.StartLoc,
21696 QualType ReductionType = SemaRef.GetTypeFromParser(ParsedType.get());
21732 LookupResult Lookup(SemaRef, Name, SourceLocation(),
21734 SemaRef.forRedeclarationInCurContext());
21745 FunctionScopeInfo *ParentFn = SemaRef.getEnclosingFunction();
21748 SemaRef.LookupName(Lookup, S);
21749 SemaRef.FilterLookupForScope(Lookup, DC, S, /*ConsiderLinkage=*/false,
21810 SemaRef.PushFunctionScope();
21811 SemaRef.setFunctionHasBranchProtectedScope();
21812 SemaRef.getCurFunction()->setHasOMPDeclareReductionCombiner();
21815 SemaRef.PushDeclContext(S, DRD);
21817 SemaRef.CurContext = DRD;
21819 SemaRef.PushExpressionEvaluationContext(
21830 buildVarDecl(SemaRef, D->getLocation(), ReductionType, "omp_in");
21838 buildVarDecl(SemaRef, D->getLocation(), ReductionType, "omp_out");
21840 SemaRef.PushOnScopeChains(OmpInParm, S);
21841 SemaRef.PushOnScopeChains(OmpOutParm, S);
21847 ::buildDeclRefExpr(SemaRef, OmpInParm, ReductionType, D->getLocation());
21849 ::buildDeclRefExpr(SemaRef, OmpOutParm, ReductionType, D->getLocation());
21856 SemaRef.DiscardCleanupsInEvaluationContext();
21857 SemaRef.PopExpressionEvaluationContext();
21859 SemaRef.PopDeclContext();
21860 SemaRef.PopFunctionScopeInfo();
21873 SemaRef.PushFunctionScope();
21874 SemaRef.setFunctionHasBranchProtectedScope();
21877 SemaRef.PushDeclContext(S, DRD);
21879 SemaRef.CurContext = DRD;
21881 SemaRef.PushExpressionEvaluationContext(
21892 buildVarDecl(SemaRef, D->getLocation(), ReductionType, "omp_priv");
21900 buildVarDecl(SemaRef, D->getLocation(), ReductionType, "omp_orig");
21902 SemaRef.PushOnScopeChains(OmpPrivParm, S);
21903 SemaRef.PushOnScopeChains(OmpOrigParm, S);
21909 ::buildDeclRefExpr(SemaRef, OmpOrigParm, ReductionType, D->getLocation());
21911 ::buildDeclRefExpr(SemaRef, OmpPrivParm, ReductionType, D->getLocation());
21919 SemaRef.DiscardCleanupsInEvaluationContext();
21920 SemaRef.PopExpressionEvaluationContext();
21922 SemaRef.PopDeclContext();
21923 SemaRef.PopFunctionScopeInfo();
21942 SemaRef.PushOnScopeChains(cast<OMPDeclareReductionDecl>(D), S,
21953 TypeSourceInfo *TInfo = SemaRef.GetTypeForDeclarator(D);
21960 SemaRef.CheckExtraCXXDefaultArguments(D);
21963 return SemaRef.CreateParsedType(T, TInfo);
21970 QualType MapperType = SemaRef.GetTypeFromParser(ParsedType.get());
21986 LookupResult Lookup(SemaRef, Name, SourceLocation(),
21988 SemaRef.forRedeclarationInCurContext());
21999 FunctionScopeInfo *ParentFn = SemaRef.getEnclosingFunction();
22002 SemaRef.LookupName(Lookup, S);
22003 SemaRef.FilterLookupForScope(Lookup, DC, S, /*ConsiderLinkage=*/false,
22047 processImplicitMapsWithDefaultMappers(SemaRef, DSAStack,
22053 SemaRef.PushOnScopeChains(DMD, S);
22078 SemaRef.PushOnScopeChains(VD, S, /*AddToContext=*/false);
22079 Expr *E = buildDeclRefExpr(SemaRef, VD, MapperType, StartLoc);
22119 if (!isNonNegativeIntegerValue(ValExpr, SemaRef, OMPC_num_teams,
22127 if (CaptureRegion == OMPD_unknown || SemaRef.CurContext->isDependentContext())
22135 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
22136 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
22155 if (!isNonNegativeIntegerValue(ValExpr, SemaRef, OMPC_thread_limit,
22163 if (CaptureRegion == OMPD_unknown || SemaRef.CurContext->isDependentContext())
22171 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
22172 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
22192 ValExpr, SemaRef, OMPC_priority,
22223 if (!isNonNegativeIntegerValue(ValExpr, SemaRef, OMPC_grainsize,
22258 ValExpr, SemaRef, OMPC_num_tasks,
22306 if (!findOMPEventHandleT(SemaRef, Evt->getExprLoc(), DSAStack))
22339 reportOriginalDsa(SemaRef, DSAStack, VD, DVar);
22388 !SemaRef.CurContext->isDependentContext()) {
22389 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
22391 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
22492 DeclContext *CurLexicalContext = SemaRef.getCurLexicalContext();
22535 LookupResult Lookup(SemaRef, Id, Sema::LookupOrdinaryName);
22536 SemaRef.LookupParsedName(Lookup, CurScope, &ScopeSpec,
22545 VarOrFuncDeclFilterCCC CCC(SemaRef);
22547 SemaRef.CorrectTypo(Id, Sema::LookupOrdinaryName, CurScope, nullptr,
22549 SemaRef.diagnoseTypo(Corrected,
22550 SemaRef.PDiag(diag::err_undeclared_var_use_suggest)
22639 Sema &SemaRef, Decl *D) {
22645 if (SemaRef.LangOpts.OpenMP >= 50 &&
22646 (SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=*/true) ||
22647 SemaRef.getCurBlock() || SemaRef.getCurCapturedRegion()) &&
22656 SemaRef.Diag(VD->getLocation(),
22658 SemaRef.Diag(SL, diag::note_var_explicitly_captured_here)
22665 SemaRef.Diag(VD->getLocation(), diag::warn_omp_not_in_target_context);
22666 SemaRef.Diag(SL, diag::note_used_here) << SR;
22670 Sema &SemaRef, DSAStackTy *Stack,
22673 checkTypeMappable(SL, SR, SemaRef, Stack, VD->getType(),
22692 reportOriginalDsa(SemaRef, DSAStack, VD, DSAStack->getTopDSA(VD, false));
22711 !checkValueDeclInTarget(SL, SR, SemaRef, DSAStack, VD))
22745 checkDeclInTargetContext(E->getExprLoc(), E->getSourceRange(), SemaRef, D);
22822 checkMappableExpressionList(SemaRef, DSAStack, OMPC_to, MVLI, Locs.StartLoc,
22859 checkMappableExpressionList(SemaRef, DSAStack, OMPC_from, MVLI, Locs.StartLoc,
22882 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
22907 buildVarDecl(SemaRef, ELoc, Type, D->getName(),
22913 SemaRef.CurContext->addDecl(VDPrivate);
22915 SemaRef, VDPrivate, RefExpr->getType().getUnqualifiedType(), ELoc);
22919 buildVarDecl(SemaRef, RefExpr->getExprLoc(), Type, ".devptr.temp");
22921 SemaRef, VDInit, RefExpr->getType(), RefExpr->getExprLoc());
22922 SemaRef.AddInitializerToDecl(
22923 VDPrivate, SemaRef.DefaultLvalueConversion(VDInitRefExpr).get(),
22930 Ref = buildCapture(SemaRef, D, SimpleRefExpr, /*WithInit=*/true);
22966 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange,
22981 Ref = buildCapture(SemaRef, D, SimpleRefExpr, /*WithInit=*/true);
22997 SemaRef.DefaultFunctionArrayLvalueConversion(SimpleRefExpr).get();
23019 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
23045 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
23103 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange,
23121 reportOriginalDsa(SemaRef, DSAStack, D, DVar);
23147 SemaRef.DefaultFunctionArrayLvalueConversion(SimpleRefExpr).get();
23154 if (!VD && !SemaRef.CurContext->isDependentContext()) {
23156 buildCapture(SemaRef, D, SimpleRefExpr, /*WithInit=*/true);
23200 if (!findOMPAllocatorHandleT(SemaRef, Allocator->getExprLoc(), DSAStack))
23203 ExprResult AllocatorRes = SemaRef.DefaultLvalueConversion(Allocator);
23206 AllocatorRes = SemaRef.PerformImplicitConversion(
23222 SemaRef.targetDiag(StartLoc, diag::err_expected_allocator_expression);
23242 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
23253 if (!VD && !SemaRef.CurContext->isDependentContext())
23254 Ref = buildCapture(SemaRef, D, SimpleRefExpr, /*WithInit=*/false);
23255 Vars.push_back((VD || SemaRef.CurContext->isDependentContext())
23282 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange);
23318 SemaRef.setFunctionHasBranchProtectedScope();
23334 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange,
23375 auto Res = getPrivateItem(SemaRef, SimpleRefExpr, ELoc, ERange,
23430 if (!findOMPAllocatorHandleT(SemaRef, StartLoc, DSAStack))
23437 !findOMPAlloctraitT(SemaRef, StartLoc, DSAStack))
23445 PredefinedAllocators.insert(SemaRef.LookupSingleName(
23446 SemaRef.TUScope, AllocatorName, StartLoc, Sema::LookupAnyName));
23463 getAllocatorKind(SemaRef, DSAStack, AllocatorExpr);
23508 AllocatorExpr = SemaRef.DefaultLvalueConversion(AllocatorExpr).get();
23582 Sema::TentativeAnalysisScope Trap(SemaRef);
23583 Res = SemaRef.CreateBuiltinUnaryOp(ELoc, UO_AddrOf, SimpleExpr);
23625 if (!isNonNegativeIntegerValue(ValExpr, SemaRef, OMPC_ompx_dyn_cgroup_mem,
23633 !SemaRef.CurContext->isDependentContext()) {
23634 ValExpr = SemaRef.MakeFullExpr(ValExpr).get();
23636 ValExpr = tryBuildCapture(SemaRef, ValExpr, Captures).get();
23662 SemaRef,
23732 ExprResult Result = SemaRef.CheckPlaceholderExpr(Base);
23738 ExprResult Result = SemaRef.CheckPlaceholderExpr(LowerBound);
23741 Result = SemaRef.DefaultLvalueConversion(Result.get());
23747 ExprResult Result = SemaRef.CheckPlaceholderExpr(Length);
23750 Result = SemaRef.DefaultLvalueConversion(Result.get());
23756 ExprResult Result = SemaRef.CheckPlaceholderExpr(Stride);
23759 Result = SemaRef.DefaultLvalueConversion(Result.get());
23842 if (SemaRef.RequireCompleteType(Base->getExprLoc(), ResultTy,
23901 ExprResult Result = SemaRef.DefaultFunctionArrayLvalueConversion(Base);
23916 ExprResult Result = SemaRef.CheckPlaceholderExpr(Base);
23919 Result = SemaRef.DefaultLvalueConversion(Result.get());
23941 ExprResult Result = SemaRef.CheckPlaceholderExpr(Dim);
23946 Result = SemaRef.DefaultLvalueConversion(Result.get());
24036 VarDecl::Create(Context, SemaRef.CurContext, StartLoc, D.DeclIdentLoc,
24042 LookupResult Previous(SemaRef, NameInfo, Sema::LookupOrdinaryName,
24045 SemaRef.LookupName(Previous, S);
24047 SemaRef.FilterLookupForScope(Previous, SemaRef.CurContext, S,
24055 SemaRef.PushOnScopeChains(VD, S);
24058 SemaRef.CurContext->addDecl(VD);
24066 ExprResult BeginRes = SemaRef.PerformImplicitConversion(
24072 ExprResult EndRes = SemaRef.PerformImplicitConversion(
24118 if (!SemaRef.CurContext->isDependentContext()) {
24124 ExprResult Res = SemaRef.CreateBuiltinBinOp(D.AssignmentLoc, BO_Sub,
24134 Res = SemaRef.CreateBuiltinBinOp(D.AssignmentLoc, BO_Add, Res.get(),
24141 Res = SemaRef.CreateBuiltinBinOp(
24143 SemaRef.ActOnIntegerConstant(D.AssignmentLoc, 1).get());
24149 Res = SemaRef.CreateBuiltinBinOp(D.AssignmentLoc, BO_Div, Res.get(),
24155 St1 = SemaRef.CreateBuiltinUnaryOp(D.AssignmentLoc, UO_Minus,
24158 ExprResult Res1 = SemaRef.CreateBuiltinBinOp(
24165 Res1 = SemaRef.CreateBuiltinBinOp(D.AssignmentLoc, BO_Add, Res1.get(),
24172 Res1 = SemaRef.CreateBuiltinBinOp(
24174 SemaRef.ActOnIntegerConstant(D.AssignmentLoc, 1).get());
24180 Res1 = SemaRef.CreateBuiltinBinOp(D.AssignmentLoc, BO_Div, Res1.get(),
24187 ExprResult CmpRes = SemaRef.CreateBuiltinBinOp(
24189 SemaRef.ActOnIntegerConstant(D.AssignmentLoc, 0).get());
24194 Res = SemaRef.ActOnConditionalOp(D.AssignmentLoc, D.AssignmentLoc,
24201 Res = SemaRef.ActOnFinishFullExpr(Res.get(), /*DiscardedValue=*/false);
24209 auto *CounterVD = VarDecl::Create(Context, SemaRef.CurContext,
24215 SemaRef.BuildDeclRefExpr(CounterVD, CounterVD->getType(), VK_LValue,
24221 UpdateRes = SemaRef.CreateBuiltinBinOp(
24223 SemaRef.DefaultLvalueConversion(RefRes.get()).get(), St.get());
24225 UpdateRes = SemaRef.DefaultLvalueConversion(RefRes.get());
24231 UpdateRes = SemaRef.CreateBuiltinBinOp(D.AssignmentLoc, BO_Add,
24238 SemaRef.BuildDeclRefExpr(cast<VarDecl>(D.IteratorDecl),
24241 UpdateRes = SemaRef.CreateBuiltinBinOp(D.AssignmentLoc, BO_Assign,
24248 SemaRef.ActOnFinishFullExpr(UpdateRes.get(), /*DiscardedValue=*/true);
24253 ExprResult CounterUpdateRes = SemaRef.CreateBuiltinUnaryOp(
24259 CounterUpdateRes = SemaRef.ActOnFinishFullExpr(CounterUpdateRes.get(),
24315 if (!SemaRef.checkStringLiteralArgumentAttr(AL, 0, Str, &AttrStrLoc))
24318 checkOMPAssumeAttr(SemaRef, AttrStrLoc, Str);