1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | #ifndef LLVM_CLANG_REWRITE_CORE_TOKENREWRITER_H |
15 | #define LLVM_CLANG_REWRITE_CORE_TOKENREWRITER_H |
16 | |
17 | #include "clang/Basic/SourceLocation.h" |
18 | #include "clang/Lex/Token.h" |
19 | #include <cassert> |
20 | #include <list> |
21 | #include <map> |
22 | #include <memory> |
23 | |
24 | namespace clang { |
25 | |
26 | class LangOptions; |
27 | class ScratchBuffer; |
28 | class SourceManager; |
29 | |
30 | class TokenRewriter { |
31 | |
32 | |
33 | std::list<Token> TokenList; |
34 | |
35 | |
36 | using TokenRefTy = std::list<Token>::iterator; |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | std::map<SourceLocation, TokenRefTy> TokenAtLoc; |
43 | |
44 | |
45 | std::unique_ptr<ScratchBuffer> ScratchBuf; |
46 | |
47 | public: |
48 | |
49 | |
50 | TokenRewriter(FileID FID, SourceManager &SM, const LangOptions &LO); |
51 | |
52 | TokenRewriter(const TokenRewriter &) = delete; |
53 | TokenRewriter &operator=(const TokenRewriter &) = delete; |
54 | ~TokenRewriter(); |
55 | |
56 | using token_iterator = std::list<Token>::const_iterator; |
57 | |
58 | token_iterator token_begin() const { return TokenList.begin(); } |
59 | token_iterator token_end() const { return TokenList.end(); } |
60 | |
61 | token_iterator AddTokenBefore(token_iterator I, const char *Val); |
62 | |
63 | token_iterator AddTokenAfter(token_iterator I, const char *Val) { |
64 | (0) . __assert_fail ("I != token_end() && \"Cannot insert after token_end()!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Rewrite/Core/TokenRewriter.h", 64, __PRETTY_FUNCTION__))" file_link="../../../../../include/assert.h.html#88" macro="true">assert(I != token_end() && "Cannot insert after token_end()!"); |
65 | return AddTokenBefore(++I, Val); |
66 | } |
67 | |
68 | private: |
69 | |
70 | |
71 | TokenRefTy RemapIterator(token_iterator I); |
72 | |
73 | |
74 | |
75 | TokenRefTy AddToken(const Token &T, TokenRefTy Where); |
76 | }; |
77 | |
78 | } |
79 | |
80 | #endif |
81 | |