Skip to content

Commit 418d6ba

Browse files
committed
fix review
1 parent 00a2038 commit 418d6ba

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4029,14 +4029,12 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
40294029
LastField = nullptr;
40304030
if (ObjType->isArrayType()) {
40314031
// Next subobject is an array element.
4032-
const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(ObjType);
4033-
const IncompleteArrayType *IAT =
4034-
Info.Ctx.getAsIncompleteArrayType(ObjType);
4035-
const ArrayType *AT = CAT ? static_cast<const ArrayType *>(CAT)
4036-
: static_cast<const ArrayType *>(IAT);
4037-
assert(AT && "vla in literal type?");
4032+
const ArrayType *AT = Info.Ctx.getAsArrayType(ObjType);
4033+
assert((isa<ConstantArrayType>(AT) || isa<IncompleteArrayType>(AT)) &&
4034+
"vla in literal type?");
40384035
uint64_t Index = Sub.Entries[I].getAsArrayIndex();
4039-
if (CAT && CAT->getSize().ule(Index)) {
4036+
if (isa<ConstantArrayType>(AT) &&
4037+
cast<ConstantArrayType>(AT)->getSize().ule(Index)) {
40404038
// Note, it should not be possible to form a pointer with a valid
40414039
// designator which points more than one past the end of the array.
40424040
if (Info.getLangOpts().CPlusPlus11)
@@ -4052,7 +4050,8 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
40524050
if (O->getArrayInitializedElts() > Index)
40534051
O = &O->getArrayInitializedElt(Index);
40544052
else if (!isRead(handler.AccessKind)) {
4055-
if (CAT && !CheckArraySize(Info, CAT, E->getExprLoc()))
4053+
if (isa<ConstantArrayType>(AT) &&
4054+
!CheckArraySize(Info, cast<ConstantArrayType>(AT), E->getExprLoc()))
40564055
return handler.failed();
40574056

40584057
expandArray(*O, Index);

0 commit comments

Comments
 (0)