efriedma added inline comments.

================
Comment at: clang/lib/AST/ExprConstant.cpp:11737
     bool Ret = HandleSizeof(Info, ExprLoc, Ty, Result);
     if (Ty->isStructureType() &&
         Ty->getAsStructureType()->getDecl()->hasFlexibleArrayMember()) {
----------------
For the second call to CheckHandleSizeof (line 11791), is the type of 
consistent with the type of the variable?  If Ty refers to a field, I'm not 
sure it makes sense to call getFlexibleArrayInitChars().  Something along the 
lines of "struct Z { struct A { int x, y[]; } z; int a; };"


================
Comment at: clang/lib/AST/ExprConstant.cpp:11740
+      if (const auto *V = LVal.getLValueBase().dyn_cast<const ValueDecl *>())
+        Result += cast<VarDecl>(V)->getFlexibleArrayInitChars(Info.Ctx);
     }
----------------
I think I'd like to check `isa<VarDecl>` here to be on the safe side, even if I 
don't have a specific example where it would break.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151148

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to