llvm::RewriteBuffer

Buffer holding rewritten source text and original-to-rewritten offset maps.

Synopsis

Declared in <llvm/ADT/RewriteBuffer.h>

class RewriteBuffer;

Description

As code is rewritten, SourceBuffers from the original input with modifications get a RewriteBuffer associated with them. The RewriteBuffer captures the modified text itself as well as information used to map between SourceLocations 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.

Type Aliases

NameDescription
iterator Const iterator over characters in the rewritten buffer.

Member Functions

NameDescription
Initialize Initialize overloads
InsertText 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.
InsertTextAfter Insert Str after original offset OrigOffset.
InsertTextBefore Insert Str before original offset OrigOffset.
RemoveText RemoveText - Remove the specified text.
ReplaceText ReplaceText - This method replaces a range of characters in the input buffer with a new string. This is effectively a combined "remove/insert" operation.
begin Iterator to the first character of the rewritten text.
end Iterator one past the last character of the rewritten text.
size Number of characters currently stored in the rewritten buffer.
write 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.

Friends

NameDescription
clang::Rewriter