[cfe-dev] Parsing, pretty-printing, and compiling the result should work, right?

Roberto Bagnara bagnara at cs.unipr.it
Sun Jan 18 13:14:12 PST 2009


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.

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.

Unless we have grossly misinterpreted the objectives of the clang project,
this kind of exercise should be regared as valuable: right?
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.

Solution b) is not very attractive, since the only solution we see for some
of the open problems would be to complicate the pretty-printer to a point
where it is no longer a pretty-printer (but something that, instead of
working sequentially, has to walk through the entire AST in order to gather
information that has been moved by clang to places that are far from where
it should be printed).

Please, let me know what you think about the above: perhaps we have made
some wrong choices and we do not want to waste our time or the time of anyone.
Thanks a lot,

    Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it



More information about the cfe-dev mailing list