llvm.org GIT mirror llvm / 34cd4a4
Fix more -Wshorten-64-to-32 warnings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50659 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 12 years ago
55 changed file(s) with 225 addition(s) and 186 deletion(s). Raw diff Collapse all Expand all
2424 class BitVector {
2525 typedef unsigned long BitWord;
2626
27 enum { BITWORD_SIZE = sizeof(BitWord) * 8 };
27 enum { BITWORD_SIZE = (unsigned)sizeof(BitWord) * 8 };
2828
2929 BitWord *Bits; // Actual bits.
3030 unsigned Size; // Size of bitvector in bits.
102102 unsigned NumBits = 0;
103103 for (unsigned i = 0; i < NumBitWords(size()); ++i)
104104 if (sizeof(BitWord) == 4)
105 NumBits += CountPopulation_32(Bits[i]);
105 NumBits += CountPopulation_32((uint32_t)Bits[i]);
106106 else if (sizeof(BitWord) == 8)
107107 NumBits += CountPopulation_64(Bits[i]);
108108 else
129129 for (unsigned i = 0; i < NumBitWords(size()); ++i)
130130 if (Bits[i] != 0) {
131131 if (sizeof(BitWord) == 4)
132 return i * BITWORD_SIZE + CountTrailingZeros_32(Bits[i]);
132 return i * BITWORD_SIZE + CountTrailingZeros_32((uint32_t)Bits[i]);
133133 else if (sizeof(BitWord) == 8)
134134 return i * BITWORD_SIZE + CountTrailingZeros_64(Bits[i]);
135135 else
153153
154154 if (Copy != 0) {
155155 if (sizeof(BitWord) == 4)
156 return WordPos * BITWORD_SIZE + CountTrailingZeros_32(Copy);
156 return WordPos * BITWORD_SIZE + CountTrailingZeros_32((uint32_t)Copy);
157157 else if (sizeof(BitWord) == 8)
158158 return WordPos * BITWORD_SIZE + CountTrailingZeros_64(Copy);
159159 else
164164 for (unsigned i = WordPos+1; i < NumBitWords(size()); ++i)
165165 if (Bits[i] != 0) {
166166 if (sizeof(BitWord) == 4)
167 return i * BITWORD_SIZE + CountTrailingZeros_32(Bits[i]);
167 return i * BITWORD_SIZE + CountTrailingZeros_32((uint32_t)Bits[i]);
168168 else if (sizeof(BitWord) == 8)
169169 return i * BITWORD_SIZE + CountTrailingZeros_64(Bits[i]);
170170 else
120120 bool isSmall() const { return CurArray == &SmallArray[0]; }
121121
122122 unsigned Hash(const void *Ptr) const {
123 return ((uintptr_t)Ptr >> 4) & (CurArraySize-1);
123 return static_cast(((uintptr_t)Ptr >> 4) & (CurArraySize-1));
124124 }
125125 const void * const *FindBucketFor(const void *Ptr) const;
126126 void shrink_and_clear();
189189 ///
190190 template
191191 void append(in_iter in_start, in_iter in_end) {
192 unsigned NumInputs = std::distance(in_start, in_end);
192 size_type NumInputs = std::distance(in_start, in_end);
193193 // Grow allocated space if needed.
194194 if (End+NumInputs > Capacity)
195195 grow(size()+NumInputs);
241241 *I = Elt;
242242 return I;
243243 }
244 unsigned EltNo = I-Begin;
244 size_t EltNo = I-Begin;
245245 grow();
246246 I = Begin+EltNo;
247247 goto Retry;
254254 return end()-1;
255255 }
256256
257 unsigned NumToInsert = std::distance(From, To);
257 size_t NumToInsert = std::distance(From, To);
258258 // Convert iterator to elt# to avoid invalidating iterator when we reserve()
259 unsigned InsertElt = I-begin();
259 size_t InsertElt = I-begin();
260260
261261 // Ensure there is enough space.
262 reserve(size() + NumToInsert);
262 reserve(static_cast(size() + NumToInsert));
263263
264264 // Uninvalidate the iterator.
265265 I = begin()+InsertElt;
284284 // Copy over the elements that we're about to overwrite.
285285 T *OldEnd = End;
286286 End += NumToInsert;
287 unsigned NumOverwritten = OldEnd-I;
287 size_t NumOverwritten = OldEnd-I;
288288 std::uninitialized_copy(I, OldEnd, End-NumOverwritten);
289289
290290 // Replace the overwritten part.
317317
318318 /// grow - double the size of the allocated memory, guaranteeing space for at
319319 /// least one more element or MinSize if specified.
320 void grow(unsigned MinSize = 0);
320 void grow(size_type MinSize = 0);
321321
322322 void construct_range(T *S, T *E, const T &Elt) {
323323 for (; S != E; ++S)
334334
335335 // Define this out-of-line to dissuade the C++ compiler from inlining it.
336336 template
337 void SmallVectorImpl::grow(unsigned MinSize) {
338 unsigned CurCapacity = unsigned(Capacity-Begin);
339 unsigned CurSize = unsigned(size());
340 unsigned NewCapacity = 2*CurCapacity;
337 void SmallVectorImpl::grow(size_t MinSize) {
338 size_t CurCapacity = Capacity-Begin;
339 size_t CurSize = size();
340 size_t NewCapacity = 2*CurCapacity;
341341 if (NewCapacity < MinSize)
342342 NewCapacity = MinSize;
343343 T *NewElts = reinterpret_cast(new char[NewCapacity*sizeof(T)]);
374374 RHS.grow(size());
375375
376376 // Swap the shared elements.
377 unsigned NumShared = size();
377 size_t NumShared = size();
378378 if (NumShared > RHS.size()) NumShared = RHS.size();
379 for (unsigned i = 0; i != NumShared; ++i)
379 for (unsigned i = 0; i != static_cast(NumShared); ++i)
380380 std::swap(Begin[i], RHS[i]);
381381
382382 // Copy over the extra elts.
383383 if (size() > RHS.size()) {
384 unsigned EltDiff = size() - RHS.size();
384 size_t EltDiff = size() - RHS.size();
385385 std::uninitialized_copy(Begin+NumShared, End, RHS.End);
386386 RHS.End += EltDiff;
387387 destroy_range(Begin+NumShared, End);
388388 End = Begin+NumShared;
389389 } else if (RHS.size() > size()) {
390 unsigned EltDiff = RHS.size() - size();
390 size_t EltDiff = RHS.size() - size();
391391 std::uninitialized_copy(RHS.Begin+NumShared, RHS.End, End);
392392 End += EltDiff;
393393 destroy_range(RHS.Begin+NumShared, RHS.End);
457457 typedef typename SmallVectorImpl::U U;
458458 enum {
459459 // MinUs - The number of U's require to cover N T's.
460 MinUs = (sizeof(T)*N+sizeof(U)-1)/sizeof(U),
460 MinUs = (static_cast(sizeof(T))*N +
461 static_cast(sizeof(U)) - 1) /
462 static_cast(sizeof(U)),
461463
462464 // NumInlineEltsElts - The number of elements actually in this array. There
463465 // is already one in the parent class, and we have to round up to avoid
466468
467469 // NumTsAvailable - The number of T's we actually have space for, which may
468470 // be more than N due to rounding.
469 NumTsAvailable = (NumInlineEltsElts+1)*sizeof(U) / sizeof(T)
471 NumTsAvailable = (NumInlineEltsElts+1)*static_cast(sizeof(U))/
472 static_cast(sizeof(T))
470473 };
471474 U InlineElts[NumInlineEltsElts];
472475 public:
125125 static inline bool StringsEqualNoCase(const std::string &LHS,
126126 const std::string &RHS) {
127127 if (LHS.size() != RHS.size()) return false;
128 for (unsigned i = 0, e = LHS.size(); i != e; ++i)
128 for (unsigned i = 0, e = static_cast(LHS.size()); i != e; ++i)
129129 if (tolower(LHS[i]) != tolower(RHS[i])) return false;
130130 return true;
131131 }
134134 /// case.
135135 static inline bool StringsEqualNoCase(const std::string &LHS,
136136 const char *RHS) {
137 for (unsigned i = 0, e = LHS.size(); i != e; ++i) {
137 for (unsigned i = 0, e = static_cast(LHS.size()); i != e; ++i) {
138138 if (RHS[i] == 0) return false; // RHS too short.
139139 if (tolower(LHS[i]) != tolower(RHS[i])) return false;
140140 }
152152 static StringMapEntry *Create(const char *KeyStart, const char *KeyEnd,
153153 AllocatorTy &Allocator,
154154 InitType InitVal) {
155 unsigned KeyLength = KeyEnd-KeyStart;
155 unsigned KeyLength = static_cast(KeyEnd-KeyStart);
156156
157157 // Okay, the item doesn't already exist, and 'Bucket' is the bucket to fill
158158 // in. Allocate a new item with space for the string at the end and a null
159159 // terminator.
160160
161 unsigned AllocSize = sizeof(StringMapEntry)+KeyLength+1;
161 unsigned AllocSize = static_cast(sizeof(StringMapEntry))+
162 KeyLength+1;
162163 unsigned Alignment = alignof();
163164
164165 StringMapEntry *NewItem =
235236 AllocatorTy Allocator;
236237 typedef StringMapEntry MapEntryTy;
237238 public:
238 StringMap() : StringMapImpl(sizeof(MapEntryTy)) {}
239 StringMap() : StringMapImpl(static_cast(sizeof(MapEntryTy))) {}
239240 explicit StringMap(unsigned InitialSize)
240 : StringMapImpl(InitialSize, sizeof(MapEntryTy)) {}
241 : StringMapImpl(InitialSize, static_cast(sizeof(MapEntryTy))) {}
241242
242243 AllocatorTy &getAllocator() { return Allocator; }
243244 const AllocatorTy &getAllocator() const { return Allocator; }
4040 if (Val) return Val;
4141
4242 // Compute ID for entry.
43 Val = Vector.size() + 1;
43 Val = static_cast(Vector.size()) + 1;
4444
4545 // Insert in vector.
4646 Vector.push_back(Entry);
231231 bool KnownMustAlias = false);
232232 void addCallSite(CallSite CS, AliasAnalysis &AA);
233233 void removeCallSite(CallSite CS) {
234 for (unsigned i = 0, e = CallSites.size(); i != e; ++i)
234 for (size_t i = 0, e = CallSites.size(); i != e; ++i)
235235 if (CallSites[i].getInstruction() == CS.getInstruction()) {
236236 CallSites[i] = CallSites.back();
237237 CallSites.pop_back();
190190 inline const_iterator begin() const { return CalledFunctions.begin(); }
191191 inline const_iterator end() const { return CalledFunctions.end(); }
192192 inline bool empty() const { return CalledFunctions.empty(); }
193 inline unsigned size() const { return CalledFunctions.size(); }
193 inline unsigned size() const { return (unsigned)CalledFunctions.size(); }
194194
195195 // Subscripting operator - Return the i'th called function...
196196 //
247247
248248 // Step #1: Number blocks in depth-first order and initialize variables used
249249 // in later stages of the algorithm.
250 for (unsigned i = 0, e = DT.Roots.size(); i != e; ++i)
250 for (unsigned i = 0, e = static_cast(DT.Roots.size());
251 i != e; ++i)
251252 N = DFSPass(DT, DT.Roots[i], N);
252253
253254 // it might be that some blocks did not get a DFS number (e.g., blocks of
236236 bool NewBBDominatesNewBBSucc = true;
237237 {
238238 typename GraphT::NodeType* OnePred = PredBlocks[0];
239 unsigned i = 1, e = PredBlocks.size();
239 size_t i = 1, e = PredBlocks.size();
240240 for (i = 1; !DT.isReachableFromEntry(OnePred); ++i) {
241241 assert(i != e && "Didn't find reachable pred?");
242242 OnePred = PredBlocks[i];
566566 SmallVector*,
567567 typename DomTreeNodeBase::iterator>, 32> WorkStack;
568568
569 for (unsigned i = 0, e = this->Roots.size(); i != e; ++i) {
569 for (unsigned i = 0, e = (unsigned)this->Roots.size(); i != e; ++i) {
570570 DomTreeNodeBase *ThisRoot = getNode(this->Roots[i]);
571571 WorkStack.push_back(std::make_pair(ThisRoot, ThisRoot->begin()));
572572 ThisRoot->DFSNumIn = DFSNum++;
7979 /// Loop ctor - This creates an empty loop.
8080 LoopBase() : ParentLoop(0) {}
8181 ~LoopBase() {
82 for (unsigned i = 0, e = SubLoops.size(); i != e; ++i)
82 for (size_t i = 0, e = SubLoops.size(); i != e; ++i)
8383 delete SubLoops[i];
8484 }
8585
846846 "This loop should not be inserted here!");
847847
848848 // Check to see if it belongs in a child loop...
849 for (unsigned i = 0, e = Parent->SubLoops.size(); i != e; ++i)
849 for (unsigned i = 0, e = static_cast(Parent->SubLoops.size());
850 i != e; ++i)
850851 if (Parent->SubLoops[i]->contains(LHeader)) {
851852 InsertLoopInto(L, Parent->SubLoops[i]);
852853 return;
228228 ~SCEVCommutativeExpr();
229229
230230 public:
231 unsigned getNumOperands() const { return Operands.size(); }
231 unsigned getNumOperands() const { return (unsigned)Operands.size(); }
232232 const SCEVHandle &getOperand(unsigned i) const {
233233 assert(i < Operands.size() && "Operand index out of range!");
234234 return Operands[i];
386386
387387 SCEVAddRecExpr(const std::vector &ops, const Loop *l)
388388 : SCEV(scAddRecExpr), Operands(ops), L(l) {
389 for (unsigned i = 0, e = Operands.size(); i != e; ++i)
389 for (size_t i = 0, e = Operands.size(); i != e; ++i)
390390 assert(Operands[i]->isLoopInvariant(l) &&
391391 "Operands of AddRec must be loop-invariant!");
392392 }
396396 op_iterator op_begin() const { return Operands.begin(); }
397397 op_iterator op_end() const { return Operands.end(); }
398398
399 unsigned getNumOperands() const { return Operands.size(); }
399 unsigned getNumOperands() const { return (unsigned)Operands.size(); }
400400 const SCEVHandle &getOperand(unsigned i) const { return Operands[i]; }
401401 const SCEVHandle &getStart() const { return Operands[0]; }
402402 const Loop *getLoop() const { return L; }
253253 inline reverse_iterator rend () { return members.rend(); }
254254 inline const_reverse_iterator rend () const { return members.rend(); }
255255
256 inline unsigned size() const { return members.size(); }
256 inline size_t size() const { return members.size(); }
257257 inline bool empty() const { return members.empty(); }
258258 inline const ArchiveMember& front() const { return members.front(); }
259259 inline ArchiveMember& front() { return members.front(); }
164164 void addRef() { ++RefCount; }
165165 void dropRef() { if (--RefCount == 0) delete this; }
166166
167 unsigned getNumOperandInfos() const { return OperandList.size(); }
167 unsigned getNumOperandInfos() const {
168 return static_cast(OperandList.size());
169 }
168170 const BitCodeAbbrevOp &getOperandInfo(unsigned N) const {
169171 return OperandList[N];
170172 }
8484 ~BitstreamReader() {
8585 // Abbrevs could still exist if the stream was broken. If so, don't leak
8686 // them.
87 for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
87 for (unsigned i = 0, e = static_cast(CurAbbrevs.size());
88 i != e; ++i)
8889 CurAbbrevs[i]->dropRef();
8990
90 for (unsigned S = 0, e = BlockScope.size(); S != e; ++S) {
91 for (unsigned S = 0, e = static_cast(BlockScope.size());
92 S != e; ++S) {
9193 std::vector &Abbrevs = BlockScope[S].PrevAbbrevs;
92 for (unsigned i = 0, e = Abbrevs.size(); i != e; ++i)
94 for (unsigned i = 0, e = static_cast(Abbrevs.size());
95 i != e; ++i)
9396 Abbrevs[i]->dropRef();
9497 }
9598
97100 while (!BlockInfoRecords.empty()) {
98101 BlockInfo &Info = BlockInfoRecords.back();
99102 // Free blockinfo abbrev info.
100 for (unsigned i = 0, e = Info.Abbrevs.size(); i != e; ++i)
103 for (unsigned i = 0, e = static_cast(Info.Abbrevs.size());
104 i != e; ++i)
101105 Info.Abbrevs[i]->dropRef();
102106 BlockInfoRecords.pop_back();
103107 }
126130 // Skip over any bits that are already consumed.
127131 if (WordBitNo) {
128132 NextChar -= 4;
129 Read(WordBitNo);
133 Read(static_cast(WordBitNo));
130134 }
131135 }
132136
236240 if (!BlockInfoRecords.empty() && BlockInfoRecords.back().BlockID == BlockID)
237241 return &BlockInfoRecords.back();
238242
239 for (unsigned i = 0, e = BlockInfoRecords.size(); i != e; ++i)
243 for (unsigned i = 0, e = static_cast(BlockInfoRecords.size());
244 i != e; ++i)
240245 if (BlockInfoRecords[i].BlockID == BlockID)
241246 return &BlockInfoRecords[i];
242247 return 0;
281286
282287 // Add the abbrevs specific to this block to the CurAbbrevs list.
283288 if (BlockInfo *Info = getBlockInfo(BlockID)) {
284 for (unsigned i = 0, e = Info->Abbrevs.size(); i != e; ++i) {
289 for (unsigned i = 0, e = static_cast(Info->Abbrevs.size());
290 i != e; ++i) {
285291 CurAbbrevs.push_back(Info->Abbrevs[i]);
286292 CurAbbrevs.back()->addRef();
287293 }
316322 CurCodeSize = BlockScope.back().PrevCodeSize;
317323
318324 // Delete abbrevs from popped scope.
319 for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
325 for (unsigned i = 0, e = static_cast(CurAbbrevs.size());
326 i != e; ++i)
320327 CurAbbrevs[i]->dropRef();
321328
322329 BlockScope.back().PrevAbbrevs.swap(CurAbbrevs);
6969 while (!BlockInfoRecords.empty()) {
7070 BlockInfo &Info = BlockInfoRecords.back();
7171 // Free blockinfo abbrev info.
72 for (unsigned i = 0, e = Info.Abbrevs.size(); i != e; ++i)
72 for (unsigned i = 0, e = static_cast(Info.Abbrevs.size());
73 i != e; ++i)
7374 Info.Abbrevs[i]->dropRef();
7475 BlockInfoRecords.pop_back();
7576 }
166167 if (!BlockInfoRecords.empty() && BlockInfoRecords.back().BlockID == BlockID)
167168 return &BlockInfoRecords.back();
168169
169 for (unsigned i = 0, e = BlockInfoRecords.size(); i != e; ++i)
170 for (unsigned i = 0, e = static_cast(BlockInfoRecords.size());
171 i != e; ++i)
170172 if (BlockInfoRecords[i].BlockID == BlockID)
171173 return &BlockInfoRecords[i];
172174 return 0;
180182 EmitVBR(CodeLen, bitc::CodeLenWidth);
181183 FlushToWord();
182184
183 unsigned BlockSizeWordLoc = Out.size();
185 unsigned BlockSizeWordLoc = static_cast(Out.size());
184186 unsigned OldCodeSize = CurCodeSize;
185187
186188 // Emit a placeholder, which will be replaced when the block is popped.
196198 // If there is a blockinfo for this BlockID, add all the predefined abbrevs
197199 // to the abbrev list.
198200 if (BlockInfo *Info = getBlockInfo(BlockID)) {
199 for (unsigned i = 0, e = Info->Abbrevs.size(); i != e; ++i) {
201 for (unsigned i = 0, e = static_cast(Info->Abbrevs.size());
202 i != e; ++i) {
200203 CurAbbrevs.push_back(Info->Abbrevs[i]);
201204 Info->Abbrevs[i]->addRef();
202205 }
207210 assert(!BlockScope.empty() && "Block scope imbalance!");
208211
209212 // Delete all abbrevs.
210 for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
213 for (unsigned i = 0, e = static_cast(CurAbbrevs.size());
214 i != e; ++i)
211215 CurAbbrevs[i]->dropRef();
212216
213217 const Block &B = BlockScope.back();
218222 FlushToWord();
219223
220224 // Compute the size of the block, in words, not counting the size field.
221 unsigned SizeInWords = Out.size()/4-B.StartSizeWord - 1;
225 unsigned SizeInWords= static_cast(Out.size())/4-B.StartSizeWord-1;
222226 unsigned ByteNo = B.StartSizeWord*4;
223227
224228 // Update the block size field in the header of this sub-block.
282286 Vals.insert(Vals.begin(), Code);
283287
284288 unsigned RecordIdx = 0;
285 for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) {
289 for (unsigned i = 0, e = static_cast(Abbv->getNumOperandInfos());
290 i != e; ++i) {
286291 const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i);
287292 if (Op.isLiteral() || Op.getEncoding() != BitCodeAbbrevOp::Array) {
288293 assert(RecordIdx < Vals.size() && "Invalid abbrev/record");
294299 const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i);
295300
296301 // Emit a vbr6 to indicate the number of elements present.
297 EmitVBR(Vals.size()-RecordIdx, 6);
302 EmitVBR(static_cast(Vals.size()-RecordIdx), 6);
298303
299304 // Emit each field.
300305 for (; RecordIdx != Vals.size(); ++RecordIdx)
307312 // form.
308313 EmitCode(bitc::UNABBREV_RECORD);
309314 EmitVBR(Code, 6);
310 EmitVBR(Vals.size(), 6);
311 for (unsigned i = 0, e = Vals.size(); i != e; ++i)
315 EmitVBR(static_cast(Vals.size()), 6);
316 for (unsigned i = 0, e = static_cast(Vals.size()); i != e; ++i)
312317 EmitVBR64(Vals[i], 6);
313318 }
314319 }
322327 void EncodeAbbrev(BitCodeAbbrev *Abbv) {
323328 EmitCode(bitc::DEFINE_ABBREV);
324329 EmitVBR(Abbv->getNumOperandInfos(), 5);
325 for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) {
330 for (unsigned i = 0, e = static_cast(Abbv->getNumOperandInfos());
331 i != e; ++i) {
326332 const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i);
327333 Emit(Op.isLiteral(), 1);
328334 if (Op.isLiteral()) {
342348 // Emit the abbreviation as a record.
343349 EncodeAbbrev(Abbv);
344350 CurAbbrevs.push_back(Abbv);
345 return CurAbbrevs.size()-1+bitc::FIRST_APPLICATION_ABBREV;
351 return static_cast(CurAbbrevs.size())-1 +
352 bitc::FIRST_APPLICATION_ABBREV;
346353 }
347354
348355 //===--------------------------------------------------------------------===//
142142
143143 bool containsOneValue() const { return valnos.size() == 1; }
144144
145 unsigned getNumValNums() const { return valnos.size(); }
145 unsigned getNumValNums() const { return (unsigned)valnos.size(); }
146146
147147 /// getValNumInfo - Returns pointer to the specified val#.
148148 ///
167167 VNInfo *getNextValue(unsigned MIIdx, MachineInstr *CopyMI,
168168 BumpPtrAllocator &VNInfoAllocator) {
169169 #ifdef __GNUC__
170 unsigned Alignment = __alignof__(VNInfo);
170 unsigned Alignment = (unsigned)__alignof__(VNInfo);
171171 #else
172172 // FIXME: ugly.
173173 unsigned Alignment = 8;
174174 #endif
175 VNInfo *VNI= static_cast(VNInfoAllocator.Allocate(sizeof(VNInfo),
176 Alignment));
177 new (VNI) VNInfo(valnos.size(), MIIdx, CopyMI);
175 VNInfo *VNI =
176 static_cast(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo),
177 Alignment));
178 new (VNI) VNInfo((unsigned)valnos.size(), MIIdx, CopyMI);
178179 valnos.push_back(VNI);
179180 return VNI;
180181 }
195196 /// addKills - Add a number of kills into the VNInfo kill vector. If this
196197 /// interval is live at a kill point, then the kill is not added.
197198 void addKills(VNInfo *VNI, const SmallVector &kills) {
198 for (unsigned i = 0, e = kills.size(); i != e; ++i) {
199 for (unsigned i = 0, e = static_cast(kills.size());
200 i != e; ++i) {
199201 unsigned KillIdx = kills[i];
200202 if (!liveBeforeAndAt(KillIdx)) {
201203 SmallVector::iterator
130130 const_iterator end() const { return r2iMap_.end(); }
131131 iterator begin() { return r2iMap_.begin(); }
132132 iterator end() { return r2iMap_.end(); }
133 unsigned getNumIntervals() const { return r2iMap_.size(); }
133 unsigned getNumIntervals() const { return (unsigned)r2iMap_.size(); }
134134
135135 LiveInterval &getInterval(unsigned reg) {
136136 Reg2IntervalMap::iterator I = r2iMap_.find(reg);
107107 typedef std::reverse_iterator const_reverse_iterator;
108108 typedef std::reverse_iterator reverse_iterator;
109109
110 unsigned size() const { return Insts.size(); }
110 unsigned size() const { return (unsigned)Insts.size(); }
111111 bool empty() const { return Insts.empty(); }
112112
113113 MachineInstr& front() { return Insts.front(); }
148148 { return Predecessors.rend(); }
149149 const_pred_reverse_iterator pred_rend() const
150150 { return Predecessors.rend(); }
151 unsigned pred_size() const { return Predecessors.size(); }
151 unsigned pred_size() const {
152 return (unsigned)Predecessors.size();
153 }
152154 bool pred_empty() const { return Predecessors.empty(); }
153155 succ_iterator succ_begin() { return Successors.begin(); }
154156 const_succ_iterator succ_begin() const { return Successors.begin(); }
162164 { return Successors.rend(); }
163165 const_succ_reverse_iterator succ_rend() const
164166 { return Successors.rend(); }
165 unsigned succ_size() const { return Successors.size(); }
167 unsigned succ_size() const {
168 return (unsigned)Successors.size();
169 }
166170 bool succ_empty() const { return Successors.empty(); }
167171
168172 // LiveIn management methods.
167167 /// emitString - This callback is invoked when a String needs to be
168168 /// written to the output stream.
169169 void emitString(const std::string &String) {
170 for (unsigned i = 0, N = String.size(); i < N; ++i) {
170 for (unsigned i = 0, N = static_cast(String.size());
171 i < N; ++i) {
171172 unsigned char C = String[i];
172173 emitByte(C);
173174 }
192192
193193 /// getObjectIndexEnd - Return one past the maximum frame object index...
194194 ///
195 int getObjectIndexEnd() const { return Objects.size()-NumFixedObjects; }
195 int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; }
196196
197197 /// getObjectSize - Return the size of the specified object
198198 ///
310310 int CreateStackObject(uint64_t Size, unsigned Alignment) {
311311 assert(Size != 0 && "Cannot allocate zero size stack objects!");
312312 Objects.push_back(StackObject(Size, Alignment, -1));
313 return Objects.size()-NumFixedObjects-1;
313 return (int)Objects.size()-NumFixedObjects-1;
314314 }
315315
316316 /// RemoveStackObject - Remove or mark dead a statically sized stack object.
332332 int CreateVariableSizedObject() {
333333 HasVarSizedObjects = true;
334334 Objects.push_back(StackObject(0, 1, -1));
335 return Objects.size()-NumFixedObjects-1;
335 return (int)Objects.size()-NumFixedObjects-1;
336336 }
337337
338338 /// getCalleeSavedInfo - Returns a reference to call saved info vector for the
164164
165165 /// getNumBlockIDs - Return the number of MBB ID's allocated.
166166 ///
167 unsigned getNumBlockIDs() const { return MBBNumbering.size(); }
167 unsigned getNumBlockIDs() const { return (unsigned)MBBNumbering.size(); }
168168
169169 /// RenumberBlocks - This discards all of the MachineBasicBlock numbers and
170170 /// recomputes them. This guarantees that the MBB numbers are sequential,
237237 reverse_iterator rend () { return BasicBlocks.rend(); }
238238 const_reverse_iterator rend () const { return BasicBlocks.rend(); }
239239
240 unsigned size() const { return BasicBlocks.size(); }
240 unsigned size() const { return (unsigned)BasicBlocks.size();}
241241 bool empty() const { return BasicBlocks.empty(); }
242242 const MachineBasicBlock &front() const { return BasicBlocks.front(); }
243243 MachineBasicBlock &front() { return BasicBlocks.front(); }
253253 ///
254254 unsigned addToMBBNumbering(MachineBasicBlock *MBB) {
255255 MBBNumbering.push_back(MBB);
256 return MBBNumbering.size()-1;
256 return (unsigned)MBBNumbering.size()-1;
257257 }
258258
259259 /// removeFromMBBNumbering - Remove the specific machine basic block from our
8181
8282 /// Access to explicit operands of the instruction.
8383 ///
84 unsigned getNumOperands() const { return Operands.size(); }
84 unsigned getNumOperands() const { return (unsigned)Operands.size(); }
8585
8686 const MachineOperand& getOperand(unsigned i) const {
8787 assert(i < getNumOperands() && "getOperand() out of range!");
9797 unsigned getNumExplicitOperands() const;
9898
9999 /// Access to memory operands of the instruction
100 unsigned getNumMemOperands() const { return MemOperands.size(); }
100 unsigned getNumMemOperands() const { return (unsigned)MemOperands.size(); }
101101
102102 const MachineMemOperand& getMemOperand(unsigned i) const {
103103 assert(i < getNumMemOperands() && "getMemOperand() out of range!");
6969 bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New) {
7070 assert(Old != New && "Not making a change?");
7171 bool MadeChange = false;
72 for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) {
72 for (size_t i = 0, e = JumpTables.size(); i != e; ++i) {
7373 MachineJumpTableEntry &JTE = JumpTables[i];
74 for (unsigned j = 0, e = JTE.MBBs.size(); j != e; ++j)
74 for (size_t j = 0, e = JTE.MBBs.size(); j != e; ++j)
7575 if (JTE.MBBs[j] == Old) {
7676 JTE.MBBs[j] = New;
7777 MadeChange = true;
10991099 /// NextLabelID - Return the next unique label id.
11001100 ///
11011101 unsigned NextLabelID() {
1102 unsigned ID = LabelIDList.size() + 1;
1102 unsigned ID = (unsigned)LabelIDList.size() + 1;
11031103 LabelIDList.push_back(ID);
11041104 return ID;
11051105 }
151151 /// getLastVirtReg - Return the highest currently assigned virtual register.
152152 ///
153153 unsigned getLastVirtReg() const {
154 return VRegInfo.size()+TargetRegisterInfo::FirstVirtualRegister-1;
154 return (unsigned)VRegInfo.size()+TargetRegisterInfo::FirstVirtualRegister-1;
155155 }
156156
157157
142142 /// not already. This returns true if this is a new pred.
143143 bool addPred(SUnit *N, bool isCtrl, bool isSpecial,
144144 unsigned PhyReg = 0, int Cost = 1) {
145 for (unsigned i = 0, e = Preds.size(); i != e; ++i)
145 for (unsigned i = 0, e = (unsigned)Preds.size(); i != e; ++i)
146146 if (Preds[i].Dep == N &&
147147 Preds[i].isCtrl == isCtrl && Preds[i].isSpecial == isSpecial)
148148 return false;
188188 }
189189
190190 bool isPred(SUnit *N) {
191 for (unsigned i = 0, e = Preds.size(); i != e; ++i)
191 for (unsigned i = 0, e = (unsigned)Preds.size(); i != e; ++i)
192192 if (Preds[i].Dep == N)
193193 return true;
194194 return false;
195195 }
196196
197197 bool isSucc(SUnit *N) {
198 for (unsigned i = 0, e = Succs.size(); i != e; ++i)
198 for (unsigned i = 0, e = (unsigned)Succs.size(); i != e; ++i)
199199 if (Succs[i].Dep == N)
200200 return true;
201201 return false;
292292 /// NewSUnit - Creates a new SUnit and return a ptr to it.
293293 ///
294294 SUnit *NewSUnit(SDNode *N) {
295 SUnits.push_back(SUnit(N, SUnits.size()));
295 SUnits.push_back(SUnit(N, (unsigned)SUnits.size()));
296296 return &SUnits.back();
297297 }
298298
451451
452452 static SUnitIterator begin(SUnit *N) { return SUnitIterator(N, 0); }
453453 static SUnitIterator end (SUnit *N) {
454 return SUnitIterator(N, N->Preds.size());
454 return SUnitIterator(N, (unsigned)N->Preds.size());
455455 }
456456
457457 unsigned getOperand() const { return Operand; }
162162 return getVTList(VT1, VT2, VT3).VTs;
163163 }
164164 const MVT::ValueType *getNodeValueTypes(std::vector &VTList) {
165 return getVTList(&VTList[0], VTList.size()).VTs;
165 return getVTList(&VTList[0], (unsigned)VTList.size()).VTs;
166166 }
167167
168168
286286 Ops.push_back(Op2);
287287 Ops.push_back(InFlag);
288288 return getNode(ISD::CALLSEQ_END, NodeTys, &Ops[0],
289 Ops.size() - (InFlag.Val == 0 ? 1 : 0));
289 (unsigned)Ops.size() - (InFlag.Val == 0 ? 1 : 0));
290290 }
291291
292292 /// getNode - Gets or creates the specified node.
971971
972972 SDOperandPtr(SDUse * use_ptr) {
973973 ptr = &use_ptr->getSDOperand();
974 object_size = sizeof(SDUse);
974 object_size = (int)sizeof(SDUse);
975975 }
976976
977977 SDOperandPtr(const SDOperand * op_ptr) {
978978 ptr = op_ptr;
979 object_size = sizeof(SDOperand);
979 object_size = (int)sizeof(SDOperand);
980980 }
981981
982982 const SDOperand operator *() { return *ptr; }
11061106 /// getOperandNum - Retrive a number of a current operand.
11071107 unsigned getOperandNum() const {
11081108 assert(Op && "Cannot dereference end iterator!");
1109 return (Op - Op->getUser()->OperandList);
1109 return (unsigned)(Op - Op->getUser()->OperandList);
11101110 }
11111111
11121112 /// Retrieve a reference to the current operand.
6666 void setProgramArguments(It I, It E) {
6767 ProgramArguments.assign(I, E);
6868 }
69 unsigned getNumProgramArguments() const { return ProgramArguments.size(); }
69 unsigned getNumProgramArguments() const {
70 return static_cast(ProgramArguments.size());
71 }
7072 const std::string &getProgramArgument(unsigned i) const {
7173 return ProgramArguments[i];
7274 }
7373 ///
7474 unsigned getNumLines() const {
7575 if (LineOffset.empty()) calculateLineOffsets();
76 return LineOffset.size();
76 return static_cast(LineOffset.size());
7777 }
7878
7979 private:
396396 // This argument ensures that we have an iterator we can
397397 // do arithmetic on in constant time
398398 std::random_access_iterator_tag) {
399 typename std::iterator_traits::difference_type NumIdx =
400 std::distance(IdxBegin, IdxEnd);
399 unsigned NumIdx = static_cast(std::distance(IdxBegin, IdxEnd));
401400
402401 if (NumIdx > 0) {
403402 // This requires that the itoerator points to contiguous memory.
429428 // have an iterator we can do
430429 // arithmetic on in constant time
431430 std::random_access_iterator_tag) {
432 typename std::iterator_traits::difference_type NumIdx =
433 std::distance(IdxBegin, IdxEnd);
431 unsigned NumIdx = static_cast(std::distance(IdxBegin, IdxEnd));
434432
435433 if (NumIdx > 0) {
436434 // This requires that the iterator points to contiguous memory.
960958 Instruction *InsertBefore = 0) {
961959 return new(1) CallInst(F, Name, InsertBefore);
962960 }
963 static CallInst *Create(Value *F, const std::string &Name, BasicBlock *InsertAtEnd) {
961 static CallInst *Create(Value *F, const std::string &Name,
962 BasicBlock *InsertAtEnd) {
964963 return new(1) CallInst(F, Name, InsertAtEnd);
965964 }
966965
123123 template
124124 static PAListPtr get(const Iter &I, const Iter &E) {
125125 if (I == E) return PAListPtr(); // Empty list.
126 return get(&*I, E-I);
126 return get(&*I, static_cast(E-I));
127127 }
128128
129129 /// addAttr - Add the specified attribute at the specified index to this
145145 public:
146146
147147 virtual unsigned getNumContainedManagers() {
148 return PassManagers.size();
148 return (unsigned)PassManagers.size();
149149 }
150150
151151 /// Schedule pass P for execution. Make sure that passes required by
305305 const std::vector &Set) const;
306306
307307 virtual unsigned getNumContainedPasses() {
308 return PassVector.size();
308 return (unsigned)PassVector.size();
309309 }
310310
311311 virtual PassManagerType getPassManagerType() const {
3333 /// compile-time constant (e.g., for template instantiation).
3434 template
3535 struct AlignOf {
36 enum { Alignment = sizeof(AlignmentCalcImpl) - sizeof(T) };
36 enum { Alignment =
37 static_cast(sizeof(AlignmentCalcImpl) - sizeof(T)) };
3738
3839 enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 };
3940 enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 };
2424 ~MallocAllocator() {}
2525
2626 void Reset() {}
27 void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); }
27 void *Allocate(size_t Size, size_t Alignment) { return malloc(Size); }
2828
2929 template
3030 void *Allocate() { return reinterpret_cast(malloc(sizeof(T))); }
4444 ~BumpPtrAllocator();
4545
4646 void Reset();
47 void *Allocate(unsigned Size, unsigned Alignment);
47 void *Allocate(size_t Size, size_t Alignment);
4848
4949 template
5050 void *Allocate() {
218218 Option *getNextRegisteredOption() const { return NextRegistered; }
219219
220220 // Return the width of the option tag for printing...
221 virtual unsigned getOptionWidth() const = 0;
221 virtual size_t getOptionWidth() const = 0;
222222
223223 // printOptionInfo - Print out information about this option. The
224224 // to-be-maintained width is specified.
225225 //
226 virtual void printOptionInfo(unsigned GlobalWidth) const = 0;
226 virtual void printOptionInfo(size_t GlobalWidth) const = 0;
227227
228228 virtual void getExtraOptionNames(std::vector &OptionNames) {}
229229
333333
334334 template
335335 void apply(Opt &O) const {
336 for (unsigned i = 0, e = Values.size(); i != e; ++i)
336 for (unsigned i = 0, e = static_cast(Values.size());
337 i != e; ++i)
337338 O.getParser().addLiteralOption(Values[i].first, Values[i].second.first,
338339 Values[i].second.second);
339340 }
377378 virtual const char *getDescription(unsigned N) const = 0;
378379
379380 // Return the width of the option tag for printing...
380 virtual unsigned getOptionWidth(const Option &O) const;
381 virtual size_t getOptionWidth(const Option &O) const;
381382
382383 // printOptionInfo - Print out information about this option. The
383384 // to-be-maintained width is specified.
384385 //
385 virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const;
386 virtual void printOptionInfo(const Option &O, size_t GlobalWidth) const;
386387
387388 void initialize(Option &O) {
388389 // All of the modifiers for the option have been processed by now, so the
458459 else
459460 ArgVal = ArgName;
460461
461 for (unsigned i = 0, e = Values.size(); i != e; ++i)
462 for (unsigned i = 0, e = static_cast(Values.size());
463 i != e; ++i)
462464 if (ArgVal == Values[i].first) {
463465 V = Values[i].second.first;
464466 return false;
501503 void initialize(Option &O) {}
502504
503505 // Return the width of the option tag for printing...
504 unsigned getOptionWidth(const Option &O) const;
506 size_t getOptionWidth(const Option &O) const;
505507
506508 // printOptionInfo - Print out information about this option. The
507509 // to-be-maintained width is specified.
508510 //
509 void printOptionInfo(const Option &O, unsigned GlobalWidth) const;
511 void printOptionInfo(const Option &O, size_t GlobalWidth) const;
510512
511513 // getValueName - Overload in subclass to provide a better default value.
512514 virtual const char *getValueName() const { return "value"; }
814816 }
815817
816818 // Forward printing stuff to the parser...
817 virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);}
818 virtual void printOptionInfo(unsigned GlobalWidth) const {
819 virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);}
820 virtual void printOptionInfo(size_t GlobalWidth) const {
819821 Parser.printOptionInfo(*this, GlobalWidth);
820822 }
821823
980982 }
981983
982984 // Forward printing stuff to the parser...
983 virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);}
984 virtual void printOptionInfo(unsigned GlobalWidth) const {
985 virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);}
986 virtual void printOptionInfo(size_t GlobalWidth) const {
985987 Parser.printOptionInfo(*this, GlobalWidth);
986988 }
987989
11661168 }
11671169
11681170 // Forward printing stuff to the parser...
1169 virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);}
1170 virtual void printOptionInfo(unsigned GlobalWidth) const {
1171 virtual size_t getOptionWidth() const {return Parser.getOptionWidth(*this);}
1172 virtual void printOptionInfo(size_t GlobalWidth) const {
11711173 Parser.printOptionInfo(*this, GlobalWidth);
11721174 }
11731175
12591261 return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg);
12601262 }
12611263 // Handle printing stuff...
1262 virtual unsigned getOptionWidth() const;
1263 virtual void printOptionInfo(unsigned GlobalWidth) const;
1264 virtual size_t getOptionWidth() const;
1265 virtual void printOptionInfo(size_t GlobalWidth) const;
12641266
12651267 void done() {
12661268 if (!hasArgStr())
174174 child_iterator TargetIt = DOTTraits::getEdgeTarget(Node, EI);
175175
176176 // Figure out which edge this targets...
177 unsigned Offset = std::distance(GTraits::child_begin(TargetNode),
178 TargetIt);
177 unsigned Offset =
178 (unsigned)std::distance(GTraits::child_begin(TargetNode), TargetIt);
179179 DestPort = static_cast(Offset);
180180 }
181181
3939
4040 const char *getBufferStart() const { return BufferStart; }
4141 const char *getBufferEnd() const { return BufferEnd; }
42 unsigned getBufferSize() const { return BufferEnd-BufferStart; }
42 size_t getBufferSize() const { return BufferEnd-BufferStart; }
4343
4444 /// getBufferIdentifier - Return an identifier for this buffer, typically the
4545 /// filename it was read from.
7070 /// is completely initialized to zeros. Note that the caller should
7171 /// initialize the memory allocated by this method. The memory is owned by
7272 /// the MemoryBuffer object.
73 static MemoryBuffer *getNewMemBuffer(unsigned Size,
73 static MemoryBuffer *getNewMemBuffer(size_t Size,
7474 const char *BufferName = "");
7575
7676 /// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size
7777 /// that is not initialized. Note that the caller should initialize the
7878 /// memory allocated by this method. The memory is owned by the MemoryBuffer
7979 /// object.
80 static MemoryBuffer *getNewUninitMemBuffer(unsigned Size,
80 static MemoryBuffer *getNewUninitMemBuffer(size_t Size,
8181 const char *BufferName = "");
8282
8383 /// getSTDIN - Read all of stdin into a file buffer, and return it. This
106106 outxword(X);
107107 }
108108 void outstring(const std::string &S, unsigned Length) {
109 unsigned len_to_copy = S.length() < Length ? S.length() : Length;
110 unsigned len_to_fill = S.length() < Length ? Length - S.length() : 0;
109 unsigned len_to_copy = static_cast(S.length()) < Length
110 ? static_cast(S.length()) : Length;
111 unsigned len_to_fill = static_cast(S.length()) < Length
112 ? Length - static_cast(S.length()) : 0;
111113
112114 for (unsigned i = 0; i < len_to_copy; ++i)
113115 outbyte(S[i]);
206206 /// @returns true if \p this and \p that refer to the same thing.
207207 /// @brief Equality Operator
208208 bool operator==(const Path &that) const {
209 return 0 == path.compare(that.path);
209 return path == that.path;
210210 }
211211
212212 /// Compares \p this Path with \p that Path for inequality.
213213 /// @returns true if \p this and \p that refer to different things.
214214 /// @brief Inequality Operator
215215 bool operator!=(const Path &that) const {
216 return 0 != path.compare(that.path);
216 return path != that.path;
217217 }
218218
219219 /// Determines if \p this Path is less than \p that Path. This is required
223223 /// @returns true if \p this path is lexicographically less than \p that.
224224 /// @brief Less Than Operator
225225 bool operator<(const Path& that) const {
226 return 0 > path.compare(that.path);
226 return path < that.path;
227227 }
228228
229229 /// @}
287287 const char *c_str() const { return path.c_str(); }
288288
289289 /// size - Return the length in bytes of this path name.
290 unsigned size() const { return path.size(); }
290 size_t size() const { return path.size(); }
291291
292292 /// empty - Returns true if the path is empty.
293293 unsigned empty() const { return path.empty(); }
9898
9999 /// getNumRegs - Return the number of registers in this class.
100100 ///
101 unsigned getNumRegs() const { return RegsEnd-RegsBegin; }
101 unsigned getNumRegs() const { return (unsigned)(RegsEnd-RegsBegin); }
102102
103103 /// getRegister - Return the specified register in the class.
104104 ///
464464 regclass_iterator regclass_end() const { return RegClassEnd; }
465465
466466 unsigned getNumRegClasses() const {
467 return regclass_end()-regclass_begin();
467 return (unsigned)(regclass_end()-regclass_begin());
468468 }
469469
470470 /// getRegClass - Returns the register class associated with the enumeration
3838 ///
3939 unsigned NumOperands;
4040
41 void *operator new(size_t s, unsigned) {
41 void *operator new(size_t s, size_t) {
4242 return ::operator new(s);
4343 }
4444 User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps)
4444
4545 /// Allocate - Allocate and return at least the specified number of bytes.
4646 ///
47 void *Allocate(unsigned AllocSize, unsigned Alignment, MemRegion **RegPtr) {
47 void *Allocate(size_t AllocSize, size_t Alignment, MemRegion **RegPtr) {
4848
4949 char* Result = (char*) (((uintptr_t) (NextPtr+Alignment-1))
5050 & ~((uintptr_t) Alignment-1));
112112 TheMemory = MRP;
113113 }
114114
115 void *BumpPtrAllocator::Allocate(unsigned Size, unsigned Align) {
115 void *BumpPtrAllocator::Allocate(size_t Size, size_t Align) {
116116 MemRegion *MRP = (MemRegion*)TheMemory;
117117 void *Ptr = MRP->Allocate(Size, Align, &MRP);
118118 TheMemory = MRP;
114114 OptionNames.push_back(O->ArgStr);
115115
116116 // Handle named options.
117 for (unsigned i = 0, e = OptionNames.size(); i != e; ++i) {
117 for (size_t i = 0, e = OptionNames.size(); i != e; ++i) {
118118 // Add argument to the argument map!
119119 if (!OptionsMap.insert(std::pair(OptionNames[i],
120120 O)).second) {
222222 // see if there options that satisfy the predicate. If we find one, return it,
223223 // otherwise return null.
224224 //
225 static Option *getOptionPred(std::string Name, unsigned &Length,
225 static Option *getOptionPred(std::string Name, size_t &Length,
226226 bool (*Pred)(const Option*),
227227 std::map &OptionsMap) {
228228
328328 // Parse the value of the environment variable into a "command line"
329329 // and hand it off to ParseCommandLineOptions().
330330 ParseCStringVector(newArgv, envValue);
331 int newArgc = newArgv.size();
331 int newArgc = static_cast(newArgv.size());
332332 ParseCommandLineOptions(newArgc, &newArgv[0], Overview, ReadResponseFiles);
333333
334334 // Free all the strdup()ed strings.
390390 newArgv.push_back(strdup(argv[0]));
391391 ExpandResponseFiles(argc, argv, newArgv);
392392 argv = &newArgv[0];
393 argc = newArgv.size();
393 argc = static_cast(newArgv.size());
394394 }
395395
396396 sys::Path progname(argv[0]);
419419
420420 // Calculate how many positional values are _required_.
421421 bool UnboundedFound = false;
422 for (unsigned i = ConsumeAfterOpt != 0, e = PositionalOpts.size();
422 for (size_t i = ConsumeAfterOpt != 0, e = PositionalOpts.size();
423423 i != e; ++i) {
424424 Option *Opt = PositionalOpts[i];
425425 if (RequiresValue(Opt))
524524 if (Handler == 0) {
525525 std::string RealName(ArgName);
526526 if (RealName.size() > 1) {
527 unsigned Length = 0;
527 size_t Length = 0;
528528 Option *PGOpt = getOptionPred(RealName, Length, isPrefixedOrGrouping,
529529 Opts);
530530
626626
627627 } else if (ConsumeAfterOpt == 0) {
628628 // Positional args have already been handled if ConsumeAfter is specified...
629 unsigned ValNo = 0, NumVals = PositionalVals.size();
630 for (unsigned i = 0, e = PositionalOpts.size(); i != e; ++i) {
629 unsigned ValNo = 0, NumVals = static_cast(PositionalVals.size());
630 for (size_t i = 0, e = PositionalOpts.size(); i != e; ++i) {
631631 if (RequiresValue(PositionalOpts[i])) {
632632 ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo].first,
633633 PositionalVals[ValNo].second);
661661 } else {
662662 assert(ConsumeAfterOpt && NumPositionalRequired <= PositionalVals.size());
663663 unsigned ValNo = 0;
664 for (unsigned j = 1, e = PositionalOpts.size(); j != e; ++j)
664 for (size_t j = 1, e = PositionalOpts.size(); j != e; ++j)
665665 if (RequiresValue(PositionalOpts[j])) {
666666 ErrorParsing |= ProvidePositionalOption(PositionalOpts[j],
667667 PositionalVals[ValNo].first,
774774 //
775775
776776 // Return the width of the option tag for printing...
777 unsigned alias::getOptionWidth() const {
777 size_t alias::getOptionWidth() const {
778778 return std::strlen(ArgStr)+6;
779779 }
780780
781781 // Print out the option for the alias.
782 void alias::printOptionInfo(unsigned GlobalWidth) const {
783 unsigned L = std::strlen(ArgStr);
782 void alias::printOptionInfo(size_t GlobalWidth) const {
783 size_t L = std::strlen(ArgStr);
784784 cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - "
785785 << HelpStr << "\n";
786786 }
795795 //
796796
797797 // Return the width of the option tag for printing...
798 unsigned basic_parser_impl::getOptionWidth(const Option &O) const {
799 unsigned Len = std::strlen(O.ArgStr);
798 size_t basic_parser_impl::getOptionWidth(const Option &O) const {
799 size_t Len = std::strlen(O.ArgStr);
800800 if (const char *ValName = getValueName())
801801 Len += std::strlen(getValueStr(O, ValName))+3;
802802
807807 // to-be-maintained width is specified.
808808 //
809809 void basic_parser_impl::printOptionInfo(const Option &O,
810 unsigned GlobalWidth) const {
810 size_t GlobalWidth) const {
811811 cout << " -" << O.ArgStr;
812812
813813 if (const char *ValName = getValueName())
925925
926926
927927 // Return the width of the option tag for printing...
928 unsigned generic_parser_base::getOptionWidth(const Option &O) const {
928 size_t generic_parser_base::getOptionWidth(const Option &O) const {
929929 if (O.hasArgStr()) {
930 unsigned Size = std::strlen(O.ArgStr)+6;
930 size_t Size = std::strlen(O.ArgStr)+6;
931931 for (unsigned i = 0, e = getNumOptions(); i != e; ++i)
932 Size = std::max(Size, (unsigned)std::strlen(getOption(i))+8);
932 Size = std::max(Size, std::strlen(getOption(i))+8);
933933 return Size;
934934 } else {
935 unsigned BaseSize = 0;
935 size_t BaseSize = 0;
936936 for (unsigned i = 0, e = getNumOptions(); i != e; ++i)
937 BaseSize = std::max(BaseSize, (unsigned)std::strlen(getOption(i))+8);
937 BaseSize = std::max(BaseSize, std::strlen(getOption(i))+8);
938938 return BaseSize;
939939 }
940940 }
943943 // to-be-maintained width is specified.
944944 //
945945 void generic_parser_base::printOptionInfo(const Option &O,
946 unsigned GlobalWidth) const {
946 size_t GlobalWidth) const {
947947 if (O.hasArgStr()) {
948 unsigned L = std::strlen(O.ArgStr);
948 size_t L = std::strlen(O.ArgStr);
949949 cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ')
950950 << " - " << O.HelpStr << "\n";
951951
952952 for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
953 unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8;
953 size_t NumSpaces = GlobalWidth-strlen(getOption(i))-8;
954954 cout << " =" << getOption(i) << std::string(NumSpaces, ' ')
955955 << " - " << getDescription(i) << "\n";
956956 }
958958 if (O.HelpStr[0])
959959 cout << " " << O.HelpStr << "\n";
960960 for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
961 unsigned L = std::strlen(getOption(i));
961 size_t L = std::strlen(getOption(i));
962962 cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ')
963963 << " - " << getDescription(i) << "\n";
964964 }
973973 namespace {
974974
975975 class HelpPrinter {
976 unsigned MaxArgLen;
976 size_t MaxArgLen;
977977 const Option *EmptyArg;
978978 const bool ShowHidden;
979979
10291029 PositionalOpts[0]->getNumOccurrencesFlag() == ConsumeAfter)
10301030 CAOpt = PositionalOpts[0];
10311031
1032 for (unsigned i = CAOpt != 0, e = PositionalOpts.size(); i != e; ++i) {
1032 for (size_t i = CAOpt != 0, e = PositionalOpts.size(); i != e; ++i) {
10331033 if (PositionalOpts[i]->ArgStr[0])
10341034 cout << " --" << PositionalOpts[i]->ArgStr;
10351035 cout << " " << PositionalOpts[i]->HelpStr;
10421042
10431043 // Compute the maximum argument length...
10441044 MaxArgLen = 0;
1045 for (unsigned i = 0, e = Opts.size(); i != e; ++i)
1045 for (size_t i = 0, e = Opts.size(); i != e; ++i)
10461046 MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth());
10471047
10481048 cout << "OPTIONS:\n";
1049 for (unsigned i = 0, e = Opts.size(); i != e; ++i)
1049 for (size_t i = 0, e = Opts.size(); i != e; ++i)
10501050 Opts[i].second->printOptionInfo(MaxArgLen);
10511051
10521052 // Print any extra help the user has declared.
9797 if (*F1NumEnd == 'D' || *F1NumEnd == 'd') {
9898 // Copy string into tmp buffer to replace the 'D' with an 'e'.
9999 SmallString<200> StrTmp(F1P, EndOfNumber(F1NumEnd)+1);
100 StrTmp[F1NumEnd-F1P] = 'e'; // Strange exponential notation!
100 // Strange exponential notation!
101 StrTmp[static_cast(F1NumEnd-F1P)] = 'e';
101102
102103 V1 = strtod(&StrTmp[0], const_cast(&F1NumEnd));
103104 F1NumEnd = F1P + (F1NumEnd-&StrTmp[0]);
106107 if (*F2NumEnd == 'D' || *F2NumEnd == 'd') {
107108 // Copy string into tmp buffer to replace the 'D' with an 'e'.
108109 SmallString<200> StrTmp(F2P, EndOfNumber(F2NumEnd)+1);
109 StrTmp[F2NumEnd-F2P] = 'e'; // Strange exponential notation!
110 // Strange exponential notation!
111 StrTmp[static_cast(F2NumEnd-F2P)] = 'e';
110112
111113 V2 = strtod(&StrTmp[0], const_cast(&F2NumEnd));
112114 F2NumEnd = F2P + (F2NumEnd-&StrTmp[0]);
5757 AddInteger(DoubleToBits(D));
5858 }
5959 void FoldingSetNodeID::AddString(const std::string &String) {
60 unsigned Size = String.size();
60 unsigned Size = static_cast(String.size());
6161 Bits.push_back(Size);
6262 if (!Size) return;
6363
9797 /// lookup the node in the FoldingSetImpl.
9898 unsigned FoldingSetNodeID::ComputeHash() const {
9999 // This is adapted from SuperFastHash by Paul Hsieh.
100 unsigned Hash = Bits.size();
100 unsigned Hash = static_cast(Bits.size());
101101 for (const unsigned *BP = &Bits[0], *E = BP+Bits.size(); BP != E; ++BP) {
102102 unsigned Data = *BP;
103103 Hash += Data & 0xFFFF;
105105 /// that is completely initialized to zeros. Note that the caller should
106106 /// initialize the memory allocated by this method. The memory is owned by
107107 /// the MemoryBuffer object.
108 MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(unsigned Size,
108 MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(size_t Size,
109109 const char *BufferName) {
110110 char *Buf = new char[Size+1];
111111 Buf[Size] = 0;
119119 /// is completely initialized to zeros. Note that the caller should
120120 /// initialize the memory allocated by this method. The memory is owned by
121121 /// the MemoryBuffer object.
122 MemoryBuffer *MemoryBuffer::getNewMemBuffer(unsigned Size,
122 MemoryBuffer *MemoryBuffer::getNewMemBuffer(size_t Size,
123123 const char *BufferName) {
124124 MemoryBuffer *SB = getNewUninitMemBuffer(Size, BufferName);
125125 memset(const_cast(SB->getBufferStart()), 0, Size+1);
213213 SB.reset(MemoryBuffer::getNewUninitMemBuffer(FileSize, Filename));
214214 char *BufPtr = const_cast(SB->getBufferStart());
215215
216 unsigned BytesLeft = FileSize;
216 size_t BytesLeft = FileSize;
217217 while (BytesLeft) {
218218 ssize_t NumRead = ::read(FD, BufPtr, BytesLeft);
219219 if (NumRead != -1) {
8989
9090 // Figure out how long the biggest Value and Name fields are.
9191 unsigned MaxNameLen = 0, MaxValLen = 0;
92 for (unsigned i = 0, e = Stats.size(); i != e; ++i) {
92 for (size_t i = 0, e = Stats.size(); i != e; ++i) {
9393 MaxValLen = std::max(MaxValLen,
9494 (unsigned)utostr(Stats[i]->getValue()).size());
9595 MaxNameLen = std::max(MaxNameLen,
105105 << "===" << std::string(73, '-') << "===\n\n";
106106
107107 // Print all of the statistics.
108 for (unsigned i = 0, e = Stats.size(); i != e; ++i) {
108 for (size_t i = 0, e = Stats.size(); i != e; ++i) {
109109 std::string CountStr = utostr(Stats[i]->getValue());
110110 OutStream << std::string(MaxValLen-CountStr.size(), ' ')
111111 << CountStr << " " << Stats[i]->getName()
2121 /// The Source source string is updated in place to remove the returned string
2222 /// and any delimiter prefix from it.
2323 std::string llvm::getToken(std::string &Source, const char *Delimiters) {
24 unsigned NumDelimiters = std::strlen(Delimiters);
24 size_t NumDelimiters = std::strlen(Delimiters);
2525
2626 // Figure out where the token starts.
2727 std::string::size_type Start =
123123 if (canRead()) {
124124 std::string Magic;
125125 if (getMagicNumber(Magic, 64))
126 switch (IdentifyFileType(Magic.c_str(), Magic.length())) {
126 switch (IdentifyFileType(Magic.c_str(),
127 static_cast(Magic.length()))) {
127128 default: return false;
128129 case Mach_O_FixedVirtualMemorySharedLib_FileType:
129130 case Mach_O_DynamicallyLinkedSharedLib_FileType:
166167
167168 bool Path::hasMagicNumber(const std::string &Magic) const {
168169 std::string actualMagic;
169 if (getMagicNumber(actualMagic, Magic.size()))
170 if (getMagicNumber(actualMagic, static_cast(Magic.size())))
170171 return Magic == actualMagic;
171172 return false;
172173 }
203204 // If the path is all slashes, return a single slash.
204205 // Otherwise, remove all trailing slashes.
205206
206 signed pos = path.size() - 1;
207 signed pos = static_cast(path.size()) - 1;
207208
208209 while (pos >= 0 && path[pos] == Sep)
209210 --pos;
2727 std::string *ErrMsg) {
2828 if (NumBytes == 0) return MemoryBlock();
2929
30 long pageSize = Process::GetPageSize();
30 unsigned pageSize = Process::GetPageSize();
3131 unsigned NumPages = (NumBytes+pageSize-1)/pageSize;
3232
3333 int fd = -1;
565565 path.copy(pathname,MAXPATHLEN);
566566
567567 // Null-terminate the last component
568 int lastchar = path.length() - 1 ;
568 size_t lastchar = path.length() - 1 ;
569569
570570 if (pathname[lastchar] != '/')
571571 ++lastchar;
638638 // Otherwise, try to just remove the one directory.
639639 char pathname[MAXPATHLEN];
640640 path.copy(pathname, MAXPATHLEN);
641 int lastchar = path.length() - 1 ;
641 size_t lastchar = path.length() - 1;
642642 if (pathname[lastchar] == '/')
643643 pathname[lastchar] = 0;
644644 else
5757 return Path();
5858
5959 // Now we have a colon separated list of directories to search; try them.
60 unsigned PathLen = strlen(PathStr);
60 size_t PathLen = strlen(PathStr);
6161 while (PathLen) {
6262 // Find the first colon...
6363 const char *Colon = std::find(PathStr, PathStr+PathLen, ':');
6464 static void PrintStackTrace() {
6565 #ifdef HAVE_BACKTRACE
6666 // Use backtrace() to output a backtrace on Linux systems with glibc.
67 int depth = backtrace(StackTrace, array_lengthof(StackTrace));
67 int depth = backtrace(StackTrace,
68 static_cast(array_lengthof(StackTrace)));
6869 backtrace_symbols_fd(StackTrace, depth, STDERR_FILENO);
6970 #endif
7071 }