aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-04-29 23:12:05 -0600
committerTom Tromey <tom@tromey.com>2018-05-25 12:41:00 -0600
commit716b8bc52eef6044f1ff361e3e2eeb9307849034 (patch)
treebe8a74abc1f0764e7c94ae19b607a3ed224f8785 /gdb
parent753ff9bd837e2ba183e3ff789847a81221561392 (diff)
downloadgdb-716b8bc52eef6044f1ff361e3e2eeb9307849034.zip
gdb-716b8bc52eef6044f1ff361e3e2eeb9307849034.tar.gz
gdb-716b8bc52eef6044f1ff361e3e2eeb9307849034.tar.bz2
Change the as_*_interp functions to use dynamic_cast
This changes the various as_*_interp functions to be implemented using dynamic_cast. I believe this is a small improvement, because it is more typesafe -- the C++ runtime does the type-checking for us. ChangeLog 2018-05-25 Tom Tromey <tom@tromey.com> * tui/tui-interp.c (as_tui_interp): Use dynamic_cast. * mi/mi-interp.c (as_mi_interp): Use dynamic_cast. * cli/cli-interp.c (as_cli_interp): Use dynamic_cast.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/cli/cli-interp.c4
-rw-r--r--gdb/mi/mi-interp.c4
-rw-r--r--gdb/tui/tui-interp.c4
4 files changed, 9 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3e199b6..1cf048b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2018-05-25 Tom Tromey <tom@tromey.com>
+ * tui/tui-interp.c (as_tui_interp): Use dynamic_cast.
+ * mi/mi-interp.c (as_mi_interp): Use dynamic_cast.
+ * cli/cli-interp.c (as_cli_interp): Use dynamic_cast.
+
+2018-05-25 Tom Tromey <tom@tromey.com>
+
* cli/cli-interp.c (safe_execute_command): Use scoped_restore.
* interps.c (interp_exec): Use scoped_restore.
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index 0663301..e12d45b 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -73,9 +73,7 @@ struct cli_suppress_notification cli_suppress_notification =
static struct cli_interp *
as_cli_interp (struct interp *interp)
{
- if (strcmp (interp_name (interp), INTERP_CONSOLE) == 0)
- return (struct cli_interp *) interp;
- return NULL;
+ return dynamic_cast<cli_interp *> (interp);
}
/* Longjmp-safe wrapper for "execute_command". */
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 8bfb129..7536817 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -106,9 +106,7 @@ display_mi_prompt (struct mi_interp *mi)
static struct mi_interp *
as_mi_interp (struct interp *interp)
{
- if (interp_ui_out (interp)->is_mi_like_p ())
- return (struct mi_interp *) interp;
- return NULL;
+ return dynamic_cast<mi_interp *> (interp);
}
void
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index cf32c90..aa5e328 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -58,9 +58,7 @@ public:
static tui_interp *
as_tui_interp (struct interp *interp)
{
- if (strcmp (interp_name (interp), INTERP_TUI) == 0)
- return (tui_interp *) interp;
- return NULL;
+ return dynamic_cast<tui_interp *> (interp);
}
/* Cleanup the tui before exiting. */