[clang] [OpenMP] Add runtime selection for metadirective with non-constant conditions. (PR #192455)
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 27 06:51:26 PDT 2026
================
@@ -2689,6 +2723,148 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
// A single match is returned for OpenMP 5.0
int BestIdx = getBestVariantMatchForContext(VMIs, OMPCtx);
+ // Check if we have user conditions that are not simple IntegerLiterals.
+ // For simple IntegerLiterals (like condition(0) or condition(1)), we can
+ // evaluate them here. For anything else (variables, templates, complex
+ // expressions), we need to send to Sema for proper handling.
+ bool HasNonConstantUserCondition = false;
+ for (OMPTraitInfo *TI : TraitInfos) {
+ if (TI && TI->hasUserCondition()) {
+ // Check if all user conditions are simple IntegerLiterals.
+ TI->anyScoreOrCondition([&](Expr *&E, bool IsScore) {
+ if (!IsScore && E) {
+ // If it's not a simple IntegerLiteral, we need Sema
+ if (!isa<IntegerLiteral>(E->IgnoreParenImpCasts())) {
+ HasNonConstantUserCondition = true;
+ return true;
+ }
+ }
+ return false;
+ });
+ if (HasNonConstantUserCondition)
+ break;
+ }
+ }
----------------
zahiraam wrote:
Done.
https://github.com/llvm/llvm-project/pull/192455
More information about the cfe-commits
mailing list