Fix more -Wshorten-64-to-32 warnings.
authorEvan Cheng <evan.cheng@apple.com>
Mon, 5 May 2008 18:30:58 +0000 (18:30 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Mon, 5 May 2008 18:30:58 +0000 (18:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50659 91177308-0d34-0410-b5e6-96231b3b80d8

55 files changed:
include/llvm/ADT/BitVector.h
include/llvm/ADT/SmallPtrSet.h
include/llvm/ADT/SmallVector.h
include/llvm/ADT/StringExtras.h
include/llvm/ADT/StringMap.h
include/llvm/ADT/UniqueVector.h
include/llvm/Analysis/AliasSetTracker.h
include/llvm/Analysis/CallGraph.h
include/llvm/Analysis/DominatorInternals.h
include/llvm/Analysis/Dominators.h
include/llvm/Analysis/LoopInfo.h
include/llvm/Analysis/ScalarEvolutionExpressions.h
include/llvm/Bitcode/Archive.h
include/llvm/Bitcode/BitCodes.h
include/llvm/Bitcode/BitstreamReader.h
include/llvm/Bitcode/BitstreamWriter.h
include/llvm/CodeGen/LiveInterval.h
include/llvm/CodeGen/LiveIntervalAnalysis.h
include/llvm/CodeGen/MachineBasicBlock.h
include/llvm/CodeGen/MachineCodeEmitter.h
include/llvm/CodeGen/MachineFrameInfo.h
include/llvm/CodeGen/MachineFunction.h
include/llvm/CodeGen/MachineInstr.h
include/llvm/CodeGen/MachineJumpTableInfo.h
include/llvm/CodeGen/MachineModuleInfo.h
include/llvm/CodeGen/MachineRegisterInfo.h
include/llvm/CodeGen/ScheduleDAG.h
include/llvm/CodeGen/SelectionDAG.h
include/llvm/CodeGen/SelectionDAGNodes.h
include/llvm/Debugger/Debugger.h
include/llvm/Debugger/SourceFile.h
include/llvm/Instructions.h
include/llvm/ParameterAttributes.h
include/llvm/PassManagers.h
include/llvm/Support/AlignOf.h
include/llvm/Support/Allocator.h
include/llvm/Support/CommandLine.h
include/llvm/Support/GraphWriter.h
include/llvm/Support/MemoryBuffer.h
include/llvm/Support/OutputBuffer.h
include/llvm/System/Path.h
include/llvm/Target/TargetRegisterInfo.h
include/llvm/User.h
lib/Support/Allocator.cpp
lib/Support/CommandLine.cpp
lib/Support/FileUtilities.cpp
lib/Support/FoldingSet.cpp
lib/Support/MemoryBuffer.cpp
lib/Support/Statistic.cpp
lib/Support/StringExtras.cpp
lib/System/Path.cpp
lib/System/Unix/Memory.inc
lib/System/Unix/Path.inc
lib/System/Unix/Program.inc
lib/System/Unix/Signals.inc

index a3a8920186468ebf5f48044752fa0dde6ad4d4bd..fccb1c6e8abac0d921f009dce82ed5b204dba35f 100644 (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
index 8b85a67afb78220869f23a5238fd650c6362a4ec..f73a4a9bc4ca1eba06476fd11478cb0af50bef9a 100644 (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();
index 6d279725ad709a2fe9a4f9593c92df868e3d9e4a..2da6a788ebac9a26a5e04bbda0ecfe649d5e9733 100644 (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:  
index e4c941007d82d0f2b843b116228191d169bc6513..3bfd3f5c72721c875d647fbdaba073d2dae94259 100644 (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;
   }
index 27ea5d3ea1b34bbaafab8e9d6db7afc841ce5e88..869a87fdced331b0be84ea6b353dfe211cd46f48 100644 (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; }
index 76e8e0b72a6d3eb3c37aaf530cb9cac8f8270991..b114b8231efa219542791c0bdef5ec8038802235 100644 (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);
index a4367c43734ac0e8a0e69ee0fae0108cca5c7ddb..70c25b0680b5dd5c4a555f2cb45e7dab73a41131 100644 (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();
index 2bb06900abad0d90ca5a97793e4ba588e00cb334..88449ab2580f2e08cd2502b586ca7027d5dd61e5 100644 (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...
   //
index 063602e92f297953a9a9b7fc35f65450c24feef7..1564774adaeccda2ad4760a9f2a47d6b552dff5f 100644 (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 
index ad1766c85ab1c204f3ae1f55871844655a55fd5e..6ce3260b8f5294bd000afd6f94aab0d7fdee128d 100644 (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++;
index fdb722c225b71350c296dda74093cbec2690936d..0243a00df5523530d5891337c95d042a7958caf1 100644 (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;
index 39b083d5fac3fa22b07f0801c77c24d479c9a8b4..e077cfe2a0ff2113f611b6e7fe198fe688540bd3 100644 (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; }
index 1dcbe3abe27e18d6fd555f08bbaa39c679429d53..50562e490ff97f19aeacaf7e93d27acd4617a904 100644 (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();  }
index 94e3a6615cf8ffdb7c07a780aa8f8d8b7f0ea48b..f140cc3b19d912ac77e1037e3e7d611e8e5b9f70 100644 (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];
   }
index 456f1ce5a120c5c2cb9cd72c634d5671c7c9e62f..3b7a9b61e6aaab5d8a14ae85cb9e20e08b2f83ad 100644 (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);
index 70acc019c545a659f0bac99ae66c2478e081de37..3b7e40541472dce65a9e587f35a61db8c6591ef3 100644 (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;
   }
   
   //===--------------------------------------------------------------------===//
index 3fb0c1dc4e82ca6abbd79fbf52347ac01039d9ec..31d6947a76c826048e4c1b51f33408f60cbc24af 100644 (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
index 7bd4ea4a19b04aaba1f2870539e347e09c5d6801..c6b5cfaebc443aa6b77f0802023f6844ea4b5905 100644 (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);
index 4ce695c1f3bb0b1fdbb4953bd4564c2d89575e44..0b3173c5b1d34c04ff8789314387e3ed6ecffc7f 100644 (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.
index 6bf72de0ff292992647ee2917cba94896647cec4..e38eb061baa66dbb48e61f70d5b5d5cd67bcbd2f 100644 (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);
     }
index 4cc9073435649016f464ca7fbab1752474416add..592c17f56b511ec1322ed27f877fc41356b1f060 100644 (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
index 46d14e148462e9cfc78fccd51316fefe1fe0089d..97027da7d67999c1d21da82b16016c8cc1a592e2 100644 (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
index 5dfe14cb623382577299301950ad3e1cf6d1a514..ff64e7e2e693aceb1d996cad5236511823d6a10a 100644 (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!");
index bccd65dfbd060e331b29a67b4cb4fb3f4d1ba65e..e0acb27f46b5320de97174c3adb62d7d6e7452cd 100644 (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;
index 40c67fd8e8c345ebc09a52b9246b1b0ca2a9c452..b7066f4c65722a6d46876381681f22c131bce644 100644 (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;
   }
index fee1ef44e833b49fd76936d7036277e5e1a4750e..665b55c4ca043b31e43dfff4a57a08c363275070 100644 (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;
   }
   
   
index c611bfae5c1867f9532c0e9fb91a6300d65d558d..d49c7db6fde6a056e4643a972effea064c4c7864 100644 (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; }
index e17e32eaf14310185df213703b43ac38c75e9bb4..b36ed86ac96e50fc3164f708ed1e13c0b1883c30 100644 (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.
index a688a9f5af7dc3a0f2dac099878a310536c79feb..c9872cf19f905dfd92e73ab3f696abdda7b66b1a 100644 (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.
index 394592f3170f82caa0e291aa28a42abaf9efda59..5b0b97addf4ab059ec59078bbad7079c8d1415ed 100644 (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];
     }
index 66783ce088face307db5308686756881906a102e..249435af8b179945c50915f41f63244491071b36 100644 (file)
@@ -74,7 +74,7 @@ namespace llvm {
     ///
     unsigned getNumLines() const {
       if (LineOffset.empty()) calculateLineOffsets();
-      return LineOffset.size();
+      return static_cast<unsigned>(LineOffset.size());
     }
 
   private:
index 59670c64edee0c2450466c3fae605c3716e88623..f292a3173feb77385dac8bca1dde0339f36623e0 100644 (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);
   }
 
index 5031d8467c8de2e9715363f818ee492facb1e3f3..22833629f06ebeed34fe883d45eb3df5d0d171cc 100644 (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
index 04bb48bc3e323057846dbe8602f0bc6e62705311..5bf4dfb0a1047a6a20d37a03de5c0c878add1b64 100644 (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 { 
index 108c59f0eb40de7b5087a697600b206441747fcd..aecb478eefda3d93b08fc73a96b67315a1bc724c 100644 (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 };
index fc82597be42c77ccc8f4402139af8c74882c247c..33cdca13e64e014720466c7fc66fba649a472035 100644 (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() { 
index 27782c875fffbe1886d5e53554ed7149d7468972..f4db8c4bf8fe73252c07053cfbed304ab7673da8 100644 (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())
index 5ddc47e0a85cddab59aadacab0932c7036110455..cb9199162ed3ac9506d4af5a1743ff3bb3f51945 100644 (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);
       }
 
index 8c36791be53e983b262ef609587b644d4a69556f..ac77f6c9a18134ec4ed4da7838703b28011f7784 100644 (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
index d16adbd93f39008788ba5508bb1a6c2ce8bb75ca..0fedb15e40507a64faf9edef7d9fbc2f832488bf 100644 (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]);
index f4487c4542dec317e34aad2775702f625070448c..37c42aa366c84c041eb8de130193e54c71063576 100644 (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(); }
index e902cafa9bdb34a1691a4ebcd616459d866f3204..f606c8814f93dd58de6d8f0af5d3e31a7f9dd5ca 100644 (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
index 77bba9de64a9b47bac6cd0cc1ba046ab1d4fa6ca..d3e4f1ede2a9389d6644b93ace1920891da17e88 100644 (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)
index 4b6f9ff7b1330fc32df40c7dfce60d33a7b0cf33..ba6a393c81fc9b1778a6b372e97e41709c2f641b 100644 (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;
index f4594610dffcf801baafb2486106a77ad30027d8..412dcb61839ea14943ffc01002f0255e9526a0df 100644 (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.
index 3340e8b2eb83c9925a696c5fed7f756e2c62d4e4..21080b64399ead67f20a1045b9acfa6d7c6446eb 100644 (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]);
index bf50ed43dfe178414e9eaa544f6acad3f52eb25c..6daa157af1316087b983f5860d5614aa20d9cbf0 100644 (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;
index 9c2eb4244319f1cc0f08025bc9515d9f22461e2a..83f149423c55906be56a6b2dd3fbeedc7da6cda2 100644 (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) {
index e500b55f5f54f2c0823dc10bed3fc58a828d8b86..4516ebc6b344ab2a69aea4c886aa4bea9a5c9e1b 100644 (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()
index 1fae4fae488186d313e427496d6ab33d797408d1..d403a083d47f8543515a0a19eee03397e4db9f15 100644 (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 =
index e8fd5f29634c91358c02a2c3f3d34a5ab495ffe0..086c9f0238c42715cbb7e5b719530cdbc4aa5fe9 100644 (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;
index afa8f03117fb5d195a77bff9083afc72b1a7ce24..0b74f74f7b6e1bc8d55214e6b15ece5a4d5805a5 100644 (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;
index aca4b936e87246c1479f9a3f2777520a6c4a2cf5..9f4b5914ce0e2450d10b1e3af8a5a3b784735589 100644 (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
index 91baefb3294e996a8b792a26c3d5b5f0e07d8aa2..d0dade1f8cadc2467e5c0c988a388d4a82f509cf 100644 (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, ':');
index 3314a43e744477ef60b39e2a5439e68de8a9df56..79236cdad9311ba624338ab2d75cbfeb8590ab19 100644 (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
 }