From 5a7971e0c31a10959d555b3c321baece799afb73 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 26 Jan 2009 19:29:26 +0000 Subject: This change refactors some of the low-level lexer interfaces a bit. Token now has a class of kinds for "literals", which include numeric constants, strings, etc. These tokens can optionally have a pointer to the start of the token in the lexer buffer. This makes it faster to get spelling and do other gymnastics, because we don't have to go through source locations. This change is performance neutral, but will make other changes more feasible down the road. llvm-svn: 63028 --- clang/lib/Rewrite/TokenRewriter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'clang/lib/Rewrite') diff --git a/clang/lib/Rewrite/TokenRewriter.cpp b/clang/lib/Rewrite/TokenRewriter.cpp index aab6fb0cce8..e17e80133b1 100644 --- a/clang/lib/Rewrite/TokenRewriter.cpp +++ b/clang/lib/Rewrite/TokenRewriter.cpp @@ -78,14 +78,15 @@ TokenRewriter::AddToken(const Token &T, TokenRefTy Where) { TokenRewriter::token_iterator -TokenRewriter::AddTokenBefore(token_iterator I, const char *Val){ +TokenRewriter::AddTokenBefore(token_iterator I, const char *Val) { unsigned Len = strlen(Val); // Plop the string into the scratch buffer, then create a token for this // string. Token Tok; Tok.startToken(); - Tok.setLocation(ScratchBuf->getToken(Val, Len)); + const char *Spelling; + Tok.setLocation(ScratchBuf->getToken(Val, Len, Spelling)); Tok.setLength(Len); // TODO: Form a whole lexer around this and relex the token! For now, just -- cgit v1.2.3