[Lldb-commits] [lldb] r270474 - Removed the m_decl_objects map from ClangASTContext.

Sean Callanan via lldb-commits lldb-commits at lists.llvm.org
Mon May 23 11:31:00 PDT 2016


Author: spyffe
Date: Mon May 23 13:30:59 2016
New Revision: 270474

URL: http://llvm.org/viewvc/llvm-project?rev=270474&view=rev
Log:
Removed the m_decl_objects map from ClangASTContext.

m_decl_objects is problematic because it assumes that each VarDecl has a unique
variable associated with it.  This is not the case in inline contexts.

Also the information in this map can be reconstructed very easily without
maintaining the map.  The rest of the testsuite passes with this cange, and I've
added a testcase covering the inline contexts affected by this.

<rdar://problem/26278502>

Added:
    lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py
    lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c
Modified:
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/include/lldb/Symbol/CompilerDecl.h
    lldb/trunk/include/lldb/Symbol/GoASTContext.h
    lldb/trunk/include/lldb/Symbol/JavaASTContext.h
    lldb/trunk/include/lldb/Symbol/TypeSystem.h
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
    lldb/trunk/source/Symbol/ClangASTContext.cpp
    lldb/trunk/source/Symbol/CompilerDecl.cpp
    lldb/trunk/source/Symbol/JavaASTContext.cpp
    lldb/trunk/source/Symbol/Variable.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=270474&r1=270473&r2=270474&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Mon May 23 13:30:59 2016
@@ -557,12 +557,6 @@ public:
     //----------------------------------------------------------------------
     // CompilerDecl override functions
     //----------------------------------------------------------------------
-    lldb::VariableSP
-    DeclGetVariable (void *opaque_decl) override;
-
-    void
-    DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) override;
-    
     ConstString
     DeclGetName (void *opaque_decl) override;
 
@@ -1218,7 +1212,6 @@ protected:
     uint32_t                                        m_pointer_byte_size;
     bool                                            m_ast_owned;
     bool                                            m_can_evaluate_expressions;
-    std::map<void *, std::shared_ptr<void>>         m_decl_objects;
     // clang-format on
 private:
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Symbol/CompilerDecl.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompilerDecl.h?rev=270474&r1=270473&r2=270474&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/CompilerDecl.h (original)
+++ lldb/trunk/include/lldb/Symbol/CompilerDecl.h Mon May 23 13:30:59 2016
@@ -65,12 +65,6 @@ public:
     IsClang () const;
 
     //----------------------------------------------------------------------
-    // Object linked to the decl
-    //----------------------------------------------------------------------
-    lldb::VariableSP
-    GetAsVariable ();
-
-    //----------------------------------------------------------------------
     // Accessors
     //----------------------------------------------------------------------
     

Modified: lldb/trunk/include/lldb/Symbol/GoASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/GoASTContext.h?rev=270474&r1=270473&r2=270474&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/GoASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/GoASTContext.h Mon May 23 13:30:59 2016
@@ -85,17 +85,6 @@ class GoASTContext : public TypeSystem
         return ConstString();
     }
 
-    lldb::VariableSP
-    DeclGetVariable (void *opaque_decl) override
-    {
-        return lldb::VariableSP();
-    }
-
-    void
-    DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) override
-    {
-    }
-
     //----------------------------------------------------------------------
     // CompilerDeclContext functions
     //----------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Symbol/JavaASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/JavaASTContext.h?rev=270474&r1=270473&r2=270474&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/JavaASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/JavaASTContext.h Mon May 23 13:30:59 2016
@@ -70,12 +70,6 @@ public:
     ConstString
     DeclGetName(void *opaque_decl) override;
 
-    lldb::VariableSP
-    DeclGetVariable(void *opaque_decl) override;
-
-    void
-    DeclLinkToObject(void *opaque_decl, std::shared_ptr<void> object) override;
-
     //----------------------------------------------------------------------
     // CompilerDeclContext functions
     //----------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=270474&r1=270473&r2=270474&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Mon May 23 13:30:59 2016
@@ -127,12 +127,6 @@ public:
     virtual ConstString
     DeclGetMangledName (void *opaque_decl);
 
-    virtual lldb::VariableSP
-    DeclGetVariable (void *opaque_decl) = 0;
-
-    virtual void
-    DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) = 0;
-
     virtual CompilerDeclContext
     DeclGetDeclContext (void *opaque_decl);
 

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py?rev=270474&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py Mon May 23 13:30:59 2016
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), [])

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c?rev=270474&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c Mon May 23 13:30:59 2016
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+void test1(int) __attribute__ ((always_inline));
+void test2(int) __attribute__ ((always_inline));
+
+void test2(int b) {
+    printf("test2(%d)\n", b); //% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["42"])
+}
+
+void test1(int a) {
+    printf("test1(%d)\n",  a);
+    test2(a+1);//% self.dbg.HandleCommand("step")
+               //% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["24"])
+}
+
+int main() {
+    test2(42);
+    test1(23);
+}

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp?rev=270474&r1=270473&r2=270474&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp Mon May 23 13:30:59 2016
@@ -1260,7 +1260,16 @@ ClangExpressionDeclMap::FindExternalVisi
                 bool variable_found = false;
                 for (CompilerDecl decl : found_decls)
                 {
-                    var = decl.GetAsVariable();
+                    for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi)
+                    {
+                        VariableSP candidate_var = vars->GetVariableAtIndex(vi);
+                        if (candidate_var->GetDecl() == decl)
+                        {
+                            var = candidate_var;
+                            break;
+                        }
+                    }
+
                     if (var)
                     {
                         variable_found = true;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=270474&r1=270473&r2=270474&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Mon May 23 13:30:59 2016
@@ -3607,6 +3607,14 @@ DWARFASTParserClang::GetClangDeclForDIE
         m_decl_to_die[decl].insert(die.GetDIE());
         return decl;
     }
+    
+    if (DWARFDIE abstract_origin_die = die.GetReferencedDIE(DW_AT_abstract_origin))
+    {
+        clang::Decl *decl = GetClangDeclForDIE(abstract_origin_die);
+        m_die_to_decl[die.GetDIE()] = decl;
+        m_decl_to_die[decl].insert(die.GetDIE());
+        return decl;
+    }
 
     clang::Decl *decl = nullptr;
     switch (die.Tag())

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=270474&r1=270473&r2=270474&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Mon May 23 13:30:59 2016
@@ -9595,24 +9595,6 @@ ClangASTContext::LayoutRecordType(void *
 //----------------------------------------------------------------------
 // CompilerDecl override functions
 //----------------------------------------------------------------------
-lldb::VariableSP
-ClangASTContext::DeclGetVariable (void *opaque_decl)
-{
-    if (llvm::dyn_cast<clang::VarDecl>((clang::Decl *)opaque_decl))
-    {
-        auto decl_search_it = m_decl_objects.find(opaque_decl);
-        if (decl_search_it != m_decl_objects.end())
-            return std::static_pointer_cast<Variable>(decl_search_it->second);
-    }
-    return VariableSP();
-}
-
-void
-ClangASTContext::DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object)
-{
-    if (m_decl_objects.find(opaque_decl) == m_decl_objects.end())
-        m_decl_objects.insert(std::make_pair(opaque_decl, object));
-}
 
 ConstString
 ClangASTContext::DeclGetName (void *opaque_decl)

Modified: lldb/trunk/source/Symbol/CompilerDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompilerDecl.cpp?rev=270474&r1=270473&r2=270474&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/CompilerDecl.cpp (original)
+++ lldb/trunk/source/Symbol/CompilerDecl.cpp Mon May 23 13:30:59 2016
@@ -31,12 +31,6 @@ CompilerDecl::GetMangledName () const
     return m_type_system->DeclGetMangledName(m_opaque_decl);
 }
 
-lldb::VariableSP
-CompilerDecl::GetAsVariable ()
-{
-    return m_type_system->DeclGetVariable(m_opaque_decl);
-}
-
 CompilerDeclContext
 CompilerDecl::GetDeclContext() const
 {

Modified: lldb/trunk/source/Symbol/JavaASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/JavaASTContext.cpp?rev=270474&r1=270473&r2=270474&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/JavaASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/JavaASTContext.cpp Mon May 23 13:30:59 2016
@@ -535,17 +535,6 @@ JavaASTContext::DeclGetName(void *opaque
     return ConstString();
 }
 
-lldb::VariableSP
-JavaASTContext::DeclGetVariable(void *opaque_decl)
-{
-    return lldb::VariableSP();
-}
-
-void
-JavaASTContext::DeclLinkToObject(void *opaque_decl, std::shared_ptr<void> object)
-{
-}
-
 std::vector<CompilerDecl>
 JavaASTContext::DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_imported_decls)
 {

Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=270474&r1=270473&r2=270474&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Mon May 23 13:30:59 2016
@@ -252,15 +252,8 @@ Variable::GetDeclContext ()
 CompilerDecl
 Variable::GetDecl ()
 {
-    CompilerDecl decl;
     Type *type = GetType();
-    if (type)
-    {
-        decl = type->GetSymbolFile()->GetDeclForUID(GetID());
-        if (decl)
-            decl.GetTypeSystem()->DeclLinkToObject(decl.GetOpaqueDecl(), shared_from_this());
-    }
-    return decl;
+    return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
 }
 
 void




More information about the lldb-commits mailing list