[PATCH 2/3] Always pass an explicit language down to c_type_print
Pedro Alves
pedro@palves.net
Fri May 6 12:33:47 GMT 2022
On 2022-05-05 21:47, Keith Seitz wrote:
> On 5/5/22 11:50, Pedro Alves wrote:
>> diff --git a/gdb/c-lang.h b/gdb/c-lang.h
>> index 46e562df055..c81c3bbc3b8 100644
>> --- a/gdb/c-lang.h
>> +++ b/gdb/c-lang.h
>> @@ -65,16 +65,17 @@ extern int c_parse (struct parser_state *);
>> extern int c_parse_escape (const char **, struct obstack *);
>> /* Defined in c-typeprint.c */
>> -extern void c_print_type (struct type *, const char *,
>> - struct ui_file *, int, int,
>> - const struct type_print_options *);
>> -/* Print a type but allow the precise language to be specified. */
>> +/* LEVEL is the depth to indent lines by. Allows the precise language
>> + to be specified, because many languages defer to C type
>> + printing. */
>
> The actual description of the function (if brief) has been removed. The new
> comment explains the LEVEL argument, but the decl only contains types. A
> casual reader (like myself) would have to go figure out to which argument this
> refers.
>
> I have to ask: Is this what you intended? It seems like a cut-n-paste
> error?
Yeah, I had just blindly moved the comment from the .c file to the .h file:
-/* LEVEL is the depth to indent lines by. */
-
-void
-c_print_type (struct type *type,
- const char *varstring,
If it was good there, it must still be good in the .h file! :-) 1/2 kidding.
The "Print a type but allow the precise language to be specified."
comment was saying that that overload was the same as the one without
the language, except it takes a language. I dropped that one, and didn't
even realize that the comment in the other overload didn't refer to
type printing.
I've changed this now to look like this:
--- c/gdb/c-lang.h
+++ w/gdb/c-lang.h
@@ -65,16 +65,17 @@ extern int c_parse (struct parser_state *);
extern int c_parse_escape (const char **, struct obstack *);
/* Defined in c-typeprint.c */
-extern void c_print_type (struct type *, const char *,
- struct ui_file *, int, int,
- const struct type_print_options *);
-/* Print a type but allow the precise language to be specified. */
+/* Print TYPE to STREAM using syntax appropriate for LANGUAGE, a
+ C-like language. The other parameters are like
+ type_language_defn::print_type's. */
-extern void c_print_type (struct type *, const char *,
- struct ui_file *, int, int,
- enum language,
- const struct type_print_options *);
+extern void c_print_type (struct type *type,
+ const char *varstring,
+ struct ui_file *stream,
+ int show, int level,
+ enum language language,
+ const struct type_print_options *flags);
extern void c_print_typedef (struct type *,
struct symbol *,
More information about the Gdb-patches
mailing list