This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: ObjC++-related common code mods



On 17 Aug 2004, at 11.55, Zack Weinberg wrote:
Talking just about the gengtype.c change here, I still don't even know
what it does, and I'm at a loss to explain to you what you've left out
of your explanation, other than "everything".

Clearly, your definition of "everything" differs from mine. Let's recap the "nothing" I've posted thus far; further discussion has been interspersed with the diff itself, below.

 * gengtype.c (get_file_basename): Match entire subdirectory name
 ('cp', 'objc', 'objcp') rather than just its suffix.
 (get_base_file_bitmap): Allow for files to belong to more than one
 language.
 (get_output_file_with_visibility): Treat objc/objc-act.h as a header
 used by more than one front-end.

Index: gcc/gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype.c,v
retrieving revision 1.62
diff -u -3 -p -r1.62 gengtype.c
--- gcc/gengtype.c      4 Aug 2004 20:55:07 -0000       1.62
+++ gcc/gengtype.c      17 Aug 2004 19:40:54 -0000
@@ -1096,7 +1096,7 @@ get_file_basename (const char *f)
       s2 = lang_dir_names [i];
       l1 = strlen (s1);
       l2 = strlen (s2);
-      if (l1 >= l2 && !memcmp (s1, s2, l2))
+      if (l1 >= l2 && s1[-1] == '/' && !memcmp (s1, s2, l2))
         {
           basename -= l2 + 1;
           if ((basename - f - 1) != srcdir_len)

The get_file_basename() routine attempts to find which language subdirectory
a given file lives in by comparing the identifiers immediately preceding the
'/' directory separator with the directories it knows about. This works now,
with the directory list consisting of 'cp' and 'objc', but breaks when you
add 'objcp' into the mix. For example, upon being handed in
'gcc/objcp/objcp-decl.h', the routine erroneously concluded that the file
resides in 'cp', by matching the 'cp/objcp-decl.h' suffix of the name.


@@ -1125,6 +1125,10 @@ get_base_file_bitmap (const char *input_
   unsigned k;
   unsigned bitmap;

+ /* If the file resides in a language subdirectory (e.g., 'cp'), assume that
+ it belongs to the corresponding language. The file may belong to other
+ languages as well (which is checked for below). */
+
if (slashpos)
{
size_t i;


@@ -1134,10 +1138,7 @@ get_base_file_bitmap (const char *input_
           {
             /* It's in a language directory, set that language.  */
             bitmap = 1 << i;
-            return bitmap;
           }
-
-      abort (); /* Should have found the language.  */
     }

/* If it's in any config-lang.in, then set for the languages

There is a comment (in English) at the top of this hunk, explaining what's
going on. The abort() is removed so that the logic falls through to the
config-lang.in checks to determine which language(s) the file belongs to.
The important part here is that a file may belong to (i.e., be used by)
more than one front-end.


@@ -1200,11 +1201,18 @@ get_output_file_with_visibility (const c
memcpy (s, ".h", sizeof (".h"));
for_name = basename;
}
+ /* Some headers get used by more than one front-end; hence, it
+ would be inappropriate to spew them out to a single gtype-<lang>.h
+ (and gengtype doesn't know how to direct spewage into multiple
+ gtype-<lang>.h headers at this time). Instead, we pair up these
+ headers with source files (and their special purpose gt-*.h headers). */
else if (strcmp (basename, "c-common.h") == 0)
output_name = "gt-c-common.h", for_name = "c-common.c";
else if (strcmp (basename, "c-tree.h") == 0)
output_name = "gt-c-decl.h", for_name = "c-decl.c";
- else
+ else if (strcmp (basename, "objc/objc-act.h") == 0)
+ output_name = "gt-objc-objc-act.h", for_name = "objc/objc-act.c";
+ else
{
size_t i;


Again, note the English comment. Also note that I'm extending an existing
idiom for handling files used by more than one idiom.


--Zem
--------------------------------------------------------------
Ziemowit Laski                 1 Infinite Loop, MS 301-2K
Mac OS X Compiler Group        Cupertino, CA USA  95014-2083
Apple Computer, Inc.           +1.408.974.6229  Fax .5477


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]