diff options
author | Jason Merrill <jason@redhat.com> | 2002-02-04 03:55:43 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2002-02-04 03:55:43 -0500 |
commit | 9780c24faf10be83aaab8fef66a6390bc75e40b1 (patch) | |
tree | 5e3b6ed2d6d74714731b9f2986290a2932ca24e6 /gcc | |
parent | fecaac3765895574348015a1794de65c2e2a64c6 (diff) | |
download | gcc-9780c24faf10be83aaab8fef66a6390bc75e40b1.zip gcc-9780c24faf10be83aaab8fef66a6390bc75e40b1.tar.gz gcc-9780c24faf10be83aaab8fef66a6390bc75e40b1.tar.bz2 |
xref.c: Remove.
* xref.c: Remove.
* Make-lang.in (CXX_OBJS): Remove cp/xref.o
(cp/xref.o): Remove dependencies.
* class.c (finish_struct_1, check_methods): Don't call xref fns.
(finish_struct_1): Likewise.
* friend.c (make_friend_class): Likewise.
* lex.c (cxx_init, cxx_finish, extract_interface_info): Likewise.
* spew.c (read_process_identifier): Likewise.
From-SVN: r49472
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/Make-lang.in | 3 | ||||
-rw-r--r-- | gcc/cp/class.c | 6 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 18 | ||||
-rw-r--r-- | gcc/cp/decl.c | 30 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 2 | ||||
-rw-r--r-- | gcc/cp/friend.c | 2 | ||||
-rw-r--r-- | gcc/cp/lex.c | 7 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 4 | ||||
-rw-r--r-- | gcc/cp/spew.c | 5 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 6 | ||||
-rw-r--r-- | gcc/cp/xref.c | 829 |
12 files changed, 15 insertions, 908 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0bd68be..6787e88 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2002-02-03 Jason Merrill <jason@redhat.com> + + * xref.c: Remove. + * Make-lang.in (CXX_OBJS): Remove cp/xref.o + (cp/xref.o): Remove dependencies. + * class.c (finish_struct_1, check_methods): Don't call xref fns. + (finish_struct_1): Likewise. + * friend.c (make_friend_class): Likewise. + * lex.c (cxx_init, cxx_finish, extract_interface_info): Likewise. + * spew.c (read_process_identifier): Likewise. + 2002-02-01 Jason Merrill <jason@redhat.com> PR c++/4872 diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 895b410..6123612 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -102,7 +102,7 @@ CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \ CXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \ cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parse.o cp/ptree.o cp/rtti.o \ cp/spew.o cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o \ - cp/search.o cp/semantics.o cp/tree.o cp/xref.o cp/repo.o cp/dump.o \ + cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o \ cp/optimize.o cp/mangle.o cp/cp-lang.o # Use loose warnings for this front end. @@ -280,7 +280,6 @@ cp/except.o: cp/except.c $(CXX_TREE_H) flags.h $(RTL_H) except.h toplev.h \ cp/cfns.h $(EXPR_H) libfuncs.h cp/decl.h $(OBSTACK_H) cp/expr.o: cp/expr.c $(CXX_TREE_H) $(RTL_H) flags.h $(EXPR_H) toplev.h \ except.h $(TM_P_H) -cp/xref.o: cp/xref.c $(CXX_TREE_H) input.h toplev.h cp/pt.o: cp/pt.c $(CXX_TREE_H) cp/decl.h cp/parse.h cp/lex.h toplev.h \ $(GGC_H) $(RTL_H) except.h tree-inline.h cp/error.o: cp/error.c $(CXX_TREE_H) toplev.h diagnostic.h flags.h real.h diff --git a/gcc/cp/class.c b/gcc/cp/class.c index aa83b8d..1e62c59 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3284,8 +3284,6 @@ check_field_decls (t, access_decls, empty_p, tree x = *field; tree type = TREE_TYPE (x); - GNU_xref_member (current_class_name, x); - next = &TREE_CHAIN (x); if (TREE_CODE (x) == FIELD_DECL) @@ -3925,8 +3923,6 @@ check_methods (t) for (x = TYPE_METHODS (t); x; x = TREE_CHAIN (x)) { - GNU_xref_member (current_class_name, x); - /* If this was an evil function, don't keep it in class. */ if (DECL_ASSEMBLER_NAME_SET_P (x) && IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (x))) @@ -5049,8 +5045,6 @@ finish_struct_1 (t) return; } - GNU_xref_decl (current_function_decl, t); - /* If this type was previously laid out as a forward reference, make sure we lay it out again. */ TYPE_SIZE (t) = NULL_TREE; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 703720e..8b242e5 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -932,10 +932,6 @@ extern int flag_no_gnu_keywords; extern int flag_operator_names; -/* For cross referencing. */ - -extern int flag_gnu_xref; - /* For environments where you can use GNU binutils (as, ld in particular). */ extern int flag_gnu_binutils; @@ -4370,20 +4366,6 @@ extern void check_for_new_type PARAMS ((const char *, flagged_type_tree)); extern tree add_exception_specifier PARAMS ((tree, tree, int)); extern tree merge_exception_specifiers PARAMS ((tree, tree)); -/* in xref.c */ -extern void GNU_xref_begin PARAMS ((const char *)); -extern void GNU_xref_end PARAMS ((int)); -extern void GNU_xref_file PARAMS ((const char *)); -extern void GNU_xref_start_scope PARAMS ((HOST_WIDE_INT)); -extern void GNU_xref_end_scope PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, int, int)); -extern void GNU_xref_ref PARAMS ((tree, const char *)); -extern void GNU_xref_decl PARAMS ((tree, tree)); -extern void GNU_xref_call PARAMS ((tree, const char *)); -extern void GNU_xref_function PARAMS ((tree, tree)); -extern void GNU_xref_assign PARAMS ((tree)); -extern void GNU_xref_hier PARAMS ((tree, tree, int, int, int)); -extern void GNU_xref_member PARAMS ((tree, tree)); - /* in mangle.c */ extern void init_mangle PARAMS ((void)); extern void mangle_decl PARAMS ((tree)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 41a6889..4909985 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -842,7 +842,6 @@ pushlevel (tag_transparent) newlevel = make_binding_level (); push_binding_level (newlevel, tag_transparent, keep_next_level_flag); - GNU_xref_start_scope ((size_t) newlevel); keep_next_level_flag = 0; } @@ -1301,11 +1300,6 @@ poplevel (keep, reverse, functionbody) rather than the end. This hack is no longer used. */ my_friendly_assert (keep == 0 || keep == 1, 0); - GNU_xref_end_scope ((size_t) current_binding_level, - (size_t) current_binding_level->level_chain, - current_binding_level->parm_flag, - current_binding_level->keep); - if (current_binding_level->keep == 1) keep = 1; @@ -1727,11 +1721,6 @@ poplevel_class () shadowed = TREE_CHAIN (shadowed)) pop_binding (TREE_PURPOSE (shadowed), TREE_TYPE (shadowed)); - GNU_xref_end_scope ((size_t) class_binding_level, - (size_t) class_binding_level->level_chain, - class_binding_level->parm_flag, - class_binding_level->keep); - /* Now, pop out of the binding level which we created up in the `pushlevel_class' routine. */ #if defined(DEBUG_CP_BINDING_LEVELS) @@ -8130,7 +8119,6 @@ cp_finish_decl (decl, init, asmspec_tree, flags) set_identifier_type_value (DECL_NAME (decl), type); CLASSTYPE_GOT_SEMICOLON (type) = 1; } - GNU_xref_decl (current_function_decl, decl); /* If we have installed this as the canonical typedef for this type, and that type has not been defined yet, delay emitting @@ -8171,8 +8159,6 @@ cp_finish_decl (decl, init, asmspec_tree, flags) init = check_initializer (decl, init); maybe_deduce_size_from_array_init (decl, init); - GNU_xref_decl (current_function_decl, decl); - /* Add this declaration to the statement-tree. This needs to happen after the call to check_initializer so that the DECL_STMT for a reference temp is added before the DECL_STMT for the reference itself. */ @@ -12914,7 +12900,8 @@ xref_tag_from_type (old, id, globalize) void xref_basetypes (code_type_node, name, ref, binfo) tree code_type_node; - tree name, ref; + tree name ATTRIBUTE_UNUSED; + tree ref; tree binfo; { /* In the declaration `A : X, Y, ... Z' we mark all the types @@ -12985,8 +12972,6 @@ xref_basetypes (code_type_node, name, ref, binfo) continue; } - GNU_xref_hier (name, basetype, via_public, via_virtual, 0); - /* This code replaces similar code in layout_basetypes. We put the complete_type first for implicit `typename'. */ if (!COMPLETE_TYPE_P (basetype) @@ -13127,7 +13112,6 @@ start_enum (name) if (current_class_type) TREE_ADDRESSABLE (b->tags) = 1; - GNU_xref_decl (current_function_decl, enumtype); return enumtype; } @@ -13373,10 +13357,7 @@ build_enumerator (name, value, enumtype) things like `S::i' later.) */ finish_member_declaration (decl); else - { - pushdecl (decl); - GNU_xref_decl (current_function_decl, decl); - } + pushdecl (decl); /* Add this enumeration constant to the list for this type. */ TYPE_VALUES (enumtype) = tree_cons (name, decl, TYPE_VALUES (enumtype)); @@ -14419,11 +14400,6 @@ finish_method (decl) DECL_CONTEXT (link) = NULL_TREE; } - GNU_xref_end_scope ((size_t) current_binding_level, - (size_t) current_binding_level->level_chain, - current_binding_level->parm_flag, - current_binding_level->keep); - poplevel (0, 0, 0); DECL_INITIAL (fndecl) = old_initial; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 9b1c355..7a9a21ed 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1702,8 +1702,6 @@ grokbitfield (declarator, declspecs, width) return void_type_node; } - GNU_xref_member (current_class_name, value); - if (TREE_STATIC (value)) { error ("static member `%D' cannot be a bit-field", value); diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 1d96701..441be67 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -252,8 +252,6 @@ make_friend_class (type, friend_type) return; } - GNU_xref_hier (type, friend_type, 0, 0, 1); - if (is_template_friend) friend_type = CLASSTYPE_TI_TEMPLATE (friend_type); diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 0287f70..885002a9 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -263,8 +263,6 @@ cxx_init_options () void cxx_finish () { - if (flag_gnu_xref) - GNU_xref_end (errorcount + sorrycount); c_common_finish (); } @@ -733,8 +731,6 @@ cxx_init (filename) init_cp_pragma (); - if (flag_gnu_xref) - GNU_xref_begin (filename); init_repo (filename); return filename; @@ -931,9 +927,6 @@ extract_interface_info () interface_only = finfo->interface_only; interface_unknown = finfo->interface_unknown; - - /* This happens to be a convenient place to put this. */ - if (flag_gnu_xref) GNU_xref_file (input_filename); } /* Return nonzero if S is not considered part of an diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 603326c..7ac47a1 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2526,10 +2526,6 @@ genrtl_start_function (fn) DECL_SAVED_FUNCTION_DATA (fn) = NULL; } - /* Tell the cross-reference machinery that we're defining this - function. */ - GNU_xref_function (fn, DECL_ARGUMENTS (fn)); - /* Keep track of how many functions we're presently expanding. */ ++function_depth; diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c index e610aec..212dada 100644 --- a/gcc/cp/spew.c +++ b/gcc/cp/spew.c @@ -221,16 +221,11 @@ read_process_identifier (pyylval) case RID_NOT_EQ: pyylval->code = NE_EXPR; return EQCOMPARE; default: - if (C_RID_YYCODE (id) == TYPESPEC) - GNU_xref_ref (current_function_decl, IDENTIFIER_POINTER (id)); - pyylval->ttype = ridpointers[C_RID_CODE (id)]; return C_RID_YYCODE (id); } } - GNU_xref_ref (current_function_decl, IDENTIFIER_POINTER (id)); - /* Make sure that user does not collide with our internal naming scheme. This is not necessary if '.' is used to remove them from the user's namespace, but is if '$' or double underscores are. */ diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index ba37b10..4cc576b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3013,10 +3013,6 @@ build_function_call_real (function, params, require_complete, flags) name = DECL_NAME (function); assembler_name = DECL_ASSEMBLER_NAME (function); - GNU_xref_call (current_function_decl, - IDENTIFIER_POINTER (name ? name - : TYPE_IDENTIFIER (DECL_CLASS_CONTEXT - (function)))); mark_used (function); fndecl = function; @@ -5748,8 +5744,6 @@ build_modify_expr (lhs, modifycode, rhs) if (!lvalue_or_else (lhs, "assignment")) return error_mark_node; - GNU_xref_assign (lhs); - /* Warn about modifying something that is `const'. Don't warn if this is initialization. */ if (modifycode != INIT_EXPR diff --git a/gcc/cp/xref.c b/gcc/cp/xref.c deleted file mode 100644 index 4560c4a..0000000 --- a/gcc/cp/xref.c +++ /dev/null @@ -1,829 +0,0 @@ -/* Code for handling XREF output from GNU C++. - Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 2000, 2002 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@cygnus.com) - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -#include "config.h" -#include "system.h" -#include "tree.h" -#include "cp-tree.h" -#include "input.h" -#include "toplev.h" - -/* The character(s) used to join a directory specification (obtained with - getwd or equivalent) with a non-absolute file name. */ - -#ifndef FILE_NAME_JOINER -#define FILE_NAME_JOINER "/" -#endif - -/* Nonzero if NAME as a file name is absolute. */ -#ifndef FILE_NAME_ABSOLUTE_P -#define FILE_NAME_ABSOLUTE_P(NAME) ((NAME)[0] == '/') -#endif - -/* For cross referencing. */ - -int flag_gnu_xref; - -/************************************************************************/ -/* */ -/* Common definitions */ -/* */ -/************************************************************************/ - -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -#define PALLOC(TYP) ((TYP *) xcalloc (1, sizeof (TYP))) - - -/* Return a malloc'd copy of STR. */ -#define SALLOC(STR) ((char *) ((STR) == NULL ? NULL : xstrdup (STR))) -#define SFREE(STR) ((STR) != NULL && (free (STR), 0)) - -#define STREQL(S1,S2) (strcmp ((S1), (S2)) == 0) -#define STRNEQ(S1,S2) (strcmp ((S1), (S2)) != 0) -#define STRLSS(S1,S2) (strcmp ((S1), (S2)) < 0) -#define STRLEQ(S1,S2) (strcmp ((S1), (S2)) <= 0) -#define STRGTR(S1,S2) (strcmp ((S1), (S2)) > 0) -#define STRGEQ(S1,S2) (strcmp ((S1), (S2)) >= 0) - -/************************************************************************/ -/* */ -/* Type definitions */ -/* */ -/************************************************************************/ - - -typedef struct _XREF_FILE * XREF_FILE; -typedef struct _XREF_SCOPE * XREF_SCOPE; - -typedef struct _XREF_FILE -{ - const char *name; - const char *outname; - XREF_FILE next; -} XREF_FILE_INFO; - -typedef struct _XREF_SCOPE -{ - int gid; - int lid; - XREF_FILE file; - int start; - XREF_SCOPE outer; -} XREF_SCOPE_INFO; - -/************************************************************************/ -/* */ -/* Local storage */ -/* */ -/************************************************************************/ - -static char doing_xref = 0; -static FILE * xref_file = NULL; -static char xref_name[1024]; -static XREF_FILE all_files = NULL; -static char * wd_name = NULL; -static XREF_SCOPE cur_scope = NULL; -static int scope_ctr = 0; -static XREF_FILE last_file = NULL; -static tree last_fndecl = NULL; - -/************************************************************************/ -/* */ -/* Forward definitions */ -/* */ -/************************************************************************/ -static void gen_assign PARAMS ((XREF_FILE, tree)); -static XREF_FILE find_file PARAMS ((const char *)); -static const char * filename PARAMS ((XREF_FILE)); -static const char * fctname PARAMS ((tree)); -static const char * declname PARAMS ((tree)); -static void simplify_type PARAMS ((char *)); -static const char * fixname PARAMS ((const char *, char *)); -static void open_xref_file PARAMS ((const char *)); -static const char * classname PARAMS ((tree)); - -/* Start cross referencing. FILE is the name of the file we xref. */ - -void -GNU_xref_begin (file) - const char *file; -{ - doing_xref = 1; - - if (file != NULL && STRNEQ (file,"-")) - { - open_xref_file(file); - GNU_xref_file(file); - } -} - -/* Finish cross-referencing. ERRCNT is the number of errors - we encountered. */ - -void -GNU_xref_end (ect) - int ect; -{ - XREF_FILE xf; - - if (!doing_xref) return; - - xf = find_file (input_filename); - if (xf == NULL) return; - - while (cur_scope != NULL) - GNU_xref_end_scope(cur_scope->gid,0,0,0); - - doing_xref = 0; - - if (xref_file == NULL) return; - - fclose (xref_file); - - xref_file = NULL; - all_files = NULL; - - if (ect > 0) unlink (xref_name); -} - -/* Write out xref for file named NAME. */ - -void -GNU_xref_file (name) - const char *name; -{ - XREF_FILE xf; - - if (!doing_xref || name == NULL) return; - - if (xref_file == NULL) - { - open_xref_file (name); - if (!doing_xref) return; - } - - if (all_files == NULL) - fprintf(xref_file,"SCP * 0 0 0 0 RESET\n"); - - xf = find_file (name); - if (xf != NULL) return; - - xf = PALLOC (XREF_FILE_INFO); - xf->name = SALLOC (name); - xf->next = all_files; - all_files = xf; - - if (wd_name == NULL) - wd_name = getpwd (); - - if (FILE_NAME_ABSOLUTE_P (name) || ! wd_name) - xf->outname = xf->name; - else - xf->outname = name = concat (wd_name, FILE_NAME_JOINER, name, NULL); - - fprintf (xref_file, "FIL %s %s 0\n", name, wd_name); - - filename (xf); - fctname (NULL); -} - -/* Start a scope identified at level ID. */ - -void -GNU_xref_start_scope (id) - HOST_WIDE_INT id; -{ - XREF_SCOPE xs; - XREF_FILE xf; - - if (!doing_xref) return; - xf = find_file (input_filename); - - xs = PALLOC (XREF_SCOPE_INFO); - xs->file = xf; - xs->start = lineno; - if (xs->start <= 0) xs->start = 1; - xs->gid = id; - xs->lid = ++scope_ctr; - xs->outer = cur_scope; - cur_scope = xs; -} - -/* Finish a scope at level ID. - INID is ??? - PRM is ??? - KEEP is nonzero iff this scope is retained (nonzero if it's - a compiler-generated invisible scope). - TRNS is ??? */ - -void -GNU_xref_end_scope (id,inid,prm,keep) - HOST_WIDE_INT id; - HOST_WIDE_INT inid; - int prm,keep; -{ - XREF_FILE xf; - XREF_SCOPE xs,lxs,oxs; - const char *stype; - - if (!doing_xref) return; - xf = find_file (input_filename); - if (xf == NULL) return; - - lxs = NULL; - for (xs = cur_scope; xs != NULL; xs = xs->outer) - { - if (xs->gid == id) break; - lxs = xs; - } - if (xs == NULL) return; - - if (inid != 0) { - for (oxs = cur_scope; oxs != NULL; oxs = oxs->outer) { - if (oxs->gid == inid) break; - } - if (oxs == NULL) return; - inid = oxs->lid; - } - - if (prm == 2) stype = "SUE"; - else if (prm != 0) stype = "ARGS"; - else if (keep == 2 || inid != 0) stype = "INTERN"; - else stype = "EXTERN"; - - fprintf (xref_file, "SCP %s %d %d %d ", - filename (xf), xs->start, lineno,xs->lid); - fprintf (xref_file, HOST_WIDE_INT_PRINT_DEC, inid); - fprintf (xref_file, " %s\n", stype); - - if (lxs == NULL) cur_scope = xs->outer; - else lxs->outer = xs->outer; - - free (xs); -} - -/* Output a reference to NAME in FNDECL. */ - -void -GNU_xref_ref (fndecl,name) - tree fndecl; - const char *name; -{ - XREF_FILE xf; - - if (!doing_xref) return; - xf = find_file (input_filename); - if (xf == NULL) return; - - fprintf (xref_file, "REF %s %d %s %s\n", - filename (xf), lineno, fctname (fndecl), name); -} - -/* Output a reference to DECL in FNDECL. */ - -void -GNU_xref_decl (fndecl,decl) - tree fndecl; - tree decl; -{ - XREF_FILE xf,xf1; - const char *cls = 0; - const char *name; - char buf[10240]; - int uselin; - - if (!doing_xref) return; - xf = find_file (input_filename); - if (xf == NULL) return; - - uselin = FALSE; - - if (TREE_CODE (decl) == TYPE_DECL) cls = "TYPEDEF"; - else if (TREE_CODE (decl) == FIELD_DECL) cls = "FIELD"; - else if (TREE_CODE (decl) == VAR_DECL) - { - if (fndecl == NULL && TREE_STATIC(decl) - && TREE_READONLY(decl) && DECL_INITIAL(decl) != 0 - && !TREE_PUBLIC(decl) && !DECL_EXTERNAL(decl) - && DECL_MODE(decl) != BLKmode) cls = "CONST"; - else if (DECL_EXTERNAL(decl)) cls = "EXTERN"; - else if (TREE_PUBLIC(decl)) cls = "EXTDEF"; - else if (TREE_STATIC(decl)) cls = "STATIC"; - else if (DECL_REGISTER(decl)) cls = "REGISTER"; - else cls = "AUTO"; - } - else if (TREE_CODE (decl) == PARM_DECL) cls = "PARAM"; - else if (TREE_CODE (decl) == FIELD_DECL) cls = "FIELD"; - else if (TREE_CODE (decl) == CONST_DECL) cls = "CONST"; - else if (TREE_CODE (decl) == FUNCTION_DECL) - { - if (DECL_EXTERNAL (decl)) cls = "EXTERN"; - else if (TREE_PUBLIC (decl)) cls = "EFUNCTION"; - else cls = "SFUNCTION"; - } - else if (TREE_CODE (decl) == LABEL_DECL) cls = "LABEL"; - else if (TREE_CODE (decl) == UNION_TYPE) - { - cls = "UNIONID"; - decl = TYPE_NAME (decl); - uselin = TRUE; - } - else if (TREE_CODE (decl) == RECORD_TYPE) - { - if (CLASSTYPE_DECLARED_CLASS (decl)) cls = "CLASSID"; - else cls = "STRUCTID"; - decl = TYPE_NAME (decl); - uselin = TRUE; - } - else if (TREE_CODE (decl) == ENUMERAL_TYPE) - { - cls = "ENUMID"; - decl = TYPE_NAME (decl); - uselin = TRUE; - } - else if (TREE_CODE (decl) == TEMPLATE_DECL) - { - if (TREE_CODE (DECL_RESULT (decl)) == TYPE_DECL) - cls = "CLASSTEMP"; - else if (TREE_CODE (DECL_RESULT (decl)) == FUNCTION_DECL) - cls = "FUNCTEMP"; - else if (TREE_CODE (DECL_RESULT (decl)) == VAR_DECL) - cls = "VARTEMP"; - else - abort (); - uselin = TRUE; - } - else cls = "UNKNOWN"; - - if (decl == NULL || DECL_NAME (decl) == NULL) return; - - if (uselin && decl->decl.linenum > 0 && decl->decl.filename != NULL) - { - xf1 = find_file (decl->decl.filename); - if (xf1 != NULL) - { - lineno = decl->decl.linenum; - xf = xf1; - } - } - - if (DECL_ASSEMBLER_NAME (decl)) - name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - else - name = IDENTIFIER_POINTER (DECL_NAME (decl)); - - strcpy (buf, type_as_string (TREE_TYPE (decl), 0)); - simplify_type (buf); - - fprintf (xref_file, "DCL %s %d %s %d %s %s %s\n", - filename(xf), lineno, name, - (cur_scope != NULL ? cur_scope->lid : 0), - cls, fctname(fndecl), buf); - - if (STREQL (cls, "STRUCTID") || STREQL (cls, "UNIONID")) - { - cls = "CLASSID"; - fprintf (xref_file, "DCL %s %d %s %d %s %s %s\n", - filename(xf), lineno,name, - (cur_scope != NULL ? cur_scope->lid : 0), - cls, fctname(fndecl), buf); - } -} - -/* Output a reference to a call to NAME in FNDECL. */ - -void -GNU_xref_call (fndecl, name) - tree fndecl; - const char *name; -{ - XREF_FILE xf; - char buf[1024]; - const char *s; - - if (!doing_xref) return; - xf = find_file (input_filename); - if (xf == NULL) return; - name = fixname (name, buf); - - for (s = name; *s != 0; ++s) - if (*s == '_' && s[1] == '_') break; - if (*s != 0) GNU_xref_ref (fndecl, name); - - fprintf (xref_file, "CAL %s %d %s %s\n", - filename (xf), lineno, name, fctname (fndecl)); -} - -/* Output cross-reference info about FNDECL. If non-NULL, - ARGS are the arguments for the function (i.e., before the FUNCTION_DECL - has been fully built). */ - -void -GNU_xref_function (fndecl, args) - tree fndecl; - tree args; -{ - XREF_FILE xf; - int ct; - char buf[1024]; - - if (!doing_xref) return; - xf = find_file (input_filename); - if (xf == NULL) return; - - ct = 0; - buf[0] = 0; - if (args == NULL) args = DECL_ARGUMENTS (fndecl); - - GNU_xref_decl (NULL, fndecl); - - for ( ; args != NULL; args = TREE_CHAIN (args)) - { - GNU_xref_decl (fndecl,args); - if (ct != 0) strcat (buf,","); - strcat (buf, declname (args)); - ++ct; - } - - fprintf (xref_file, "PRC %s %d %s %d %d %s\n", - filename(xf), lineno, declname(fndecl), - (cur_scope != NULL ? cur_scope->lid : 0), - ct, buf); -} - -/* Output cross-reference info about an assignment to NAME. */ - -void -GNU_xref_assign(name) - tree name; -{ - XREF_FILE xf; - - if (!doing_xref) return; - xf = find_file(input_filename); - if (xf == NULL) return; - - gen_assign(xf, name); -} - -static void -gen_assign(xf, name) - XREF_FILE xf; - tree name; -{ - const char *s; - - s = NULL; - - switch (TREE_CODE (name)) - { - case IDENTIFIER_NODE : - s = IDENTIFIER_POINTER(name); - break; - case VAR_DECL : - s = declname(name); - break; - case COMPONENT_REF : - gen_assign(xf, TREE_OPERAND(name, 0)); - gen_assign(xf, TREE_OPERAND(name, 1)); - break; - case INDIRECT_REF : - case OFFSET_REF : - case ARRAY_REF : - case BUFFER_REF : - gen_assign(xf, TREE_OPERAND(name, 0)); - break; - case COMPOUND_EXPR : - gen_assign(xf, TREE_OPERAND(name, 1)); - break; - default : - break; - } - - if (s != NULL) - fprintf(xref_file, "ASG %s %d %s\n", filename(xf), lineno, s); -} - -static const char * -classname (cls) - tree cls; -{ - if (cls && TYPE_P (cls)) - cls = TYPE_NAME (cls); - if (cls && DECL_P (cls)) - cls = DECL_NAME (cls); - if (cls && TREE_CODE (cls) == IDENTIFIER_NODE) - return IDENTIFIER_POINTER (cls); - return "?"; -} - -/* Output cross-reference info about a class hierarchy. - CLS is the class type of interest. BASE is a baseclass - for CLS. PUB and VIRT give the access info about - the class derivation. FRND is nonzero iff BASE is a friend - of CLS. - - ??? Needs to handle nested classes. */ - -void -GNU_xref_hier(cls, base, pub, virt, frnd) - tree cls; - tree base; - int pub; - int virt; - int frnd; -{ - XREF_FILE xf; - - if (!doing_xref) return; - xf = find_file(input_filename); - if (xf == NULL) return; - - fprintf(xref_file, "HIE %s %d %s %s %d %d %d\n", - filename(xf), lineno, classname (cls), classname (base), - pub, virt, frnd); -} - -/* Output cross-reference info about class members. CLS - is the containing type; FLD is the class member. */ - -void -GNU_xref_member(cls, fld) - tree cls; - tree fld; -{ - XREF_FILE xf; - const char *prot; - int confg, pure; - const char *d; -#ifdef XREF_SHORT_MEMBER_NAMES - int i; -#endif - char buf[1024], bufa[1024]; - - if (!doing_xref) return; - xf = find_file(fld->decl.filename); - if (xf == NULL) return; - - if (TREE_PRIVATE (fld)) prot = "PRIVATE"; - else if (TREE_PROTECTED(fld)) prot = "PROTECTED"; - else prot = "PUBLIC"; - - confg = 0; - if (TREE_CODE (fld) == FUNCTION_DECL && DECL_CONST_MEMFUNC_P(fld)) - confg = 1; - else if (TREE_CODE (fld) == CONST_DECL) - confg = 1; - - pure = 0; - if (TREE_CODE (fld) == FUNCTION_DECL && DECL_PURE_VIRTUAL_P(fld)) - pure = 1; - - d = IDENTIFIER_POINTER(cls); - sprintf(buf, "%d%s", (int) strlen(d), d); -#ifdef XREF_SHORT_MEMBER_NAMES - i = strlen(buf); -#endif - strcpy(bufa, declname(fld)); - -#ifdef XREF_SHORT_MEMBER_NAMES - for (p = &bufa[1]; *p != 0; ++p) - { - if (p[0] == '_' && p[1] == '_' && ISDIGIT (p[2])) { - if (strncmp(&p[2], buf, i) == 0) *p = 0; - break; - } - else if (p[0] == '_' && p[1] == '_' && p[2] == 'C' && ISDIGIT (p[3])) { - if (strncmp(&p[3], buf, i) == 0) *p = 0; - break; - } - } -#endif - - fprintf(xref_file, "MEM %s %d %s %s %s %d %d %d %d %d %d %d\n", - filename(xf), fld->decl.linenum, d, bufa, prot, - (TREE_CODE (fld) == FUNCTION_DECL ? 0 : 1), - (DECL_INLINE (fld) ? 1 : 0), - (DECL_LANG_SPECIFIC(fld) && DECL_FRIEND_P(fld) ? 1 : 0), - (DECL_VINDEX(fld) ? 1 : 0), - (TREE_STATIC(fld) ? 1 : 0), - pure, confg); -} - -/* Find file entry given name. */ - -static XREF_FILE -find_file(name) - const char *name; -{ - XREF_FILE xf; - - for (xf = all_files; xf != NULL; xf = xf->next) { - if (STREQL(name, xf->name)) break; - } - - return xf; -} - -/* Return filename for output purposes. */ - -static const char * -filename(xf) - XREF_FILE xf; -{ - if (xf == NULL) { - last_file = NULL; - return "*"; - } - - if (last_file == xf) return "*"; - - last_file = xf; - - return xf->outname; -} - -/* Return function name for output purposes. */ - -static const char * -fctname(fndecl) - tree fndecl; -{ - static char fctbuf[1024]; - const char *s; - - if (fndecl == NULL && last_fndecl == NULL) return "*"; - - if (fndecl == NULL) - { - last_fndecl = NULL; - return "*TOP*"; - } - - if (fndecl == last_fndecl) return "*"; - - last_fndecl = fndecl; - - s = declname(fndecl); - s = fixname(s, fctbuf); - - return s; -} - -/* Return decl name for output purposes. */ - -static const char * -declname(dcl) - tree dcl; -{ - if (DECL_NAME (dcl) == NULL) return "?"; - - if (DECL_ASSEMBLER_NAME (dcl)) - return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (dcl)); - else - return IDENTIFIER_POINTER (DECL_NAME (dcl)); -} - -/* Simplify a type string by removing unneeded parenthesis. */ - -static void -simplify_type(typ) - char *typ; -{ - char *s; - int lvl, i; - - i = strlen(typ); - while (i > 0 && ISSPACE((unsigned char) typ[i-1])) typ[--i] = 0; - - if (i > 7 && STREQL(&typ[i-5], "const")) - { - typ[i-5] = 0; - i -= 5; - } - - if (typ[i-1] != ')') return; - - s = &typ[i-2]; - lvl = 1; - while (*s != 0) { - if (*s == ')') ++lvl; - else if (*s == '(') - { - --lvl; - if (lvl == 0) - { - s[1] = ')'; - s[2] = 0; - break; - } - } - --s; - } - - if (*s != 0 && s[-1] == ')') - { - --s; - --s; - if (*s == '(') s[2] = 0; - else if (*s == ':') { - while (*s != '(') --s; - s[1] = ')'; - s[2] = 0; - } - } -} - -/* Fixup a function name (take care of embedded spaces). */ - -static const char * -fixname(nam, buf) - const char *nam; - char *buf; -{ - const char *s; - char *t; - int fg; - - s = nam; - t = buf; - fg = 0; - - while (*s != 0) - { - if (*s == ' ') - { - *t++ = '\36'; - ++fg; - } - else *t++ = *s; - ++s; - } - *t = 0; - - if (fg == 0) return nam; - - return buf; -} - -/* Open file for xreffing. */ - -static void -open_xref_file(file) - const char *file; -{ - const char *s; - char *t; - -#ifdef XREF_FILE_NAME - XREF_FILE_NAME (xref_name, file); -#else - s = strrchr (file, '/'); - if (s == NULL) - sprintf (xref_name, ".%s.gxref", file); - else - { - ++s; - strcpy (xref_name, file); - t = strrchr (xref_name, '/'); - ++t; - *t++ = '.'; - strcpy (t, s); - strcat (t, ".gxref"); - } -#endif /* no XREF_FILE_NAME */ - - xref_file = fopen(xref_name, "w"); - - if (xref_file == NULL) - { - error("can't create cross-reference file `%s'", xref_name); - doing_xref = 0; - } -} |