[applied] ir: Don't crash when looking at corpus-less translation units
Commit Message
Hello,
Back in the early days, there was the possibility to have an ABIXML
output that was just a translation unit. There was no XML corpus
element holding the abi-instr element. We still need to support this
going forward.
While looking at something else, I stumbled across spots in the source
code that would crash upon encountering such corpus-less ABIXML
inputs.
Fixed thus.
* src/abg-ir.cc ({decl,type}_topo_comp::operator()): Support types
that inherits from an empty corpus.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
src/abg-ir.cc | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
@@ -3353,8 +3353,9 @@ struct decl_topo_comp
// If both decls come from an abixml file, keep the order they
// have from that abixml file.
- if (f->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN
- && s->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN)
+ if ((!f->get_corpus() && !s->get_corpus())
+ || (f->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN
+ && s->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN))
return compare_using_locations(f, s);
// If a decl has artificial location, then use that one over the
@@ -3451,8 +3452,9 @@ struct type_topo_comp
{
// If both decls come from an abixml file, keep the order they
// have from that abixml file.
- if (f->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN
- && s->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN)
+ if ((!f->get_corpus() && !s->get_corpus())
+ || (f->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN
+ && s->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN))
return compare_using_locations(is_decl(f), is_decl(s));
bool f_is_ptr_ref_or_qual = is_ptr_ref_or_qual_type(f);