[cfe-dev] Parsing, pretty-printing, and compiling the result should work, right?
Chris Lattner
clattner at apple.com
Sun Jan 18 13:57:26 PST 2009
On Jan 18, 2009, at 1:14 PM, Roberto Bagnara wrote:
>
> Hi there,
>
> from some of the replies we got to bug reports we submitted I gather
> that it is best if we ask the advice of this list concerning what we
> are trying to do.
Hi Roberto,
I agree that this is a better place to discuss this than in individual
bugzillas,
> Our first objective is to understand whether clang can be the parser
> for a program analyzer we are building. In order to ascertain that,
> our plan was to build confidence on clang by:
>
> 1) Writing a pretty-printer that produces parsable C code from the
> AST.
> 2) Writing a driver that calls the parser, then the pretty-printer,
> and
> then invokes gcc over the pretty-printed program. In other
> words, this
> driver behaves exactly like plain gcc, with the only difference
> that it will compile the program produced by clang + pretty-printer
> instead of what gcc would normally obtain by running its own
> preprocessor.
> 3) Using this driver, compile as much code as possible (Linux, GNU
> software
> a go-go, everything we can put our hand on) and check whether the
> result
> runs as expected.
Ok, this sounds like a great project. I don't know of anyone doing
anything similar, but it seems very useful to a variety of different
people.
> Unless we have grossly misinterpreted the objectives of the clang
> project,
> this kind of exercise should be regared as valuable: right?
Absolutely!
> Point 2) is basically complete. Full realization of point 1) is
> currently
> impeded by a number of problems for which we have pending bug reports.
> For those we are unsure whether it is best to:
>
> a) wait for a fix;
> b) implement a workaround in the pretty-printer.
This is a general problem with Open Source projects. You're
interested in doing something that would be very valuable for Clang to
do, however, Clang isn't quite there yet. Further, you are the first
person to want to do this, and you're hitting problems.
Unfortunately, clang is developed by volunteers, and most of them have
their own specific agenda that they prioritize. For example, mine is
"make clang a production quality C compiler sooner rather than
later". This means that you can't really "force" someone to fix a bug
or implement a feature that you're lacking. Your options basically
come down to:
1) fix it yourself. The various issues you have identified would all
be great to fix in clang, so I'm sure that the patches would be welcome.
2) pay someone to fix it.
3) try to stir up interest in the problem, so that someone else feels
compelled to look into it.
4) find a way to work around the problem.
I think your email has the effect of doing #3, as I think that many
people would find this functionality useful. For #4, you might want
to consider using the rewriter infrastructure, which does not suffer
from the class of problem and is already in use for several projects.
-Chris
More information about the cfe-dev
mailing list