[PATCH] D149904: Generic selection expressions that accept a type operand

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 5 00:01:29 PDT 2023


cor3ntin added a comment.

I observe there is no documentation or release notes yet :)



================
Comment at: clang/include/clang/AST/Expr.h:5930
+  /// argument.
+  bool isExprPredicate() const { return IsExprPredicate; }
+  /// Whether this generic selection uses a type as its controlling argument.
----------------
nitpick: wouldn't `PredicateIsExpr()` make more sense?


================
Comment at: clang/include/clang/AST/Expr.h:5970
   ArrayRef<Expr *> getAssocExprs() const {
     return {reinterpret_cast<Expr *const *>(getTrailingObjects<Stmt *>() +
+                                            getIndexOfStartOfAssociatedExprs()),
----------------
Pre-existing but why not use `cast` here?


================
Comment at: clang/lib/Sema/SemaExpr.cpp:1704-1711
+        // We relax the restriction on use of incomplete types and non-object
+        // types with the type-based extension of _Generic. Allowing incomplete
+        // objects means those can be used as "tags" for a type-safe way to map
+        // to a value. Similarly, matching on function types rather than
+        // function pointer types can be useful. However, the restriction on VM
+        // types makes sense to retain as there are open questions about how
+        // the selection can be made at compile time.
----------------
 Does that mean you can match on array of unknown bound? I struggle to imagine how this could be used.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149904/new/

https://reviews.llvm.org/D149904



More information about the cfe-commits mailing list