[Lldb-commits] [lldb] r247923 - Fix caching for clang::Decl in DWARFASTParserClang

Paul Herman via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 17 12:32:03 PDT 2015


Author: paulherman
Date: Thu Sep 17 14:32:02 2015
New Revision: 247923

URL: http://llvm.org/viewvc/llvm-project?rev=247923&view=rev
Log:
Fix caching for clang::Decl in DWARFASTParserClang

Reviewers: sivachandra, chaoren, clayborg, tberghammer

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D12942

Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

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=247923&r1=247922&r2=247923&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Thu Sep 17 14:32:02 2015
@@ -3225,13 +3225,31 @@ DWARFASTParserClang::GetClangDeclForDIE
     if (!die)
         return nullptr;
 
-    if (die.GetReferencedDIE(DW_AT_specification))
-        return GetClangDeclForDIE(die.GetReferencedDIE(DW_AT_specification));
+    switch (die.Tag())
+    {
+        case DW_TAG_variable:
+        case DW_TAG_constant:
+        case DW_TAG_formal_parameter:
+        case DW_TAG_imported_declaration:
+        case DW_TAG_imported_module:
+            break;
+        default:
+            return nullptr;
+    }
 
-    clang::Decl *decl = m_die_to_decl[die.GetDIE()];
-    if (decl != nullptr)
+    DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+    if (cache_pos != m_die_to_decl.end())
+        return cache_pos->second;
+
+    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:




More information about the lldb-commits mailing list