[CodeGen] Use range-based for loops (NFC) (#144939)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user