Lines Matching full:info

201     // arrays that lack size info.
394 bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK);
461 void diagnoseUnsizedArrayPointerArithmetic(EvalInfo &Info, const Expr *E);
462 void diagnosePointerArithmetic(EvalInfo &Info, const Expr *E,
465 void adjustIndex(EvalInfo &Info, const Expr *E, APSInt N) {
469 diagnoseUnsizedArrayPointerArithmetic(Info, E);
494 diagnosePointerArithmetic(Info, E, N);
546 EvalInfo &Info;
612 CallStackFrame(EvalInfo &Info, SourceRange CallRange,
721 static bool HandleDestruction(EvalInfo &Info, const Expr *E,
723 static bool HandleDestruction(EvalInfo &Info, SourceLocation Loc,
744 bool endLifetime(EvalInfo &Info, bool RunDestructors) {
751 return HandleDestruction(Info, Loc, Base, *Value.getPointer(), T);
1318 EvalInfo &Info;
1322 ArrayInitLoopIndex(EvalInfo &Info)
1323 : Info(Info), OuterIndex(Info.ArrayInitIndex) {
1324 Info.ArrayInitIndex = 0;
1326 ~ArrayInitLoopIndex() { Info.ArrayInitIndex = OuterIndex; }
1328 operator uint64_t&() { return Info.ArrayInitIndex; }
1334 EvalInfo &Info;
1339 explicit FoldConstant(EvalInfo &Info, bool Enabled)
1340 : Info(Info),
1342 HadNoPriorDiags(Info.EvalStatus.Diag &&
1343 Info.EvalStatus.Diag->empty() &&
1344 !Info.EvalStatus.HasSideEffects),
1345 OldMode(Info.EvalMode) {
1347 Info.EvalMode = EvalInfo::EM_ConstantFold;
1351 if (Enabled && HadNoPriorDiags && !Info.EvalStatus.Diag->empty() &&
1352 !Info.EvalStatus.HasSideEffects)
1353 Info.EvalStatus.Diag->clear();
1354 Info.EvalMode = OldMode;
1361 EvalInfo &Info;
1363 explicit IgnoreSideEffectsRAII(EvalInfo &Info)
1364 : Info(Info), OldMode(Info.EvalMode) {
1365 Info.EvalMode = EvalInfo::EM_IgnoreSideEffects;
1368 ~IgnoreSideEffectsRAII() { Info.EvalMode = OldMode; }
1374 EvalInfo *Info = nullptr;
1379 Info = Other.Info;
1382 Other.Info = nullptr;
1386 if (!Info)
1389 Info->EvalStatus = OldStatus;
1390 Info->SpeculativeEvaluationDepth = OldSpeculativeEvaluationDepth;
1397 EvalInfo &Info, SmallVectorImpl<PartialDiagnosticAt> *NewDiag = nullptr)
1398 : Info(&Info), OldStatus(Info.EvalStatus),
1399 OldSpeculativeEvaluationDepth(Info.SpeculativeEvaluationDepth) {
1400 Info.EvalStatus.Diag = NewDiag;
1401 Info.SpeculativeEvaluationDepth = Info.CallStackDepth + 1;
1422 EvalInfo &Info;
1425 ScopeRAII(EvalInfo &Info)
1426 : Info(Info), OldStackSize(Info.CleanupStack.size()) {
1429 Info.CurrentCall->pushTempVersion();
1432 bool OK = cleanup(Info, RunDestructors, OldStackSize);
1441 Info.CurrentCall->popTempVersion();
1444 static bool cleanup(EvalInfo &Info, bool RunDestructors,
1446 assert(OldStackSize <= Info.CleanupStack.size() &&
1452 for (unsigned I = Info.CleanupStack.size(); I > OldStackSize; --I) {
1453 if (Info.CleanupStack[I - 1].isDestroyedAtEndOf(Kind)) {
1454 if (!Info.CleanupStack[I - 1].endLifetime(Info, RunDestructors)) {
1462 auto NewEnd = Info.CleanupStack.begin() + OldStackSize;
1465 std::remove_if(NewEnd, Info.CleanupStack.end(), [](Cleanup &C) {
1468 Info.CleanupStack.erase(NewEnd, Info.CleanupStack.end());
1477 bool SubobjectDesignator::checkSubobject(EvalInfo &Info, const Expr *E,
1482 Info.CCEDiag(E, diag::note_constexpr_past_end_subobject)
1493 void SubobjectDesignator::diagnoseUnsizedArrayPointerArithmetic(EvalInfo &Info,
1495 Info.CCEDiag(E, diag::note_constexpr_unsized_array_indexed);
1500 void SubobjectDesignator::diagnosePointerArithmetic(EvalInfo &Info,
1506 Info.CCEDiag(E, diag::note_constexpr_array_index)
1510 Info.CCEDiag(E, diag::note_constexpr_array_index)
1515 CallStackFrame::CallStackFrame(EvalInfo &Info, SourceRange CallRange,
1518 : Info(Info), Caller(Info.CurrentCall), Callee(Callee), This(This),
1520 Index(Info.NextCallIndex++) {
1521 Info.CurrentCall = this;
1522 ++Info.CallStackDepth;
1526 assert(Info.CurrentCall == this && "calls retired out of order");
1527 --Info.CallStackDepth;
1528 Info.CurrentCall = Caller;
1727 bool checkNullPointer(EvalInfo &Info, const Expr *E,
1729 return checkNullPointerDiagnosingWith([&Info, E, CSK] {
1730 Info.CCEDiag(E, diag::note_constexpr_null_subobject) << CSK;
1734 bool checkNullPointerForFoldAccess(EvalInfo &Info, const Expr *E,
1736 return checkNullPointerDiagnosingWith([&Info, E, AK] {
1737 Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
1743 bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK) {
1744 return (CSK == CSK_ArrayToPointer || checkNullPointer(Info, E, CSK)) &&
1745 Designator.checkSubobject(Info, E, CSK);
1748 void addDecl(EvalInfo &Info, const Expr *E,
1750 if (checkSubobject(Info, E, isa<FieldDecl>(D) ? CSK_Field : CSK_Base))
1753 void addUnsizedArray(EvalInfo &Info, const Expr *E, QualType ElemTy) {
1755 Info.CCEDiag(E, diag::note_constexpr_unsupported_unsized_array);
1759 if (checkSubobject(Info, E, CSK_ArrayToPointer)) {
1765 void addArray(EvalInfo &Info, const Expr *E, const ConstantArrayType *CAT) {
1766 if (checkSubobject(Info, E, CSK_ArrayToPointer))
1769 void addComplex(EvalInfo &Info, const Expr *E, QualType EltTy, bool Imag) {
1770 if (checkSubobject(Info, E, Imag ? CSK_Imag : CSK_Real))
1773 void addVectorElement(EvalInfo &Info, const Expr *E, QualType EltTy,
1775 if (checkSubobject(Info, E, CSK_VectorElement))
1781 void adjustOffsetAndIndex(EvalInfo &Info, const Expr *E,
1796 if (checkNullPointer(Info, E, CSK_ArrayIndex))
1797 Designator.adjustIndex(Info, E, Index);
1906 static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E);
1907 static bool EvaluateInPlace(APValue &Result, EvalInfo &Info,
1910 static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
1912 static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info,
1915 EvalInfo &Info);
1916 static bool EvaluateTemporary(const Expr *E, LValue &Result, EvalInfo &Info);
1917 static bool EvaluateInteger(const Expr *E, APSInt &Result, EvalInfo &Info);
1919 EvalInfo &Info);
1920 static bool EvaluateFloat(const Expr *E, APFloat &Result, EvalInfo &Info);
1921 static bool EvaluateComplex(const Expr *E, ComplexValue &Res, EvalInfo &Info);
1923 EvalInfo &Info);
1924 static bool EvaluateAsRValue(EvalInfo &Info, const Expr *E, APValue &Result);
1926 EvalInfo &Info,
1931 EvalInfo &Info);
1935 EvalInfo &Info);
1992 if (Index <= Info.SpeculativeEvaluationDepth) {
1994 Info.noteSideEffect();
1996 Info.CleanupStack.push_back(Cleanup(&Result, Base, T, Scope));
2024 Callee->getNameForDiagnostic(Out, Info.Ctx.getPrintingPolicy(),
2030 Object->printPretty(Out, /*Helper=*/nullptr, Info.Ctx.getPrintingPolicy(),
2039 Info.Ctx.getPrintingPolicy(),
2046 Out, Info.Ctx,
2047 Info.Ctx.getLValueReferenceType(This->Designator.MostDerivedType));
2050 Callee->getNameForDiagnostic(Out, Info.Ctx.getPrintingPolicy(),
2063 APValue *V = Info.getParamSlot(Arguments, Param);
2065 V->printPretty(Out, Info.Ctx, Param->getType());
2079 static bool EvaluateIgnoredValue(EvalInfo &Info, const Expr *E) {
2082 if (!Evaluate(Scratch, Info, E))
2084 return Info.noteSideEffect();
2183 static bool GetLValueBaseAsString(const EvalInfo &Info, const LValue &LVal,
2191 Info.Ctx.getObjCEncodingForType(EE->getEncodedType(),
2225 static bool ArePotentiallyOverlappingStringLiterals(const EvalInfo &Info,
2229 if (!GetLValueBaseAsString(Info, LHS, LHSString) ||
2230 !GetLValueBaseAsString(Info, RHS, RHSString))
2292 static void NoteLValueLocation(EvalInfo &Info, APValue::LValueBase Base) {
2301 for (CallStackFrame *F = Info.CurrentCall; F; F = F->Caller) {
2312 Info.Note(VD->getLocation(), diag::note_declared_at);
2314 Info.Note(E->getExprLoc(), diag::note_constexpr_temporary_here);
2317 if (std::optional<DynAlloc *> Alloc = Info.lookupDynamicAlloc(DA))
2318 Info.Note((*Alloc)->AllocExpr->getExprLoc(),
2336 EvalInfo &Info, SourceLocation DiagLoc,
2345 static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
2376 Info.FFDiag(Loc, diag::note_constexpr_invalid_template_arg)
2385 Info.FFDiag(Loc, diag::note_consteval_address_accessible)
2387 Info.Note(FD->getLocation(), diag::note_declared_at);
2395 if (Info.getLangOpts().CPlusPlus11) {
2396 Info.FFDiag(Loc, diag::note_constexpr_non_global, 1)
2406 Info.Note(VarD->getLocation(), diag::note_constexpr_not_static)
2410 NoteLValueLocation(Info, Base);
2413 Info.FFDiag(Loc);
2418 assert((Info.checkingPotentialConstantExpression() ||
2423 Info.FFDiag(Loc, diag::note_constexpr_dynamic_alloc)
2425 NoteLValueLocation(Info, Base);
2444 if (Info.getASTContext().getLangOpts().CUDA &&
2445 Info.getASTContext().getLangOpts().CUDAIsDevice &&
2446 Info.getASTContext().CUDAConstantEvalCtx.NoWrongSidedVars) {
2466 if (Info.getLangOpts().CPlusPlus && !isForManglingOnly(Kind) &&
2476 Info.FFDiag(MTE->getExprLoc(),
2485 Info, MTE->getExprLoc(), TempType, *V, Kind,
2499 Info.CCEDiag(Loc);
2505 Info.FFDiag(Loc, diag::note_constexpr_past_end, 1)
2507 NoteLValueLocation(Info, Base);
2515 static bool CheckMemberPointerConstantExpression(EvalInfo &Info,
2525 Info.FFDiag(Loc, diag::note_consteval_address_accessible) << /*pointer*/ 0;
2526 Info.Note(FD->getLocation(), diag::note_declared_at);
2535 static bool CheckLiteralType(EvalInfo &Info, const Expr *E,
2538 if (Info.getLangOpts().CPlusPlus23)
2541 if (!E->isPRValue() || E->getType()->isLiteralType(Info.Ctx))
2557 if (This && Info.EvaluatingDecl == This->getLValueBase())
2561 if (Info.getLangOpts().CPlusPlus11)
2562 Info.FFDiag(E, diag::note_constexpr_nonliteral)
2565 Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
2570 EvalInfo &Info, SourceLocation DiagLoc,
2577 Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized)
2579 Info.Note(SubobjectDecl->getLocation(),
2582 Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized)
2599 if (!CheckEvaluationResult(CERK, Info, DiagLoc, EltTy,
2606 return CheckEvaluationResult(CERK, Info, DiagLoc, EltTy,
2612 CERK, Info, DiagLoc, Value.getUnionField()->getType(),
2623 Info.FFDiag(TypeBeginLoc, diag::note_constexpr_uninitialized_base)
2627 if (!CheckEvaluationResult(CERK, Info, DiagLoc, BS.getType(), BaseValue,
2638 if (!CheckEvaluationResult(CERK, Info, DiagLoc, I->getType(),
2648 LVal.setFrom(Info.Ctx, Value);
2649 return CheckLValueConstantExpression(Info, DiagLoc, Type, LVal, Kind,
2655 return CheckMemberPointerConstantExpression(Info, DiagLoc, Type, Value, Kind);
2664 static bool CheckConstantExpression(EvalInfo &Info, SourceLocation DiagLoc,
2673 Info, DiagLoc, Type, Value, Kind,
2679 static bool CheckFullyInitialized(EvalInfo &Info, SourceLocation DiagLoc,
2683 CheckEvaluationResultKind::FullyInitialized, Info, DiagLoc, Type, Value,
2689 static bool CheckMemoryLeaks(EvalInfo &Info) {
2690 if (!Info.HeapAllocs.empty()) {
2694 Info.CCEDiag(Info.HeapAllocs.begin()->second.AllocExpr,
2696 << unsigned(Info.HeapAllocs.size() - 1);
2760 EvalInfo &Info) {
2764 if (!Evaluate(Val, Info, E))
2770 static bool HandleOverflow(EvalInfo &Info, const Expr *E,
2772 Info.CCEDiag(E, diag::note_constexpr_overflow)
2774 return Info.noteUndefinedBehavior();
2777 static bool HandleFloatToIntCast(EvalInfo &Info, const Expr *E,
2780 unsigned DestWidth = Info.Ctx.getIntWidth(DestType);
2788 return HandleOverflow(Info, E, Value, DestType);
2797 static llvm::RoundingMode getActiveRoundingMode(EvalInfo &Info, const Expr *E) {
2799 E->getFPFeaturesInEffect(Info.Ctx.getLangOpts()).getRoundingMode();
2806 static bool checkFloatingPointResult(EvalInfo &Info, const Expr *E,
2810 if (Info.InConstantContext)
2813 FPOptions FPO = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
2818 Info.FFDiag(E, diag::note_constexpr_dynamic_rounding);
2826 Info.FFDiag(E, diag::note_constexpr_float_arithmetic_strict);
2833 Info.FFDiag(E);
2846 static bool HandleFloatToFloatCast(EvalInfo &Info, const Expr *E,
2854 llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
2858 St = Result.convert(Info.Ctx.getFloatTypeSemantics(DestType), RM, &ignored);
2859 return checkFloatingPointResult(Info, E, St);
2862 static APSInt HandleIntToIntCast(EvalInfo &Info, const Expr *E,
2865 unsigned DestWidth = Info.Ctx.getIntWidth(DestType);
2875 static bool HandleIntToFloatCast(EvalInfo &Info, const Expr *E,
2879 Result = APFloat(Info.Ctx.getFloatTypeSemantics(DestType), 1);
2880 llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
2882 return checkFloatingPointResult(Info, E, St);
2885 static bool truncateBitfieldValue(EvalInfo &Info, const Expr *E,
2894 Info.FFDiag(E);
2910 static bool CheckedIntArithmetic(EvalInfo &Info, const Expr *E,
2922 if (Info.checkingForUndefinedBehavior())
2923 Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
2928 return HandleOverflow(Info, E, Value, E->getType());
2934 static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E,
2940 Info.FFDiag(E);
2943 return CheckedIntArithmetic(Info, E, LHS, RHS, LHS.getBitWidth() * 2,
2946 return CheckedIntArithmetic(Info, E, LHS, RHS, LHS.getBitWidth() + 1,
2949 return CheckedIntArithmetic(Info, E, LHS, RHS, LHS.getBitWidth() + 1,
2957 Info.FFDiag(E, diag::note_expr_divide_by_zero)
2966 Info, E, -LHS.extend(LHS.getBitWidth() + 1), E->getType());
2970 if (Info.getLangOpts().OpenCL)
2978 Info.CCEDiag(E, diag::note_constexpr_negative_shift) << RHS;
2979 if (!Info.noteUndefinedBehavior())
2989 Info.CCEDiag(E, diag::note_constexpr_large_shift)
2991 if (!Info.noteUndefinedBehavior())
2993 } else if (LHS.isSigned() && !Info.getLangOpts().CPlusPlus20) {
2999 Info.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << LHS;
3000 if (!Info.noteUndefinedBehavior())
3003 Info.CCEDiag(E, diag::note_constexpr_lshift_discards);
3004 if (!Info.noteUndefinedBehavior())
3012 if (Info.getLangOpts().OpenCL)
3020 Info.CCEDiag(E, diag::note_constexpr_negative_shift) << RHS;
3021 if (!Info.noteUndefinedBehavior())
3031 Info.CCEDiag(E, diag::note_constexpr_large_shift)
3033 if (!Info.noteUndefinedBehavior())
3053 static bool handleFloatFloatBinOp(EvalInfo &Info, const BinaryOperator *E,
3056 llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
3060 Info.FFDiag(E);
3075 Info.CCEDiag(E, diag::note_expr_divide_by_zero);
3085 Info.CCEDiag(E, diag::note_constexpr_float_arithmetic) << LHS.isNaN();
3086 return Info.noteUndefinedBehavior();
3089 return checkFloatingPointResult(Info, E, St);
3177 static bool handleVectorVectorBinOp(EvalInfo &Info, const BinaryOperator *E,
3194 Info.FFDiag(E);
3208 APSInt EltResult{Info.Ctx.getIntWidth(EltTy),
3217 Success = handleIntIntBinOp(Info, E, LHSElt.getInt(), Opcode,
3221 Info.FFDiag(E);
3232 if (!handleFloatFloatBinOp(Info, E, LHSFloat, Opcode,
3234 Info.FFDiag(E);
3248 static bool CastToDerivedClass(EvalInfo &Info, const Expr *E, LValue &Result,
3258 if (!Result.checkSubobject(Info, E, CSK_Derived))
3265 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
3277 static bool HandleLValueDirectBase(EvalInfo &Info, const Expr *E, LValue &Obj,
3283 RL = &Info.Ctx.getASTRecordLayout(Derived);
3286 Obj.addDecl(Info, E, Base, /*Virtual*/ false);
3291 static bool HandleLValueBase(EvalInfo &Info, const Expr *E, LValue &Obj,
3297 return HandleLValueDirectBase(Info, E, Obj, DerivedDecl, BaseDecl);
3305 if (!CastToDerivedClass(Info, E, Obj, DerivedDecl, D.MostDerivedPathLength))
3310 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(DerivedDecl);
3311 Obj.addDecl(Info, E, BaseDecl, /*Virtual*/ true);
3316 static bool HandleLValueBasePath(EvalInfo &Info, const CastExpr *E,
3321 if (!HandleLValueBase(Info, E, Result, Type->getAsCXXRecordDecl(),
3330 static bool CastToBaseClass(EvalInfo &Info, const Expr *E, LValue &Result,
3339 if (!HandleLValueBase(Info, E, Result, Elem.Class, Elem.Base))
3346 static bool HandleLValueMember(EvalInfo &Info, const Expr *E, LValue &LVal,
3351 RL = &Info.Ctx.getASTRecordLayout(FD->getParent());
3355 LVal.addDecl(Info, E, FD);
3356 LVal.adjustOffset(Info.Ctx.toCharUnitsFromBits(RL->getFieldOffset(I)));
3361 static bool HandleLValueIndirectMember(EvalInfo &Info, const Expr *E,
3365 if (!HandleLValueMember(Info, E, LVal, cast<FieldDecl>(C)))
3376 static bool HandleSizeof(EvalInfo &Info, SourceLocation Loc, QualType Type,
3386 Info.FFDiag(Loc);
3393 Info.FFDiag(Loc);
3398 Size = Info.Ctx.getTypeSizeInChars(Type);
3400 Size = Info.Ctx.getTypeInfoDataSizeInChars(Type).Width;
3405 /// \param Info - Information about the ongoing evaluation.
3410 static bool HandleLValueArrayAdjustment(EvalInfo &Info, const Expr *E,
3414 if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfPointee))
3417 LVal.adjustOffsetAndIndex(Info, E, Adjustment, SizeOfPointee);
3421 static bool HandleLValueArrayAdjustment(EvalInfo &Info, const Expr *E,
3424 return HandleLValueArrayAdjustment(Info, E, LVal, EltTy,
3429 /// \param Info - Information about the ongoing evaluation.
3433 static bool HandleLValueComplexElement(EvalInfo &Info, const Expr *E,
3438 if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfComponent))
3442 LVal.addComplex(Info, E, EltTy, Imag);
3446 static bool HandleLValueVectorElement(EvalInfo &Info, const Expr *E,
3451 if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfElement))
3455 LVal.addVectorElement(Info, E, EltTy, Size, Idx);
3461 /// \param Info Information about the ongoing evaluation.
3468 static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
3474 Info.getLangOpts().CPlusPlus23 && VD->getType()->isReferenceType();
3492 if (Info.checkingPotentialConstantExpression())
3496 Info.FFDiag(E->getBeginLoc(),
3505 if (Info.EvaluatingDecl == Base) {
3506 Result = Info.EvaluatingDeclValue;
3517 if (!Info.checkingPotentialConstantExpression() ||
3518 !Info.CurrentCall->Callee ||
3519 !Info.CurrentCall->Callee->Equals(VD->getDeclContext())) {
3520 if (Info.getLangOpts().CPlusPlus11) {
3521 Info.FFDiag(E, diag::note_constexpr_function_param_value_unknown)
3523 NoteLValueLocation(Info, Base);
3525 Info.FFDiag(E);
3545 if (!Info.checkingPotentialConstantExpression()) {
3546 Info.FFDiag(E, diag::note_constexpr_var_init_unknown, 1)
3548 NoteLValueLocation(Info, Base);
3563 assert(!VD->mightBeUsableInConstantExpressions(Info.Ctx));
3564 if (!Info.checkingPotentialConstantExpression()) {
3565 Info.FFDiag(E, Info.getLangOpts().CPlusPlus11
3569 NoteLValueLocation(Info, Base);
3582 Result = &Info.CurrentCall->createConstexprUnknownAPValues(VD, Base);
3585 Info.FFDiag(E, diag::note_constexpr_var_init_non_constant, 1) << VD;
3586 NoteLValueLocation(Info, Base);
3599 if ((Info.getLangOpts().CPlusPlus && !VD->hasConstantInitialization() &&
3600 VD->mightBeUsableInConstantExpressions(Info.Ctx)) ||
3601 ((Info.getLangOpts().CPlusPlus || Info.getLangOpts().OpenCL) &&
3602 !Info.getLangOpts().CPlusPlus11 && !VD->hasICEInitializer(Info.Ctx))) {
3604 Info.CCEDiag(E, diag::note_constexpr_var_init_non_constant, 1) << VD;
3605 NoteLValueLocation(Info, Base);
3607 Info.CCEDiag(E);
3614 Info.FFDiag(E, diag::note_constexpr_var_init_weak) << VD;
3615 NoteLValueLocation(Info, Base);
3630 Result = &Info.CurrentCall->createConstexprUnknownAPValues(VD, Base);
3653 static APSInt extractStringLiteralCharacter(EvalInfo &Info, const Expr *Lit,
3661 Info.Ctx.getObjCEncodingForType(ObjCEnc->getEncodedType(), Str);
3670 Info.Ctx.getAsConstantArrayType(S->getType());
3674 APSInt Value(Info.Ctx.getTypeSize(CharType),
3685 static void expandStringLiteral(EvalInfo &Info, const StringLiteral *S,
3688 const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(
3697 APSInt Value(Info.Ctx.getTypeSize(CharType),
3760 static bool diagnoseMutableFields(EvalInfo &Info, const Expr *E, AccessKinds AK,
3776 Info.FFDiag(E, diag::note_constexpr_access_mutable, 1) << AK << Field;
3777 Info.Note(Field->getLocation(), diag::note_declared_at);
3781 if (diagnoseMutableFields(Info, E, AK, Field->getType()))
3786 if (diagnoseMutableFields(Info, E, AK, BaseSpec.getType()))
3793 static bool lifetimeStartedInEvaluation(EvalInfo &Info,
3800 switch (Info.IsEvaluatingDecl) {
3806 if (Info.EvaluatingDecl == Base)
3813 return Info.EvaluatingDecl == BaseMTE->getExtendingDecl();
3821 if (MutableSubobject || Base != Info.EvaluatingDecl)
3833 static bool CheckArraySize(EvalInfo &Info, const ConstantArrayType *CAT,
3835 return Info.CheckArraySize(
3837 CAT->getNumAddressingBits(Info.Ctx), CAT->getZExtSize(),
3856 bool mayAccessMutableMembers(EvalInfo &Info, AccessKinds AK) const {
3858 // info), allow it. We assume the type doesn't change dynamically for
3867 if (!Info.getLangOpts().CPlusPlus14 &&
3870 return lifetimeStartedInEvaluation(Info, Base, /*MutableSubobject*/true);
3894 findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
3900 if (Info.getLangOpts().CPlusPlus11)
3901 Info.FFDiag(E, Sub.isOnePastTheEnd()
3906 Info.FFDiag(E);
3932 if (!Info.checkingPotentialConstantExpression())
3933 Info.FFDiag(E, diag::note_constexpr_access_uninit)
3944 Info.isEvaluatingCtorDtor(
3948 ObjType = Info.Ctx.getCanonicalType(ObjType);
3957 if (Info.getLangOpts().CPlusPlus) {
3974 Info.FFDiag(E, diag::note_constexpr_access_volatile_obj, 1)
3976 Info.Note(Loc, diag::note_constexpr_volatile_here) << DiagKind;
3978 Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
3988 !Obj.mayAccessMutableMembers(Info, handler.AccessKind) &&
3989 diagnoseMutableFields(Info, E, handler.AccessKind, ObjType))
4000 !truncateBitfieldValue(Info, E, *O, LastField))
4009 const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(ObjType);
4015 if (Info.getLangOpts().CPlusPlus11)
4016 Info.FFDiag(E, diag::note_constexpr_access_past_end)
4019 Info.FFDiag(E);
4028 if (!CheckArraySize(Info, CAT, E->getExprLoc()))
4039 if (Info.getLangOpts().CPlusPlus11)
4040 Info.FFDiag(E, diag::note_constexpr_access_past_end)
4043 Info.FFDiag(E);
4063 if (Info.getLangOpts().CPlusPlus11)
4064 Info.FFDiag(E, diag::note_constexpr_access_past_end)
4067 Info.FFDiag(E);
4072 Info.CCEDiag(E, diag::note_constexpr_array_index)
4082 !Obj.mayAccessMutableMembers(Info, handler.AccessKind)) {
4083 Info.FFDiag(E, diag::note_constexpr_access_mutable, 1)
4085 Info.Note(Field->getLocation(), diag::note_declared_at);
4106 Info.FFDiag(E, diag::note_constexpr_access_inactive_union_member)
4125 ObjType = getSubobjectType(ObjType, Info.Ctx.getRecordType(Base));
4132 EvalInfo &Info;
4143 return CheckFullyInitialized(Info, E->getExprLoc(), SubobjType, Result);
4157 static bool extractSubobject(EvalInfo &Info, const Expr *E,
4162 ExtractSubobjectHandler Handler = {Info, E, Result, AK};
4163 return findSubobject(Info, E, Obj, Sub, Handler);
4168 EvalInfo &Info;
4178 Info.FFDiag(E, diag::note_constexpr_modify_const_type) << QT;
4197 Info.FFDiag(E);
4215 static bool modifySubobject(EvalInfo &Info, const Expr *E,
4219 ModifySubobjectHandler Handler = { Info, NewVal, E };
4220 return findSubobject(Info, E, Obj, Sub, Handler);
4282 static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
4286 Info.FFDiag(E);
4291 Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
4299 Info.getCallFrameAndDepth(LVal.getLValueCallIndex());
4301 Info.FFDiag(E, diag::note_constexpr_lifetime_ended, 1)
4303 NoteLValueLocation(Info, LVal.Base);
4315 if (Info.getLangOpts().CPlusPlus)
4316 Info.FFDiag(E, diag::note_constexpr_access_volatile_type)
4319 Info.FFDiag(E);
4327 if (Info.getLangOpts().CPlusPlus14 && LVal.Base == Info.EvaluatingDecl &&
4328 lifetimeStartedInEvaluation(Info, LVal.Base)) {
4331 BaseVal = Info.EvaluatingDeclValue;
4337 Info.FFDiag(E, diag::note_constexpr_modify_global);
4342 Info.FFDiag(E, diag::note_constexpr_unsupported_layout)
4352 Info.FFDiag(E, diag::note_constexpr_modify_global);
4362 Info.FFDiag(E, diag::note_constexpr_modify_global);
4378 if (const VarDecl *VDef = VD->getDefinition(Info.Ctx))
4382 Info.FFDiag(E);
4386 bool IsConstant = BaseType.isConstant(Info.Ctx);
4389 Info.EvaluatingDecl.dyn_cast<const ValueDecl *>()))
4399 } else if (Info.getLangOpts().CPlusPlus14 &&
4400 lifetimeStartedInEvaluation(Info, LVal.Base)) {
4406 Info.FFDiag(E, diag::note_constexpr_modify_global);
4410 } else if (Info.getLangOpts().C23 && ConstexprVar) {
4411 Info.FFDiag(E);
4417 if (Info.getLangOpts().CPlusPlus) {
4418 Info.FFDiag(E, diag::note_constexpr_ltor_non_const_int, 1) << VD;
4419 Info.Note(VD->getLocation(), diag::note_declared_at);
4421 Info.FFDiag(E);
4427 } else if (IsConstant && Info.checkingPotentialConstantExpression() &&
4428 BaseType->isLiteralType(Info.Ctx) && !VD->hasDefinition()) {
4434 if (Info.getLangOpts().CPlusPlus) {
4435 Info.CCEDiag(E, Info.getLangOpts().CPlusPlus11
4439 Info.Note(VD->getLocation(), diag::note_declared_at);
4441 Info.CCEDiag(E);
4445 if (Info.getLangOpts().CPlusPlus) {
4446 Info.FFDiag(E, Info.getLangOpts().CPlusPlus11
4450 Info.Note(VD->getLocation(), diag::note_declared_at);
4452 Info.FFDiag(E);
4458 if (!evaluateVarDeclInit(Info, E, VD, Frame, LVal.getLValueVersion(), BaseVal))
4461 std::optional<DynAlloc *> Alloc = Info.lookupDynamicAlloc(DA);
4463 Info.FFDiag(E, diag::note_constexpr_access_deleted_object) << AK;
4502 if (!MTE->isUsableInConstantExpressions(Info.Ctx) &&
4503 !lifetimeStartedInEvaluation(Info, LVal.Base)) {
4506 Info.FFDiag(E, diag::note_constexpr_access_static_temporary, 1) << AK;
4507 Info.Note(MTE->getExprLoc(), diag::note_constexpr_temporary_here);
4518 Info.FFDiag(E, diag::note_constexpr_access_unreadable_object)
4520 << Val.getAsString(Info.Ctx,
4521 Info.Ctx.getLValueReferenceType(LValType));
4522 NoteLValueLocation(Info, LVal.Base);
4542 if ((Frame && Info.getLangOpts().CPlusPlus14 &&
4543 Info.EvalStatus.HasSideEffects) ||
4544 (isModification(AK) && VisibleDepth < Info.SpeculativeEvaluationDepth))
4554 /// \param Info - Information about the ongoing evaluation.
4565 handleLValueToRValueConversion(EvalInfo &Info, const Expr *Conv, QualType Type,
4583 Info.FFDiag(Conv);
4588 if (!Evaluate(Lit, Info, CLE->getInitializer()))
4591 // According to GCC info page:
4606 if (!CLETy.isConstant(Info.Ctx)) {
4607 Info.FFDiag(Conv);
4608 Info.Note(CLE->getExprLoc(), diag::note_declared_at);
4614 return extractSubobject(Info, Conv, LitObj, LVal.Designator, RVal, AK);
4624 Info.FFDiag(Conv);
4628 if (Info.getLangOpts().CPlusPlus11)
4629 Info.FFDiag(Conv, diag::note_constexpr_access_past_end) << AK;
4631 Info.FFDiag(Conv);
4635 RVal = APValue(extractStringLiteralCharacter(Info, Base, CharIndex));
4640 CompleteObject Obj = findCompleteObject(Info, Conv, AK, LVal, Type);
4641 return Obj && extractSubobject(Info, Conv, Obj, LVal.Designator, RVal, AK);
4645 static bool handleAssignment(EvalInfo &Info, const Expr *E, const LValue &LVal,
4650 if (!Info.getLangOpts().CPlusPlus14) {
4651 Info.FFDiag(E);
4655 CompleteObject Obj = findCompleteObject(Info, E, AK_Assign, LVal, LValType);
4656 return Obj && modifySubobject(Info, E, Obj, LVal.Designator, Val);
4661 EvalInfo &Info;
4674 Info.FFDiag(E, diag::note_constexpr_modify_const_type) << QT;
4690 Info.FFDiag(E);
4697 Info.FFDiag(E, diag::note_constexpr_access_uninit)
4703 Info.FFDiag(E);
4713 Info.FFDiag(E);
4716 return handleVectorVectorBinOp(Info, E, Opcode, Value, RHS);
4726 Info.FFDiag(E);
4732 HandleIntToIntCast(Info, E, PromotedLHSType, SubobjType, Value);
4733 if (!handleIntIntBinOp(Info, E, LHS, Opcode, RHS.getInt(), LHS))
4735 Value = HandleIntToIntCast(Info, E, SubobjType, PromotedLHSType, LHS);
4739 Info.Ctx.getLangOpts());
4741 return HandleIntToFloatCast(Info, E, FPO, SubobjType, Value,
4743 handleFloatFloatBinOp(Info, E, FValue, Opcode, RHS.getFloat()) &&
4744 HandleFloatToIntCast(Info, E, PromotedLHSType, FValue, SubobjType,
4748 Info.FFDiag(E);
4753 HandleFloatToFloatCast(Info, E, SubobjType, PromotedLHSType,
4755 handleFloatFloatBinOp(Info, E, Value, Opcode, RHS.getFloat()) &&
4756 HandleFloatToFloatCast(Info, E, PromotedLHSType, SubobjType, Value);
4768 Info.FFDiag(E);
4777 LVal.setFrom(Info.Ctx, Subobj);
4778 if (!HandleLValueArrayAdjustment(Info, E, LVal, PointeeType, Offset))
4789 static bool handleCompoundAssignment(EvalInfo &Info,
4798 if (!Info.getLangOpts().CPlusPlus14) {
4799 Info.FFDiag(E);
4803 CompleteObject Obj = findCompleteObject(Info, E, AK_Assign, LVal, LValType);
4804 CompoundAssignSubobjectHandler Handler = { Info, E, PromotedLValType, Opcode,
4806 return Obj && findSubobject(Info, E, Obj, LVal.Designator, Handler);
4811 EvalInfo &Info;
4821 Info.FFDiag(E, diag::note_constexpr_modify_const_type) << QT;
4853 Info.FFDiag(E);
4864 Info.FFDiag(E);
4886 return HandleOverflow(Info, E, ActualValue, SubobjType);
4895 return HandleOverflow(Info, E, ActualValue, SubobjType);
4907 llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
4913 return checkFloatingPointResult(Info, E, St);
4923 Info.FFDiag(E);
4928 LVal.setFrom(Info.Ctx, Subobj);
4929 if (!HandleLValueArrayAdjustment(Info, E, LVal, PointeeType,
4939 static bool handleIncDec(EvalInfo &Info, const Expr *E, const LValue &LVal,
4944 if (!Info.getLangOpts().CPlusPlus14) {
4945 Info.FFDiag(E);
4950 CompleteObject Obj = findCompleteObject(Info, E, AK, LVal, LValType);
4951 IncDecSubobjectHandler Handler = {Info, cast<UnaryOperator>(E), AK, Old};
4952 return Obj && findSubobject(Info, E, Obj, LVal.Designator, Handler);
4956 static bool EvaluateObjectArgument(EvalInfo &Info, const Expr *Object,
4959 return EvaluatePointer(Object, This, Info);
4962 return EvaluateLValue(Object, This, Info);
4964 if (Object->getType()->isLiteralType(Info.Ctx))
4965 return EvaluateTemporary(Object, This, Info);
4968 return EvaluateTemporary(Object, This, Info);
4970 Info.FFDiag(Object, diag::note_constexpr_nonliteral) << Object->getType();
4977 /// \param Info - Information about the ongoing evaluation.
4985 static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info,
4991 if (!EvaluateMemberPointer(RHS, MemPtr, Info))
4998 Info.FFDiag(RHS);
5008 Info.FFDiag(RHS);
5018 Info.FFDiag(RHS);
5024 if (!CastToDerivedClass(Info, RHS, LV, MemPtr.getContainingRecord(),
5040 if (!HandleLValueDirectBase(Info, RHS, LV, RD, Base))
5045 if (!HandleLValueDirectBase(Info, RHS, LV, RD,
5053 if (!HandleLValueMember(Info, RHS, LV, FD))
5057 if (!HandleLValueIndirectMember(Info, RHS, LV, IFD))
5067 static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info,
5073 if (!EvaluateObjectArgument(Info, BO->getLHS(), LV)) {
5074 if (Info.noteFailure()) {
5076 EvaluateMemberPointer(BO->getRHS(), MemPtr, Info);
5081 return HandleMemberPointerAccess(Info, BO->getLHS()->getType(), LV,
5087 static bool HandleBaseToDerivedCast(EvalInfo &Info, const CastExpr *E,
5090 if (D.Invalid || !Result.checkNullPointer(Info, E, CSK_Derived))
5099 Info.CCEDiag(E, diag::note_constexpr_invalid_downcast)
5114 Info.CCEDiag(E, diag::note_constexpr_invalid_downcast)
5120 return CastToDerivedClass(Info, E, Result, TargetType, NewEntriesSize);
5191 static bool EvaluateVarDecl(EvalInfo &Info, const VarDecl *VD) {
5199 APValue &Val = Info.CurrentCall->createTemporary(VD, VD->getType(),
5205 return Info.noteSideEffect();
5211 if (!EvaluateInPlace(Val, Info, Result, InitE)) {
5221 static bool EvaluateDecl(EvalInfo &Info, const Decl *D) {
5225 OK &= EvaluateVarDecl(Info, VD);
5230 OK &= EvaluateDecl(Info, VD);
5235 static bool EvaluateDependentExpr(const Expr *E, EvalInfo &Info) {
5237 if (Info.noteSideEffect())
5245 static bool EvaluateCond(EvalInfo &Info, const VarDecl *CondDecl,
5249 FullExpressionRAII Scope(Info);
5250 if (CondDecl && !EvaluateDecl(Info, CondDecl))
5252 if (!EvaluateAsBooleanCondition(Cond, Result, Info))
5281 static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
5286 static EvalStmtResult EvaluateLoopBody(StmtResult &Result, EvalInfo &Info,
5289 BlockScopeRAII Scope(Info);
5291 EvalStmtResult ESR = EvaluateStmt(Result, Info, Body, Case);
5310 static EvalStmtResult EvaluateSwitch(StmtResult &Result, EvalInfo &Info,
5312 BlockScopeRAII Scope(Info);
5318 EvalStmtResult ESR = EvaluateStmt(Result, Info, Init);
5326 FullExpressionRAII CondScope(Info);
5328 !EvaluateDecl(Info, SS->getConditionVariable()))
5332 EvaluateDependentExpr(SS->getCond(), Info);
5335 if (!EvaluateInteger(SS->getCond(), Value, Info))
5353 APSInt LHS = CS->getLHS()->EvaluateKnownConstInt(Info.Ctx);
5354 APSInt RHS = CS->getRHS() ? CS->getRHS()->EvaluateKnownConstInt(Info.Ctx)
5366 EvalStmtResult ESR = EvaluateStmt(Result, Info, SS->getBody(), Found);
5381 Info.FFDiag(Found->getBeginLoc(),
5388 static bool CheckLocalVariableDeclaration(EvalInfo &Info, const VarDecl *VD) {
5394 !VD->isUsableInConstantExpressions(Info.Ctx)) {
5395 Info.CCEDiag(VD->getLocation(), diag::note_constexpr_static_local)
5403 static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
5405 if (!Info.nextStep(S))
5434 BlockScopeRAII Scope(Info);
5439 EvalStmtResult ESR = EvaluateStmt(Result, Info, Init, Case);
5451 EvalStmtResult ESR = EvaluateStmt(Result, Info, IS->getThen(), Case);
5459 ESR = EvaluateStmt(Result, Info, IS->getElse(), Case);
5469 EvaluateLoopBody(Result, Info, cast<WhileStmt>(S)->getBody(), Case);
5477 BlockScopeRAII Scope(Info);
5482 EvalStmtResult ESR = EvaluateStmt(Result, Info, Init, Case);
5490 EvaluateLoopBody(Result, Info, FS->getBody(), Case);
5495 if (!EvaluateDependentExpr(Inc, Info))
5498 FullExpressionRAII IncScope(Info);
5499 if (!EvaluateIgnoredValue(Info, Inc) || !IncScope.destroy())
5512 if (!CheckLocalVariableDeclaration(Info, VD))
5515 if (!EvaluateVarDecl(Info, VD))
5534 if (!EvaluateDependentExpr(E, Info))
5541 FullExpressionRAII Scope(Info);
5542 if (!EvaluateIgnoredValue(Info, E) || !Scope.destroy())
5548 Info.FFDiag(S->getBeginLoc()) << S->getSourceRange();
5558 if (VD && !CheckLocalVariableDeclaration(Info, VD))
5561 FullExpressionRAII Scope(Info);
5562 if (!EvaluateDecl(Info, D) && !Info.noteFailure())
5572 FullExpressionRAII Scope(Info);
5574 EvaluateDependentExpr(RetExpr, Info);
5580 ? EvaluateInPlace(Result.Value, Info, *Result.Slot, RetExpr)
5581 : Evaluate(Result.Value, Info, RetExpr)))
5587 BlockScopeRAII Scope(Info);
5591 EvalStmtResult ESR = EvaluateStmt(Result, Info, BI, Case);
5609 BlockScopeRAII Scope(Info);
5611 EvalStmtResult ESR = EvaluateStmt(Result, Info, Init);
5623 if (!Info.InConstantContext)
5625 } else if (!EvaluateCond(Info, IS->getConditionVariable(), IS->getCond(),
5630 EvalStmtResult ESR = EvaluateStmt(Result, Info, SubStmt);
5643 BlockScopeRAII Scope(Info);
5645 if (!EvaluateCond(Info, WS->getConditionVariable(), WS->getCond(),
5651 EvalStmtResult ESR = EvaluateLoopBody(Result, Info, WS->getBody());
5667 EvalStmtResult ESR = EvaluateLoopBody(Result, Info, DS->getBody(), Case);
5673 EvaluateDependentExpr(DS->getCond(), Info);
5677 FullExpressionRAII CondScope(Info);
5678 if (!EvaluateAsBooleanCondition(DS->getCond(), Continue, Info) ||
5687 BlockScopeRAII ForScope(Info);
5689 EvalStmtResult ESR = EvaluateStmt(Result, Info, FS->getInit());
5697 BlockScopeRAII IterScope(Info);
5699 if (FS->getCond() && !EvaluateCond(Info, FS->getConditionVariable(),
5705 EvalStmtResult ESR = EvaluateLoopBody(Result, Info, FS->getBody());
5714 if (!EvaluateDependentExpr(Inc, Info))
5717 FullExpressionRAII IncScope(Info);
5718 if (!EvaluateIgnoredValue(Info, Inc) || !IncScope.destroy())
5731 BlockScopeRAII Scope(Info);
5735 EvalStmtResult ESR = EvaluateStmt(Result, Info, FS->getInit());
5744 EvalStmtResult ESR = EvaluateStmt(Result, Info, FS->getRangeStmt());
5757 ESR = EvaluateStmt(Result, Info, FS->getBeginStmt());
5763 ESR = EvaluateStmt(Result, Info, FS->getEndStmt());
5774 EvaluateDependentExpr(FS->getCond(), Info);
5779 FullExpressionRAII CondExpr(Info);
5780 if (!EvaluateAsBooleanCondition(FS->getCond(), Continue, Info))
5787 BlockScopeRAII InnerScope(Info);
5788 ESR = EvaluateStmt(Result, Info, FS->getLoopVarStmt());
5796 ESR = EvaluateLoopBody(Result, Info, FS->getBody());
5803 if (!EvaluateDependentExpr(FS->getInc(), Info))
5807 if (!EvaluateIgnoredValue(Info, FS->getInc()))
5819 return EvaluateSwitch(Result, Info, cast<SwitchStmt>(S));
5828 return EvaluateStmt(Result, Info, cast<LabelStmt>(S)->getSubStmt(), Case);
5834 *Info.CurrentCall, hasSpecificAttr<MSConstexprAttr>(AS->getAttrs()) &&
5837 auto LO = Info.getASTContext().getLangOpts();
5848 if (Assumption->HasSideEffects(Info.getASTContext()))
5852 if (!EvaluateAsBooleanCondition(Assumption, Value, Info))
5855 Info.CCEDiag(Assumption->getExprLoc(),
5862 return EvaluateStmt(Result, Info, SS, Case);
5867 return EvaluateStmt(Result, Info, cast<SwitchCase>(S)->getSubStmt(), Case);
5870 return EvaluateStmt(Result, Info, cast<CXXTryStmt>(S)->getTryBlock(), Case);
5878 static bool CheckTrivialDefaultConstructor(EvalInfo &Info, SourceLocation Loc,
5888 if (Info.getLangOpts().CPlusPlus11) {
5891 Info.CCEDiag(Loc, diag::note_constexpr_invalid_function, 1)
5893 Info.Note(CD->getLocation(), diag::note_declared_at);
5895 Info.CCEDiag(Loc, diag::note_invalid_subexpr_in_const_expr);
5903 static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc,
5909 if (Info.checkingPotentialConstantExpression() && !Definition &&
5917 Info.FFDiag(CallLoc, diag::note_invalid_subexpr_in_const_expr);
5924 if (!Info.Ctx.getLangOpts().CPlusPlus20 && isa<CXXMethodDecl>(Declaration) &&
5926 Info.CCEDiag(CallLoc, diag::note_constexpr_virtual_call);
5929 Info.FFDiag(CallLoc, diag::note_invalid_subexpr_in_const_expr);
5935 (Definition->isConstexpr() || (Info.CurrentCall->CanEvalMSConstexpr &&
5939 if (Info.getLangOpts().CPlusPlus11) {
5955 Info.FFDiag(CallLoc, diag::note_constexpr_invalid_inhctor, 1)
5958 Info.FFDiag(CallLoc, diag::note_constexpr_invalid_function, 1)
5960 Info.Note(DiagDecl->getLocation(), diag::note_declared_at);
5962 Info.FFDiag(CallLoc, diag::note_invalid_subexpr_in_const_expr);
5980 static bool checkDynamicType(EvalInfo &Info, const Expr *E, const LValue &This,
5994 CompleteObject Obj = findCompleteObject(Info, E, AK, This, QualType());
6005 Info.FFDiag(E, This.Designator.isOnePastTheEnd()
6016 Info.Ctx.getLValueReferenceType(This.Designator.getType(Info.Ctx));
6017 Info.FFDiag(E, diag::note_constexpr_polymorphic_unknown_dynamic_type)
6018 << AK << Val.getAsString(Info.Ctx, StarThisType);
6025 return Obj && findSubobject(Info, E, Obj, This.Designator, Handler);
6031 checkNonVirtualMemberCallThisPointer(EvalInfo &Info, const Expr *E,
6035 Info, E, This,
6056 static std::optional<DynamicType> ComputeDynamicType(EvalInfo &Info,
6063 if (!checkDynamicType(Info, E, This, AK,
6081 Info.FFDiag(E);
6092 switch (Info.isEvaluatingCtorDtor(This.getLValueBase(),
6114 Info.FFDiag(E);
6120 EvalInfo &Info, const Expr *E, LValue &This, const CXXMethodDecl *Found,
6123 Info, E, This,
6148 Info.FFDiag(E, diag::note_constexpr_pure_virtual_call, 1) << Callee;
6149 Info.Note(Callee->getLocation(), diag::note_declared_at);
6155 if (!Info.Ctx.hasSameUnqualifiedType(Callee->getReturnType(),
6165 if (Next && !Info.Ctx.hasSameUnqualifiedType(
6169 if (!Info.Ctx.hasSameUnqualifiedType(Found->getReturnType(),
6175 if (!CastToDerivedClass(Info, E, This, Callee->getParent(), PathLength))
6184 static bool HandleCovariantReturnAdjustment(EvalInfo &Info, const Expr *E,
6193 LVal.setFrom(Info.Ctx, Result);
6200 !CastToBaseClass(Info, E, LVal, OldClass, NewClass))
6225 static bool HandleDynamicCast(EvalInfo &Info, const ExplicitCastExpr *E,
6241 ComputeDynamicType(Info, E, Ptr, AK_DynamicCast);
6249 return CastToDerivedClass(Info, E, Ptr, DynType->Type, DynType->PathLength);
6253 CanQualType CQT = Info.Ctx.getCanonicalType(Info.Ctx.getRecordType(C));
6260 Ptr.setNull(Info.Ctx, E->getType());
6277 Info.FFDiag(E, diag::note_constexpr_dynamic_cast_to_reference_failed)
6278 << DiagKind << Ptr.Designator.getType(Info.Ctx)
6279 << Info.Ctx.getRecordType(DynType->Type)
6291 return CastToDerivedClass(Info, E, Ptr, Class, PathLength);
6306 if (!CastToDerivedClass(Info, E, Ptr, DynType->Type, DynType->PathLength))
6310 if (!HandleLValueBase(Info, E, Ptr, Elem.Class, Elem.Base))
6321 EvalInfo &Info;
6349 Info.FFDiag(LHSExpr,
6373 static bool MaybeHandleUnionActiveMemberChange(EvalInfo &Info,
6456 findCompleteObject(Info, LHSExpr, AK_Assign, LHS, LHSExpr->getType());
6463 D.truncate(Info.Ctx, LHS.Base, LengthAndField.first);
6465 bool DuringInit = Info.isEvaluatingCtorDtor(LHS.Base, D.Entries) ==
6468 Info, LHSExpr, LengthAndField.second, DuringInit};
6469 if (!findSubobject(Info, LHSExpr, Obj, D, StartLifetime))
6477 CallRef Call, EvalInfo &Info,
6485 APValue &V = PVD ? Info.CurrentCall->createParam(Call, PVD, LV)
6486 : Info.CurrentCall->createTemporary(Arg, Arg->getType(),
6488 if (!EvaluateInPlace(V, Info, LV, Arg))
6494 Info.CCEDiag(Arg, diag::note_non_null_attribute_failed);
6503 EvalInfo &Info, const FunctionDecl *Callee,
6527 if (!EvaluateCallArg(PVD, Args[Idx], Call, Info, NonNull)) {
6530 if (!Info.noteFailure())
6540 static bool handleTrivialCopy(EvalInfo &Info, const ParmVarDecl *Param,
6544 CallStackFrame *Frame = Info.CurrentCall;
6545 APValue *RefValue = Info.getParamSlot(Frame->Arguments, Param);
6547 Info.FFDiag(E);
6553 RefLValue.setFrom(Info.Ctx, *RefValue);
6555 Info, E, Param->getType().getNonReferenceType(), RefLValue, Result,
6563 CallRef Call, const Stmt *Body, EvalInfo &Info,
6565 if (!Info.CheckCallLimit(CallLoc))
6568 CallStackFrame Frame(Info, E->getSourceRange(), Callee, This, E, Call);
6584 if (!handleTrivialCopy(Info, MD->getParamDecl(0), Args[0], RHSValue,
6587 if (!handleAssignment(Info, Args[0], *This, MD->getThisType(),
6599 if (!Info.checkingPotentialConstantExpression())
6605 EvalStmtResult ESR = EvaluateStmt(Ret, Info, Body);
6609 Info.FFDiag(Callee->getEndLoc(), diag::note_constexpr_no_return);
6618 EvalInfo &Info, APValue &Result) {
6620 if (!Info.CheckCallLimit(CallLoc))
6625 Info.FFDiag(CallLoc, diag::note_constexpr_virtual_base) << RD;
6630 Info,
6633 CallStackFrame Frame(Info, E->getSourceRange(), Definition, &This, E, Call);
6644 if (!EvaluateDependentExpr((*I)->getInit(), Info))
6647 FullExpressionRAII InitScope(Info);
6648 if (!EvaluateInPlace(Result, Info, This, (*I)->getInit()) ||
6652 return EvaluateStmt(Ret, Info, Definition->getBody()) != ESR_Failed;
6667 return handleTrivialCopy(Info, Definition->getParamDecl(0), E, Result,
6682 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
6685 BlockScopeRAII LifetimeExtendedScope(Info);
6725 assert(Info.Ctx.hasSameUnqualifiedType(BaseIt->getType(), BaseType) &&
6729 if (!HandleLValueDirectBase(Info, I->getInit(), Subobject, RD,
6734 if (!HandleLValueMember(Info, I->getInit(), Subobject, FD, &Layout))
6764 handleDefaultInitValue(Info.Ctx.getRecordType(CD), *Value);
6770 if (!HandleLValueMember(Info, I->getInit(), Subobject, FD))
6789 if (!EvaluateDependentExpr(Init, Info))
6792 ThisOverrideRAII ThisOverride(*Info.CurrentCall, &SubobjectParent,
6794 FullExpressionRAII InitScope(Info);
6795 if (!EvaluateInPlace(*Value, Info, Subobject, Init) ||
6797 !truncateBitfieldValue(Info, Init, *Value, FD))) {
6800 if (!Info.noteFailure())
6825 EvaluateStmt(Ret, Info, Definition->getBody()) != ESR_Failed &&
6832 EvalInfo &Info, APValue &Result) {
6833 CallScopeRAII CallScope(Info);
6834 CallRef Call = Info.CurrentCall->createCall(Definition);
6835 if (!EvaluateArgs(Args, Call, Info, Definition))
6838 return HandleConstructorCall(E, This, Call, Definition, Info, Result) &&
6842 static bool HandleDestructionImpl(EvalInfo &Info, SourceRange CallRange,
6852 Info.FFDiag(CallRange.getBegin(),
6854 << Printable.getAsString(Info.Ctx, Info.Ctx.getLValueReferenceType(T));
6860 OpaqueValueExpr LocE(CallRange.getBegin(), Info.Ctx.IntTy, VK_PRValue);
6863 if (const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(T)) {
6867 if (!CheckArraySize(Info, CAT, CallRange.getBegin()))
6871 ElemLV.addArray(Info, &LocE, CAT);
6872 if (!HandleLValueArrayAdjustment(Info, &LocE, ElemLV, ElemT, Size))
6885 if (!HandleLValueArrayAdjustment(Info, &LocE, ElemLV, ElemT, -1) ||
6886 !HandleDestructionImpl(Info, CallRange, ElemLV, Elem, ElemT))
6898 Info.FFDiag(CallRange.getBegin(),
6909 Info.FFDiag(CallRange.getBegin(), diag::note_constexpr_virtual_base) << RD;
6915 Info.FFDiag(CallRange.getBegin());
6934 if (!Info.CheckCallLimit(CallRange.getBegin()))
6940 if (!CheckConstexprFunction(Info, CallRange.getBegin(), DD, Definition, Body))
6943 CallStackFrame Frame(Info, CallRange, Definition, &This, /*CallExpr=*/nullptr,
6949 Info,
6958 Info.FFDiag(CallRange.getBegin(), diag::note_constexpr_double_destroy);
6966 if (EvaluateStmt(Ret, Info, Definition->getBody()) == ESR_Failed)
6973 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
6983 if (!HandleLValueMember(Info, &LocE, Subobject, FD, &Layout))
6987 if (!HandleDestructionImpl(Info, CallRange, Subobject, *SubobjectValue,
7001 if (!HandleLValueDirectBase(Info, &LocE, Subobject, RD,
7006 if (!HandleDestructionImpl(Info, CallRange, Subobject, *SubobjectValue,
7019 EvalInfo &Info;
7027 return HandleDestructionImpl(Info, E->getSourceRange(), This, Subobj,
7031 Info.FFDiag(E, diag::note_constexpr_destroy_complex_elem);
7035 Info.FFDiag(E, diag::note_constexpr_destroy_complex_elem);
7043 static bool HandleDestruction(EvalInfo &Info, const Expr *E,
7045 CompleteObject Obj = findCompleteObject(Info, E, AK_Destroy, This, ThisType);
7046 DestroyObjectHandler Handler = {Info, E, This, AK_Destroy};
7047 return Obj && findSubobject(Info, E, Obj, This.Designator, Handler);
7051 static bool HandleDestruction(EvalInfo &Info, SourceLocation Loc,
7056 if (Info.EvalStatus.HasSideEffects)
7061 return HandleDestructionImpl(Info, Loc, LV, Value, T);
7065 static bool HandleOperatorNewCall(EvalInfo &Info, const CallExpr *E,
7067 if (Info.checkingPotentialConstantExpression() ||
7068 Info.SpeculativeEvaluationDepth)
7072 auto Caller = Info.getStdAllocatorCaller("allocate");
7074 Info.FFDiag(E->getExprLoc(), Info.getLangOpts().CPlusPlus20
7082 Info.FFDiag(E->getExprLoc(),
7089 if (!EvaluateInteger(E->getArg(0), ByteSize, Info))
7093 EvaluateIgnoredValue(Info, E->getArg(I));
7098 if (!HandleSizeof(Info, E->getExprLoc(), ElemType, ElemSize))
7105 Info.FFDiag(E->getExprLoc(), diag::note_constexpr_operator_new_bad_size)
7110 if (!Info.CheckArraySize(E->getBeginLoc(), ByteSize.getActiveBits(),
7113 Result.setNull(Info.Ctx, E->getType());
7119 QualType AllocType = Info.Ctx.getConstantArrayType(
7121 APValue *Val = Info.createHeapAlloc(Caller.Call, AllocType, Result);
7123 Result.addArray(Info, E, cast<ConstantArrayType>(AllocType));
7146 static std::optional<DynAlloc *> CheckDeleteKind(EvalInfo &Info, const Expr *E,
7150 return Pointer.toString(Info.Ctx, Info.Ctx.VoidPtrTy);
7155 Info.FFDiag(E, diag::note_constexpr_delete_not_heap_alloc)
7158 NoteLValueLocation(Info, Pointer.Base);
7162 std::optional<DynAlloc *> Alloc = Info.lookupDynamicAlloc(DA);
7164 Info.FFDiag(E, diag::note_constexpr_double_delete);
7170 Info.FFDiag(E, diag::note_constexpr_new_delete_mismatch)
7172 NoteLValueLocation(Info, Pointer.Base);
7185 Info.FFDiag(E, diag::note_constexpr_delete_subobject)
7194 static bool HandleOperatorDeleteCall(EvalInfo &Info, const CallExpr *E) {
7195 if (Info.checkingPotentialConstantExpression() ||
7196 Info.SpeculativeEvaluationDepth)
7200 if (!Info.getStdAllocatorCaller("deallocate")) {
7201 Info.FFDiag(E->getExprLoc());
7206 if (!EvaluatePointer(E->getArg(0), Pointer, Info))
7209 EvaluateIgnoredValue(Info, E->getArg(I));
7217 Info.CCEDiag(E->getExprLoc(), diag::note_constexpr_deallocate_null);
7221 if (!CheckDeleteKind(Info, E, Pointer, DynAlloc::StdAllocator))
7224 Info.HeapAllocs.erase(Pointer.Base.get<DynamicAllocLValue>());
7283 EvalInfo &Info;
7287 APValueToBufferConverter(EvalInfo &Info, CharUnits ObjectWidth,
7289 : Info(Info),
7290 Buffer(ObjectWidth, Info.Ctx.getTargetInfo().isLittleEndian()),
7331 Info.FFDiag(BCE->getBeginLoc(),
7345 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
7363 Info.FFDiag(BCE->getBeginLoc(),
7370 assert(FieldOffsetBits % Info.Ctx.getCharWidth() == 0 &&
7373 Info.Ctx.toCharUnitsFromBits(FieldOffsetBits) + Offset;
7389 CharUnits ElemWidth = Info.Ctx.getTypeSizeInChars(CAT->getElementType());
7414 CharUnits EltSizeChars = Info.Ctx.getTypeSizeInChars(EltTy);
7450 bool BigEndian = Info.Ctx.getTargetInfo().isBigEndian();
7467 CharUnits EltSizeChars = Info.Ctx.getTypeSizeInChars(EltTy);
7481 Width = Info.Ctx.getTypeSize(Ty);
7498 convert(EvalInfo &Info, const APValue &Src, const CastExpr *BCE) {
7499 CharUnits DstSize = Info.Ctx.getTypeSizeInChars(BCE->getType());
7500 APValueToBufferConverter Converter(Info, DstSize, BCE);
7509 EvalInfo &Info;
7513 BufferToAPValueConverter(EvalInfo &Info, const BitCastBuffer &Buffer,
7515 : Info(Info), Buffer(Buffer), BCE(BCE) {}
7521 Info.FFDiag(BCE->getBeginLoc(),
7528 Info.FFDiag(BCE->getBeginLoc(),
7537 uint64_t NullValue = Info.Ctx.getTargetNullPointerValue(QualType(T, 0));
7543 CharUnits SizeOf = Info.Ctx.getTypeSizeInChars(T);
7550 Info.Ctx.getFloatTypeSemantics(QualType(T, 0));
7568 Info.FFDiag(BCE->getExprLoc(),
7570 << DisplayType << Info.Ctx.getLangOpts().CharIsSigned;
7577 APSInt Val(SizeOf.getQuantity() * Info.Ctx.getCharWidth(), true);
7583 unsigned IntWidth = Info.Ctx.getIntWidth(QualType(T, 0));
7596 Info.Ctx.getFloatTypeSemantics(QualType(T, 0));
7605 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
7634 Info.FFDiag(BCE->getBeginLoc(),
7640 assert(FieldOffsetBits % Info.Ctx.getCharWidth() == 0);
7643 CharUnits::fromQuantity(FieldOffsetBits / Info.Ctx.getCharWidth()) +
7669 CharUnits ElementWidth = Info.Ctx.getTypeSizeInChars(Ty->getElementType());
7685 CharUnits ElementWidth = Info.Ctx.getTypeSizeInChars(ElementType);
7704 VTy->isExtVectorBoolType() ? 1 : Info.Ctx.getTypeSize(EltTy);
7717 bool BigEndian = Info.Ctx.getTargetInfo().isBigEndian();
7736 CharUnits EltSizeChars = Info.Ctx.getTypeSizeInChars(EltTy);
7778 static std::optional<APValue> convert(EvalInfo &Info, BitCastBuffer &Buffer,
7780 BufferToAPValueConverter Converter(Info, Buffer, BCE);
7786 QualType Ty, EvalInfo *Info,
7792 if (Info)
7793 Info->FFDiag(Loc, diag::note_constexpr_bit_cast_invalid_type)
7798 if (Info)
7799 Info->Note(NoteLoc, diag::note_constexpr_bit_cast_invalid_subtype)
7816 if (!checkBitCastConstexprEligibilityType(Loc, BS.getType(), Info, Ctx,
7823 if (!checkBitCastConstexprEligibilityType(Loc, FD->getType(), Info, Ctx,
7831 Info, Ctx, CheckingDest))
7844 Info->FFDiag(Loc, diag::note_constexpr_bit_cast_invalid_vector)
7854 Info->FFDiag(Loc, diag::note_constexpr_bit_cast_unsupported_type)
7863 static bool checkBitCastConstexprEligibility(EvalInfo *Info,
7867 BCE->getBeginLoc(), BCE->getType(), Info, Ctx, true);
7870 BCE->getSubExpr()->getType(), Info, Ctx, false);
7874 static bool handleRValueToRValueBitCast(EvalInfo &Info, APValue &DestValue,
7877 assert(CHAR_BIT == 8 && Info.Ctx.getTargetInfo().getCharWidth() == 8 &&
7880 if (!checkBitCastConstexprEligibility(&Info, Info.Ctx, BCE))
7885 APValueToBufferConverter::convert(Info, SourceRValue, BCE);
7891 BufferToAPValueConverter::convert(Info, *Buffer, BCE);
7899 static bool handleLValueToRValueBitCast(EvalInfo &Info, APValue &DestValue,
7902 assert(CHAR_BIT == 8 && Info.Ctx.getTargetInfo().getCharWidth() == 8 &&
7909 SourceLValue.setFrom(Info.Ctx, SourceValue);
7911 Info, BCE, BCE->getSubExpr()->getType().withConst(), SourceLValue,
7915 return handleRValueToRValueBitCast(Info, DestValue, SourceRValue, BCE);
7935 assert(Info.checkingPotentialConstantExpression());
7940 SpeculativeEvaluationRAII Speculate(Info, &Diag);
7947 SpeculativeEvaluationRAII Speculate(Info, &Diag);
7961 if (!EvaluateAsBooleanCondition(E->getCond(), BoolResult, Info)) {
7962 if (Info.checkingPotentialConstantExpression() && Info.noteFailure()) {
7966 if (Info.noteFailure()) {
7978 EvalInfo &Info;
7983 return Info.CCEDiag(E, D);
7991 Info.Ctx.BuiltinInfo.isConstantEvaluated(BuiltinOp);
7995 ExprEvaluatorBase(EvalInfo &Info) : Info(Info) {}
7997 EvalInfo &getEvalInfo() { return Info; }
8002 Info.FFDiag(E, D) << E->getSourceRange();
8044 TempVersionRAII RAII(*Info.CurrentCall);
8045 SourceLocExprScopeGuard Guard(E, Info.CurrentCall->CurSourceLocExprScope);
8049 TempVersionRAII RAII(*Info.CurrentCall);
8053 SourceLocExprScopeGuard Guard(E, Info.CurrentCall->CurSourceLocExprScope);
8058 FullExpressionRAII Scope(Info);
8073 if (!Info.Ctx.getLangOpts().CPlusPlus20)
8093 if (!HandleMemberPointerAccess(Info, E, Obj))
8096 if (!handleLValueToRValueConversion(Info, E, E->getType(), Obj, Result))
8111 if (!Evaluate(Info.CurrentCall->createTemporary(
8113 getStorageType(Info.Ctx, E->getOpaqueValue()),
8115 Info, E->getCommon()))
8136 if (Info.checkingPotentialConstantExpression() && IsBcpCall)
8139 FoldConstant Fold(Info, IsBcpCall);
8149 if (APValue *Value = Info.CurrentCall->getCurrentTemporary(E);
8178 if (!Evaluate(Info.CurrentCall->createTemporary(
8179 OVE, getStorageType(Info.Ctx, OVE),
8181 Info, OVE->getSourceExpr()))
8187 if (!EvaluateIgnoredValue(Info, SemE))
8203 CallScopeRAII CallScope(Info);
8220 if (!EvaluateObjectArgument(Info, ME->getBase(), ThisVal))
8230 HandleMemberPointerAccess(Info, BE, ThisVal, false);
8238 if (!Info.getLangOpts().CPlusPlus20)
8239 Info.CCEDiag(PDE, diag::note_constexpr_pseudo_destructor);
8240 return EvaluateObjectArgument(Info, PDE->getBase(), ThisVal) &&
8241 HandleDestruction(Info, PDE, ThisVal, PDE->getDestroyedType());
8247 if (!EvaluatePointer(Callee, CalleeLV, Info))
8253 Info.FFDiag(Callee, diag::note_constexpr_null_callee)
8263 if (!Info.Ctx.hasSameFunctionTypeIgnoringExceptionSpec(
8273 Call = Info.CurrentCall->createCall(FD);
8277 if (!EvaluateArgs(HasThis ? Args.slice(1) : Args, Call, Info, FD,
8293 if (!EvaluateObjectArgument(Info, Args[0], ThisVal))
8304 if (Info.getLangOpts().CPlusPlus20 && OCE &&
8306 !MaybeHandleUnionActiveMemberChange(Info, Args[0], ThisVal))
8348 if (!HandleOperatorNewCall(Info, E, Ptr))
8353 return HandleOperatorDeleteCall(Info, E) && CallScope.destroy();
8361 Call = Info.CurrentCall->createCall(FD);
8362 if (!EvaluateArgs(Args, Call, Info, FD))
8371 FD = HandleVirtualDispatch(Info, E, *This, NamedMember,
8379 if (!checkNonVirtualMemberCallThisPointer(Info, E, *This, NamedMember))
8387 return HandleDestruction(Info, E, *This,
8388 Info.Ctx.getRecordType(DD->getParent())) &&
8395 if (!CheckConstexprFunction(Info, E->getExprLoc(), FD, Definition, Body) ||
8397 Body, Info, Result, ResultSlot))
8401 !HandleCovariantReturnAdjustment(Info, E, Result,
8430 assert(!Info.Ctx.getLangOpts().CPlusPlus11 &&
8435 if (!Evaluate(Val, Info, E->getBase()))
8454 return extractSubobject(Info, E, Obj, Designator, Result) &&
8460 if (!Evaluate(Val, Info, E->getBase()))
8493 if (!Evaluate(AtomicVal, Info, E->getSubExpr()))
8504 if (!EvaluateLValue(E->getSubExpr(), LVal, Info))
8508 if (!handleLValueToRValueConversion(Info, E, E->getSubExpr()->getType(),
8515 if (!Evaluate(SourceValue, Info, E->getSubExpr()))
8517 if (!handleLValueToRValueBitCast(Info, DestValue, SourceValue, E))
8524 if (!Evaluate(Value, Info, E->getSubExpr()))
8540 if (!Info.getLangOpts().CPlusPlus14 && !Info.keepEvaluatingAfterFailure())
8544 if (!EvaluateLValue(UO->getSubExpr(), LVal, Info))
8547 if (!handleIncDec(this->Info, UO, LVal, UO->getSubExpr()->getType(),
8556 llvm::SaveAndRestore NotCheckingForUB(Info.CheckingForUndefinedBehavior,
8563 BlockScopeRAII Scope(Info);
8570 Info.FFDiag((*BI)->getBeginLoc(),
8579 EvalStmtResult ESR = EvaluateStmt(Result, Info, *BI);
8585 Info.FFDiag((*BI)->getBeginLoc(),
8600 EvaluateIgnoredValue(Info, E);
8607 if (Info.getLangOpts().MSVCCompat && !E->HasSideEffects(Info.Ctx))
8634 return EvaluatePointer(E, Result, this->Info, InvalidBaseOK);
8638 LValueExprEvaluatorBase(EvalInfo &Info, LValue &Result, bool InvalidBaseOK)
8639 : ExprEvaluatorBaseTy(Info), Result(Result),
8643 Result.setFrom(this->Info.Ctx, V);
8656 EvalOK = EvaluateTemporary(E->getBase(), Result, this->Info);
8674 if (!HandleLValueMember(this->Info, E, Result, FD))
8677 if (!HandleLValueIndirectMember(this->Info, E, Result, IFD))
8684 if (!handleLValueToRValueConversion(this->Info, E, MD->getType(), Result,
8699 return HandleMemberPointerAccess(this->Info, E, Result);
8715 return HandleLValueBasePath(this->Info, E, E->getSubExpr()->getType(),
8759 LValueExprEvaluator(EvalInfo &Info, LValue &Result, bool InvalidBaseOK) :
8760 LValueExprEvaluatorBaseTy(Info, Result, InvalidBaseOK) {}
8773 E, 0, Info.getASTContext().getNextStringLiteralVersion()));
8799 << 2 << Info.Ctx.getLangOpts().CPlusPlus;
8808 return HandleBaseToDerivedCast(Info, E, Result);
8813 return HandleDynamicCast(Info, cast<ExplicitCastExpr>(E), Result);
8820 static bool HandleLambdaCapture(EvalInfo &Info, const Expr *E, LValue &Result,
8826 assert(Info.CurrentCall->This == nullptr &&
8836 APValue *RefValue = Info.getParamSlot(Info.CurrentCall->Arguments, Self);
8838 Result.setFrom(Info.Ctx, *RefValue);
8840 const ParmVarDecl *VD = Info.CurrentCall->Arguments.getOrigParam(Self);
8842 Info.getCallFrameAndDepth(Info.CurrentCall->Arguments.CallIndex)
8844 unsigned Version = Info.CurrentCall->Arguments.Version;
8848 Result = *Info.CurrentCall->This;
8852 if (!HandleLValueMember(Info, E, Result, FD))
8860 if (!handleLValueToRValueConversion(Info, E, FD->getType(), Result, RVal))
8862 Result.setFrom(Info.Ctx, RVal);
8872 static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
8877 return LValueExprEvaluator(Info, Result, InvalidBaseOK).Visit(E);
8897 Info.getLangOpts().CPlusPlus23 && VD->getType()->isReferenceType();
8902 if (Info.CurrentCall && isLambdaCallOperator(Info.CurrentCall->Callee) &&
8909 if (Info.checkingPotentialConstantExpression())
8912 if (auto *FD = Info.CurrentCall->LambdaCaptureFields.lookup(VD)) {
8913 const auto *MD = cast<CXXMethodDecl>(Info.CurrentCall->Callee);
8914 return HandleLambdaCapture(Info, E, Result, MD, FD,
8928 CallStackFrame *CurrFrame = Info.CurrentCall;
8937 Info.getCallFrameAndDepth(CurrFrame->Arguments.CallIndex).first;
8955 if (!Info.getLangOpts().CPlusPlus11) {
8956 Info.CCEDiag(E, diag::note_constexpr_ltor_non_integral, 1)
8958 Info.Note(VD->getLocation(), diag::note_declared_at);
8962 if (!evaluateVarDeclInit(Info, E, VD, Frame, Version, V))
8970 if (!Info.checkingPotentialConstantExpression() && !AllowConstexprUnknown)
8971 Info.FFDiag(E, diag::note_constexpr_use_uninit_reference);
9018 if (!EvaluateIgnoredValue(Info, E))
9026 if (Info.EvalMode == EvalInfo::EM_ConstantFold)
9033 Value = &Info.CurrentCall->createTemporary(
9043 if (!EvaluateInPlace(*Value, Info, Result, Inner)) {
9053 if (!HandleLValueBasePath(Info, Adjustments[I].DerivedToBase.BasePath,
9060 if (!HandleLValueMember(Info, E, Result, Adjustments[I].Field))
9066 if (!HandleMemberPointerAccess(this->Info, Type, Result,
9079 assert((!Info.getLangOpts().CPlusPlus || E->isFileScope()) &&
9091 TypeInfo = TypeInfoLValue(E->getTypeOperand(Info.Ctx).getTypePtr());
9095 if (!Info.Ctx.getLangOpts().CPlusPlus20) {
9096 Info.CCEDiag(E, diag::note_constexpr_typeid_polymorphic)
9105 ComputeDynamicType(Info, E, Result, AK_TypeId);
9110 TypeInfoLValue(Info.Ctx.getRecordType(DynType->Type).getTypePtr());
9144 if (!Evaluate(Val, Info, E->getBase())) {
9145 if (!Info.noteFailure())
9157 Result.setFrom(Info.Ctx, Val);
9159 HandleLValueVectorElement(Info, E, Result, VT->getElementType(),
9175 if (!Evaluate(Val, Info, E->getBase())) {
9176 if (!Info.noteFailure())
9181 if (!EvaluateInteger(E->getIdx(), Index, Info)) {
9182 if (!Info.noteFailure())
9188 Result.setFrom(Info.Ctx, Val);
9189 HandleLValueVectorElement(Info, E, Result, VT->getElementType(),
9200 : !EvaluateInteger(SubExpr, Index, Info)) {
9201 if (!Info.noteFailure())
9208 HandleLValueArrayAdjustment(Info, E, Result, E->getType(), Index);
9220 HandleLValueComplexElement(Info, E, Result, E->getType(), false);
9229 HandleLValueComplexElement(Info, E, Result, E->getType(), true);
9234 if (!Info.getLangOpts().CPlusPlus14 && !Info.keepEvaluatingAfterFailure())
9241 this->Info, UO, Result, UO->getSubExpr()->getType(),
9247 if (!Info.getLangOpts().CPlusPlus14 && !Info.keepEvaluatingAfterFailure())
9254 if (!Evaluate(RHS, this->Info, CAO->getRHS())) {
9255 if (!Info.noteFailure())
9265 this->Info, CAO,
9271 if (!Info.getLangOpts().CPlusPlus14 && !Info.keepEvaluatingAfterFailure())
9278 if (!Evaluate(NewVal, this->Info, E->getRHS())) {
9279 if (!Info.noteFailure())
9287 if (Info.getLangOpts().CPlusPlus20 &&
9288 !MaybeHandleUnionActiveMemberChange(Info, E->getLHS(), Result))
9291 return handleAssignment(this->Info, E, Result, E->getLHS()->getType(),
9366 static bool evaluateLValueAsAllocSize(EvalInfo &Info, APValue::LValueBase Base,
9394 Result.addUnsizedArray(Info, E, Pointee);
9410 return EvaluateLValue(E, Result, Info, InvalidBaseOK);
9414 return EvaluatePointer(E, Result, Info, InvalidBaseOK);
9420 PointerExprEvaluator(EvalInfo &info, LValue &Result, bool InvalidBaseOK)
9421 : ExprEvaluatorBaseTy(info), Result(Result),
9425 Result.setFrom(Info.Ctx, V);
9429 Result.setNull(Info.Ctx, E->getType());
9441 if (Info.noteFailure())
9442 EvaluateIgnoredValue(Info, E->getSubExpr());
9456 if (Info.getLangOpts().CPlusPlus11)
9457 Info.FFDiag(E, diag::note_constexpr_this) << E->isImplicit();
9459 Info.FFDiag(E);
9463 if (Info.checkingPotentialConstantExpression())
9467 isLambdaCallWithExplicitObjectParameter(Info.CurrentCall->Callee);
9469 if (!Info.CurrentCall->This) {
9474 Result = *Info.CurrentCall->This;
9477 if (isLambdaCallOperator(Info.CurrentCall->Callee)) {
9482 if (!Info.CurrentCall->LambdaThisCaptureField) {
9483 if (IsExplicitLambda && !Info.CurrentCall->This) {
9491 const auto *MD = cast<CXXMethodDecl>(Info.CurrentCall->Callee);
9493 Info, E, Result, MD, Info.CurrentCall->LambdaThisCaptureField,
9494 Info.CurrentCall->LambdaThisCaptureField->getType()->isPointerType());
9504 Info.Ctx, Info.CurrentCall->CurSourceLocExprScope.getDefaultExpr());
9505 Result.setFrom(Info.Ctx, LValResult);
9515 std::string ResultStr = E->ComputeName(Info.Ctx);
9517 QualType CharTy = Info.Ctx.CharTy.withConst();
9518 APInt Size(Info.Ctx.getTypeSize(Info.Ctx.getSizeType()),
9520 QualType ArrayTy = Info.Ctx.getConstantArrayType(
9524 StringLiteral::Create(Info.Ctx, ResultStr, StringLiteralKind::Ordinary,
9528 Result.addArray(Info, E, cast<ConstantArrayType>(ArrayTy));
9536 static bool EvaluatePointer(const Expr* E, LValue& Result, EvalInfo &Info,
9540 return PointerExprEvaluator(Info, Result, InvalidBaseOK).Visit(E);
9554 if (!EvalPtrOK && !Info.noteFailure())
9558 if (!EvaluateInteger(IExp, Offset, Info) || !EvalPtrOK)
9565 return HandleLValueArrayAdjustment(Info, E, Result, Pointee, Offset);
9612 Info.Ctx.hasSimilarType(Result.Designator.getType(Info.Ctx),
9622 (Info.getStdAllocatorCaller("allocate") ||
9623 IsDeclSourceLocationCurrent(Info.CurrentCall->Callee) ||
9624 Info.getLangOpts().CPlusPlus26)) {
9628 Info.getLangOpts().CPlusPlus) {
9631 << SubExpr->getType() << Info.getLangOpts().CPlusPlus26
9632 << Result.Designator.getType(Info.Ctx).getCanonicalType()
9639 << 2 << Info.Ctx.getLangOpts().CPlusPlus;
9656 return HandleLValueBasePath(Info, E, E->getSubExpr()->getType()->
9665 return HandleBaseToDerivedCast(Info, E, Result);
9670 return HandleDynamicCast(Info, cast<ExplicitCastExpr>(E), Result);
9678 << 2 << Info.Ctx.getLangOpts().CPlusPlus;
9681 if (!EvaluateIntegerOrLValue(SubExpr, Value, Info))
9685 unsigned Size = Info.Ctx.getTypeSize(E->getType());
9702 Result.setFrom(Info.Ctx, Value);
9712 APValue &Value = Info.CurrentCall->createTemporary(
9714 if (!EvaluateInPlace(Value, Info, Result, SubExpr))
9718 auto *AT = Info.Ctx.getAsArrayType(SubExpr->getType());
9720 Result.addArray(Info, E, CAT);
9722 Result.addUnsizedArray(Info, E, AT->getElementType());
9736 if (!handleLValueToRValueConversion(Info, E, E->getSubExpr()->getType(),
9739 evaluateLValueAsAllocSize(Info, LVal.Base, Result);
9793 static CharUnits getBaseAlignment(EvalInfo &Info, const LValue &Value) {
9795 return Info.Ctx.getDeclAlign(VD);
9797 return GetAlignOfExpr(Info.Ctx, E, UETT_AlignOf);
9798 return GetAlignOfType(Info.Ctx, Value.Base.getTypeInfoType(), UETT_AlignOf);
9804 EvalInfo &Info, APSInt &Alignment) {
9805 if (!EvaluateInteger(E, Alignment, Info))
9808 Info.FFDiag(E, diag::note_constexpr_invalid_alignment) << Alignment;
9811 unsigned SrcWidth = Info.Ctx.getIntWidth(ForType);
9814 Info.FFDiag(E, diag::note_constexpr_alignment_too_big)
9839 Result.addUnsizedArray(Info, E, PointeeTy);
9874 if (!getAlignmentArgument(E->getArg(1), E->getArg(0)->getType(), Info,
9881 if (!EvaluateInteger(E->getArg(2), Offset, Info))
9890 CharUnits BaseAlignment = getBaseAlignment(Info, OffsetResult);
9921 if (!getAlignmentArgument(E->getArg(1), E->getArg(0)->getType(), Info,
9924 CharUnits BaseAlignment = getBaseAlignment(Info, Result);
9949 Info.FFDiag(E->getArg(0), diag::note_constexpr_alignment_adjust)
9954 return HandleOperatorNewCall(Info, E, Result);
9961 if (Info.getLangOpts().CPlusPlus11)
9962 Info.CCEDiag(E, diag::note_constexpr_invalid_function)
9964 << Info.Ctx.BuiltinInfo.getQuotedName(BuiltinOp);
9966 Info.CCEDiag(E, diag::note_invalid_subexpr_in_const_expr);
9976 if (!EvaluateInteger(E->getArg(1), Desired, Info))
9984 if (!EvaluateInteger(E->getArg(2), N, Info))
9991 if (!Result.checkNullPointerForFoldAccess(Info, E, AK_Read) ||
9994 QualType CharTy = Result.Designator.getType(Info.Ctx);
9998 Info.Ctx.hasSameUnqualifiedType(
10002 Info.FFDiag(E, diag::note_constexpr_ltor_incomplete_type) << CharTy;
10008 Info.FFDiag(E, diag::note_constexpr_memchr_unsupported)
10009 << Info.Ctx.BuiltinInfo.getQuotedName(BuiltinOp) << CharTy;
10021 if (!APSInt::isSameValue(HandleIntToIntCast(Info, E, CharTy,
10034 DesiredVal = Desired.trunc(Info.Ctx.getCharWidth()).getZExtValue();
10050 if (!handleLValueToRValueConversion(Info, E, CharTy, Result, Char) ||
10057 if (!HandleLValueArrayAdjustment(Info, E, Result, CharTy, 1))
10068 if (Info.getLangOpts().CPlusPlus11)
10069 Info.CCEDiag(E, diag::note_constexpr_invalid_function)
10071 << Info.Ctx.BuiltinInfo.getQuotedName(BuiltinOp);
10073 Info.CCEDiag(E, diag::note_invalid_subexpr_in_const_expr);
10094 if (!EvaluatePointer(E->getArg(1), Src, Info))
10098 if (!EvaluateInteger(E->getArg(2), N, Info))
10113 Info.FFDiag(E, diag::note_constexpr_memcpy_null)
10115 << Val.getAsString(Info.Ctx, E->getArg(0)->getType());
10124 QualType T = Dest.Designator.getType(Info.Ctx);
10125 QualType SrcT = Src.Designator.getType(Info.Ctx);
10126 if (!Info.Ctx.hasSameUnqualifiedType(T, SrcT)) {
10128 Info.FFDiag(E, diag::note_constexpr_memcpy_type_pun) << Move << SrcT << T;
10132 Info.FFDiag(E, diag::note_constexpr_memcpy_incomplete_type) << Move << T;
10135 if (!T.isTriviallyCopyableType(Info.Ctx)) {
10136 Info.FFDiag(E, diag::note_constexpr_memcpy_nontrivial) << Move << T;
10141 uint64_t TSize = Info.Ctx.getTypeSizeInChars(T).getQuantity();
10149 Info.FFDiag(E, diag::note_constexpr_memcpy_unsupported)
10162 Info.FFDiag(E, diag::note_constexpr_memcpy_unsupported)
10178 Info.FFDiag(E, diag::note_constexpr_memcpy_overlap) << WChar;
10182 if (!HandleLValueArrayAdjustment(Info, E, Src, T, NElems - 1) ||
10183 !HandleLValueArrayAdjustment(Info, E, Dest, T, NElems - 1))
10189 Info.FFDiag(E, diag::note_constexpr_memcpy_overlap) << WChar;
10198 if (!handleLValueToRValueConversion(Info, E, T, Src, Val) ||
10199 !handleAssignment(Info, E, Dest, T, Val))
10205 if (!HandleLValueArrayAdjustment(Info, E, Src, T, Direction) ||
10206 !HandleLValueArrayAdjustment(Info, E, Dest, T, Direction))
10216 static bool EvaluateArrayNewInitList(EvalInfo &Info, LValue &This,
10219 static bool EvaluateArrayNewConstructExpr(EvalInfo &Info, LValue &This,
10225 if (!Info.getLangOpts().CPlusPlus20)
10226 Info.CCEDiag(E, diag::note_constexpr_new);
10229 if (Info.SpeculativeEvaluationDepth)
10252 if (!EvaluateLValue(E->getPlacementArg(0), Nothrow, Info))
10256 if (Info.CurrentCall->isStdFunction() || Info.getLangOpts().CPlusPlus26 ||
10257 (Info.CurrentCall->CanEvalMSConstexpr &&
10259 if (!EvaluatePointer(E->getPlacementArg(0), Result, Info))
10266 Info.FFDiag(E, diag::note_constexpr_new_placement)
10271 Info.FFDiag(E, diag::note_constexpr_new_placement)
10275 Info.FFDiag(E, diag::note_constexpr_new_non_replaceable)
10294 if (!EvaluateInteger(Stripped, ArrayBound, Info))
10305 Info.FFDiag(*ArraySize, diag::note_constexpr_new_negative)
10312 if (!Info.CheckArraySize(ArraySize.value()->getExprLoc(),
10314 Info.Ctx, AllocType, ArrayBound),
10332 auto *CAT = Info.Ctx.getAsConstantArrayType(Init->getType());
10343 Info.FFDiag(*ArraySize, diag::note_constexpr_new_too_small)
10356 AllocType = Info.Ctx.getConstantArrayType(AllocType, ArrayBound, nullptr,
10367 EvalInfo &Info;
10385 !Info.Ctx.hasSimilarType(Info.Ctx.getBaseElementType(SubobjType),
10386 Info.Ctx.getBaseElementType(AllocType))) {
10387 Info.FFDiag(E, diag::note_constexpr_placement_new_wrong_type)
10395 Info.FFDiag(E, diag::note_constexpr_construct_complex_elem);
10399 Info.FFDiag(E, diag::note_constexpr_construct_complex_elem);
10402 } Handler = {Info, E, AllocType, AK, nullptr};
10404 CompleteObject Obj = findCompleteObject(Info, E, AK, Result, AllocType);
10405 if (!Obj || !findSubobject(Info, E, Obj, Result.Designator, Handler))
10417 Val = Info.createHeapAlloc(E, AllocType, Result);
10424 if (!EvaluateInPlace(*Val, Info, Result, &VIE))
10427 if (!EvaluateArrayNewInitList(Info, Result, *Val, ResizedArrayILE,
10431 if (!EvaluateArrayNewConstructExpr(Info, Result, *Val, ResizedArrayCCE,
10435 if (!EvaluateInPlace(*Val, Info, Result, Init))
10444 Result.addArray(Info, E, cast<ConstantArrayType>(AT));
10463 MemberPointerExprEvaluator(EvalInfo &Info, MemberPtr &Result)
10464 : ExprEvaluatorBaseTy(Info), Result(Result) {}
10480 EvalInfo &Info) {
10483 return MemberPointerExprEvaluator(Info, Result).Visit(E);
10548 RecordExprEvaluator(EvalInfo &info, const LValue &This, APValue &Result)
10549 : ExprEvaluatorBaseTy(info), This(This), Result(Result) {}
10586 static bool HandleClassZeroInitialization(EvalInfo &Info, const Expr *E,
10595 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
10603 if (!HandleLValueDirectBase(Info, E, Subobject, CD, Base, &Layout))
10605 if (!HandleClassZeroInitialization(Info, E, Base, Subobject,
10617 if (!HandleLValueMember(Info, E, Subobject, I, &Layout))
10622 Result.getStructField(I->getFieldIndex()), Info, Subobject, &VIE))
10644 if (!HandleLValueMember(Info, E, Subobject, *I))
10648 return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, &VIE);
10652 Info.FFDiag(E, diag::note_constexpr_virtual_base) << RD;
10656 return HandleClassZeroInitialization(Info, E, RD, This, Result);
10670 if (!Evaluate(DerivedObject, Info, E->getSubExpr()))
10702 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
10706 Info,
10734 if (!HandleLValueMember(Info, InitExpr, Subobject, Field, &Layout))
10738 ThisOverrideRAII ThisOverride(*Info.CurrentCall, &This,
10741 if (EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr)) {
10743 return truncateBitfieldValue(Info, InitExpr, Result.getUnionValue(),
10764 if (!HandleLValueBase(Info, Init, Subobject, CXXRD, &Base))
10768 if (!EvaluateInPlace(FieldVal, Info, Subobject, Init)) {
10769 if (!Info.noteFailure())
10792 if (!HandleLValueMember(Info, HaveInit ? Args[ElementNo] : ExprToVisit,
10798 ImplicitValueInitExpr VIE(HaveInit ? Info.Ctx.IntTy : Field->getType());
10802 if (auto *CAT = Info.Ctx.getAsConstantArrayType(Init->getType())) {
10806 Info.FFDiag(Init, diag::note_constexpr_unsupported_flexible_array);
10813 ThisOverrideRAII ThisOverride(*Info.CurrentCall, &This,
10817 if (!EvaluateInPlace(FieldVal, Info, Subobject, Init) ||
10818 (Field->isBitField() && !truncateBitfieldValue(Info, Init,
10820 if (!Info.noteFailure())
10839 if (CheckTrivialDefaultConstructor(Info, E->getExprLoc(), FD, ZeroInit)) {
10853 if (!CheckConstexprFunction(Info, E->getExprLoc(), FD, Definition, Body))
10864 assert(SrcObj->isTemporaryObject(Info.Ctx, FD->getParent()));
10865 assert(Info.Ctx.hasSameUnqualifiedType(E->getType(), SrcObj->getType()));
10876 cast<CXXConstructorDecl>(Definition), Info,
10882 if (!Info.CurrentCall) {
10883 assert(Info.checkingPotentialConstantExpression());
10894 if (!CheckConstexprFunction(Info, E->getExprLoc(), FD, Definition, Body))
10897 return HandleConstructorCall(E, This, Info.CurrentCall->Arguments,
10898 cast<CXXConstructorDecl>(Definition), Info,
10905 Info.Ctx.getAsConstantArrayType(E->getSubExpr()->getType());
10908 if (!EvaluateLValue(E->getSubExpr(), Array, Info))
10914 Array.addArray(Info, E, ArrayType);
10923 Info.Ctx.hasSameType(Field->getType()->getPointeeType(),
10930 if (Info.Ctx.hasSameType(Field->getType(), Info.Ctx.getSizeType())) {
10935 assert(Info.Ctx.hasSameType(Field->getType()->getPointeeType(),
10938 if (!HandleLValueArrayAdjustment(Info, E, Array,
10969 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(ClosureClass);
10982 if (!HandleLValueMember(Info, E, Subobject, Field, &Layout))
10986 if (!EvaluateInPlace(FieldVal, Info, Subobject, CurFieldInit)) {
10987 if (!Info.keepEvaluatingAfterFailure())
10996 APValue &Result, EvalInfo &Info) {
11000 return RecordExprEvaluator(Info, This, Result).Visit(E);
11014 TemporaryExprEvaluator(EvalInfo &Info, LValue &Result) :
11015 LValueExprEvaluatorBaseTy(Info, Result, false) {}
11019 APValue &Value = Info.CurrentCall->createTemporary(
11021 return EvaluateInPlace(Value, Info, Result, E);
11052 static bool EvaluateTemporary(const Expr *E, LValue &Result, EvalInfo &Info) {
11055 return TemporaryExprEvaluator(Info, Result).Visit(E);
11068 VectorExprEvaluator(EvalInfo &info, APValue &Result)
11069 : ExprEvaluatorBaseTy(info), Result(Result) {}
11100 static bool EvaluateVector(const Expr* E, APValue& Result, EvalInfo &Info) {
11103 return VectorExprEvaluator(Info, Result).Visit(E);
11118 if (!EvaluateInteger(SE, IntResult, Info))
11123 if (!EvaluateFloat(SE, FloatResult, Info))
11136 if (!Evaluate(SVal, Info, SE))
11142 Info.FFDiag(E, diag::note_constexpr_invalid_cast)
11143 << 2 << Info.Ctx.getLangOpts().CPlusPlus;
11147 if (!handleRValueToRValueBitCast(Info, Result, SVal, E))
11155 if (!EvaluateVector(SE, Val, Info))
11185 if (!EvaluateVector(E->getInit(CountInits), v, Info))
11194 if (!EvaluateInteger(E->getInit(CountInits), sInt, Info))
11197 sInt = Info.Ctx.MakeIntValue(0, EltTy);
11203 if (!EvaluateFloat(E->getInit(CountInits), f, Info))
11206 f = APFloat::getZero(Info.Ctx.getFloatTypeSemantics(EltTy));
11221 ZeroElement = APValue(Info.Ctx.MakeIntValue(0, EltTy));
11224 APValue(APFloat::getZero(Info.Ctx.getFloatTypeSemantics(EltTy)));
11258 bool LHSOK = Evaluate(LHSValue, Info, LHS);
11259 if (!LHSOK && !Info.noteFailure())
11261 if (!Evaluate(RHSValue, Info, RHS) || !LHSOK)
11264 if (!handleVectorVectorBinOp(Info, E, Op, LHSValue, RHSValue))
11330 if (!Evaluate(SubExprValue, Info, SubExpr))
11348 Info.Ctx, ResultEltTy, Op, SubExprValue.getVectorElt(EltNum));
11356 static bool handleVectorElementCast(EvalInfo &Info, const FPOptions FPO,
11363 return HandleIntToFloatCast(Info, E, FPO, SourceTy, Original.getInt(),
11368 HandleIntToIntCast(Info, E, DestTy, SourceTy, Original.getInt()));
11374 return HandleFloatToFloatCast(Info, E, SourceTy, DestTy,
11379 return HandleFloatToIntCast(Info, E, SourceTy, Original.getFloat(),
11384 Info.FFDiag(E, diag::err_convertvector_constexpr_unsupported_vector_cast)
11399 if (!EvaluateAsRValue(Info, E->getArg(0), Source))
11412 APSInt(APInt(Info.Ctx.getIntWidth(DestEltTy), Elt.popcount()),
11428 if (!EvaluateAsRValue(Info, E->getArg(0), SourceLHS) ||
11429 !EvaluateAsRValue(Info, E->getArg(1), SourceRHS))
11462 if (!EvaluateAsRValue(Info, E->getSrcExpr(), Source))
11468 const FPOptions FPO = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
11475 if (!handleVectorElementCast(Info, FPO, E, SourceTy, DestTy,
11484 static bool handleVectorShuffle(EvalInfo &Info, const ShuffleVectorExpr *E,
11491 APSInt IndexVal = E->getShuffleMaskIdx(Info.Ctx, EltNum);
11498 Info.FFDiag(
11518 if (!EvaluateAsRValue(Info, Vec1, VecVal1))
11522 if (!EvaluateAsRValue(Info, Vec2, VecVal2))
11534 if (!handleVectorShuffle(Info, E, DestElTy, VecVal1, VecVal2, EltNum, Elt))
11553 ArrayExprEvaluator(EvalInfo &Info, const LValue &This, APValue &Result)
11554 : ExprEvaluatorBaseTy(Info), This(This), Result(Result) {}
11564 Info.Ctx.getAsConstantArrayType(E->getType());
11583 Subobject.addArray(Info, E, CAT);
11585 return EvaluateInPlace(Result.getArrayFiller(), Info, Subobject, &VIE);
11600 expandStringLiteral(Info, E, Result, AllocType);
11612 APValue &Result, EvalInfo &Info) {
11616 return ArrayExprEvaluator(Info, This, Result).Visit(E);
11619 static bool EvaluateArrayNewInitList(EvalInfo &Info, LValue &This,
11625 return ArrayExprEvaluator(Info, This, Result)
11629 static bool EvaluateArrayNewConstructExpr(EvalInfo &Info, LValue &This,
11636 return ArrayExprEvaluator(Info, This, Result)
11663 const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(
11690 const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(
11733 Subobject.addArray(Info, ExprToVisit, CAT);
11736 return EvaluateDependentExpr(Init, Info);
11738 if (!EvaluateInPlace(Result.getArrayInitializedElt(ArrayIndex), Info,
11740 !HandleLValueArrayAdjustment(Info, Init, Subobject,
11742 if (!Info.noteFailure())
11750 APSInt Value(Info.Ctx.getTypeSize(DestTy), DestTy->isUnsignedIntegerType());
11766 Init->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
11768 if (!HandleIntToFloatCast(Info, Init, FPO, EmbedS->getType(), Value,
11788 return EvaluateInPlace(Result.getArrayFiller(), Info, Subobject,
11796 !Evaluate(Info.CurrentCall->createTemporary(
11798 getStorageType(Info.Ctx, E->getCommonExpr()),
11800 Info, E->getCommonExpr()->getSourceExpr()))
11809 Subobject.addArray(Info, E, CAT);
11812 for (EvalInfo::ArrayInitLoopIndex Index(Info); Index != Elements; ++Index) {
11821 FullExpressionRAII Scope(Info);
11824 Info, Subobject, E->getSubExpr()) ||
11825 !HandleLValueArrayAdjustment(Info, E, Subobject,
11827 if (!Info.noteFailure())
11849 if (const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(Type)) {
11862 Info, E->getExprLoc(), E->getConstructor(),
11865 ArrayElt.addArray(Info, E, CAT);
11898 !HandleLValueArrayAdjustment(Info, E, ArrayElt,
11903 if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
11904 !Info.keepEvaluatingAfterFailure())
11916 return RecordExprEvaluator(Info, Subobject, *Value)
11942 IntExprEvaluator(EvalInfo &info, APValue &result)
11943 : ExprEvaluatorBaseTy(info), Result(result) {}
11950 assert(SI.getBitWidth() == Info.Ctx.getIntWidth(E->getType()) &&
11962 assert(I.getBitWidth() == Info.Ctx.getIntWidth(E->getType()) &&
11976 Result = APValue(Info.Ctx.MakeIntValue(Value, E->getType()));
12048 if (Info.ArrayInitIndex == uint64_t(-1)) {
12051 Info.FFDiag(E);
12054 return Success(Info.ArrayInitIndex, E);
12097 FixedPointExprEvaluator(EvalInfo &info, APValue &result)
12098 : ExprEvaluatorBaseTy(info), Result(result) {}
12102 APFixedPoint(I, Info.Ctx.getFixedPointSemantics(E->getType())), E);
12107 APFixedPoint(Value, Info.Ctx.getFixedPointSemantics(E->getType())), E);
12116 assert(V.getWidth() == Info.Ctx.getIntWidth(E->getType()) &&
12149 EvalInfo &Info) {
12152 return IntExprEvaluator(Info, Result).Visit(E);
12155 static bool EvaluateInteger(const Expr *E, APSInt &Result, EvalInfo &Info) {
12158 if (!EvaluateIntegerOrLValue(E, Val, Info))
12163 Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
12172 Info.Ctx, Info.CurrentCall->CurSourceLocExprScope.getDefaultExpr());
12177 EvalInfo &Info) {
12181 if (!FixedPointExprEvaluator(Info, Val).Visit(E))
12193 EvalInfo &Info) {
12196 auto FXSema = Info.Ctx.getFixedPointSemantics(E->getType());
12198 if (!EvaluateInteger(E, Val, Info))
12203 return EvaluateFixedPoint(E, Result, Info);
12218 == Info.Ctx.getIntWidth(E->getType()));
12228 Val = Val.extOrTrunc(Info.Ctx.getIntWidth(E->getType()));
12429 static bool EvaluateBuiltinConstantP(EvalInfo &Info, const Expr *Arg) {
12432 SpeculativeEvaluationRAII SpeculativeEval(Info);
12437 FoldConstant Fold(Info, true);
12459 if (!::EvaluateAsRValue(Info, Arg, V) || Info.EvalStatus.HasSideEffects) {
12682 static void addFlexibleArrayMemberInitSize(EvalInfo &Info, const QualType &T,
12689 Size += VD->getFlexibleArrayInitChars(Info.Ctx);
12698 static bool determineEndOffset(EvalInfo &Info, SourceLocation ExprLoc,
12710 return HandleSizeof(Info, ExprLoc, Ty, Result);
12723 getBytesReturnedByAllocSizeCall(Info.Ctx, LVal, APEndOffset))
12731 addFlexibleArrayMemberInitSize(Info, BaseTy, LVal, EndOffset);
12745 if (isUserWritingOffTheEnd(Info.Ctx, LVal)) {
12750 getBytesReturnedByAllocSizeCall(Info.Ctx, LVal, APEndOffset))
12787 EvalInfo &Info, uint64_t &Size) {
12794 SpeculativeEvaluationRAII SpeculativeEval(Info);
12795 IgnoreSideEffectsRAII Fold(Info);
12801 if (!EvaluateAsRValue(Info, E, RVal))
12803 LVal.setFrom(Info.Ctx, RVal);
12804 } else if (!EvaluatePointer(ignorePointerCastsAndParens(E), LVal, Info,
12817 if (!determineEndOffset(Info, E->getExprLoc(), Type, LVal, EndOffset))
12835 static bool getBuiltinAlignArguments(const CallExpr *E, EvalInfo &Info,
12838 if (!getAlignmentArgument(E->getArg(1), SrcTy, Info, Alignment))
12844 if (!EvaluatePointer(E->getArg(0), Ptr, Info))
12848 Info.FFDiag(E->getArg(0));
12852 if (!EvaluateInteger(E->getArg(0), SrcInt, Info))
12872 E->getArg(1)->EvaluateKnownConstInt(Info.Ctx).getZExtValue();
12876 if (tryEvaluateBuiltinObjectSize(E->getArg(0), Type, Info, Size))
12879 if (E->getArg(0)->HasSideEffects(Info.Ctx))
12884 switch (Info.EvalMode) {
12900 analyze_os_log::computeOSLogBufferLayout(Info.Ctx, E, Layout);
12907 if (!getBuiltinAlignArguments(E, Info, Src, Alignment))
12912 Ptr.setFrom(Info.Ctx, Src);
12913 CharUnits BaseAlignment = getBaseAlignment(Info, Ptr);
12931 Info.FFDiag(E->getArg(0), diag::note_constexpr_alignment_compute)
12941 if (!getBuiltinAlignArguments(E, Info, Src, Alignment))
12954 if (!getBuiltinAlignArguments(E, Info, Src, Alignment))
12970 if (!EvaluateInteger(E->getArg(0), Val, Info))
12980 if (!EvaluateInteger(E->getArg(0), Val, Info))
12987 return Success((int)EvaluateBuiltinClassifyType(E, Info.getLangOpts()), E);
12993 if (!EvaluateInteger(E->getArg(0), Val, Info))
13008 if (!EvaluateInteger(E->getArg(0), Val, Info))
13014 if (!EvaluateInteger(E->getArg(1), FallbackTemp, Info))
13039 if (EvaluateBuiltinConstantP(Info, Arg))
13041 if (Info.InConstantContext || Arg->HasSideEffects(Info.Ctx)) {
13047 Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
13056 const auto *Callee = Info.CurrentCall->getCallee();
13057 if (Info.InConstantContext && !Info.CheckingPotentialConstantExpression &&
13058 (Info.CallStackDepth == 1 ||
13059 (Info.CallStackDepth == 2 && Callee->isInStdNamespace() &&
13063 if (Info.EvalStatus.Diag)
13064 Info.report((Info.CallStackDepth == 1)
13066 : Info.CurrentCall->getCallRange().getBegin(),
13068 << (Info.CallStackDepth == 1 ? "__builtin_is_constant_evaluated"
13072 return Success(Info.InConstantContext, E);
13086 if (!EvaluateInteger(E->getArg(0), Val, Info))
13092 if (!EvaluateInteger(E->getArg(1), FallbackTemp, Info))
13108 int Operand = E->getArg(0)->EvaluateKnownConstInt(Info.Ctx).getZExtValue();
13109 Operand = Info.Ctx.getTargetInfo().getEHDataRegisterNumber(Operand);
13128 if (!EvaluateInteger(E->getArg(0), Val, Info))
13137 if (!EvaluateFloat(E->getArg(5), Val, Info))
13151 return EvaluateFloat(E->getArg(0), Val, Info) &&
13157 return EvaluateFloat(E->getArg(0), Val, Info) &&
13163 return EvaluateFloat(E->getArg(0), Val, Info) &&
13169 return EvaluateFloat(E->getArg(0), Val, Info) &&
13175 return EvaluateFloat(E->getArg(0), Val, Info) &&
13181 return EvaluateFloat(E->getArg(0), Val, Info) &&
13187 return EvaluateFloat(E->getArg(0), Val, Info) &&
13195 return EvaluateFloat(E->getArg(0), Val, Info) &&
13207 if (!EvaluateFloat(E->getArg(0), LHS, Info) ||
13208 !EvaluateFloat(E->getArg(1), RHS, Info))
13241 return EvaluateFloat(E->getArg(0), Val, Info) &&
13247 if (!EvaluateInteger(E->getArg(1), MaskVal, Info))
13251 return EvaluateFloat(E->getArg(0), Val, Info) &&
13259 if (!EvaluateInteger(E->getArg(0), Val, Info))
13269 if (!EvaluateInteger(E->getArg(0), Val, Info))
13288 if (!EvaluateInteger(E->getArg(0), Val, Info))
13304 if (!EvaluateInteger(E->getArg(0), Val, Info) ||
13305 !EvaluateInteger(E->getArg(1), Amt, Info))
13321 if (!EvaluateInteger(E->getArg(0), Val, Info) ||
13322 !EvaluateInteger(E->getArg(1), Amt, Info))
13330 if (!EvaluateInteger(E->getArg(0), LHS, Info) ||
13331 !EvaluateInteger(E->getArg(1), RHS, Info))
13339 if (!EvaluateInteger(E->getArg(0), LHS, Info) ||
13340 !EvaluateInteger(E->getArg(1), RHS, Info))
13350 if (Info.getLangOpts().CPlusPlus11)
13351 Info.CCEDiag(E, diag::note_constexpr_invalid_function)
13353 << Info.Ctx.BuiltinInfo.getQuotedName(BuiltinOp);
13355 Info.CCEDiag(E, diag::note_invalid_subexpr_in_const_expr);
13362 if (EvaluateBuiltinStrLen(E->getArg(0), StrLen, Info))
13375 if (Info.getLangOpts().CPlusPlus11)
13376 Info.CCEDiag(E, diag::note_constexpr_invalid_function)
13378 << Info.Ctx.BuiltinInfo.getQuotedName(BuiltinOp);
13380 Info.CCEDiag(E, diag::note_invalid_subexpr_in_const_expr);
13390 if (!EvaluatePointer(E->getArg(0), String1, Info) ||
13391 !EvaluatePointer(E->getArg(1), String2, Info))
13400 if (!EvaluateInteger(E->getArg(2), N, Info))
13409 if (!String1.checkNullPointerForFoldAccess(Info, E, AK_Read) ||
13410 !String2.checkNullPointerForFoldAccess(Info, E, AK_Read) ||
13414 QualType CharTy1 = String1.Designator.getType(Info.Ctx);
13415 QualType CharTy2 = String2.Designator.getType(Info.Ctx);
13423 (Info.Ctx.hasSameUnqualifiedType(
13425 Info.Ctx.hasSameUnqualifiedType(CharTy1, CharTy2)));
13432 Info.FFDiag(E, diag::note_constexpr_memcmp_unsupported)
13433 << Info.Ctx.BuiltinInfo.getQuotedName(BuiltinOp) << CharTy1
13439 return handleLValueToRValueConversion(Info, E, CharTy1, String1, Char1) &&
13440 handleLValueToRValueConversion(Info, E, CharTy2, String2, Char2) &&
13444 return HandleLValueArrayAdjustment(Info, E, String1, CharTy1, 1) &&
13445 HandleLValueArrayAdjustment(Info, E, String2, CharTy2, 1);
13485 if (!EvaluateInteger(E->getArg(0), SizeVal, Info))
13502 Info.Ctx.getTargetInfo().getMaxAtomicInlineWidth();
13503 if (Size <= Info.Ctx.toCharUnitsFromBits(InlineWidthBits)) {
13513 if (PtrArg->EvaluateAsRValue(ExprResult, Info.Ctx) &&
13515 Info.Ctx) &&
13530 Info.Ctx.getTypeAlignInChars(PointeeType) >= Size) {
13554 if (!EvaluateInteger(E->getArg(0), LHS, Info) ||
13555 !EvaluateInteger(E->getArg(1), RHS, Info) ||
13556 !EvaluateInteger(E->getArg(2), CarryIn, Info) ||
13557 !EvaluatePointer(E->getArg(3), CarryOutLValue, Info))
13590 if (!handleAssignment(Info, E, CarryOutLValue, ResultType, APV))
13619 if (!EvaluateInteger(E->getArg(0), LHS, Info) ||
13620 !EvaluateInteger(E->getArg(1), RHS, Info) ||
13621 !EvaluatePointer(E->getArg(2), ResultLValue, Info))
13637 uint64_t ResultSize = Info.Ctx.getTypeSize(ResultType);
13698 APSInt Temp = Result.extOrTrunc(Info.Ctx.getTypeSize(ResultType));
13707 if (!handleAssignment(Info, E, ResultLValue, ResultType, APV))
13720 if (!EvaluateAsRValue(Info, E->getArg(0), Source))
13731 Info, E, Reduced, Source.getVectorElt(EltNum).getInt(),
13738 Info, E, Reduced, Source.getVectorElt(EltNum).getInt(),
13776 if (!EvaluateInteger(E->getArg(0), CarryIn, Info) ||
13777 !EvaluateInteger(E->getArg(1), LHS, Info) ||
13778 !EvaluateInteger(E->getArg(2), RHS, Info) ||
13779 !EvaluatePointer(E->getArg(3), ResultLValue, Info))
13796 if (!handleAssignment(Info, E, ResultLValue, ResultType, APV))
13806 if (!EvaluateInteger(E->getArg(0), Val, Info) ||
13807 !EvaluateInteger(E->getArg(1), Idx, Info))
13827 if (!EvaluateInteger(E->getArg(0), Val, Info) ||
13828 !EvaluateInteger(E->getArg(1), Idx, Info))
13842 if (!EvaluateInteger(E->getArg(0), Val, Info))
13851 if (!EvaluateInteger(E->getArg(0), Val, Info))
13859 if (!EvaluateInteger(E->getArg(0), Val, Info) ||
13860 !EvaluateInteger(E->getArg(1), Msk, Info))
13874 if (!EvaluateInteger(E->getArg(0), Val, Info) ||
13875 !EvaluateInteger(E->getArg(1), Msk, Info))
13948 void startSpeculativeEval(EvalInfo &Info) {
13949 SpecEvalRAII = SpeculativeEvaluationRAII(Info);
13959 EvalInfo &Info;
13964 : IntEval(IntEval), Info(IntEval.getEvalInfo()), FinalResult(Result) { }
14004 return Info.CCEDiag(E, D);
14015 Result.Failed = !Evaluate(Result.Val, Info, E);
14038 return Info.noteSideEffect();
14056 if (!Info.noteSideEffect())
14071 if (LHSResult.Failed && !Info.noteFailure())
14176 APSInt Value(Info.Ctx.getIntWidth(E->getType()),
14178 if (!handleIntIntBinOp(Info, E, LHSVal.getInt(), E->getOpcode(),
14210 job.startSpeculativeEval(Info);
14242 EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
14250 Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
14263 bool LHSOK = EvaluateInteger(E->getLHS(), LHS, Info);
14264 if (!LHSOK && !Info.noteFailure())
14266 if (!EvaluateInteger(E->getRHS(), RHS, Info) || !LHSOK)
14276 APFixedPoint LHSFX(Info.Ctx.getFixedPointSemantics(LHSTy));
14277 APFixedPoint RHSFX(Info.Ctx.getFixedPointSemantics(RHSTy));
14279 bool LHSOK = EvaluateFixedPointOrInteger(E->getLHS(), LHSFX, Info);
14280 if (!LHSOK && !Info.noteFailure())
14282 if (!EvaluateFixedPointOrInteger(E->getRHS(), RHSFX, Info) || !LHSOK)
14296 EvaluateLValue(E->getLHS(), LV, Info);
14299 LHSOK = EvaluateFloat(E->getLHS(), LHS.FloatReal, Info);
14305 LHSOK = EvaluateComplex(E->getLHS(), LHS, Info);
14307 if (!LHSOK && !Info.noteFailure())
14311 if (!EvaluateFloat(E->getRHS(), RHS.FloatReal, Info) || !LHSOK)
14315 } else if (!EvaluateComplex(E->getRHS(), RHS, Info) || !LHSOK)
14337 bool LHSOK = EvaluateFloat(E->getRHS(), RHS, Info);
14338 if (!LHSOK && !Info.noteFailure())
14341 if (!EvaluateFloat(E->getLHS(), LHS, Info) || !LHSOK)
14346 if (!Info.InConstantContext &&
14348 E->getFPFeaturesInEffect(Info.Ctx.getLangOpts()).isFPConstrained()) {
14350 Info.FFDiag(E, diag::note_constexpr_float_arithmetic_strict);
14372 bool LHSOK = EvaluatePointer(E->getLHS(), LHSValue, Info);
14373 if (!LHSOK && !Info.noteFailure())
14376 if (!EvaluatePointer(E->getRHS(), RHSValue, Info) || !LHSOK)
14389 std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
14390 std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
14391 Info.FFDiag(E, DiagID)
14420 if (ArePotentiallyOverlappingStringLiterals(Info, LHSValue, RHSValue))
14433 isOnePastTheEndOfCompleteObject(Info.Ctx, RHSValue))
14437 isOnePastTheEndOfCompleteObject(Info.Ctx, LHSValue))
14478 Info.CCEDiag(E, diag::note_constexpr_pointer_comparison_base_classes);
14480 Info.CCEDiag(E, diag::note_constexpr_pointer_comparison_base_field)
14484 Info.CCEDiag(E, diag::note_constexpr_pointer_comparison_base_field)
14489 Info.CCEDiag(E,
14498 unsigned PtrSize = Info.Ctx.getTypeSize(LHSTy);
14513 CharUnits Size = Info.Ctx.getTypeSizeInChars(BaseTy);
14532 bool LHSOK = EvaluateMemberPointer(E->getLHS(), LHSValue, Info);
14533 if (!LHSOK && !Info.noteFailure())
14536 if (!EvaluateMemberPointer(E->getRHS(), RHSValue, Info) || !LHSOK)
14542 Info.FFDiag(E, diag::note_constexpr_mem_pointer_weak_comparison)
14547 Info.FFDiag(E, diag::note_constexpr_mem_pointer_weak_comparison)
14564 Info.CCEDiag(E, diag::note_constexpr_compare_virtual_mem_ptr) << MD;
14567 Info.CCEDiag(E, diag::note_constexpr_compare_virtual_mem_ptr) << MD;
14584 if (!EvaluatePointer(E->getLHS(), Res, Info) ||
14585 !EvaluatePointer(E->getRHS(), Res, Info))
14594 if (!CheckLiteralType(Info, E))
14618 Info.Ctx.CompCategories.getInfoForType(E->getType());
14623 if (!handleLValueToRValueConversion(Info, E, E->getType(), LV, Result))
14625 return CheckConstantExpression(Info, E->getExprLoc(), E->getType(), Result,
14628 return EvaluateComparisonBinaryOperator(Info, E, OnSuccess, [&]() {
14643 if (!Info.noteFailure())
14680 return EvaluateComparisonBinaryOperator(Info, E, OnSuccess, [&]() {
14692 bool LHSOK = EvaluatePointer(E->getLHS(), LHSValue, Info);
14693 if (!LHSOK && !Info.noteFailure())
14696 if (!EvaluatePointer(E->getRHS(), RHSValue, Info) || !LHSOK)
14709 std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
14710 std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
14711 Info.FFDiag(E, DiagID) << LHS << RHS;
14713 Info.Note(LHSExpr->getExprLoc(),
14722 if (ArePotentiallyOverlappingStringLiterals(Info, LHSValue, RHSValue))
14748 Info.CCEDiag(E, diag::note_constexpr_pointer_subtraction_not_same_array);
14754 if (!HandleSizeof(Info, E->getExprLoc(), ElementType, ElementSize))
14761 Info.FFDiag(E, diag::note_constexpr_pointer_subtraction_zero_size)
14779 APSInt Result = TrueResult.trunc(Info.Ctx.getIntWidth(E->getType()));
14782 !HandleOverflow(Info, E, TrueResult, E->getType()))
14799 GetAlignOfType(Info.Ctx, E->getArgumentType(), E->getKind()), E);
14802 GetAlignOfExpr(Info.Ctx, E->getArgumentExpr(), E->getKind()), E);
14809 Info.Ctx.getPointerAuthTypeDiscriminator(E->getArgumentType()), E);
14836 if (!HandleSizeof(Info, E->getExprLoc(), SrcTy, Sizeof,
14846 Info.Ctx.toCharUnitsFromBits(
14847 Info.Ctx.getOpenMPDefaultSimdAlign(E->getArgumentType()))
14858 if (Info.InConstantContext)
14859 Info.CCEDiag(E, diag::note_constexpr_non_const_vectorelements)
14881 if (!EvaluateInteger(Idx, IdxResult, Info))
14883 const ArrayType *AT = Info.Ctx.getAsArrayType(CurrentType);
14887 CharUnits ElementSize = Info.Ctx.getTypeSizeInChars(CurrentType);
14899 const ASTRecordLayout &RL = Info.Ctx.getASTRecordLayout(RD);
14902 Result += Info.Ctx.toCharUnitsFromBits(RL.getFieldOffset(i));
14921 const ASTRecordLayout &RL = Info.Ctx.getASTRecordLayout(RD);
14957 if (Info.checkingForUndefinedBehavior())
14958 Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
14964 if (!HandleOverflow(Info, E, -Value.extend(Value.getBitWidth() + 1),
14978 if (!EvaluateAsBooleanCondition(E->getSubExpr(), bres, Info))
15060 if (!EvaluateAsBooleanCondition(SubExpr, BoolResult, Info))
15069 APFixedPoint Src(Info.Ctx.getFixedPointSemantics(SrcType));
15070 if (!EvaluateFixedPoint(SubExpr, Src, Info))
15074 Info.Ctx.getIntWidth(DestType),
15076 if (Overflowed && !HandleOverflow(Info, E, Result, DestType))
15084 if (!Evaluate(Val, Info, SubExpr))
15100 return Info.Ctx.getTypeSize(DestType) <= Info.Ctx.getTypeSize(SrcType);
15102 return Info.Ctx.getTypeSize(DestType) == Info.Ctx.getTypeSize(SrcType);
15105 if (Info.Ctx.getLangOpts().CPlusPlus && Info.InConstantContext &&
15106 Info.EvalMode == EvalInfo::EM_ConstantExpression &&
15117 Info.EvaluatingDecl.dyn_cast<const ValueDecl *>()))
15142 Info.CCEDiag(E, diag::note_constexpr_unscoped_enum_out_of_range)
15147 Info.CCEDiag(E, diag::note_constexpr_unscoped_enum_out_of_range)
15153 return Success(HandleIntToIntCast(Info, E, DestType, SrcType,
15159 << 2 << Info.Ctx.getLangOpts().CPlusPlus << E->getSourceRange();
15162 if (!EvaluatePointer(SubExpr, LV, Info))
15170 if (Info.Ctx.getTypeSize(DestType) != Info.Ctx.getTypeSize(SrcType))
15181 if (!V.toIntegralConstant(AsInt, SrcType, Info.Ctx))
15184 return Success(HandleIntToIntCast(Info, E, DestType, SrcType, AsInt), E);
15189 if (!EvaluateComplex(SubExpr, C, Info))
15196 if (!EvaluateFloat(SubExpr, F, Info))
15200 if (!HandleFloatToIntCast(Info, E, SrcType, F, DestType, Value))
15206 if (!EvaluateVector(SubExpr, Val, Info))
15218 if (!EvaluateComplex(E->getSubExpr(), LV, Info))
15231 if (!EvaluateComplex(E->getSubExpr(), LV, Info))
15273 if (Overflowed && !HandleOverflow(Info, E, Negated, E->getType()))
15279 if (!EvaluateAsBooleanCondition(E->getSubExpr(), bres, Info))
15291 auto DestFXSema = Info.Ctx.getFixedPointSemantics(DestType);
15295 APFixedPoint Src(Info.Ctx.getFixedPointSemantics(SubExpr->getType()));
15296 if (!EvaluateFixedPoint(SubExpr, Src, Info))
15301 if (Info.checkingForUndefinedBehavior())
15302 Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
15305 if (!HandleOverflow(Info, E, Result, E->getType()))
15312 if (!EvaluateInteger(SubExpr, Src, Info))
15317 Src, Info.Ctx.getFixedPointSemantics(DestType), &Overflowed);
15320 if (Info.checkingForUndefinedBehavior())
15321 Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
15324 if (!HandleOverflow(Info, E, IntResult, E->getType()))
15332 if (!EvaluateFloat(SubExpr, Src, Info))
15337 Src, Info.Ctx.getFixedPointSemantics(DestType), &Overflowed);
15340 if (Info.checkingForUndefinedBehavior())
15341 Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
15344 if (!HandleOverflow(Info, E, Result, E->getType()))
15365 Info.Ctx.getFixedPointSemantics(E->getType());
15367 APFixedPoint LHSFX(Info.Ctx.getFixedPointSemantics(LHS->getType()));
15368 if (!EvaluateFixedPointOrInteger(LHS, LHSFX, Info))
15370 APFixedPoint RHSFX(Info.Ctx.getFixedPointSemantics(RHS->getType()));
15371 if (!EvaluateFixedPointOrInteger(RHS, RHSFX, Info))
15394 Info.FFDiag(E, diag::note_expr_divide_by_zero);
15413 Info.CCEDiag(E, diag::note_constexpr_negative_shift) << RHSVal;
15415 Info.CCEDiag(E, diag::note_constexpr_large_shift)
15428 if (Info.checkingForUndefinedBehavior())
15429 Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
15432 if (!HandleOverflow(Info, E, Result, E->getType()))
15447 FloatExprEvaluator(EvalInfo &info, APFloat &result)
15448 : ExprEvaluatorBaseTy(info), Result(result) {}
15456 Result = APFloat::getZero(Info.Ctx.getFloatTypeSemantics(E->getType()));
15474 static bool EvaluateFloat(const Expr* E, APFloat& Result, EvalInfo &Info) {
15477 return FloatExprEvaluator(Info, Result).Visit(E);
15537 Info.Ctx.getFloatTypeSemantics(E->getType());
15547 if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0),
15559 if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0),
15573 if (!EvaluateFloat(E->getArg(0), Result, Info))
15581 return EvaluateFloat(E->getArg(0), Result, Info);
15592 if (!EvaluateFloat(E->getArg(0), Result, Info) ||
15593 !EvaluateFloat(E->getArg(1), RHS, Info))
15606 if (!EvaluateFloat(E->getArg(0), Result, Info) ||
15607 !EvaluateFloat(E->getArg(1), RHS, Info))
15624 if (!EvaluateFloat(E->getArg(0), Result, Info) ||
15625 !EvaluateFloat(E->getArg(1), RHS, Info))
15641 if (!EvaluateFloat(E->getArg(0), Result, Info) ||
15642 !EvaluateFloat(E->getArg(1), RHS, Info))
15654 if (!EvaluateFloat(E->getArg(0), Result, Info) ||
15655 !EvaluateFloat(E->getArg(1), RHS, Info))
15666 if (!EvaluateComplex(E->getSubExpr(), CV, Info))
15678 if (!EvaluateComplex(E->getSubExpr(), CV, Info))
15685 const llvm::fltSemantics &Sem = Info.Ctx.getFloatTypeSemantics(E->getType());
15694 return EvaluateFloat(E->getSubExpr(), Result, Info);
15699 if (!EvaluateFloat(E->getSubExpr(), Result, Info))
15711 bool LHSOK = EvaluateFloat(E->getLHS(), Result, Info);
15712 if (!LHSOK && !Info.noteFailure())
15714 return EvaluateFloat(E->getRHS(), RHS, Info) && LHSOK &&
15715 handleFloatFloatBinOp(Info, E, Result, E->getOpcode(), RHS);
15733 Info.Ctx.getLangOpts());
15734 return EvaluateInteger(SubExpr, IntResult, Info) &&
15735 HandleIntToFloatCast(Info, E, FPO, SubExpr->getType(),
15740 APFixedPoint FixResult(Info.Ctx.getFixedPointSemantics(SubExpr->getType()));
15741 if (!EvaluateFixedPoint(SubExpr, FixResult, Info))
15744 FixResult.convertToFloat(Info.Ctx.getFloatTypeSemantics(E->getType()));
15751 return HandleFloatToFloatCast(Info, E, SubExpr->getType(), E->getType(),
15757 if (!EvaluateComplex(SubExpr, V, Info))
15764 if (!EvaluateVector(SubExpr, Val, Info))
15781 ComplexExprEvaluator(EvalInfo &info, ComplexValue &Result)
15782 : ExprEvaluatorBaseTy(info), Result(Result) {}
15805 EvalInfo &Info) {
15808 return ComplexExprEvaluator(Info, Result).Visit(E);
15815 APFloat Zero = APFloat::getZero(Info.Ctx.getFloatTypeSemantics(ElemTy));
15820 APSInt Zero = Info.Ctx.MakeIntValue(0, ElemTy);
15833 if (!EvaluateFloat(SubExpr, Imag, Info))
15844 if (!EvaluateInteger(SubExpr, Imag, Info))
15924 if (!EvaluateFloat(E->getSubExpr(), Real, Info))
15940 return HandleFloatToFloatCast(Info, E, From, To, Result.FloatReal) &&
15941 HandleFloatToFloatCast(Info, E, From, To, Result.FloatImag);
15952 return HandleFloatToIntCast(Info, E, From, Result.FloatReal,
15954 HandleFloatToIntCast(Info, E, From, Result.FloatImag,
15960 if (!EvaluateInteger(E->getSubExpr(), Real, Info))
15976 Result.IntReal = HandleIntToIntCast(Info, E, To, From, Result.IntReal);
15977 Result.IntImag = HandleIntToIntCast(Info, E, To, From, Result.IntImag);
15986 Info.Ctx.getLangOpts());
15991 return HandleIntToFloatCast(Info, E, FPO, From, Result.IntReal,
15993 HandleIntToFloatCast(Info, E, FPO, From, Result.IntImag,
16111 LHSOK = EvaluateFloat(E->getLHS(), Real, Info);
16119 if (!LHSOK && !Info.noteFailure())
16126 if (!EvaluateFloat(E->getRHS(), Real, Info) || !LHSOK)
16130 } else if (!EvaluateComplex(E->getRHS(), RHS, Info) || !LHSOK)
16186 if (!handleFloatFloatBinOp(Info, E, ResR, BO_Mul, C) ||
16187 !handleFloatFloatBinOp(Info, E, ResI, BO_Mul, D))
16194 if (!handleFloatFloatBinOp(Info, E, ResR, BO_Mul, A) ||
16195 !handleFloatFloatBinOp(Info, E, ResI, BO_Mul, B))
16228 if (!handleFloatFloatBinOp(Info, E, ResR, BO_Div, C) ||
16229 !handleFloatFloatBinOp(Info, E, ResI, BO_Div, C))
16294 if (!EvaluateFloat(E->getInit(0), Result.FloatReal, Info))
16296 if (!EvaluateFloat(E->getInit(1), Result.FloatImag, Info))
16300 if (!EvaluateInteger(E->getInit(0), Result.IntReal, Info))
16302 if (!EvaluateInteger(E->getInit(1), Result.IntImag, Info))
16317 if (!EvaluateFloat(E->getArg(0), Result.FloatReal, Info))
16319 if (!EvaluateFloat(E->getArg(1), Result.FloatImag, Info))
16339 AtomicExprEvaluator(EvalInfo &Info, const LValue *This, APValue &Result)
16340 : ExprEvaluatorBaseTy(Info), This(This), Result(Result) {}
16352 return This ? EvaluateInPlace(Result, Info, *This, &VIE)
16353 : Evaluate(Result, Info, &VIE);
16364 return This ? EvaluateInPlace(Result, Info, *This, E->getSubExpr())
16365 : Evaluate(Result, Info, E->getSubExpr());
16372 EvalInfo &Info) {
16375 return AtomicExprEvaluator(Info, This, Result).Visit(E);
16387 VoidExprEvaluator(EvalInfo &Info) : ExprEvaluatorBaseTy(Info) {}
16414 return HandleOperatorDeleteCall(Info, E);
16427 if (Info.SpeculativeEvaluationDepth)
16432 Info.FFDiag(E, diag::note_constexpr_new_non_replaceable)
16440 if (!EvaluatePointer(Arg, Pointer, Info))
16450 if (!Info.getLangOpts().CPlusPlus20)
16451 Info.CCEDiag(E, diag::note_constexpr_new);
16456 Info, E, Pointer, E->isArrayForm() ? DynAlloc::ArrayNew : DynAlloc::New);
16465 Info.FFDiag(E, diag::note_constexpr_delete_base_nonvirt_dtor)
16476 Info.FFDiag(E, diag::note_constexpr_new_non_replaceable)
16482 if (!HandleDestruction(Info, E->getExprLoc(), Pointer.getLValueBase(),
16486 if (!Info.HeapAllocs.erase(Pointer.Base.dyn_cast<DynamicAllocLValue>())) {
16491 Info.FFDiag(E, diag::note_constexpr_double_delete);
16498 static bool EvaluateVoid(const Expr *E, EvalInfo &Info) {
16501 return VoidExprEvaluator(Info).Visit(E);
16508 static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
16515 if (!EvaluateLValue(E, LV, Info))
16519 if (!EvaluateVector(E, Result, Info))
16522 if (!IntExprEvaluator(Info, Result).Visit(E))
16526 if (!EvaluatePointer(E, LV, Info))
16531 if (!EvaluateFloat(E, F, Info))
16536 if (!EvaluateComplex(E, C, Info))
16540 if (!FixedPointExprEvaluator(Info, Result).Visit(E)) return false;
16543 if (!EvaluateMemberPointer(E, P, Info))
16550 Info.CurrentCall->createTemporary(E, T, ScopeKind::FullExpression, LV);
16551 if (!EvaluateArray(E, LV, Value, Info))
16557 Info.CurrentCall->createTemporary(E, T, ScopeKind::FullExpression, LV);
16558 if (!EvaluateRecord(E, LV, Value, Info))
16562 if (!Info.getLangOpts().CPlusPlus11)
16563 Info.CCEDiag(E, diag::note_constexpr_nonliteral)
16565 if (!EvaluateVoid(E, Info))
16571 APValue &Value = Info.CurrentCall->createTemporary(
16573 if (!EvaluateAtomic(E, &LV, Value, Info))
16577 if (!EvaluateAtomic(E, nullptr, Result, Info))
16580 } else if (Info.getLangOpts().CPlusPlus11) {
16581 Info.FFDiag(E, diag::note_constexpr_nonliteral) << E->getType();
16584 Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
16594 static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This,
16598 if (!AllowNonLiteralTypes && !CheckLiteralType(Info, E, &This))
16606 return EvaluateArray(E, This, Result, Info);
16608 return EvaluateRecord(E, This, Result, Info);
16612 return EvaluateAtomic(E, &This, Result, Info);
16617 return Evaluate(Result, Info, E);
16622 static bool EvaluateAsRValue(EvalInfo &Info, const Expr *E, APValue &Result) {
16628 if (!CheckLiteralType(Info, E))
16631 if (Info.EnableNewConstInterp) {
16632 if (!Info.Ctx.getInterpContext().evaluateAsRValue(Info, E, Result))
16634 return CheckConstantExpression(Info, E->getExprLoc(), E->getType(), Result,
16638 if (!::Evaluate(Result, Info, E))
16644 LV.setFrom(Info.Ctx, Result);
16645 if (!handleLValueToRValueConversion(Info, E, E->getType(), LV, Result))
16650 return CheckConstantExpression(Info, E->getExprLoc(), E->getType(), Result,
16652 CheckMemoryLeaks(Info);
16715 const ASTContext &Ctx, EvalInfo &Info) {
16721 return EvaluateAsRValue(Info, E, Result.Val);
16727 EvalInfo &Info) {
16732 if (!::EvaluateAsRValue(E, ExprResult, Ctx, Info) ||
16743 EvalInfo &Info) {
16748 if (!::EvaluateAsRValue(E, ExprResult, Ctx, Info))
16768 EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
16769 Info.InConstantContext = InConstantContext;
16770 return ::EvaluateAsRValue(this, Result, Ctx, Info);
16789 EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
16790 Info.InConstantContext = InConstantContext;
16791 return ::EvaluateAsInt(this, Result, Ctx, AllowSideEffects, Info);
16800 EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
16801 Info.InConstantContext = InConstantContext;
16802 return ::EvaluateAsFixedPoint(this, Result, Ctx, AllowSideEffects, Info);
16831 EvalInfo Info(Ctx, Result, EvalInfo::EM_ConstantFold);
16832 Info.InConstantContext = InConstantContext;
16835 if (!EvaluateLValue(this, LV, Info) || !Info.discardCleanups() ||
16837 !CheckLValueConstantExpression(Info, getExprLoc(),
16850 EvalInfo Info(Ctx, EStatus,
16853 Info.setEvaluatingDecl(Base, DestroyedValue,
16855 Info.InConstantContext = IsConstantDestruction;
16860 if (!HandleDestruction(Info, Loc, Base, DestroyedValue, Type) ||
16864 if (!Info.discardCleanups())
16880 EvalInfo Info(Ctx, Result, EM);
16881 Info.InConstantContext = true;
16883 if (Info.EnableNewConstInterp) {
16884 if (!Info.Ctx.getInterpContext().evaluate(Info, this, Result.Val, Kind))
16886 return CheckConstantExpression(Info, getExprLoc(),
16900 Info.setEvaluatingDecl(Base, Result.Val);
16902 if (Info.EnableNewConstInterp) {
16903 if (!Info.Ctx.getInterpContext().evaluateAsRValue(Info, this, Result.Val))
16912 FullExpressionRAII Scope(Info);
16913 if (!::EvaluateInPlace(Result.Val, Info, LVal, this) ||
16917 if (!Info.discardCleanups())
16921 if (!CheckConstantExpression(Info, getExprLoc(), getStorageType(Ctx, this),
16924 if (!CheckMemoryLeaks(Info))
16958 EvalInfo Info(Ctx, EStatus,
16963 Info.setEvaluatingDecl(VD, Value);
16964 Info.InConstantContext = IsConstantInitialization;
16969 if (Info.EnableNewConstInterp) {
16971 if (!InterpCtx.evaluateAsInitializer(Info, VD, Value))
16974 return CheckConstantExpression(Info, DeclLoc, DeclTy, Value,
16990 FullExpressionRAII Scope(Info);
16991 if (!EvaluateInPlace(Value, Info, LVal, this,
16999 Info.performLifetimeExtension();
17001 if (!Info.discardCleanups())
17005 return CheckConstantExpression(Info, DeclLoc, DeclTy, Value,
17007 CheckMemoryLeaks(Info);
17057 EvalInfo Info(Ctx, EVResult, EvalInfo::EM_IgnoreSideEffects);
17058 Info.InConstantContext = true;
17060 bool Result = ::EvaluateAsRValue(this, EVResult, Ctx, Info);
17076 EvalInfo Info(Ctx, EVResult, EvalInfo::EM_IgnoreSideEffects);
17077 Info.InConstantContext = true;
17078 Info.CheckingForUndefinedBehavior = true;
17080 bool Result = ::EvaluateAsRValue(Info, this, EVResult.Val);
17096 EvalInfo Info(Ctx, EVResult, EvalInfo::EM_IgnoreSideEffects);
17097 Info.CheckingForUndefinedBehavior = true;
17098 (void)::EvaluateAsRValue(Info, this, EVResult.Val);
17151 EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantExpression);
17153 Info.InConstantContext = true;
17154 if (!::EvaluateAsRValue(E, EVResult, Ctx, Info) || EVResult.HasSideEffects ||
17629 EvalInfo Info(Ctx, Status, EvalInfo::EM_IgnoreSideEffects);
17630 Info.InConstantContext = true;
17632 if (!::EvaluateAsInt(this, ExprResult, Ctx, SE_AllowSideEffects, Info))
17658 EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantExpression);
17662 ::EvaluateAsRValue(Info, this, Result ? *Result : Scratch) &&
17665 Info.discardCleanups() && !Status.HasSideEffects;
17694 EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantExpressionUnevaluated);
17695 Info.InConstantContext = true;
17707 EvaluateObjectArgument(Info, This, ThisVal) &&
17708 !Info.EvalStatus.HasSideEffects)
17713 Info.EvalStatus.HasSideEffects = false;
17716 CallRef Call = Info.CurrentCall->createCall(Callee);
17724 !EvaluateCallArg(PVD, *I, Call, Info) ||
17725 Info.EvalStatus.HasSideEffects) {
17727 if (APValue *Slot = Info.getParamSlot(Call, PVD))
17733 Info.EvalStatus.HasSideEffects = false;
17738 Info.discardCleanups();
17739 Info.EvalStatus.HasSideEffects = false;
17742 CallStackFrame Frame(Info, Callee->getLocation(), Callee, ThisPtr, This,
17745 FullExpressionRAII Scope(Info);
17746 return Evaluate(Value, Info, this) && Scope.destroy() &&
17747 !Info.EvalStatus.HasSideEffects;
17770 EvalInfo Info(FD->getASTContext(), Status, EvalInfo::EM_ConstantExpression);
17771 Info.InConstantContext = true;
17772 Info.CheckingPotentialConstantExpression = true;
17775 if (Info.EnableNewConstInterp) {
17776 Info.Ctx.getInterpContext().isPotentialConstantExpr(Info, FD);
17786 ImplicitValueInitExpr VIE(RD ? Info.Ctx.getRecordType(RD) : Info.Ctx.IntTy);
17787 This.set({&VIE, Info.CurrentCall->Index});
17795 Info.setEvaluatingDecl(This.getLValueBase(), Scratch);
17796 HandleConstructorCall(&VIE, This, Args, CD, Info, Scratch);
17801 &VIE, Args, CallRef(), FD->getBody(), Info, Scratch,
17818 EvalInfo Info(FD->getASTContext(), Status,
17820 Info.InConstantContext = true;
17821 Info.CheckingPotentialConstantExpression = true;
17824 CallStackFrame Frame(Info, SourceLocation(), FD, /*This=*/nullptr,
17828 Evaluate(ResultScratch, Info, E);
17838 EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantFold);
17839 return tryEvaluateBuiltinObjectSize(this, Type, Info, Result);
17843 EvalInfo &Info, std::string *StringResult) {
17849 if (!EvaluatePointer(E, String, Info))
17862 Info.Ctx.hasSameUnqualifiedType(CharTy, Info.Ctx.CharTy)) {
17881 if (!handleLValueToRValueConversion(Info, E, CharTy, String, Char) ||
17889 if (!HandleLValueArrayAdjustment(Info, E, String, CharTy, 1))
17896 EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantFold);
17900 if (EvaluateBuiltinStrLen(this, Result, Info, &StringResult))
17910 EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantExpression);
17911 Info.InConstantContext = true;
17913 FullExpressionRAII Scope(Info);
17915 if (!::EvaluateInteger(SizeExpression, SizeValue, Info))
17920 if (!::EvaluatePointer(PtrExpression, String, Info))
17926 if (!handleLValueToRValueConversion(Info, PtrExpression, CharTy, String,
17932 if (!HandleLValueArrayAdjustment(Info, PtrExpression, String, CharTy, 1))
17938 if (!CheckMemoryLeaks(Info))
17946 EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantFold);
17947 return EvaluateBuiltinStrLen(this, Result, Info);
17952 EvalInfo &Info;
17964 EvalInfo &Info = IEE.Info;
17969 if (!Info.InConstantContext)
17976 if (!EvaluatePointer(Arg, Val, Info))
17984 const auto *Callee = Info.CurrentCall->getCallee();
17989 Info.CCEDiag(CalledFromStd ? Info.CurrentCall->getCallRange().getBegin()
18021 findCompleteObject(Info, E, AccessKinds::AK_IsWithinLifetime, Val, T);
18024 if (Info.EvaluatingDeclValue && CO.Value == Info.EvaluatingDeclValue)
18029 IsWithinLifetimeHandler handler{Info};
18030 return findSubobject(Info, E, CO, Val.getLValueDesignator(), handler);