1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

Fix more -Wshorten-64-to-32 warnings.

llvm-svn: 50659
This commit is contained in:
Evan Cheng 2008-05-05 18:30:58 +00:00
parent ca94848f66
commit d9353009b7
55 changed files with 225 additions and 186 deletions

View File

@ -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

View File

@ -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<unsigned>(((uintptr_t)Ptr >> 4) & (CurArraySize-1));
}
const void * const *FindBucketFor(const void *Ptr) const;
void shrink_and_clear();

View File

@ -190,7 +190,7 @@ public:
///
template<typename in_iter>
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<unsigned>(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 <typename T>
void SmallVectorImpl<T>::grow(unsigned MinSize) {
unsigned CurCapacity = unsigned(Capacity-Begin);
unsigned CurSize = unsigned(size());
unsigned NewCapacity = 2*CurCapacity;
void SmallVectorImpl<T>::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<T*>(new char[NewCapacity*sizeof(T)]);
@ -375,20 +375,20 @@ void SmallVectorImpl<T>::swap(SmallVectorImpl<T> &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<unsigned>(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<T> {
typedef typename SmallVectorImpl<T>::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<unsigned int>(sizeof(T))*N +
static_cast<unsigned int>(sizeof(U)) - 1) /
static_cast<unsigned int>(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<T> {
// 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<unsigned int>(sizeof(U))/
static_cast<unsigned int>(sizeof(T))
};
U InlineElts[NumInlineEltsElts];
public:

View File

@ -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<unsigned>(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<unsigned>(LHS.size()); i != e; ++i) {
if (RHS[i] == 0) return false; // RHS too short.
if (tolower(LHS[i]) != tolower(RHS[i])) return false;
}

View File

@ -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<unsigned>(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<unsigned>(sizeof(StringMapEntry))+
KeyLength+1;
unsigned Alignment = alignof<StringMapEntry>();
StringMapEntry *NewItem =
@ -236,9 +237,9 @@ class StringMap : public StringMapImpl {
AllocatorTy Allocator;
typedef StringMapEntry<ValueTy> MapEntryTy;
public:
StringMap() : StringMapImpl(sizeof(MapEntryTy)) {}
StringMap() : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) {}
explicit StringMap(unsigned InitialSize)
: StringMapImpl(InitialSize, sizeof(MapEntryTy)) {}
: StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))) {}
AllocatorTy &getAllocator() { return Allocator; }
const AllocatorTy &getAllocator() const { return Allocator; }

View File

@ -41,7 +41,7 @@ public:
if (Val) return Val;
// Compute ID for entry.
Val = Vector.size() + 1;
Val = static_cast<unsigned>(Vector.size()) + 1;
// Insert in vector.
Vector.push_back(Entry);

View File

@ -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();

View File

@ -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...
//

View File

@ -248,7 +248,8 @@ void Calculate(DominatorTreeBase<typename GraphTraits<NodeT>::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<unsigned>(DT.Roots.size());
i != e; ++i)
N = DFSPass<GraphT>(DT, DT.Roots[i], N);
// it might be that some blocks did not get a DFS number (e.g., blocks of

View File

@ -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<std::pair<DomTreeNodeBase<NodeT>*,
typename DomTreeNodeBase<NodeT>::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<NodeT> *ThisRoot = getNode(this->Roots[i]);
WorkStack.push_back(std::make_pair(ThisRoot, ThisRoot->begin()));
ThisRoot->DFSNumIn = DFSNum++;

View File

@ -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<unsigned>(Parent->SubLoops.size());
i != e; ++i)
if (Parent->SubLoops[i]->contains(LHeader)) {
InsertLoopInto(L, Parent->SubLoops[i]);
return;

View File

@ -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<SCEVHandle> &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; }

View File

@ -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(); }

View File

@ -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];
}

View File

@ -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);

View File

@ -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;
}
//===--------------------------------------------------------------------===//

View File

@ -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<VNInfo*>(VNInfoAllocator.Allocate(sizeof(VNInfo),
Alignment));
new (VNI) VNInfo(valnos.size(), MIIdx, CopyMI);
VNInfo *VNI =
static_cast<VNInfo*>(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<unsigned, 4> &kills) {
for (unsigned i = 0, e = kills.size(); i != e; ++i) {
for (unsigned i = 0, e = static_cast<unsigned>(kills.size());
i != e; ++i) {
unsigned KillIdx = kills[i];
if (!liveBeforeAndAt(KillIdx)) {
SmallVector<unsigned, 4>::iterator

View File

@ -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);

View File

@ -108,7 +108,7 @@ public:
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<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.

View File

@ -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<unsigned>(String.size());
i < N; ++i) {
unsigned char C = String[i];
emitByte(C);
}

View File

@ -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

View File

@ -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

View File

@ -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!");

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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; }

View File

@ -163,7 +163,7 @@ public:
return getVTList(VT1, VT2, VT3).VTs;
}
const MVT::ValueType *getNodeValueTypes(std::vector<MVT::ValueType> &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.

View File

@ -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.

View File

@ -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<unsigned>(ProgramArguments.size());
}
const std::string &getProgramArgument(unsigned i) const {
return ProgramArguments[i];
}

View File

@ -74,7 +74,7 @@ namespace llvm {
///
unsigned getNumLines() const {
if (LineOffset.empty()) calculateLineOffsets();
return LineOffset.size();
return static_cast<unsigned>(LineOffset.size());
}
private:

View File

@ -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<InputIterator>::difference_type NumIdx =
std::distance(IdxBegin, IdxEnd);
unsigned NumIdx = static_cast<unsigned>(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<InputIterator>::difference_type NumIdx =
std::distance(IdxBegin, IdxEnd);
unsigned NumIdx = static_cast<unsigned>(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);
}

View File

@ -124,7 +124,7 @@ public:
template <typename Iter>
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<unsigned>(E-I));
}
/// addAttr - Add the specified attribute at the specified index to this

View File

@ -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<AnalysisID> &Set) const;
virtual unsigned getNumContainedPasses() {
return PassVector.size();
return (unsigned)PassVector.size();
}
virtual PassManagerType getPassManagerType() const {

View File

@ -34,7 +34,8 @@ private:
/// compile-time constant (e.g., for template instantiation).
template <typename T>
struct AlignOf {
enum { Alignment = sizeof(AlignmentCalcImpl<T>) - sizeof(T) };
enum { Alignment =
static_cast<unsigned int>(sizeof(AlignmentCalcImpl<T>) - sizeof(T)) };
enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 };
enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 };

View File

@ -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 <typename T>
void *Allocate() { return reinterpret_cast<T*>(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 <typename T>
void *Allocate() {

View File

@ -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<const char*> &OptionNames) {}
@ -334,7 +334,8 @@ public:
template<class Opt>
void apply(Opt &O) const {
for (unsigned i = 0, e = Values.size(); i != e; ++i)
for (unsigned i = 0, e = static_cast<unsigned>(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<unsigned>(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<t>
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<DataType, 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<DataType, 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())

View File

@ -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<int>(Offset);
}

View File

@ -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

View File

@ -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<unsigned>(S.length()) < Length
? static_cast<unsigned>(S.length()) : Length;
unsigned len_to_fill = static_cast<unsigned>(S.length()) < Length
? Length - static_cast<unsigned>(S.length()) : 0;
for (unsigned i = 0; i < len_to_copy; ++i)
outbyte(S[i]);

View File

@ -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(); }

View File

@ -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

View File

@ -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)

View File

@ -45,7 +45,7 @@ public:
/// Allocate - Allocate and return at least the specified number of bytes.
///
void *Allocate(unsigned AllocSize, unsigned Alignment, MemRegion **RegPtr) {
void *Allocate(size_t AllocSize, size_t Alignment, MemRegion **RegPtr) {
char* Result = (char*) (((uintptr_t) (NextPtr+Alignment-1))
& ~((uintptr_t) Alignment-1));
@ -113,7 +113,7 @@ void BumpPtrAllocator::Reset() {
TheMemory = MRP;
}
void *BumpPtrAllocator::Allocate(unsigned Size, unsigned Align) {
void *BumpPtrAllocator::Allocate(size_t Size, size_t Align) {
MemRegion *MRP = (MemRegion*)TheMemory;
void *Ptr = MRP->Allocate(Size, Align, &MRP);
TheMemory = MRP;

View File

@ -115,7 +115,7 @@ static void GetOptionInfo(std::vector<Option*> &PositionalOpts,
OptionNames.push_back(O->ArgStr);
// Handle named options.
for (unsigned i = 0, e = OptionNames.size(); i != e; ++i) {
for (size_t i = 0, e = OptionNames.size(); i != e; ++i) {
// Add argument to the argument map!
if (!OptionsMap.insert(std::pair<std::string,Option*>(OptionNames[i],
O)).second) {
@ -223,7 +223,7 @@ static inline bool isPrefixedOrGrouping(const Option *O) {
// see if there options that satisfy the predicate. If we find one, return it,
// otherwise return null.
//
static Option *getOptionPred(std::string Name, unsigned &Length,
static Option *getOptionPred(std::string Name, size_t &Length,
bool (*Pred)(const Option*),
std::map<std::string, Option*> &OptionsMap) {
@ -329,7 +329,7 @@ void cl::ParseEnvironmentOptions(const char *progName, const char *envVar,
// Parse the value of the environment variable into a "command line"
// and hand it off to ParseCommandLineOptions().
ParseCStringVector(newArgv, envValue);
int newArgc = newArgv.size();
int newArgc = static_cast<int>(newArgv.size());
ParseCommandLineOptions(newArgc, &newArgv[0], Overview, ReadResponseFiles);
// Free all the strdup()ed strings.
@ -391,7 +391,7 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
newArgv.push_back(strdup(argv[0]));
ExpandResponseFiles(argc, argv, newArgv);
argv = &newArgv[0];
argc = newArgv.size();
argc = static_cast<int>(newArgv.size());
}
sys::Path progname(argv[0]);
@ -420,7 +420,7 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
// Calculate how many positional values are _required_.
bool UnboundedFound = false;
for (unsigned i = ConsumeAfterOpt != 0, e = PositionalOpts.size();
for (size_t i = ConsumeAfterOpt != 0, e = PositionalOpts.size();
i != e; ++i) {
Option *Opt = PositionalOpts[i];
if (RequiresValue(Opt))
@ -525,7 +525,7 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
if (Handler == 0) {
std::string RealName(ArgName);
if (RealName.size() > 1) {
unsigned Length = 0;
size_t Length = 0;
Option *PGOpt = getOptionPred(RealName, Length, isPrefixedOrGrouping,
Opts);
@ -627,8 +627,8 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
} else if (ConsumeAfterOpt == 0) {
// Positional args have already been handled if ConsumeAfter is specified...
unsigned ValNo = 0, NumVals = PositionalVals.size();
for (unsigned i = 0, e = PositionalOpts.size(); i != e; ++i) {
unsigned ValNo = 0, NumVals = static_cast<unsigned>(PositionalVals.size());
for (size_t i = 0, e = PositionalOpts.size(); i != e; ++i) {
if (RequiresValue(PositionalOpts[i])) {
ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo].first,
PositionalVals[ValNo].second);
@ -662,7 +662,7 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
} else {
assert(ConsumeAfterOpt && NumPositionalRequired <= PositionalVals.size());
unsigned ValNo = 0;
for (unsigned j = 1, e = PositionalOpts.size(); j != e; ++j)
for (size_t j = 1, e = PositionalOpts.size(); j != e; ++j)
if (RequiresValue(PositionalOpts[j])) {
ErrorParsing |= ProvidePositionalOption(PositionalOpts[j],
PositionalVals[ValNo].first,
@ -775,13 +775,13 @@ static const char *getValueStr(const Option &O, const char *DefaultMsg) {
//
// Return the width of the option tag for printing...
unsigned alias::getOptionWidth() const {
size_t alias::getOptionWidth() const {
return std::strlen(ArgStr)+6;
}
// Print out the option for the alias.
void alias::printOptionInfo(unsigned GlobalWidth) const {
unsigned L = std::strlen(ArgStr);
void alias::printOptionInfo(size_t GlobalWidth) const {
size_t L = std::strlen(ArgStr);
cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - "
<< HelpStr << "\n";
}
@ -796,8 +796,8 @@ void alias::printOptionInfo(unsigned GlobalWidth) const {
//
// Return the width of the option tag for printing...
unsigned basic_parser_impl::getOptionWidth(const Option &O) const {
unsigned Len = std::strlen(O.ArgStr);
size_t basic_parser_impl::getOptionWidth(const Option &O) const {
size_t Len = std::strlen(O.ArgStr);
if (const char *ValName = getValueName())
Len += std::strlen(getValueStr(O, ValName))+3;
@ -808,7 +808,7 @@ unsigned basic_parser_impl::getOptionWidth(const Option &O) const {
// to-be-maintained width is specified.
//
void basic_parser_impl::printOptionInfo(const Option &O,
unsigned GlobalWidth) const {
size_t GlobalWidth) const {
cout << " -" << O.ArgStr;
if (const char *ValName = getValueName())
@ -926,16 +926,16 @@ unsigned generic_parser_base::findOption(const char *Name) {
// Return the width of the option tag for printing...
unsigned generic_parser_base::getOptionWidth(const Option &O) const {
size_t generic_parser_base::getOptionWidth(const Option &O) const {
if (O.hasArgStr()) {
unsigned Size = std::strlen(O.ArgStr)+6;
size_t Size = std::strlen(O.ArgStr)+6;
for (unsigned i = 0, e = getNumOptions(); i != e; ++i)
Size = std::max(Size, (unsigned)std::strlen(getOption(i))+8);
Size = std::max(Size, std::strlen(getOption(i))+8);
return Size;
} else {
unsigned BaseSize = 0;
size_t BaseSize = 0;
for (unsigned i = 0, e = getNumOptions(); i != e; ++i)
BaseSize = std::max(BaseSize, (unsigned)std::strlen(getOption(i))+8);
BaseSize = std::max(BaseSize, std::strlen(getOption(i))+8);
return BaseSize;
}
}
@ -944,14 +944,14 @@ unsigned generic_parser_base::getOptionWidth(const Option &O) const {
// to-be-maintained width is specified.
//
void generic_parser_base::printOptionInfo(const Option &O,
unsigned GlobalWidth) const {
size_t GlobalWidth) const {
if (O.hasArgStr()) {
unsigned L = std::strlen(O.ArgStr);
size_t L = std::strlen(O.ArgStr);
cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ')
<< " - " << O.HelpStr << "\n";
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8;
size_t NumSpaces = GlobalWidth-strlen(getOption(i))-8;
cout << " =" << getOption(i) << std::string(NumSpaces, ' ')
<< " - " << getDescription(i) << "\n";
}
@ -959,7 +959,7 @@ void generic_parser_base::printOptionInfo(const Option &O,
if (O.HelpStr[0])
cout << " " << O.HelpStr << "\n";
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
unsigned L = std::strlen(getOption(i));
size_t L = std::strlen(getOption(i));
cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ')
<< " - " << getDescription(i) << "\n";
}
@ -974,7 +974,7 @@ void generic_parser_base::printOptionInfo(const Option &O,
namespace {
class HelpPrinter {
unsigned MaxArgLen;
size_t MaxArgLen;
const Option *EmptyArg;
const bool ShowHidden;
@ -1030,7 +1030,7 @@ public:
PositionalOpts[0]->getNumOccurrencesFlag() == ConsumeAfter)
CAOpt = PositionalOpts[0];
for (unsigned i = CAOpt != 0, e = PositionalOpts.size(); i != e; ++i) {
for (size_t i = CAOpt != 0, e = PositionalOpts.size(); i != e; ++i) {
if (PositionalOpts[i]->ArgStr[0])
cout << " --" << PositionalOpts[i]->ArgStr;
cout << " " << PositionalOpts[i]->HelpStr;
@ -1043,11 +1043,11 @@ public:
// Compute the maximum argument length...
MaxArgLen = 0;
for (unsigned i = 0, e = Opts.size(); i != e; ++i)
for (size_t i = 0, e = Opts.size(); i != e; ++i)
MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
cout << "OPTIONS:\n";
for (unsigned i = 0, e = Opts.size(); i != e; ++i)
for (size_t i = 0, e = Opts.size(); i != e; ++i)
Opts[i].second->printOptionInfo(MaxArgLen);
// Print any extra help the user has declared.

View File

@ -98,7 +98,8 @@ static bool CompareNumbers(const char *&F1P, const char *&F2P,
if (*F1NumEnd == 'D' || *F1NumEnd == 'd') {
// Copy string into tmp buffer to replace the 'D' with an 'e'.
SmallString<200> StrTmp(F1P, EndOfNumber(F1NumEnd)+1);
StrTmp[F1NumEnd-F1P] = 'e'; // Strange exponential notation!
// Strange exponential notation!
StrTmp[static_cast<unsigned>(F1NumEnd-F1P)] = 'e';
V1 = strtod(&StrTmp[0], const_cast<char**>(&F1NumEnd));
F1NumEnd = F1P + (F1NumEnd-&StrTmp[0]);
@ -107,7 +108,8 @@ static bool CompareNumbers(const char *&F1P, const char *&F2P,
if (*F2NumEnd == 'D' || *F2NumEnd == 'd') {
// Copy string into tmp buffer to replace the 'D' with an 'e'.
SmallString<200> StrTmp(F2P, EndOfNumber(F2NumEnd)+1);
StrTmp[F2NumEnd-F2P] = 'e'; // Strange exponential notation!
// Strange exponential notation!
StrTmp[static_cast<unsigned>(F2NumEnd-F2P)] = 'e';
V2 = strtod(&StrTmp[0], const_cast<char**>(&F2NumEnd));
F2NumEnd = F2P + (F2NumEnd-&StrTmp[0]);

View File

@ -58,7 +58,7 @@ void FoldingSetNodeID::AddDouble(double D) {
AddInteger(DoubleToBits(D));
}
void FoldingSetNodeID::AddString(const std::string &String) {
unsigned Size = String.size();
unsigned Size = static_cast<unsigned>(String.size());
Bits.push_back(Size);
if (!Size) return;
@ -98,7 +98,7 @@ void FoldingSetNodeID::AddString(const std::string &String) {
/// lookup the node in the FoldingSetImpl.
unsigned FoldingSetNodeID::ComputeHash() const {
// This is adapted from SuperFastHash by Paul Hsieh.
unsigned Hash = Bits.size();
unsigned Hash = static_cast<unsigned>(Bits.size());
for (const unsigned *BP = &Bits[0], *E = BP+Bits.size(); BP != E; ++BP) {
unsigned Data = *BP;
Hash += Data & 0xFFFF;

View File

@ -106,7 +106,7 @@ MemoryBuffer *MemoryBuffer::getMemBufferCopy(const char *StartPtr,
/// that 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.
MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(unsigned Size,
MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(size_t Size,
const char *BufferName) {
char *Buf = new char[Size+1];
Buf[Size] = 0;
@ -120,7 +120,7 @@ MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(unsigned Size,
/// 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.
MemoryBuffer *MemoryBuffer::getNewMemBuffer(unsigned Size,
MemoryBuffer *MemoryBuffer::getNewMemBuffer(size_t Size,
const char *BufferName) {
MemoryBuffer *SB = getNewUninitMemBuffer(Size, BufferName);
memset(const_cast<char*>(SB->getBufferStart()), 0, Size+1);
@ -214,7 +214,7 @@ MemoryBuffer *MemoryBuffer::getFile(const char *Filename, std::string *ErrStr,
SB.reset(MemoryBuffer::getNewUninitMemBuffer(FileSize, Filename));
char *BufPtr = const_cast<char*>(SB->getBufferStart());
unsigned BytesLeft = FileSize;
size_t BytesLeft = FileSize;
while (BytesLeft) {
ssize_t NumRead = ::read(FD, BufPtr, BytesLeft);
if (NumRead != -1) {

View File

@ -90,7 +90,7 @@ StatisticInfo::~StatisticInfo() {
// Figure out how long the biggest Value and Name fields are.
unsigned MaxNameLen = 0, MaxValLen = 0;
for (unsigned i = 0, e = Stats.size(); i != e; ++i) {
for (size_t i = 0, e = Stats.size(); i != e; ++i) {
MaxValLen = std::max(MaxValLen,
(unsigned)utostr(Stats[i]->getValue()).size());
MaxNameLen = std::max(MaxNameLen,
@ -106,7 +106,7 @@ StatisticInfo::~StatisticInfo() {
<< "===" << std::string(73, '-') << "===\n\n";
// Print all of the statistics.
for (unsigned i = 0, e = Stats.size(); i != e; ++i) {
for (size_t i = 0, e = Stats.size(); i != e; ++i) {
std::string CountStr = utostr(Stats[i]->getValue());
OutStream << std::string(MaxValLen-CountStr.size(), ' ')
<< CountStr << " " << Stats[i]->getName()

View File

@ -22,7 +22,7 @@ using namespace llvm;
/// The Source source string is updated in place to remove the returned string
/// and any delimiter prefix from it.
std::string llvm::getToken(std::string &Source, const char *Delimiters) {
unsigned NumDelimiters = std::strlen(Delimiters);
size_t NumDelimiters = std::strlen(Delimiters);
// Figure out where the token starts.
std::string::size_type Start =

View File

@ -124,7 +124,8 @@ Path::isDynamicLibrary() const {
if (canRead()) {
std::string Magic;
if (getMagicNumber(Magic, 64))
switch (IdentifyFileType(Magic.c_str(), Magic.length())) {
switch (IdentifyFileType(Magic.c_str(),
static_cast<unsigned>(Magic.length()))) {
default: return false;
case Mach_O_FixedVirtualMemorySharedLib_FileType:
case Mach_O_DynamicallyLinkedSharedLib_FileType:
@ -167,7 +168,7 @@ Path::isBitcodeFile() const {
bool Path::hasMagicNumber(const std::string &Magic) const {
std::string actualMagic;
if (getMagicNumber(actualMagic, Magic.size()))
if (getMagicNumber(actualMagic, static_cast<unsigned>(Magic.size())))
return Magic == actualMagic;
return false;
}
@ -204,7 +205,7 @@ static std::string getDirnameCharSep(const std::string& path, char Sep) {
// If the path is all slashes, return a single slash.
// Otherwise, remove all trailing slashes.
signed pos = path.size() - 1;
signed pos = static_cast<signed>(path.size()) - 1;
while (pos >= 0 && path[pos] == Sep)
--pos;

View File

@ -28,7 +28,7 @@ llvm::sys::Memory::AllocateRWX(unsigned NumBytes, const MemoryBlock* NearBlock,
std::string *ErrMsg) {
if (NumBytes == 0) return MemoryBlock();
long pageSize = Process::GetPageSize();
unsigned pageSize = Process::GetPageSize();
unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
int fd = -1;

View File

@ -566,7 +566,7 @@ Path::createDirectoryOnDisk( bool create_parents, std::string* ErrMsg ) {
path.copy(pathname,MAXPATHLEN);
// Null-terminate the last component
int lastchar = path.length() - 1 ;
size_t lastchar = path.length() - 1 ;
if (pathname[lastchar] != '/')
++lastchar;
@ -639,7 +639,7 @@ Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
// Otherwise, try to just remove the one directory.
char pathname[MAXPATHLEN];
path.copy(pathname, MAXPATHLEN);
int lastchar = path.length() - 1 ;
size_t lastchar = path.length() - 1;
if (pathname[lastchar] == '/')
pathname[lastchar] = 0;
else

View File

@ -58,7 +58,7 @@ Program::FindProgramByName(const std::string& progName) {
return Path();
// Now we have a colon separated list of directories to search; try them.
unsigned PathLen = strlen(PathStr);
size_t PathLen = strlen(PathStr);
while (PathLen) {
// Find the first colon...
const char *Colon = std::find(PathStr, PathStr+PathLen, ':');

View File

@ -65,7 +65,8 @@ static void* StackTrace[256];
static void PrintStackTrace() {
#ifdef HAVE_BACKTRACE
// Use backtrace() to output a backtrace on Linux systems with glibc.
int depth = backtrace(StackTrace, array_lengthof(StackTrace));
int depth = backtrace(StackTrace,
static_cast<int>(array_lengthof(StackTrace)));
backtrace_symbols_fd(StackTrace, depth, STDERR_FILENO);
#endif
}