diff mbox

[PATCHv2,1/5] gdb/ada: Update some predicate functions to return bool

Message ID 0ad8f4f39a6eaabe2e97467dc6f53aea89800d7e.1555455013.git.andrew.burgess@embecosm.com
State New
Headers show

Commit Message

Andrew Burgess April 16, 2019, 11:06 p.m. UTC
A later commit would like to make use of a pointer to the function
ada_is_string_type, however, this will require the function to return
a bool (so the signature matches).

As the ada_is_string_type is a predicate function, and its return
value is only ever used as either true or false, then this commit
updates the function to return a bool.

As a consequence ada_is_character_type needs to change too.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_is_character_type): Change return type to bool.
	(ada_is_string_type): Likewise.
	* ada-lang.h (ada_is_character_type): Update declaration
	(ada_is_string_type): Likewise.
---
 gdb/ChangeLog  | 7 +++++++
 gdb/ada-lang.c | 8 ++++----
 gdb/ada-lang.h | 4 ++--
 3 files changed, 13 insertions(+), 6 deletions(-)

Comments

Joel Brobecker April 18, 2019, 12:03 a.m. UTC | #1
Hi Andrew,

On Wed, Apr 17, 2019 at 12:06:06AM +0100, Andrew Burgess wrote:
> A later commit would like to make use of a pointer to the function
> ada_is_string_type, however, this will require the function to return
> a bool (so the signature matches).
> 
> As the ada_is_string_type is a predicate function, and its return
> value is only ever used as either true or false, then this commit
> updates the function to return a bool.
> 
> As a consequence ada_is_character_type needs to change too.
> 
> There should be no user visible changes after this commit.
> 
> gdb/ChangeLog:
> 
> 	* ada-lang.c (ada_is_character_type): Change return type to bool.
> 	(ada_is_string_type): Likewise.
> 	* ada-lang.h (ada_is_character_type): Update declaration
> 	(ada_is_string_type): Likewise.

This a good change, so good for me!
diff mbox

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index ccf8ed8039e..622cf59de68 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -9396,7 +9396,7 @@  value_val_atr (struct type *type, struct value *arg)
    [At the moment, this is true only for Character and Wide_Character;
    It is a heuristic test that could stand improvement].  */
 
-int
+bool
 ada_is_character_type (struct type *type)
 {
   const char *name;
@@ -9404,7 +9404,7 @@  ada_is_character_type (struct type *type)
   /* If the type code says it's a character, then assume it really is,
      and don't check any further.  */
   if (TYPE_CODE (type) == TYPE_CODE_CHAR)
-    return 1;
+    return true;
   
   /* Otherwise, assume it's a character type iff it is a discrete type
      with a known character type name.  */
@@ -9420,7 +9420,7 @@  ada_is_character_type (struct type *type)
 
 /* True if TYPE appears to be an Ada string type.  */
 
-int
+bool
 ada_is_string_type (struct type *type)
 {
   type = ada_check_typedef (type);
@@ -9435,7 +9435,7 @@  ada_is_string_type (struct type *type)
       return ada_is_character_type (elttype);
     }
   else
-    return 0;
+    return false;
 }
 
 /* The compiler sometimes provides a parallel XVS type for a given
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index ee03dbd2aad..8740916a193 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -268,9 +268,9 @@  extern struct value *ada_value_primitive_packed_val (struct value *,
 
 extern struct type *ada_coerce_to_simple_array_type (struct type *);
 
-extern int ada_is_character_type (struct type *);
+extern bool ada_is_character_type (struct type *);
 
-extern int ada_is_string_type (struct type *);
+extern bool ada_is_string_type (struct type *);
 
 extern int ada_is_tagged_type (struct type *, int);