26 return c ==
' ' || c ==
'\t' || c ==
'\f' || c ==
'\v' || c ==
'\r';
30 bool removeLineIfEmpty) {
35 unsigned RealOffset = getMappedOffset(OrigOffset,
true);
36 assert(RealOffset +
Size <= Buffer.size() &&
"Invalid location");
39 Buffer.erase(RealOffset,
Size);
42 AddReplaceDelta(OrigOffset, -
Size);
44 if (removeLineIfEmpty) {
49 unsigned curLineStartOffs = 0;
51 for (
unsigned i = 0; i != RealOffset; ++i) {
55 curLineStartOffs = i + 1;
60 unsigned lineSize = 0;
66 if (posI !=
end() && *posI ==
'\n') {
67 Buffer.erase(curLineStartOffs, lineSize + 1 );
79 AddReplaceDelta(curLineStartOffs, -(lineSize + 1 ));
90 unsigned RealOffset = getMappedOffset(OrigOffset, InsertAfter);
91 Buffer.insert(RealOffset, Str.begin(), Str.end());
94 AddInsertDelta(OrigOffset, Str.size());
102 unsigned RealOffset = getMappedOffset(OrigOffset,
true);
103 Buffer.erase(RealOffset, OrigLength);
104 Buffer.insert(RealOffset, NewStr.
begin(), NewStr.
end());
105 if (OrigLength != NewStr.
size())
106 AddReplaceDelta(OrigOffset, NewStr.
size() - OrigLength);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isWhitespaceExceptNL(unsigned char c)
Return true if this character is non-new-line whitespace: ' ', '\t', '\f', '\v', '\r'.
LLVM_ABI void RemoveText(unsigned OrigOffset, unsigned Size, bool removeLineIfEmpty=false)
RemoveText - Remove the specified text.
LLVM_ABI raw_ostream & write(raw_ostream &Stream) const
Write to Stream the result of applying all changes to the original buffer.
LLVM_ABI 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 rel...
RewriteRope::const_iterator iterator
LLVM_ABI void ReplaceText(unsigned OrigOffset, unsigned OrigLength, StringRef NewStr)
ReplaceText - This method replaces a range of characters in the input buffer with a new string.
RopePieceBTreeIterator - This class provides read-only forward iteration over bytes that are in a Rop...
StringRef - Represent a constant reference to a string, i.e.
constexpr size_t size() const
size - Get the string size.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.