diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-05-05 18:30:58 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-05-05 18:30:58 +0000 |
commit | 34cd4a484e532cc463fd5a4bf59b88d13c5467c1 (patch) | |
tree | eefdfb1d225da0317e7f7912079c430b5c3ed92c /include/llvm/Bitcode | |
parent | b61bfdb56e1c018f10a2c1c9fb49d7e2a78ed24e (diff) |
Fix more -Wshorten-64-to-32 warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50659 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Bitcode')
-rw-r--r-- | include/llvm/Bitcode/Archive.h | 2 | ||||
-rw-r--r-- | include/llvm/Bitcode/BitCodes.h | 4 | ||||
-rw-r--r-- | include/llvm/Bitcode/BitstreamReader.h | 23 | ||||
-rw-r--r-- | include/llvm/Bitcode/BitstreamWriter.h | 31 |
4 files changed, 38 insertions, 22 deletions
diff --git a/include/llvm/Bitcode/Archive.h b/include/llvm/Bitcode/Archive.h index 1dcbe3abe2..50562e490f 100644 --- a/include/llvm/Bitcode/Archive.h +++ b/include/llvm/Bitcode/Archive.h @@ -254,7 +254,7 @@ class Archive { inline reverse_iterator rend () { return members.rend(); } inline const_reverse_iterator rend () const { return members.rend(); } - inline unsigned size() const { return members.size(); } + inline size_t size() const { return members.size(); } inline bool empty() const { return members.empty(); } inline const ArchiveMember& front() const { return members.front(); } inline ArchiveMember& front() { return members.front(); } diff --git a/include/llvm/Bitcode/BitCodes.h b/include/llvm/Bitcode/BitCodes.h index 94e3a6615c..f140cc3b19 100644 --- a/include/llvm/Bitcode/BitCodes.h +++ b/include/llvm/Bitcode/BitCodes.h @@ -165,7 +165,9 @@ public: void addRef() { ++RefCount; } void dropRef() { if (--RefCount == 0) delete this; } - unsigned getNumOperandInfos() const { return OperandList.size(); } + unsigned getNumOperandInfos() const { + return static_cast<unsigned>(OperandList.size()); + } const BitCodeAbbrevOp &getOperandInfo(unsigned N) const { return OperandList[N]; } diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h index 456f1ce5a1..3b7a9b61e6 100644 --- a/include/llvm/Bitcode/BitstreamReader.h +++ b/include/llvm/Bitcode/BitstreamReader.h @@ -85,12 +85,15 @@ public: ~BitstreamReader() { // Abbrevs could still exist if the stream was broken. If so, don't leak // them. - for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast<unsigned>(CurAbbrevs.size()); + i != e; ++i) CurAbbrevs[i]->dropRef(); - for (unsigned S = 0, e = BlockScope.size(); S != e; ++S) { + for (unsigned S = 0, e = static_cast<unsigned>(BlockScope.size()); + S != e; ++S) { std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs; - for (unsigned i = 0, e = Abbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast<unsigned>(Abbrevs.size()); + i != e; ++i) Abbrevs[i]->dropRef(); } @@ -98,7 +101,8 @@ public: while (!BlockInfoRecords.empty()) { BlockInfo &Info = BlockInfoRecords.back(); // Free blockinfo abbrev info. - for (unsigned i = 0, e = Info.Abbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast<unsigned>(Info.Abbrevs.size()); + i != e; ++i) Info.Abbrevs[i]->dropRef(); BlockInfoRecords.pop_back(); } @@ -127,7 +131,7 @@ public: // Skip over any bits that are already consumed. if (WordBitNo) { NextChar -= 4; - Read(WordBitNo); + Read(static_cast<unsigned>(WordBitNo)); } } @@ -237,7 +241,8 @@ private: if (!BlockInfoRecords.empty() && BlockInfoRecords.back().BlockID == BlockID) return &BlockInfoRecords.back(); - for (unsigned i = 0, e = BlockInfoRecords.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast<unsigned>(BlockInfoRecords.size()); + i != e; ++i) if (BlockInfoRecords[i].BlockID == BlockID) return &BlockInfoRecords[i]; return 0; @@ -282,7 +287,8 @@ public: // Add the abbrevs specific to this block to the CurAbbrevs list. if (BlockInfo *Info = getBlockInfo(BlockID)) { - for (unsigned i = 0, e = Info->Abbrevs.size(); i != e; ++i) { + for (unsigned i = 0, e = static_cast<unsigned>(Info->Abbrevs.size()); + i != e; ++i) { CurAbbrevs.push_back(Info->Abbrevs[i]); CurAbbrevs.back()->addRef(); } @@ -317,7 +323,8 @@ private: CurCodeSize = BlockScope.back().PrevCodeSize; // Delete abbrevs from popped scope. - for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast<unsigned>(CurAbbrevs.size()); + i != e; ++i) CurAbbrevs[i]->dropRef(); BlockScope.back().PrevAbbrevs.swap(CurAbbrevs); diff --git a/include/llvm/Bitcode/BitstreamWriter.h b/include/llvm/Bitcode/BitstreamWriter.h index 70acc019c5..3b7e405414 100644 --- a/include/llvm/Bitcode/BitstreamWriter.h +++ b/include/llvm/Bitcode/BitstreamWriter.h @@ -70,7 +70,8 @@ public: while (!BlockInfoRecords.empty()) { BlockInfo &Info = BlockInfoRecords.back(); // Free blockinfo abbrev info. - for (unsigned i = 0, e = Info.Abbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast<unsigned>(Info.Abbrevs.size()); + i != e; ++i) Info.Abbrevs[i]->dropRef(); BlockInfoRecords.pop_back(); } @@ -167,7 +168,8 @@ public: if (!BlockInfoRecords.empty() && BlockInfoRecords.back().BlockID == BlockID) return &BlockInfoRecords.back(); - for (unsigned i = 0, e = BlockInfoRecords.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast<unsigned>(BlockInfoRecords.size()); + i != e; ++i) if (BlockInfoRecords[i].BlockID == BlockID) return &BlockInfoRecords[i]; return 0; @@ -181,7 +183,7 @@ public: EmitVBR(CodeLen, bitc::CodeLenWidth); FlushToWord(); - unsigned BlockSizeWordLoc = Out.size(); + unsigned BlockSizeWordLoc = static_cast<unsigned>(Out.size()); unsigned OldCodeSize = CurCodeSize; // Emit a placeholder, which will be replaced when the block is popped. @@ -197,7 +199,8 @@ public: // If there is a blockinfo for this BlockID, add all the predefined abbrevs // to the abbrev list. if (BlockInfo *Info = getBlockInfo(BlockID)) { - for (unsigned i = 0, e = Info->Abbrevs.size(); i != e; ++i) { + for (unsigned i = 0, e = static_cast<unsigned>(Info->Abbrevs.size()); + i != e; ++i) { CurAbbrevs.push_back(Info->Abbrevs[i]); Info->Abbrevs[i]->addRef(); } @@ -208,7 +211,8 @@ public: assert(!BlockScope.empty() && "Block scope imbalance!"); // Delete all abbrevs. - for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast<unsigned>(CurAbbrevs.size()); + i != e; ++i) CurAbbrevs[i]->dropRef(); const Block &B = BlockScope.back(); @@ -219,7 +223,7 @@ public: FlushToWord(); // Compute the size of the block, in words, not counting the size field. - unsigned SizeInWords = Out.size()/4-B.StartSizeWord - 1; + unsigned SizeInWords= static_cast<unsigned>(Out.size())/4-B.StartSizeWord-1; unsigned ByteNo = B.StartSizeWord*4; // Update the block size field in the header of this sub-block. @@ -283,7 +287,8 @@ public: Vals.insert(Vals.begin(), Code); unsigned RecordIdx = 0; - for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) { + for (unsigned i = 0, e = static_cast<unsigned>(Abbv->getNumOperandInfos()); + i != e; ++i) { const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); if (Op.isLiteral() || Op.getEncoding() != BitCodeAbbrevOp::Array) { assert(RecordIdx < Vals.size() && "Invalid abbrev/record"); @@ -295,7 +300,7 @@ public: const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); // Emit a vbr6 to indicate the number of elements present. - EmitVBR(Vals.size()-RecordIdx, 6); + EmitVBR(static_cast<uint32_t>(Vals.size()-RecordIdx), 6); // Emit each field. for (; RecordIdx != Vals.size(); ++RecordIdx) @@ -308,8 +313,8 @@ public: // form. EmitCode(bitc::UNABBREV_RECORD); EmitVBR(Code, 6); - EmitVBR(Vals.size(), 6); - for (unsigned i = 0, e = Vals.size(); i != e; ++i) + EmitVBR(static_cast<uint32_t>(Vals.size()), 6); + for (unsigned i = 0, e = static_cast<unsigned>(Vals.size()); i != e; ++i) EmitVBR64(Vals[i], 6); } } @@ -323,7 +328,8 @@ private: void EncodeAbbrev(BitCodeAbbrev *Abbv) { EmitCode(bitc::DEFINE_ABBREV); EmitVBR(Abbv->getNumOperandInfos(), 5); - for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) { + for (unsigned i = 0, e = static_cast<unsigned>(Abbv->getNumOperandInfos()); + i != e; ++i) { const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); Emit(Op.isLiteral(), 1); if (Op.isLiteral()) { @@ -343,7 +349,8 @@ public: // Emit the abbreviation as a record. EncodeAbbrev(Abbv); CurAbbrevs.push_back(Abbv); - return CurAbbrevs.size()-1+bitc::FIRST_APPLICATION_ABBREV; + return static_cast<unsigned>(CurAbbrevs.size())-1 + + bitc::FIRST_APPLICATION_ABBREV; } //===--------------------------------------------------------------------===// |