Skip to content

[llvm-debuginfo-analyzer][NFC] Move some functionality to LVReader. #142740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

CarlosAlbertoEnciso
Copy link
Member

Hoist out from LVDWARFReader and LVBinaryReader some generic
code, so it can be available to other readers that do not share the
binary format.

Hoist out from LVDWARFReader and LVBinaryReader some generic
code, so it can be available to other readers that do not
share the binary format.
@llvmbot
Copy link
Member

llvmbot commented Jun 4, 2025

@llvm/pr-subscribers-llvm-binary-utilities

@llvm/pr-subscribers-debuginfo

Author: Carlos Alberto Enciso (CarlosAlbertoEnciso)

Changes

Hoist out from LVDWARFReader and LVBinaryReader some generic
code, so it can be available to other readers that do not share the
binary format.


Patch is 23.38 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/142740.diff

6 Files Affected:

  • (modified) llvm/include/llvm/DebugInfo/LogicalView/Core/LVReader.h (+25-1)
  • (modified) llvm/include/llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h (-11)
  • (modified) llvm/include/llvm/DebugInfo/LogicalView/Readers/LVDWARFReader.h (-10)
  • (modified) llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp (+247)
  • (modified) llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp (-24)
  • (modified) llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp (-217)
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVReader.h b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVReader.h
index 870b53f6774a8..5388887df4ed4 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Core/LVReader.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Core/LVReader.h
@@ -56,7 +56,7 @@ class LVSplitContext final {
 
 /// The logical reader owns of all the logical elements created during
 /// the debug information parsing. For its creation it uses a specific
-///  bump allocator for each type of logical element.
+/// bump allocator for each type of logical element.
 class LVReader {
   LVBinaryType BinaryType;
 
@@ -122,7 +122,24 @@ class LVReader {
 
 #undef LV_OBJECT_ALLOCATOR
 
+  // Scopes with ranges for current compile unit. It is used to find a line
+  // giving its exact or closest address. To support comdat functions, all
+  // addresses for the same section are recorded in the same map.
+  using LVSectionRanges = std::map<LVSectionIndex, std::unique_ptr<LVRange>>;
+  LVSectionRanges SectionRanges;
+
 protected:
+  // Current elements during the processing of a DIE/MDNode.
+  LVElement *CurrentElement = nullptr;
+  LVScope *CurrentScope = nullptr;
+  LVSymbol *CurrentSymbol = nullptr;
+  LVType *CurrentType = nullptr;
+  LVLine *CurrentLine = nullptr;
+  LVOffset CurrentOffset = 0;
+
+  // Address ranges collected for current DIE/MDNode/AST Node.
+  std::vector<LVAddressRange> CurrentRanges;
+
   LVScopeRoot *Root = nullptr;
   std::string InputFilename;
   std::string FileFormatName;
@@ -133,11 +150,18 @@ class LVReader {
   // Only for ELF format. The CodeView is handled in a different way.
   LVSectionIndex DotTextSectionIndex = UndefinedSectionIndex;
 
+  void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope);
+  void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope,
+                       LVAddress LowerAddress, LVAddress UpperAddress);
+  LVRange *getSectionRanges(LVSectionIndex SectionIndex);
+
   // Record Compilation Unit entry.
   void addCompileUnitOffset(LVOffset Offset, LVScopeCompileUnit *CompileUnit) {
     CompileUnits.emplace(Offset, CompileUnit);
   }
 
+  LVElement *createElement(dwarf::Tag Tag);
+
   // Create the Scope Root.
   virtual Error createScopes() {
     Root = createScopeRoot();
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h b/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h
index 9cda64e33ddf7..1847fa8323480 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h
@@ -93,12 +93,6 @@ class LVBinaryReader : public LVReader {
       SectionAddresses.emplace(Section.getAddress(), Section);
   }
 
-  // Scopes with ranges for current compile unit. It is used to find a line
-  // giving its exact or closest address. To support comdat functions, all
-  // addresses for the same section are recorded in the same map.
-  using LVSectionRanges = std::map<LVSectionIndex, std::unique_ptr<LVRange>>;
-  LVSectionRanges SectionRanges;
-
   // Image base and virtual address for Executable file.
   uint64_t ImageBaseAddress = 0;
   uint64_t VirtualAddress = 0;
@@ -179,11 +173,6 @@ class LVBinaryReader : public LVReader {
   Expected<std::pair<LVSectionIndex, object::SectionRef>>
   getSection(LVScope *Scope, LVAddress Address, LVSectionIndex SectionIndex);
 
-  void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope);
-  void addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope,
-                       LVAddress LowerAddress, LVAddress UpperAddress);
-  LVRange *getSectionRanges(LVSectionIndex SectionIndex);
-
   void includeInlineeLines(LVSectionIndex SectionIndex, LVScope *Function);
 
   Error createInstructions();
diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVDWARFReader.h b/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVDWARFReader.h
index aa47bd9cd2cdd..d64723ced2e75 100644
--- a/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVDWARFReader.h
+++ b/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVDWARFReader.h
@@ -39,12 +39,6 @@ class LVDWARFReader final : public LVBinaryReader {
   LVAddress CUBaseAddress = 0;
   LVAddress CUHighAddress = 0;
 
-  // Current elements during the processing of a DIE.
-  LVElement *CurrentElement = nullptr;
-  LVScope *CurrentScope = nullptr;
-  LVSymbol *CurrentSymbol = nullptr;
-  LVType *CurrentType = nullptr;
-  LVOffset CurrentOffset = 0;
   LVOffset CurrentEndOffset = 0;
 
   // In DWARF v4, the files are 1-indexed.
@@ -52,9 +46,6 @@ class LVDWARFReader final : public LVBinaryReader {
   // The DWARF reader expects the indexes as 1-indexed.
   bool IncrementFileIndex = false;
 
-  // Address ranges collected for current DIE.
-  std::vector<LVAddressRange> CurrentRanges;
-
   // Symbols with locations for current compile unit.
   LVSymbols SymbolsWithLocations;
 
@@ -82,7 +73,6 @@ class LVDWARFReader final : public LVBinaryReader {
 
   void mapRangeAddress(const object::ObjectFile &Obj) override;
 
-  LVElement *createElement(dwarf::Tag Tag);
   void traverseDieAndChildren(DWARFDie &DIE, LVScope *Parent,
                               DWARFDie &SkeletonDie);
   // Process the attributes for the given DIE.
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
index 328ced9f4eb66..c1017d8a3c22f 100644
--- a/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Core/LVReader.cpp
@@ -194,6 +194,253 @@ StringRef LVReader::getFilename(LVObject *Object, size_t Index) const {
   return CompileUnit ? CompileUnit->getFilename(Index) : StringRef();
 }
 
+void LVReader::addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope) {
+  LVRange *ScopesWithRanges = getSectionRanges(SectionIndex);
+  ScopesWithRanges->addEntry(Scope);
+}
+
+void LVReader::addSectionRange(LVSectionIndex SectionIndex, LVScope *Scope,
+                               LVAddress LowerAddress, LVAddress UpperAddress) {
+  LVRange *ScopesWithRanges = getSectionRanges(SectionIndex);
+  ScopesWithRanges->addEntry(Scope, LowerAddress, UpperAddress);
+}
+
+LVRange *LVReader::getSectionRanges(LVSectionIndex SectionIndex) {
+  // Check if we already have a mapping for this section index.
+  LVSectionRanges::iterator IterSection = SectionRanges.find(SectionIndex);
+  if (IterSection == SectionRanges.end())
+    IterSection =
+        SectionRanges.emplace(SectionIndex, std::make_unique<LVRange>()).first;
+  LVRange *Range = IterSection->second.get();
+  assert(Range && "Range is null.");
+  return Range;
+}
+
+LVElement *LVReader::createElement(dwarf::Tag Tag) {
+  CurrentScope = nullptr;
+  CurrentSymbol = nullptr;
+  CurrentType = nullptr;
+  CurrentRanges.clear();
+
+  LLVM_DEBUG(
+      { dbgs() << "\n[createElement] " << dwarf::TagString(Tag) << "\n"; });
+
+  if (!options().getPrintSymbols()) {
+    switch (Tag) {
+    // As the command line options did not specify a request to print
+    // logical symbols (--print=symbols or --print=all or --print=elements),
+    // skip its creation.
+    case dwarf::DW_TAG_formal_parameter:
+    case dwarf::DW_TAG_unspecified_parameters:
+    case dwarf::DW_TAG_member:
+    case dwarf::DW_TAG_variable:
+    case dwarf::DW_TAG_inheritance:
+    case dwarf::DW_TAG_constant:
+    case dwarf::DW_TAG_call_site_parameter:
+    case dwarf::DW_TAG_GNU_call_site_parameter:
+      return nullptr;
+    default:
+      break;
+    }
+  }
+
+  switch (Tag) {
+  // Types.
+  case dwarf::DW_TAG_base_type:
+    CurrentType = createType();
+    CurrentType->setIsBase();
+    if (options().getAttributeBase())
+      CurrentType->setIncludeInPrint();
+    return CurrentType;
+  case dwarf::DW_TAG_const_type:
+    CurrentType = createType();
+    CurrentType->setIsConst();
+    CurrentType->setName("const");
+    return CurrentType;
+  case dwarf::DW_TAG_enumerator:
+    CurrentType = createTypeEnumerator();
+    return CurrentType;
+  case dwarf::DW_TAG_imported_declaration:
+    CurrentType = createTypeImport();
+    CurrentType->setIsImportDeclaration();
+    return CurrentType;
+  case dwarf::DW_TAG_imported_module:
+    CurrentType = createTypeImport();
+    CurrentType->setIsImportModule();
+    return CurrentType;
+  case dwarf::DW_TAG_pointer_type:
+    CurrentType = createType();
+    CurrentType->setIsPointer();
+    CurrentType->setName("*");
+    return CurrentType;
+  case dwarf::DW_TAG_ptr_to_member_type:
+    CurrentType = createType();
+    CurrentType->setIsPointerMember();
+    CurrentType->setName("*");
+    return CurrentType;
+  case dwarf::DW_TAG_reference_type:
+    CurrentType = createType();
+    CurrentType->setIsReference();
+    CurrentType->setName("&");
+    return CurrentType;
+  case dwarf::DW_TAG_restrict_type:
+    CurrentType = createType();
+    CurrentType->setIsRestrict();
+    CurrentType->setName("restrict");
+    return CurrentType;
+  case dwarf::DW_TAG_rvalue_reference_type:
+    CurrentType = createType();
+    CurrentType->setIsRvalueReference();
+    CurrentType->setName("&&");
+    return CurrentType;
+  case dwarf::DW_TAG_subrange_type:
+    CurrentType = createTypeSubrange();
+    return CurrentType;
+  case dwarf::DW_TAG_template_value_parameter:
+    CurrentType = createTypeParam();
+    CurrentType->setIsTemplateValueParam();
+    return CurrentType;
+  case dwarf::DW_TAG_template_type_parameter:
+    CurrentType = createTypeParam();
+    CurrentType->setIsTemplateTypeParam();
+    return CurrentType;
+  case dwarf::DW_TAG_GNU_template_template_param:
+    CurrentType = createTypeParam();
+    CurrentType->setIsTemplateTemplateParam();
+    return CurrentType;
+  case dwarf::DW_TAG_typedef:
+    CurrentType = createTypeDefinition();
+    return CurrentType;
+  case dwarf::DW_TAG_unspecified_type:
+    CurrentType = createType();
+    CurrentType->setIsUnspecified();
+    return CurrentType;
+  case dwarf::DW_TAG_volatile_type:
+    CurrentType = createType();
+    CurrentType->setIsVolatile();
+    CurrentType->setName("volatile");
+    return CurrentType;
+
+  // Symbols.
+  case dwarf::DW_TAG_formal_parameter:
+    CurrentSymbol = createSymbol();
+    CurrentSymbol->setIsParameter();
+    return CurrentSymbol;
+  case dwarf::DW_TAG_unspecified_parameters:
+    CurrentSymbol = createSymbol();
+    CurrentSymbol->setIsUnspecified();
+    CurrentSymbol->setName("...");
+    return CurrentSymbol;
+  case dwarf::DW_TAG_member:
+    CurrentSymbol = createSymbol();
+    CurrentSymbol->setIsMember();
+    return CurrentSymbol;
+  case dwarf::DW_TAG_variable:
+    CurrentSymbol = createSymbol();
+    CurrentSymbol->setIsVariable();
+    return CurrentSymbol;
+  case dwarf::DW_TAG_inheritance:
+    CurrentSymbol = createSymbol();
+    CurrentSymbol->setIsInheritance();
+    return CurrentSymbol;
+  case dwarf::DW_TAG_call_site_parameter:
+  case dwarf::DW_TAG_GNU_call_site_parameter:
+    CurrentSymbol = createSymbol();
+    CurrentSymbol->setIsCallSiteParameter();
+    return CurrentSymbol;
+  case dwarf::DW_TAG_constant:
+    CurrentSymbol = createSymbol();
+    CurrentSymbol->setIsConstant();
+    return CurrentSymbol;
+
+  // Scopes.
+  case dwarf::DW_TAG_catch_block:
+    CurrentScope = createScope();
+    CurrentScope->setIsCatchBlock();
+    return CurrentScope;
+  case dwarf::DW_TAG_lexical_block:
+    CurrentScope = createScope();
+    CurrentScope->setIsLexicalBlock();
+    return CurrentScope;
+  case dwarf::DW_TAG_try_block:
+    CurrentScope = createScope();
+    CurrentScope->setIsTryBlock();
+    return CurrentScope;
+  case dwarf::DW_TAG_compile_unit:
+  case dwarf::DW_TAG_skeleton_unit:
+    CurrentScope = createScopeCompileUnit();
+    CompileUnit = static_cast<LVScopeCompileUnit *>(CurrentScope);
+    return CurrentScope;
+  case dwarf::DW_TAG_inlined_subroutine:
+    CurrentScope = createScopeFunctionInlined();
+    return CurrentScope;
+  case dwarf::DW_TAG_namespace:
+    CurrentScope = createScopeNamespace();
+    return CurrentScope;
+  case dwarf::DW_TAG_template_alias:
+    CurrentScope = createScopeAlias();
+    return CurrentScope;
+  case dwarf::DW_TAG_array_type:
+    CurrentScope = createScopeArray();
+    return CurrentScope;
+  case dwarf::DW_TAG_call_site:
+  case dwarf::DW_TAG_GNU_call_site:
+    CurrentScope = createScopeFunction();
+    CurrentScope->setIsCallSite();
+    return CurrentScope;
+  case dwarf::DW_TAG_entry_point:
+    CurrentScope = createScopeFunction();
+    CurrentScope->setIsEntryPoint();
+    return CurrentScope;
+  case dwarf::DW_TAG_subprogram:
+    CurrentScope = createScopeFunction();
+    CurrentScope->setIsSubprogram();
+    return CurrentScope;
+  case dwarf::DW_TAG_subroutine_type:
+    CurrentScope = createScopeFunctionType();
+    return CurrentScope;
+  case dwarf::DW_TAG_label:
+    CurrentScope = createScopeFunction();
+    CurrentScope->setIsLabel();
+    return CurrentScope;
+  case dwarf::DW_TAG_class_type:
+    CurrentScope = createScopeAggregate();
+    CurrentScope->setIsClass();
+    return CurrentScope;
+  case dwarf::DW_TAG_structure_type:
+    CurrentScope = createScopeAggregate();
+    CurrentScope->setIsStructure();
+    return CurrentScope;
+  case dwarf::DW_TAG_union_type:
+    CurrentScope = createScopeAggregate();
+    CurrentScope->setIsUnion();
+    return CurrentScope;
+  case dwarf::DW_TAG_enumeration_type:
+    CurrentScope = createScopeEnumeration();
+    return CurrentScope;
+  case dwarf::DW_TAG_GNU_formal_parameter_pack:
+    CurrentScope = createScopeFormalPack();
+    return CurrentScope;
+  case dwarf::DW_TAG_GNU_template_parameter_pack:
+    CurrentScope = createScopeTemplatePack();
+    return CurrentScope;
+  case dwarf::DW_TAG_module:
+    CurrentScope = createScopeModule();
+    return CurrentScope;
+  default:
+    // Collect TAGs not implemented.
+    if (options().getInternalTag() && Tag)
+      CompileUnit->addDebugTag(Tag, CurrentOffset);
+    break;
+  }
+
+  LLVM_DEBUG({
+    dbgs() << "DWARF Tag not implemented: " << dwarf::TagString(Tag) << "\n";
+  });
+
+  return nullptr;
+}
+
 // The Reader is the module that creates the logical view using the debug
 // information contained in the binary file specified in the command line.
 // This is the main entry point for the Reader and performs the following
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
index 434709f076dc5..6c66a5a163ad5 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
@@ -367,30 +367,6 @@ LVBinaryReader::getSection(LVScope *Scope, LVAddress Address,
   return std::make_pair(Iter->first, Iter->second);
 }
 
-void LVBinaryReader::addSectionRange(LVSectionIndex SectionIndex,
-                                     LVScope *Scope) {
-  LVRange *ScopesWithRanges = getSectionRanges(SectionIndex);
-  ScopesWithRanges->addEntry(Scope);
-}
-
-void LVBinaryReader::addSectionRange(LVSectionIndex SectionIndex,
-                                     LVScope *Scope, LVAddress LowerAddress,
-                                     LVAddress UpperAddress) {
-  LVRange *ScopesWithRanges = getSectionRanges(SectionIndex);
-  ScopesWithRanges->addEntry(Scope, LowerAddress, UpperAddress);
-}
-
-LVRange *LVBinaryReader::getSectionRanges(LVSectionIndex SectionIndex) {
-  // Check if we already have a mapping for this section index.
-  LVSectionRanges::iterator IterSection = SectionRanges.find(SectionIndex);
-  if (IterSection == SectionRanges.end())
-    IterSection =
-        SectionRanges.emplace(SectionIndex, std::make_unique<LVRange>()).first;
-  LVRange *Range = IterSection->second.get();
-  assert(Range && "Range is null.");
-  return Range;
-}
-
 Error LVBinaryReader::createInstructions(LVScope *Scope,
                                          LVSectionIndex SectionIndex,
                                          const LVNameInfo &NameInfo) {
diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
index 14538c1aefa18..3dbe11accd2d4 100644
--- a/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
+++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp
@@ -28,223 +28,6 @@ using namespace llvm::logicalview;
 
 #define DEBUG_TYPE "DWARFReader"
 
-LVElement *LVDWARFReader::createElement(dwarf::Tag Tag) {
-  CurrentScope = nullptr;
-  CurrentSymbol = nullptr;
-  CurrentType = nullptr;
-  CurrentRanges.clear();
-
-  if (!options().getPrintSymbols()) {
-    switch (Tag) {
-    // As the command line options did not specify a request to print
-    // logical symbols (--print=symbols or --print=all or --print=elements),
-    // skip its creation.
-    case dwarf::DW_TAG_formal_parameter:
-    case dwarf::DW_TAG_unspecified_parameters:
-    case dwarf::DW_TAG_member:
-    case dwarf::DW_TAG_variable:
-    case dwarf::DW_TAG_inheritance:
-    case dwarf::DW_TAG_constant:
-    case dwarf::DW_TAG_call_site_parameter:
-    case dwarf::DW_TAG_GNU_call_site_parameter:
-      return nullptr;
-    default:
-      break;
-    }
-  }
-
-  switch (Tag) {
-  // Types.
-  case dwarf::DW_TAG_base_type:
-    CurrentType = createType();
-    CurrentType->setIsBase();
-    if (options().getAttributeBase())
-      CurrentType->setIncludeInPrint();
-    return CurrentType;
-  case dwarf::DW_TAG_const_type:
-    CurrentType = createType();
-    CurrentType->setIsConst();
-    CurrentType->setName("const");
-    return CurrentType;
-  case dwarf::DW_TAG_enumerator:
-    CurrentType = createTypeEnumerator();
-    return CurrentType;
-  case dwarf::DW_TAG_imported_declaration:
-    CurrentType = createTypeImport();
-    CurrentType->setIsImportDeclaration();
-    return CurrentType;
-  case dwarf::DW_TAG_imported_module:
-    CurrentType = createTypeImport();
-    CurrentType->setIsImportModule();
-    return CurrentType;
-  case dwarf::DW_TAG_pointer_type:
-    CurrentType = createType();
-    CurrentType->setIsPointer();
-    CurrentType->setName("*");
-    return CurrentType;
-  case dwarf::DW_TAG_ptr_to_member_type:
-    CurrentType = createType();
-    CurrentType->setIsPointerMember();
-    CurrentType->setName("*");
-    return CurrentType;
-  case dwarf::DW_TAG_reference_type:
-    CurrentType = createType();
-    CurrentType->setIsReference();
-    CurrentType->setName("&");
-    return CurrentType;
-  case dwarf::DW_TAG_restrict_type:
-    CurrentType = createType();
-    CurrentType->setIsRestrict();
-    CurrentType->setName("restrict");
-    return CurrentType;
-  case dwarf::DW_TAG_rvalue_reference_type:
-    CurrentType = createType();
-    CurrentType->setIsRvalueReference();
-    CurrentType->setName("&&");
-    return CurrentType;
-  case dwarf::DW_TAG_subrange_type:
-    CurrentType = createTypeSubrange();
-    return CurrentType;
-  case dwarf::DW_TAG_template_value_parameter:
-    CurrentType = createTypeParam();
-    CurrentType->setIsTemplateValueParam();
-    return CurrentType;
-  case dwarf::DW_TAG_template_type_parameter:
-    CurrentType = createTypeParam();
-    CurrentType->setIsTemplateTypeParam();
-    return CurrentType;
-  case dwarf::DW_TAG_GNU_template_template_param:
-    CurrentType = createTypeParam();
-    CurrentType->setIsTemplateTemplateParam();
-    return CurrentType;
-  case dwarf::DW_TAG_typedef:
-    CurrentType = createTypeDefinition();
-    return CurrentType;
-  case dwarf::DW_TAG_unspecified_type:
-    CurrentType = createType();
-    CurrentType->setIsUnspecified();
-    return CurrentType;
-  case dwarf::DW_TAG_volatile_type:
-    CurrentType = createType();
-    CurrentType->setIsVolatile();
-    CurrentType->setName("volatile");
-    return CurrentType;
-
-  // Symbols.
-  case dwarf::DW_TAG_formal_parameter:
-    CurrentSymbol = createSymbol();
-    CurrentSymbol->setIsParameter();
-    return CurrentSymbol;
-  case dwarf::DW_TAG_unspecified_parameters:
-    CurrentSymbol = createSymbol();
-    CurrentSymbol->setIsUnspecified();
-    CurrentSymbol->setName("...");
-    return CurrentSymbol;
-  case dwarf::DW_TAG_member:
-    CurrentSymbol = createSymbol();
-    CurrentSymbol->setIsMember();
-    return CurrentSymbol;
-  case dwarf::DW_TAG_variable:
-    CurrentSymbol = createSymbol();
-    CurrentSymbol->setIsVariable();
-    return CurrentSymbol;
-  case dwarf::DW_TAG_in...
[truncated]

@CarlosAlbertoEnciso
Copy link
Member Author

Initially the hoisted code was done in #135440

Copy link
Member

@jmorse jmorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What with this being purely mechanical and heading up the class hierachy, LGTM

@CarlosAlbertoEnciso CarlosAlbertoEnciso merged commit fef5096 into llvm:main Jun 4, 2025
15 checks passed
@CarlosAlbertoEnciso
Copy link
Member Author

@jmorse Thanks for your additional note.

@CarlosAlbertoEnciso CarlosAlbertoEnciso deleted the dwarf-binary-reader-nfc branch June 4, 2025 16:04
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
…lvm#142740)

Hoist out from LVDWARFReader and LVBinaryReader some generic
code, so it can be available to other readers that do not share the
binary format.
DhruvSrivastavaX pushed a commit to DhruvSrivastavaX/lldb-for-aix that referenced this pull request Jun 12, 2025
…lvm#142740)

Hoist out from LVDWARFReader and LVBinaryReader some generic
code, so it can be available to other readers that do not share the
binary format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants