LLVM: lib/Support/RewriteBuffer.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

11

12using namespace llvm;

13

15

16

18 I.MoveToNextPiece())

19 Stream << I.piece();

20 return Stream;

21}

22

23

24

26 return c == ' ' || c == '\t' || c == '\f' || c == '\v' || c == '\r';

27}

28

30 bool removeLineIfEmpty) {

31

32 if (Size == 0)

33 return;

34

35 unsigned RealOffset = getMappedOffset(OrigOffset, true);

36 assert(RealOffset + Size <= Buffer.size() && "Invalid location");

37

38

39 Buffer.erase(RealOffset, Size);

40

41

42 AddReplaceDelta(OrigOffset, -Size);

43

44 if (removeLineIfEmpty) {

45

46

47

49 unsigned curLineStartOffs = 0;

51 for (unsigned i = 0; i != RealOffset; ++i) {

52 if (*posI == '\n') {

53 curLineStart = posI;

54 ++curLineStart;

55 curLineStartOffs = i + 1;

56 }

57 ++posI;

58 }

59

60 unsigned lineSize = 0;

61 posI = curLineStart;

63 ++posI;

64 ++lineSize;

65 }

66 if (posI != end() && *posI == '\n') {

67 Buffer.erase(curLineStartOffs, lineSize + 1 );

68

69

70

71

72

73

74

75

76

77

78

79 AddReplaceDelta(curLineStartOffs, -(lineSize + 1 ));

80 }

81 }

82}

83

85 bool InsertAfter) {

86

87 if (Str.empty())

88 return;

89

90 unsigned RealOffset = getMappedOffset(OrigOffset, InsertAfter);

91 Buffer.insert(RealOffset, Str.begin(), Str.end());

92

93

94 AddInsertDelta(OrigOffset, Str.size());

95}

96

97

98

99

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);

107}

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'.

Definition RewriteBuffer.cpp:25

LLVM_ABI void RemoveText(unsigned OrigOffset, unsigned Size, bool removeLineIfEmpty=false)

RemoveText - Remove the specified text.

Definition RewriteBuffer.cpp:29

LLVM_ABI raw_ostream & write(raw_ostream &Stream) const

Write to Stream the result of applying all changes to the original buffer.

Definition RewriteBuffer.cpp:14

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...

Definition RewriteBuffer.cpp:84

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.

Definition RewriteBuffer.cpp:100

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.