simplify some logic by making ScratchBuffer handle the application of trailing
\0's to created tokens instead of making all clients do it.  No functionality
change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66373 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 6cb1908..84056c3 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -475,14 +475,10 @@
     Loc = SourceMgr.getInstantiationRange(Loc).second;
     PresumedLoc PLoc = SourceMgr.getPresumedLoc(Loc);
     
-    // __LINE__ expands to a simple numeric value.  Add a space after it so that
-    // it will tokenize as a number (and not run into stuff after it in the temp
-    // buffer).
-    sprintf(TmpBuffer, "%u ", PLoc.getLine());
-    unsigned Length = strlen(TmpBuffer)-1;
+    // __LINE__ expands to a simple numeric value.
+    sprintf(TmpBuffer, "%u", PLoc.getLine());
     Tok.setKind(tok::numeric_constant);
-    CreateString(TmpBuffer, Length+1, Tok, Tok.getLocation());
-    Tok.setLength(Length);  // Trim off space.
+    CreateString(TmpBuffer, strlen(TmpBuffer), Tok, Tok.getLocation());
   } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
     // C99 6.10.8: "__FILE__: The presumed name of the current source file (a
     // character string literal)". This can be affected by #line.
@@ -532,14 +528,10 @@
     for (; PLoc.isValid(); ++Depth)
       PLoc = SourceMgr.getPresumedLoc(PLoc.getIncludeLoc());
     
-    // __INCLUDE_LEVEL__ expands to a simple numeric value.  Add a space after
-    // it so that it will tokenize as a number (and not run into stuff after it
-    // in the temp buffer).
-    sprintf(TmpBuffer, "%u ", Depth);
-    unsigned Length = strlen(TmpBuffer)-1;
+    // __INCLUDE_LEVEL__ expands to a simple numeric value.
+    sprintf(TmpBuffer, "%u", Depth);
     Tok.setKind(tok::numeric_constant);
-    CreateString(TmpBuffer, Length, Tok, Tok.getLocation());
-    Tok.setLength(Length);  // Trim off space.
+    CreateString(TmpBuffer, strlen(TmpBuffer), Tok, Tok.getLocation());
   } else if (II == Ident__TIMESTAMP__) {
     // MSVC, ICC, GCC, VisualAge C++ extension.  The generated string should be
     // of the form "Ddd Mmm dd hh::mm::ss yyyy", which is returned by asctime.
@@ -565,10 +557,9 @@
     TmpBuffer[0] = '"';
     strcpy(TmpBuffer+1, Result);
     unsigned Len = strlen(TmpBuffer);
-    TmpBuffer[Len-1] = '"';  // Replace the newline with a quote.
+    TmpBuffer[Len] = '"';  // Replace the newline with a quote.
     Tok.setKind(tok::string_literal);
     CreateString(TmpBuffer, Len+1, Tok, Tok.getLocation());
-    Tok.setLength(Len);  // Trim off space.
   } else {
     assert(0 && "Unknown identifier!");
   }