[Lldb-commits] [lldb] r125437 - /lldb/branches/apple/calcite/lldb/source/Expression/IRForTarget.cpp

Greg Clayton gclayton at apple.com
Sat Feb 12 09:52:49 PST 2011


Author: gclayton
Date: Sat Feb 12 11:52:49 2011
New Revision: 125437

URL: http://llvm.org/viewvc/llvm-project?rev=125437&view=rev
Log:
Patch for constant objective C strings (part 2).


Modified:
    lldb/branches/apple/calcite/lldb/source/Expression/IRForTarget.cpp

Modified: lldb/branches/apple/calcite/lldb/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Expression/IRForTarget.cpp?rev=125437&r1=125436&r2=125437&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/source/Expression/IRForTarget.cpp (original)
+++ lldb/branches/apple/calcite/lldb/source/Expression/IRForTarget.cpp Sat Feb 12 11:52:49 2011
@@ -478,13 +478,18 @@
         m_CFStringCreateWithBytes = ConstantExpr::getIntToPtr(CFSCWB_addr_int, CFSCWB_ptr_ty);
     }
     
-    ConstantArray *string_array = dyn_cast<ConstantArray>(cstr->getInitializer());
+    ConstantArray *string_array;
+    
+    if (cstr)
+        string_array = dyn_cast<ConstantArray>(cstr->getInitializer());
+    else
+        string_array = NULL;
                         
     SmallVector <Value*, 5> CFSCWB_arguments;
     
     Constant *alloc_arg         = Constant::getNullValue(i8_ptr_ty);
-    Constant *bytes_arg         = ConstantExpr::getBitCast(cstr, i8_ptr_ty);
-    Constant *numBytes_arg      = ConstantInt::get(intptr_ty, string_array->getType()->getNumElements() - 1, false);
+    Constant *bytes_arg         = cstr ? ConstantExpr::getBitCast(cstr, i8_ptr_ty) : Constant::getNullValue(i8_ptr_ty);
+    Constant *numBytes_arg      = ConstantInt::get(intptr_ty, cstr ? string_array->getType()->getNumElements() - 1 : 0, false);
     Constant *encoding_arg      = ConstantInt::get(i32_ty, 0x0600, false); /* 0x0600 is kCFStringEncodingASCII */
     Constant *isExternal_arg    = ConstantInt::get(i8_ty, 0x0, false); /* 0x0 is false */
     
@@ -664,9 +669,8 @@
                 
                 return false;
             }
-            
-            ConstantArray *cstr_array = dyn_cast<ConstantArray>(cstr_global->getInitializer());
-            
+                        
+            /*
             if (!cstr_array)
             {
                 if (log)
@@ -688,9 +692,20 @@
                 
                 return false;
             }
+            */
+            
+            ConstantArray *cstr_array = dyn_cast<ConstantArray>(cstr_global->getInitializer());
             
             if (log)
-                log->Printf("Found NSString constant %s, which contains \"%s\"", vi->first(), cstr_array->getAsString().c_str());
+            {
+                if (cstr_array)
+                    log->Printf("Found NSString constant %s, which contains \"%s\"", vi->first(), cstr_array->getAsString().c_str());
+                else
+                    log->Printf("Found NSString constant %s, which contains \"\"", vi->first());
+            }
+            
+            if (!cstr_array)
+                cstr_global = NULL;
             
             if (!RewriteObjCConstString(llvm_module, nsstring_global, cstr_global, FirstEntryInstruction))
             {                





More information about the lldb-commits mailing list