summaryrefslogtreecommitdiff
path: root/gdb/symtab.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-11-17 12:05:58 -0700
committerTom Tromey <tom@tromey.com>2017-11-17 14:34:14 -0700
commitcf724bc93ee954a6f7aac0557afc41c1316dc80c (patch)
tree4fe0e1abc6f5e512121fa9ad6e263b2aff6682bf /gdb/symtab.h
parent68e745e38edebd2a12d60ef7b5774066db3f1c40 (diff)
downloadbinutils-gdb-cf724bc93ee954a6f7aac0557afc41c1316dc80c.tar.gz
Use an enum to represent subclasses of symbol
This changes struct symbol to use an enum to encode the concrete subclass of a particular symbol. Note that "enum class" doesn't work properly with bitfields, so a plain enum is used. 2017-11-17 Tom Tromey <tom@tromey.com> * symtab.h (enum symbol_subclass_kind): New. (struct symbol) <is_cplus_template_function, is_rust_vtable>: Remove. <subclass>: New member. (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION): Update. * rust-lang.c (rust_get_trait_object_pointer): Update. * dwarf2read.c (read_func_scope): Update. (read_variable): Update.
Diffstat (limited to 'gdb/symtab.h')
-rw-r--r--gdb/symtab.h26
1 files changed, 18 insertions, 8 deletions
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 83d0ff25696..2d826aabb50 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1009,6 +1009,21 @@ struct symbol_impl
const struct symbol_register_ops *ops_register;
};
+/* struct symbol has some subclasses. This enum is used to
+ differentiate between them. */
+
+enum symbol_subclass_kind
+{
+ /* Plain struct symbol. */
+ SYMBOL_NONE,
+
+ /* struct template_symbol. */
+ SYMBOL_TEMPLATE,
+
+ /* struct rust_vtable_symbol. */
+ SYMBOL_RUST_VTABLE
+};
+
/* This structure is space critical. See space comments at the top. */
struct symbol
@@ -1058,14 +1073,9 @@ struct symbol
/* Whether this is an inlined function (class LOC_BLOCK only). */
unsigned is_inlined : 1;
- /* True if this is a C++ function symbol with template arguments.
- In this case the symbol is really a "struct template_symbol". */
- unsigned is_cplus_template_function : 1;
-
- /* True if this is a Rust virtual table. In this case, the symbol
- can be downcast to "struct rust_vtable_symbol". */
+ /* The concrete type of this symbol. */
- unsigned is_rust_vtable : 1;
+ ENUM_BITFIELD (symbol_subclass_kind) subclass : 2;
/* Line number of this symbol's definition, except for inlined
functions. For an inlined function (class LOC_BLOCK and
@@ -1127,7 +1137,7 @@ extern const struct block_symbol null_block_symbol;
#define SYMBOL_IS_ARGUMENT(symbol) (symbol)->is_argument
#define SYMBOL_INLINED(symbol) (symbol)->is_inlined
#define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \
- (symbol)->is_cplus_template_function
+ (((symbol)->subclass) == SYMBOL_TEMPLATE)
#define SYMBOL_TYPE(symbol) (symbol)->type
#define SYMBOL_LINE(symbol) (symbol)->line
#define SYMBOL_COMPUTED_OPS(symbol) (SYMBOL_IMPL (symbol).ops_computed)