paulherman updated this revision to Diff 35019.
paulherman added a comment.

Fix caching for clang::Decl in DWARFASTParserClang

Fixed small mistakes from previous commit.


http://reviews.llvm.org/D12942

Files:
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3225,13 +3225,23 @@
     if (!die)
         return nullptr;
 
-    if (die.GetReferencedDIE(DW_AT_specification))
-        return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+    const std::set<dw_tag_t> tags_with_decls { DW_TAG_variable, 
DW_TAG_constant, DW_TAG_formal_parameter, DW_TAG_imported_module, 
DW_TAG_imported_declaration };
+    if (tags_with_decls.find(die.Tag()) == tags_with_decls.end())
+        return nullptr;
+
+    DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+    if (cache_pos != m_die_to_decl.end())
+        return cache_pos->second;
 
-    clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-    if (decl != nullptr)
+    if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification))
+    {
+        clang::Decl *decl = GetClangDeclForDIE(spec_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())
     {
         case DW_TAG_variable:


Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3225,13 +3225,23 @@
     if (!die)
         return nullptr;
 
-    if (die.GetReferencedDIE(DW_AT_specification))
-        return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+    const std::set<dw_tag_t> tags_with_decls { DW_TAG_variable, DW_TAG_constant, DW_TAG_formal_parameter, DW_TAG_imported_module, DW_TAG_imported_declaration };
+    if (tags_with_decls.find(die.Tag()) == tags_with_decls.end())
+        return nullptr;
+
+    DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+    if (cache_pos != m_die_to_decl.end())
+        return cache_pos->second;
 
-    clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-    if (decl != nullptr)
+    if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification))
+    {
+        clang::Decl *decl = GetClangDeclForDIE(spec_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())
     {
         case DW_TAG_variable:
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to