The if-clause on the combined directive potentially applies to both the
'target' and the 'parallel' regions. Codegen'ing the if-clause on the
combined directive requires additional support because the expression in
the clause must be captured by the 'target' capture statement but not
the 'parallel' capture statement. Note that this situation arises for
other clauses such as num_threads.
The OMPIfClause class inherits OMPClauseWithPreInit to support capturing
of expressions in the clause. A member CaptureRegion is added to
OMPClauseWithPreInit to indicate the innermost captured statement (in this
case 'target' but not 'parallel') that captures these expressions.
To ensure correct codegen of captured expressions in the presence of
'parallel' combined with 'target', OMPParallelScope was added to 'parallel'
codegen.
Could you join it with OMPLexicalScope somehow? I don't like the idea of adding a different kind of scope for parallel and other directives.
Or follow the solution for OMPLoopScope, rather than for OMPLexicalScope.