<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">$ svn commit</div><div class="">Sending        source/Plugins/ExpressionParser/Clang/IRForTarget.cpp</div><div class="">Transmitting file data .done</div><div class="">Committing transaction...</div><div class="">Committed revision 288403.</div><div class=""><br class=""></div><div class="">Sorry for the noise, folks.</div><div class=""><br class=""></div><div class="">Sean</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Dec 1, 2016, at 11:21 AM, Sean Callanan <<a href="mailto:scallanan@apple.com" class="">scallanan@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">It'll be a fix.  ETA 10 minutes.<div class=""><br class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 1, 2016, at 11:16 AM, Sean Callanan via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" class="">lldb-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">It's definitely this one.  I'll have a fix or a revert in the next 30 minutes.<br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 1, 2016, at 10:58 AM, Tim Hammerquist <<a href="mailto:penryu@gmail.com" class="">penryu@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Builds with this patch have been failing due to a segfaulting testcase. See:<div class=""><br class=""></div><div class=""><a href="http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22721/" class="">http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22721/</a><br class=""></div><div class=""><a href="http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22722/" class="">http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22722/</a><br class=""></div><div class=""><br class=""></div><div class="">At first glance, it's possible the failure was introduced by either this commit (r288386) or possibly r288372.</div><div class=""><br class=""></div><div class="">-Tim</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Dec 1, 2016 at 9:46 AM, Sean Callanan via lldb-commits <span dir="ltr" class=""><<a href="mailto:lldb-commits@lists.llvm.org" target="_blank" class="">lldb-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: spyffe<br class="">
Date: Thu Dec  1 11:46:51 2016<br class="">
New Revision: 288386<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=288386&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project?rev=288386&view=rev</a><br class="">
Log:<br class="">
Handle UTF-16 and UTF-32 constant CFStrings<br class="">
<br class="">
We have a longstanding issue where the expression parser does not handle wide CFStrings (e.g., @"凸凹") correctly, producing the useless error message<br class="">
<br class="">
Internal error [IRForTarget]: An Objective-C constant string's string initializer is not an array<br class="">
error: warning: expression result unused<br class="">
error: The expression could not be prepared to run in the target<br class="">
<br class="">
This is just a side effect of the fact that we don't handle wide string constants when converting these to CFStringCreateWithBytes. That function takes the string's encoding as an argument, so I made it work and added a testcase.<br class="">
<br class="">
<a href="https://reviews.llvm.org/D27291" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/<wbr class="">D27291</a><br class="">
<<a href="rdar://problem/13190557" class="">rdar://problem/13190557</a>><br class="">
<br class="">
Added:<br class="">
    lldb/trunk/packages/Python/<wbr class="">lldbsuite/test/lang/objc/<wbr class="">unicode-string/<br class="">
    lldb/trunk/packages/Python/<wbr class="">lldbsuite/test/lang/objc/<wbr class="">unicode-string/<wbr class="">TestUnicodeString.py<br class="">
    lldb/trunk/packages/Python/<wbr class="">lldbsuite/test/lang/objc/<wbr class="">unicode-string/main.m<br class="">
Modified:<br class="">
    lldb/trunk/source/Plugins/<wbr class="">ExpressionParser/Clang/<wbr class="">IRForTarget.cpp<br class="">
<br class="">
Added: lldb/trunk/packages/Python/<wbr class="">lldbsuite/test/lang/objc/<wbr class="">unicode-string/<wbr class="">TestUnicodeString.py<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py?rev=288386&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/lldb/trunk/packages/<wbr class="">Python/lldbsuite/test/lang/<wbr class="">objc/unicode-string/<wbr class="">TestUnicodeString.py?rev=<wbr class="">288386&view=auto</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lldb/trunk/packages/Python/<wbr class="">lldbsuite/test/lang/objc/<wbr class="">unicode-string/<wbr class="">TestUnicodeString.py (added)<br class="">
+++ lldb/trunk/packages/Python/<wbr class="">lldbsuite/test/lang/objc/<wbr class="">unicode-string/<wbr class="">TestUnicodeString.py Thu Dec  1 11:46:51 2016<br class="">
@@ -0,0 +1,6 @@<br class="">
+from lldbsuite.test import lldbinline<br class="">
+from lldbsuite.test import decorators<br class="">
+<br class="">
+lldbinline.MakeInlineTest(<br class="">
+    __file__, globals(), [<br class="">
+        decorators.skipUnlessDarwin])<br class="">
<br class="">
Added: lldb/trunk/packages/Python/<wbr class="">lldbsuite/test/lang/objc/<wbr class="">unicode-string/main.m<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m?rev=288386&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/lldb/trunk/packages/<wbr class="">Python/lldbsuite/test/lang/<wbr class="">objc/unicode-string/main.m?<wbr class="">rev=288386&view=auto</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lldb/trunk/packages/Python/<wbr class="">lldbsuite/test/lang/objc/<wbr class="">unicode-string/main.m (added)<br class="">
+++ lldb/trunk/packages/Python/<wbr class="">lldbsuite/test/lang/objc/<wbr class="">unicode-string/main.m Thu Dec  1 11:46:51 2016<br class="">
@@ -0,0 +1,5 @@<br class="">
+#import <Foundation/Foundation.h><br class="">
+<br class="">
+int main() {<br class="">
+  NSLog(@"凸"); //% self.expect("po @\"凹\"", DATA_TYPES_DISPLAYED_<wbr class="">CORRECTLY, substrs = ["凹"])<br class="">
+}<br class="">
<br class="">
Modified: lldb/trunk/source/Plugins/<wbr class="">ExpressionParser/Clang/<wbr class="">IRForTarget.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=288386&r1=288385&r2=288386&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/lldb/trunk/source/<wbr class="">Plugins/ExpressionParser/<wbr class="">Clang/IRForTarget.cpp?rev=<wbr class="">288386&r1=288385&r2=288386&<wbr class="">view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lldb/trunk/source/Plugins/<wbr class="">ExpressionParser/Clang/<wbr class="">IRForTarget.cpp (original)<br class="">
+++ lldb/trunk/source/Plugins/<wbr class="">ExpressionParser/Clang/<wbr class="">IRForTarget.cpp Thu Dec  1 11:46:51 2016<br class="">
@@ -498,42 +498,60 @@ bool IRForTarget::<wbr class="">RewriteObjCConstString<br class="">
   Constant *bytes_arg = cstr ? ConstantExpr::getBitCast(cstr, i8_ptr_ty)<br class="">
                              : Constant::getNullValue(i8_ptr_<wbr class="">ty);<br class="">
   Constant *numBytes_arg = ConstantInt::get(<br class="">
-      m_intptr_ty, cstr ? string_array->getNumElements() - 1 : 0, false);<br class="">
-  Constant *encoding_arg = ConstantInt::get(<br class="">
-      i32_ty, 0x0600, false); /* 0x0600 is kCFStringEncodingASCII */<br class="">
-  Constant *isExternal_arg =<br class="">
-      ConstantInt::get(i8_ty, 0x0, false); /* 0x0 is false */<br class="">
-<br class="">
-  Value *argument_array[5];<br class="">
-<br class="">
-  argument_array[0] = alloc_arg;<br class="">
-  argument_array[1] = bytes_arg;<br class="">
-  argument_array[2] = numBytes_arg;<br class="">
-  argument_array[3] = encoding_arg;<br class="">
-  argument_array[4] = isExternal_arg;<br class="">
-<br class="">
-  ArrayRef<Value *> CFSCWB_arguments(argument_<wbr class="">array, 5);<br class="">
-<br class="">
-  FunctionValueCache CFSCWB_Caller(<br class="">
-      [this, &CFSCWB_arguments](llvm::<wbr class="">Function *function) -> llvm::Value * {<br class="">
-        return CallInst::Create(<br class="">
-            m_CFStringCreateWithBytes, CFSCWB_arguments,<br class="">
-            "CFStringCreateWithBytes",<br class="">
-            llvm::cast<Instruction>(<br class="">
-                m_entry_instruction_finder.<wbr class="">GetValue(function)));<br class="">
-      });<br class="">
-<br class="">
-  if (!UnfoldConstant(ns_str, nullptr, CFSCWB_Caller,<br class="">
-                      m_entry_instruction_finder, m_error_stream)) {<br class="">
-    if (log)<br class="">
-      log->PutCString(<br class="">
-          "Couldn't replace the NSString with the result of the call");<br class="">
-<br class="">
-    m_error_stream.Printf("error [IRForTarget internal]: Couldn't replace an "<br class="">
-                          "Objective-C constant string with a dynamic "<br class="">
-                          "string\n");<br class="">
+      m_intptr_ty, cstr ? (string_array->getNumElements(<wbr class="">) - 1) * string_array-><wbr class="">getElementByteSize() : 0, false);<br class="">
+ int encoding_flags = 0;<br class="">
+ switch (string_array-><wbr class="">getElementByteSize()) {<br class="">
+ case 1:<br class="">
+   encoding_flags = 0x08000100; /* 0x08000100 is kCFStringEncodingUTF8 */<br class="">
+   break;<br class="">
+ case 2:<br class="">
+   encoding_flags = 0x0100; /* 0x0100 is kCFStringEncodingUTF16 */<br class="">
+   break;<br class="">
+ case 4:<br class="">
+   encoding_flags = 0x0c000100; /* 0x0c000100 is kCFStringEncodingUTF32 */<br class="">
+   break;<br class="">
+ default:<br class="">
+   encoding_flags = 0x0600; /* fall back to 0x0600, kCFStringEncodingASCII */<br class="">
+   if (log) {<br class="">
+     log->Printf("Encountered an Objective-C constant string with unusual "<br class="">
+                 "element size %llu",<br class="">
+                 string_array-><wbr class="">getElementByteSize());<br class="">
+   }<br class="">
+ }<br class="">
+ Constant *encoding_arg = ConstantInt::get(i32_ty, encoding_flags, false);<br class="">
+ Constant *isExternal_arg =<br class="">
+     ConstantInt::get(i8_ty, 0x0, false); /* 0x0 is false */<br class="">
+<br class="">
+ Value *argument_array[5];<br class="">
+<br class="">
+ argument_array[0] = alloc_arg;<br class="">
+ argument_array[1] = bytes_arg;<br class="">
+ argument_array[2] = numBytes_arg;<br class="">
+ argument_array[3] = encoding_arg;<br class="">
+ argument_array[4] = isExternal_arg;<br class="">
+<br class="">
+ ArrayRef<Value *> CFSCWB_arguments(argument_<wbr class="">array, 5);<br class="">
+<br class="">
+ FunctionValueCache CFSCWB_Caller(<br class="">
+     [this, &CFSCWB_arguments](llvm::<wbr class="">Function *function) -> llvm::Value * {<br class="">
+       return CallInst::Create(<br class="">
+           m_CFStringCreateWithBytes, CFSCWB_arguments,<br class="">
+           "CFStringCreateWithBytes",<br class="">
+           llvm::cast<Instruction>(<br class="">
+               m_entry_instruction_finder.<wbr class="">GetValue(function)));<br class="">
+     });<br class="">
+<br class="">
+ if (!UnfoldConstant(ns_str, nullptr, CFSCWB_Caller, m_entry_instruction_finder,<br class="">
+                     m_error_stream)) {<br class="">
+   if (log)<br class="">
+     log->PutCString(<br class="">
+         "Couldn't replace the NSString with the result of the call");<br class="">
+<br class="">
+   m_error_stream.Printf("error [IRForTarget internal]: Couldn't replace an "<br class="">
+                         "Objective-C constant string with a dynamic "<br class="">
+                         "string\n");<br class="">
<br class="">
-    return false;<br class="">
+   return false;<br class="">
   }<br class="">
<br class="">
   ns_str->eraseFromParent();<br class="">
@@ -642,31 +660,23 @@ bool IRForTarget::<wbr class="">RewriteObjCConstString<br class="">
         return false;<br class="">
       }<br class="">
<br class="">
-      if (nsstring_expr->getOpcode() != Instruction::GetElementPtr) {<br class="">
-        if (log)<br class="">
-          log->Printf("NSString initializer's str element is not a "<br class="">
-                      "GetElementPtr expression, it's a %s",<br class="">
-                      nsstring_expr->getOpcodeName()<wbr class="">);<br class="">
-<br class="">
-        m_error_stream.Printf("<wbr class="">Internal error [IRForTarget]: An Objective-C "<br class="">
-                              "constant string's string initializer is not an "<br class="">
-                              "array\n");<br class="">
+      GlobalVariable *cstr_global = nullptr;<br class="">
<br class="">
-        return false;<br class="">
+      if (nsstring_expr->getOpcode() == Instruction::GetElementPtr) {<br class="">
+        Constant *nsstring_cstr = nsstring_expr->getOperand(0);<br class="">
+        cstr_global = dyn_cast<GlobalVariable>(<wbr class="">nsstring_cstr);<br class="">
+      } else if (nsstring_expr->getOpcode() == Instruction::BitCast) {<br class="">
+        Constant *nsstring_cstr = nsstring_expr->getOperand(0);<br class="">
+        cstr_global = dyn_cast<GlobalVariable>(<wbr class="">nsstring_cstr);<br class="">
       }<br class="">
<br class="">
-      Constant *nsstring_cstr = nsstring_expr->getOperand(0);<br class="">
-<br class="">
-      GlobalVariable *cstr_global = dyn_cast<GlobalVariable>(<wbr class="">nsstring_cstr);<br class="">
-<br class="">
       if (!cstr_global) {<br class="">
         if (log)<br class="">
           log->PutCString(<br class="">
               "NSString initializer's str element is not a GlobalVariable");<br class="">
<br class="">
-        m_error_stream.Printf("<wbr class="">Internal error [IRForTarget]: An Objective-C "<br class="">
-                              "constant string's string initializer doesn't "<br class="">
-                              "point to a global\n");<br class="">
+        m_error_stream.Printf("<wbr class="">Internal error [IRForTarget]: Unhandled"<br class="">
+                              "constant string initializer\n");<br class="">
<br class="">
         return false;<br class="">
       }<br class="">
<br class="">
<br class="">
______________________________<wbr class="">_________________<br class="">
lldb-commits mailing list<br class="">
<a href="mailto:lldb-commits@lists.llvm.org" class="">lldb-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/lldb-commits</a><br class="">
</blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature" data-smartmail="gmail_signature">Tim <<a href="mailto:penryu@gmail.com" target="_blank" class="">penryu@gmail.com</a>></div>
</div>
</div></blockquote></div><br class=""></div>_______________________________________________<br class="">lldb-commits mailing list<br class=""><a href="mailto:lldb-commits@lists.llvm.org" class="">lldb-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br class=""></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></body></html>