privatize all of the string literal memory allocation/creation
stuff behind a private static function.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64898 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 48f338e..b2df86a 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -352,17 +352,13 @@
   StrTy = Context.getConstantArrayType(StrTy,
                                    llvm::APInt(32, Literal.GetStringLength()+1),
                                        ArrayType::Normal, 0);
-  // Allocate enough space for the StringLiteral plus an array of locations for
-  // any concatenated strings.
-  void *Mem = Context.Allocate(sizeof(StringLiteral)+
-                               sizeof(SourceLocation)*(NumStringToks-1));
   
   // Pass &StringTokLocs[0], StringTokLocs.size() to factory!
-  return Owned(new (Mem) StringLiteral(Context, Literal.GetString(), 
-                                       Literal.GetStringLength(),
-                                       Literal.AnyWide, StrTy,
-                                       &StringTokLocs[0],
-                                       StringTokLocs.size()));
+  return Owned(StringLiteral::Create(Context, Literal.GetString(), 
+                                     Literal.GetStringLength(),
+                                     Literal.AnyWide, StrTy,
+                                     &StringTokLocs[0],
+                                     StringTokLocs.size()));
 }
 
 /// ShouldSnapshotBlockValueReference - Return true if a reference inside of
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 6e40b3c..886a3ca 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -51,9 +51,9 @@
       S->Destroy(Context);
     }
     // FIXME: PASS LOCATIONS PROPERLY.
-    S = new (Context) StringLiteral(Context, strBuf, Length, false,
-                                    Context.getPointerType(Context.CharTy),
-                                    AtLocs[0]);
+    S = StringLiteral::Create(Context, strBuf, Length, false,
+                              Context.getPointerType(Context.CharTy),
+                              AtLocs[0]);
   }
   
   // Verify that this composite string is acceptable for ObjC strings.