From 34cd4a484e532cc463fd5a4bf59b88d13c5467c1 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Mon, 5 May 2008 18:30:58 +0000 Subject: Fix more -Wshorten-64-to-32 warnings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50659 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/BitVector.h | 10 +++--- include/llvm/ADT/SmallPtrSet.h | 2 +- include/llvm/ADT/SmallVector.h | 37 ++++++++++++---------- include/llvm/ADT/StringExtras.h | 4 +-- include/llvm/ADT/StringMap.h | 9 +++--- include/llvm/ADT/UniqueVector.h | 2 +- include/llvm/Analysis/AliasSetTracker.h | 2 +- include/llvm/Analysis/CallGraph.h | 2 +- include/llvm/Analysis/DominatorInternals.h | 3 +- include/llvm/Analysis/Dominators.h | 4 +-- include/llvm/Analysis/LoopInfo.h | 5 +-- include/llvm/Analysis/ScalarEvolutionExpressions.h | 6 ++-- include/llvm/Bitcode/Archive.h | 2 +- include/llvm/Bitcode/BitCodes.h | 4 ++- include/llvm/Bitcode/BitstreamReader.h | 23 +++++++++----- include/llvm/Bitcode/BitstreamWriter.h | 31 +++++++++++------- include/llvm/CodeGen/LiveInterval.h | 14 ++++---- include/llvm/CodeGen/LiveIntervalAnalysis.h | 2 +- include/llvm/CodeGen/MachineBasicBlock.h | 10 ++++-- include/llvm/CodeGen/MachineCodeEmitter.h | 3 +- include/llvm/CodeGen/MachineFrameInfo.h | 6 ++-- include/llvm/CodeGen/MachineFunction.h | 6 ++-- include/llvm/CodeGen/MachineInstr.h | 4 +-- include/llvm/CodeGen/MachineJumpTableInfo.h | 4 +-- include/llvm/CodeGen/MachineModuleInfo.h | 2 +- include/llvm/CodeGen/MachineRegisterInfo.h | 2 +- include/llvm/CodeGen/ScheduleDAG.h | 10 +++--- include/llvm/CodeGen/SelectionDAG.h | 4 +-- include/llvm/CodeGen/SelectionDAGNodes.h | 6 ++-- include/llvm/Debugger/Debugger.h | 4 ++- include/llvm/Debugger/SourceFile.h | 2 +- include/llvm/Instructions.h | 9 +++--- include/llvm/ParameterAttributes.h | 2 +- include/llvm/PassManagers.h | 4 +-- include/llvm/Support/AlignOf.h | 3 +- include/llvm/Support/Allocator.h | 4 +-- include/llvm/Support/CommandLine.h | 34 ++++++++++---------- include/llvm/Support/GraphWriter.h | 4 +-- include/llvm/Support/MemoryBuffer.h | 6 ++-- include/llvm/Support/OutputBuffer.h | 6 ++-- include/llvm/System/Path.h | 8 ++--- include/llvm/Target/TargetRegisterInfo.h | 4 +-- include/llvm/User.h | 2 +- 43 files changed, 173 insertions(+), 138 deletions(-) (limited to 'include') diff --git a/include/llvm/ADT/BitVector.h b/include/llvm/ADT/BitVector.h index a3a8920186..fccb1c6e8a 100644 --- a/include/llvm/ADT/BitVector.h +++ b/include/llvm/ADT/BitVector.h @@ -25,7 +25,7 @@ namespace llvm { class BitVector { typedef unsigned long BitWord; - enum { BITWORD_SIZE = sizeof(BitWord) * 8 }; + enum { BITWORD_SIZE = (unsigned)sizeof(BitWord) * 8 }; BitWord *Bits; // Actual bits. unsigned Size; // Size of bitvector in bits. @@ -103,7 +103,7 @@ public: unsigned NumBits = 0; for (unsigned i = 0; i < NumBitWords(size()); ++i) if (sizeof(BitWord) == 4) - NumBits += CountPopulation_32(Bits[i]); + NumBits += CountPopulation_32((uint32_t)Bits[i]); else if (sizeof(BitWord) == 8) NumBits += CountPopulation_64(Bits[i]); else @@ -130,7 +130,7 @@ public: for (unsigned i = 0; i < NumBitWords(size()); ++i) if (Bits[i] != 0) { if (sizeof(BitWord) == 4) - return i * BITWORD_SIZE + CountTrailingZeros_32(Bits[i]); + return i * BITWORD_SIZE + CountTrailingZeros_32((uint32_t)Bits[i]); else if (sizeof(BitWord) == 8) return i * BITWORD_SIZE + CountTrailingZeros_64(Bits[i]); else @@ -154,7 +154,7 @@ public: if (Copy != 0) { if (sizeof(BitWord) == 4) - return WordPos * BITWORD_SIZE + CountTrailingZeros_32(Copy); + return WordPos * BITWORD_SIZE + CountTrailingZeros_32((uint32_t)Copy); else if (sizeof(BitWord) == 8) return WordPos * BITWORD_SIZE + CountTrailingZeros_64(Copy); else @@ -165,7 +165,7 @@ public: for (unsigned i = WordPos+1; i < NumBitWords(size()); ++i) if (Bits[i] != 0) { if (sizeof(BitWord) == 4) - return i * BITWORD_SIZE + CountTrailingZeros_32(Bits[i]); + return i * BITWORD_SIZE + CountTrailingZeros_32((uint32_t)Bits[i]); else if (sizeof(BitWord) == 8) return i * BITWORD_SIZE + CountTrailingZeros_64(Bits[i]); else diff --git a/include/llvm/ADT/SmallPtrSet.h b/include/llvm/ADT/SmallPtrSet.h index 8b85a67afb..f73a4a9bc4 100644 --- a/include/llvm/ADT/SmallPtrSet.h +++ b/include/llvm/ADT/SmallPtrSet.h @@ -121,7 +121,7 @@ private: bool isSmall() const { return CurArray == &SmallArray[0]; } unsigned Hash(const void *Ptr) const { - return ((uintptr_t)Ptr >> 4) & (CurArraySize-1); + return static_cast(((uintptr_t)Ptr >> 4) & (CurArraySize-1)); } const void * const *FindBucketFor(const void *Ptr) const; void shrink_and_clear(); diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index 6d279725ad..2da6a788eb 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -190,7 +190,7 @@ public: /// template void append(in_iter in_start, in_iter in_end) { - unsigned NumInputs = std::distance(in_start, in_end); + size_type NumInputs = std::distance(in_start, in_end); // Grow allocated space if needed. if (End+NumInputs > Capacity) grow(size()+NumInputs); @@ -242,7 +242,7 @@ public: *I = Elt; return I; } - unsigned EltNo = I-Begin; + size_t EltNo = I-Begin; grow(); I = Begin+EltNo; goto Retry; @@ -255,12 +255,12 @@ public: return end()-1; } - unsigned NumToInsert = std::distance(From, To); + size_t NumToInsert = std::distance(From, To); // Convert iterator to elt# to avoid invalidating iterator when we reserve() - unsigned InsertElt = I-begin(); + size_t InsertElt = I-begin(); // Ensure there is enough space. - reserve(size() + NumToInsert); + reserve(static_cast(size() + NumToInsert)); // Uninvalidate the iterator. I = begin()+InsertElt; @@ -285,7 +285,7 @@ public: // Copy over the elements that we're about to overwrite. T *OldEnd = End; End += NumToInsert; - unsigned NumOverwritten = OldEnd-I; + size_t NumOverwritten = OldEnd-I; std::uninitialized_copy(I, OldEnd, End-NumOverwritten); // Replace the overwritten part. @@ -318,7 +318,7 @@ private: /// grow - double the size of the allocated memory, guaranteeing space for at /// least one more element or MinSize if specified. - void grow(unsigned MinSize = 0); + void grow(size_type MinSize = 0); void construct_range(T *S, T *E, const T &Elt) { for (; S != E; ++S) @@ -335,10 +335,10 @@ private: // Define this out-of-line to dissuade the C++ compiler from inlining it. template -void SmallVectorImpl::grow(unsigned MinSize) { - unsigned CurCapacity = unsigned(Capacity-Begin); - unsigned CurSize = unsigned(size()); - unsigned NewCapacity = 2*CurCapacity; +void SmallVectorImpl::grow(size_t MinSize) { + size_t CurCapacity = Capacity-Begin; + size_t CurSize = size(); + size_t NewCapacity = 2*CurCapacity; if (NewCapacity < MinSize) NewCapacity = MinSize; T *NewElts = reinterpret_cast(new char[NewCapacity*sizeof(T)]); @@ -375,20 +375,20 @@ void SmallVectorImpl::swap(SmallVectorImpl &RHS) { RHS.grow(size()); // Swap the shared elements. - unsigned NumShared = size(); + size_t NumShared = size(); if (NumShared > RHS.size()) NumShared = RHS.size(); - for (unsigned i = 0; i != NumShared; ++i) + for (unsigned i = 0; i != static_cast(NumShared); ++i) std::swap(Begin[i], RHS[i]); // Copy over the extra elts. if (size() > RHS.size()) { - unsigned EltDiff = size() - RHS.size(); + size_t EltDiff = size() - RHS.size(); std::uninitialized_copy(Begin+NumShared, End, RHS.End); RHS.End += EltDiff; destroy_range(Begin+NumShared, End); End = Begin+NumShared; } else if (RHS.size() > size()) { - unsigned EltDiff = RHS.size() - size(); + size_t EltDiff = RHS.size() - size(); std::uninitialized_copy(RHS.Begin+NumShared, RHS.End, End); End += EltDiff; destroy_range(RHS.Begin+NumShared, RHS.End); @@ -458,7 +458,9 @@ class SmallVector : public SmallVectorImpl { typedef typename SmallVectorImpl::U U; enum { // MinUs - The number of U's require to cover N T's. - MinUs = (sizeof(T)*N+sizeof(U)-1)/sizeof(U), + MinUs = (static_cast(sizeof(T))*N + + static_cast(sizeof(U)) - 1) / + static_cast(sizeof(U)), // NumInlineEltsElts - The number of elements actually in this array. There // is already one in the parent class, and we have to round up to avoid @@ -467,7 +469,8 @@ class SmallVector : public SmallVectorImpl { // NumTsAvailable - The number of T's we actually have space for, which may // be more than N due to rounding. - NumTsAvailable = (NumInlineEltsElts+1)*sizeof(U) / sizeof(T) + NumTsAvailable = (NumInlineEltsElts+1)*static_cast(sizeof(U))/ + static_cast(sizeof(T)) }; U InlineElts[NumInlineEltsElts]; public: diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h index e4c941007d..3bfd3f5c72 100644 --- a/include/llvm/ADT/StringExtras.h +++ b/include/llvm/ADT/StringExtras.h @@ -126,7 +126,7 @@ static inline std::string UppercaseString(const std::string &S) { static inline bool StringsEqualNoCase(const std::string &LHS, const std::string &RHS) { if (LHS.size() != RHS.size()) return false; - for (unsigned i = 0, e = LHS.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(LHS.size()); i != e; ++i) if (tolower(LHS[i]) != tolower(RHS[i])) return false; return true; } @@ -135,7 +135,7 @@ static inline bool StringsEqualNoCase(const std::string &LHS, /// case. static inline bool StringsEqualNoCase(const std::string &LHS, const char *RHS) { - for (unsigned i = 0, e = LHS.size(); i != e; ++i) { + for (unsigned i = 0, e = static_cast(LHS.size()); i != e; ++i) { if (RHS[i] == 0) return false; // RHS too short. if (tolower(LHS[i]) != tolower(RHS[i])) return false; } diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index 27ea5d3ea1..869a87fdce 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -153,13 +153,14 @@ public: static StringMapEntry *Create(const char *KeyStart, const char *KeyEnd, AllocatorTy &Allocator, InitType InitVal) { - unsigned KeyLength = KeyEnd-KeyStart; + unsigned KeyLength = static_cast(KeyEnd-KeyStart); // Okay, the item doesn't already exist, and 'Bucket' is the bucket to fill // in. Allocate a new item with space for the string at the end and a null // terminator. - unsigned AllocSize = sizeof(StringMapEntry)+KeyLength+1; + unsigned AllocSize = static_cast(sizeof(StringMapEntry))+ + KeyLength+1; unsigned Alignment = alignof(); StringMapEntry *NewItem = @@ -236,9 +237,9 @@ class StringMap : public StringMapImpl { AllocatorTy Allocator; typedef StringMapEntry MapEntryTy; public: - StringMap() : StringMapImpl(sizeof(MapEntryTy)) {} + StringMap() : StringMapImpl(static_cast(sizeof(MapEntryTy))) {} explicit StringMap(unsigned InitialSize) - : StringMapImpl(InitialSize, sizeof(MapEntryTy)) {} + : StringMapImpl(InitialSize, static_cast(sizeof(MapEntryTy))) {} AllocatorTy &getAllocator() { return Allocator; } const AllocatorTy &getAllocator() const { return Allocator; } diff --git a/include/llvm/ADT/UniqueVector.h b/include/llvm/ADT/UniqueVector.h index 76e8e0b72a..b114b8231e 100644 --- a/include/llvm/ADT/UniqueVector.h +++ b/include/llvm/ADT/UniqueVector.h @@ -41,7 +41,7 @@ public: if (Val) return Val; // Compute ID for entry. - Val = Vector.size() + 1; + Val = static_cast(Vector.size()) + 1; // Insert in vector. Vector.push_back(Entry); diff --git a/include/llvm/Analysis/AliasSetTracker.h b/include/llvm/Analysis/AliasSetTracker.h index a4367c4373..70c25b0680 100644 --- a/include/llvm/Analysis/AliasSetTracker.h +++ b/include/llvm/Analysis/AliasSetTracker.h @@ -232,7 +232,7 @@ private: bool KnownMustAlias = false); void addCallSite(CallSite CS, AliasAnalysis &AA); void removeCallSite(CallSite CS) { - for (unsigned i = 0, e = CallSites.size(); i != e; ++i) + for (size_t i = 0, e = CallSites.size(); i != e; ++i) if (CallSites[i].getInstruction() == CS.getInstruction()) { CallSites[i] = CallSites.back(); CallSites.pop_back(); diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 2bb06900ab..88449ab258 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -191,7 +191,7 @@ public: inline const_iterator begin() const { return CalledFunctions.begin(); } inline const_iterator end() const { return CalledFunctions.end(); } inline bool empty() const { return CalledFunctions.empty(); } - inline unsigned size() const { return CalledFunctions.size(); } + inline unsigned size() const { return (unsigned)CalledFunctions.size(); } // Subscripting operator - Return the i'th called function... // diff --git a/include/llvm/Analysis/DominatorInternals.h b/include/llvm/Analysis/DominatorInternals.h index 063602e92f..1564774ada 100644 --- a/include/llvm/Analysis/DominatorInternals.h +++ b/include/llvm/Analysis/DominatorInternals.h @@ -248,7 +248,8 @@ void Calculate(DominatorTreeBase::NodeType>& DT, // Step #1: Number blocks in depth-first order and initialize variables used // in later stages of the algorithm. - for (unsigned i = 0, e = DT.Roots.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(DT.Roots.size()); + i != e; ++i) N = DFSPass(DT, DT.Roots[i], N); // it might be that some blocks did not get a DFS number (e.g., blocks of diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index ad1766c85a..6ce3260b8f 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -237,7 +237,7 @@ protected: bool NewBBDominatesNewBBSucc = true; { typename GraphT::NodeType* OnePred = PredBlocks[0]; - unsigned i = 1, e = PredBlocks.size(); + size_t i = 1, e = PredBlocks.size(); for (i = 1; !DT.isReachableFromEntry(OnePred); ++i) { assert(i != e && "Didn't find reachable pred?"); OnePred = PredBlocks[i]; @@ -567,7 +567,7 @@ protected: SmallVector*, typename DomTreeNodeBase::iterator>, 32> WorkStack; - for (unsigned i = 0, e = this->Roots.size(); i != e; ++i) { + for (unsigned i = 0, e = (unsigned)this->Roots.size(); i != e; ++i) { DomTreeNodeBase *ThisRoot = getNode(this->Roots[i]); WorkStack.push_back(std::make_pair(ThisRoot, ThisRoot->begin())); ThisRoot->DFSNumIn = DFSNum++; diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index fdb722c225..0243a00df5 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -80,7 +80,7 @@ public: /// Loop ctor - This creates an empty loop. LoopBase() : ParentLoop(0) {} ~LoopBase() { - for (unsigned i = 0, e = SubLoops.size(); i != e; ++i) + for (size_t i = 0, e = SubLoops.size(); i != e; ++i) delete SubLoops[i]; } @@ -847,7 +847,8 @@ public: "This loop should not be inserted here!"); // Check to see if it belongs in a child loop... - for (unsigned i = 0, e = Parent->SubLoops.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(Parent->SubLoops.size()); + i != e; ++i) if (Parent->SubLoops[i]->contains(LHeader)) { InsertLoopInto(L, Parent->SubLoops[i]); return; diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index 39b083d5fa..e077cfe2a0 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -229,7 +229,7 @@ namespace llvm { ~SCEVCommutativeExpr(); public: - unsigned getNumOperands() const { return Operands.size(); } + unsigned getNumOperands() const { return (unsigned)Operands.size(); } const SCEVHandle &getOperand(unsigned i) const { assert(i < Operands.size() && "Operand index out of range!"); return Operands[i]; @@ -387,7 +387,7 @@ namespace llvm { SCEVAddRecExpr(const std::vector &ops, const Loop *l) : SCEV(scAddRecExpr), Operands(ops), L(l) { - for (unsigned i = 0, e = Operands.size(); i != e; ++i) + for (size_t i = 0, e = Operands.size(); i != e; ++i) assert(Operands[i]->isLoopInvariant(l) && "Operands of AddRec must be loop-invariant!"); } @@ -397,7 +397,7 @@ namespace llvm { op_iterator op_begin() const { return Operands.begin(); } op_iterator op_end() const { return Operands.end(); } - unsigned getNumOperands() const { return Operands.size(); } + unsigned getNumOperands() const { return (unsigned)Operands.size(); } const SCEVHandle &getOperand(unsigned i) const { return Operands[i]; } const SCEVHandle &getStart() const { return Operands[0]; } const Loop *getLoop() const { return L; } 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(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(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(BlockScope.size()); + S != e; ++S) { std::vector &Abbrevs = BlockScope[S].PrevAbbrevs; - for (unsigned i = 0, e = Abbrevs.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(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(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(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(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(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(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(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(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(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(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(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(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(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(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(Vals.size()), 6); + for (unsigned i = 0, e = static_cast(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(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(CurAbbrevs.size())-1 + + bitc::FIRST_APPLICATION_ABBREV; } //===--------------------------------------------------------------------===// diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 3fb0c1dc4e..31d6947a76 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -143,7 +143,7 @@ namespace llvm { bool containsOneValue() const { return valnos.size() == 1; } - unsigned getNumValNums() const { return valnos.size(); } + unsigned getNumValNums() const { return (unsigned)valnos.size(); } /// getValNumInfo - Returns pointer to the specified val#. /// @@ -168,14 +168,15 @@ namespace llvm { VNInfo *getNextValue(unsigned MIIdx, MachineInstr *CopyMI, BumpPtrAllocator &VNInfoAllocator) { #ifdef __GNUC__ - unsigned Alignment = __alignof__(VNInfo); + unsigned Alignment = (unsigned)__alignof__(VNInfo); #else // FIXME: ugly. unsigned Alignment = 8; #endif - VNInfo *VNI= static_cast(VNInfoAllocator.Allocate(sizeof(VNInfo), - Alignment)); - new (VNI) VNInfo(valnos.size(), MIIdx, CopyMI); + VNInfo *VNI = + static_cast(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo), + Alignment)); + new (VNI) VNInfo((unsigned)valnos.size(), MIIdx, CopyMI); valnos.push_back(VNI); return VNI; } @@ -196,7 +197,8 @@ namespace llvm { /// addKills - Add a number of kills into the VNInfo kill vector. If this /// interval is live at a kill point, then the kill is not added. void addKills(VNInfo *VNI, const SmallVector &kills) { - for (unsigned i = 0, e = kills.size(); i != e; ++i) { + for (unsigned i = 0, e = static_cast(kills.size()); + i != e; ++i) { unsigned KillIdx = kills[i]; if (!liveBeforeAndAt(KillIdx)) { SmallVector::iterator diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index 7bd4ea4a19..c6b5cfaebc 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -131,7 +131,7 @@ namespace llvm { const_iterator end() const { return r2iMap_.end(); } iterator begin() { return r2iMap_.begin(); } iterator end() { return r2iMap_.end(); } - unsigned getNumIntervals() const { return r2iMap_.size(); } + unsigned getNumIntervals() const { return (unsigned)r2iMap_.size(); } LiveInterval &getInterval(unsigned reg) { Reg2IntervalMap::iterator I = r2iMap_.find(reg); diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index 4ce695c1f3..0b3173c5b1 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -108,7 +108,7 @@ public: typedef std::reverse_iterator const_reverse_iterator; typedef std::reverse_iterator reverse_iterator; - unsigned size() const { return Insts.size(); } + unsigned size() const { return (unsigned)Insts.size(); } bool empty() const { return Insts.empty(); } MachineInstr& front() { return Insts.front(); } @@ -149,7 +149,9 @@ public: { return Predecessors.rend(); } const_pred_reverse_iterator pred_rend() const { return Predecessors.rend(); } - unsigned pred_size() const { return Predecessors.size(); } + unsigned pred_size() const { + return (unsigned)Predecessors.size(); + } bool pred_empty() const { return Predecessors.empty(); } succ_iterator succ_begin() { return Successors.begin(); } const_succ_iterator succ_begin() const { return Successors.begin(); } @@ -163,7 +165,9 @@ public: { return Successors.rend(); } const_succ_reverse_iterator succ_rend() const { return Successors.rend(); } - unsigned succ_size() const { return Successors.size(); } + unsigned succ_size() const { + return (unsigned)Successors.size(); + } bool succ_empty() const { return Successors.empty(); } // LiveIn management methods. diff --git a/include/llvm/CodeGen/MachineCodeEmitter.h b/include/llvm/CodeGen/MachineCodeEmitter.h index 6bf72de0ff..e38eb061ba 100644 --- a/include/llvm/CodeGen/MachineCodeEmitter.h +++ b/include/llvm/CodeGen/MachineCodeEmitter.h @@ -168,7 +168,8 @@ public: /// emitString - This callback is invoked when a String needs to be /// written to the output stream. void emitString(const std::string &String) { - for (unsigned i = 0, N = String.size(); i < N; ++i) { + for (unsigned i = 0, N = static_cast(String.size()); + i < N; ++i) { unsigned char C = String[i]; emitByte(C); } diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h index 4cc9073435..592c17f56b 100644 --- a/include/llvm/CodeGen/MachineFrameInfo.h +++ b/include/llvm/CodeGen/MachineFrameInfo.h @@ -193,7 +193,7 @@ public: /// getObjectIndexEnd - Return one past the maximum frame object index... /// - int getObjectIndexEnd() const { return Objects.size()-NumFixedObjects; } + int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; } /// getObjectSize - Return the size of the specified object /// @@ -311,7 +311,7 @@ public: int CreateStackObject(uint64_t Size, unsigned Alignment) { assert(Size != 0 && "Cannot allocate zero size stack objects!"); Objects.push_back(StackObject(Size, Alignment, -1)); - return Objects.size()-NumFixedObjects-1; + return (int)Objects.size()-NumFixedObjects-1; } /// RemoveStackObject - Remove or mark dead a statically sized stack object. @@ -333,7 +333,7 @@ public: int CreateVariableSizedObject() { HasVarSizedObjects = true; Objects.push_back(StackObject(0, 1, -1)); - return Objects.size()-NumFixedObjects-1; + return (int)Objects.size()-NumFixedObjects-1; } /// getCalleeSavedInfo - Returns a reference to call saved info vector for the diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 46d14e1484..97027da7d6 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -165,7 +165,7 @@ public: /// getNumBlockIDs - Return the number of MBB ID's allocated. /// - unsigned getNumBlockIDs() const { return MBBNumbering.size(); } + unsigned getNumBlockIDs() const { return (unsigned)MBBNumbering.size(); } /// RenumberBlocks - This discards all of the MachineBasicBlock numbers and /// recomputes them. This guarantees that the MBB numbers are sequential, @@ -238,7 +238,7 @@ public: reverse_iterator rend () { return BasicBlocks.rend(); } const_reverse_iterator rend () const { return BasicBlocks.rend(); } - unsigned size() const { return BasicBlocks.size(); } + unsigned size() const { return (unsigned)BasicBlocks.size();} bool empty() const { return BasicBlocks.empty(); } const MachineBasicBlock &front() const { return BasicBlocks.front(); } MachineBasicBlock &front() { return BasicBlocks.front(); } @@ -254,7 +254,7 @@ public: /// unsigned addToMBBNumbering(MachineBasicBlock *MBB) { MBBNumbering.push_back(MBB); - return MBBNumbering.size()-1; + return (unsigned)MBBNumbering.size()-1; } /// removeFromMBBNumbering - Remove the specific machine basic block from our diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 5dfe14cb62..ff64e7e2e6 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -82,7 +82,7 @@ public: /// Access to explicit operands of the instruction. /// - unsigned getNumOperands() const { return Operands.size(); } + unsigned getNumOperands() const { return (unsigned)Operands.size(); } const MachineOperand& getOperand(unsigned i) const { assert(i < getNumOperands() && "getOperand() out of range!"); @@ -98,7 +98,7 @@ public: unsigned getNumExplicitOperands() const; /// Access to memory operands of the instruction - unsigned getNumMemOperands() const { return MemOperands.size(); } + unsigned getNumMemOperands() const { return (unsigned)MemOperands.size(); } const MachineMemOperand& getMemOperand(unsigned i) const { assert(i < getNumMemOperands() && "getMemOperand() out of range!"); diff --git a/include/llvm/CodeGen/MachineJumpTableInfo.h b/include/llvm/CodeGen/MachineJumpTableInfo.h index bccd65dfbd..e0acb27f46 100644 --- a/include/llvm/CodeGen/MachineJumpTableInfo.h +++ b/include/llvm/CodeGen/MachineJumpTableInfo.h @@ -70,9 +70,9 @@ public: bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New) { assert(Old != New && "Not making a change?"); bool MadeChange = false; - for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) { + for (size_t i = 0, e = JumpTables.size(); i != e; ++i) { MachineJumpTableEntry &JTE = JumpTables[i]; - for (unsigned j = 0, e = JTE.MBBs.size(); j != e; ++j) + for (size_t j = 0, e = JTE.MBBs.size(); j != e; ++j) if (JTE.MBBs[j] == Old) { JTE.MBBs[j] = New; MadeChange = true; diff --git a/include/llvm/CodeGen/MachineModuleInfo.h b/include/llvm/CodeGen/MachineModuleInfo.h index 40c67fd8e8..b7066f4c65 100644 --- a/include/llvm/CodeGen/MachineModuleInfo.h +++ b/include/llvm/CodeGen/MachineModuleInfo.h @@ -1100,7 +1100,7 @@ public: /// NextLabelID - Return the next unique label id. /// unsigned NextLabelID() { - unsigned ID = LabelIDList.size() + 1; + unsigned ID = (unsigned)LabelIDList.size() + 1; LabelIDList.push_back(ID); return ID; } diff --git a/include/llvm/CodeGen/MachineRegisterInfo.h b/include/llvm/CodeGen/MachineRegisterInfo.h index fee1ef44e8..665b55c4ca 100644 --- a/include/llvm/CodeGen/MachineRegisterInfo.h +++ b/include/llvm/CodeGen/MachineRegisterInfo.h @@ -152,7 +152,7 @@ public: /// getLastVirtReg - Return the highest currently assigned virtual register. /// unsigned getLastVirtReg() const { - return VRegInfo.size()+TargetRegisterInfo::FirstVirtualRegister-1; + return (unsigned)VRegInfo.size()+TargetRegisterInfo::FirstVirtualRegister-1; } diff --git a/include/llvm/CodeGen/ScheduleDAG.h b/include/llvm/CodeGen/ScheduleDAG.h index c611bfae5c..d49c7db6fd 100644 --- a/include/llvm/CodeGen/ScheduleDAG.h +++ b/include/llvm/CodeGen/ScheduleDAG.h @@ -143,7 +143,7 @@ namespace llvm { /// not already. This returns true if this is a new pred. bool addPred(SUnit *N, bool isCtrl, bool isSpecial, unsigned PhyReg = 0, int Cost = 1) { - for (unsigned i = 0, e = Preds.size(); i != e; ++i) + for (unsigned i = 0, e = (unsigned)Preds.size(); i != e; ++i) if (Preds[i].Dep == N && Preds[i].isCtrl == isCtrl && Preds[i].isSpecial == isSpecial) return false; @@ -189,14 +189,14 @@ namespace llvm { } bool isPred(SUnit *N) { - for (unsigned i = 0, e = Preds.size(); i != e; ++i) + for (unsigned i = 0, e = (unsigned)Preds.size(); i != e; ++i) if (Preds[i].Dep == N) return true; return false; } bool isSucc(SUnit *N) { - for (unsigned i = 0, e = Succs.size(); i != e; ++i) + for (unsigned i = 0, e = (unsigned)Succs.size(); i != e; ++i) if (Succs[i].Dep == N) return true; return false; @@ -293,7 +293,7 @@ namespace llvm { /// NewSUnit - Creates a new SUnit and return a ptr to it. /// SUnit *NewSUnit(SDNode *N) { - SUnits.push_back(SUnit(N, SUnits.size())); + SUnits.push_back(SUnit(N, (unsigned)SUnits.size())); return &SUnits.back(); } @@ -452,7 +452,7 @@ namespace llvm { static SUnitIterator begin(SUnit *N) { return SUnitIterator(N, 0); } static SUnitIterator end (SUnit *N) { - return SUnitIterator(N, N->Preds.size()); + return SUnitIterator(N, (unsigned)N->Preds.size()); } unsigned getOperand() const { return Operand; } diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index e17e32eaf1..b36ed86ac9 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -163,7 +163,7 @@ public: return getVTList(VT1, VT2, VT3).VTs; } const MVT::ValueType *getNodeValueTypes(std::vector &VTList) { - return getVTList(&VTList[0], VTList.size()).VTs; + return getVTList(&VTList[0], (unsigned)VTList.size()).VTs; } @@ -287,7 +287,7 @@ public: Ops.push_back(Op2); Ops.push_back(InFlag); return getNode(ISD::CALLSEQ_END, NodeTys, &Ops[0], - Ops.size() - (InFlag.Val == 0 ? 1 : 0)); + (unsigned)Ops.size() - (InFlag.Val == 0 ? 1 : 0)); } /// getNode - Gets or creates the specified node. diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index a688a9f5af..c9872cf19f 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -972,12 +972,12 @@ public: SDOperandPtr(SDUse * use_ptr) { ptr = &use_ptr->getSDOperand(); - object_size = sizeof(SDUse); + object_size = (int)sizeof(SDUse); } SDOperandPtr(const SDOperand * op_ptr) { ptr = op_ptr; - object_size = sizeof(SDOperand); + object_size = (int)sizeof(SDOperand); } const SDOperand operator *() { return *ptr; } @@ -1107,7 +1107,7 @@ public: /// getOperandNum - Retrive a number of a current operand. unsigned getOperandNum() const { assert(Op && "Cannot dereference end iterator!"); - return (Op - Op->getUser()->OperandList); + return (unsigned)(Op - Op->getUser()->OperandList); } /// Retrieve a reference to the current operand. diff --git a/include/llvm/Debugger/Debugger.h b/include/llvm/Debugger/Debugger.h index 394592f317..5b0b97addf 100644 --- a/include/llvm/Debugger/Debugger.h +++ b/include/llvm/Debugger/Debugger.h @@ -67,7 +67,9 @@ namespace llvm { void setProgramArguments(It I, It E) { ProgramArguments.assign(I, E); } - unsigned getNumProgramArguments() const { return ProgramArguments.size(); } + unsigned getNumProgramArguments() const { + return static_cast(ProgramArguments.size()); + } const std::string &getProgramArgument(unsigned i) const { return ProgramArguments[i]; } diff --git a/include/llvm/Debugger/SourceFile.h b/include/llvm/Debugger/SourceFile.h index 66783ce088..249435af8b 100644 --- a/include/llvm/Debugger/SourceFile.h +++ b/include/llvm/Debugger/SourceFile.h @@ -74,7 +74,7 @@ namespace llvm { /// unsigned getNumLines() const { if (LineOffset.empty()) calculateLineOffsets(); - return LineOffset.size(); + return static_cast(LineOffset.size()); } private: diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 59670c64ed..f292a3173f 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -397,8 +397,7 @@ class GetElementPtrInst : public Instruction { // This argument ensures that we have an iterator we can // do arithmetic on in constant time std::random_access_iterator_tag) { - typename std::iterator_traits::difference_type NumIdx = - std::distance(IdxBegin, IdxEnd); + unsigned NumIdx = static_cast(std::distance(IdxBegin, IdxEnd)); if (NumIdx > 0) { // This requires that the itoerator points to contiguous memory. @@ -430,8 +429,7 @@ class GetElementPtrInst : public Instruction { // have an iterator we can do // arithmetic on in constant time std::random_access_iterator_tag) { - typename std::iterator_traits::difference_type NumIdx = - std::distance(IdxBegin, IdxEnd); + unsigned NumIdx = static_cast(std::distance(IdxBegin, IdxEnd)); if (NumIdx > 0) { // This requires that the iterator points to contiguous memory. @@ -961,7 +959,8 @@ public: Instruction *InsertBefore = 0) { return new(1) CallInst(F, Name, InsertBefore); } - static CallInst *Create(Value *F, const std::string &Name, BasicBlock *InsertAtEnd) { + static CallInst *Create(Value *F, const std::string &Name, + BasicBlock *InsertAtEnd) { return new(1) CallInst(F, Name, InsertAtEnd); } diff --git a/include/llvm/ParameterAttributes.h b/include/llvm/ParameterAttributes.h index 5031d8467c..22833629f0 100644 --- a/include/llvm/ParameterAttributes.h +++ b/include/llvm/ParameterAttributes.h @@ -124,7 +124,7 @@ public: template static PAListPtr get(const Iter &I, const Iter &E) { if (I == E) return PAListPtr(); // Empty list. - return get(&*I, E-I); + return get(&*I, static_cast(E-I)); } /// addAttr - Add the specified attribute at the specified index to this diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h index 04bb48bc3e..5bf4dfb0a1 100644 --- a/include/llvm/PassManagers.h +++ b/include/llvm/PassManagers.h @@ -146,7 +146,7 @@ class PMTopLevelManager { public: virtual unsigned getNumContainedManagers() { - return PassManagers.size(); + return (unsigned)PassManagers.size(); } /// Schedule pass P for execution. Make sure that passes required by @@ -306,7 +306,7 @@ public: const std::vector &Set) const; virtual unsigned getNumContainedPasses() { - return PassVector.size(); + return (unsigned)PassVector.size(); } virtual PassManagerType getPassManagerType() const { diff --git a/include/llvm/Support/AlignOf.h b/include/llvm/Support/AlignOf.h index 108c59f0eb..aecb478eef 100644 --- a/include/llvm/Support/AlignOf.h +++ b/include/llvm/Support/AlignOf.h @@ -34,7 +34,8 @@ private: /// compile-time constant (e.g., for template instantiation). template struct AlignOf { - enum { Alignment = sizeof(AlignmentCalcImpl) - sizeof(T) }; + enum { Alignment = + static_cast(sizeof(AlignmentCalcImpl) - sizeof(T)) }; enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 }; enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 }; diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index fc82597be4..33cdca13e6 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -25,7 +25,7 @@ public: ~MallocAllocator() {} void Reset() {} - void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); } + void *Allocate(size_t Size, size_t Alignment) { return malloc(Size); } template void *Allocate() { return reinterpret_cast(malloc(sizeof(T))); } @@ -45,7 +45,7 @@ public: ~BumpPtrAllocator(); void Reset(); - void *Allocate(unsigned Size, unsigned Alignment); + void *Allocate(size_t Size, size_t Alignment); template void *Allocate() { diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 27782c875f..f4db8c4bf8 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -219,12 +219,12 @@ public: Option *getNextRegisteredOption() const { return NextRegistered; } // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const = 0; + virtual size_t getOptionWidth() const = 0; // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // - virtual void printOptionInfo(unsigned GlobalWidth) const = 0; + virtual void printOptionInfo(size_t GlobalWidth) const = 0; virtual void getExtraOptionNames(std::vector &OptionNames) {} @@ -334,7 +334,8 @@ public: template void apply(Opt &O) const { - for (unsigned i = 0, e = Values.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(Values.size()); + i != e; ++i) O.getParser().addLiteralOption(Values[i].first, Values[i].second.first, Values[i].second.second); } @@ -378,12 +379,12 @@ struct generic_parser_base { virtual const char *getDescription(unsigned N) const = 0; // Return the width of the option tag for printing... - virtual unsigned getOptionWidth(const Option &O) const; + virtual size_t getOptionWidth(const Option &O) const; // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // - virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; + virtual void printOptionInfo(const Option &O, size_t GlobalWidth) const; void initialize(Option &O) { // All of the modifiers for the option have been processed by now, so the @@ -459,7 +460,8 @@ public: else ArgVal = ArgName; - for (unsigned i = 0, e = Values.size(); i != e; ++i) + for (unsigned i = 0, e = static_cast(Values.size()); + i != e; ++i) if (ArgVal == Values[i].first) { V = Values[i].second.first; return false; @@ -502,12 +504,12 @@ struct basic_parser_impl { // non-template implementation of basic_parser void initialize(Option &O) {} // Return the width of the option tag for printing... - unsigned getOptionWidth(const Option &O) const; + size_t getOptionWidth(const Option &O) const; // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // - void printOptionInfo(const Option &O, unsigned GlobalWidth) const; + void printOptionInfo(const Option &O, size_t GlobalWidth) const; // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "value"; } @@ -815,8 +817,8 @@ class opt : public Option, } // Forward printing stuff to the parser... - virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} - virtual void printOptionInfo(unsigned GlobalWidth) const { + virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);} + virtual void printOptionInfo(size_t GlobalWidth) const { Parser.printOptionInfo(*this, GlobalWidth); } @@ -981,8 +983,8 @@ class list : public Option, public list_storage { } // Forward printing stuff to the parser... - virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} - virtual void printOptionInfo(unsigned GlobalWidth) const { + virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);} + virtual void printOptionInfo(size_t GlobalWidth) const { Parser.printOptionInfo(*this, GlobalWidth); } @@ -1167,8 +1169,8 @@ class bits : public Option, public bits_storage { } // Forward printing stuff to the parser... - virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} - virtual void printOptionInfo(unsigned GlobalWidth) const { + virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);} + virtual void printOptionInfo(size_t GlobalWidth) const { Parser.printOptionInfo(*this, GlobalWidth); } @@ -1260,8 +1262,8 @@ class alias : public Option { return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg); } // Handle printing stuff... - virtual unsigned getOptionWidth() const; - virtual void printOptionInfo(unsigned GlobalWidth) const; + virtual size_t getOptionWidth() const; + virtual void printOptionInfo(size_t GlobalWidth) const; void done() { if (!hasArgStr()) diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h index 5ddc47e0a8..cb9199162e 100644 --- a/include/llvm/Support/GraphWriter.h +++ b/include/llvm/Support/GraphWriter.h @@ -175,8 +175,8 @@ public: child_iterator TargetIt = DOTTraits::getEdgeTarget(Node, EI); // Figure out which edge this targets... - unsigned Offset = std::distance(GTraits::child_begin(TargetNode), - TargetIt); + unsigned Offset = + (unsigned)std::distance(GTraits::child_begin(TargetNode), TargetIt); DestPort = static_cast(Offset); } diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h index 8c36791be5..ac77f6c9a1 100644 --- a/include/llvm/Support/MemoryBuffer.h +++ b/include/llvm/Support/MemoryBuffer.h @@ -40,7 +40,7 @@ public: const char *getBufferStart() const { return BufferStart; } const char *getBufferEnd() const { return BufferEnd; } - unsigned getBufferSize() const { return BufferEnd-BufferStart; } + size_t getBufferSize() const { return BufferEnd-BufferStart; } /// getBufferIdentifier - Return an identifier for this buffer, typically the /// filename it was read from. @@ -71,14 +71,14 @@ public: /// is completely initialized to zeros. Note that the caller should /// initialize the memory allocated by this method. The memory is owned by /// the MemoryBuffer object. - static MemoryBuffer *getNewMemBuffer(unsigned Size, + static MemoryBuffer *getNewMemBuffer(size_t Size, const char *BufferName = ""); /// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size /// that is not initialized. Note that the caller should initialize the /// memory allocated by this method. The memory is owned by the MemoryBuffer /// object. - static MemoryBuffer *getNewUninitMemBuffer(unsigned Size, + static MemoryBuffer *getNewUninitMemBuffer(size_t Size, const char *BufferName = ""); /// getSTDIN - Read all of stdin into a file buffer, and return it. This diff --git a/include/llvm/Support/OutputBuffer.h b/include/llvm/Support/OutputBuffer.h index d16adbd93f..0fedb15e40 100644 --- a/include/llvm/Support/OutputBuffer.h +++ b/include/llvm/Support/OutputBuffer.h @@ -107,8 +107,10 @@ namespace llvm { outxword(X); } void outstring(const std::string &S, unsigned Length) { - unsigned len_to_copy = S.length() < Length ? S.length() : Length; - unsigned len_to_fill = S.length() < Length ? Length - S.length() : 0; + unsigned len_to_copy = static_cast(S.length()) < Length + ? static_cast(S.length()) : Length; + unsigned len_to_fill = static_cast(S.length()) < Length + ? Length - static_cast(S.length()) : 0; for (unsigned i = 0; i < len_to_copy; ++i) outbyte(S[i]); diff --git a/include/llvm/System/Path.h b/include/llvm/System/Path.h index f4487c4542..37c42aa366 100644 --- a/include/llvm/System/Path.h +++ b/include/llvm/System/Path.h @@ -207,14 +207,14 @@ namespace sys { /// @returns true if \p this and \p that refer to the same thing. /// @brief Equality Operator bool operator==(const Path &that) const { - return 0 == path.compare(that.path); + return path == that.path; } /// Compares \p this Path with \p that Path for inequality. /// @returns true if \p this and \p that refer to different things. /// @brief Inequality Operator bool operator!=(const Path &that) const { - return 0 != path.compare(that.path); + return path != that.path; } /// Determines if \p this Path is less than \p that Path. This is required @@ -224,7 +224,7 @@ namespace sys { /// @returns true if \p this path is lexicographically less than \p that. /// @brief Less Than Operator bool operator<(const Path& that) const { - return 0 > path.compare(that.path); + return path < that.path; } /// @} @@ -288,7 +288,7 @@ namespace sys { const char *c_str() const { return path.c_str(); } /// size - Return the length in bytes of this path name. - unsigned size() const { return path.size(); } + size_t size() const { return path.size(); } /// empty - Returns true if the path is empty. unsigned empty() const { return path.empty(); } diff --git a/include/llvm/Target/TargetRegisterInfo.h b/include/llvm/Target/TargetRegisterInfo.h index e902cafa9b..f606c8814f 100644 --- a/include/llvm/Target/TargetRegisterInfo.h +++ b/include/llvm/Target/TargetRegisterInfo.h @@ -99,7 +99,7 @@ public: /// getNumRegs - Return the number of registers in this class. /// - unsigned getNumRegs() const { return RegsEnd-RegsBegin; } + unsigned getNumRegs() const { return (unsigned)(RegsEnd-RegsBegin); } /// getRegister - Return the specified register in the class. /// @@ -465,7 +465,7 @@ public: regclass_iterator regclass_end() const { return RegClassEnd; } unsigned getNumRegClasses() const { - return regclass_end()-regclass_begin(); + return (unsigned)(regclass_end()-regclass_begin()); } /// getRegClass - Returns the register class associated with the enumeration diff --git a/include/llvm/User.h b/include/llvm/User.h index 77bba9de64..d3e4f1ede2 100644 --- a/include/llvm/User.h +++ b/include/llvm/User.h @@ -39,7 +39,7 @@ protected: /// unsigned NumOperands; - void *operator new(size_t s, unsigned) { + void *operator new(size_t s, size_t) { return ::operator new(s); } User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps) -- cgit v1.2.3