-fdump-translation-unit considered harmful

Robert Dewar dewar@adacore.com
Sun Dec 19 10:37:00 GMT 2004


Stefan Strasser wrote:

> but I think there should be a stable interface or a stable xml output 
> for c++ code. (I know there is gccxml patch, but it is nothing else than 
> a dump-translation-unit written to a flat xml file, no hierarchy, no 
> statements)

I assume you are aware of the non-technical difficulties with such an
approach, but just to continue with the technical discussions, I think
that an output of this kind is only a first step. What is really needed
is something analogous to the ASIS interface in Ada, i.e. a well defined
API that let's programs make structured queries on the semantics of a
parsed program. This approach has several advantages:

1. You do not have to try to stablilize the intermdiate output used as
an input to this tool (e.g. the GNAT tree changes all the time), but
instead you just keep the API stable.

2. The API is at a far more convenient level for writing typical tools

3. The API is not in general planned to be convenient for, or efficient
enough, to write an entire compiler (thus addressing one of the critical
non-technical issues).

Robert Dewar



More information about the Gcc mailing list