aboutsummaryrefslogtreecommitdiff
path: root/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-07-22 22:50:09 +0000
committerChris Lattner <sabre@nondot.org>2007-07-22 22:50:09 +0000
commit0f67032078de7b8944eb8dc5fea4fef6f483c385 (patch)
tree2c44befeff9d407f37fb433463364e9372d1c312 /Lex/Preprocessor.cpp
parent349b42aed281533c04102ac4647023b3f02036e0 (diff)
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
Diffstat (limited to 'Lex/Preprocessor.cpp')
-rw-r--r--Lex/Preprocessor.cpp8
1 files changed, 7 insertions, 1 deletions
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.