diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-11-03 10:13:58 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-11-03 21:54:22 +0100 |
commit | 63510eb0acb3babcda112adeb506c8f4f47158f1 (patch) | |
tree | bdd2cf2d2e817b980fe2da850fbe377ae95567f4 | |
parent | 1e6f6c0efc0fd3386669cfa55f8333887b8d5ea5 (diff) | |
download | sparse-63510eb0acb3babcda112adeb506c8f4f47158f1.tar.gz |
remove unneeded MOD_TYPE
MOD_TYPE is used for the sparse extension which allow
to directly compare types with each others.
Expressions for direct type are EXPR_TYPE with the type in
expr->symbol and the expression itself having it's type
(expr->ctype) set to &type_ctype. This is one of the few
base/builtin types and is the only one which can have MOD_TYPE.
However, a specific modifier is not needed, the address of
the symbol can simple be used (like it is done for 'bad_ctype'
or 'incomplete_ctype'). Also, there is only a single place where
MOD_TYPE is tested: is_type_ctype(), itself used a single time.
So:
* rewrite the unique test using is_type_ctype() by directly
comparing with &type_ctype instead;
* remove the now unused is_type_ctype();
* remove MOD_TYPE from type_ctype's definition;
* remove MOD_TYPE's definition;
and spare one precious bit for other modifiers.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | gdbhelpers | 3 | ||||
-rw-r--r-- | show-parse.c | 1 | ||||
-rw-r--r-- | symbol.c | 2 | ||||
-rw-r--r-- | symbol.h | 4 |
4 files changed, 3 insertions, 7 deletions
@@ -152,9 +152,6 @@ define gdb_show_ctype if ($arg0->modifiers & MOD_ASSIGNED) printf "MOD_ASSIGNED " end - if ($arg0->modifiers & MOD_TYPE) - printf "MOD_TYPE " - end if ($arg0->modifiers & MOD_SAFE) printf "MOD_SAFE " end diff --git a/show-parse.c b/show-parse.c index 7b65ba67..68b3e718 100644 --- a/show-parse.c +++ b/show-parse.c @@ -140,7 +140,6 @@ const char *modifier_string(unsigned long mod) {MOD_NODEREF, "[noderef]"}, {MOD_TOPLEVEL, "[toplevel]"}, {MOD_ASSIGNED, "[assigned]"}, - {MOD_TYPE, "[type]"}, {MOD_SAFE, "[safe]"}, {MOD_USERTYPE, "[usertype]"}, {MOD_NORETURN, "[noreturn]"}, @@ -742,7 +742,7 @@ static const struct ctype_declare { } ctype_declaration[] = { { &bool_ctype, SYM_BASETYPE, MOD_UNSIGNED, &bits_in_bool, &max_int_alignment, &int_type }, { &void_ctype, SYM_BASETYPE, 0, NULL, NULL, NULL }, - { &type_ctype, SYM_BASETYPE, MOD_TYPE, NULL, NULL, NULL }, + { &type_ctype, SYM_BASETYPE, 0, NULL, NULL, NULL }, { &incomplete_ctype,SYM_BASETYPE, 0, NULL, NULL, NULL }, { &bad_ctype, SYM_BASETYPE, 0, NULL, NULL, NULL }, @@ -222,7 +222,7 @@ struct symbol { #define MOD_UNSIGNED 0x00004000 #define MOD_EXPLICITLY_SIGNED 0x00008000 -#define MOD_TYPE 0x00010000 + // MOD UNUSED 0x00010000 #define MOD_USERTYPE 0x00020000 #define MOD_CHAR 0x00040000 #define MOD_SHORT 0x00080000 @@ -373,7 +373,7 @@ static inline int is_signed_type(struct symbol *sym) static inline int is_type_type(struct symbol *type) { - return (type->ctype.modifiers & MOD_TYPE) != 0; + return type == &type_ctype; } static inline int is_ptr_type(struct symbol *type) |