Convert ValueObject to explicitly maintain the Execution Context in which they were created, and then use that when they update themselves.  That means all the ValueObject evaluate me type functions that used to require a Frame object now do not.  I didn't remove the SBValue API's that take this now useless frame, but I added ones that don't require the frame, and marked the SBFrame taking ones as deprecated.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128593 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index d528d38..411651f 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -131,18 +131,19 @@
                                               const llvm::APInt& value)
 {
     assert (m_parser_vars.get());
-
-    clang::ASTContext *context(m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext());
+    ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
+    clang::ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext());
     
     TypeFromUser user_type(ClangASTContext::CopyType(context, 
                                                      type.GetASTContext(),
                                                      type.GetOpaqueQualType()),
                            context);
     
-    if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (name, 
+    if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx->GetBestExecutionContextScope (),
+                                                                     name, 
                                                                      user_type, 
-                                                                     m_parser_vars->m_exe_ctx->process->GetByteOrder(),
-                                                                     m_parser_vars->m_exe_ctx->process->GetAddressByteSize()))
+                                                                     exe_ctx->process->GetByteOrder(),
+                                                                     exe_ctx->process->GetAddressByteSize()))
         return lldb::ClangExpressionVariableSP();
     
     ClangExpressionVariableSP pvar_sp (m_parser_vars->m_persistent_vars->GetVariable(name));
@@ -156,7 +157,7 @@
     
     uint64_t value64 = value.getLimitedValue();
     
-    ByteOrder byte_order = m_parser_vars->m_exe_ctx->process->GetByteOrder();
+    ByteOrder byte_order = exe_ctx->process->GetByteOrder();
     
     size_t num_val_bytes = sizeof(value64);
     size_t num_data_bytes = pvar_sp->GetByteSize();
@@ -209,18 +210,20 @@
     assert (m_parser_vars.get());
     
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
     
-    clang::ASTContext *context(m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext());
+    clang::ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext());
     
     TypeFromUser user_type(ClangASTContext::CopyType(context, 
                                                      parser_type.GetASTContext(),
                                                      parser_type.GetOpaqueQualType()),
                            context);
     
-    if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (name, 
+    if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx->GetBestExecutionContextScope (),
+                                                                     name, 
                                                                      user_type, 
-                                                                     m_parser_vars->m_exe_ctx->process->GetByteOrder(),
-                                                                     m_parser_vars->m_exe_ctx->process->GetAddressByteSize()))
+                                                                     exe_ctx->process->GetByteOrder(),
+                                                                     exe_ctx->process->GetAddressByteSize()))
         return false;
     
     ClangExpressionVariableSP var_sp (m_parser_vars->m_persistent_vars->GetVariable(name));
@@ -986,7 +989,8 @@
                 // If the reference comes from the program, then the ClangExpressionVariable's
                 // live variable data hasn't been set up yet.  Do this now.
                 
-                var_sp->m_live_sp.reset(new lldb_private::ValueObjectConstResult(var_sp->GetTypeFromUser().GetASTContext(),
+                var_sp->m_live_sp.reset(new lldb_private::ValueObjectConstResult(exe_ctx.GetBestExecutionContextScope (),
+                                                                                 var_sp->GetTypeFromUser().GetASTContext(),
                                                                                  var_sp->GetTypeFromUser().GetOpaqueQualType(),
                                                                                  var_sp->GetName(),
                                                                                  mem,
@@ -1080,7 +1084,8 @@
             
             // Put the location of the spare memory into the live data of the ValueObject.
             
-            var_sp->m_live_sp.reset(new lldb_private::ValueObjectConstResult(var_sp->GetTypeFromUser().GetASTContext(),
+            var_sp->m_live_sp.reset(new lldb_private::ValueObjectConstResult(exe_ctx.GetBestExecutionContextScope(),
+                                                                             var_sp->GetTypeFromUser().GetASTContext(),
                                                                              var_sp->GetTypeFromUser().GetOpaqueQualType(),
                                                                              var_sp->GetName(),
                                                                              mem,
@@ -1344,7 +1349,8 @@
                 
                 // Put the location of the spare memory into the live data of the ValueObject.
                 
-                expr_var->m_live_sp.reset(new lldb_private::ValueObjectConstResult(type.GetASTContext(),
+                expr_var->m_live_sp.reset(new lldb_private::ValueObjectConstResult(exe_ctx.GetBestExecutionContextScope(),
+                                                                                   type.GetASTContext(),
                                                                                    type.GetOpaqueQualType(),
                                                                                    name,
                                                                                    mem,
@@ -1920,7 +1926,8 @@
     NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(pt.GetASTContext(), pt.GetOpaqueQualType()));
     std::string decl_name(context.m_decl_name.getAsString());
     ConstString entity_name(decl_name.c_str());
-    ClangExpressionVariableSP entity(m_found_entities.CreateVariable (entity_name, 
+    ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->GetBestExecutionContextScope (),
+                                                                      entity_name, 
                                                                       ut,
                                                                       m_parser_vars->m_exe_ctx->process->GetByteOrder(),
                                                                       m_parser_vars->m_exe_ctx->process->GetAddressByteSize()));
@@ -2002,7 +2009,8 @@
     
     NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType());
     
-    ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->process->GetByteOrder(),
+    ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->GetBestExecutionContextScope(),
+                                                                      m_parser_vars->m_exe_ctx->process->GetByteOrder(),
                                                                       m_parser_vars->m_exe_ctx->process->GetAddressByteSize()));
     assert (entity.get());
     std::string decl_name(context.m_decl_name.getAsString());
@@ -2098,7 +2106,8 @@
     fun_location->SetValueType(Value::eValueTypeLoadAddress);
     fun_location->GetScalar() = load_addr;
     
-    ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->process->GetByteOrder(),
+    ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->GetBestExecutionContextScope (),
+                                                                      m_parser_vars->m_exe_ctx->process->GetByteOrder(),
                                                                       m_parser_vars->m_exe_ctx->process->GetAddressByteSize()));
     assert (entity.get());
     std::string decl_name(context.m_decl_name.getAsString());
diff --git a/source/Expression/ClangExpressionVariable.cpp b/source/Expression/ClangExpressionVariable.cpp
index c5bc5c4..7cb25e3 100644
--- a/source/Expression/ClangExpressionVariable.cpp
+++ b/source/Expression/ClangExpressionVariable.cpp
@@ -25,10 +25,10 @@
 using namespace lldb_private;
 using namespace clang;
 
-ClangExpressionVariable::ClangExpressionVariable(lldb::ByteOrder byte_order, uint32_t addr_byte_size) :
+ClangExpressionVariable::ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size) :
     m_parser_vars(),
     m_jit_vars (),
-    m_frozen_sp (new ValueObjectConstResult(byte_order, addr_byte_size)),
+    m_frozen_sp (new ValueObjectConstResult(exe_scope, byte_order, addr_byte_size)),
     m_flags (EVNone)
 {
 }
diff --git a/source/Expression/ClangPersistentVariables.cpp b/source/Expression/ClangPersistentVariables.cpp
index d5ab9e5..c4bf885 100644
--- a/source/Expression/ClangPersistentVariables.cpp
+++ b/source/Expression/ClangPersistentVariables.cpp
@@ -30,12 +30,16 @@
 }
 
 ClangExpressionVariableSP
-ClangPersistentVariables::CreatePersistentVariable (const ConstString &name, const TypeFromUser& user_type, lldb::ByteOrder byte_order, uint32_t addr_byte_size)
+ClangPersistentVariables::CreatePersistentVariable (ExecutionContextScope *exe_scope, 
+                                                    const ConstString &name, 
+                                                    const TypeFromUser& user_type, 
+                                                    lldb::ByteOrder byte_order, 
+                                                    uint32_t addr_byte_size)
 {
     ClangExpressionVariableSP var_sp (GetVariable(name));
     
     if (!var_sp)
-        var_sp = CreateVariable(name, user_type, byte_order, addr_byte_size);
+        var_sp = CreateVariable(exe_scope, name, user_type, byte_order, addr_byte_size);
 
     return var_sp;
 }
diff --git a/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp
index dda810e..d560e0f 100644
--- a/source/Expression/ClangUserExpression.cpp
+++ b/source/Expression/ClangUserExpression.cpp
@@ -570,7 +570,7 @@
     {
         error.SetErrorString ("Must have a process to evaluate expressions.");
             
-        result_valobj_sp.reset (new ValueObjectConstResult (error));
+        result_valobj_sp.reset (new ValueObjectConstResult (NULL, error));
         return eExecutionSetupError;
     }
     
@@ -590,7 +590,7 @@
             else
                 error.SetErrorString (install_errors.GetString().c_str());
             
-            result_valobj_sp.reset (new ValueObjectConstResult (error));
+            result_valobj_sp.reset (new ValueObjectConstResult (NULL, error));
             return eExecutionSetupError;
         }
             
@@ -658,7 +658,7 @@
                     result_valobj_sp = expr_result->GetValueObject();
                     
                     if (log)
-                        log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with result %s ==", result_valobj_sp->GetValueAsCString(exe_ctx.GetBestExecutionContextScope()));
+                        log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with result %s ==", result_valobj_sp->GetValueAsCString());
                 }
                 else
                 {
@@ -672,7 +672,7 @@
     }
     
     if (result_valobj_sp.get() == NULL)
-        result_valobj_sp.reset (new ValueObjectConstResult (error));
+        result_valobj_sp.reset (new ValueObjectConstResult (NULL, error));
 
     return execution_results;
 }