aboutsummaryrefslogtreecommitdiff
path: root/gdb/language.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2020-11-16 19:15:00 +0000
committerPedro Alves <pedro@palves.net>2020-11-20 13:27:01 +0000
commitcbbcd7a716d7f1f65c57aa6ba6e034ecb9a78378 (patch)
treed2d5bd43aaa5a9adf354ff9f17945c285bc4ce04 /gdb/language.c
parente6f6aa8d184c38230d9acd91a49aa0cbe3f37e42 (diff)
downloadgdb-cbbcd7a716d7f1f65c57aa6ba6e034ecb9a78378.zip
gdb-cbbcd7a716d7f1f65c57aa6ba6e034ecb9a78378.tar.gz
gdb-cbbcd7a716d7f1f65c57aa6ba6e034ecb9a78378.tar.bz2
language_lookup_primitive_type, std::function -> gdb::function_view
gdb/ChangeLog: * language.c (language_arch_info::lookup_primitive_type): Use gdb::function_view instead of gdb::function. (template language_lookup_primitive_type): Rename to ... (language_lookup_primitive_type_1): ... this, and make static. (language_lookup_primitive_type(const struct language_defn *, struct gdbarch *, const char *): Make non-template. (language_lookup_primitive_type(const struct language_defn *, struct gdbarch *, std::function<bool (struct type *)>): Make non-template and use gdb::function_view. * language.h (language_arch_info::lookup_primitive_type): Use gdb::function_view instead of std::function. (language_lookup_primitive_type): No longer template. * opencl-lang.c (lookup_opencl_vector_type): 'filter' is now a lambda instead of a std::function.
Diffstat (limited to 'gdb/language.c')
-rw-r--r--gdb/language.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/gdb/language.c b/gdb/language.c
index 579cf91..5e64e6a 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -1088,7 +1088,7 @@ language_arch_info::lookup_primitive_type (const char *name)
struct type *
language_arch_info::lookup_primitive_type
- (std::function<bool (struct type *)> filter)
+ (gdb::function_view<bool (struct type *)> filter)
{
for (struct type_and_symbol &tas : primitive_types_and_symbols)
{
@@ -1111,32 +1111,39 @@ language_arch_info::lookup_primitive_type_as_symbol (const char *name,
return nullptr;
}
-/* See language.h. */
+/* Helper for the language_lookup_primitive_type overloads to forward
+ to the corresponding language's lookup_primitive_type overload. */
template<typename T>
-struct type *
-language_lookup_primitive_type (const struct language_defn *la,
- struct gdbarch *gdbarch,
- T arg)
+static struct type *
+language_lookup_primitive_type_1 (const struct language_defn *la,
+ struct gdbarch *gdbarch,
+ T arg)
{
struct language_gdbarch *ld =
(struct language_gdbarch *) gdbarch_data (gdbarch, language_gdbarch_data);
return ld->arch_info[la->la_language].lookup_primitive_type (arg);
}
-/* Template instantiation. */
+/* See language.h. */
-template struct type *
+struct type *
language_lookup_primitive_type (const struct language_defn *la,
struct gdbarch *gdbarch,
- const char *arg);
+ const char *name)
+{
+ return language_lookup_primitive_type_1 (la, gdbarch, name);
+}
-/* Template instantiation. */
+/* See language.h. */
-template struct type *
+struct type *
language_lookup_primitive_type (const struct language_defn *la,
struct gdbarch *gdbarch,
- std::function<bool (struct type *)> arg);
+ gdb::function_view<bool (struct type *)> filter)
+{
+ return language_lookup_primitive_type_1 (la, gdbarch, filter);
+}
/* See language.h. */