This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[drow-cplus-branch] Print qualifiers after types for C++


In C, one calls it "const int"; in C++, at least in v3, it's generally "int
const".  Update the type printer to match.  The goal is to produce roughly
the same strings for type-printed methods as for demangled ones.  Committed
on the branch.

I found another lovely wart while debugging this.  Given a class
"Foo<char volatile*>", the DWARF-2 debugging information will give its name
as "Foo<volatile char*>" - even though that's not how it appears in mangled
method names.  We'll have to canonicalize qualifiers at some stage in
recording symbols.  Wonderful.  (And I'll eventually file a GCC bug report
to get this fixed.)

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2002-10-30  Daniel Jacobowitz  <drow@mvista.com>

	* c-typeprint.c (c_type_print_modifier_before): New function.
	(c_type_print_modifier_after): New function.
	(c_type_print_base): Call c_type_print_modifier_before and
	c_type_print_modifier_after.

Index: c-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-typeprint.c,v
retrieving revision 1.22.10.3
diff -u -p -r1.22.10.3 c-typeprint.c
--- c-typeprint.c	29 Oct 2002 03:10:51 -0000	1.22.10.3
+++ c-typeprint.c	30 Oct 2002 23:08:12 -0000
@@ -336,8 +336,19 @@ c_type_print_modifier (struct type *type
     fprintf_filtered (stream, " ");
 }
 
+static void
+c_type_print_modifier_before (struct type *type, struct ui_file *stream)
+{
+  if (current_language->la_language != language_cplus)
+    c_type_print_modifier (type, stream, 0, 1);
+}
 
-
+static void
+c_type_print_modifier_after (struct type *type, struct ui_file *stream)
+{
+  if (current_language->la_language == language_cplus)
+    c_type_print_modifier (type, stream, 1, 0);
+}
 
 static void
 c_type_print_args (struct type *type, struct ui_file *stream)
@@ -675,8 +686,9 @@ c_type_print_base (struct type *type, st
   if (show <= 0
       && TYPE_NAME (type) != NULL)
     {
-      c_type_print_modifier (type, stream, 0, 1);
+      c_type_print_modifier_before (type, stream);
       fputs_filtered (TYPE_NAME (type), stream);
+      c_type_print_modifier_after (type, stream);
       return;
     }
 
@@ -695,7 +707,7 @@ c_type_print_base (struct type *type, st
       break;
 
     case TYPE_CODE_STRUCT:
-      c_type_print_modifier (type, stream, 0, 1);
+      c_type_print_modifier_before (type, stream);
       /* Note TYPE_CODE_STRUCT and TYPE_CODE_CLASS have the same value,
        * so we use another means for distinguishing them.
        */
@@ -728,7 +740,7 @@ c_type_print_base (struct type *type, st
       goto struct_union;
 
     case TYPE_CODE_UNION:
-      c_type_print_modifier (type, stream, 0, 1);
+      c_type_print_modifier_before (type, stream);
       fprintf_filtered (stream, "union ");
 
     struct_union:
@@ -752,6 +764,7 @@ c_type_print_base (struct type *type, st
 	  /* If we just printed a tag name, no need to print anything else.  */
 	  if (TYPE_TAG_NAME (type) == NULL)
 	    fprintf_filtered (stream, "{...}");
+	  c_type_print_modifier_after (type, stream);
 	}
       else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
 	{
@@ -1026,6 +1039,8 @@ c_type_print_base (struct type *type, st
 
 	  fprintfi_filtered (level, stream, "}");
 
+	  c_type_print_modifier_after (type, stream);
+
 	  if (TYPE_LOCALTYPE_PTR (type) && show >= 0)
 	    fprintfi_filtered (level, stream, " (Local at %s:%d)\n",
 			       TYPE_LOCALTYPE_FILE (type),
@@ -1036,7 +1051,7 @@ c_type_print_base (struct type *type, st
       break;
 
     case TYPE_CODE_ENUM:
-      c_type_print_modifier (type, stream, 0, 1);
+      c_type_print_modifier_before (type, stream);
       /* HP C supports sized enums */
       if (hp_som_som_object_present)
 	switch (TYPE_LENGTH (type))
@@ -1117,7 +1132,7 @@ c_type_print_base (struct type *type, st
          template <class T1, class T2> class "
          and then merges with the struct/union/class code to
          print the rest of the definition. */
-      c_type_print_modifier (type, stream, 0, 1);
+      c_type_print_modifier_before (type, stream);
       fprintf_filtered (stream, "template <");
       for (i = 0; i < TYPE_NTEMPLATE_ARGS (type); i++)
 	{
@@ -1152,8 +1167,9 @@ c_type_print_base (struct type *type, st
          is no type name, then complain. */
       if (TYPE_NAME (type) != NULL)
 	{
-	  c_type_print_modifier (type, stream, 0, 1);
+	  c_type_print_modifier_before (type, stream);
 	  fputs_filtered (TYPE_NAME (type), stream);
+	  c_type_print_modifier_after (type, stream);
 	}
       else
 	{


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]