Convert parts of Rewriter to StringRef based API.
 - Please accept my sincere apologies for the gratuitous elimination of code
   duplication, manual string length counting, unnecessary strlen calls, etc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79448 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp
index 72982d2..b3de536 100644
--- a/lib/Frontend/RewriteObjC.cpp
+++ b/lib/Frontend/RewriteObjC.cpp
@@ -175,7 +175,7 @@
       const std::string &Str = S.str();
 
       // If replacement succeeded or warning disabled return with no warning.
-      if (!Rewrite.ReplaceText(SrcRange.getBegin(), Size, &Str[0], Str.size())) {
+      if (!Rewrite.ReplaceText(SrcRange.getBegin(), Size, Str)) {
         ReplacedNodes[Old] = New;
         return;
       }
@@ -188,7 +188,8 @@
     void InsertText(SourceLocation Loc, const char *StrData, unsigned StrLen,
                     bool InsertAfter = true) {
       // If insertion succeeded or warning disabled return with no warning.
-      if (!Rewrite.InsertText(Loc, StrData, StrLen, InsertAfter) ||
+      if (!Rewrite.InsertText(Loc, llvm::StringRef(StrData, StrLen),
+                              InsertAfter) ||
           SilenceRewriteMacroWarning)
         return;
       
@@ -206,7 +207,8 @@
     void ReplaceText(SourceLocation Start, unsigned OrigLength,
                      const char *NewStr, unsigned NewLength) {
       // If removal succeeded or warning disabled return with no warning.
-      if (!Rewrite.ReplaceText(Start, OrigLength, NewStr, NewLength) ||
+      if (!Rewrite.ReplaceText(Start, OrigLength,
+                               llvm::StringRef(NewStr, NewLength)) ||
           SilenceRewriteMacroWarning)
         return;
       
@@ -1605,8 +1607,7 @@
       assert((*bodyBuf == '{') && "bogus @catch body location");
       
       buf += "1) { id _tmp = _caught;";
-      Rewrite.ReplaceText(startLoc, bodyBuf-startBuf+1, 
-                          buf.c_str(), buf.size());      
+      Rewrite.ReplaceText(startLoc, bodyBuf-startBuf+1, buf);
     } else if (catchDecl) {
       QualType t = catchDecl->getType();
       if (t == Context->getObjCIdType()) {