diff options
author | Chris Lattner <sabre@nondot.org> | 2008-10-12 06:09:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-10-12 06:09:52 +0000 |
commit | 99bd46c018ece10d6541a4b6bf0dbe97ad162477 (patch) | |
tree | ef850dfd6e2cca38fea0a10b8a7f16b17f5484e1 /include/clang/Rewrite | |
parent | cff9cc95de367a3aea885a7f8fee304fe2707b92 (diff) |
make the -rewrite-test a bit more interesting: it now
wraps comments in <i> tags. Extend rewrite tokens to support
this minimal functionality.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57409 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Rewrite')
-rw-r--r-- | include/clang/Rewrite/TokenRewriter.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/include/clang/Rewrite/TokenRewriter.h b/include/clang/Rewrite/TokenRewriter.h index da0141ff34..1703ea7885 100644 --- a/include/clang/Rewrite/TokenRewriter.h +++ b/include/clang/Rewrite/TokenRewriter.h @@ -16,12 +16,14 @@ #define LLVM_CLANG_TOKENREWRITER_H #include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/OwningPtr.h" #include <list> #include <map> namespace clang { class Token; class LangOptions; + class ScratchBuffer; class TokenRewriter { /// TokenList - This is the list of raw tokens that make up this file. Each @@ -37,20 +39,37 @@ namespace clang { /// backwards. std::map<SourceLocation, TokenRefTy> TokenAtLoc; + /// ScratchBuf - This is the buffer that we create scratch tokens from. + /// + llvm::OwningPtr<ScratchBuffer> ScratchBuf; + + TokenRewriter(const TokenRewriter&); // DO NOT IMPLEMENT + void operator=(const TokenRewriter&); // DO NOT IMPLEMENT. public: /// TokenRewriter - This creates a TokenRewriter for the file with the /// specified FileID. TokenRewriter(unsigned FileID, SourceManager &SM, const LangOptions &LO); - + ~TokenRewriter(); typedef std::list<Token>::const_iterator token_iterator; token_iterator token_begin() const { return TokenList.begin(); } token_iterator token_end() const { return TokenList.end(); } + + token_iterator AddTokenBefore(token_iterator I, const char *Val); + token_iterator AddTokenAfter(token_iterator I, const char *Val) { + assert(I != token_end() && "Cannot insert after token_end()!"); + return AddTokenBefore(++I, Val); + } + private: + /// RemapIterator - Convert from token_iterator (a const iterator) to + /// TokenRefTy (a non-const iterator). + TokenRefTy RemapIterator(token_iterator I); + /// AddToken - Add the specified token into the Rewriter before the other /// position. - void AddToken(const Token &T, TokenRefTy Where); + TokenRefTy AddToken(const Token &T, TokenRefTy Where); }; |