The IRDynamicChecks subsystem was not properly
detecting Objective-C method calls because the
"lldb.call.realName" metadata was no longer
being correctly installed.  I fixed this problem.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@143371 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index feac492..029d4f5 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -291,6 +291,36 @@
     return ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty);
 }
 
+void
+IRForTarget::RegisterFunctionMetadata(LLVMContext &context,
+                                      llvm::Value *function_ptr, 
+                                      const char *name)
+{
+    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+    for (Value::use_iterator i = function_ptr->use_begin(), e = function_ptr->use_end();
+         i != e;
+         ++i)
+    {
+        Value *user = *i;
+                
+        if (Instruction *user_inst = dyn_cast<Instruction>(user))
+        {
+            Constant *name_array = ConstantArray::get(context, StringRef(name));
+            
+            ArrayRef<Value *> md_values(name_array);
+            
+            MDNode *metadata = MDNode::get(context, md_values);
+            
+            user_inst->setMetadata("lldb.call.realName", metadata);
+        }
+        else
+        {
+            RegisterFunctionMetadata (context, user, name);
+        }
+    }
+}
+
 bool 
 IRForTarget::ResolveFunctionPointers(llvm::Module &llvm_module,
                                      llvm::Function &llvm_function)
@@ -326,6 +356,8 @@
         
         Constant *value = BuildFunctionPointer(fun->getFunctionType(), addr);
         
+        RegisterFunctionMetadata (llvm_module.getContext(), fun, name.AsCString());
+        
         if (value_ptr)
             *value_ptr = value;