ir: translation_unit::is_empty should work without environment.
authorDodji Seketeli <dodji@redhat.com>
Fri, 2 Sep 2022 15:34:04 +0000 (17:34 +0200)
committerDodji Seketeli <dodji@redhat.com>
Mon, 5 Sep 2022 16:13:02 +0000 (18:13 +0200)
I noticed that some code failed trying to call
translation_unit::is_empty in the absence of the instance of the
abigail::ir::environment type used to create the IR.

This is because translation_unit::is_empty was trying to create
something.  That's odd.  It shouldn't need to create anything to test
for its emptiness.  Fixed thus.

* src/abg-ir.cc (translation_unit::is_empty): If there is no
global scope, then we know its empty.  No need to create one.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-ir.cc

index 7c8b66404e31ef4f130c0f63efb0de664922dac3..91c8e99bd58e99f2da49c55a651fdc3a91ccdd4f 100644 (file)
@@ -1353,7 +1353,11 @@ translation_unit::get_loc_mgr() const
 /// @return true iff the current translation unit is empty.
 bool
 translation_unit::is_empty() const
-{return get_global_scope()->is_empty();}
+{
+  if (!priv_->global_scope_)
+    return true;
+  return get_global_scope()->is_empty();
+}
 
 /// Getter of the address size in this translation unit.
 ///