Skip to content

Commit da24d3a

Browse files
[AsmParser] Use range-based for loops (NFC) (#97499)
1 parent f819302 commit da24d3a

File tree

1 file changed

+35
-36
lines changed

1 file changed

+35
-36
lines changed

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,17 +3293,16 @@ bool LLParser::parseFunctionType(Type *&Result) {
32933293
return true;
32943294

32953295
// Reject names on the arguments lists.
3296-
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
3297-
if (!ArgList[i].Name.empty())
3298-
return error(ArgList[i].Loc, "argument name invalid in function type");
3299-
if (ArgList[i].Attrs.hasAttributes())
3300-
return error(ArgList[i].Loc,
3301-
"argument attributes invalid in function type");
3296+
for (const ArgInfo &Arg : ArgList) {
3297+
if (!Arg.Name.empty())
3298+
return error(Arg.Loc, "argument name invalid in function type");
3299+
if (Arg.Attrs.hasAttributes())
3300+
return error(Arg.Loc, "argument attributes invalid in function type");
33023301
}
33033302

33043303
SmallVector<Type*, 16> ArgListTy;
3305-
for (unsigned i = 0, e = ArgList.size(); i != e; ++i)
3306-
ArgListTy.push_back(ArgList[i].Ty);
3304+
for (const ArgInfo &Arg : ArgList)
3305+
ArgListTy.push_back(Arg.Ty);
33073306

33083307
Result = FunctionType::get(Result, ArgListTy, IsVarArg);
33093308
return false;
@@ -6404,9 +6403,9 @@ bool LLParser::parseFunctionHeader(Function *&Fn, bool IsDefine,
64046403
std::vector<Type*> ParamTypeList;
64056404
SmallVector<AttributeSet, 8> Attrs;
64066405

6407-
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
6408-
ParamTypeList.push_back(ArgList[i].Ty);
6409-
Attrs.push_back(ArgList[i].Attrs);
6406+
for (const ArgInfo &Arg : ArgList) {
6407+
ParamTypeList.push_back(Arg.Ty);
6408+
Attrs.push_back(Arg.Attrs);
64106409
}
64116410

64126411
AttributeList PAL =
@@ -7230,8 +7229,8 @@ bool LLParser::parseIndirectBr(Instruction *&Inst, PerFunctionState &PFS) {
72307229
return true;
72317230

72327231
IndirectBrInst *IBI = IndirectBrInst::Create(Address, DestList.size());
7233-
for (unsigned i = 0, e = DestList.size(); i != e; ++i)
7234-
IBI->addDestination(DestList[i]);
7232+
for (BasicBlock *Dest : DestList)
7233+
IBI->addDestination(Dest);
72357234
Inst = IBI;
72367235
return false;
72377236
}
@@ -7246,8 +7245,8 @@ bool LLParser::resolveFunctionType(Type *RetType,
72467245
if (!FuncTy) {
72477246
// Pull out the types of all of the arguments...
72487247
std::vector<Type*> ParamTypes;
7249-
for (unsigned i = 0, e = ArgList.size(); i != e; ++i)
7250-
ParamTypes.push_back(ArgList[i].V->getType());
7248+
for (const ParamInfo &Arg : ArgList)
7249+
ParamTypes.push_back(Arg.V->getType());
72517250

72527251
if (!FunctionType::isValidReturnType(RetType))
72537252
return true;
@@ -7310,19 +7309,19 @@ bool LLParser::parseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
73107309
// correctly. Also, gather any parameter attributes.
73117310
FunctionType::param_iterator I = Ty->param_begin();
73127311
FunctionType::param_iterator E = Ty->param_end();
7313-
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
7312+
for (const ParamInfo &Arg : ArgList) {
73147313
Type *ExpectedTy = nullptr;
73157314
if (I != E) {
73167315
ExpectedTy = *I++;
73177316
} else if (!Ty->isVarArg()) {
7318-
return error(ArgList[i].Loc, "too many arguments specified");
7317+
return error(Arg.Loc, "too many arguments specified");
73197318
}
73207319

7321-
if (ExpectedTy && ExpectedTy != ArgList[i].V->getType())
7322-
return error(ArgList[i].Loc, "argument is not of expected type '" +
7323-
getTypeString(ExpectedTy) + "'");
7324-
Args.push_back(ArgList[i].V);
7325-
ArgAttrs.push_back(ArgList[i].Attrs);
7320+
if (ExpectedTy && ExpectedTy != Arg.V->getType())
7321+
return error(Arg.Loc, "argument is not of expected type '" +
7322+
getTypeString(ExpectedTy) + "'");
7323+
Args.push_back(Arg.V);
7324+
ArgAttrs.push_back(Arg.Attrs);
73267325
}
73277326

73287327
if (I != E)
@@ -7623,19 +7622,19 @@ bool LLParser::parseCallBr(Instruction *&Inst, PerFunctionState &PFS) {
76237622
// correctly. Also, gather any parameter attributes.
76247623
FunctionType::param_iterator I = Ty->param_begin();
76257624
FunctionType::param_iterator E = Ty->param_end();
7626-
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
7625+
for (const ParamInfo &Arg : ArgList) {
76277626
Type *ExpectedTy = nullptr;
76287627
if (I != E) {
76297628
ExpectedTy = *I++;
76307629
} else if (!Ty->isVarArg()) {
7631-
return error(ArgList[i].Loc, "too many arguments specified");
7630+
return error(Arg.Loc, "too many arguments specified");
76327631
}
76337632

7634-
if (ExpectedTy && ExpectedTy != ArgList[i].V->getType())
7635-
return error(ArgList[i].Loc, "argument is not of expected type '" +
7636-
getTypeString(ExpectedTy) + "'");
7637-
Args.push_back(ArgList[i].V);
7638-
ArgAttrs.push_back(ArgList[i].Attrs);
7633+
if (ExpectedTy && ExpectedTy != Arg.V->getType())
7634+
return error(Arg.Loc, "argument is not of expected type '" +
7635+
getTypeString(ExpectedTy) + "'");
7636+
Args.push_back(Arg.V);
7637+
ArgAttrs.push_back(Arg.Attrs);
76397638
}
76407639

76417640
if (I != E)
@@ -8018,19 +8017,19 @@ bool LLParser::parseCall(Instruction *&Inst, PerFunctionState &PFS,
80188017
// correctly. Also, gather any parameter attributes.
80198018
FunctionType::param_iterator I = Ty->param_begin();
80208019
FunctionType::param_iterator E = Ty->param_end();
8021-
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
8020+
for (const ParamInfo &Arg : ArgList) {
80228021
Type *ExpectedTy = nullptr;
80238022
if (I != E) {
80248023
ExpectedTy = *I++;
80258024
} else if (!Ty->isVarArg()) {
8026-
return error(ArgList[i].Loc, "too many arguments specified");
8025+
return error(Arg.Loc, "too many arguments specified");
80278026
}
80288027

8029-
if (ExpectedTy && ExpectedTy != ArgList[i].V->getType())
8030-
return error(ArgList[i].Loc, "argument is not of expected type '" +
8031-
getTypeString(ExpectedTy) + "'");
8032-
Args.push_back(ArgList[i].V);
8033-
Attrs.push_back(ArgList[i].Attrs);
8028+
if (ExpectedTy && ExpectedTy != Arg.V->getType())
8029+
return error(Arg.Loc, "argument is not of expected type '" +
8030+
getTypeString(ExpectedTy) + "'");
8031+
Args.push_back(Arg.V);
8032+
Attrs.push_back(Arg.Attrs);
80348033
}
80358034

80368035
if (I != E)

0 commit comments

Comments
 (0)