[PATCH] D123826: Fix size of flexible array initializers, and re-enable assertions.

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 15 08:55:59 PDT 2022


erichkeane added inline comments.


================
Comment at: clang/lib/AST/Decl.cpp:2735
+  const Expr *FlexibleInit = List->getInit(List->getNumInits() - 1);
+  auto InitTy = Ctx.getAsConstantArrayType(FlexibleInit->getType());
+  if (!InitTy)
----------------
efriedma wrote:
> erichkeane wrote:
> > Same here
> You want something like this?
> 
> ```
> if (auto *List = dyn_cast<InitListExpr>(getInit()->IgnoreParens())) {
>   const Expr *FlexibleInit = List->getInit(List->getNumInits() - 1);
>   if (auto InitTy = Ctx.getAsConstantArrayType(FlexibleInit->getType())) {
>     return InitTy->getSize() != 0;
>   }
> }
> return false;
> ```
ah, shucks, i missed that this was an early exit (that is, I missed the '!').  Disregard.  LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123826



More information about the cfe-commits mailing list