[llvm] Use range-based for loops (NFC)

This commit is contained in:
Kazu Hirata
2021-11-20 18:42:10 -08:00
parent 6cc820a3e2
commit f6bce30cf9
9 changed files with 49 additions and 58 deletions

View File

@@ -596,10 +596,10 @@ static void writeStringRecord(BitstreamWriter &Stream, unsigned Code,
SmallVector<unsigned, 64> Vals;
// Code: [strchar x N]
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
if (AbbrevToUse && !BitCodeAbbrevOp::isChar6(Str[i]))
for (char C : Str) {
if (AbbrevToUse && !BitCodeAbbrevOp::isChar6(C))
AbbrevToUse = 0;
Vals.push_back(Str[i]);
Vals.push_back(C);
}
// Emit the finished record.
@@ -914,8 +914,7 @@ void ModuleBitcodeWriter::writeTypeTable() {
TypeVals.clear();
// Loop over all of the types, emitting each in turn.
for (unsigned i = 0, e = TypeList.size(); i != e; ++i) {
Type *T = TypeList[i];
for (Type *T : TypeList) {
int AbbrevToUse = 0;
unsigned Code = 0;
@@ -3343,19 +3342,18 @@ void ModuleBitcodeWriter::writeFunction(
DILocation *LastDL = nullptr;
// Finally, emit all the instructions, in order.
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
I != E; ++I) {
writeInstruction(*I, InstID, Vals);
for (const BasicBlock &BB : F)
for (const Instruction &I : BB) {
writeInstruction(I, InstID, Vals);
if (!I->getType()->isVoidTy())
if (!I.getType()->isVoidTy())
++InstID;
// If the instruction has metadata, write a metadata attachment later.
NeedsMetadataAttachment |= I->hasMetadataOtherThanDebugLoc();
NeedsMetadataAttachment |= I.hasMetadataOtherThanDebugLoc();
// If the instruction has a debug location, emit it.
DILocation *DL = I->getDebugLoc();
DILocation *DL = I.getDebugLoc();
if (!DL)
continue;
@@ -4429,9 +4427,9 @@ void ModuleBitcodeWriter::write() {
// Emit function bodies.
DenseMap<const Function *, uint64_t> FunctionToBitcodeIndex;
for (Module::const_iterator F = M.begin(), E = M.end(); F != E; ++F)
if (!F->isDeclaration())
writeFunction(*F, FunctionToBitcodeIndex);
for (const Function &F : M)
if (!F.isDeclaration())
writeFunction(F, FunctionToBitcodeIndex);
// Need to write after the above call to WriteFunction which populates
// the summary information in the index.