public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applied] ir: translation_unit::is_empty should work without environment.
Date: Mon, 05 Sep 2022 18:20:16 +0200	[thread overview]
Message-ID: <87edwpkd33.fsf@redhat.com> (raw)

Hello,

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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 7c8b6640..91c8e99b 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -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.
 ///
-- 
2.37.2


-- 
		Dodji


                 reply	other threads:[~2022-09-05 16:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87edwpkd33.fsf@redhat.com \
    --to=dodji@redhat.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).