Home | History | Annotate | Download | only in AST

Lines Matching defs:Ctx

115   unsigned findMostDerivedSubobject(ASTContext &Ctx, QualType Base,
124 cast<ConstantArrayType>(Ctx.getAsArrayType(Type));
193 SubobjectDesignator(ASTContext &Ctx, const APValue &V)
204 findMostDerivedSubobject(Ctx, getType(V.getLValueBase()),
437 ASTContext &Ctx;
538 : Ctx(const_cast<ASTContext &>(C)), EvalStatus(S), CurrentCall(nullptr),
551 const LangOptions &getLangOpts() const { return Ctx.getLangOpts(); }
592 PartialDiagnostic PD(DiagId, Ctx.getDiagAllocator());
631 unsigned Limit = Ctx.getDiagnostics().getConstexprBacktraceLimit();
1013 void setFrom(ASTContext &Ctx, const APValue &V) {
1019 Designator = SubobjectDesignator(Ctx, V);
1208 Val.printPretty(Out, Frame->Info.Ctx,
1222 Arg.printPretty(Out, Frame->Info.Ctx, Param->getType());
1405 if (!E->isRValue() || E->getType()->isLiteralType(Info.Ctx))
1480 LVal.setFrom(Info.Ctx, Value);
1584 unsigned DestWidth = Info.Ctx.getIntWidth(DestType);
1601 if (Result.convert(Info.Ctx.getFloatTypeSemantics(DestType),
1611 unsigned DestWidth = Info.Ctx.getIntWidth(DestType);
1623 Result = APFloat(Info.Ctx.getFloatTypeSemantics(DestType), 1);
1646 unsigned NewBitWidth = FD->getBitWidthValue(Info.Ctx);
1667 unsigned VecSize = Info.Ctx.getTypeSize(VecTy);
1669 unsigned EltSize = Info.Ctx.getTypeSize(EltTy);
1670 bool BigEndian = Info.Ctx.getTargetInfo().isBigEndian();
1716 Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
1871 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
1889 RL = &Info.Ctx.getASTRecordLayout(Derived);
1916 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(DerivedDecl);
1942 RL = &Info.Ctx.getASTRecordLayout(FD->getParent());
1946 LVal.Offset += Info.Ctx.toCharUnitsFromBits(RL->getFieldOffset(I));
1978 Size = Info.Ctx.getTypeSizeInChars(Type);
2124 Info.Ctx.getAsConstantArrayType(S->getType());
2129 APSInt Value(S->getCharByteWidth() * Info.Ctx.getCharWidth(),
2141 Info.Ctx.getAsConstantArrayType(S->getType());
2149 APSInt Value(S->getCharByteWidth() * Info.Ctx.getCharWidth(),
2318 const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(ObjType);
2426 ObjType = Info.Ctx.getRecordType(Base);
2637 if (const VarDecl *VDef = VD->getDefinition(Info.Ctx))
2738 BaseVal = Info.Ctx.getMaterializedTemporaryValue(MTE, false);
2767 BaseType = Info.Ctx.getCanonicalType(BaseType);
2846 static bool isOverflowingIntegerType(ASTContext &Ctx, QualType T) {
2848 Ctx.getIntWidth(T) >= Ctx.getIntWidth(Ctx.IntTy);
2936 LVal.setFrom(Info.Ctx, Subobj);
3045 isOverflowingIntegerType(Info.Ctx, SubobjType)) {
3053 isOverflowingIntegerType(Info.Ctx, SubobjType)) {
3088 LVal.setFrom(Info.Ctx, Subobj);
3127 if (Object->getType()->isLiteralType(Info.Ctx))
3400 APSInt LHS = CS->getLHS()->EvaluateKnownConstInt(Info.Ctx);
3401 APSInt RHS = CS->getRHS() ? CS->getRHS()->EvaluateKnownConstInt(Info.Ctx)
3834 RHS.setFrom(Info.Ctx, ArgValues[0]);
3839 if (!handleAssignment(Info, Args[0], *This, MD->getThisType(Info.Ctx),
3904 RHS.setFrom(Info.Ctx, ArgValues[0]);
3915 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
3937 assert(Info.Ctx.hasSameType(BaseIt->getType(), BaseType) &&
4261 if (!Info.Ctx.hasSameType(CalleeType->getPointeeType(), FD->getType()))
4454 Result.setFrom(this->Info.Ctx, V);
4678 Value = Info.Ctx.getMaterializedTemporaryValue(E, true);
4878 Result.setFrom(Info.Ctx, V);
5014 unsigned Size = Info.Ctx.getTypeSize(E->getType());
5024 Result.setFrom(Info.Ctx, Value);
5040 = Info.Ctx.getAsConstantArrayType(SubExpr->getType()))
5061 return Info.Ctx.toCharUnitsFromBits(
5062 Info.Ctx.getPreferredTypeAlign(T.getTypePtr()));
5075 return Info.Ctx.getDeclAlign(DRE->getDecl(),
5079 return Info.Ctx.getDeclAlign(ME->getMemberDecl(),
5119 BaseAlignment = Info.Ctx.getDeclAlign(VD);
5296 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
5393 const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
5444 ImplicitValueInitExpr VIE(HaveInit ? Info.Ctx.IntTy : Field->getType());
5509 Info.Ctx.getAsConstantArrayType(E->getSubExpr()->getType());
5526 !Info.Ctx.hasSameType(Field->getType()->getPointeeType(),
5538 Info.Ctx.hasSameType(Field->getType()->getPointeeType(),
5546 } else if (Info.Ctx.hasSameType(Field->getType(), Info.Ctx.getSizeType()))
5693 unsigned EltSize = Info.Ctx.getTypeSize(EltTy);
5694 bool BigEndian = Info.Ctx.getTargetInfo().isBigEndian();
5697 const llvm::fltSemantics &Sem = Info.Ctx.getFloatTypeSemantics(EltTy);
5759 sInt = Info.Ctx.MakeIntValue(0, EltTy);
5768 f = APFloat::getZero(Info.Ctx.getFloatTypeSemantics(EltTy));
5783 ZeroElement = APValue(Info.Ctx.MakeIntValue(0, EltTy));
5786 APValue(APFloat::getZero(Info.Ctx.getFloatTypeSemantics(EltTy)));
5820 Info.Ctx.getAsConstantArrayType(E->getType());
5853 const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(E->getType());
5931 if (const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(Type)) {
6012 assert(SI.getBitWidth() == Info.Ctx.getIntWidth(E->getType()) &&
6024 assert(I.getBitWidth() == Info.Ctx.getIntWidth(E->getType()) &&
6038 Result = APValue(Info.Ctx.MakeIntValue(Value, E->getType()));
6169 == Info.Ctx.getIntWidth(E->getType()));
6179 Val = Val.extOrTrunc(Info.Ctx.getIntWidth(E->getType()));
6254 static bool EvaluateBuiltinConstantP(ASTContext &Ctx, const Expr *Arg) {
6272 if (!Arg->EvaluateAsRValue(Result, Ctx) || Result.HasSideEffects)
6281 return Arg->isEvaluatable(Ctx);
6285 EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantFold);
6349 static bool isDesignatorAtObjectEnd(const ASTContext &Ctx, const LValue &LVal) {
6352 auto IsLastFieldDecl = [&Ctx](const FieldDecl *FD) {
6355 const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(FD->getParent());
6378 auto *CAT = cast<ConstantArrayType>(Ctx.getAsArrayType(BaseType));
6453 Base.setFrom(Info.Ctx, RVal);
6544 isDesignatorAtObjectEnd(Info.Ctx, End))
6572 E->getArg(1)->EvaluateKnownConstInt(Info.Ctx).getZExtValue();
6578 if (E->getArg(0)->HasSideEffects(Info.Ctx))
6630 return Success(EvaluateBuiltinConstantP(Info.Ctx, E->getArg(0)), E);
6646 int Operand = E->getArg(0)->EvaluateKnownConstInt(Info.Ctx).getZExtValue();
6647 Operand = Info.Ctx.getTargetInfo().getEHDataRegisterNumber(Operand);
6800 Info.Ctx.getTargetInfo().getMaxAtomicInlineWidth();
6801 if (Size <= Info.Ctx.toCharUnitsFromBits(InlineWidthBits)) {
6804 E->getArg(1)->isNullPointerConstant(Info.Ctx,
6813 Info.Ctx.getTypeAlignInChars(PointeeType) >= Size) {
6848 static bool isOnePastTheEndOfCompleteObject(const ASTContext &Ctx,
6869 auto Size = Ctx.getTypeSizeInChars(Ty);
7134 APSInt Value(Info.Ctx.getIntWidth(E->getType()),
7347 isOnePastTheEndOfCompleteObject(Info.Ctx, RHSValue)) ||
7349 Ctx, LHSValue)))
7410 APSInt Result = TrueResult.trunc(Info.Ctx.getIntWidth(E->getType()));
7473 unsigned PtrSize = Info.Ctx.getTypeSize(LHSTy);
7488 CharUnits Size = Info.Ctx.getTypeSizeInChars(BaseTy);
7604 Info.Ctx.toCharUnitsFromBits(
7605 Info.Ctx.getOpenMPDefaultSimdAlign(E->getArgumentType()))
7627 const ArrayType *AT = Info.Ctx.getAsArrayType(CurrentType);
7631 CharUnits ElementSize = Info.Ctx.getTypeSizeInChars(CurrentType);
7643 const ASTRecordLayout &RL = Info.Ctx.getASTRecordLayout(RD);
7646 Result += Info.Ctx.toCharUnitsFromBits(RL.getFieldOffset(i));
7665 const ASTRecordLayout &RL = Info.Ctx.getASTRecordLayout(RD);
7803 return Info.Ctx.getTypeSize(DestType) <= Info.Ctx.getTypeSize(SrcType);
7805 return Info.Ctx.getTypeSize(DestType) == Info.Ctx.getTypeSize(SrcType);
7824 if (Info.Ctx.getTypeSize(DestType) != Info.Ctx.getTypeSize(SrcType))
7832 APSInt AsInt = Info.Ctx.MakeIntValue(LV.getLValueOffset().getQuantity(),
7912 Result = APFloat::getZero(Info.Ctx.getFloatTypeSemantics(E->getType()));
7985 Info.Ctx.getFloatTypeSemantics(E->getType());
7993 if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0),
8003 if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0),
8057 const llvm::fltSemantics &Sem = Info.Ctx.getFloatTypeSemantics(E->getType());
8165 APFloat Zero = APFloat::getZero(Info.Ctx.getFloatTypeSemantics(ElemTy));
8170 APSInt Zero = Info.Ctx.MakeIntValue(0, ElemTy);
8803 LV.setFrom(Info.Ctx, Result);
8813 const ASTContext &Ctx, bool &IsConst) {
8834 !Ctx.getLangOpts().CPlusPlus11) {
8847 bool Expr::EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const {
8849 if (FastEvaluateAsRValue(this, Result, Ctx, IsConst))
8852 EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
8857 const ASTContext &Ctx) const {
8859 return EvaluateAsRValue(Scratch, Ctx) &&
8869 bool Expr::EvaluateAsInt(APSInt &Result, const ASTContext &Ctx,
8875 if (!EvaluateAsRValue(ExprResult, Ctx) || !ExprResult.Val.isInt() ||
8883 bool Expr::EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx) const {
8884 EvalInfo Info(Ctx, Result, EvalInfo::EM_ConstantFold);
8889 Ctx.getLValueReferenceType(getType()), LV))
8896 bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx,
8902 !Ctx.getLangOpts().CPlusPlus11)
8908 EvalInfo InitInfo(Ctx, EStatus, VD->isConstexpr()
8920 if (Ctx.getLangOpts().CPlusPlus && !VD->hasLocalStorage() &&
8939 bool Expr::isEvaluatable(const ASTContext &Ctx, SideEffectsKind SEK) const {
8941 return EvaluateAsRValue(Result, Ctx) &&
8945 APSInt Expr::EvaluateKnownConstInt(const ASTContext &Ctx,
8949 bool Result = EvaluateAsRValue(EvalResult, Ctx);
8957 void Expr::EvaluateForOverflow(const ASTContext &Ctx) const {
8960 if (!FastEvaluateAsRValue(this, EvalResult, Ctx, IsConst)) {
8961 EvalInfo Info(Ctx, EvalResult, EvalInfo::EM_EvaluateForOverflow);
9013 static ICEDiag CheckEvalInICE(const Expr* E, const ASTContext &Ctx) {
9015 if (!E->EvaluateAsRValue(EVResult, Ctx) || EVResult.HasSideEffects ||
9022 static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
9113 return CheckICE(cast<InitListExpr>(E)->getInit(0), Ctx);
9124 CheckICE(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(), Ctx);
9127 return CheckICE(cast<ParenExpr>(E)->getSubExpr(), Ctx);
9129 return CheckICE(cast<GenericSelectionExpr>(E)->getResultExpr(), Ctx);
9147 return CheckEvalInICE(E, Ctx);
9154 if (Ctx.getLangOpts().CPlusPlus &&
9201 return CheckICE(Exp->getSubExpr(), Ctx);
9213 return CheckEvalInICE(E, Ctx);
9260 ICEDiag LHSResult = CheckICE(Exp->getLHS(), Ctx);
9261 ICEDiag RHSResult = CheckICE(Exp->getRHS(), Ctx);
9267 llvm::APSInt REval = Exp->getRHS()->EvaluateKnownConstInt(Ctx);
9271 llvm::APSInt LEval = Exp->getLHS()->EvaluateKnownConstInt(Ctx);
9278 if (Ctx.getLangOpts().C99) {
9292 ICEDiag LHSResult = CheckICE(Exp->getLHS(), Ctx);
9293 ICEDiag RHSResult = CheckICE(Exp->getRHS(), Ctx);
9299 (Exp->getLHS()->EvaluateKnownConstInt(Ctx) == 0))
9319 unsigned DestWidth = Ctx.getIntWidth(E->getType());
9340 return CheckICE(SubExpr, Ctx);
9347 ICEDiag CommonResult = CheckICE(Exp->getCommon(), Ctx);
9349 ICEDiag FalseResult = CheckICE(Exp->getFalseExpr(), Ctx);
9353 Exp->getCommon()->EvaluateKnownConstInt(Ctx) != 0) return NoDiag();
9365 return CheckEvalInICE(E, Ctx);
9366 ICEDiag CondResult = CheckICE(Exp->getCond(), Ctx);
9370 ICEDiag TrueResult = CheckICE(Exp->getTrueExpr(), Ctx);
9371 ICEDiag FalseResult = CheckICE(Exp->getFalseExpr(), Ctx);
9384 if (Exp->getCond()->EvaluateKnownConstInt(Ctx) == 0)
9389 return CheckICE(cast<CXXDefaultArgExpr>(E)->getExpr(), Ctx);
9391 return CheckICE(cast<CXXDefaultInitExpr>(E)->getExpr(), Ctx);
9393 return CheckICE(cast<ChooseExpr>(E)->getChosenSubExpr(), Ctx);
9401 static bool EvaluateCPlusPlus11IntegralConstantExpr(const ASTContext &Ctx,
9411 if (!E->isCXX11ConstantExpr(Ctx, &Result, Loc))
9423 bool Expr::isIntegerConstantExpr(const ASTContext &Ctx,
9425 if (Ctx.getLangOpts().CPlusPlus11)
9426 return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, nullptr, Loc);
9428 ICEDiag D = CheckICE(this, Ctx);
9436 bool Expr::isIntegerConstantExpr(llvm::APSInt &Value, const ASTContext &Ctx,
9438 if (Ctx.getLangOpts().CPlusPlus11)
9439 return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc);
9441 if (!isIntegerConstantExpr(Ctx, Loc))
9447 if (!EvaluateAsInt(Value, Ctx, SE_AllowSideEffects))
9452 bool Expr::isCXX98IntegralConstantExpr(const ASTContext &Ctx) const {
9453 return CheckICE(this, Ctx).Kind == IK_ICE;
9456 bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result,
9460 assert(Ctx.getLangOpts().CPlusPlus);
9466 EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantExpression);
9482 bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
9486 EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantExpressionUnevaluated);
9526 ImplicitValueInitExpr VIE(RD ? Info.Ctx.getRecordType(RD) : Info.Ctx.IntTy);
9570 bool Expr::tryEvaluateObjectSize(uint64_t &Result, ASTContext &Ctx,
9576 EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantFold);