LLVM 20.0.0git
|
RewriteBuffer - As code is rewritten, SourceBuffer's from the original input with modifications get a new RewriteBuffer associated with them. More...
#include "llvm/ADT/RewriteBuffer.h"
Public Types | |
using | iterator = RewriteRope::const_iterator |
Public Member Functions | |
iterator | begin () const |
iterator | end () const |
unsigned | size () const |
void | Initialize (const char *BufStart, const char *BufEnd) |
Initialize - Start this rewrite buffer out with a copy of the unmodified input buffer. | |
void | Initialize (StringRef Input) |
raw_ostream & | write (raw_ostream &Stream) const |
Write to Stream the result of applying all changes to the original buffer. | |
void | RemoveText (unsigned OrigOffset, unsigned Size, bool removeLineIfEmpty=false) |
RemoveText - Remove the specified text. | |
void | InsertText (unsigned OrigOffset, StringRef Str, bool InsertAfter=true) |
InsertText - Insert some text at the specified point, where the offset in the buffer is specified relative to the original SourceBuffer. | |
void | InsertTextBefore (unsigned OrigOffset, StringRef Str) |
InsertTextBefore - Insert some text before the specified point, where the offset in the buffer is specified relative to the original SourceBuffer. | |
void | InsertTextAfter (unsigned OrigOffset, StringRef Str) |
InsertTextAfter - Insert some text at the specified point, where the offset in the buffer is specified relative to the original SourceBuffer. | |
void | ReplaceText (unsigned OrigOffset, unsigned OrigLength, StringRef NewStr) |
ReplaceText - This method replaces a range of characters in the input buffer with a new string. | |
Friends | |
class | clang::Rewriter |
RewriteBuffer - As code is rewritten, SourceBuffer's from the original input with modifications get a new RewriteBuffer associated with them.
The RewriteBuffer captures the modified text itself as well as information used to map between SourceLocation's in the original input and offsets in the RewriteBuffer. For example, if text is inserted into the buffer, any locations after the insertion point have to be mapped.
Definition at line 30 of file RewriteBuffer.h.
Definition at line 40 of file RewriteBuffer.h.
|
inline |
Definition at line 42 of file RewriteBuffer.h.
References llvm::RewriteRope::begin().
Referenced by RemoveText(), and write().
|
inline |
Definition at line 43 of file RewriteBuffer.h.
References llvm::RewriteRope::end().
Referenced by RemoveText(), and write().
Initialize - Start this rewrite buffer out with a copy of the unmodified input buffer.
Definition at line 48 of file RewriteBuffer.h.
References llvm::RewriteRope::assign().
|
inline |
Definition at line 51 of file RewriteBuffer.h.
References llvm::StringRef::begin(), llvm::StringRef::end(), and Initialize().
Referenced by Initialize().
InsertText - Insert some text at the specified point, where the offset in the buffer is specified relative to the original SourceBuffer.
The text is inserted after the specified location.
Definition at line 84 of file RewriteBuffer.cpp.
References llvm::RewriteRope::insert().
Referenced by InsertTextAfter(), and InsertTextBefore().
InsertTextAfter - Insert some text at the specified point, where the offset in the buffer is specified relative to the original SourceBuffer.
The text is inserted after the specified location.
Definition at line 82 of file RewriteBuffer.h.
References InsertText().
InsertTextBefore - Insert some text before the specified point, where the offset in the buffer is specified relative to the original SourceBuffer.
The text is inserted before the specified location. This is method is the same as InsertText with "InsertAfter == false".
Definition at line 75 of file RewriteBuffer.h.
References InsertText().
void RewriteBuffer::RemoveText | ( | unsigned | OrigOffset, |
unsigned | Size, | ||
bool | removeLineIfEmpty = false |
||
) |
RemoveText - Remove the specified text.
Definition at line 29 of file RewriteBuffer.cpp.
References assert(), begin(), end(), llvm::RewriteRope::erase(), isWhitespaceExceptNL(), llvm::RewriteRope::size(), and Size.
ReplaceText - This method replaces a range of characters in the input buffer with a new string.
This is effectively a combined "remove/insert" operation.
This is effectively a combined "remove+insert" operation.
Definition at line 100 of file RewriteBuffer.cpp.
References llvm::StringRef::begin(), llvm::StringRef::end(), llvm::RewriteRope::erase(), llvm::RewriteRope::insert(), and llvm::StringRef::size().
|
inline |
Definition at line 44 of file RewriteBuffer.h.
References llvm::RewriteRope::size().
raw_ostream & RewriteBuffer::write | ( | raw_ostream & | Stream | ) | const |
Write to Stream
the result of applying all changes to the original buffer.
Note that it isn't safe to use this function to overwrite memory mapped files in-place (PR17960). Consider using a higher-level utility such as Rewriter::overwriteChangedFiles() instead.
The original buffer is not actually changed.
Definition at line 14 of file RewriteBuffer.cpp.
|
friend |
Definition at line 31 of file RewriteBuffer.h.