[Lldb-commits] [lldb] 6dd0163 - [lldb] Revert refactorization from: Move non-DWARF code: DWARFUnit -> SymbolFileDWARF

Jan Kratochvil via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 31 07:06:38 PST 2020


Author: Jan Kratochvil
Date: 2020-01-31T16:06:23+01:00
New Revision: 6dd0163502ff8c48195643b2b08a123c495743a0

URL: https://github.com/llvm/llvm-project/commit/6dd0163502ff8c48195643b2b08a123c495743a0
DIFF: https://github.com/llvm/llvm-project/commit/6dd0163502ff8c48195643b2b08a123c495743a0.diff

LOG: [lldb] Revert refactorization from: Move non-DWARF code: DWARFUnit -> SymbolFileDWARF

Reverting part of commit 789beeeca3cdeecc00cd731c940e52effdd7c7df.

Its DWARFDebugInfoEntry::GetDWARFDeclContext() refactorization for
return value is now adding it in opposite order.

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
    lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
    lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 57bda49952f4..db49010a846f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -726,7 +726,8 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
     if (type_sp)
       return type_sp;
 
-    DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
+    DWARFDeclContext die_decl_ctx;
+    SymbolFileDWARF::GetDWARFDeclContext(die, die_decl_ctx);
 
     type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
 
@@ -1514,7 +1515,8 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
     if (type_sp)
       return type_sp;
 
-    DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
+    DWARFDeclContext die_decl_ctx;
+    SymbolFileDWARF::GetDWARFDeclContext(die, die_decl_ctx);
 
     // type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
     // type_name_const_str);
@@ -2323,9 +2325,10 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
         unsigned type_quals = 0;
         std::vector<CompilerType> param_types;
         std::vector<clang::ParmVarDecl *> param_decls;
+        DWARFDeclContext decl_ctx;
         StreamString sstr;
 
-        DWARFDeclContext decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
+        SymbolFileDWARF::GetDWARFDeclContext(die, decl_ctx);
         sstr << decl_ctx.GetQualifiedName();
 
         clang::DeclContext *containing_decl_ctx =

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 4723fc8c35f2..885ca3d32d64 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -868,20 +868,19 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
   }
 }
 
-DWARFDeclContext DWARFDebugInfoEntry::GetDWARFDeclContext(DWARFUnit *cu) const {
-  DWARFDeclContext dwarf_decl_ctx;
+void DWARFDebugInfoEntry::GetDWARFDeclContext(
+    DWARFUnit *cu, DWARFDeclContext &dwarf_decl_ctx) const {
   const dw_tag_t tag = Tag();
   if (tag != DW_TAG_compile_unit && tag != DW_TAG_partial_unit) {
+    dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
     DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
     if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this) {
       if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit &&
           parent_decl_ctx_die.Tag() != DW_TAG_partial_unit)
-        dwarf_decl_ctx = parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
-            parent_decl_ctx_die.GetCU());
+        parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
+            parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
     }
-    dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
   }
-  return dwarf_decl_ctx;
 }
 
 DWARFDIE

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
index a61ed5bbfe67..2bb69e738a2f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -158,7 +158,8 @@ class DWARFDebugInfoEntry {
     return HasChildren() ? this + 1 : nullptr;
   }
 
-  DWARFDeclContext GetDWARFDeclContext(DWARFUnit *cu) const;
+  void GetDWARFDeclContext(DWARFUnit *cu,
+                           DWARFDeclContext &dwarf_decl_ctx) const;
 
   DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu) const;
   DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu,

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index b1d82ddb4e3e..5ef2dd3f04b3 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2956,8 +2956,8 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
             }
 
             if (try_resolving_type) {
-              DWARFDeclContext type_dwarf_decl_ctx =
-                  GetDWARFDeclContext(type_die);
+              DWARFDeclContext type_dwarf_decl_ctx;
+              GetDWARFDeclContext(type_die, type_dwarf_decl_ctx);
 
               if (log) {
                 GetObjectFile()->GetModule()->LogMessage(
@@ -3374,10 +3374,12 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
         // declaration context.
         if ((parent_tag == DW_TAG_compile_unit ||
              parent_tag == DW_TAG_partial_unit) &&
-            Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU())))
-          mangled = GetDWARFDeclContext(die)
-                        .GetQualifiedNameAsConstString()
-                        .GetCString();
+            Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU()))) {
+          DWARFDeclContext decl_ctx;
+
+          GetDWARFDeclContext(die, decl_ctx);
+          mangled = decl_ctx.GetQualifiedNameAsConstString().GetCString();
+        }
       }
 
       if (tag == DW_TAG_formal_parameter)
@@ -3979,13 +3981,14 @@ SymbolFileDWARF::GetContainingDeclContext(const DWARFDIE &die) {
   return CompilerDeclContext();
 }
 
-DWARFDeclContext SymbolFileDWARF::GetDWARFDeclContext(const DWARFDIE &die) {
-  if (!die.IsValid())
-    return {};
-  DWARFDeclContext dwarf_decl_ctx =
-      die.GetDIE()->GetDWARFDeclContext(die.GetCU());
+void SymbolFileDWARF::GetDWARFDeclContext(const DWARFDIE &die,
+                                          DWARFDeclContext &dwarf_decl_ctx) {
+  if (!die.IsValid()) {
+    dwarf_decl_ctx.Clear();
+    return;
+  }
   dwarf_decl_ctx.SetLanguage(GetLanguage(*die.GetCU()));
-  return dwarf_decl_ctx;
+  die.GetDIE()->GetDWARFDeclContext(die.GetCU(), dwarf_decl_ctx);
 }
 
 LanguageType SymbolFileDWARF::LanguageTypeFromDWARF(uint64_t val) {

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index e2163a7f4f0d..4510efcf25ff 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -315,7 +315,8 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
   static lldb_private::CompilerDeclContext
   GetContainingDeclContext(const DWARFDIE &die);
 
-  static DWARFDeclContext GetDWARFDeclContext(const DWARFDIE &die);
+  static void GetDWARFDeclContext(const DWARFDIE &die,
+                                  DWARFDeclContext &dwarf_decl_ctx);
 
   static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);
 


        


More information about the lldb-commits mailing list