X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gcc%2Fcp%2Fxref.c;h=af35020efb82766f7886fbf382fa1b265f4af077;hb=6f32162af66395b5ae357d714d8d18fb6f666feb;hp=fc2d1078ac2f021e87f631811aaa10575a8467b9;hpb=49c249e1c8aecde11d2166d5bfc6789cb3882172;p=gcc.git diff --git a/gcc/cp/xref.c b/gcc/cp/xref.c index fc2d1078ac2..af35020efb8 100644 --- a/gcc/cp/xref.c +++ b/gcc/cp/xref.c @@ -1,5 +1,6 @@ /* Code for handling XREF output from GNU C++. - Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, + 2000 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@cygnus.com) This file is part of GNU CC. @@ -21,29 +22,11 @@ Boston, MA 02111-1307, USA. */ #include "config.h" +#include "system.h" #include "tree.h" -#include #include "cp-tree.h" #include "input.h" - -#include - -#ifdef HAVE_STDLIB_H -#include -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - -extern char *getpwd PROTO((void)); - -#ifdef HAVE_STRING_H -#include -#else -extern char *index (); -extern char *rindex (); -#endif +#include "toplev.h" /* The character(s) used to join a directory specification (obtained with getwd or equivalent) with a non-absolute file name. */ @@ -74,13 +57,11 @@ int flag_gnu_xref; #define FALSE 0 #endif -#define PALLOC(typ) ((typ *) calloc(1,sizeof(typ))) +#define PALLOC(typ) ((typ *) xcalloc(1,sizeof(typ))) /* Return a malloc'd copy of STR. */ -#define SALLOC(str) \ - ((char *) ((str) == NULL ? NULL \ - : (char *) strcpy ((char *) malloc (strlen ((str)) + 1), (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) @@ -102,8 +83,8 @@ typedef struct _XREF_SCOPE * XREF_SCOPE; typedef struct _XREF_FILE { - char *name; - char *outname; + const char *name; + const char *outname; XREF_FILE next; } XREF_FILE_INFO; @@ -137,20 +118,21 @@ static tree last_fndecl = NULL; /* Forward definitions */ /* */ /************************************************************************/ -static void gen_assign PROTO((XREF_FILE, tree)); -static XREF_FILE find_file PROTO((char *)); -static char * filename PROTO((XREF_FILE)); -static char * fctname PROTO((tree)); -static char * declname PROTO((tree)); -static void simplify_type PROTO((char *)); -static char * fixname PROTO((char *, char *)); -static void open_xref_file PROTO((char *)); +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) - char *file; + const char *file; { doing_xref = 1; @@ -194,7 +176,7 @@ GNU_xref_end (ect) void GNU_xref_file (name) - char *name; + const char *name; { XREF_FILE xf; @@ -223,14 +205,7 @@ GNU_xref_file (name) if (FILE_NAME_ABSOLUTE_P (name) || ! wd_name) xf->outname = xf->name; else - { - char *nmbuf - = (char *) malloc (strlen (wd_name) + strlen (FILE_NAME_JOINER) - + strlen (name) + 1); - sprintf (nmbuf, "%s%s%s", wd_name, FILE_NAME_JOINER, name); - name = nmbuf; - xf->outname = nmbuf; - } + xf->outname = name = concat (wd_name, FILE_NAME_JOINER, name, NULL); fprintf (xref_file, "FIL %s %s 0\n", name, wd_name); @@ -275,7 +250,7 @@ GNU_xref_end_scope (id,inid,prm,keep) { XREF_FILE xf; XREF_SCOPE xs,lxs,oxs; - char *stype; + const char *stype; if (!doing_xref) return; xf = find_file (input_filename); @@ -302,8 +277,10 @@ GNU_xref_end_scope (id,inid,prm,keep) else if (keep == 2 || inid != 0) stype = "INTERN"; else stype = "EXTERN"; - fprintf (xref_file,"SCP %s %d %d %d %d %s\n", - filename (xf), xs->start, lineno,xs->lid, inid, stype); + 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; @@ -316,7 +293,7 @@ GNU_xref_end_scope (id,inid,prm,keep) void GNU_xref_ref (fndecl,name) tree fndecl; - char *name; + const char *name; { XREF_FILE xf; @@ -336,8 +313,8 @@ GNU_xref_decl (fndecl,decl) tree decl; { XREF_FILE xf,xf1; - char *cls; - char *name; + const char *cls = 0; + const char *name; char buf[10240]; int uselin; @@ -380,7 +357,6 @@ GNU_xref_decl (fndecl,decl) else if (TREE_CODE (decl) == RECORD_TYPE) { if (CLASSTYPE_DECLARED_CLASS (decl)) cls = "CLASSID"; - else if (IS_SIGNATURE (decl)) cls = "SIGNATUREID"; else cls = "STRUCTID"; decl = TYPE_NAME (decl); uselin = TRUE; @@ -430,8 +406,7 @@ GNU_xref_decl (fndecl,decl) (cur_scope != NULL ? cur_scope->lid : 0), cls, fctname(fndecl), buf); - if (STREQL (cls, "STRUCTID") || STREQL (cls, "UNIONID") - || STREQL (cls, "SIGNATUREID")) + if (STREQL (cls, "STRUCTID") || STREQL (cls, "UNIONID")) { cls = "CLASSID"; fprintf (xref_file, "DCL %s %d %s %d %s %s %s\n", @@ -446,11 +421,11 @@ GNU_xref_decl (fndecl,decl) void GNU_xref_call (fndecl, name) tree fndecl; - char *name; + const char *name; { XREF_FILE xf; char buf[1024]; - char *s; + const char *s; if (!doing_xref) return; xf = find_file (input_filename); @@ -522,7 +497,7 @@ gen_assign(xf, name) XREF_FILE xf; tree name; { - char *s; + const char *s; s = NULL; @@ -555,6 +530,19 @@ gen_assign(xf, name) 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 @@ -565,8 +553,8 @@ gen_assign(xf, name) void GNU_xref_hier(cls, base, pub, virt, frnd) - char *cls; - char *base; + tree cls; + tree base; int pub; int virt; int frnd; @@ -578,7 +566,8 @@ GNU_xref_hier(cls, base, pub, virt, frnd) if (xf == NULL) return; fprintf(xref_file, "HIE %s %d %s %s %d %d %d\n", - filename(xf), lineno, cls, base, pub, virt, frnd); + filename(xf), lineno, classname (cls), classname (base), + pub, virt, frnd); } /* Output cross-reference info about class members. CLS @@ -590,9 +579,9 @@ GNU_xref_member(cls, fld) tree fld; { XREF_FILE xf; - char *prot; + const char *prot; int confg, pure; - char *d; + const char *d; #ifdef XREF_SHORT_MEMBER_NAMES int i; #endif @@ -613,11 +602,11 @@ GNU_xref_member(cls, fld) confg = 1; pure = 0; - if (TREE_CODE (fld) == FUNCTION_DECL && DECL_ABSTRACT_VIRTUAL_P(fld)) + if (TREE_CODE (fld) == FUNCTION_DECL && DECL_PURE_VIRTUAL_P(fld)) pure = 1; d = IDENTIFIER_POINTER(cls); - sprintf(buf, "%d%s", strlen(d), d); + sprintf(buf, "%d%s", (int) strlen(d), d); #ifdef XREF_SHORT_MEMBER_NAMES i = strlen(buf); #endif @@ -651,7 +640,7 @@ GNU_xref_member(cls, fld) static XREF_FILE find_file(name) - char *name; + const char *name; { XREF_FILE xf; @@ -664,7 +653,7 @@ find_file(name) /* Return filename for output purposes. */ -static char * +static const char * filename(xf) XREF_FILE xf; { @@ -682,12 +671,12 @@ filename(xf) /* Return function name for output purposes. */ -static char * +static const char * fctname(fndecl) tree fndecl; { static char fctbuf[1024]; - char *s; + const char *s; if (fndecl == NULL && last_fndecl == NULL) return "*"; @@ -709,7 +698,7 @@ fctname(fndecl) /* Return decl name for output purposes. */ -static char * +static const char * declname(dcl) tree dcl; { @@ -731,7 +720,7 @@ simplify_type(typ) int lvl, i; i = strlen(typ); - while (i > 0 && isspace(typ[i-1])) typ[--i] = 0; + while (i > 0 && ISSPACE((unsigned char) typ[i-1])) typ[--i] = 0; if (i > 7 && STREQL(&typ[i-5], "const")) { @@ -773,12 +762,13 @@ simplify_type(typ) /* Fixup a function name (take care of embedded spaces). */ -static char * +static const char * fixname(nam, buf) - char *nam; + const char *nam; char *buf; { - char *s, *t; + const char *s; + char *t; int fg; s = nam; @@ -806,21 +796,22 @@ fixname(nam, buf) static void open_xref_file(file) - char *file; + const char *file; { - char *s, *t; + const char *s; + char *t; #ifdef XREF_FILE_NAME XREF_FILE_NAME (xref_name, file); #else - s = rindex (file, '/'); + s = strrchr (file, '/'); if (s == NULL) sprintf (xref_name, ".%s.gxref", file); else { ++s; strcpy (xref_name, file); - t = rindex (xref_name, '/'); + t = strrchr (xref_name, '/'); ++t; *t++ = '.'; strcpy (t, s);