summaryrefslogtreecommitdiffstats
path: root/clang/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
commit32e6d641767af4b0a82dff374077eca5f5041f4a (patch)
tree997f0841551658b9819d2e1961f74768dc13d8e1 /clang/Lex/Preprocessor.cpp
parent7dd7a1d310335c641ae0ee982672110d8ed1cd10 (diff)
downloadbcm5719-llvm-32e6d641767af4b0a82dff374077eca5f5041f4a.tar.gz
bcm5719-llvm-32e6d641767af4b0a82dff374077eca5f5041f4a.zip
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. llvm-svn: 40410
Diffstat (limited to 'clang/Lex/Preprocessor.cpp')
-rw-r--r--clang/Lex/Preprocessor.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/Lex/Preprocessor.cpp b/clang/Lex/Preprocessor.cpp
index 2067a0bc4ae..ceab0ba1e7d 100644
--- a/clang/Lex/Preprocessor.cpp
+++ b/clang/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.
OpenPOWER on IntegriCloud