[cfe-dev] [RFC] OpenMP Support in Clang

Dmitri Gribenko gribozavr at gmail.com
Tue Feb 12 05:24:10 PST 2013


On Tue, Feb 12, 2013 at 2:26 PM, Alexey Bataev <a.bataev at hotmail.com> wrote:
> Hello everybody,
> I'd like to discuss representation of OpenMP directives and clauses in AST.
> I'm trying to solve this problem by introducing new Stmt-based classes for
> each executable directive and clause. But there is a class AttributedStmt
> with some remarkable comment:
> /// Represents an attribute applied to a statement. For example:
> ///   [[omp::for(...)]] for (...) { ... }
>
> So, what is preferred solution? Introduce new Stmt classes for directives
> and clauses or it would be better to try to represent them as attributes and
> to use existing class AttributedStmt?

I think this was discussed before, and the consensus was to create new
AST nodes because:

* translating pragmas to attributes might be hard;
* preserving enough source information in attributes that really
represent pragmas will be definitely hard and non-intuitive.

The [[omp::for...]] example is there because OpenMP pragmas was a
motivation for C++11 attributes.  Like: C++11 attributes will enable
OpenMP to create a new syntax without pramgas.  But this did not
happen yet.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-dev mailing list