[PATCH] D146801: [clang] Fix consteval initializers of temporaries

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 24 07:15:51 PDT 2023


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:1593-1595
+  if (ConstantExpr *CE = dyn_cast_or_null<ConstantExpr>(Inner))
+    if (CE->isImmediateInvocation())
+      Inner = CE->getSubExpr();
----------------
Fznamznon wrote:
> aaron.ballman wrote:
> > This will need reformatting, but because we can use C++17 features, we can be slightly fancier here. :-)
> > 
> > NB: I think we don't need to use `dyn_cast_or_null` here or on the predicate above. We're calling `isa<Whatever>(Inner)` immediately below and that will assert if `Inner` was null, so it seems like we're already relying on `Inner` being nonnull.
> That makes sense, thank you.
> Although, I can't make `CE` const because `Inner` is not `const`.
Ah, that's fine, no worries about the `const` then. That suggestion is mostly a reflex for me at this point. :-D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146801



More information about the cfe-commits mailing list