[cfe-dev] OpenMP support in CLANG: A proposal
Olaf Krzikalla
Olaf.Krzikalla at tu-dresden.de
Wed Nov 7 06:28:07 PST 2012
Hi,
a general note at first: I noticed the line
PP.EnterTokenStream(Toks, 1, /*DisableMacroExpansion=*/true,
/*OwnsTokens=*/false);
in your code. IMHO DisableMacroExpansion should be false, since all text
after a #pragma omp is subject to macro expansion (OpenMP 3.1, sec.2.1).
Also I dont understand what you mean with scope in the case of "if" clauses.
I see, what you want to accomplish by integrating OpenMP directly in the
parser. If you encounter a omp parallel directive you instruct the
parser to parse a structured block. And if that fails it is an error.
I would go another route. I would stll see OpenMP directives as
attributes to statements. And by the moment these attributes are
attached to a statement the appropriate checks can be made.
Try to attach an "omp parallel" directive to a class declaration -> error
Try to attach an "omp parallel for" directive to a non-conforming
for-Statement -> error.
You see by the second example, that with this approach you aren't longer
limited by the means of the parser.
Of course you are right by writing:
> So, we have to piggy back Global parser
> to handle scopes, parse expressions and compound statement (structured
> block).
Thats what I meant in point 4 of my previous writing. We have to shout
it out as often as possible to the right people (I don't belong to them)
that the Parser needs a serious refactoring in order to support
expressions inside pragmas and (later) C++0x-attributes.
To say it with Douglas Gregors words from a another posting: while
OpenMP is just a standard, using it is an industry trend. (actually I
have wondered that the clang people could ignore it successfully for
such a long time).
So my suggestion remains: try to handle OpenMP directives as attributes.
Extend the attribute framework in a way, that made it possible to
user-check attributes at the time they are attached to the appropriate
AST entity. And refactor the parser framework so that it is possible to
parse code snippets.
Best Olaf
More information about the cfe-dev
mailing list