aboutsummaryrefslogtreecommitdiff
path: root/lib/Rewrite/Rewriter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-03-18 21:17:59 +0000
committerTed Kremenek <kremenek@apple.com>2008-03-18 21:17:59 +0000
commit886c8db545170850f7806f47b5f6120864effd09 (patch)
tree8b533e70c76c07d7a607891698c886553c9d1994 /lib/Rewrite/Rewriter.cpp
parent88ad97f17790b753e2e113b149d7f164e42fa2ba (diff)
Added variant of "InsertText" in the Rewriter to support inserting text both
*before* and after a specific location. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48504 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite/Rewriter.cpp')
-rw-r--r--lib/Rewrite/Rewriter.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Rewrite/Rewriter.cpp b/lib/Rewrite/Rewriter.cpp
index e3cc977bea..7b35cf1c59 100644
--- a/lib/Rewrite/Rewriter.cpp
+++ b/lib/Rewrite/Rewriter.cpp
@@ -101,11 +101,13 @@ void RewriteBuffer::RemoveText(unsigned OrigOffset, unsigned Size) {
}
void RewriteBuffer::InsertText(unsigned OrigOffset,
- const char *StrData, unsigned StrLen) {
+ const char *StrData, unsigned StrLen,
+ bool InsertAfter) {
+
// Nothing to insert, exit early.
if (StrLen == 0) return;
- unsigned RealOffset = getMappedOffset(OrigOffset, true);
+ unsigned RealOffset = getMappedOffset(OrigOffset, InsertAfter);
assert(RealOffset <= Buffer.size() && "Invalid location");
// Insert the new characters.
@@ -207,12 +209,12 @@ RewriteBuffer &Rewriter::getEditBuffer(unsigned FileID) {
/// InsertText - Insert the specified string at the specified location in the
/// original buffer.
-bool Rewriter::InsertText(SourceLocation Loc,
- const char *StrData, unsigned StrLen) {
+bool Rewriter::InsertText(SourceLocation Loc, const char *StrData,
+ unsigned StrLen, bool InsertAfter) {
if (!isRewritable(Loc)) return true;
unsigned FileID;
unsigned StartOffs = getLocationOffsetAndFileID(Loc, FileID);
- getEditBuffer(FileID).InsertText(StartOffs, StrData, StrLen);
+ getEditBuffer(FileID).InsertText(StartOffs, StrData, StrLen, InsertAfter);
return false;
}