[cfe-dev] Pragma information in AST processing
Peter Thoman
peter.thoman at uibk.ac.at
Wed Jun 10 06:02:27 PDT 2009
On 10.06.2009 05:18, Daniel Dunbar wrote:
> Hi Peter,
> What kind of information do you want to extract from pragmas? Are you
> planning on adding specific pragmas for your problem, or you want to
> do something with existing pragmas which clang handles?
They are pragmas that are not yet handled by clang.
> The way we currently handle pragmas is generally to attach attributes
> to other AST nodes in the pragma handler. This is relatively clean,
> but does have the downside that there is no easy way to determine that
> the attribute came from a pragma instead of being specified manually.
>
This sounds like it would work for my case. I digged around in the
source tree and I think this is done in SemaAttr.cpp right now (in
ActOnPragmaUnused). So I would derive subclasses from clang::Attr and
attach them to the statements to carry the pragma information.
What I don't know how to do at this point is accessing the AST node for
the statement that follows the pragma in question (which is what I would
want to attach my attributes to). I'm confused because it seems like the
nodes would not be available at the point where the pragma handler is
executed (during the Preprocessor run).
> Eventually I can imagine that we will want to have an explicit
> representation in the AST of the pragma (for example, if we want to be
> able to print the parse AST back out in exactly the form the user
> specified it). However, if your problem can be fit into the existing
> model that will probably be much less work. Can you tell us more about
> what you are trying to do?
>
As I said above my problem should more or less fit into the attribute
model (I don't care about the specific pragma string used) -- at least
if I can attach these attributes to any statement following one of the
pragmas. What I'm actually working on is a source to source OpenMP 3
implementation. Once that is in a usable state it should serve as a
research testbed for checking the usefulness of some additions to OMP 3.
Obviously this is a rather long-term project ;)
Thanks,
Peter
More information about the cfe-dev
mailing list