zahiraam wrote:

@alexey-bataev - I understand the current implementation is fundamentally 
broken. Before implementing a fix, I want to confirm the following correct 
approach.

Parser:
  1. Parse each variant directive completely including all clauses.
  2. Do not parse the associated statement (body).
  3. Return complete directive AST nodes with nullptr body.
  4. Parse the shared body once after all variants.
  5. Pass complete directive (nodes + shared body) to Sema.

Sema:
  1. Receive complete directive ASTs (with all clauses) and shared body.
  2. Set the shared body on each variant directive.
  3. Build IfStmt branching between complete directive nodes.
  4. Wrap in OMPMetaDirective.

Example:
  #pragma omp metadirective \
      when(user={condition(flag)}: parallel num_threads(4)) \
      otherwise(single nowait)
  { foo(); }

Parser produces:
  - OMPParallelDirective with num_threads(4) clause, body=nullptr
  - OMPSingleDirective with nowait clause, body=nullptr
  - Shared body: { foo(); }

Sema produces:
  IfStmt(flag,
    then: OMPParallelDirective(num_threads(4)) { foo(); },
    else: OMPSingleDirective(nowait) { foo(); }
  )

Is this the correct approach? 
Thanks.

https://github.com/llvm/llvm-project/pull/192455
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to