10 #ifndef LLVM_CLANG_EDIT_COMMIT_H 11 #define LLVM_CLANG_EDIT_COMMIT_H 14 #include "llvm/ADT/SmallVector.h" 15 #include "llvm/ADT/StringRef.h" 16 #include "llvm/Support/Allocator.h" 20 class PPConditionalDirectiveRecord;
56 llvm::BumpPtrAllocator StrAlloc;
62 : SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec), Editor(nullptr),
63 IsCommitable(
true) { }
68 bool beforePreviousInsertions =
false);
70 bool beforePreviousInsertions =
false) {
71 return insert(loc, text,
true, beforePreviousInsertions);
74 return insert(loc, text,
false,
78 bool afterToken =
false,
79 bool beforePreviousInsertions =
false);
87 StringRef replacementText);
90 bool afterToken =
false,
91 bool beforePreviousInsertions =
false) {
93 afterToken, beforePreviousInsertions);
110 edit_iterator
edit_begin()
const {
return CachedEdits.begin(); }
111 edit_iterator
edit_end()
const {
return CachedEdits.end(); }
115 FileOffset Offs, StringRef text,
bool beforePreviousInsertions);
118 bool beforePreviousInsertions);
129 void commitInsert(
FileOffset offset, StringRef text,
130 bool beforePreviousInsertions);
bool insertWrap(StringRef before, CharSourceRange range, StringRef after)
static CharSourceRange getTokenRange(SourceRange R)
bool insertAfterToken(SourceLocation loc, StringRef text, bool beforePreviousInsertions=false)
bool replace(SourceRange TokenRange, StringRef text)
bool insertFromRange(SourceLocation loc, CharSourceRange range, bool afterToken=false, bool beforePreviousInsertions=false)
bool insert(SourceLocation loc, StringRef text, bool afterToken=false, bool beforePreviousInsertions=false)
edit_iterator edit_end() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Commit(const SourceManager &SM, const LangOptions &LangOpts, const PPConditionalDirectiveRecord *PPRec=nullptr)
bool replace(CharSourceRange range, StringRef text)
CharSourceRange getFileRange(SourceManager &SM) const
Represents a character-granular source range.
edit_iterator edit_begin() const
FileOffset InsertFromRangeOffs
float __ovld __cnfn length(float p)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
Encodes a location in the source.
Records preprocessor conditional directive regions and allows querying in which region source locatio...
SmallVectorImpl< Edit >::const_iterator edit_iterator
bool insertWrap(StringRef before, SourceRange TokenRange, StringRef after)
Dataflow Directional Tag Classes.
bool isCommitable() const
CharSourceRange getInsertFromRange(SourceManager &SM) const
bool replaceText(SourceLocation loc, StringRef text, StringRef replacementText)
bool insertFromRange(SourceLocation loc, SourceRange TokenRange, bool afterToken=false, bool beforePreviousInsertions=false)
Commit(EditedSource &Editor)
bool replaceWithInner(SourceRange TokenRange, SourceRange TokenInnerRange)
bool insertBefore(SourceLocation loc, StringRef text)
SourceLocation getFileLocation(SourceManager &SM) const
bool replaceWithInner(CharSourceRange range, CharSourceRange innerRange)
A trivial tuple used to represent a source range.
This class handles loading and caching of source files into memory.