[1/1] DWARF reader workaround for declaration-only types
Commit Message
abidw sometimes unexpectedly emits types as declaration-only (often
just preserving the size information associated with full definitions
elsewhere in the corpus.
This workaround illustrates the issue (it breaks some tests).
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
src/abg-dwarf-reader.cc | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
@@ -4808,6 +4808,23 @@ public:
cn_timer.start();
}
+ {
+ // Partition the types so that definitions appear before declarations.
+ struct Partition {
+ read_context * ctxt;
+ die_source source;
+ bool operator()(Dwarf_Off off) const
+ {
+ type_base_sptr t = ctxt->lookup_type_from_die_offset(off, source);
+ decl_base * db = dynamic_cast<decl_base *>(t.get());
+ return !db || !db->get_is_declaration_only();
+ }
+ };
+ Partition partition { this, source };
+ std::vector<Dwarf_Off>& types = types_to_canonicalize(source);
+ std::partition(types.begin(), types.end(), partition);
+ }
+
if (!types_to_canonicalize(source).empty())
{
tools_utils::timer single_type_cn_timer;