llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen Author: Kazu Hirata (kazutakahirata) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/144939.diff 10 Files Affected: - (modified) clang/lib/CodeGen/CGBlocks.cpp (+3-3) - (modified) clang/lib/CodeGen/CGCleanup.cpp (+2-2) - (modified) clang/lib/CodeGen/CGDeclCXX.cpp (+3-3) - (modified) clang/lib/CodeGen/CGException.cpp (+5-5) - (modified) clang/lib/CodeGen/CGExpr.cpp (+6-6) - (modified) clang/lib/CodeGen/CGExprConstant.cpp (+1-3) - (modified) clang/lib/CodeGen/CGObjC.cpp (+2-2) - (modified) clang/lib/CodeGen/CGObjCGNU.cpp (+8-11) - (modified) clang/lib/CodeGen/CGObjCMac.cpp (+8-12) - (modified) clang/lib/CodeGen/CGObjCRuntime.cpp (+1-3) ``````````diff diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 729758ddce560..f3ddf7bf9a463 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1415,10 +1415,10 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction( // Arrange for local static and local extern declarations to appear // to be local to this function as well, in case they're directly // referenced in a block. - for (DeclMapTy::const_iterator i = ldm.begin(), e = ldm.end(); i != e; ++i) { - const auto *var = dyn_cast<VarDecl>(i->first); + for (const auto &KV : ldm) { + const auto *var = dyn_cast<VarDecl>(KV.first); if (var && !var->hasLocalStorage()) - setAddrOfLocalVar(var, i->second); + setAddrOfLocalVar(var, KV.second); } // Begin building the function declaration. diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp index 4ed2c5183c47e..28ac9bf396356 100644 --- a/clang/lib/CodeGen/CGCleanup.cpp +++ b/clang/lib/CodeGen/CGCleanup.cpp @@ -962,8 +962,8 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough, // Append the prepared cleanup prologue from above. llvm::BasicBlock *NormalExit = Builder.GetInsertBlock(); - for (unsigned I = 0, E = InstsToAppend.size(); I != E; ++I) - InstsToAppend[I]->insertInto(NormalExit, NormalExit->end()); + for (llvm::Instruction *Inst : InstsToAppend) + Inst->insertInto(NormalExit, NormalExit->end()); // Optimistically hope that any fixups will continue falling through. for (unsigned I = FixupDepth, E = EHStack.getNumBranchFixups(); diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 69d77f283db3b..7ae99935c8ad3 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -1121,9 +1121,9 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, EmitObjCAutoreleasePoolCleanup(token); } - for (unsigned i = 0, e = Decls.size(); i != e; ++i) - if (Decls[i]) - EmitRuntimeCall(Decls[i]); + for (llvm::Function *Decl : Decls) + if (Decl) + EmitRuntimeCall(Decl); Scope.ForceCleanup(); diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index e0367282355cf..ad138b9876e8c 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -319,9 +319,9 @@ static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn) { llvm::Function *F = dyn_cast<llvm::Function>(U); if (!F) return false; - for (auto BB = F->begin(), E = F->end(); BB != E; ++BB) { - if (BB->isLandingPad()) - if (!LandingPadHasOnlyCXXUses(BB->getLandingPadInst())) + for (llvm::BasicBlock &BB : *F) { + if (BB.isLandingPad()) + if (!LandingPadHasOnlyCXXUses(BB.getLandingPadInst())) return false; } } @@ -937,8 +937,8 @@ llvm::BasicBlock *CodeGenFunction::EmitLandingPad() { filterTypes[0]->getType() : Int8PtrTy, filterTypes.size()); - for (unsigned i = 0, e = filterTypes.size(); i != e; ++i) - Filters.push_back(cast<llvm::Constant>(filterTypes[i])); + for (llvm::Value *filterType : filterTypes) + Filters.push_back(cast<llvm::Constant>(filterType)); llvm::Constant *FilterArray = llvm::ConstantArray::get(AType, Filters); LPadInst->addClause(FilterArray); diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 6cb348ffdf55f..85c768807572f 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3801,8 +3801,8 @@ void CodeGenFunction::EmitCheck( ArgTypes.push_back(Args.back()->getType()); } - for (size_t i = 0, n = DynamicArgs.size(); i != n; ++i) { - Args.push_back(EmitCheckValue(DynamicArgs[i])); + for (llvm::Value *DynamicArg : DynamicArgs) { + Args.push_back(EmitCheckValue(DynamicArg)); ArgTypes.push_back(IntPtrTy); } } @@ -4932,8 +4932,8 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) { llvm::Constant *BaseElts = Base.getExtVectorElts(); SmallVector<llvm::Constant *, 4> CElts; - for (unsigned i = 0, e = Indices.size(); i != e; ++i) - CElts.push_back(BaseElts->getAggregateElement(Indices[i])); + for (unsigned Index : Indices) + CElts.push_back(BaseElts->getAggregateElement(Index)); llvm::Constant *CV = llvm::ConstantVector::get(CElts); return LValue::MakeExtVectorElt(Base.getExtVectorAddress(), CV, type, Base.getBaseInfo(), TBAAAccessInfo()); @@ -6660,8 +6660,8 @@ static LValueOrRValue emitPseudoObjectExpr(CodeGenFunction &CGF, } // Unbind all the opaques now. - for (unsigned i = 0, e = opaques.size(); i != e; ++i) - opaques[i].unbind(CGF); + for (CodeGenFunction::OpaqueValueMappingData &opaque : opaques) + opaque.unbind(CGF); return result; } diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 069cc09cd91d3..715bd392f59f7 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -871,9 +871,7 @@ bool ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD, } llvm::stable_sort(Bases); - for (unsigned I = 0, N = Bases.size(); I != N; ++I) { - BaseInfo &Base = Bases[I]; - + for (const BaseInfo &Base : Bases) { bool IsPrimaryBase = Layout.getPrimaryBase() == Base.Decl; Build(Val.getStructBase(Base.Index), Base.Decl, IsPrimaryBase, VTableClass, Offset + Base.Offset); diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 8a1b44a0c157c..6f87444d3f672 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -3173,8 +3173,8 @@ ARCExprEmitter<Impl,Result>::visitPseudoObjectExpr(const PseudoObjectExpr *E) { } // Unbind all the opaques now. - for (unsigned i = 0, e = opaques.size(); i != e; ++i) - opaques[i].unbind(CGF); + for (CodeGenFunction::OpaqueValueMappingData &opaque : opaques) + opaque.unbind(CGF); return result; } diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 3fc837c12a925..d828702cbb87f 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -1103,8 +1103,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { bool isNamed = !isNonASCII; if (isNamed) { StringName = ".objc_str_"; - for (int i=0,e=Str.size() ; i<e ; ++i) { - unsigned char c = Str[i]; + for (unsigned char c : Str) { if (isalnum(c)) StringName += c; else if (c == ' ') @@ -2560,10 +2559,9 @@ llvm::Value *CGObjCGNU::GetTypedSelector(CodeGenFunction &CGF, Selector Sel, SmallVectorImpl<TypedSelector> &Types = SelectorTable[Sel]; llvm::GlobalAlias *SelValue = nullptr; - for (SmallVectorImpl<TypedSelector>::iterator i = Types.begin(), - e = Types.end() ; i!=e ; i++) { - if (i->first == TypeEncoding) { - SelValue = i->second; + for (const TypedSelector &Type : Types) { + if (Type.first == TypeEncoding) { + SelValue = Type.second; break; } } @@ -3333,13 +3331,12 @@ CGObjCGNU::GenerateProtocolList(ArrayRef<std::string> Protocols) { ProtocolList.addInt(LongTy, Protocols.size()); auto Elements = ProtocolList.beginArray(PtrToInt8Ty); - for (const std::string *iter = Protocols.begin(), *endIter = Protocols.end(); - iter != endIter ; iter++) { + for (const std::string &Protocol : Protocols) { llvm::Constant *protocol = nullptr; - llvm::StringMap<llvm::Constant*>::iterator value = - ExistingProtocols.find(*iter); + llvm::StringMap<llvm::Constant *>::iterator value = + ExistingProtocols.find(Protocol); if (value == ExistingProtocols.end()) { - protocol = GenerateEmptyProtocol(*iter); + protocol = GenerateEmptyProtocol(Protocol); } else { protocol = value->getValue(); } diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 1c23a8b4db918..a52c92cdbc83b 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -2702,8 +2702,8 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) { unsigned char inst = (BLOCK_LAYOUT_OPERATOR << 4) | 0; Layout.push_back(inst); std::string BitMap; - for (unsigned i = 0, e = Layout.size(); i != e; i++) - BitMap += Layout[i]; + for (unsigned char C : Layout) + BitMap += C; if (CGM.getLangOpts().ObjCGCBitmapPrint) { if (ComputeByrefLayout) @@ -4225,9 +4225,8 @@ FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) { return; // Collect all the blocks in the function. - for (llvm::Function::iterator I = CGF.CurFn->begin(), E = CGF.CurFn->end(); - I != E; ++I) - BlocksBeforeTry.insert(&*I); + for (llvm::BasicBlock &BB : *CGF.CurFn) + BlocksBeforeTry.insert(&BB); llvm::FunctionType *AsmFnTy = GetAsmFnType(); @@ -4299,9 +4298,7 @@ void FragileHazards::emitHazardsInNewBlocks() { CGBuilderTy Builder(CGF, CGF.getLLVMContext()); // Iterate through all blocks, skipping those prior to the try. - for (llvm::Function::iterator FI = CGF.CurFn->begin(), FE = CGF.CurFn->end(); - FI != FE; ++FI) { - llvm::BasicBlock &BB = *FI; + for (llvm::BasicBlock &BB : *CGF.CurFn) { if (BlocksBeforeTry.count(&BB)) continue; @@ -4348,10 +4345,9 @@ void FragileHazards::collectLocals() { // Collect all the allocas currently in the function. This is // probably way too aggressive. llvm::BasicBlock &Entry = CGF.CurFn->getEntryBlock(); - for (llvm::BasicBlock::iterator I = Entry.begin(), E = Entry.end(); I != E; - ++I) - if (isa<llvm::AllocaInst>(*I) && !AllocasToIgnore.count(&*I)) - Locals.push_back(&*I); + for (llvm::Instruction &I : Entry) + if (isa<llvm::AllocaInst>(I) && !AllocasToIgnore.count(&I)) + Locals.push_back(&I); } llvm::FunctionType *FragileHazards::GetAsmFnType() { diff --git a/clang/lib/CodeGen/CGObjCRuntime.cpp b/clang/lib/CodeGen/CGObjCRuntime.cpp index dfb0fd14d93ac..6e2f32022a01e 100644 --- a/clang/lib/CodeGen/CGObjCRuntime.cpp +++ b/clang/lib/CodeGen/CGObjCRuntime.cpp @@ -220,9 +220,7 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF, CGBuilderTy::InsertPoint SavedIP = CGF.Builder.saveAndClearIP(); // Emit the handlers. - for (unsigned I = 0, E = Handlers.size(); I != E; ++I) { - CatchHandler &Handler = Handlers[I]; - + for (CatchHandler &Handler : Handlers) { CGF.EmitBlock(Handler.Block); CodeGenFunction::LexicalScope Cleanups(CGF, Handler.Body->getSourceRange()); `````````` </details> https://github.com/llvm/llvm-project/pull/144939 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits