aboutsummaryrefslogtreecommitdiff
path: root/contrib/gcc/cp/xref.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gcc/cp/xref.c')
-rw-r--r--contrib/gcc/cp/xref.c78
1 files changed, 33 insertions, 45 deletions
diff --git a/contrib/gcc/cp/xref.c b/contrib/gcc/cp/xref.c
index 6e06eda92fb9..4560c4a2c6f3 100644
--- a/contrib/gcc/cp/xref.c
+++ b/contrib/gcc/cp/xref.c
@@ -1,5 +1,6 @@
/* Code for handling XREF output from GNU C++.
- Copyright (C) 1992, 93-97, 1998 Free Software Foundation, Inc.
+ 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.
@@ -27,8 +28,6 @@ Boston, MA 02111-1307, USA. */
#include "input.h"
#include "toplev.h"
-extern char *getpwd PROTO((void));
-
/* The character(s) used to join a directory specification (obtained with
getwd or equivalent) with a non-absolute file name. */
@@ -38,7 +37,7 @@ extern char *getpwd PROTO((void));
/* Nonzero if NAME as a file name is absolute. */
#ifndef FILE_NAME_ABSOLUTE_P
-#define FILE_NAME_ABSOLUTE_P(NAME) (NAME[0] == '/')
+#define FILE_NAME_ABSOLUTE_P(NAME) ((NAME)[0] == '/')
#endif
/* For cross referencing. */
@@ -58,21 +57,19 @@ 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 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)
+#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)
/************************************************************************/
/* */
@@ -121,15 +118,15 @@ static tree last_fndecl = NULL;
/* Forward definitions */
/* */
/************************************************************************/
-static void gen_assign PROTO((XREF_FILE, tree));
-static XREF_FILE find_file PROTO((const char *));
-static const char * filename PROTO((XREF_FILE));
-static const char * fctname PROTO((tree));
-static const char * declname PROTO((tree));
-static void simplify_type PROTO((char *));
-static const char * fixname PROTO((const char *, char *));
-static void open_xref_file PROTO((const char *));
-static const char * classname PROTO((tree));
+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. */
@@ -208,14 +205,7 @@ GNU_xref_file (name)
if (FILE_NAME_ABSOLUTE_P (name) || ! wd_name)
xf->outname = xf->name;
else
- {
- char *nmbuf
- = (char *) xmalloc (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);
@@ -367,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;
@@ -387,7 +376,7 @@ GNU_xref_decl (fndecl,decl)
else if (TREE_CODE (DECL_RESULT (decl)) == VAR_DECL)
cls = "VARTEMP";
else
- my_friendly_abort (358);
+ abort ();
uselin = TRUE;
}
else cls = "UNKNOWN";
@@ -417,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",
@@ -546,9 +534,9 @@ static const char *
classname (cls)
tree cls;
{
- if (cls && TREE_CODE_CLASS (TREE_CODE (cls)) == 't')
+ if (cls && TYPE_P (cls))
cls = TYPE_NAME (cls);
- if (cls && TREE_CODE_CLASS (TREE_CODE (cls)) == 'd')
+ if (cls && DECL_P (cls))
cls = DECL_NAME (cls);
if (cls && TREE_CODE (cls) == IDENTIFIER_NODE)
return IDENTIFIER_POINTER (cls);
@@ -614,7 +602,7 @@ 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);
@@ -627,11 +615,11 @@ GNU_xref_member(cls, fld)
#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;
}
@@ -816,14 +804,14 @@ open_xref_file(file)
#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);
@@ -835,7 +823,7 @@ open_xref_file(file)
if (xref_file == NULL)
{
- error("Can't create cross-reference file `%s'", xref_name);
+ error("can't create cross-reference file `%s'", xref_name);
doing_xref = 0;
}
}