[PATCH] D132900: [DWARF] Fix infinite recursion in Type Printer.
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 23 14:12:02 PDT 2022
dblaikie added a comment.
So, I'm not sure what failures you're seeing, but I tried this locally:
$ git diff
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
index 2d8add64537c..969a6525d821 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
@@ -284,12 +284,32 @@ void DWARFTypePrinter::appendUnqualifiedNameAfter(
void DWARFTypePrinter::appendQualifiedName(DWARFDie D) {
if (D)
- appendScopes(D.getParent());
+ switch (D.getTag()) {
+ case dwarf::DW_TAG_structure_type:
+ case dwarf::DW_TAG_class_type:
+ case dwarf::DW_TAG_union_type:
+ case dwarf::DW_TAG_namespace:
+ case dwarf::DW_TAG_enumeration_type:
+ appendScopes(D.getParent());
+ break;
+ default:
+ break;
+ }
appendUnqualifiedName(D);
}
DWARFDie DWARFTypePrinter::appendQualifiedNameBefore(DWARFDie D) {
if (D)
- appendScopes(D.getParent());
+ switch (D.getTag()) {
+ case dwarf::DW_TAG_structure_type:
+ case dwarf::DW_TAG_class_type:
+ case dwarf::DW_TAG_union_type:
+ case dwarf::DW_TAG_namespace:
+ case dwarf::DW_TAG_enumeration_type:
+ appendScopes(D.getParent());
+ break;
+ default:
+ break;
+ }
return appendUnqualifiedNameBefore(D);
}
bool DWARFTypePrinter::appendTemplateParameters(DWARFDie D,
@@ -516,7 +536,7 @@ void DWARFTypePrinter::appendSubroutineNameAfter(
for (DWARFDie P : D) {
if (P.getTag() != DW_TAG_formal_parameter &&
P.getTag() != DW_TAG_unspecified_parameters)
- return;
+ continue;
DWARFDie T = resolveReferencedType(P);
if (SkipFirstParamIfArtificial && RealFirst && P.find(DW_AT_artificial)) {
FirstParamIfArtificial = T;
and I tried the initial test case and the follow-up one and they seem to work correctly without assertions/crashes/infinite recursion for me.
Can you help me understand what you're hitting up against?
(this ^ patch isn't quite ready - would be good to refactor out the two switches into a single switch to avoid code duplication & possibly adding extra test coverage for that `return` -> `continue` change that lets the function type be fully printed despite non-parameter DIEs in the subroutine type)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132900/new/
https://reviews.llvm.org/D132900
More information about the llvm-commits
mailing list