[cfe-commits] r78001 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGen/darwin-string-literals.c

Daniel Dunbar daniel at zuster.org
Mon Aug 3 14:47:09 PDT 2009


Author: ddunbar
Date: Mon Aug  3 16:47:08 2009
New Revision: 78001

URL: http://llvm.org/viewvc/llvm-project?rev=78001&view=rev
Log:
Make sure UTF-16 strings end with a 16-bit null (as opposed to 8-bit).

Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/test/CodeGen/darwin-string-literals.c

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=78001&r1=78000&r2=78001&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Aug  3 16:47:08 2009
@@ -1251,6 +1251,9 @@
       AsBytes.push_back(Val & 0xFF);
     }
   }
+  // Append one extra null character, the second is automatically added by our
+  // caller.
+  AsBytes.push_back(0);
 
   IsUTF16 = true;
   return Map.GetOrCreateValue(llvm::StringRef(AsBytes.data(), AsBytes.size()));

Modified: cfe/trunk/test/CodeGen/darwin-string-literals.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/darwin-string-literals.c?rev=78001&r1=78000&r2=78001&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/darwin-string-literals.c (original)
+++ cfe/trunk/test/CodeGen/darwin-string-literals.c Mon Aug  3 16:47:08 2009
@@ -2,14 +2,15 @@
 
 // CHECK-LSB: @.str = private constant [8 x i8] c"string0\00"
 // CHECK-LSB: @.str1 = private constant [8 x i8] c"string1\00", section "__TEXT,__cstring,cstring_literals"
-// CHECK-LSB: @__utf16_string_ = internal global [35 x i8] c"h\00e\00l\00l\00o\00 \00\92! \00\03& \00\90! \00w\00o\00r\00l\00d\00\00", section "__TEXT,__ustring", align 2
+// CHECK-LSB: @__utf16_string_ = internal global [36 x i8] c"h\00e\00l\00l\00o\00 \00\92! \00\03& \00\90! \00w\00o\00r\00l\00d\00\00\00", section "__TEXT,__ustring", align 2
 
 // RUN: clang-cc -triple powerpc-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix MSB %s
 
 // CHECK-MSB: @.str = private constant [8 x i8] c"string0\00"
 // CHECK-MSB: @.str1 = private constant [8 x i8] c"string1\00", section "__TEXT,__cstring,cstring_literals"
-// CHECK-MSB: @__utf16_string_ = internal global [35 x i8] c"\00h\00e\00l\00l\00o\00 !\92\00 &\03\00 !\90\00 \00w\00o\00r\00l\00d\00", section "__TEXT,__ustring", align 2
+// CHECK-MSB: @__utf16_string_ = internal global [36 x i8] c"\00h\00e\00l\00l\00o\00 !\92\00 &\03\00 !\90\00 \00w\00o\00r\00l\00d\00\00", section "__TEXT,__ustring", align 2
 
 const char *g0 = "string0";
 const void *g1 = __builtin___CFStringMakeConstantString("string1");
 const void *g2 = __builtin___CFStringMakeConstantString("hello \u2192 \u2603 \u2190 world");
+const void *g3 = __builtin___CFStringMakeConstantString("test™");





More information about the cfe-commits mailing list