[PATCH] D132900: [DWARF] Fix infinite recursion in Type Printer.

Alexander Yermolovich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 9 14:49:32 PDT 2022


ayermolo added inline comments.


================
Comment at: llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp:287-289
+    if (CircularDep.contains(D.getOffset()))
+      return;
+    CircularDep.insert(D.getOffset());
----------------
dblaikie wrote:
> Avoid the extra lookup.
> 
> Though more generally this solution is probably incorrect - presumably it would cause problems for any type that isn't circular, but references the same type twice? eg: "void(x::y, x::y)" would fail/bail out unnecessarily? 
> 
> To catch the recursion correctly, we'd probably have to use scope chains (walking back up the list of "these are the types we're printing" and see if the type is in the list) or use scoped insertion/removal into the set (each time we go down into a type we add to the set, each time we back out, we remove from the set)?
oh yeah I don't think this is a right way. It breaks at least one unit test.


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