[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


================
@@ -7425,6 +7425,12 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
     writeEnum(DC->getDefaultClauseKind());
     return;
   }
+  case OpenACCClauseKind::If: {
+    const auto *IC = cast<OpenACCIfClause>(C);
+    writeSourceLocation(IC->getLParenLoc());
+    AddStmt(const_cast<Expr *>(IC->getConditionExpr()));
----------------
erichkeane wrote:

Removing 'const' from these handful of places means that a whole ton of other stuff ends up needing to lose const-correctness.  The Construct storage needs to stop using 'const' clauses (or at least the 'clauses' function), and 'const'ness gets lost everywhere else. .

These pair of const-casts seemed like the 'lesser' of evils?

WDYT?  I could take the time to de-const much of the AST nodes if you'd like, but was hoping to avoid that (And I don't know if that means NO const casts, we might need some anyway).  

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


More information about the cfe-commits mailing list