[clang] [OpenACC] Implement 'if' clause for Compute Constructs (PR #88411)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 11 12:58:18 PDT 2024


================
@@ -27,10 +28,48 @@ OpenACCDefaultClause *OpenACCDefaultClause::Create(const ASTContext &C,
   return new (Mem) OpenACCDefaultClause(K, BeginLoc, LParenLoc, EndLoc);
 }
 
+OpenACCIfClause *OpenACCIfClause::Create(const ASTContext &C,
+                                         SourceLocation BeginLoc,
+                                         SourceLocation LParenLoc,
+                                         Expr *ConditionExpr,
+                                         SourceLocation EndLoc) {
+  void *Mem = C.Allocate(sizeof(OpenACCIfClause), alignof(OpenACCIfClause));
+  return new (Mem) OpenACCIfClause(BeginLoc, LParenLoc, ConditionExpr, EndLoc);
+}
+
+OpenACCIfClause::OpenACCIfClause(SourceLocation BeginLoc,
+                                 SourceLocation LParenLoc, Expr *ConditionExpr,
+                                 SourceLocation EndLoc)
+    : OpenACCClauseWithCondition(OpenACCClauseKind::If, BeginLoc, LParenLoc,
+                                 ConditionExpr, EndLoc) {
+  assert(ConditionExpr && "if clause requires condition expr");
+  assert((ConditionExpr->isInstantiationDependent() ||
+          ConditionExpr->getType()->isScalarType()) &&
----------------
erichkeane wrote:

Nope, sadly no.  "C" mode actually just leaves it as a scalar since it doesn't have a bool type, and we don't manage to do any real conversions there.  So I have to accept 'scalar', then follow language rules in CodeGen to get to the correct type.

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


More information about the cfe-commits mailing list