[PATCH] D132900: [DWARF] Fix infinite recursion in Type Printer.
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 15 13:27:40 PDT 2022
dblaikie added inline comments.
================
Comment at: llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp:289-290
void DWARFTypePrinter::appendQualifiedName(DWARFDie D) {
- if (D)
+ if (D && !ScopelessDIEs.count(D.getTag()))
appendScopes(D.getParent());
+
----------------
ayermolo wrote:
> dblaikie wrote:
> > Might be inclined to use a switch here, rather than a set lookup - and it's probably easier to make a positive list of the things that are scoped than those that aren't.
> Unfortunately this doesn't work for:
>
> ```
> class codecvt_base
> {
> public:
> enum result {
> ok
> };
> };
>
> class __codecvt_abstract_base
> : public codecvt_base
> {
> public:
> result out(const wchar_t* __from) const {
> return result::ok;
> }
> };
>
> class codecvt
> : public __codecvt_abstract_base{};
>
> inline bool
> __str_codecvt_out()
> {
> using _Codecvt = codecvt;
> using _ConvFn = codecvt_base::result
> (_Codecvt::*)(const wchar_t*) const;
> _ConvFn __fn = &codecvt::out;
> return true;
> }
>
> bool test() {
> return __str_codecvt_out();
> }
> ```
>
> It prints out this before eventually crashing.
> 0x00000133: DW_TAG_formal_parameter [8] (0x00000126)
> DW_AT_type [DW_FORM_ref4] (cu + 0x0138 => {0x00000138} "codecvt_base::result (codecvt_base::result (codecvt_base::result (codecvt_base::result (codecvt_base::result (codecvt_base::result (codecvt_base::result (codecvt_base::result (codecvt_base::result (codecvt_base::result (::codecvt_base::result (::const _Codecvt *::codecvt_base::result (::const _Codecvt *::codecvt_base::result (::const _Codecvt *::codecvt_base::result (::const _Codecvt *::codecvt_base::result (::const _Codecvt *::codecvt_base::result (::const _Codecvt *::codecvt_base::result (::const _Codecvt *::codecvt_base::result (::const _Codecvt *::codecvt_base::result (::const _Codecvt *::codecvt_base::result (::const _Codecvt *")
>
>
> Maybe better approach is to apply this allow list approach to DWARFTypePrinter::appendScopes? So it will return unless it's one of those TAGs.
I don't think it'd work to do this in `appendScopes` because `appendScopes` gets passed the scope, not the thing that's being scoped - and the determination on whether to skip scopes should be on the type being scoped, not the scoping.
Could you reduce the test down a bit - help understand what's interesting about this? I guess there's some other place that appends scopes that needs handling? Looks like the only other uses is `appendQualifiedNameBefore` - so I guess the handling needs to be in both of those, which sounds plausible/reasonable.
But yeah, maybe sinking a wrapper. `appendQualification` or something, which just does the `if (D) / check the type, then appendScopes(D.getParent())`
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