<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">The way I understand this from talking with Sean about it is that the persistent variables for each type system will need to generate non-conflicting names</div><div class=""><br class=""></div><div class="">In your example,</div><div class=""><br class=""></div><div class="">(lldb) expr -l c — 1</div><div class="">$1 = 1</div><div class="">(lldb) expr -l go — 2</div><div class="">$G1 = 2</div><div class="">(lldb) expr -l go — $1</div><div class="">Identifier ‘$1’ not recognized (or whatever equivalent error Go would produce, unless you had somehow gotten Go and Clang to interop with each other in a smart way)</div><div class=""><br class=""></div><div class="">But that is simply my understanding</div><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 1, 2015, at 11:15 AM, Ryan Brown via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" class="">lldb-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Oh, now I see the search in 249027.<div class="">But how does this work with multiple type systems?</div><div class="">Target no longer manages persistent variable names so won't each type system generate conflicting names? </div><div class="">e.g.</div><div class="">(lldb) expr -l c -- 1</div><div class="">$1 = 1</div><div class="">(lldb) expr -l go -- 2</div><div class="">$1 = 2</div><div class="">(lldb) expr -l go -- $1</div><div class=""><br class=""></div><div class="">Which $1 do you get?</div><div class=""><br class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Oct 1, 2015 at 10:59 AM Ryan Brown <<a href="mailto:ribrdb@google.com" target="_blank" class="">ribrdb@google.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Shouldn't Target::GetPersistentVariable take a language parameter instead of assuming clang?</div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Sep 30, 2015 at 12:59 PM Sean Callanan via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" target="_blank" class="">lldb-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: spyffe<br class="">
Date: Wed Sep 30 14:57:57 2015<br class="">
New Revision: 248934<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=248934&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=248934&view=rev</a><br class="">
Log:<br class="">
Now persistent expression data no longer lives with the Target, but rather with<br class="">
the corresponding TypeSystem.  This makes sense because what kind of data there<br class="">
is -- and how it can be looked up -- depends on the language.<br class="">
<br class="">
Functionality that is common to all type systems is factored out into<br class="">
PersistentExpressionState.<br class="">
<br class="">
Modified:<br class="">
    lldb/trunk/include/lldb/Expression/ExpressionVariable.h<br class="">
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h<br class="">
    lldb/trunk/include/lldb/Symbol/TypeSystem.h<br class="">
    lldb/trunk/include/lldb/Target/Target.h<br class="">
    lldb/trunk/include/lldb/lldb-forward.h<br class="">
    lldb/trunk/source/API/SBFrame.cpp<br class="">
    lldb/trunk/source/Commands/CommandObjectMemory.cpp<br class="">
    lldb/trunk/source/Core/ValueObject.cpp<br class="">
    lldb/trunk/source/Expression/ExpressionSourceCode.cpp<br class="">
    lldb/trunk/source/Expression/ExpressionVariable.cpp<br class="">
    lldb/trunk/source/Expression/Materializer.cpp<br class="">
    lldb/trunk/source/Expression/UserExpression.cpp<br class="">
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp<br class="">
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp<br class="">
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp<br class="">
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp<br class="">
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h<br class="">
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp<br class="">
    lldb/trunk/source/Symbol/ClangASTContext.cpp<br class="">
    lldb/trunk/source/Target/ABI.cpp<br class="">
    lldb/trunk/source/Target/Target.cpp<br class="">
<br class="">
Modified: lldb/trunk/include/lldb/Expression/ExpressionVariable.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionVariable.h?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionVariable.h?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/include/lldb/Expression/ExpressionVariable.h (original)<br class="">
+++ lldb/trunk/include/lldb/Expression/ExpressionVariable.h Wed Sep 30 14:57:57 2015<br class="">
@@ -265,6 +265,36 @@ private:<br class="">
     std::vector <lldb::ExpressionVariableSP> m_variables;<br class="">
 };<br class="">
<br class="">
+class PersistentExpressionState : public ExpressionVariableList {<br class="">
+public:<br class="">
+    //----------------------------------------------------------------------<br class="">
+    // See TypeSystem.h for how to add subclasses to this.<br class="">
+    //----------------------------------------------------------------------<br class="">
+    enum LLVMCastKind {<br class="">
+        eKindClang,<br class="">
+        eKindSwift,<br class="">
+        eKindGo,<br class="">
+        kNumKinds<br class="">
+    };<br class="">
+<br class="">
+    LLVMCastKind getKind() const { return m_kind; }<br class="">
+<br class="">
+    PersistentExpressionState(LLVMCastKind kind) :<br class="">
+        m_kind(kind)<br class="">
+    {<br class="">
+    }<br class="">
+<br class="">
+    virtual ~PersistentExpressionState ();<br class="">
+<br class="">
+    virtual ConstString<br class="">
+    GetNextPersistentVariableName () = 0;<br class="">
+<br class="">
+    virtual void<br class="">
+    RemovePersistentVariable (lldb::ExpressionVariableSP variable) = 0;<br class="">
+private:<br class="">
+    LLVMCastKind m_kind;<br class="">
+};<br class="">
+<br class="">
 }<br class="">
<br class="">
 #endif /* liblldb_ExpressionVariable_h_ */<br class="">
<br class="">
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)<br class="">
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Wed Sep 30 14:57:57 2015<br class="">
@@ -20,6 +20,8 @@<br class="">
 #include <utility><br class="">
<br class="">
 // Other libraries and framework includes<br class="">
+#include "ClangPersistentVariables.h"<br class="">
+<br class="">
 #include "llvm/ADT/SmallVector.h"<br class="">
 #include "clang/AST/ASTContext.h"<br class="">
 #include "clang/AST/TemplateBase.h"<br class="">
@@ -1188,8 +1190,12 @@ public:<br class="">
<br class="">
     UtilityFunction *<br class="">
     GetUtilityFunction(const char *text, const char *name) override;<br class="">
+<br class="">
+    PersistentExpressionState *<br class="">
+    GetPersistentExpressionState() override;<br class="">
 private:<br class="">
     lldb::TargetWP m_target_wp;<br class="">
+    lldb::ClangPersistentVariablesUP m_persistent_variables;      ///< These are the persistent variables associated with this process for the expression parser.<br class="">
 };<br class="">
<br class="">
 } // namespace lldb_private<br class="">
<br class="">
Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)<br class="">
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Wed Sep 30 14:57:57 2015<br class="">
@@ -504,6 +504,12 @@ public:<br class="">
         return nullptr;<br class="">
     }<br class="">
<br class="">
+    virtual PersistentExpressionState *<br class="">
+    GetPersistentExpressionState()<br class="">
+    {<br class="">
+        return nullptr;<br class="">
+    }<br class="">
+<br class="">
     virtual CompilerType<br class="">
     GetTypeForFormatters (void* type);<br class="">
<br class="">
<br class="">
Modified: lldb/trunk/include/lldb/Target/Target.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/include/lldb/Target/Target.h (original)<br class="">
+++ lldb/trunk/include/lldb/Target/Target.h Wed Sep 30 14:57:57 2015<br class="">
@@ -1319,9 +1319,9 @@ public:<br class="">
                         lldb::ValueObjectSP &result_valobj_sp,<br class="">
                         const EvaluateExpressionOptions& options = EvaluateExpressionOptions());<br class="">
<br class="">
-    ClangPersistentVariables &<br class="">
-    GetPersistentVariables();<br class="">
-<br class="">
+    lldb::ExpressionVariableSP<br class="">
+    GetPersistentVariable(const ConstString &name);<br class="">
+<br class="">
     //------------------------------------------------------------------<br class="">
     // Target Stop Hooks<br class="">
     //------------------------------------------------------------------<br class="">
@@ -1523,7 +1523,6 @@ protected:<br class="">
     lldb::ClangASTSourceUP m_scratch_ast_source_ap;<br class="">
     lldb::ClangASTImporterUP m_ast_importer_ap;<br class="">
     lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_ap;<br class="">
-    lldb::ClangPersistentVariablesUP m_persistent_variables;      ///< These are the persistent variables associated with this process for the expression parser.<br class="">
<br class="">
     lldb::SourceManagerUP m_source_manager_ap;<br class="">
<br class="">
<br class="">
Modified: lldb/trunk/include/lldb/lldb-forward.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/include/lldb/lldb-forward.h (original)<br class="">
+++ lldb/trunk/include/lldb/lldb-forward.h Wed Sep 30 14:57:57 2015<br class="">
@@ -165,6 +165,7 @@ class   OptionValueUUID;<br class="">
 class   NamedOption;<br class="">
 class   PathMappingList;<br class="">
 class   FunctionCaller;<br class="">
+class   PersistentExpressionState;<br class="">
 class   Platform;<br class="">
 class   Process;<br class="">
 class   ProcessAttachInfo;<br class="">
<br class="">
Modified: lldb/trunk/source/API/SBFrame.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/API/SBFrame.cpp (original)<br class="">
+++ lldb/trunk/source/API/SBFrame.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -956,7 +956,7 @@ SBFrame::FindValue (const char *name, Va<br class="">
                 case eValueTypeConstResult:         // constant result variables<br class="">
                     {<br class="">
                         ConstString const_name(name);<br class="">
-                        ExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name));<br class="">
+                        ExpressionVariableSP expr_var_sp (target->GetPersistentVariable (const_name));<br class="">
                         if (expr_var_sp)<br class="">
                         {<br class="">
                             value_sp = expr_var_sp->GetValueObject();<br class="">
<br class="">
Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)<br class="">
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -530,7 +530,7 @@ protected:<br class="">
<br class="">
             if (type_list.GetSize() == 0 && lookup_type_name.GetCString() && *lookup_type_name.GetCString() == '$')<br class="">
             {<br class="">
-                clang::TypeDecl *tdecl = target->GetPersistentVariables().GetPersistentType(ConstString(lookup_type_name));<br class="">
+                clang::TypeDecl *tdecl = llvm::cast<ClangPersistentVariables>(target->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState())->GetPersistentType(ConstString(lookup_type_name));<br class="">
                 if (tdecl)<br class="">
                 {<br class="">
                     clang_ast_type.SetCompilerType(ClangASTContext::GetASTContext(&tdecl->getASTContext()),(const lldb::opaque_compiler_type_t)tdecl->getTypeForDecl());<br class="">
<br class="">
Modified: lldb/trunk/source/Core/ValueObject.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Core/ValueObject.cpp (original)<br class="">
+++ lldb/trunk/source/Core/ValueObject.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -4277,14 +4277,19 @@ ValueObject::Persist ()<br class="">
     if (!target_sp)<br class="">
         return nullptr;<br class="">
<br class="">
-    ConstString name(target_sp->GetPersistentVariables().GetNextPersistentVariableName());<br class="">
+    PersistentExpressionState *persistent_state = target_sp->GetScratchTypeSystemForLanguage(GetCompilerType().GetMinimumLanguage())->GetPersistentExpressionState();<br class="">
+<br class="">
+    if (!persistent_state)<br class="">
+        return nullptr;<br class="">
+<br class="">
+    ConstString name(persistent_state->GetNextPersistentVariableName());<br class="">
<br class="">
     ExpressionVariableSP clang_var_sp(new ClangExpressionVariable(target_sp.get(), GetValue(), name));<br class="">
     if (clang_var_sp)<br class="">
     {<br class="">
         clang_var_sp->m_live_sp = clang_var_sp->m_frozen_sp;<br class="">
         clang_var_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;<br class="">
-        target_sp->GetPersistentVariables().AddVariable(clang_var_sp);<br class="">
+        persistent_state->AddVariable(clang_var_sp);<br class="">
     }<br class="">
<br class="">
     return clang_var_sp->GetValueObject();<br class="">
<br class="">
Modified: lldb/trunk/source/Expression/ExpressionSourceCode.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionSourceCode.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionSourceCode.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Expression/ExpressionSourceCode.cpp (original)<br class="">
+++ lldb/trunk/source/Expression/ExpressionSourceCode.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -13,6 +13,7 @@<br class="">
 #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"<br class="">
 #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"<br class="">
 #include "lldb/Symbol/Block.h"<br class="">
+#include "lldb/Symbol/TypeSystem.h"<br class="">
 #include "lldb/Target/ExecutionContext.h"<br class="">
 #include "lldb/Target/Platform.h"<br class="">
 #include "lldb/Target/StackFrame.h"<br class="">
@@ -82,7 +83,8 @@ bool ExpressionSourceCode::GetText (std:<br class="">
<br class="">
         if (ClangModulesDeclVendor *decl_vendor = target->GetClangModulesDeclVendor())<br class="">
         {<br class="">
-            const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = target->GetPersistentVariables().GetHandLoadedClangModules();<br class="">
+            ClangPersistentVariables *persistent_vars = llvm::cast<ClangPersistentVariables>(target->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState());<br class="">
+            const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = persistent_vars->GetHandLoadedClangModules();<br class="">
             ClangModulesDeclVendor::ModuleVector modules_for_macros;<br class="">
<br class="">
             for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules)<br class="">
<br class="">
Modified: lldb/trunk/source/Expression/ExpressionVariable.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionVariable.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionVariable.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Expression/ExpressionVariable.cpp (original)<br class="">
+++ lldb/trunk/source/Expression/ExpressionVariable.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -30,3 +30,7 @@ ExpressionVariable::GetValueBytes()<br class="">
     }<br class="">
     return NULL;<br class="">
 }<br class="">
+<br class="">
+PersistentExpressionState::~PersistentExpressionState ()<br class="">
+{<br class="">
+}<br class="">
<br class="">
Modified: lldb/trunk/source/Expression/Materializer.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Expression/Materializer.cpp (original)<br class="">
+++ lldb/trunk/source/Expression/Materializer.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -11,8 +11,7 @@<br class="">
 #include "lldb/Core/RegisterValue.h"<br class="">
 #include "lldb/Core/ValueObjectConstResult.h"<br class="">
 #include "lldb/Core/ValueObjectVariable.h"<br class="">
-#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h"<br class="">
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"<br class="">
+#include "lldb/Expression/ExpressionVariable.h"<br class="">
 #include "lldb/Expression/Materializer.h"<br class="">
 #include "lldb/Symbol/ClangASTContext.h"<br class="">
 #include "lldb/Symbol/Symbol.h"<br class="">
@@ -858,9 +857,25 @@ public:<br class="">
             return;<br class="">
         }<br class="">
<br class="">
-        ConstString name = target_sp->GetPersistentVariables().GetNextPersistentVariableName();<br class="">
+        TypeSystem *type_system = target_sp->GetScratchTypeSystemForLanguage(m_type.GetMinimumLanguage());<br class="">
<br class="">
-        lldb::ExpressionVariableSP ret = ClangExpressionVariable::CreateVariableInList(target_sp->GetPersistentVariables(),<br class="">
+        if (!type_system)<br class="">
+        {<br class="">
+            err.SetErrorString("Couldn't dematerialize a result variable: couldn't get the corresponding type system");<br class="">
+            return;<br class="">
+        }<br class="">
+<br class="">
+        PersistentExpressionState *persistent_state = type_system->GetPersistentExpressionState();<br class="">
+<br class="">
+        if (!persistent_state)<br class="">
+        {<br class="">
+            err.SetErrorString("Couldn't dematerialize a result variable: corresponding type system doesn't handle persistent variables");<br class="">
+            return;<br class="">
+        }<br class="">
+<br class="">
+        ConstString name = persistent_state->GetNextPersistentVariableName();<br class="">
+<br class="">
+        lldb::ExpressionVariableSP ret = ClangExpressionVariable::CreateVariableInList(*persistent_state,<br class="">
                                                                                        exe_scope,<br class="">
                                                                                        name,<br class="">
                                                                                        m_type,<br class="">
<br class="">
Modified: lldb/trunk/source/Expression/UserExpression.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/UserExpression.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/UserExpression.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Expression/UserExpression.cpp (original)<br class="">
+++ lldb/trunk/source/Expression/UserExpression.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -34,6 +34,7 @@<br class="">
 #include "lldb/Symbol/ObjectFile.h"<br class="">
 #include "lldb/Symbol/SymbolVendor.h"<br class="">
 #include "lldb/Symbol/Type.h"<br class="">
+#include "lldb/Symbol/TypeSystem.h"<br class="">
 #include "lldb/Symbol/VariableList.h"<br class="">
 #include "lldb/Target/ExecutionContext.h"<br class="">
 #include "lldb/Target/Process.h"<br class="">
@@ -586,7 +587,7 @@ UserExpression::Evaluate (ExecutionConte<br class="">
<br class="">
             if (options.GetResultIsInternal() && expr_result && process)<br class="">
             {<br class="">
-                process->GetTarget().GetPersistentVariables().RemovePersistentVariable (expr_result);<br class="">
+                process->GetTarget().GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState()->RemovePersistentVariable (expr_result);<br class="">
             }<br class="">
<br class="">
             if (execution_results != lldb::eExpressionCompleted)<br class="">
<br class="">
Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp (original)<br class="">
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -464,7 +464,7 @@ ASTResultSynthesizer::MaybeRecordPersist<br class="">
                                                                  D);<br class="">
<br class="">
     if (TypeDecl *TypeDecl_scratch = dyn_cast<TypeDecl>(D_scratch))<br class="">
-        m_target.GetPersistentVariables().RegisterPersistentType(name_cs, TypeDecl_scratch);<br class="">
+        llvm::cast<ClangPersistentVariables>(m_target.GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState())->RegisterPersistentType(name_cs, TypeDecl_scratch);<br class="">
 }<br class="">
<br class="">
 void<br class="">
<br class="">
Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp (original)<br class="">
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -104,7 +104,7 @@ ClangExpressionDeclMap::WillParse(Execut<br class="">
<br class="">
     if (target)<br class="">
     {<br class="">
-        m_parser_vars->m_persistent_vars = &target->GetPersistentVariables();<br class="">
+        m_parser_vars->m_persistent_vars = llvm::cast<ClangPersistentVariables>(target->GetScratchTypeSystemForLanguage(eLanguageTypeC)->GetPersistentExpressionState());<br class="">
<br class="">
         if (!target->GetScratchClangASTContext())<br class="">
             return false;<br class="">
<br class="">
Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original)<br class="">
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -331,7 +331,8 @@ ClangExpressionParser::ClangExpressionPa<br class="">
<br class="">
     if (ClangModulesDeclVendor *decl_vendor = target_sp->GetClangModulesDeclVendor())<br class="">
     {<br class="">
-        std::unique_ptr<PPCallbacks> pp_callbacks(new LLDBPreprocessorCallbacks(*decl_vendor, target_sp->GetPersistentVariables()));<br class="">
+        ClangPersistentVariables *clang_persistent_vars = llvm::cast<ClangPersistentVariables>(target_sp->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState());<br class="">
+        std::unique_ptr<PPCallbacks> pp_callbacks(new LLDBPreprocessorCallbacks(*decl_vendor, *clang_persistent_vars));<br class="">
         m_pp_callbacks = static_cast<LLDBPreprocessorCallbacks*>(pp_callbacks.get());<br class="">
         m_compiler->getPreprocessor().addPPCallbacks(std::move(pp_callbacks));<br class="">
     }<br class="">
<br class="">
Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp (original)<br class="">
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -20,7 +20,7 @@ using namespace lldb;<br class="">
 using namespace lldb_private;<br class="">
<br class="">
 ClangPersistentVariables::ClangPersistentVariables () :<br class="">
-    ExpressionVariableList(),<br class="">
+    lldb_private::PersistentExpressionState(LLVMCastKind::eKindClang),<br class="">
     m_next_persistent_variable_id (0)<br class="">
 {<br class="">
 }<br class="">
<br class="">
Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h (original)<br class="">
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h Wed Sep 30 14:57:57 2015<br class="">
@@ -13,6 +13,8 @@<br class="">
 #include "ClangExpressionVariable.h"<br class="">
 #include "ClangModulesDeclVendor.h"<br class="">
<br class="">
+#include "lldb/Expression/ExpressionVariable.h"<br class="">
+<br class="">
 #include "llvm/ADT/DenseMap.h"<br class="">
<br class="">
 namespace lldb_private<br class="">
@@ -26,7 +28,7 @@ namespace lldb_private<br class="">
 /// ClangPersistentVariable for more discussion.  Also provides an increasing,<br class="">
 /// 0-based counter for naming result variables.<br class="">
 //----------------------------------------------------------------------<br class="">
-class ClangPersistentVariables : public ExpressionVariableList<br class="">
+class ClangPersistentVariables : public PersistentExpressionState<br class="">
 {<br class="">
 public:<br class="">
<br class="">
@@ -34,6 +36,16 @@ public:<br class="">
     /// Constructor<br class="">
     //----------------------------------------------------------------------<br class="">
     ClangPersistentVariables ();<br class="">
+<br class="">
+    ~ClangPersistentVariables () { }<br class="">
+<br class="">
+    //------------------------------------------------------------------<br class="">
+    // llvm casting support<br class="">
+    //------------------------------------------------------------------<br class="">
+    static bool classof(const PersistentExpressionState *pv)<br class="">
+    {<br class="">
+        return pv->getKind() == PersistentExpressionState::eKindClang;<br class="">
+    }<br class="">
<br class="">
     lldb::ExpressionVariableSP<br class="">
     CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp);<br class="">
@@ -53,10 +65,10 @@ public:<br class="">
     ///     A string that contains the next persistent variable name.<br class="">
     //----------------------------------------------------------------------<br class="">
     ConstString<br class="">
-    GetNextPersistentVariableName ();<br class="">
+    GetNextPersistentVariableName () override;<br class="">
<br class="">
     void<br class="">
-    RemovePersistentVariable (lldb::ExpressionVariableSP variable);<br class="">
+    RemovePersistentVariable (lldb::ExpressionVariableSP variable) override;<br class="">
<br class="">
     void<br class="">
     RegisterPersistentType (const ConstString &name,<br class="">
<br class="">
Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp (original)<br class="">
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -357,7 +357,7 @@ ClangUserExpression::Parse (Stream &erro<br class="">
<br class="">
     if (ClangModulesDeclVendor *decl_vendor = m_target->GetClangModulesDeclVendor())<br class="">
     {<br class="">
-        const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = m_target->GetPersistentVariables().GetHandLoadedClangModules();<br class="">
+        const ClangModulesDeclVendor::ModuleVector &hand_imported_modules = llvm::cast<ClangPersistentVariables>(m_target->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC)->GetPersistentExpressionState())->GetHandLoadedClangModules();<br class="">
         ClangModulesDeclVendor::ModuleVector modules_for_macros;<br class="">
<br class="">
         for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules)<br class="">
<br class="">
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)<br class="">
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -9158,7 +9158,8 @@ ClangASTContext::DeclContextGetClangASTC<br class="">
<br class="">
 ClangASTContextForExpressions::ClangASTContextForExpressions (Target &target) :<br class="">
     ClangASTContext (target.GetArchitecture().GetTriple().getTriple().c_str()),<br class="">
-    m_target_wp(target.shared_from_this())<br class="">
+    m_target_wp(target.shared_from_this()),<br class="">
+    m_persistent_variables (new ClangPersistentVariables)<br class="">
 {<br class="">
 }<br class="">
<br class="">
@@ -9196,9 +9197,15 @@ UtilityFunction *<br class="">
 ClangASTContextForExpressions::GetUtilityFunction (const char *text,<br class="">
                                                    const char *name)<br class="">
 {<br class="">
-     TargetSP target_sp = m_target_wp.lock();<br class="">
+    TargetSP target_sp = m_target_wp.lock();<br class="">
     if (!target_sp)<br class="">
         return nullptr;<br class="">
<br class="">
     return new ClangUtilityFunction(*target_sp.get(), text, name);<br class="">
 }<br class="">
+<br class="">
+PersistentExpressionState *<br class="">
+ClangASTContextForExpressions::GetPersistentExpressionState ()<br class="">
+{<br class="">
+    return m_persistent_variables.get();<br class="">
+}<br class="">
<br class="">
Modified: lldb/trunk/source/Target/ABI.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ABI.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ABI.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Target/ABI.cpp (original)<br class="">
+++ lldb/trunk/source/Target/ABI.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -13,6 +13,7 @@<br class="">
 #include "lldb/Core/ValueObjectConstResult.h"<br class="">
 #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"<br class="">
 #include "lldb/Symbol/CompilerType.h"<br class="">
+#include "lldb/Symbol/TypeSystem.h"<br class="">
 #include "lldb/Target/Target.h"<br class="">
 #include "lldb/Target/Thread.h"<br class="">
<br class="">
@@ -123,8 +124,8 @@ ABI::GetReturnValueObject (Thread &threa<br class="">
<br class="">
     if (persistent)<br class="">
     {<br class="">
-        ClangPersistentVariables& persistent_variables = thread.CalculateTarget()->GetPersistentVariables();<br class="">
-        ConstString persistent_variable_name (persistent_variables.GetNextPersistentVariableName());<br class="">
+        PersistentExpressionState *persistent_expression_state = thread.CalculateTarget()->GetScratchTypeSystemForLanguage(ast_type.GetMinimumLanguage())->GetPersistentExpressionState();<br class="">
+        ConstString persistent_variable_name (persistent_expression_state->GetNextPersistentVariableName());<br class="">
<br class="">
         lldb::ValueObjectSP const_valobj_sp;<br class="">
<br class="">
@@ -141,7 +142,7 @@ ABI::GetReturnValueObject (Thread &threa<br class="">
<br class="">
         return_valobj_sp = const_valobj_sp;<br class="">
<br class="">
-        ExpressionVariableSP clang_expr_variable_sp(persistent_variables.CreatePersistentVariable(return_valobj_sp));<br class="">
+        ExpressionVariableSP clang_expr_variable_sp(ClangExpressionVariable::CreateVariableInList(*persistent_expression_state, return_valobj_sp)->shared_from_this());<br class="">
<br class="">
         assert (clang_expr_variable_sp.get());<br class="">
<br class="">
<br class="">
Modified: lldb/trunk/source/Target/Target.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=248934&r1=248933&r2=248934&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=248934&r1=248933&r2=248934&view=diff</a><br class="">
==============================================================================<br class="">
--- lldb/trunk/source/Target/Target.cpp (original)<br class="">
+++ lldb/trunk/source/Target/Target.cpp Wed Sep 30 14:57:57 2015<br class="">
@@ -88,7 +88,6 @@ Target::Target(Debugger &debugger, const<br class="">
     m_scratch_ast_context_ap (),<br class="">
     m_scratch_ast_source_ap (),<br class="">
     m_ast_importer_ap (),<br class="">
-    m_persistent_variables (new ClangPersistentVariables),<br class="">
     m_source_manager_ap(),<br class="">
     m_stop_hooks (),<br class="">
     m_stop_hook_next_id (0),<br class="">
@@ -231,7 +230,6 @@ Target::Destroy()<br class="">
     m_last_created_watchpoint.reset();<br class="">
     m_search_filter_sp.reset();<br class="">
     m_image_search_paths.Clear(notify);<br class="">
-    m_persistent_variables->Clear();<br class="">
     m_stop_hooks.clear();<br class="">
     m_stop_hook_next_id = 0;<br class="">
     m_suppress_stop_hooks = false;<br class="">
@@ -2119,7 +2117,7 @@ Target::EvaluateExpression<br class="">
     lldb::ExpressionVariableSP persistent_var_sp;<br class="">
     // Only check for persistent variables the expression starts with a '$'<br class="">
     if (expr_cstr[0] == '$')<br class="">
-        persistent_var_sp = m_persistent_variables->GetVariable (expr_cstr);<br class="">
+        persistent_var_sp = GetScratchTypeSystemForLanguage(eLanguageTypeC)->GetPersistentExpressionState()->GetVariable (expr_cstr);<br class="">
<br class="">
     if (persistent_var_sp)<br class="">
     {<br class="">
@@ -2143,10 +2141,18 @@ Target::EvaluateExpression<br class="">
     return execution_results;<br class="">
 }<br class="">
<br class="">
-ClangPersistentVariables &<br class="">
-Target::GetPersistentVariables()<br class="">
+lldb::ExpressionVariableSP<br class="">
+Target::GetPersistentVariable(const ConstString &name)<br class="">
 {<br class="">
-    return *m_persistent_variables;<br class="">
+    if (ClangASTContext *ast_context = GetScratchClangASTContext(false))<br class="">
+    {<br class="">
+        if (PersistentExpressionState *persistent_state = ast_context->GetPersistentExpressionState())<br class="">
+        {<br class="">
+            return persistent_state->GetVariable(name);<br class="">
+        }<br class="">
+    }<br class="">
+<br class="">
+    return ExpressionVariableSP();<br class="">
 }<br class="">
<br class="">
 lldb::addr_t<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
lldb-commits mailing list<br class="">
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank" class="">lldb-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br class="">
</blockquote></div></blockquote></div></div>
_______________________________________________<br class="">lldb-commits mailing list<br class=""><a href="mailto:lldb-commits@lists.llvm.org" class="">lldb-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits<br class=""></div></blockquote></div><br class=""><div class="">
<div class="" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class="Apple-interchange-newline">Thanks,</div><div class="" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><i class="">- Enrico</i><br class="">📩 egranata@<font color="#ff2600" class=""></font>.com ☎️ 27683</div>
</div>
<br class=""></body></html>