r243968 - [Edit] Use StringRef's copy method. No functional change intended.

Benjamin Kramer benny.kra at googlemail.com
Tue Aug 4 04:18:09 PDT 2015


Author: d0k
Date: Tue Aug  4 06:18:09 2015
New Revision: 243968

URL: http://llvm.org/viewvc/llvm-project?rev=243968&view=rev
Log:
[Edit] Use StringRef's copy method. No functional change intended.

Modified:
    cfe/trunk/include/clang/Edit/Commit.h
    cfe/trunk/include/clang/Edit/EditedSource.h
    cfe/trunk/lib/Edit/Commit.cpp

Modified: cfe/trunk/include/clang/Edit/Commit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Edit/Commit.h?rev=243968&r1=243967&r2=243968&view=diff
==============================================================================
--- cfe/trunk/include/clang/Edit/Commit.h (original)
+++ cfe/trunk/include/clang/Edit/Commit.h Tue Aug  4 06:18:09 2015
@@ -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());
-  }
 };
 
 }

Modified: cfe/trunk/include/clang/Edit/EditedSource.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Edit/EditedSource.h?rev=243968&r1=243967&r2=243968&view=diff
==============================================================================
--- cfe/trunk/include/clang/Edit/EditedSource.h (original)
+++ cfe/trunk/include/clang/Edit/EditedSource.h Tue Aug  4 06:18:09 2015
@@ -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:

Modified: cfe/trunk/lib/Edit/Commit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Edit/Commit.cpp?rev=243968&r1=243967&r2=243968&view=diff
==============================================================================
--- cfe/trunk/lib/Edit/Commit.cpp (original)
+++ cfe/trunk/lib/Edit/Commit.cpp Tue Aug  4 06:18:09 2015
@@ -183,7 +183,7 @@ void Commit::addInsert(SourceLocation Or
   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);
 }





More information about the cfe-commits mailing list