"this patch adds code generation hooks for Objective-C constant strings.  It also modifies Sema so that Objective-C constant strings are treated as untyped objects if the interface for the constant string class can not be found.  This is consistent with Apple GCC.  I thought it was consistent with GNU GCC, since this was causing failures when trying to compile GNUstep with (GNU) GCC, but it appears that this is not the case when attempting to produce a simple test case to demonstrate it.  Possibly there is a way of making the error go away, but I haven't found out what it is yet."

Patch by David Chisnall!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52599 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index e545fc1..f2cfdca 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -302,9 +302,10 @@
 //constant strings.
 llvm::Constant *CGObjCGNU::GenerateConstantString(const char *String, const
     size_t length) {
+  std::string Str(String, String +length);
   std::vector<llvm::Constant*> Ivars;
   Ivars.push_back(NULLPtr);
-  Ivars.push_back(MakeConstantString(String));
+  Ivars.push_back(MakeConstantString(Str));
   Ivars.push_back(llvm::ConstantInt::get(IntTy, length));
   llvm::Constant *ObjCStr = MakeGlobal(
     llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, IntTy, NULL),