[clang] [OpenMP] Add runtime selection for metadirective with non-constant conditions. (PR #192455)

Zahira Ammarguellat via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 17 08:33:59 PDT 2026


================
@@ -2662,11 +2664,115 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
       TI.getAsVariantMatchInfo(ASTContext, VMI);
 
       VMIs.push_back(VMI);
+      TraitInfos.push_back(&TI);
+      ClauseKinds.push_back(CKind);
     }
 
     TPA.Revert();
     // End of the first iteration. Parser is reset to the start of metadirective
 
+    // Check if we have non-constant user conditions.
+    bool HasNonConstantUserCondition = false;
+    for (unsigned i = 0; i < TraitInfos.size(); ++i) {
+      if (ClauseKinds[i] == OMPC_when) {
+        OMPTraitInfo *TI = TraitInfos[i];
+        TI->anyScoreOrCondition([&](Expr *&E, bool IsScore) {
+          if (!IsScore && E && !E->isIntegerConstantExpr(ASTContext)) {
----------------
zahiraam wrote:

After investigation, I discovered that template instantiation for metadirectives is not currently
supported. `TreeTransform::TransformOMPMetaDirective` returns an error for any template instantiation.
I am scoping this PR to non-template cases only. I will add comments documenting this limitation in the Parser, Sema, and CodeGen. Template support will require additional implementation to properly handle instantiation, which I plan to address in a follow-up PR. Does this scoping seem reasonable?

https://github.com/llvm/llvm-project/pull/192455


More information about the cfe-commits mailing list