]> granicus.if.org Git - clang/commitdiff
fix a bug getting the spelling of an identifier token
authorChris Lattner <sabre@nondot.org>
Sun, 22 Jul 2007 22:50:09 +0000 (22:50 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 22 Jul 2007 22:50:09 +0000 (22:50 +0000)
that required cleaning.  If the token required cleaning,
don't include the cleaned tokens in the returned length.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40410 91177308-0d34-0410-b5e6-96231b3b80d8

Lex/Preprocessor.cpp

index 2067a0bc4ae189cb03dc24055e01a167b7f8651b..ceab0ba1e7d7fb1ff33f4af961bea01cf8f91034 100644 (file)
@@ -217,7 +217,13 @@ unsigned Preprocessor::getSpelling(const Token &Tok,
   // table, which is very quick.
   if (const IdentifierInfo *II = Tok.getIdentifierInfo()) {
     Buffer = II->getName();
-    return Tok.getLength();
+    
+    // Return the length of the token.  If the token needed cleaning, don't
+    // include the size of the newlines or trigraphs in it.
+    if (!Tok.needsCleaning())
+      return Tok.getLength();
+    else
+      return strlen(Buffer);
   }
   
   // Otherwise, compute the start of the token in the input lexer buffer.