spyffe updated this revision to Diff 34004.
spyffe added a comment.

According to Jim's suggestions, made CreateVariableInList return a 
ClangExpressionVariable * rather than a ExpressionVariableSP.  Also made 
ExpressionVariable be able to get a shared pointer from itself, so that the few 
cases that want to create a variable and get a shared pointer can do that 
correctly.


http://reviews.llvm.org/D12602

Files:
  include/lldb/Core/ValueObject.h
  include/lldb/Expression/ClangExpressionDeclMap.h
  include/lldb/Expression/ClangFunction.h
  include/lldb/Expression/ClangPersistentVariables.h
  include/lldb/Expression/ClangUserExpression.h
  include/lldb/Expression/ClangUtilityFunction.h
  include/lldb/Expression/ExpressionVariable.h
  include/lldb/Expression/Materializer.h
  include/lldb/Target/StopInfo.h
  include/lldb/Target/Thread.h
  include/lldb/Target/ThreadPlan.h
  include/lldb/Target/ThreadPlanCallUserExpression.h
  include/lldb/lldb-forward.h
  source/API/SBFrame.cpp
  source/Breakpoint/BreakpointLocation.cpp
  source/Core/FormatEntity.cpp
  source/Core/ValueObject.cpp
  source/Expression/ClangExpressionDeclMap.cpp
  source/Expression/ClangPersistentVariables.cpp
  source/Expression/ClangUserExpression.cpp
  source/Expression/ExpressionVariable.cpp
  source/Expression/Materializer.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
  source/Target/ABI.cpp
  source/Target/StopInfo.cpp
  source/Target/Target.cpp
  source/Target/Thread.cpp

Index: include/lldb/lldb-forward.h
===================================================================
--- include/lldb/lldb-forward.h
+++ include/lldb/lldb-forward.h
@@ -52,8 +52,6 @@
 class   ClangExpressionDeclMap;
 class   ClangExpressionParser;
 class   ClangExpressionVariable;
-class   ClangExpressionVariableList;
-class   ClangExpressionVariableList;
 class   ClangExpressionVariables;
 class   ClangFunction;
 class   ClangModulesDeclVendor;
@@ -95,6 +93,8 @@
 class   ExecutionContextRef;
 class   ExecutionContextRefLocker;
 class   ExecutionContextScope;
+class   ExpressionVariable;
+class   ExpressionVariableList;
 class   File;
 class   FileSpec;
 class   FileSpecList;
@@ -305,7 +305,6 @@
     typedef std::unique_ptr<lldb_private::ClangASTContext> ClangASTContextUP;
     typedef std::unique_ptr<lldb_private::ClangASTImporter> ClangASTImporterUP;
     typedef std::unique_ptr<lldb_private::ClangASTSource> ClangASTSourceUP;
-    typedef std::shared_ptr<lldb_private::ClangExpressionVariable> ClangExpressionVariableSP;
     typedef std::unique_ptr<lldb_private::ClangModulesDeclVendor> ClangModulesDeclVendorUP;
     typedef std::unique_ptr<lldb_private::ClangPersistentVariables> ClangPersistentVariablesUP;
     typedef std::shared_ptr<lldb_private::ClangUserExpression> ClangUserExpressionSP;
@@ -323,6 +322,7 @@
     typedef std::unique_ptr<lldb_private::DynamicLoader> DynamicLoaderUP;
     typedef std::shared_ptr<lldb_private::Event> EventSP;
     typedef std::shared_ptr<lldb_private::ExecutionContextRef> ExecutionContextRefSP;
+    typedef std::shared_ptr<lldb_private::ExpressionVariable> ExpressionVariableSP;
     typedef std::shared_ptr<lldb_private::File> FileSP;
     typedef std::shared_ptr<lldb_private::Function> FunctionSP;
     typedef std::shared_ptr<lldb_private::FuncUnwinders> FuncUnwindersSP;
Index: include/lldb/Target/ThreadPlanCallUserExpression.h
===================================================================
--- include/lldb/Target/ThreadPlanCallUserExpression.h
+++ include/lldb/Target/ThreadPlanCallUserExpression.h
@@ -52,7 +52,7 @@
         m_manage_materialization = true;
     }
     
-    lldb::ClangExpressionVariableSP
+    lldb::ExpressionVariableSP
     GetExpressionVariable() override
     {
         return m_result_var_sp;
@@ -64,7 +64,7 @@
                                                          // User expression the initiated this ThreadPlan
                                                          // lives as long as the thread plan does.
     bool m_manage_materialization = false;
-    lldb::ClangExpressionVariableSP m_result_var_sp;     // If we are left to manage the materialization,
+    lldb::ExpressionVariableSP m_result_var_sp;     // If we are left to manage the materialization,
                                                          // then stuff the result expression variable here.
 
     DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallUserExpression);
Index: include/lldb/Target/ThreadPlan.h
===================================================================
--- include/lldb/Target/ThreadPlan.h
+++ include/lldb/Target/ThreadPlan.h
@@ -519,10 +519,10 @@
     // the user regained control at that point) a subsequent process control command step/continue/etc. might
     // complete the expression evaluations.  If so, the result of the expression evaluation will show up here.
     
-    virtual lldb::ClangExpressionVariableSP
+    virtual lldb::ExpressionVariableSP
     GetExpressionVariable ()
     {
-        return lldb::ClangExpressionVariableSP();
+        return lldb::ExpressionVariableSP();
     }
     
     // If a thread plan stores the state before it was run, then you might
Index: include/lldb/Target/Thread.h
===================================================================
--- include/lldb/Target/Thread.h
+++ include/lldb/Target/Thread.h
@@ -988,11 +988,11 @@
     /// Gets the outer-most expression variable from the completed plans
     ///
     /// @return
-    ///     A ClangExpressionVariableSP, either empty if there is no
+    ///     A ExpressionVariableSP, either empty if there is no
     ///     plan completed an expression during the current stop
     ///     or the expression variable that was made for the completed expression.
     //------------------------------------------------------------------
-    lldb::ClangExpressionVariableSP
+    lldb::ExpressionVariableSP
     GetExpressionVariable ();
 
     //------------------------------------------------------------------
Index: include/lldb/Target/StopInfo.h
===================================================================
--- include/lldb/Target/StopInfo.h
+++ include/lldb/Target/StopInfo.h
@@ -172,7 +172,7 @@
     static lldb::StopInfoSP
     CreateStopReasonWithPlan (lldb::ThreadPlanSP &plan,
                               lldb::ValueObjectSP return_valobj_sp,
-                              lldb::ClangExpressionVariableSP expression_variable_sp);
+                              lldb::ExpressionVariableSP expression_variable_sp);
 
     static lldb::StopInfoSP
     CreateStopReasonWithException (Thread &thread, const char *description);
@@ -183,7 +183,7 @@
     static lldb::ValueObjectSP
     GetReturnValueObject (lldb::StopInfoSP &stop_info_sp);
 
-    static lldb::ClangExpressionVariableSP
+    static lldb::ExpressionVariableSP
     GetExpressionVariable (lldb::StopInfoSP &stop_info_sp);
 
 protected:
Index: include/lldb/Expression/Materializer.h
===================================================================
--- include/lldb/Expression/Materializer.h
+++ include/lldb/Expression/Materializer.h
@@ -44,7 +44,7 @@
         }
         
         void Dematerialize (Error &err,
-                            lldb::ClangExpressionVariableSP &result_sp,
+                            lldb::ExpressionVariableSP &result_sp,
                             lldb::addr_t frame_top,
                             lldb::addr_t frame_bottom);
         
@@ -84,7 +84,7 @@
     
     DematerializerSP Materialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Error &err);
     
-    uint32_t AddPersistentVariable (lldb::ClangExpressionVariableSP &persistent_variable_sp, Error &err);
+    uint32_t AddPersistentVariable (lldb::ExpressionVariableSP &persistent_variable_sp, Error &err);
     uint32_t AddVariable (lldb::VariableSP &variable_sp, Error &err);
     uint32_t AddResultVariable (const TypeFromUser &type, bool is_lvalue, bool keep_in_memory, Error &err);
     uint32_t AddSymbol (const Symbol &symbol_sp, Error &err);
Index: include/lldb/Expression/ExpressionVariable.h
===================================================================
--- include/lldb/Expression/ExpressionVariable.h
+++ include/lldb/Expression/ExpressionVariable.h
@@ -10,5 +10,247 @@
 #ifndef liblldb_ExpressionVariable_h_
 #define liblldb_ExpressionVariable_h_
 
+// C Includes
+#include <signal.h>
+#include <stdint.h>
+#include <string.h>
 
+// C++ Includes
+#include <vector>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/ValueObject.h"
+
+namespace lldb_private
+{
+    
+class ClangExpressionVariable;
+
+class ExpressionVariable :
+    public std::enable_shared_from_this<ExpressionVariable>
+{
+public:
+    size_t
+    GetByteSize ()
+    {
+        return m_frozen_sp->GetByteSize();
+    }
+    
+    const ConstString &
+    GetName ()
+    {
+        return m_frozen_sp->GetName();
+    }
+    
+    lldb::ValueObjectSP
+    GetValueObject()
+    {
+        return m_frozen_sp;
+    }
+    
+    virtual ClangExpressionVariable *AsClangExpressionVariable() {
+        return nullptr;
+    }
+    
+    uint8_t *GetValueBytes();
+    
+    void
+    ValueUpdated ()
+    {
+        m_frozen_sp->ValueUpdated ();
+    }
+    
+    RegisterInfo *
+    GetRegisterInfo()
+    {
+        return m_frozen_sp->GetValue().GetRegisterInfo();
+    }
+    
+    void
+    SetRegisterInfo (const RegisterInfo *reg_info)
+    {
+        return m_frozen_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_info));
+    }
+    
+    CompilerType
+    GetCompilerType()
+    {
+        return m_frozen_sp->GetCompilerType();
+    }
+    
+    void
+    SetCompilerType(const CompilerType &clang_type)
+    {
+        m_frozen_sp->GetValue().SetCompilerType(clang_type);
+    }
+    
+    void
+    SetName (const ConstString &name)
+    {
+        m_frozen_sp->SetName (name);
+    }
+    
+    // this function is used to copy the address-of m_live_sp into m_frozen_sp
+    // this is necessary because the results of certain cast and pointer-arithmetic
+    // operations (such as those described in bugzilla issues 11588 and 11618) generate
+    // frozen objects that do not have a valid address-of, which can be troublesome when
+    // using synthetic children providers. Transferring the address-of the live object
+    // solves these issues and provides the expected user-level behavior
+    void
+    TransferAddress (bool force = false)
+    {
+        if (m_live_sp.get() == NULL)
+            return;
+        
+        if (m_frozen_sp.get() == NULL)
+            return;
+        
+        if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
+            m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());
+    }
+    
+    virtual ~ExpressionVariable();
+
+    enum Flags
+    {
+        EVNone                  = 0,
+        EVIsLLDBAllocated       = 1 << 0,   ///< This variable is resident in a location specifically allocated for it by LLDB in the target process
+        EVIsProgramReference    = 1 << 1,   ///< This variable is a reference to a (possibly invalid) area managed by the target program
+        EVNeedsAllocation       = 1 << 2,   ///< Space for this variable has yet to be allocated in the target process
+        EVIsFreezeDried         = 1 << 3,   ///< This variable's authoritative version is in m_frozen_sp (for example, for statically-computed results)
+        EVNeedsFreezeDry        = 1 << 4,   ///< Copy from m_live_sp to m_frozen_sp during dematerialization
+        EVKeepInTarget          = 1 << 5,   ///< Keep the allocation after the expression is complete rather than freeze drying its contents and freeing it
+        EVTypeIsReference       = 1 << 6,   ///< The original type of this variable is a reference, so materialize the value rather than the location
+        EVUnknownType           = 1 << 7,   ///< This is a symbol of unknown type, and the type must be resolved after parsing is complete
+        EVBareRegister          = 1 << 8    ///< This variable is a direct reference to $pc or some other entity.
+    };
+    
+    typedef uint16_t FlagType;
+    
+    FlagType m_flags; // takes elements of Flags
+
+    // these should be private
+    lldb::ValueObjectSP m_frozen_sp;
+    lldb::ValueObjectSP m_live_sp;
+};
+    
+//----------------------------------------------------------------------
+/// @class ExpressionVariableList ExpressionVariable.h "lldb/Expression/ExpressionVariable.h"
+/// @brief A list of variable references.
+///
+/// This class stores variables internally, acting as the permanent store.
+//----------------------------------------------------------------------
+class ExpressionVariableList
+{
+public:
+    //----------------------------------------------------------------------
+    /// Implementation of methods in ExpressionVariableListBase
+    //----------------------------------------------------------------------
+    size_t 
+    GetSize()
+    {
+        return m_variables.size();
+    }
+    
+    lldb::ExpressionVariableSP
+    GetVariableAtIndex(size_t index)
+    {
+        lldb::ExpressionVariableSP var_sp;
+        if (index < m_variables.size())
+            var_sp = m_variables[index];
+        return var_sp;
+    }
+    
+    size_t
+    AddVariable (const lldb::ExpressionVariableSP &var_sp)
+    {
+        m_variables.push_back(var_sp);
+        return m_variables.size() - 1;
+    }
+
+    bool
+    ContainsVariable (const lldb::ExpressionVariableSP &var_sp)
+    {
+        const size_t size = m_variables.size();
+        for (size_t index = 0; index < size; ++index)
+        {
+            if (m_variables[index].get() == var_sp.get())
+                return true;
+        }
+        return false;
+    }
+
+    //----------------------------------------------------------------------
+    /// Finds a variable by name in the list.
+    ///
+    /// @param[in] name
+    ///     The name of the requested variable.
+    ///
+    /// @return
+    ///     The variable requested, or NULL if that variable is not in the list.
+    //----------------------------------------------------------------------
+    lldb::ExpressionVariableSP
+    GetVariable (const ConstString &name)
+    {
+        lldb::ExpressionVariableSP var_sp;
+        for (size_t index = 0, size = GetSize(); index < size; ++index)
+        {
+            var_sp = GetVariableAtIndex(index);
+            if (var_sp->GetName() == name)
+                return var_sp;
+        }
+        var_sp.reset();
+        return var_sp;
+    }
+
+    lldb::ExpressionVariableSP
+    GetVariable (const char *name)
+    {
+        lldb::ExpressionVariableSP var_sp;
+        if (name && name[0])
+        {
+            for (size_t index = 0, size = GetSize(); index < size; ++index)
+            {
+                var_sp = GetVariableAtIndex(index);
+                const char *var_name_cstr = var_sp->GetName().GetCString();
+                if (!var_name_cstr || !name)
+                    continue;
+                if (::strcmp (var_name_cstr, name) == 0)
+                    return var_sp;
+            }
+            var_sp.reset();
+        }
+        return var_sp;
+    }
+    
+    void
+    RemoveVariable (lldb::ExpressionVariableSP var_sp)
+    {
+        for (std::vector<lldb::ExpressionVariableSP>::iterator vi = m_variables.begin(), ve = m_variables.end();
+             vi != ve;
+             ++vi)
+        {
+            if (vi->get() == var_sp.get())
+            {
+                m_variables.erase(vi);
+                return;
+            }
+        }
+    }
+    
+    void
+    Clear()
+    {
+        m_variables.clear();
+    }
+
+private:
+    std::vector <lldb::ExpressionVariableSP> m_variables;
+};
+    
+}
+
 #endif /* liblldb_ExpressionVariable_h_ */
Index: include/lldb/Expression/ClangUtilityFunction.h
===================================================================
--- include/lldb/Expression/ClangUtilityFunction.h
+++ include/lldb/Expression/ClangUtilityFunction.h
@@ -125,7 +125,7 @@
     /// Return the object that the parser should use when registering
     /// local variables.  May be NULL if the Expression doesn't care.
     //------------------------------------------------------------------
-    ClangExpressionVariableList *
+    ExpressionVariableList *
     LocalVariables ()
     {
         return NULL;
Index: include/lldb/Expression/ClangUserExpression.h
===================================================================
--- include/lldb/Expression/ClangUserExpression.h
+++ include/lldb/Expression/ClangUserExpression.h
@@ -145,7 +145,7 @@
              ExecutionContext &exe_ctx,
              const EvaluateExpressionOptions& options,
              lldb::ClangUserExpressionSP &shared_ptr_to_me,
-             lldb::ClangExpressionVariableSP &result);
+             lldb::ExpressionVariableSP &result);
 
     //------------------------------------------------------------------
     /// Apply the side effects of the function to program state.
@@ -173,7 +173,7 @@
     bool
     FinalizeJITExecution (Stream &error_stream,
                           ExecutionContext &exe_ctx,
-                          lldb::ClangExpressionVariableSP &result,
+                          lldb::ExpressionVariableSP &result,
                           lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
                           lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS);
 
Index: include/lldb/Expression/ClangPersistentVariables.h
===================================================================
--- include/lldb/Expression/ClangPersistentVariables.h
+++ include/lldb/Expression/ClangPersistentVariables.h
@@ -26,7 +26,7 @@
 /// ClangPersistentVariable for more discussion.  Also provides an increasing,
 /// 0-based counter for naming result variables.
 //----------------------------------------------------------------------
-class ClangPersistentVariables : public ClangExpressionVariableList
+class ClangPersistentVariables : public ExpressionVariableList
 {
 public:
     
@@ -35,10 +35,10 @@
     //----------------------------------------------------------------------
     ClangPersistentVariables ();
 
-    lldb::ClangExpressionVariableSP
+    lldb::ExpressionVariableSP
     CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp);
 
-    lldb::ClangExpressionVariableSP
+    ClangExpressionVariable *
     CreatePersistentVariable (ExecutionContextScope *exe_scope,
                               const ConstString &name, 
                               const TypeFromUser& user_type, 
@@ -56,7 +56,7 @@
     GetNextPersistentVariableName ();
     
     void
-    RemovePersistentVariable (lldb::ClangExpressionVariableSP variable);
+    RemovePersistentVariable (lldb::ExpressionVariableSP variable);
 
     void
     RegisterPersistentType (const ConstString &name,
Index: include/lldb/Expression/ClangFunction.h
===================================================================
--- include/lldb/Expression/ClangFunction.h
+++ include/lldb/Expression/ClangFunction.h
@@ -364,7 +364,7 @@
     /// Return the object that the parser should use when registering
     /// local variables.  May be NULL if the Expression doesn't care.
     //------------------------------------------------------------------
-    ClangExpressionVariableList *
+    ExpressionVariableList *
     LocalVariables ()
     {
         return NULL;
Index: include/lldb/Expression/ClangExpressionDeclMap.h
===================================================================
--- include/lldb/Expression/ClangExpressionDeclMap.h
+++ include/lldb/Expression/ClangExpressionDeclMap.h
@@ -387,9 +387,9 @@
                               CompilerDeclContext &namespace_decl,
                               unsigned int current_id);
 private:
-    ClangExpressionVariableList    m_found_entities;           ///< All entities that were looked up for the parser.
-    ClangExpressionVariableList    m_struct_members;           ///< All entities that need to be placed in the struct.
-    bool                           m_keep_result_in_memory;    ///< True if result persistent variables generated by this expression should stay in memory.
+    ExpressionVariableList      m_found_entities;           ///< All entities that were looked up for the parser.
+    ExpressionVariableList      m_struct_members;           ///< All entities that need to be placed in the struct.
+    bool                        m_keep_result_in_memory;    ///< True if result persistent variables generated by this expression should stay in memory.
     
     //----------------------------------------------------------------------
     /// The following values should not live beyond parsing
@@ -615,7 +615,7 @@
     //------------------------------------------------------------------
     void 
     AddOneVariable (NameSearchContext &context, 
-                    lldb::ClangExpressionVariableSP &pvar_sp,
+                    lldb::ExpressionVariableSP &pvar_sp,
                     unsigned int current_id);
     
     //------------------------------------------------------------------
Index: include/lldb/Core/ValueObject.h
===================================================================
--- include/lldb/Core/ValueObject.h
+++ include/lldb/Core/ValueObject.h
@@ -1139,7 +1139,7 @@
     
     friend class ValueObjectChild;
     friend class ClangExpressionDeclMap;  // For GetValue
-    friend class ClangExpressionVariable; // For SetName
+    friend class ExpressionVariable;      // For SetName
     friend class Target;                  // For SetName
     friend class ValueObjectConstResultImpl;
     friend class ValueObjectSynthetic;    // For ClearUserVisibleData
Index: source/Target/Thread.cpp
===================================================================
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -1244,20 +1244,20 @@
     return ValueObjectSP();
 }
 
-ClangExpressionVariableSP
+ExpressionVariableSP
 Thread::GetExpressionVariable ()
 {
     if (!m_completed_plan_stack.empty())
     {
         for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--)
         {
-            ClangExpressionVariableSP expression_variable_sp;
+            ExpressionVariableSP expression_variable_sp;
             expression_variable_sp = m_completed_plan_stack[i]->GetExpressionVariable();
             if (expression_variable_sp)
                 return expression_variable_sp;
         }
     }
-    return ClangExpressionVariableSP();
+    return ExpressionVariableSP();
 }
 
 bool
Index: source/Target/Target.cpp
===================================================================
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -2032,7 +2032,7 @@
     
     // Make sure we aren't just trying to see the value of a persistent
     // variable (something like "$0")
-    lldb::ClangExpressionVariableSP persistent_var_sp;
+    lldb::ExpressionVariableSP persistent_var_sp;
     // Only check for persistent variables the expression starts with a '$' 
     if (expr_cstr[0] == '$')
         persistent_var_sp = m_persistent_variables->GetVariable (expr_cstr);
Index: source/Target/StopInfo.cpp
===================================================================
--- source/Target/StopInfo.cpp
+++ source/Target/StopInfo.cpp
@@ -1054,7 +1054,7 @@
 {
 public:
 
-    StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ClangExpressionVariableSP &expression_variable_sp) :
+    StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp, ExpressionVariableSP &expression_variable_sp) :
         StopInfo (plan_sp->GetThread(), LLDB_INVALID_UID),
         m_plan_sp (plan_sp),
         m_return_valobj_sp (return_valobj_sp),
@@ -1090,7 +1090,7 @@
         return m_return_valobj_sp;
     }
     
-    ClangExpressionVariableSP
+    ExpressionVariableSP
     GetExpressionVariable()
     {
         return m_expression_variable_sp;
@@ -1109,7 +1109,7 @@
 private:
     ThreadPlanSP m_plan_sp;
     ValueObjectSP m_return_valobj_sp;
-    ClangExpressionVariableSP m_expression_variable_sp;
+    ExpressionVariableSP m_expression_variable_sp;
 };
     
 class StopInfoExec : public StopInfo
@@ -1190,7 +1190,7 @@
 StopInfoSP
 StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp,
                                     ValueObjectSP return_valobj_sp,
-                                    ClangExpressionVariableSP expression_variable_sp)
+                                    ExpressionVariableSP expression_variable_sp)
 {
     return StopInfoSP (new StopInfoThreadPlan (plan_sp, return_valobj_sp, expression_variable_sp));
 }
@@ -1219,7 +1219,7 @@
         return ValueObjectSP();
 }
 
-ClangExpressionVariableSP
+ExpressionVariableSP
 StopInfo::GetExpressionVariable(StopInfoSP &stop_info_sp)
 {
     if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonPlanComplete)
@@ -1228,5 +1228,5 @@
         return plan_stop_info->GetExpressionVariable();
     }
     else
-        return ClangExpressionVariableSP();
+        return ExpressionVariableSP();
 }
Index: source/Target/ABI.cpp
===================================================================
--- source/Target/ABI.cpp
+++ source/Target/ABI.cpp
@@ -141,7 +141,7 @@
         
         return_valobj_sp = const_valobj_sp;
 
-        ClangExpressionVariableSP clang_expr_variable_sp(persistent_variables.CreatePersistentVariable(return_valobj_sp));
+        ExpressionVariableSP clang_expr_variable_sp(persistent_variables.CreatePersistentVariable(return_valobj_sp));
                
         assert (clang_expr_variable_sp.get());
         
Index: source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
@@ -26,6 +26,7 @@
 #include "lldb/Core/ClangForward.h"
 #include "lldb/Core/ConstString.h"
 #include "lldb/Core/Value.h"
+#include "lldb/Expression/ExpressionVariable.h"
 #include "lldb/Symbol/TaggedASTType.h"
 
 namespace llvm {
@@ -34,7 +35,6 @@
 
 namespace lldb_private {
 
-class ClangExpressionVariableList;
 class ValueObjectConstResult;
 
 //----------------------------------------------------------------------
@@ -60,7 +60,7 @@
 /// polymorphism, and provides necessary support methods.  Its interface
 /// is RTTI-neutral.
 //----------------------------------------------------------------------
-class ClangExpressionVariable
+class ClangExpressionVariable : public ExpressionVariable
 {
 public:
     ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size);
@@ -71,6 +71,78 @@
                              uint16_t flags = EVNone);
     
     ClangExpressionVariable(const lldb::ValueObjectSP &valobj_sp);
+    
+    ClangExpressionVariable *AsClangExpressionVariable() override
+    {
+        return this;
+    }
+    
+    //----------------------------------------------------------------------
+    /// Utility functions for dealing with ExpressionVariableLists in Clang-specific ways
+    //----------------------------------------------------------------------
+    
+    //----------------------------------------------------------------------
+    /// Finds a variable by NamedDecl in the list.
+    ///
+    /// @param[in] name
+    ///     The name of the requested variable.
+    ///
+    /// @return
+    ///     The variable requested, or NULL if that variable is not in the list.
+    //----------------------------------------------------------------------
+    static lldb::ExpressionVariableSP
+    FindVariableInList (ExpressionVariableList &list, const clang::NamedDecl *decl, uint64_t parser_id)
+    {
+        lldb::ExpressionVariableSP var_sp;
+        for (size_t index = 0, size = list.GetSize(); index < size; ++index)
+        {
+            var_sp = list.GetVariableAtIndex(index);
+            
+            if (ClangExpressionVariable *clang_var = var_sp->AsClangExpressionVariable())
+            {
+                ClangExpressionVariable::ParserVars *parser_vars = clang_var->GetParserVars(parser_id);
+                
+                if (parser_vars && parser_vars->m_named_decl == decl)
+                    return var_sp;
+            }
+        }
+        var_sp.reset();
+        return var_sp;
+    }
+    
+    static ClangExpressionVariable *
+    CreateVariableInList (ExpressionVariableList &list, ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size)
+    {
+        ClangExpressionVariable *clang_var = new ClangExpressionVariable(exe_scope, byte_order, addr_byte_size);
+        lldb::ExpressionVariableSP var_sp(clang_var);
+        list.AddVariable(var_sp);
+        return clang_var;
+    }
+    
+    static ClangExpressionVariable *
+    CreateVariableInList (ExpressionVariableList &list, const lldb::ValueObjectSP &valobj_sp)
+    {
+        ClangExpressionVariable *clang_var = new ClangExpressionVariable(valobj_sp);
+        lldb::ExpressionVariableSP var_sp(clang_var);
+        list.AddVariable(var_sp);
+        return clang_var;
+    }
+    
+    static ClangExpressionVariable *
+    CreateVariableInList (ExpressionVariableList &list,
+                          ExecutionContextScope *exe_scope,
+                          const ConstString &name,
+                          const TypeFromUser& user_type,
+                          lldb::ByteOrder byte_order,
+                          uint32_t addr_byte_size)
+    {
+        ClangExpressionVariable *clang_var = new ClangExpressionVariable(exe_scope, byte_order, addr_byte_size);
+        lldb::ExpressionVariableSP var_sp(clang_var);
+        clang_var->SetName (name);
+        clang_var->SetCompilerType (user_type);
+        list.AddVariable(var_sp);
+        return clang_var;
+    }
 
     //----------------------------------------------------------------------
     /// If the variable contains its own data, make a Value point at it.
@@ -90,9 +162,6 @@
     bool
     PointValueAtData(Value &value, ExecutionContext *exe_ctx);
     
-    lldb::ValueObjectSP
-    GetValueObject();
-
     //----------------------------------------------------------------------
     /// The following values should not live beyond parsing
     //----------------------------------------------------------------------
@@ -205,252 +274,16 @@
         else
             return &i->second;
     }
-        
-    //----------------------------------------------------------------------
-    /// Return the variable's size in bytes
-    //----------------------------------------------------------------------
-    size_t 
-    GetByteSize ();
-
-    const ConstString &
-    GetName();
-
-    RegisterInfo *
-    GetRegisterInfo();
     
-    void
-    SetRegisterInfo (const RegisterInfo *reg_info);
-
-    CompilerType
-    GetCompilerType ();
-    
-    void
-    SetCompilerType (const CompilerType &clang_type);
-
     TypeFromUser
     GetTypeFromUser ();
-
-    uint8_t *
-    GetValueBytes ();
     
-    void
-    SetName (const ConstString &name);
-
-    void
-    ValueUpdated ();
-    
-    // this function is used to copy the address-of m_live_sp into m_frozen_sp
-    // this is necessary because the results of certain cast and pointer-arithmetic
-    // operations (such as those described in bugzilla issues 11588 and 11618) generate
-    // frozen objects that do not have a valid address-of, which can be troublesome when
-    // using synthetic children providers. Transferring the address-of the live object
-    // solves these issues and provides the expected user-level behavior
-    void
-    TransferAddress (bool force = false);
-
-    typedef std::shared_ptr<ValueObjectConstResult> ValueObjectConstResultSP;
-
     //----------------------------------------------------------------------
     /// Members
-    //----------------------------------------------------------------------
-    enum Flags 
-    {
-        EVNone                  = 0,
-        EVIsLLDBAllocated       = 1 << 0,   ///< This variable is resident in a location specifically allocated for it by LLDB in the target process
-        EVIsProgramReference    = 1 << 1,   ///< This variable is a reference to a (possibly invalid) area managed by the target program
-        EVNeedsAllocation       = 1 << 2,   ///< Space for this variable has yet to be allocated in the target process
-        EVIsFreezeDried         = 1 << 3,   ///< This variable's authoritative version is in m_frozen_sp (for example, for statically-computed results)
-        EVNeedsFreezeDry        = 1 << 4,   ///< Copy from m_live_sp to m_frozen_sp during dematerialization
-        EVKeepInTarget          = 1 << 5,   ///< Keep the allocation after the expression is complete rather than freeze drying its contents and freeing it
-        EVTypeIsReference       = 1 << 6,   ///< The original type of this variable is a reference, so materialize the value rather than the location
-        EVUnknownType           = 1 << 7,   ///< This is a symbol of unknown type, and the type must be resolved after parsing is complete
-        EVBareRegister          = 1 << 8    ///< This variable is a direct reference to $pc or some other entity.
-    };
-    
-    typedef uint16_t FlagType;
-    
-    FlagType m_flags; // takes elements of Flags
-    
-    lldb::ValueObjectSP m_frozen_sp;
-    lldb::ValueObjectSP m_live_sp;
-    
+    //----------------------------------------------------------------------        
     DISALLOW_COPY_AND_ASSIGN (ClangExpressionVariable);
 };
 
-//----------------------------------------------------------------------
-/// @class ClangExpressionVariableListBase ClangExpressionVariable.h "lldb/Expression/ClangExpressionVariable.h"
-/// @brief A list of variable references.
-///
-/// This class stores variables internally, acting as the permanent store.
-//----------------------------------------------------------------------
-class ClangExpressionVariableList
-{
-public:
-    //----------------------------------------------------------------------
-    /// Implementation of methods in ClangExpressionVariableListBase
-    //----------------------------------------------------------------------
-    size_t 
-    GetSize()
-    {
-        return m_variables.size();
-    }
-    
-    lldb::ClangExpressionVariableSP
-    GetVariableAtIndex(size_t index)
-    {
-        lldb::ClangExpressionVariableSP var_sp;
-        if (index < m_variables.size())
-            var_sp = m_variables[index];
-        return var_sp;
-    }
-    
-    size_t
-    AddVariable (const lldb::ClangExpressionVariableSP &var_sp)
-    {
-        m_variables.push_back(var_sp);
-        return m_variables.size() - 1;
-    }
-
-    bool
-    ContainsVariable (const lldb::ClangExpressionVariableSP &var_sp)
-    {
-        const size_t size = m_variables.size();
-        for (size_t index = 0; index < size; ++index)
-        {
-            if (m_variables[index].get() == var_sp.get())
-                return true;
-        }
-        return false;
-    }
-
-    //----------------------------------------------------------------------
-    /// Finds a variable by name in the list.
-    ///
-    /// @param[in] name
-    ///     The name of the requested variable.
-    ///
-    /// @return
-    ///     The variable requested, or NULL if that variable is not in the list.
-    //----------------------------------------------------------------------
-    lldb::ClangExpressionVariableSP
-    GetVariable (const ConstString &name)
-    {
-        lldb::ClangExpressionVariableSP var_sp;
-        for (size_t index = 0, size = GetSize(); index < size; ++index)
-        {
-            var_sp = GetVariableAtIndex(index);
-            if (var_sp->GetName() == name)
-                return var_sp;
-        }
-        var_sp.reset();
-        return var_sp;
-    }
-
-    lldb::ClangExpressionVariableSP
-    GetVariable (const char *name)
-    {
-        lldb::ClangExpressionVariableSP var_sp;
-        if (name && name[0])
-        {
-            for (size_t index = 0, size = GetSize(); index < size; ++index)
-            {
-                var_sp = GetVariableAtIndex(index);
-                const char *var_name_cstr = var_sp->GetName().GetCString();
-                if (!var_name_cstr || !name)
-                    continue;
-                if (::strcmp (var_name_cstr, name) == 0)
-                    return var_sp;
-            }
-            var_sp.reset();
-        }
-        return var_sp;
-    }
-    
-    //----------------------------------------------------------------------
-    /// Finds a variable by NamedDecl in the list.
-    ///
-    /// @param[in] name
-    ///     The name of the requested variable.
-    ///
-    /// @return
-    ///     The variable requested, or NULL if that variable is not in the list.
-    //----------------------------------------------------------------------
-    lldb::ClangExpressionVariableSP
-    GetVariable (const clang::NamedDecl *decl, uint64_t parser_id)
-    {
-        lldb::ClangExpressionVariableSP var_sp;
-        for (size_t index = 0, size = GetSize(); index < size; ++index)
-        {
-            var_sp = GetVariableAtIndex(index);
-            
-            ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(parser_id);
-            
-            if (parser_vars && parser_vars->m_named_decl == decl)
-                return var_sp;
-        }
-        var_sp.reset();
-        return var_sp;
-    }
-
-    //----------------------------------------------------------------------
-    /// Create a new variable in the list and return its index
-    //----------------------------------------------------------------------
-    lldb::ClangExpressionVariableSP
-    CreateVariable (ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size)
-    {
-        lldb::ClangExpressionVariableSP var_sp(new ClangExpressionVariable(exe_scope, byte_order, addr_byte_size));
-        m_variables.push_back(var_sp);
-        return var_sp;
-    }
-
-    lldb::ClangExpressionVariableSP
-    CreateVariable(const lldb::ValueObjectSP &valobj_sp)
-    {
-        lldb::ClangExpressionVariableSP var_sp(new ClangExpressionVariable(valobj_sp));
-        m_variables.push_back(var_sp);
-        return var_sp;
-    }
-
-    lldb::ClangExpressionVariableSP
-    CreateVariable (ExecutionContextScope *exe_scope,
-                    const ConstString &name, 
-                    const TypeFromUser& user_type,
-                    lldb::ByteOrder byte_order, 
-                    uint32_t addr_byte_size)
-    {
-        lldb::ClangExpressionVariableSP var_sp(new ClangExpressionVariable(exe_scope, byte_order, addr_byte_size));
-        var_sp->SetName (name);
-        var_sp->SetCompilerType (user_type);
-        m_variables.push_back(var_sp);
-        return var_sp;
-    }
-    
-    void
-    RemoveVariable (lldb::ClangExpressionVariableSP var_sp)
-    {
-        for (std::vector<lldb::ClangExpressionVariableSP>::iterator vi = m_variables.begin(), ve = m_variables.end();
-             vi != ve;
-             ++vi)
-        {
-            if (vi->get() == var_sp.get())
-            {
-                m_variables.erase(vi);
-                return;
-            }
-        }
-    }
-    
-    void
-    Clear()
-    {
-        m_variables.clear();
-    }
-
-private:
-    std::vector <lldb::ClangExpressionVariableSP> m_variables;
-};
-
-
 } // namespace lldb_private
 
 #endif  // liblldb_ClangExpressionVariable_h_
Index: source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
@@ -24,122 +24,38 @@
 const char *g_clang_expression_variable_kind_name = "ClangExpressionVariable";
 
 ClangExpressionVariable::ClangExpressionVariable(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size) :
+    ExpressionVariable(),
     m_parser_vars(),
-    m_jit_vars (),
-    m_flags (EVNone),
-    m_frozen_sp (ValueObjectConstResult::Create (exe_scope, byte_order, addr_byte_size))
+    m_jit_vars ()
 {
+    m_flags = EVNone;
+    m_frozen_sp = ValueObjectConstResult::Create (exe_scope, byte_order, addr_byte_size);
 }
 
 ClangExpressionVariable::ClangExpressionVariable (ExecutionContextScope *exe_scope,
                                                   Value &value,
                                                   const ConstString &name,
                                                   uint16_t flags) :
+    ExpressionVariable(),
     m_parser_vars(),
-    m_jit_vars (),
-    m_flags (flags),
-    m_frozen_sp (ValueObjectConstResult::Create (exe_scope, value, name))
+    m_jit_vars ()
 {
+    m_flags = flags;
+    m_frozen_sp = ValueObjectConstResult::Create (exe_scope, value, name);
 }
 
 ClangExpressionVariable::ClangExpressionVariable (const lldb::ValueObjectSP &valobj_sp) :
+    ExpressionVariable(),
     m_parser_vars(),
-    m_jit_vars (),
-    m_flags (EVNone),
-    m_frozen_sp (valobj_sp)
+    m_jit_vars ()
 {
+    m_flags = EVNone;
+    m_frozen_sp = valobj_sp;
 }
 
-//----------------------------------------------------------------------
-/// Return the variable's size in bytes
-//----------------------------------------------------------------------
-size_t
-ClangExpressionVariable::GetByteSize ()
-{
-    return m_frozen_sp->GetByteSize();
-}
-
-const ConstString &
-ClangExpressionVariable::GetName ()
-{
-    return m_frozen_sp->GetName();
-}
-
-lldb::ValueObjectSP
-ClangExpressionVariable::GetValueObject()
-{
-    return m_frozen_sp;
-}
-
-RegisterInfo *
-ClangExpressionVariable::GetRegisterInfo()
-{
-    return m_frozen_sp->GetValue().GetRegisterInfo();
-}
-
-void
-ClangExpressionVariable::SetRegisterInfo (const RegisterInfo *reg_info)
-{
-    return m_frozen_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_info));
-}
-
-CompilerType
-ClangExpressionVariable::GetCompilerType()
-{
-    return m_frozen_sp->GetCompilerType();
-}
-
-void
-ClangExpressionVariable::SetCompilerType(const CompilerType &clang_type)
-{
-    m_frozen_sp->GetValue().SetCompilerType(clang_type);
-}
-
-
 TypeFromUser
 ClangExpressionVariable::GetTypeFromUser()
 {
     TypeFromUser tfu (m_frozen_sp->GetCompilerType());
     return tfu;
 }
-
-uint8_t *
-ClangExpressionVariable::GetValueBytes()
-{
-    const size_t byte_size = m_frozen_sp->GetByteSize();
-    if (byte_size > 0)
-    {
-        if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size)
-        {
-            m_frozen_sp->GetValue().ResizeData(byte_size);
-            m_frozen_sp->GetValue().GetData (m_frozen_sp->GetDataExtractor());
-        }
-        return const_cast<uint8_t *>(m_frozen_sp->GetDataExtractor().GetDataStart());
-    }
-    return NULL;
-}
-
-void
-ClangExpressionVariable::SetName (const ConstString &name)
-{
-    m_frozen_sp->SetName (name);
-}
-
-void
-ClangExpressionVariable::ValueUpdated ()
-{
-    m_frozen_sp->ValueUpdated ();
-}
-
-void
-ClangExpressionVariable::TransferAddress (bool force)
-{
-    if (m_live_sp.get() == NULL)
-        return;
-
-    if (m_frozen_sp.get() == NULL)
-        return;
-
-    if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
-        m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());
-}
Index: source/Expression/Materializer.cpp
===================================================================
--- source/Expression/Materializer.cpp
+++ source/Expression/Materializer.cpp
@@ -66,7 +66,7 @@
 class EntityPersistentVariable : public Materializer::Entity
 {
 public:
-    EntityPersistentVariable (lldb::ClangExpressionVariableSP &persistent_variable_sp) :
+    EntityPersistentVariable (lldb::ExpressionVariableSP &persistent_variable_sp) :
         Entity(),
         m_persistent_variable_sp(persistent_variable_sp)
     {
@@ -99,9 +99,9 @@
             log->Printf("Allocated %s (0x%" PRIx64 ") successfully", m_persistent_variable_sp->GetName().GetCString(), mem);
         
         // Put the location of the spare memory into the live data of the ValueObject.
-                
+        
         m_persistent_variable_sp->m_live_sp = ValueObjectConstResult::Create (map.GetBestExecutionContextScope(),
-                                                                              m_persistent_variable_sp->GetTypeFromUser(),
+                                                                              m_persistent_variable_sp->AsClangExpressionVariable()->GetTypeFromUser(),
                                                                               m_persistent_variable_sp->GetName(),
                                                                               mem,
                                                                               eAddressTypeLoad,
@@ -230,9 +230,9 @@
                     err.SetErrorStringWithFormat("couldn't read the address of program-allocated variable %s: %s", m_persistent_variable_sp->GetName().GetCString(), read_error.AsCString());
                     return;
                 }
-                                
+                
                 m_persistent_variable_sp->m_live_sp = ValueObjectConstResult::Create (map.GetBestExecutionContextScope (),
-                                                                                      m_persistent_variable_sp->GetTypeFromUser(),
+                                                                                      m_persistent_variable_sp->AsClangExpressionVariable()->GetTypeFromUser(),
                                                                                       m_persistent_variable_sp->GetName(),
                                                                                       location,
                                                                                       eAddressTypeLoad,
@@ -390,11 +390,11 @@
     {
     }
 private:
-    lldb::ClangExpressionVariableSP m_persistent_variable_sp;
+    lldb::ExpressionVariableSP m_persistent_variable_sp;
 };
 
 uint32_t
-Materializer::AddPersistentVariable (lldb::ClangExpressionVariableSP &persistent_variable_sp, Error &err)
+Materializer::AddPersistentVariable (lldb::ExpressionVariableSP &persistent_variable_sp, Error &err)
 {
     EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
     iter->reset (new EntityPersistentVariable (persistent_variable_sp));
@@ -820,7 +820,7 @@
         err.SetErrorString("Tried to detmaterialize a result variable with the normal Dematerialize method");
     }
     
-    void Dematerialize (lldb::ClangExpressionVariableSP &result_variable_sp,
+    void Dematerialize (lldb::ExpressionVariableSP &result_variable_sp,
                         lldb::StackFrameSP &frame_sp,
                         IRMemoryMap &map,
                         lldb::addr_t process_address,
@@ -860,14 +860,13 @@
         
         ConstString name = target_sp->GetPersistentVariables().GetNextPersistentVariableName();
         
-        lldb::ClangExpressionVariableSP ret;
+        lldb::ExpressionVariableSP ret = ClangExpressionVariable::CreateVariableInList(target_sp->GetPersistentVariables(),
+                                                                                       exe_scope,
+                                                                                       name,
+                                                                                       m_type,
+                                                                                       map.GetByteOrder(),
+                                                                                       map.GetAddressByteSize())->shared_from_this();
         
-        ret = target_sp->GetPersistentVariables().CreateVariable(exe_scope,
-                                                                 name,
-                                                                 m_type,
-                                                                 map.GetByteOrder(),
-                                                                 map.GetAddressByteSize());
-        
         if (!ret)
         {
             err.SetErrorStringWithFormat("couldn't dematerialize a result variable: failed to make persistent variable %s", name.AsCString());
@@ -1395,7 +1394,7 @@
 }
 
 void
-Materializer::Dematerializer::Dematerialize (Error &error, lldb::ClangExpressionVariableSP &result_sp, lldb::addr_t frame_bottom, lldb::addr_t frame_top)
+Materializer::Dematerializer::Dematerialize (Error &error, lldb::ExpressionVariableSP &result_sp, lldb::addr_t frame_bottom, lldb::addr_t frame_top)
 {
     lldb::StackFrameSP frame_sp;
 
Index: source/Expression/ExpressionVariable.cpp
===================================================================
--- source/Expression/ExpressionVariable.cpp
+++ source/Expression/ExpressionVariable.cpp
@@ -9,3 +9,24 @@
 
 #include "lldb/Expression/ExpressionVariable.h"
 
+using namespace lldb_private;
+
+ExpressionVariable::~ExpressionVariable()
+{
+}
+
+uint8_t *
+ExpressionVariable::GetValueBytes()
+{
+    const size_t byte_size = m_frozen_sp->GetByteSize();
+    if (byte_size > 0)
+    {
+        if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size)
+        {
+            m_frozen_sp->GetValue().ResizeData(byte_size);
+            m_frozen_sp->GetValue().GetData (m_frozen_sp->GetDataExtractor());
+        }
+        return const_cast<uint8_t *>(m_frozen_sp->GetDataExtractor().GetDataStart());
+    }
+    return NULL;
+}
\ No newline at end of file
Index: source/Expression/ClangUserExpression.cpp
===================================================================
--- source/Expression/ClangUserExpression.cpp
+++ source/Expression/ClangUserExpression.cpp
@@ -797,7 +797,7 @@
 bool
 ClangUserExpression::FinalizeJITExecution (Stream &error_stream,
                                            ExecutionContext &exe_ctx,
-                                           lldb::ClangExpressionVariableSP &result,
+                                           lldb::ExpressionVariableSP &result,
                                            lldb::addr_t function_stack_bottom,
                                            lldb::addr_t function_stack_top)
 {
@@ -835,7 +835,7 @@
                               ExecutionContext &exe_ctx,
                               const EvaluateExpressionOptions& options,
                               lldb::ClangUserExpressionSP &shared_ptr_to_me,
-                              lldb::ClangExpressionVariableSP &result)
+                              lldb::ExpressionVariableSP &result)
 {
     // The expression log is quite verbose, and if you're just tracking the execution of the
     // expression, it's quite convenient to have these logs come out with the STEP log as well.
@@ -1090,7 +1090,7 @@
     }
     else
     {
-        lldb::ClangExpressionVariableSP expr_result;
+        lldb::ExpressionVariableSP expr_result;
 
         if (execution_policy == eExecutionPolicyNever &&
             !user_expression_sp->CanInterpret())
Index: source/Expression/ClangPersistentVariables.cpp
===================================================================
--- source/Expression/ClangPersistentVariables.cpp
+++ source/Expression/ClangPersistentVariables.cpp
@@ -19,35 +19,35 @@
 using namespace lldb_private;
 
 ClangPersistentVariables::ClangPersistentVariables () :
-    ClangExpressionVariableList(),
+    ExpressionVariableList(),
     m_next_persistent_variable_id (0)
 {
 }
 
-ClangExpressionVariableSP
+ExpressionVariableSP
 ClangPersistentVariables::CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp)
 {
-    ClangExpressionVariableSP var_sp (CreateVariable(valobj_sp));
+    ExpressionVariableSP var_sp (ClangExpressionVariable::CreateVariableInList(*this, valobj_sp));
     return var_sp;
 }
 
-ClangExpressionVariableSP
+ClangExpressionVariable *
 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));
+    ExpressionVariableSP var_sp (GetVariable(name));
     
     if (!var_sp)
-        var_sp = CreateVariable(exe_scope, name, user_type, byte_order, addr_byte_size);
+        var_sp = ClangExpressionVariable::CreateVariableInList(*this, exe_scope, name, user_type, byte_order, addr_byte_size)->shared_from_this();
 
-    return var_sp;
+    return var_sp->AsClangExpressionVariable();
 }
 
 void
-ClangPersistentVariables::RemovePersistentVariable (lldb::ClangExpressionVariableSP variable)
+ClangPersistentVariables::RemovePersistentVariable (lldb::ExpressionVariableSP variable)
 {
     RemoveVariable(variable);
     
Index: source/Expression/ClangExpressionDeclMap.cpp
===================================================================
--- source/Expression/ClangExpressionDeclMap.cpp
+++ source/Expression/ClangExpressionDeclMap.cpp
@@ -132,18 +132,18 @@
              entity_index < num_entities;
              ++entity_index)
         {
-            ClangExpressionVariableSP var_sp(m_found_entities.GetVariableAtIndex(entity_index));
+            ExpressionVariableSP var_sp(m_found_entities.GetVariableAtIndex(entity_index));
             if (var_sp)
-                var_sp->DisableParserVars(GetParserID());
+                var_sp->AsClangExpressionVariable()->DisableParserVars(GetParserID());
         }
 
         for (size_t pvar_index = 0, num_pvars = m_parser_vars->m_persistent_vars->GetSize();
              pvar_index < num_pvars;
              ++pvar_index)
         {
-            ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
+            ExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
             if (pvar_sp)
-                pvar_sp->DisableParserVars(GetParserID());
+                pvar_sp->AsClangExpressionVariable()->DisableParserVars(GetParserID());
         }
 
         DisableParserVars();
@@ -210,25 +210,26 @@
 
         uint32_t offset = m_parser_vars->m_materializer->AddResultVariable(user_type, is_lvalue, m_keep_result_in_memory, err);
 
-        ClangExpressionVariableSP var_sp = m_found_entities.CreateVariable(exe_ctx.GetBestExecutionContextScope(),
-                                                                           name,
-                                                                           user_type,
-                                                                           m_parser_vars->m_target_info.byte_order,
-                                                                           m_parser_vars->m_target_info.address_byte_size);
+        ClangExpressionVariable *var = ClangExpressionVariable::CreateVariableInList(m_found_entities,
+                                                                                     exe_ctx.GetBestExecutionContextScope(),
+                                                                                     name,
+                                                                                     user_type,
+                                                                                     m_parser_vars->m_target_info.byte_order,
+                                                                                     m_parser_vars->m_target_info.address_byte_size);
 
-        if (!var_sp)
+        if (!var)
             return false;
 
-        var_sp->EnableParserVars(GetParserID());
+        var->EnableParserVars(GetParserID());
 
-        ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+        ClangExpressionVariable::ParserVars *parser_vars = var->GetParserVars(GetParserID());
 
         parser_vars->m_named_decl = decl;
         parser_vars->m_parser_type = parser_type;
 
-        var_sp->EnableJITVars(GetParserID());
+        var->EnableJITVars(GetParserID());
 
-        ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID());
+        ClangExpressionVariable::JITVars *jit_vars = var->GetJITVars(GetParserID());
 
         jit_vars->m_offset = offset;
 
@@ -258,43 +259,43 @@
     if (!m_parser_vars->m_target_info.IsValid())
         return false;
 
-    ClangExpressionVariableSP var_sp = m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx.GetBestExecutionContextScope (),
-                                                                                                   name,
-                                                                                                   user_type,
-                                                                                                   m_parser_vars->m_target_info.byte_order,
-                                                                                                   m_parser_vars->m_target_info.address_byte_size);
+    ClangExpressionVariable *var = m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx.GetBestExecutionContextScope (),
+                                                                                               name,
+                                                                                               user_type,
+                                                                                               m_parser_vars->m_target_info.byte_order,
+                                                                                               m_parser_vars->m_target_info.address_byte_size);
 
-    if (!var_sp)
+    if (!var)
         return false;
 
-    var_sp->m_frozen_sp->SetHasCompleteType();
+    var->m_frozen_sp->SetHasCompleteType();
 
     if (is_result)
-        var_sp->m_flags |= ClangExpressionVariable::EVNeedsFreezeDry;
+        var->m_flags |= ClangExpressionVariable::EVNeedsFreezeDry;
     else
-        var_sp->m_flags |= ClangExpressionVariable::EVKeepInTarget; // explicitly-declared persistent variables should persist
+        var->m_flags |= ClangExpressionVariable::EVKeepInTarget; // explicitly-declared persistent variables should persist
 
     if (is_lvalue)
     {
-        var_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;
+        var->m_flags |= ClangExpressionVariable::EVIsProgramReference;
     }
     else
     {
-        var_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
-        var_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
+        var->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
+        var->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
     }
 
     if (m_keep_result_in_memory)
     {
-        var_sp->m_flags |= ClangExpressionVariable::EVKeepInTarget;
+        var->m_flags |= ClangExpressionVariable::EVKeepInTarget;
     }
 
     if (log)
-        log->Printf("Created persistent variable with flags 0x%hx", var_sp->m_flags);
+        log->Printf("Created persistent variable with flags 0x%hx", var->m_flags);
 
-    var_sp->EnableParserVars(GetParserID());
+    var->EnableParserVars(GetParserID());
 
-    ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+    ClangExpressionVariable::ParserVars *parser_vars = var->GetParserVars(GetParserID());
 
     parser_vars->m_named_decl = decl;
     parser_vars->m_parser_type = parser_type;
@@ -321,14 +322,14 @@
 
     m_struct_vars->m_struct_laid_out = false;
 
-    if (m_struct_members.GetVariable(decl, GetParserID()))
+    if (ClangExpressionVariable::FindVariableInList(m_struct_members, decl, GetParserID()))
         return true;
 
-    ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl, GetParserID()));
+    ExpressionVariableSP var_sp (ClangExpressionVariable::FindVariableInList(m_found_entities, decl, GetParserID()));
 
     if (!var_sp)
     {
-        var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl, GetParserID());
+        var_sp = ClangExpressionVariable::FindVariableInList(*m_parser_vars->m_persistent_vars, decl, GetParserID());
         is_persistent_variable = true;
     }
 
@@ -343,11 +344,11 @@
     // We know entity->m_parser_vars is valid because we used a parser variable
     // to find it
 
-    ClangExpressionVariable::ParserVars *parser_vars = var_sp->GetParserVars(GetParserID());
+    ClangExpressionVariable::ParserVars *parser_vars = var_sp->AsClangExpressionVariable()->GetParserVars(GetParserID());
 
     parser_vars->m_llvm_value = value;
 
-    if (ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID()))
+    if (ClangExpressionVariable::JITVars *jit_vars = var_sp->AsClangExpressionVariable()->GetJITVars(GetParserID()))
     {
         // We already laid this out; do not touch
 
@@ -355,9 +356,9 @@
             log->Printf("Already placed at 0x%llx", (unsigned long long)jit_vars->m_offset);
     }
 
-    var_sp->EnableJITVars(GetParserID());
+    var_sp->AsClangExpressionVariable()->EnableJITVars(GetParserID());
 
-    ClangExpressionVariable::JITVars *jit_vars = var_sp->GetJITVars(GetParserID());
+    ClangExpressionVariable::JITVars *jit_vars = var_sp->AsClangExpressionVariable()->GetJITVars(GetParserID());
 
     jit_vars->m_alignment = alignment;
     jit_vars->m_size = size;
@@ -450,13 +451,13 @@
     if (index >= m_struct_members.GetSize())
         return false;
 
-    ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
+    ExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
 
     if (!member_sp)
         return false;
 
-    ClangExpressionVariable::ParserVars *parser_vars = member_sp->GetParserVars(GetParserID());
-    ClangExpressionVariable::JITVars *jit_vars = member_sp->GetJITVars(GetParserID());
+    ClangExpressionVariable::ParserVars *parser_vars = member_sp->AsClangExpressionVariable()->GetParserVars(GetParserID());
+    ClangExpressionVariable::JITVars *jit_vars = member_sp->AsClangExpressionVariable()->GetJITVars(GetParserID());
 
     if (!parser_vars ||
         !jit_vars ||
@@ -478,7 +479,7 @@
     uint64_t &ptr
 )
 {
-    ClangExpressionVariableSP entity_sp(m_found_entities.GetVariable(decl, GetParserID()));
+    ExpressionVariableSP entity_sp(ClangExpressionVariable::FindVariableInList(m_found_entities, decl, GetParserID()));
 
     if (!entity_sp)
         return false;
@@ -486,7 +487,7 @@
     // We know m_parser_vars is valid since we searched for the variable by
     // its NamedDecl
 
-    ClangExpressionVariable::ParserVars *parser_vars = entity_sp->GetParserVars(GetParserID());
+    ClangExpressionVariable::ParserVars *parser_vars = entity_sp->AsClangExpressionVariable()->GetParserVars(GetParserID());
 
     ptr = parser_vars->m_lldb_value.GetScalar().ULongLong();
 
@@ -1288,7 +1289,7 @@
             context.AddNamedDecl(parser_ptype_type_decl);
         } while (0);
 
-        ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariable(name));
+        ExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariable(name));
 
         if (pvar_sp)
         {
@@ -1744,9 +1745,9 @@
 
     std::string decl_name(context.m_decl_name.getAsString());
     ConstString entity_name(decl_name.c_str());
-    ClangExpressionVariableSP entity(m_found_entities.CreateVariable (valobj));
+    ClangExpressionVariable *entity(ClangExpressionVariable::CreateVariableInList(m_found_entities, valobj));
 
-    assert (entity.get());
+    assert (entity);
     entity->EnableParserVars(GetParserID());
     ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
     parser_vars->m_parser_type = pt;
@@ -1768,12 +1769,12 @@
 
 void
 ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
-                                       ClangExpressionVariableSP &pvar_sp,
+                                       ExpressionVariableSP &pvar_sp,
                                        unsigned int current_id)
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
-    TypeFromUser user_type (pvar_sp->GetTypeFromUser());
+    TypeFromUser user_type (pvar_sp->AsClangExpressionVariable()->GetTypeFromUser());
 
     TypeFromParser parser_type (GuardedCopyType(user_type));
 
@@ -1786,8 +1787,8 @@
 
     NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::GetLValueReferenceType(parser_type));
 
-    pvar_sp->EnableParserVars(GetParserID());
-    ClangExpressionVariable::ParserVars *parser_vars = pvar_sp->GetParserVars(GetParserID());
+    pvar_sp->AsClangExpressionVariable()->EnableParserVars(GetParserID());
+    ClangExpressionVariable::ParserVars *parser_vars = pvar_sp->AsClangExpressionVariable()->GetParserVars(GetParserID());
     parser_vars->m_parser_type = parser_type;
     parser_vars->m_named_decl = var_decl;
     parser_vars->m_llvm_value = NULL;
@@ -1822,12 +1823,13 @@
 
     std::string decl_name(context.m_decl_name.getAsString());
     ConstString entity_name(decl_name.c_str());
-    ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
-                                                                      entity_name,
-                                                                      user_type,
-                                                                      m_parser_vars->m_target_info.byte_order,
-                                                                      m_parser_vars->m_target_info.address_byte_size));
-    assert (entity.get());
+    ClangExpressionVariable *entity(ClangExpressionVariable::CreateVariableInList(m_found_entities,
+                                                                                  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
+                                                                                  entity_name,
+                                                                                  user_type,
+                                                                                  m_parser_vars->m_target_info.byte_order,
+                                                                                  m_parser_vars->m_target_info.address_byte_size));
+    assert (entity);
 
     entity->EnableParserVars(GetParserID());
     ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
@@ -1865,9 +1867,9 @@
          index < num_entities;
          ++index)
     {
-        ClangExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
+        ExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
 
-        ClangExpressionVariable::ParserVars *parser_vars = entity->GetParserVars(GetParserID());
+        ClangExpressionVariable::ParserVars *parser_vars = entity->AsClangExpressionVariable()->GetParserVars(GetParserID());
 
         if (entity->m_flags & ClangExpressionVariable::EVUnknownType)
         {
@@ -1897,7 +1899,7 @@
                 if (log)
                     log->Printf("ClangExpressionDeclMap::ResolveUnknownType - Couldn't import the type for a variable");
 
-                return (bool) lldb::ClangExpressionVariableSP();
+                return (bool) lldb::ExpressionVariableSP();
             }
 
             TypeFromUser user_type(copied_type, scratch_ast_context);
@@ -1937,10 +1939,11 @@
 
     NamedDecl *var_decl = context.AddVarDecl(parser_clang_type);
 
-    ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
-                                                                      m_parser_vars->m_target_info.byte_order,
-                                                                      m_parser_vars->m_target_info.address_byte_size));
-    assert (entity.get());
+    ClangExpressionVariable *entity(ClangExpressionVariable::CreateVariableInList(m_found_entities,
+                                                                                  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
+                                                                                  m_parser_vars->m_target_info.byte_order,
+                                                                                  m_parser_vars->m_target_info.address_byte_size));
+    assert (entity);
 
     std::string decl_name(context.m_decl_name.getAsString());
     entity->SetName (ConstString (decl_name.c_str()));
@@ -2045,10 +2048,11 @@
 
     lldb::addr_t load_addr = fun_address.GetCallableLoadAddress(target, is_indirect_function);
 
-    ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
-                                                                      m_parser_vars->m_target_info.byte_order,
-                                                                      m_parser_vars->m_target_info.address_byte_size));
-    assert (entity.get());
+    ClangExpressionVariable *entity(ClangExpressionVariable::CreateVariableInList (m_found_entities,
+                                                                                   m_parser_vars->m_exe_ctx.GetBestExecutionContextScope (),
+                                                                                   m_parser_vars->m_target_info.byte_order,
+                                                                                   m_parser_vars->m_target_info.address_byte_size));
+    assert (entity);
 
     std::string decl_name(context.m_decl_name.getAsString());
     entity->SetName(ConstString(decl_name.c_str()));
Index: source/Core/ValueObject.cpp
===================================================================
--- source/Core/ValueObject.cpp
+++ source/Core/ValueObject.cpp
@@ -4280,7 +4280,7 @@
     
     ConstString name(target_sp->GetPersistentVariables().GetNextPersistentVariableName());
     
-    ClangExpressionVariableSP clang_var_sp(new ClangExpressionVariable(target_sp.get(), GetValue(), name));
+    ExpressionVariableSP clang_var_sp(new ClangExpressionVariable(target_sp.get(), GetValue(), name));
     if (clang_var_sp)
     {
         clang_var_sp->m_live_sp = clang_var_sp->m_frozen_sp;
Index: source/Core/FormatEntity.cpp
===================================================================
--- source/Core/FormatEntity.cpp
+++ source/Core/FormatEntity.cpp
@@ -1437,7 +1437,7 @@
                     StopInfoSP stop_info_sp = thread->GetStopInfo ();
                     if (stop_info_sp && stop_info_sp->IsValid())
                     {
-                        ClangExpressionVariableSP expression_var_sp = StopInfo::GetExpressionVariable (stop_info_sp);
+                        ExpressionVariableSP expression_var_sp = StopInfo::GetExpressionVariable (stop_info_sp);
                         if (expression_var_sp && expression_var_sp->GetValueObject())
                         {
                             expression_var_sp->GetValueObject()->Dump(s);
Index: source/Breakpoint/BreakpointLocation.cpp
===================================================================
--- source/Breakpoint/BreakpointLocation.cpp
+++ source/Breakpoint/BreakpointLocation.cpp
@@ -314,7 +314,7 @@
     
     StreamString execution_errors;
     
-    ClangExpressionVariableSP result_variable_sp;
+    ExpressionVariableSP result_variable_sp;
     
     ExpressionResults result_code =
     m_user_expression_sp->Execute(execution_errors,
Index: source/API/SBFrame.cpp
===================================================================
--- source/API/SBFrame.cpp
+++ source/API/SBFrame.cpp
@@ -956,7 +956,7 @@
                 case eValueTypeConstResult:         // constant result variables
                     {
                         ConstString const_name(name);
-                        ClangExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name));
+                        ExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name));
                         if (expr_var_sp)
                         {
                             value_sp = expr_var_sp->GetValueObject();
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to