This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: [PATCH] [C++/DWARF] Add 'using' support - take 3



On Jan 23, 2004, at 12:50 PM, Jason Merrill wrote:


On Thu, 22 Jan 2004 16:13:29 -0800, Devang Patel <dpatel@apple.com> wrote:

- Instead of emitting abstract or half backed definition now force_decl_die()
forces declaration dies for functions and variables. Related changes are

1) Remove checks that allowed definition die reuse
2) Selectively remove child dies while using subprogram declaration die as
definition die
3) Equate declaration die to line number

You mean decl number, right?

yes


+ /* Enum to distinguish imported modules vs. decls.  */
+ enum dbg_module_or_decl
+   {
+     DBG_IMPORTED_MODULE,
+     DBG_IMPORTED_DECL
+   };

Why did we need this, again? It seems to me that we should be able to tell
which it is based on the decl passed. Sorry I didn't mention this before;
I thought of it when reviewing your last patch, but looking back over my
mail I don't see it.

I want to use same debug hook (I'll rename it appropriately later) to emit
DW_AT_Friend, DW_TAG_Try_Block, DW_TAG_Catch_Block, DW_TAG_Thrown_Type etc...
so I need some one enum.



*************** gen_subprogram_die (tree decl, dw_die_re
! 	  remove_children (subr_die);
--- 10748,10757 ----
! 	  remove_child_TAG (subr_die, DW_TAG_formal_parameter);

What other children will there be?

At least newly added DW_TAG_Imported_Module or Decl die.


! force_decl_die (tree decl)
! {
...
! 	case FIELD_DECL:
! 	case VAR_DECL:
! 	  /* Set external flag to force declaration die. Restore it after
! 	   gen_decl_die() call.  */

Does this work for fields?

hmm.. now I realize that we do not need to force field_decls. If require, we
force entire type earlier.

+ dwarf2out_imported_module_or_decl (tree decl, tree context,
+ 				   enum dbg_module_or_decl tag)
+ {
...
+   /* Ignore this FUNCTION_DECL if it refers to a builtin declaration
+      of a builtin function.  */
+   if (TREE_CODE (decl) == FUNCTION_DECL
+       && DECL_EXTERNAL (decl)
+       && DECL_BUILT_IN (decl))
+     return;

Ignore builtins in the front end, not in dwarf2out.

ok


+ /* OK, now we have DIEs for decl as well as scope. Emit imported die. */
+ if (tag == DBG_IMPORTED_MODULE)
+ imported_die = new_die (DW_TAG_imported_module, scope_die, context);
+ else if (tag == DBG_IMPORTED_DECL)
+ imported_die = new_die (DW_TAG_imported_declaration, scope_die, context);
+ else
+ abort ();

So if we drop the enum, this would just check TREE_CODE (decl) == NAMESPACE_DECL.

*************** do_local_using_decl (tree decl, tree sco
+   /* Emit debug info.  */
+   cp_emit_debug_info_for_using (orig_decl, current_scope());

I would expect this to need !processing_template_decl, too.

ok


*************** do_using_directive (tree namespace)
*** 3289,3294 ****
--- 3312,3324 ----
    else
      /* direct usage */
      add_using_namespace (current_namespace, namespace, 0);
+
+   /* Emit debugging info.  */
+   if (current_namespace != global_namespace)
+     context = current_namespace;
+   (*debug_hooks->imported_module_or_decl) (namespace,
+ 					   current_scope (),
+ 					   DBG_IMPORTED_MODULE);
  }

I should have been more clear. If toplevel_bindings_p(), use
current_namespace. Otherwise, use current_scope(). Conveniently, this is
the same condition tested by the if/else immediately above this patch.

Well, I was dense here :-). T tried to get correct context, but without using
toplevel_bindings_p(), earlier. When you asked question about it last time, I
couldn't myself decode my own logic, so I gave up and blindly followed your
suggestion.


This code should also check !processing_template_decl.

ok


I will send updated patch soon.

Thank you,
--
Devang


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