Provide CreateValueFromData,Expression at the SBTarget level as well as the SBValue level; and also make all the implenentations agree on using the matching ValueObject::Create instead of doing code copypastas

llvm-svn: 224460
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index f8c75eb..0d3d7ad 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -864,21 +864,11 @@
     if (value_sp)
     {
         ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
-        Target* target = exe_ctx.GetTargetPtr();
-        if (target)
-        {
-            options.ref().SetKeepInMemory(true);
-            target->EvaluateExpression (expression,
-                                        exe_ctx.GetFramePtr(),
-                                        new_value_sp,
-                                        options.ref());
-            if (new_value_sp)
-            {
-                new_value_sp->SetName(ConstString(name));
-                sb_value.SetSP(new_value_sp);
-            }
-        }
+        new_value_sp = ValueObject::CreateValueObjectFromExpression(name, expression, exe_ctx, options.ref());
+        if (new_value_sp)
+            new_value_sp->SetName(ConstString(name));
     }
+    sb_value.SetSP(new_value_sp);
     if (log)
     {
         if (new_value_sp)
@@ -902,30 +892,11 @@
     lldb::TypeImplSP type_impl_sp (sb_type.GetSP());
     if (value_sp && type_impl_sp)
     {
-        ClangASTType pointer_ast_type(type_impl_sp->GetClangASTType(false).GetPointerType ());
-        if (pointer_ast_type)
-        {
-            lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
-
-            ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
-            ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
-                                                                               pointer_ast_type,
-                                                                               ConstString(name),
-                                                                               buffer,
-                                                                               exe_ctx.GetByteOrder(),
-                                                                               exe_ctx.GetAddressByteSize()));
-
-            if (ptr_result_valobj_sp)
-            {
-                ptr_result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress);
-                Error err;
-                new_value_sp = ptr_result_valobj_sp->Dereference(err);
-                if (new_value_sp)
-                    new_value_sp->SetName(ConstString(name));
-            }
-            sb_value.SetSP(new_value_sp);
-        }
+        ClangASTType ast_type(type_impl_sp->GetClangASTType(true));
+        ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
+        new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, ast_type);
     }
+    sb_value.SetSP(new_value_sp);
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
@@ -950,15 +921,10 @@
     if (value_sp)
     {
         ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
-
-        new_value_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
-                                                       type.m_opaque_sp->GetClangASTType(false),
-                                                       ConstString(name),
-                                                       *data.m_opaque_sp,
-                                                       LLDB_INVALID_ADDRESS);
+        new_value_sp = ValueObject::CreateValueObjectFromData(name, **data, exe_ctx, type.GetSP()->GetClangASTType(true));
         new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
-        sb_value.SetSP(new_value_sp);
     }
+    sb_value.SetSP(new_value_sp);
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {