[PATCH] D132900: [DWARF] Fix infinite recursion in Type Printer.
Alexander Yermolovich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 14 14:17:51 PDT 2022
ayermolo 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());
+
----------------
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.
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