On Thu, May 24, 2012 at 3:24 AM, Richard Guenther <richard.guent...@gmail.com> wrote: > On Wed, May 23, 2012 at 9:49 PM, Diego Novillo <dnovi...@google.com> wrote: >> >> Part 2 of the VEC C++ conversion. This patch implements the gengtype >> changes. >> >> I extended gengtype to understand templated types. These changes are >> not as ugly as I thought they would be. Gengtype has some hardwired >> knowledge of VEC_*, which I renamed to vec_t. I'm not even sure why >> gengtype needs to care about vec_t in this way, but I was looking for >> minimal changes, so I just did it. >> >> The other change is more generic. It allows gengtype to deal with >> templated types. There is a new function (filter_type_name) that >> recognizes C++ special characters '<', '>' and ':'. It turns them >> into '_'. This way, gengtype can generate a valid identifier for the >> pre-processor. It only does this in contexts where it needs a >> pre-processor identifier. For everything else, it emits the type >> directly. So, the functions emitted in gt-*.h files have proper >> template type references. > > This is, of course, just a replacement of special-case handling for vec.h > with another special-case handling. It does not show us how templated > structs should work with gengtype in general. And no, I don't think > gengtype should keep the special-case for vec.h. > > The point was to make all the gt_ggc_* functions function template > specializations so the code gengtype emits for walking a structs fields > would be just > > mark (field1); > mark (field2); > ... > > and we could manually provide specializations for selected types > (well, the templates). Add a GTY((template)) marker to make gengtype > not emit the specializations itself (or simply make it recognize template > types and do nothing for them).
True, but as a preliminary step (and a member of a series of patches), it does make sense and is good to have. -- Gaby