diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 3f4a78ddbf3c6c..c02641c4cba977 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1349,7 +1349,7 @@ static void buildStructValue(ConstantStructBuilder &Fields, CodeGenModule &CGM, llvm::StructType *StructTy = RL.getLLVMType(); unsigned PrevIdx = 0; ConstantInitBuilder CIBuilder(CGM); - auto DI = Data.begin(); + const auto *DI = Data.begin(); for (const FieldDecl *FD : RD->fields()) { unsigned Idx = RL.getLLVMFieldNo(FD); // Fill the alignment. @@ -3975,7 +3975,7 @@ static bool checkInitIsRequired(CodeGenFunction &CGF, continue; const VarDecl *VD = Pair.second.PrivateCopy; const Expr *Init = VD->getAnyInitializer(); - InitRequired = InitRequired || (Init && isa(Init) && + InitRequired = InitRequired || (isa_and_nonnull(Init) && !CGF.isTrivialInitializer(Init)); if (InitRequired) break; @@ -5476,7 +5476,7 @@ llvm::Function *CGOpenMPRuntime::emitReductionFunction( // *(Type*)lhs[i] = RedOp(*(Type*)lhs[i], *(Type*)rhs[i]); // ... CodeGenFunction::OMPPrivateScope Scope(CGF); - auto IPriv = Privates.begin(); + const auto *IPriv = Privates.begin(); unsigned Idx = 0; for (unsigned I = 0, E = ReductionOps.size(); I < E; ++I, ++IPriv, ++Idx) { const auto *RHSVar = @@ -5505,8 +5505,8 @@ llvm::Function *CGOpenMPRuntime::emitReductionFunction( } Scope.Privatize(); IPriv = Privates.begin(); - auto ILHS = LHSExprs.begin(); - auto IRHS = RHSExprs.begin(); + const auto *ILHS = LHSExprs.begin(); + const auto *IRHS = RHSExprs.begin(); for (const Expr *E : ReductionOps) { if ((*IPriv)->getType()->isArrayType()) { // Emit reduction for array section. @@ -5601,9 +5601,9 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc, if (SimpleReduction) { CodeGenFunction::RunCleanupsScope Scope(CGF); - auto IPriv = Privates.begin(); - auto ILHS = LHSExprs.begin(); - auto IRHS = RHSExprs.begin(); + const auto *IPriv = Privates.begin(); + const auto *ILHS = LHSExprs.begin(); + const auto *IRHS = RHSExprs.begin(); for (const Expr *E : ReductionOps) { emitSingleReductionCombiner(CGF, E, *IPriv, cast(*ILHS), cast(*IRHS)); @@ -5628,7 +5628,7 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc, /*IndexTypeQuals=*/0); Address ReductionList = CGF.CreateMemTemp(ReductionArrayTy, ".omp.reduction.red_list"); - auto IPriv = Privates.begin(); + const auto *IPriv = Privates.begin(); unsigned Idx = 0; for (unsigned I = 0, E = RHSExprs.size(); I < E; ++I, ++IPriv, ++Idx) { Address Elem = CGF.Builder.CreateConstArrayGEP(ReductionList, Idx); @@ -5705,9 +5705,9 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc, auto &&CodeGen = [Privates, LHSExprs, RHSExprs, ReductionOps]( CodeGenFunction &CGF, PrePostActionTy &Action) { CGOpenMPRuntime &RT = CGF.CGM.getOpenMPRuntime(); - auto IPriv = Privates.begin(); - auto ILHS = LHSExprs.begin(); - auto IRHS = RHSExprs.begin(); + const auto *IPriv = Privates.begin(); + const auto *ILHS = LHSExprs.begin(); + const auto *IRHS = RHSExprs.begin(); for (const Expr *E : ReductionOps) { RT.emitSingleReductionCombiner(CGF, E, *IPriv, cast(*ILHS), cast(*IRHS)); @@ -5739,9 +5739,9 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc, auto &&AtomicCodeGen = [Loc, Privates, LHSExprs, RHSExprs, ReductionOps]( CodeGenFunction &CGF, PrePostActionTy &Action) { - auto ILHS = LHSExprs.begin(); - auto IRHS = RHSExprs.begin(); - auto IPriv = Privates.begin(); + const auto *ILHS = LHSExprs.begin(); + const auto *IRHS = RHSExprs.begin(); + const auto *IPriv = Privates.begin(); for (const Expr *E : ReductionOps) { const Expr *XExpr = nullptr; const Expr *EExpr = nullptr; @@ -8352,7 +8352,7 @@ class MappableExprsHandler { } // Skip the dummy dimension since we have already have its information. - auto DI = DimSizes.begin() + 1; + auto *DI = DimSizes.begin() + 1; // Product of dimension. llvm::Value *DimProd = llvm::ConstantInt::get(CGF.CGM.Int64Ty, ElementTypeSize); @@ -10358,8 +10358,8 @@ void CGOpenMPRuntime::emitTargetCall( llvm::Value *MapTypesArray = nullptr; llvm::Value *MapNamesArray = nullptr; // Generate code for the host fallback function. - auto &&FallbackGen = [this, &D, OutlinedFn, &CapturedVars, RequiresOuterTask, &CS, - OffloadingMandatory](CodeGenFunction &CGF) { + auto &&FallbackGen = [this, OutlinedFn, &D, &CapturedVars, RequiresOuterTask, + &CS, OffloadingMandatory](CodeGenFunction &CGF) { if (OffloadingMandatory) { CGF.Builder.CreateUnreachable(); } else { @@ -10371,8 +10371,8 @@ void CGOpenMPRuntime::emitTargetCall( } }; // Fill up the pointer arrays and transfer execution to the device. - auto &&ThenGen = [this, Device, OutlinedFnID, &D, &InputInfo, - &MapTypesArray, &MapNamesArray, SizeEmitter, + auto &&ThenGen = [this, Device, OutlinedFnID, &D, &InputInfo, &MapTypesArray, + &MapNamesArray, SizeEmitter, FallbackGen](CodeGenFunction &CGF, PrePostActionTy &) { if (Device.getInt() == OMPC_DEVICE_ancestor) { // Reverse offloading is not supported, so just execute on the host. @@ -11995,7 +11995,7 @@ void CGOpenMPRuntime::emitDeclareSimdFunction(const FunctionDecl *FD, ParamAttrs[Pos].Kind = Uniform; } // Get alignment info. - auto NI = Attr->alignments_begin(); + auto *NI = Attr->alignments_begin(); for (const Expr *E : Attr->aligneds()) { E = E->IgnoreParenImpCasts(); unsigned Pos; @@ -12018,8 +12018,8 @@ void CGOpenMPRuntime::emitDeclareSimdFunction(const FunctionDecl *FD, ++NI; } // Mark linear parameters. - auto SI = Attr->steps_begin(); - auto MI = Attr->modifiers_begin(); + auto *SI = Attr->steps_begin(); + auto *MI = Attr->modifiers_begin(); for (const Expr *E : Attr->linears()) { E = E->IgnoreParenImpCasts(); unsigned Pos; @@ -12046,7 +12046,8 @@ void CGOpenMPRuntime::emitDeclareSimdFunction(const FunctionDecl *FD, if (!(*SI)->EvaluateAsInt(Result, C, Expr::SE_AllowSideEffects)) { if (const auto *DRE = cast((*SI)->IgnoreParenImpCasts())) { - if (const auto *StridePVD = cast(DRE->getDecl())) { + if (const auto *StridePVD = + dyn_cast(DRE->getDecl())) { ParamAttr.Kind = LinearWithVarStride; ParamAttr.StrideOrArg = llvm::APSInt::getUnsigned( ParamPositions[StridePVD->getCanonicalDecl()]);