@@ -3843,9 +3843,8 @@ static bool handleScalarCast(EvalInfo &Info, const FPOptions FPO, const Expr *E,
38433843 if (!HandleConversionToBool(Original, BoolResult))
38443844 return false;
38453845 uint64_t IntResult = BoolResult;
3846- Result = APValue(Info.Ctx.MakeIntValue(IntResult, DestTy));
3847- // TODO destty is wrong here if destty is float....
3848- // can we use sourcety here?
3846+ Result = APValue(Info.Ctx.MakeIntValue(
3847+ IntResult, Info.Ctx.getIntTypeForBitwidth(64, true)));
38493848 }
38503849 if (DestTy->isFloatingType()) {
38513850 APValue Result2 = APValue(APFloat(0.0));
@@ -3897,8 +3896,6 @@ static bool handleScalarCast(EvalInfo &Info, const FPOptions FPO, const Expr *E,
38973896 }
38983897 }
38993898
3900- // Info.FFDiag(E, diag::err_convertvector_constexpr_unsupported_vector_cast)
3901- // << SourceTy << DestTy;
39023899 return false;
39033900}
39043901
@@ -3917,7 +3914,7 @@ static bool constructAggregate(EvalInfo &Info, const FPOptions FPO,
39173914 while (!WorkList.empty() && ElI < Elements.size()) {
39183915 auto [Res, Type, BitWidth] = WorkList.pop_back_val();
39193916
3920- if (Type->isRealFloatingType() || Type->isBooleanType() ) {
3917+ if (Type->isRealFloatingType()) {
39213918 if (!handleScalarCast(Info, FPO, E, ElTypes[ElI], Type, Elements[ElI],
39223919 *Res))
39233920 return false;
@@ -3978,10 +3975,10 @@ static bool constructAggregate(EvalInfo &Info, const FPOptions FPO,
39783975 // we need to traverse backwards
39793976 // Visit the base classes.
39803977 if (auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
3981- // todo assert there is only 1 base at most
3982- for (size_t I = 0, E = CXXRD->getNumBases(); I != E; ++I) {
3983- const CXXBaseSpecifier &BS = CXXRD->bases_begin()[I ];
3984- ReverseList.emplace_back(&Res->getStructBase(I ), BS.getType(), 0u);
3978+ if (CXXRD->getNumBases() > 0) {
3979+ assert( CXXRD->getNumBases() == 1);
3980+ const CXXBaseSpecifier &BS = CXXRD->bases_begin()[0 ];
3981+ ReverseList.emplace_back(&Res->getStructBase(0 ), BS.getType(), 0u);
39853982 }
39863983 }
39873984
@@ -4057,13 +4054,12 @@ static unsigned elementwiseSize(EvalInfo &Info, QualType BaseTy) {
40574054 }
40584055 if (Type->isRecordType()) {
40594056 const RecordDecl *RD = Type->getAsRecordDecl();
4060- // const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
40614057
40624058 // Visit the base classes.
40634059 if (auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
4064- // todo assert there is only 1 base at most
4065- for (size_t I = 0, E = CXXRD->getNumBases(); I != E; ++I) {
4066- const CXXBaseSpecifier &BS = CXXRD->bases_begin()[I ];
4060+ if (CXXRD->getNumBases() > 0) {
4061+ assert( CXXRD->getNumBases() == 1);
4062+ const CXXBaseSpecifier &BS = CXXRD->bases_begin()[0 ];
40674063 WorkList.push_back(BS.getType());
40684064 }
40694065 }
@@ -4126,7 +4122,6 @@ static bool flattenAPValue(const ASTContext &Ctx, APValue Value,
41264122 for (FieldDecl *FD : RD->fields()) {
41274123 if (FD->isUnnamedBitField())
41284124 continue;
4129- // if (FD->isBitField()) {
41304125 ReverseList.emplace_back(Work.getStructField(FD->getFieldIndex()),
41314126 FD->getType());
41324127 }
0 commit comments