================ @@ -4029,10 +4029,12 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj, LastField = nullptr; if (ObjType->isArrayType()) { // Next subobject is an array element. - const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(ObjType); - assert(CAT && "vla in literal type?"); + const ArrayType *AT = Info.Ctx.getAsArrayType(ObjType); + assert((isa<ConstantArrayType>(AT) || isa<IncompleteArrayType>(AT)) && + "vla in literal type?"); uint64_t Index = Sub.Entries[I].getAsArrayIndex(); - if (CAT->getSize().ule(Index)) { + if (isa<ConstantArrayType>(AT) && + cast<ConstantArrayType>(AT)->getSize().ule(Index)) { ---------------- Fznamznon wrote:
isa and cast does isa two times. AFAIK llvm coding guide recommends to avoid that. Can we do ```suggestion if (auto *CAT = dyn_cast<ConstantArrayType>(AT); CAT && CAT->getSize().ule(Index)) { ``` https://github.com/llvm/llvm-project/pull/155080 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits