From: Chris Lattner Date: Sun, 22 Jul 2007 22:50:09 +0000 (+0000) Subject: fix a bug getting the spelling of an identifier token X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f67032078de7b8944eb8dc5fea4fef6f483c385;p=clang fix a bug getting the spelling of an identifier token 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 --- diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp index 2067a0bc4a..ceab0ba1e7 100644 --- a/Lex/Preprocessor.cpp +++ b/Lex/Preprocessor.cpp @@ -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.