[llvm-commits] [llvm] r76069 - in /llvm/trunk: include/llvm/Support/FormattedStream.h include/llvm/Support/raw_ostream.h lib/Support/FormattedStream.cpp lib/Support/raw_ostream.cpp

Dan Gohman gohman at apple.com
Thu Jul 16 08:25:04 PDT 2009


Author: djg
Date: Thu Jul 16 10:24:40 2009
New Revision: 76069

URL: http://llvm.org/viewvc/llvm-project?rev=76069&view=rev
Log:
Use size_t.

Modified:
    llvm/trunk/include/llvm/Support/FormattedStream.h
    llvm/trunk/include/llvm/Support/raw_ostream.h
    llvm/trunk/lib/Support/FormattedStream.cpp
    llvm/trunk/lib/Support/raw_ostream.cpp

Modified: llvm/trunk/include/llvm/Support/FormattedStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FormattedStream.h?rev=76069&r1=76068&r2=76069&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/FormattedStream.h (original)
+++ llvm/trunk/include/llvm/Support/FormattedStream.h Thu Jul 16 10:24:40 2009
@@ -47,7 +47,7 @@
     ///
     unsigned Column;
 
-    virtual void write_impl(const char *Ptr, unsigned Size) {
+    virtual void write_impl(const char *Ptr, size_t Size) {
       ComputeColumn(Ptr, Size);
       TheStream->write(Ptr, Size);
     }
@@ -63,7 +63,7 @@
     /// ComputeColumn - Examine the current output and figure out
     /// which column we end up in after output.
     ///
-    void ComputeColumn(const char *Ptr, unsigned Size);
+    void ComputeColumn(const char *Ptr, size_t Size);
 
   public:
     /// formatted_raw_ostream - Open the specified file for

Modified: llvm/trunk/include/llvm/Support/raw_ostream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=76069&r1=76068&r2=76069&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Thu Jul 16 10:24:40 2009
@@ -93,7 +93,7 @@
 
   /// SetBufferSize - Set the internal buffer size to the specified amount
   /// instead of the default.
-  void SetBufferSize(unsigned Size=4096) {
+  void SetBufferSize(size_t Size=4096) {
     assert(Size >= 64 &&
            "Buffer size must be somewhat large for invariants to hold");
     flush();
@@ -117,7 +117,7 @@
     Unbuffered = true;
   }
 
-  unsigned GetNumBytesInBuffer() const {
+  size_t GetNumBytesInBuffer() const {
     return OutBufCur - OutBufStart;
   }
 
@@ -155,7 +155,7 @@
     // Inline fast path, particulary for constant strings where a
     // sufficiently smart compiler will simplify strlen.
 
-    unsigned Size = strlen(Str);
+    size_t Size = strlen(Str);
 
     // Make sure we can use the fast path.
     if (OutBufCur+Size > OutBufEnd)
@@ -192,7 +192,7 @@
   }
 
   raw_ostream &write(unsigned char C);
-  raw_ostream &write(const char *Ptr, unsigned Size);
+  raw_ostream &write(const char *Ptr, size_t Size);
 
   // Formatted output, see the format() function in Support/Format.h.
   raw_ostream &operator<<(const format_object_base &Fmt);
@@ -221,7 +221,7 @@
   /// \arg Ptr to the underlying stream.
   /// 
   /// \invariant { Size > 0 }
-  virtual void write_impl(const char *Ptr, unsigned Size) = 0;
+  virtual void write_impl(const char *Ptr, size_t Size) = 0;
 
   // An out of line virtual method to provide a home for the class vtable.
   virtual void handle();
@@ -257,7 +257,7 @@
   uint64_t pos;
 
   /// write_impl - See raw_ostream::write_impl.
-  virtual void write_impl(const char *Ptr, unsigned Size);
+  virtual void write_impl(const char *Ptr, size_t Size);
 
   /// current_pos - Return the current position within the stream, not
   /// counting the bytes currently in the buffer.
@@ -339,7 +339,7 @@
   std::ostream &OS;
 
   /// write_impl - See raw_ostream::write_impl.
-  virtual void write_impl(const char *Ptr, unsigned Size);
+  virtual void write_impl(const char *Ptr, size_t Size);
 
   /// current_pos - Return the current position within the stream, not
   /// counting the bytes currently in the buffer.
@@ -359,7 +359,7 @@
   std::string &OS;
 
   /// write_impl - See raw_ostream::write_impl.
-  virtual void write_impl(const char *Ptr, unsigned Size);
+  virtual void write_impl(const char *Ptr, size_t Size);
 
   /// current_pos - Return the current position within the stream, not
   /// counting the bytes currently in the buffer.
@@ -386,7 +386,7 @@
   SmallVectorImpl<char> &OS;
 
   /// write_impl - See raw_ostream::write_impl.
-  virtual void write_impl(const char *Ptr, unsigned Size);
+  virtual void write_impl(const char *Ptr, size_t Size);
 
   /// current_pos - Return the current position within the stream, not
   /// counting the bytes currently in the buffer.

Modified: llvm/trunk/lib/Support/FormattedStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FormattedStream.cpp?rev=76069&r1=76068&r2=76069&view=diff

==============================================================================
--- llvm/trunk/lib/Support/FormattedStream.cpp (original)
+++ llvm/trunk/lib/Support/FormattedStream.cpp Thu Jul 16 10:24:40 2009
@@ -17,7 +17,7 @@
 /// ComputeColumn - Examine the current output and figure out which
 /// column we end up in after output.
 ///
-void formatted_raw_ostream::ComputeColumn(const char *Ptr, unsigned Size) {
+void formatted_raw_ostream::ComputeColumn(const char *Ptr, size_t Size) {
   // Keep track of the current column by scanning the string for
   // special characters
 

Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=76069&r1=76068&r2=76069&view=diff

==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Thu Jul 16 10:24:40 2009
@@ -121,7 +121,7 @@
   char *CurPtr = EndPtr;
 
   while (N) {
-    unsigned x = N % 16;
+    uintptr_t x = N % 16;
     *--CurPtr = (x < 10 ? '0' + x : 'a' + x - 10);
     N /= 16;
   }
@@ -153,7 +153,7 @@
   return *this;
 }
 
-raw_ostream &raw_ostream::write(const char *Ptr, unsigned Size) {
+raw_ostream &raw_ostream::write(const char *Ptr, size_t Size) {
   // Group exceptional cases into a single branch.
   if (BUILTIN_EXPECT(OutBufCur+Size > OutBufEnd, false)) {
     if (Unbuffered) {
@@ -203,10 +203,10 @@
   // anyway. We should just flush upfront in such cases, and use the
   // whole buffer as our scratch pad. Note, however, that this case is
   // also necessary for correctness on unbuffered streams.
-  unsigned NextBufferSize = 127;
+  size_t NextBufferSize = 127;
   if (OutBufEnd-OutBufCur > 3) {
-    unsigned BufferBytesLeft = OutBufEnd-OutBufCur;
-    unsigned BytesUsed = Fmt.print(OutBufCur, BufferBytesLeft);
+    size_t BufferBytesLeft = OutBufEnd-OutBufCur;
+    size_t BytesUsed = Fmt.print(OutBufCur, BufferBytesLeft);
     
     // Common case is that we have plenty of space.
     if (BytesUsed < BufferBytesLeft) {
@@ -228,7 +228,7 @@
     V.resize(NextBufferSize);
     
     // Try formatting into the SmallVector.
-    unsigned BytesUsed = Fmt.print(&V[0], NextBufferSize);
+    size_t BytesUsed = Fmt.print(&V[0], NextBufferSize);
     
     // If BytesUsed fit into the vector, we win.
     if (BytesUsed <= NextBufferSize)
@@ -296,7 +296,7 @@
   }
 }
 
-void raw_fd_ostream::write_impl(const char *Ptr, unsigned Size) {
+void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
   assert (FD >= 0 && "File already closed.");
   pos += Size;
   if (::write(FD, Ptr, Size) != (ssize_t) Size)
@@ -328,7 +328,7 @@
     (colors == SAVEDCOLOR) ? sys::Process::OutputBold(bg)
     : sys::Process::OutputColor(colors, bold, bg);
   if (colorcode) {
-    unsigned len = strlen(colorcode);
+    size_t len = strlen(colorcode);
     write(colorcode, len);
     // don't account colors towards output characters
     pos -= len;
@@ -341,7 +341,7 @@
     flush();
   const char *colorcode = sys::Process::ResetColor();
   if (colorcode) {
-    unsigned len = strlen(colorcode);
+    size_t len = strlen(colorcode);
     write(colorcode, len);
     // don't account colors towards output characters
     pos -= len;
@@ -383,7 +383,7 @@
   flush();
 }
 
-void raw_os_ostream::write_impl(const char *Ptr, unsigned Size) {
+void raw_os_ostream::write_impl(const char *Ptr, size_t Size) {
   OS.write(Ptr, Size);
 }
 
@@ -401,7 +401,7 @@
   flush();
 }
 
-void raw_string_ostream::write_impl(const char *Ptr, unsigned Size) {
+void raw_string_ostream::write_impl(const char *Ptr, size_t Size) {
   OS.append(Ptr, Size);
 }
 
@@ -413,7 +413,7 @@
   flush();
 }
 
-void raw_svector_ostream::write_impl(const char *Ptr, unsigned Size) {
+void raw_svector_ostream::write_impl(const char *Ptr, size_t Size) {
   OS.append(Ptr, Ptr + Size);
 }
 





More information about the llvm-commits mailing list