diff options
-rw-r--r-- | clang/include/clang/Edit/Commit.h | 6 | ||||
-rw-r--r-- | clang/include/clang/Edit/EditedSource.h | 6 | ||||
-rw-r--r-- | clang/lib/Edit/Commit.cpp | 2 |
3 files changed, 2 insertions, 12 deletions
diff --git a/clang/include/clang/Edit/Commit.h b/clang/include/clang/Edit/Commit.h index 5cc5b9c6ff8..ac4bb471fe1 100644 --- a/clang/include/clang/Edit/Commit.h +++ b/clang/include/clang/Edit/Commit.h @@ -134,12 +134,6 @@ private: SourceLocation *MacroBegin = nullptr) const; bool isAtEndOfMacroExpansion(SourceLocation loc, SourceLocation *MacroEnd = nullptr) const; - - StringRef copyString(StringRef str) { - char *buf = StrAlloc.Allocate<char>(str.size()); - std::memcpy(buf, str.data(), str.size()); - return StringRef(buf, str.size()); - } }; } diff --git a/clang/include/clang/Edit/EditedSource.h b/clang/include/clang/Edit/EditedSource.h index 150a5b41b5a..8bc27e73bee 100644 --- a/clang/include/clang/Edit/EditedSource.h +++ b/clang/include/clang/Edit/EditedSource.h @@ -62,11 +62,7 @@ public: void applyRewrites(EditsReceiver &receiver); void clearRewrites(); - StringRef copyString(StringRef str) { - char *buf = StrAlloc.Allocate<char>(str.size()); - std::memcpy(buf, str.data(), str.size()); - return StringRef(buf, str.size()); - } + StringRef copyString(StringRef str) { return str.copy(StrAlloc); } StringRef copyString(const Twine &twine); private: diff --git a/clang/lib/Edit/Commit.cpp b/clang/lib/Edit/Commit.cpp index 9c08cc28ac9..cb7a784a41a 100644 --- a/clang/lib/Edit/Commit.cpp +++ b/clang/lib/Edit/Commit.cpp @@ -183,7 +183,7 @@ void Commit::addInsert(SourceLocation OrigLoc, FileOffset Offs, StringRef text, data.Kind = Act_Insert; data.OrigLoc = OrigLoc; data.Offset = Offs; - data.Text = copyString(text); + data.Text = text.copy(StrAlloc); data.BeforePrev = beforePreviousInsertions; CachedEdits.push_back(data); } |