Skip to content

Commit

Permalink
DWARF reader workaround for declaration-only types
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
myxoid committed Oct 2, 2020
1 parent b96040e commit b49e705
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/abg-dwarf-reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4808,6 +4808,23 @@ class read_context
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;
Expand Down

0 comments on commit b49e705

Please sign in to comment.