diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-26 19:29:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-26 19:29:26 +0000 |
commit | 47246be8ac5b0ddde6c402b8fc6946b6135487b5 (patch) | |
tree | 7d62292bae42147bda438278b0cba02eb818db50 /lib/Rewrite | |
parent | 550faa3a6bb394eaa4013fcff0582434f4e924af (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63028 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite')
-rw-r--r-- | lib/Rewrite/TokenRewriter.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Rewrite/TokenRewriter.cpp b/lib/Rewrite/TokenRewriter.cpp index aab6fb0cce..e17e80133b 100644 --- a/lib/Rewrite/TokenRewriter.cpp +++ b/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 |