aboutsummaryrefslogtreecommitdiff
path: root/gdb/compile/compile-c.h
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2018-08-10 10:48:03 -0700
committerKeith Seitz <keiths@redhat.com>2018-08-10 11:14:25 -0700
commit9cdfd9a26ef63ef2fee58c0e7475b5373b61e5d1 (patch)
tree65edd204b72edbe64897ffef609af0e566c4db26 /gdb/compile/compile-c.h
parent18cdc6d8f8e8b55e84783e0a2b5a80b41a0e917b (diff)
downloadgdb-9cdfd9a26ef63ef2fee58c0e7475b5373b61e5d1.zip
gdb-9cdfd9a26ef63ef2fee58c0e7475b5373b61e5d1.tar.gz
gdb-9cdfd9a26ef63ef2fee58c0e7475b5373b61e5d1.tar.bz2
Change compile_instance/compile_c_instance into classes
This patch changes structs compile_instance and compile_c_instance into classes. Because of the nature of the change, there are a number of unavoidably mechanical changes buried in here, such as turning variable access of the POD struct into method calls, removing the struct keyword, and changing access of the plugin from "c_plugin->operation()" to "plugin ().operation ()". There is one "non-trivial" change associated with this patch, though. The type cache and symbol error maps have been moved into the base class, believing these facilities would be used other language implementations. [They are indeed re-used by C++.] gdb/ChangeLog: * compile/compile-c-support.c (c_get_compile_context): Use `new' instead of `new_compile_instance'. * compile/compile-c-symbols.c (compile_instance::insert_symbol_error): Update description. If the symbol error map is not initialized, create it. (generate_c_for_for_one_symbol): Do not check/initialize the symbol error map. * compile/compile-c-types.c (compile_c_instance): Make a class. Update all callers. (compile_instance::compile_instance): Initialize the type cache. (get_cached_type): New function. (insert_type): Update description. (compile_c_instance::m_default_cflags): Define. (convert_type): Update description. Use get_cached_type. (delete_instance): Moved to destructor. (new_compile_instance): Moved to constructor. * compile/compile-c.h (compile_c_instance): Make class inheriting from compile_instance. <base>: Remove field. <type_map, symbol_err_map>: Move to base class. <c_plugin>: Rename to `m_plugin' and remove pointer type. * compile/compile-internal.h (compile_instance): Make class. <type_map_t, symbol_err_map_t>: Define. <fe>: Rename to `m_gcc_fe'. <scope, block, gcc_target_options>: Add `m_' prefix. <m_type_map, m_symbol_err_map>: New fields, moved from compile_c_instance. <destroy>: Remove. (convert_type, new_compile_instance): Remove. * compile/compile.c (cleanup_compile_instance): Remove. (compile_to_object): Use unique_ptr to eliminate cleanups. (compile_instance::set_print_callback, compile_instance::version) (compile_instance::set_verbose) (compile_instance::set_driver_filename) (compile_instance::set_triplet_regexp) (compile_instance::set_arguments) (compile_instance::set_source_file) (compile_instance::compile): Define.
Diffstat (limited to 'gdb/compile/compile-c.h')
-rw-r--r--gdb/compile/compile-c.h33
1 files changed, 21 insertions, 12 deletions
diff --git a/gdb/compile/compile-c.h b/gdb/compile/compile-c.h
index ffa5802..4dece9c 100644
--- a/gdb/compile/compile-c.h
+++ b/gdb/compile/compile-c.h
@@ -19,7 +19,6 @@
#include "common/enum-flags.h"
#include "gcc-c-plugin.h"
-#include "hashtab.h"
/* enum-flags wrapper. */
@@ -36,20 +35,30 @@ extern gcc_c_symbol_address_function gcc_symbol_address;
/* A subclass of compile_instance that is specific to the C front
end. */
-struct compile_c_instance
+class compile_c_instance : public compile_instance
{
- /* Base class. Note that the base class vtable actually points to a
- gcc_c_fe_vtable. */
- struct compile_instance base;
+public:
+ explicit compile_c_instance (struct gcc_c_context *gcc_c)
+ : compile_instance (&gcc_c->base, m_default_cflags),
+ m_plugin (gcc_c)
+ {
+ m_plugin.set_callbacks (gcc_convert_symbol, gcc_symbol_address, this);
+ }
- /* Map from gdb types to gcc types. */
- htab_t type_map;
+ /* Convert a gdb type, TYPE, to a GCC type.
- /* Map from gdb symbols to gcc error messages to emit. */
- htab_t symbol_err_map;
+ The new GCC type is returned. */
+ gcc_type convert_type (struct type *type);
- /* GCC C plugin. */
- gcc_c_plugin *c_plugin;
+ /* Return a handle for the GCC plug-in. */
+ gcc_c_plugin &plugin () { return m_plugin; }
+
+private:
+ /* Default compiler flags for C. */
+ static const char *m_default_cflags;
+
+ /* The GCC plug-in. */
+ gcc_c_plugin m_plugin;
};
/* Emit code to compute the address for all the local variables in
@@ -59,7 +68,7 @@ struct compile_c_instance
extern gdb::unique_xmalloc_ptr<unsigned char>
generate_c_for_variable_locations
- (struct compile_c_instance *compiler,
+ (compile_instance *compiler,
string_file &stream,
struct gdbarch *gdbarch,
const struct block *block,