[02/10] Factor out block::containing_function_block
Commit Message
Factor out new function block::containing_function_block out of
block::containing_function.
---
gdb/block.c | 18 ++++++++++++++----
gdb/block.h | 5 +++++
2 files changed, 19 insertions(+), 4 deletions(-)
@@ -99,15 +99,25 @@ block::linkage_function () const
/* See block.h. */
-struct symbol *
-block::containing_function () const
+const struct block *
+block::containing_function_block () const
{
const block *bl = this;
- while (bl->function () == NULL && bl->superblock () != NULL)
+ while (bl->function () == nullptr && bl->superblock () != nullptr)
bl = bl->superblock ();
- return bl->function ();
+ return bl->function () != nullptr ? bl : nullptr;
+}
+
+/* See block.h. */
+
+struct symbol *
+block::containing_function () const
+{
+ const block *bl = containing_function_block ();
+
+ return bl != nullptr ? bl->function () : nullptr;
}
/* See block.h. */
@@ -258,6 +258,11 @@ struct block : public allocate_on_obstack<block>
struct symbol *containing_function () const;
+ /* Return the block for the closest enclosing function, which might be an
+ inline function. */
+
+ const struct block *containing_function_block () const;
+
/* Return the static block associated with this block. Return NULL
if block is a global block. */