clang: include/clang/Edit/Commit.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_CLANG_EDIT_COMMIT_H
10#define LLVM_CLANG_EDIT_COMMIT_H
11
15#include "llvm/ADT/SmallVector.h"
16#include "llvm/ADT/StringRef.h"
17#include "llvm/Support/Allocator.h"
18
20
21class LangOptions;
22class PPConditionalDirectiveRecord;
23class SourceManager;
24
25namespace edit {
26
28
30public:
36
45
49 };
50
51private:
56
57 bool IsCommitable = true;
59
60 llvm::BumpPtrAllocator StrAlloc;
61
62public:
66 : SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec) {}
67
69
71 bool beforePreviousInsertions = false);
72
74 bool beforePreviousInsertions = false) {
75 return insert(loc, text, true, beforePreviousInsertions);
76 }
77
79 return insert(loc, text, false,
80 true);
81 }
82
84 bool afterToken = false,
85 bool beforePreviousInsertions = false);
87
89
93 StringRef replacementText);
94
96 bool afterToken = false,
97 bool beforePreviousInsertions = false) {
99 afterToken, beforePreviousInsertions);
100 }
101
104 }
105
108 }
109
112 }
113
117 }
118
120
123
124private:
126 FileOffset Offs, StringRef text, bool beforePreviousInsertions);
128 FileOffset RangeOffs, unsigned RangeLen,
129 bool beforePreviousInsertions);
131
137 bool canReplaceText(SourceLocation loc, StringRef text,
139
140 void commitInsert(FileOffset offset, StringRef text,
141 bool beforePreviousInsertions);
143
148};
149
150}
151
152}
153
154#endif
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
Represents a character-granular source range.
static CharSourceRange getTokenRange(SourceRange R)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Records preprocessor conditional directive regions and allows querying in which region source locatio...
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
bool replaceWithInner(CharSourceRange range, CharSourceRange innerRange)
bool remove(SourceRange TokenRange)
bool insertWrap(StringRef before, CharSourceRange range, StringRef after)
bool insertFromRange(SourceLocation loc, CharSourceRange range, bool afterToken=false, bool beforePreviousInsertions=false)
bool insert(SourceLocation loc, StringRef text, bool afterToken=false, bool beforePreviousInsertions=false)
Commit(const SourceManager &SM, const LangOptions &LangOpts, const PPConditionalDirectiveRecord *PPRec=nullptr)
bool isCommitable() const
bool insertAfterToken(SourceLocation loc, StringRef text, bool beforePreviousInsertions=false)
edit_iterator edit_begin() const
SmallVectorImpl< Edit >::const_iterator edit_iterator
bool remove(CharSourceRange range)
bool insertBefore(SourceLocation loc, StringRef text)
bool insertWrap(StringRef before, SourceRange TokenRange, StringRef after)
bool replace(SourceRange TokenRange, StringRef text)
bool insertFromRange(SourceLocation loc, SourceRange TokenRange, bool afterToken=false, bool beforePreviousInsertions=false)
bool replaceWithInner(SourceRange TokenRange, SourceRange TokenInnerRange)
bool replace(CharSourceRange range, StringRef text)
edit_iterator edit_end() const
bool replaceText(SourceLocation loc, StringRef text, StringRef replacementText)
The JSON file list parser is used to communicate input to InstallAPI.
float __ovld __cnfn length(float)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
SourceLocation getFileLocation(SourceManager &SM) const
CharSourceRange getFileRange(SourceManager &SM) const
FileOffset InsertFromRangeOffs
CharSourceRange getInsertFromRange(SourceManager &SM) const