aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp4
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp9
-rw-r--r--llvm/lib/Bitcode/Reader/MetadataLoader.cpp7
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp28
-rw-r--r--llvm/lib/Bitcode/Writer/ValueEnumerator.cpp4
5 files changed, 25 insertions, 27 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp b/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
index 2723105b092f..d7bcb0d7f575 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
@@ -957,8 +957,8 @@ Error BitcodeAnalyzer::parseBlock(unsigned BlockID, unsigned IndentLevel,
O->OS.write_escaped(Blob, /*hex=*/true) << "'";
} else {
bool BlobIsPrintable = true;
- for (unsigned i = 0, e = Blob.size(); i != e; ++i)
- if (!isPrint(static_cast<unsigned char>(Blob[i]))) {
+ for (char C : Blob)
+ if (!isPrint(static_cast<unsigned char>(C))) {
BlobIsPrintable = false;
break;
}
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index c568461e62b0..993cb1de8c02 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3996,8 +3996,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
// See if anything took the address of blocks in this function.
auto BBFRI = BasicBlockFwdRefs.find(F);
if (BBFRI == BasicBlockFwdRefs.end()) {
- for (unsigned i = 0, e = FunctionBBs.size(); i != e; ++i)
- FunctionBBs[i] = BasicBlock::Create(Context, "", F);
+ for (BasicBlock *&BB : FunctionBBs)
+ BB = BasicBlock::Create(Context, "", F);
} else {
auto &BBRefs = BBFRI->second;
// Check for invalid basic block references.
@@ -4605,9 +4605,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
CaseVals.push_back(ConstantInt::get(Context, Low));
}
BasicBlock *DestBB = getBasicBlock(Record[CurIdx++]);
- for (SmallVector<ConstantInt*, 1>::iterator cvi = CaseVals.begin(),
- cve = CaseVals.end(); cvi != cve; ++cvi)
- SI->addCase(*cvi, DestBB);
+ for (ConstantInt *Cst : CaseVals)
+ SI->addCase(Cst, DestBB);
}
I = SI;
break;
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 6df5a4a64d51..60530d7f7a00 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -444,7 +444,8 @@ class MetadataLoader::MetadataLoaderImpl {
uint64_t GlobalDeclAttachmentPos = 0;
#ifndef NDEBUG
- /// Sanity check that we end up parsing all of the global decl attachments.
+ /// Baisic correctness check that we end up parsing all of the global decl
+ /// attachments.
unsigned NumGlobalDeclAttachSkipped = 0;
unsigned NumGlobalDeclAttachParsed = 0;
#endif
@@ -917,7 +918,7 @@ Expected<bool> MetadataLoader::MetadataLoaderImpl::loadGlobalDeclAttachments() {
case BitstreamEntry::Error:
return error("Malformed block");
case BitstreamEntry::EndBlock:
- // Sanity check that we parsed them all.
+ // Check that we parsed them all.
assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
return true;
case BitstreamEntry::Record:
@@ -929,7 +930,7 @@ Expected<bool> MetadataLoader::MetadataLoaderImpl::loadGlobalDeclAttachments() {
return MaybeCode.takeError();
if (MaybeCode.get() != bitc::METADATA_GLOBAL_DECL_ATTACHMENT) {
// Anything other than a global decl attachment signals the end of
- // these records. sanity check that we parsed them all.
+ // these records. Check that we parsed them all.
assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
return true;
}
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 1e9a9197aed7..e2354c40844a 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -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.
diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
index 9465a3b11c8f..07e0708e68c3 100644
--- a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
+++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -1148,8 +1148,8 @@ void ValueEnumerator::purgeFunction() {
ValueMap.erase(Values[i].first);
for (unsigned i = NumModuleMDs, e = MDs.size(); i != e; ++i)
MetadataMap.erase(MDs[i]);
- for (unsigned i = 0, e = BasicBlocks.size(); i != e; ++i)
- ValueMap.erase(BasicBlocks[i]);
+ for (const BasicBlock *BB : BasicBlocks)
+ ValueMap.erase(BB);
Values.resize(NumModuleValues);
MDs.resize(NumModuleMDs);