[cfe-commits] r54973 - /cfe/trunk/Driver/PrintPreprocessedOutput.cpp

Chris Lattner sabre at nondot.org
Mon Aug 18 21:23:15 PDT 2008


Author: lattner
Date: Mon Aug 18 23:23:15 2008
New Revision: 54973

URL: http://llvm.org/viewvc/llvm-project?rev=54973&view=rev
Log:
Use raw_ostream to output an unsigned.

Modified:
    cfe/trunk/Driver/PrintPreprocessedOutput.cpp

Modified: cfe/trunk/Driver/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/PrintPreprocessedOutput.cpp?rev=54973&r1=54972&r2=54973&view=diff

==============================================================================
--- cfe/trunk/Driver/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/Driver/PrintPreprocessedOutput.cpp Mon Aug 18 23:23:15 2008
@@ -73,21 +73,6 @@
 };
 }  // end anonymous namespace
 
-/// UToStr - Do itoa on the specified number, in-place in the specified buffer.
-/// endptr points to the end of the buffer.
-static char *UToStr(unsigned N, char *EndPtr) {
-  // Null terminate the buffer.
-  *--EndPtr = '\0';
-  if (N == 0)          // Zero is a special case.
-    *--EndPtr = '0';
-  while (N) {
-    *--EndPtr = '0' + char(N % 10);
-    N /= 10;
-  }
-  return EndPtr;
-}
-
-
 /// MoveToLine - Move the output to the source line specified by the location
 /// object.  We can do this by emitting some number of \n's, or be emitting a
 /// #line directive.  This returns false if already at the specified line, true
@@ -129,12 +114,7 @@
     
     CurLine = LineNo;
     
-    OS << '#' << ' ';
-    char NumberBuffer[20];
-    const char *NumStr = UToStr(LineNo, NumberBuffer+20);
-    OS.write(NumStr, (NumberBuffer+20)-NumStr-1);
-    OS << ' ';
-    OS << '"';
+    OS << '#' << ' ' << LineNo << ' ' << '"';
     OS.write(&CurFilename[0], CurFilename.size());
     OS << '"';
     
@@ -182,12 +162,7 @@
     EmittedTokensOnThisLine = false;
   }
   
-  OS << '#' << ' ';
-  
-  char NumberBuffer[20];
-  const char *NumStr = UToStr(CurLine, NumberBuffer+20);
-  OS.write(NumStr, (NumberBuffer+20)-NumStr-1);
-  OS << ' ' << '"';
+  OS << '#' << ' ' << CurLine << ' ' << '"';
   OS.write(&CurFilename[0], CurFilename.size());
   OS << '"';
   





More information about the cfe-commits mailing list