summaryrefslogtreecommitdiffstats
path: root/clang/Lex
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-06-18 07:35:33 +0000
committerChris Lattner <sabre@nondot.org>2006-06-18 07:35:33 +0000
commit33ce7283ee667d76a714ea4419857b1ece10a4e8 (patch)
treef376e2c6a9770b7d5edd962697df98c684d23f09 /clang/Lex
parent504f2ebb8becedb73c597743ba07c6d21125caf1 (diff)
downloadbcm5719-llvm-33ce7283ee667d76a714ea4419857b1ece10a4e8.tar.gz
bcm5719-llvm-33ce7283ee667d76a714ea4419857b1ece10a4e8.zip
Change the token representation to take a Start and Length instead of a
Start/End pointer. llvm-svn: 38548
Diffstat (limited to 'clang/Lex')
-rw-r--r--clang/Lex/Lexer.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp
index f0c242744b8..fac724529fc 100644
--- a/clang/Lex/Lexer.cpp
+++ b/clang/Lex/Lexer.cpp
@@ -86,10 +86,10 @@ void LexerToken::dump(bool DumpFlags) const {
// #define TWELVE 1\ <whitespace only>
// 2
// TWELVE
- std::cerr << "*unspelled*" << std::string(Start, End);
+ std::cerr << "*unspelled*" << std::string(getStart(), getEnd());
}
} else
- std::cerr << std::string(Start, End);
+ std::cerr << std::string(getStart(), getEnd());
std::cerr << "'";
if (DumpFlags) {
@@ -99,7 +99,7 @@ void LexerToken::dump(bool DumpFlags) const {
if (hasLeadingSpace())
std::cerr << " [LeadingSpace]";
if (needsCleaning())
- std::cerr << " [Spelling='" << std::string(Start, End) << "']";
+ std::cerr << " [Spelling='" << std::string(getStart(), getEnd()) << "']";
}
}
@@ -387,14 +387,14 @@ std::string Lexer::getSpelling(const LexerToken &Tok,
// Otherwise, hard case, relex the characters into the string.
std::string Result;
- Result.reserve(Tok.getEnd()-Tok.getStart());
+ Result.reserve(Tok.getLength());
for (const char *Ptr = Tok.getStart(), *End = Tok.getEnd(); Ptr != End; ) {
unsigned CharSize;
Result.push_back(getCharAndSizeNoWarn(Ptr, CharSize, Features));
Ptr += CharSize;
}
- assert(Result.size() != unsigned(Tok.getEnd()-Tok.getStart()) &&
+ assert(Result.size() != unsigned(Tok.getLength()) &&
"NeedsCleaning flag set on something that didn't need cleaning!");
return Result;
}
@@ -409,13 +409,13 @@ unsigned Lexer::getSpelling(const LexerToken &Tok, char *Buffer,
// If this token contains nothing interesting, return it directly.
if (!Tok.needsCleaning()) {
- unsigned Size = Tok.getEnd()-Tok.getStart();
+ unsigned Size = Tok.getLength();
memcpy(Buffer, Tok.getStart(), Size);
return Size;
}
// Otherwise, hard case, relex the characters into the string.
std::string Result;
- Result.reserve(Tok.getEnd()-Tok.getStart());
+ Result.reserve(Tok.getLength());
char *OutBuf = Buffer;
for (const char *Ptr = Tok.getStart(), *End = Tok.getEnd(); Ptr != End; ) {
@@ -423,7 +423,7 @@ unsigned Lexer::getSpelling(const LexerToken &Tok, char *Buffer,
*OutBuf++ = getCharAndSizeNoWarn(Ptr, CharSize, Features);
Ptr += CharSize;
}
- assert(OutBuf-Buffer != Tok.getEnd()-Tok.getStart() &&
+ assert(unsigned(OutBuf-Buffer) != Tok.getLength() &&
"NeedsCleaning flag set on something that didn't need cleaning!");
return OutBuf-Buffer;
@@ -459,7 +459,7 @@ FinishIdentifier:
SpelledTokEnd = Result.getEnd();
} else {
// Cleaning needed, alloca a buffer, clean into it, then use the buffer.
- char *TmpBuf = (char*)alloca(Result.getEnd()-Result.getStart());
+ char *TmpBuf = (char*)alloca(Result.getLength());
unsigned Size = getSpelling(Result, TmpBuf);
SpelledTokStart = TmpBuf;
SpelledTokEnd = TmpBuf+Size;
OpenPOWER on IntegriCloud