/* Code for handling XREF output from GNU C++.
- Copyright (C) 1992, 1993, 1994, 1995, 1997 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.
#include "tree.h"
#include "cp-tree.h"
#include "input.h"
-
-extern char *getpwd PROTO((void));
+#include "toplev.h"
/* The character(s) used to join a directory specification (obtained with
getwd or equivalent) with a non-absolute file name. */
#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)
typedef struct _XREF_FILE
{
- char *name;
- char *outname;
+ const char *name;
+ const char *outname;
XREF_FILE next;
} XREF_FILE_INFO;
/* 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;
void
GNU_xref_file (name)
- char *name;
+ const char *name;
{
XREF_FILE xf;
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);
{
XREF_FILE xf;
XREF_SCOPE xs,lxs,oxs;
- char *stype;
+ const char *stype;
if (!doing_xref) return;
xf = find_file (input_filename);
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;
void
GNU_xref_ref (fndecl,name)
tree fndecl;
- char *name;
+ const char *name;
{
XREF_FILE xf;
tree decl;
{
XREF_FILE xf,xf1;
- char *cls = 0;
- char *name;
+ const char *cls = 0;
+ const char *name;
char buf[10240];
int uselin;
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;
(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",
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);
XREF_FILE xf;
tree name;
{
- char *s;
+ const char *s;
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
void
GNU_xref_hier(cls, base, pub, virt, frnd)
- char *cls;
- char *base;
+ tree cls;
+ tree base;
int pub;
int virt;
int 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
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
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
#ifdef XREF_SHORT_MEMBER_NAMES
for (p = &bufa[1]; *p != 0; ++p)
{
- if (p[0] == '_' && p[1] == '_' && p[2] >= '0' && p[2] <= '9') {
+ 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' && p[3] >= '0' && p[3] <= '9') {
+ else if (p[0] == '_' && p[1] == '_' && p[2] == 'C' && ISDIGIT (p[3])) {
if (strncmp(&p[3], buf, i) == 0) *p = 0;
break;
}
static XREF_FILE
find_file(name)
- char *name;
+ const char *name;
{
XREF_FILE xf;
/* Return filename for output purposes. */
-static char *
+static const char *
filename(xf)
XREF_FILE 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 "*";
/* Return decl name for output purposes. */
-static char *
+static const char *
declname(dcl)
tree dcl;
{
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"))
{
/* 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;
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);