This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
New langhook: lang_get_callee_fndecl
- From: Andrew Haley <aph at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 3 Oct 2003 17:17:58 +0100
- Subject: New langhook: lang_get_callee_fndecl
Java wraps the target of some CALL_EXPRs in a indirection via a method
table, which makes get_callee_fndecl() fail and so we don't vreate a
proper call graph. This new langhook allows front ends to retrieve
the target of a call if the middle can't do it straightforwardly.
Andrew.
2003-10-03 Andrew Haley <aph@redhat.com>
* tree.c (get_callee_fndecl): Call
lang_hooks.lang_get_callee_fndecl.
* langhooks-def.h (LANG_HOOKS_GET_CALLEE_FNDECL): New.
(lhd_get_callee_fndecl): New.
Index: langhooks-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks-def.h,v
retrieving revision 1.68
diff -c -2 -p -r1.68 langhooks-def.h
*** langhooks-def.h 17 Sep 2003 20:52:40 -0000 1.68
--- langhooks-def.h 3 Oct 2003 16:16:16 -0000
*************** extern bool lhd_decl_ok_for_sibcall (tre
*** 68,71 ****
--- 68,72 ----
extern tree lhd_expr_size (tree);
extern bool lhd_decl_uninit (tree);
+ extern tree lhd_get_callee_fndecl (tree);
extern size_t lhd_tree_size (enum tree_code);
*************** extern tree lhd_callgraph_analyze_expr (
*** 120,123 ****
--- 121,125 ----
#define LANG_HOOKS_PRINT_ERROR_FUNCTION lhd_print_error_function
#define LANG_HOOKS_DECL_PRINTABLE_NAME lhd_decl_printable_name
+ #define LANG_HOOKS_GET_CALLEE_FNDECL lhd_return_null_tree
#define LANG_HOOKS_EXPR_SIZE lhd_expr_size
#define LANG_HOOKS_DECL_UNINIT lhd_decl_uninit
*************** extern int lhd_tree_dump_type_quals (tre
*** 298,301 ****
--- 300,304 ----
LANG_HOOKS_PRINT_IDENTIFIER, \
LANG_HOOKS_DECL_PRINTABLE_NAME, \
+ LANG_HOOKS_GET_CALLEE_FNDECL, \
LANG_HOOKS_PRINT_ERROR_FUNCTION, \
LANG_HOOKS_EXPR_SIZE, \
Index: langhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.h,v
retrieving revision 1.75
diff -c -2 -p -r1.75 langhooks.h
*** langhooks.h 17 Sep 2003 20:52:40 -0000 1.75
--- langhooks.h 3 Oct 2003 16:16:17 -0000
*************** struct lang_hooks
*** 379,382 ****
--- 379,385 ----
const char *(*decl_printable_name) (tree decl, int verbosity);
+ /* Given a CALL_EXPR, return a function decl that is its target. */
+ tree (*lang_get_callee_fndecl) (tree);
+
/* Called by report_error_function to print out function name. */
void (*print_error_function) (struct diagnostic_context *, const char *);
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.330
diff -c -2 -p -r1.330 tree.c
*** tree.c 22 Sep 2003 05:09:12 -0000 1.330
--- tree.c 3 Oct 2003 16:16:18 -0000
*************** get_callee_fndecl (tree call)
*** 4440,4446 ****
&& TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL)
return TREE_OPERAND (addr, 0);
!
! /* We couldn't figure out what was being called. */
! return NULL_TREE;
}
--- 4440,4447 ----
&& TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL)
return TREE_OPERAND (addr, 0);
!
! /* We couldn't figure out what was being called. Maybe the front
! end has some idea. */
! return (*lang_hooks.lang_get_callee_fndecl) (call);
}