Home | History | Annotate | Download | only in AST

Lines Matching refs:Result

19 //  * An evaluated result, valid only if constant folding has not failed.
23 // where it is possible to determine the evaluated result regardless.
913 APValue &Result = Temporaries[Key];
914 assert(Result.isUninit() && "temporary created multiple times");
915 Info.CleanupStack.push_back(Cleanup(&Result, IsLifetimeExtended));
916 return Result;
1127 // derived class of the class containing the original member, the result
1174 static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E);
1175 static bool EvaluateInPlace(APValue &Result, EvalInfo &Info,
1178 static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info);
1179 static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info);
1180 static bool EvaluateMemberPointer(const Expr *E, MemberPtr &Result,
1182 static bool EvaluateTemporary(const Expr *E, LValue &Result, EvalInfo &Info);
1183 static bool EvaluateInteger(const Expr *E, APSInt &Result, EvalInfo &Info);
1184 static bool EvaluateIntegerOrLValue(const Expr *E, APValue &Result,
1186 static bool EvaluateFloat(const Expr *E, APFloat &Result, EvalInfo &Info);
1188 static bool EvaluateAtomic(const Expr *E, APValue &Result, EvalInfo &Info);
1189 static bool EvaluateAsRValue(EvalInfo &Info, const Expr *E, APValue &Result);
1232 /// result.
1515 static bool EvalPointerValueAsBool(const APValue &Value, bool &Result) {
1519 Result = !Value.getLValueOffset().isZero();
1525 Result = true;
1530 static bool HandleConversionToBool(const APValue &Val, bool &Result) {
1535 Result = Val.getInt().getBoolValue();
1538 Result = !Val.getFloat().isZero();
1541 Result = Val.getComplexIntReal().getBoolValue() ||
1545 Result = !Val.getComplexFloatReal().isZero() ||
1549 return EvalPointerValueAsBool(Val, Result);
1551 Result = Val.getMemberPointerDecl();
1564 static bool EvaluateAsBooleanCondition(const Expr *E, bool &Result,
1570 return HandleConversionToBool(Val, Result);
1583 QualType DestType, APSInt &Result) {
1588 Result = APSInt(DestWidth, !DestSigned);
1590 if (Value.convertToInteger(Result, llvm::APFloat::rmTowardZero, &ignored)
1598 APFloat &Result) {
1599 APFloat Value = Result;
1601 if (Result.convert(Info.Ctx.getFloatTypeSemantics(DestType),
1612 APSInt Result = Value;
1615 Result = Result.extOrTrunc(DestWidth);
1616 Result.setIsUnsigned(DestType->isUnsignedIntegerOrEnumerationType());
1617 return Result;
1622 QualType DestType, APFloat &Result) {
1623 Result = APFloat(Info.Ctx.getFloatTypeSemantics(DestType), 1);
1624 if (Result.convertFromAPInt(Value, Value.isSigned(),
1706 APSInt &Result) {
1708 Result = Op(LHS, RHS);
1713 Result = Value.trunc(LHS.getBitWidth());
1714 if (Result.extend(BitWidth) != Value) {
1718 << Result.toString(10) << E->getType();
1728 APSInt &Result) {
1735 std::multiplies<APSInt>(), Result);
1738 std::plus<APSInt>(), Result);
1741 std::minus<APSInt>(), Result);
1742 case BO_And: Result = LHS & RHS; return true;
1743 case BO_Xor: Result = LHS ^ RHS; return true;
1744 case BO_Or: Result = LHS | RHS; return true;
1751 Result = (Opcode == BO_Rem ? LHS % RHS : LHS / RHS);
1753 // this operation and gives the two's complement result.
1787 Result = LHS << SA;
1810 Result = LHS >> SA;
1814 case BO_LT: Result = LHS < RHS; return true;
1815 case BO_GT: Result = LHS > RHS; return true;
1816 case BO_LE: Result = LHS <= RHS; return true;
1817 case BO_GE: Result = LHS >= RHS; return true;
1818 case BO_EQ: Result = LHS == RHS; return true;
1819 case BO_NE: Result = LHS != RHS; return true;
1854 static bool CastToDerivedClass(EvalInfo &Info, const Expr *E, LValue &Result,
1857 SubobjectDesignator &D = Result.Designator;
1864 if (!Result.checkSubobject(Info, E, CSK_Derived))
1874 Result.Offset -= Layout.getVBaseClassOffset(Base);
1876 Result.Offset -= Layout.getBaseClassOffset(Base);
1923 QualType Type, LValue &Result) {
1927 if (!HandleLValueBase(Info, E, Result, Type->getAsCXXRecordDecl(),
2026 /// \param Result Filled in with a pointer to the value of the variable.
2029 APValue *&Result) {
2041 Result = &Frame->Arguments[PVD->getFunctionScopeIndex()];
2047 Result = Frame->getTemporary(VD);
2048 assert(Result && "missing value for local variable");
2065 Result = Info.EvaluatingDeclValue;
2092 Result = VD->getEvaluatedValue();
2138 APValue &Result) {
2147 Result = APValue(APValue::UninitArray(),
2151 if (Result.hasArrayFiller())
2152 Result.getArrayFiller() = APValue(Value);
2153 for (unsigned I = 0, N = Result.getArrayInitializedElts(); I != N; ++I) {
2155 Result.getArrayInitializedElt(I) = APValue(Value);
2436 APValue &Result;
2443 Result = Subobj;
2447 Result = APValue(Value);
2451 Result = APValue(Value);
2455 Result = APValue(extractStringLiteralCharacter(
2468 APValue &Result) {
2469 ExtractSubobjectHandler Handler = { Info, Result };
3135 /// lvalue referring to the result.
3248 LValue &Result) {
3249 SubobjectDesignator &D = Result.Designator;
3250 if (D.Invalid || !Result.checkNullPointer(Info, E, CSK_Derived))
3280 return CastToDerivedClass(Info, E, Result, TargetType, NewEntriesSize);
3306 LValue Result;
3307 Result.set(VD, Info.CurrentCall->Index);
3321 if (!EvaluateInPlace(Val, Info, Result, InitE)) {
3334 const Expr *Cond, bool &Result) {
3338 return EvaluateAsBooleanCondition(Cond, Result, Info);
3341 /// \brief A location where the result (returned value) of evaluating a
3346 /// The location containing the result, if any (used to support RVO).
3350 static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
3354 /// Evaluate the body of a loop, and translate the result as appropriate.
3355 static EvalStmtResult EvaluateLoopBody(StmtResult &Result, EvalInfo &Info,
3359 switch (EvalStmtResult ESR = EvaluateStmt(Result, Info, Body, Case)) {
3374 static EvalStmtResult EvaluateSwitch(StmtResult &Result, EvalInfo &Info,
3413 switch (EvalStmtResult ESR = EvaluateStmt(Result, Info, SS->getBody(), Found)) {
3431 static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
3468 EvalStmtResult ESR = EvaluateStmt(Result, Info, IS->getThen(), Case);
3471 return EvaluateStmt(Result, Info, IS->getElse(), Case);
3476 EvaluateLoopBody(Result, Info, cast<WhileStmt>(S)->getBody(), Case);
3485 EvaluateLoopBody(Result, Info, FS->getBody(), Case);
3538 !(Result.Slot
3539 ? EvaluateInPlace(Result.Value, Info, *Result.Slot, RetExpr)
3540 : Evaluate(Result.Value, Info, RetExpr)))
3550 EvalStmtResult ESR = EvaluateStmt(Result, Info, BI, Case);
3569 EvalStmtResult ESR = EvaluateStmt(Result, Info, SubStmt);
3587 EvalStmtResult ESR = EvaluateLoopBody(Result, Info, WS->getBody());
3598 EvalStmtResult ESR = EvaluateLoopBody(Result, Info, DS->getBody(), Case);
3614 EvalStmtResult ESR = EvaluateStmt(Result, Info, FS->getInit());
3627 EvalStmtResult ESR = EvaluateLoopBody(Result, Info, FS->getBody());
3645 EvalStmtResult ESR = EvaluateStmt(Result, Info, FS->getRangeStmt());
3650 ESR = EvaluateStmt(Result, Info, FS->getBeginEndStmt());
3667 ESR = EvaluateStmt(Result, Info, FS->getLoopVarStmt());
3672 ESR = EvaluateLoopBody(Result, Info, FS->getBody());
3685 return EvaluateSwitch(Result, Info, cast<SwitchStmt>(S));
3694 return EvaluateStmt(Result, Info, cast<LabelStmt>(S)->getSubStmt(), Case);
3699 return EvaluateStmt(Result, Info, cast<AttributedStmt>(S)->getSubStmt(),
3704 return EvaluateStmt(Result, Info, cast<SwitchCase>(S)->getSubStmt(), Case);
3810 EvalInfo &Info, APValue &Result,
3842 This->moveInto(Result);
3846 StmtResult Ret = {Result, ResultSlot};
3860 EvalInfo &Info, APValue &Result) {
3886 if (!EvaluateInPlace(Result, Info, This, (*I)->getInit()))
3906 RHS, Result);
3910 if (!RD->isUnion() && Result.isUninit())
3911 Result = APValue(APValue::UninitStruct(), RD->getNumBases(),
3927 APValue *Value = &Result;
3944 Value = &Result.getStructBase(BasesSeen++);
3949 Result = APValue(FD);
3950 Value = &Result.getUnionValue();
3952 Value = &Result.getStructField(FD->getFieldIndex());
4137 APValue Result;
4138 if (!handleLValueToRValueConversion(Info, E, E->getType(), Obj, Result))
4140 return DerivedSuccess(Result, E);
4158 // the result is a constant expression if it can be folded without
4195 APValue Result;
4196 if (!handleCallExpr(E, Result, nullptr))
4198 return DerivedSuccess(Result, E);
4201 bool handleCallExpr(const CallExpr *E, APValue &Result,
4280 Result, ResultSlot))
4326 APValue Result;
4327 return extractSubobject(Info, E, Obj, Designator, Result) &&
4328 DerivedSuccess(Result, E);
4408 StmtResult Result = { ReturnValue, nullptr };
4409 EvalStmtResult ESR = EvaluateStmt(Result, Info, *BI);
4440 LValue &Result;
4445 Result.set(B);
4450 LValueExprEvaluatorBase(EvalInfo &Info, LValue &Result) :
4451 ExprEvaluatorBaseTy(Info), Result(Result) {}
4454 Result.setFrom(this->Info.Ctx, V);
4463 EvalOK = EvaluatePointer(E->getBase(), Result, this->Info);
4467 EvalOK = EvaluateTemporary(E->getBase(), Result, this->Info);
4476 Result.setInvalid(E);
4485 if (!HandleLValueMember(this->Info, E, Result, FD))
4488 if (!HandleLValueIndirectMember(this->Info, E, Result, IFD))
4495 if (!handleLValueToRValueConversion(this->Info, E, MD->getType(), Result,
4510 return HandleMemberPointerAccess(this->Info, E, Result);
4527 Result);
4568 LValueExprEvaluator(EvalInfo &Info, LValue &Result) :
4569 LValueExprEvaluatorBaseTy(Info, Result) {}
4605 Result.Designator.setInvalid();
4611 return HandleBaseToDerivedCast(Info, E, Result);
4622 static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info) {
4625 return LValueExprEvaluator(Info, Result).Visit(E);
4643 Result.set(VD, Frame->Index);
4674 // result of a constant expression evaluation, so we need to preserve its
4680 Result.set(E);
4684 Result.set(E, Info.CurrentCall->Index);
4690 if (!EvaluateInPlace(*Value, Info, Result, Inner) ||
4703 Type, Result))
4709 if (!HandleLValueMember(Info, E, Result, Adjustments[I].Field))
4715 if (!HandleMemberPointerAccess(this->Info, Type, Result,
4772 if (!EvaluatePointer(E->getBase(), Result, Info))
4779 return HandleLValueArrayAdjustment(Info, E, Result, E->getType(),
4784 return EvaluatePointer(E->getSubExpr(), Result, Info);
4792 HandleLValueComplexElement(Info, E, Result, E->getType(), false);
4801 HandleLValueComplexElement(Info, E, Result, E->getType(), true);
4813 this->Info, UO, Result, UO->getSubExpr()->getType(),
4824 // The overall lvalue result is the result of evaluating the LHS.
4836 Result, CAO->getLHS()->getType(), CAO->getComputationLHSType(),
4855 return handleAssignment(this->Info, E, Result, E->getLHS()->getType(),
4866 LValue &Result;
4869 Result.set(E);
4874 PointerExprEvaluator(EvalInfo &info, LValue &Result)
4875 : ExprEvaluatorBaseTy(info), Result(Result) {}
4878 Result.setFrom(Info.Ctx, V);
4911 Result = *Info.CurrentCall->This;
4919 static bool EvaluatePointer(const Expr* E, LValue& Result, EvalInfo &Info) {
4921 return PointerExprEvaluator(Info, Result).Visit(E);
4934 bool EvalPtrOK = EvaluatePointer(PExp, Result, Info);
4947 return HandleLValueArrayAdjustment(Info, E, Result, Pointee,
4952 return EvaluateLValue(E->getSubExpr(), Result, Info);
4973 Result.Designator.setInvalid();
4984 if (!EvaluatePointer(E->getSubExpr(), Result, Info))
4986 if (!Result.Base && Result.Offset.isZero())
4993 Result);
4998 if (!Result.Base && Result.Offset.isZero())
5000 return HandleBaseToDerivedCast(Info, E, Result);
5016 Result.Base = (Expr*)nullptr;
5017 Result.InvalidBase = false;
5018 Result.Offset = CharUnits::fromQuantity(N);
5019 Result.CallIndex = 0;
5020 Result.Designator.setInvalid();
5024 Result.setFrom(Info.Ctx, Value);
5030 if (!EvaluateLValue(SubExpr, Result, Info))
5033 Result.set(SubExpr, Info.CurrentCall->Index);
5035 Info, Result, SubExpr))
5038 // The result is a pointer to the first element of the array.
5041 Result.addArray(Info, E, CAT);
5043 Result.Designator.setInvalid();
5047 return EvaluateLValue(SubExpr, Result, Info);
5055 // When alignof is applied to a reference type, the result is the
5091 return EvaluateLValue(E->getArg(0), Result, Info);
5096 if (!EvaluatePointer(E->getArg(0), Result, Info))
5099 LValue OffsetResult(Result);
5126 Result.Designator.setInvalid();
5139 Result.Designator.setInvalid();
5169 MemberPtr &Result;
5172 Result = MemberPtr(D);
5177 MemberPointerExprEvaluator(EvalInfo &Info, MemberPtr &Result)
5178 : ExprEvaluatorBaseTy(Info), Result(Result) {}
5181 Result.setFrom(V);
5193 static bool EvaluateMemberPointer(const Expr *E, MemberPtr &Result,
5196 return MemberPointerExprEvaluator(Info, Result).Visit(E);
5221 if (!Result.castToDerived(Derived))
5225 if (!Result.castToDerived(FinalTy->getAsCXXRecordDecl()))
5237 if (!Result.castToBase(Base))
5258 APValue &Result;
5261 RecordExprEvaluator(EvalInfo &info, const LValue &This, APValue &Result)
5262 : ExprEvaluatorBaseTy(info), This(This), Result(Result) {}
5265 Result = V;
5271 return handleCallExpr(E, Result, &This);
5289 const LValue &This, APValue &Result) {
5292 Result = APValue(APValue::UninitStruct(), CD ? CD->getNumBases() : 0,
5307 Result.getStructBase(Index)))
5323 Result.getStructField(I->getFieldIndex()), Info, Subobject, &VIE))
5338 Result = APValue((const FieldDecl*)nullptr);
5345 Result = APValue(*I);
5347 return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, &VIE);
5355 return HandleClassZeroInitialization(Info, E, RD, This, Result);
5384 Result = *Value;
5397 Result = APValue(Field);
5417 return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr);
5422 Result = APValue(APValue::UninitStruct(), 0,
5451 APValue &FieldVal = Result.getStructField(Field->getFieldIndex());
5471 if (!Result.isUninit())
5503 Result);
5531 Result = APValue(APValue::UninitStruct(), 0, 2);
5532 Array.moveInto(Result.getStructField(0));
5545 Array.moveInto(Result.getStructField(1));
5548 Result.getStructField(1) = APValue(APSInt(ArrayType->getSize()));
5559 APValue &Result, EvalInfo &Info) {
5562 return RecordExprEvaluator(Info, This, Result).Visit(E);
5576 TemporaryExprEvaluator(EvalInfo &Info, LValue &Result) :
5577 LValueExprEvaluatorBaseTy(Info, Result) {}
5581 Result.set(E, Info.CurrentCall->Index);
5583 Info, Result, E);
5611 static bool EvaluateTemporary(const Expr *E, LValue &Result, EvalInfo &Info) {
5613 return TemporaryExprEvaluator(Info, Result).Visit(E);
5623 APValue &Result;
5626 VectorExprEvaluator(EvalInfo &info, APValue &Result)
5627 : ExprEvaluatorBaseTy(info), Result(Result) {}
5632 Result = APValue(V.data(), V.size());
5637 Result = V;
5653 static bool EvaluateVector(const Expr* E, APValue& Result, EvalInfo &Info) {
5655 return VectorExprEvaluator(Info, Result).Visit(E);
5805 APValue &Result;
5808 ArrayExprEvaluator(EvalInfo &Info, const LValue &This, APValue &Result)
5809 : ExprEvaluatorBaseTy(Info), This(This), Result(Result) {}
5814 Result = V;
5824 Result = APValue(APValue::UninitArray(), 0,
5826 if (!Result.hasArrayFiller()) return true;
5832 return EvaluateInPlace(Result.getArrayFiller(), Info, Subobject, &VIE);
5836 return handleCallExpr(E, Result, &This);
5847 APValue &Result, EvalInfo &Info) {
5849 return ArrayExprEvaluator(Info, This, Result).Visit(E);
5870 assert((!Result.isArray() || Result.getArrayInitializedElts() == 0) &&
5873 if (Result.isArray() && Result.hasArrayFiller())
5874 Filler = Result.getArrayFiller();
5885 Result = APValue(APValue::UninitArray(), NumEltsToInit, NumElts);
5890 for (unsigned I = 0, E = Result.getArrayInitializedElts(); I != E; ++I)
5891 Result.getArrayInitializedElt(I) = Filler;
5892 if (Result.hasArrayFiller())
5893 Result.getArrayFiller() = Filler;
5901 if (!EvaluateInPlace(Result.getArrayInitializedElt(Index),
5911 if (!Result.hasArrayFiller())
5917 return EvaluateInPlace(Result.getArrayFiller(), Info, Subobject,
5922 return VisitCXXConstructExpr(E, This, &Result, E->getType());
6002 APValue &Result;
6004 IntExprEvaluator(EvalInfo &info, APValue &result)
6005 : ExprEvaluatorBaseTy(info), Result(result) {}
6007 bool Success(const llvm::APSInt &SI, const Expr *E, APValue &Result) {
6009 "Invalid evaluation result.");
6011 "Invalid evaluation result.");
6013 "Invalid evaluation result.");
6014 Result = APValue(SI);
6018 return Success(SI, E, Result);
6021 bool Success(const llvm::APInt &I, const Expr *E, APValue &Result) {
6023 "Invalid evaluation result.");
6025 "Invalid evaluation result.");
6026 Result = APValue(APSInt(I));
6027 Result.getInt().setIsUnsigned(
6032 return Success(I, E, Result);
6035 bool Success(uint64_t Value, const Expr *E, APValue &Result) {
6037 "Invalid evaluation result.");
6038 Result = APValue(Info.Ctx.MakeIntValue(Value, E->getType()));
6042 return Success(Value, E, Result);
6051 Result = V;
6139 static bool EvaluateIntegerOrLValue(const Expr *E, APValue &Result,
6142 return IntExprEvaluator(Info, Result).Visit(E);
6145 static bool EvaluateInteger(const Expr *E, APSInt &Result, EvalInfo &Info) {
6155 Result = Val.getInt();
6241 /// EvaluateBuiltinConstantPForLValue - Determine the result of
6271 Expr::EvalResult Result;
6272 if (!Arg->EvaluateAsRValue(Result, Ctx) || Result.HasSideEffects)
6275 APValue &V = Result.Val;
6417 /// true and stores the result in @p Size.
6928 DataRecursiveIntBinOpEvaluator(IntExprEvaluator &IntEval, APValue &Result)
6929 : IntEval(IntEval), Info(IntEval.getEvalInfo()), FinalResult(Result) { }
6955 bool Success(uint64_t Value, const Expr *E, APValue &Result) {
6956 return IntEval.Success(Value, E, Result);
6958 bool Success(const APSInt &Value, const Expr *E, APValue &Result) {
6959 return IntEval.Success(Value, E, Result);
6977 const BinaryOperator *E, APValue &Result);
6979 void EvaluateExpr(const Expr *E, EvalResult &Result) {
6980 Result.Failed = !Evaluate(Result.Val, Info, E);
6981 if (Result.Failed)
6982 Result.Val = APValue();
6985 void process(EvalResult &Result);
7024 // We can't evaluate the LHS; however, sometimes the result
7044 const BinaryOperator *E, APValue &Result) {
7048 Result = RHSResult.Val;
7060 return Success(lhsResult || rhsResult, E, Result);
7062 return Success(lhsResult && rhsResult, E, Result);
7066 // We can't evaluate the LHS; however, sometimes the result
7069 return Success(rhsResult, E, Result);
7087 Result = LHSVal;
7091 Result.getLValueOffset() += AdditionalOffset;
7093 Result.getLValueOffset() -= AdditionalOffset;
7100 Result = RHSVal;
7101 Result.getLValueOffset() +=
7123 Result = APValue(LHSAddrExpr, RHSAddrExpr);
7139 return Success(Value, E, Result);
7142 void DataRecursiveIntBinOpEvaluator::process(EvalResult &Result) {
7155 EvaluateExpr(job.E, Result);
7163 if (!VisitBinOpLHSOnly(Result, Bop, SuppressRHSDiags)) {
7169 job.LHSResult.swap(Result);
7178 RHS.swap(Result);
7179 Result.Failed = !VisitBinOp(job.LHSResult, RHS, Bop, Result.Val);
7193 return DataRecursiveIntBinOpEvaluator(*this, Result).Traverse(E);
7334 // distinct addresses. In clang, the result of such a comparison is
7410 APSInt Result = TrueResult.trunc(Info.Ctx.getIntWidth(E->getType()));
7412 if (Result.extend(65) != TrueResult &&
7415 return Success(Result, E);
7420 // result defined as follows: If both pointers represent the same
7421 // address or are both the null pointer value, the result is true if the
7422 // operator is <= or >= and false otherwise; otherwise the result is
7447 // Otherwise, the result is unspecified and thus the comparison is not a
7482 // compare pointers within the object in question; otherwise, the result
7528 // result is unspecified.
7548 // are compared, the result is true of the operator is <=, >= or ==, and
7562 /// a result as the expression's type.
7592 // the result is the size of the referenced type."
7614 CharUnits Result;
7632 Result += IdxResult.getSExtValue() * ElementSize;
7646 Result += Info.Ctx.toCharUnitsFromBits(RL.getFieldOffset(i));
7674 Result += RL.getBaseClassOffset(cast<CXXRecordDecl>(BaseRT->getDecl()));
7679 return Success(Result, OOE);
7693 // The result is just the value.
7698 if (!Result.isInt()) return Error(E);
7699 const APSInt &Value = Result.getInt();
7709 if (!Result.isInt()) return Error(E);
7710 return Success(~Result.getInt(), E);
7722 /// result type is integer.
7796 if (!Result.isInt()) {
7802 if (Result.isAddrLabelDiff())
7809 Result.getInt()), E);
7828 LV.moveInto(Result);
7901 APFloat &Result;
7903 FloatExprEvaluator(EvalInfo &info, APFloat &result)
7904 : ExprEvaluatorBaseTy(info), Result(result) {}
7907 Result = V.getFloat();
7912 Result = APFloat::getZero(Info.Ctx.getFloatTypeSemantics(E->getType()));
7930 static bool EvaluateFloat(const Expr* E, APFloat& Result, EvalInfo &Info) {
7932 return FloatExprEvaluator(Info, Result).Visit(E);
7939 llvm::APFloat &Result) {
7955 Result = llvm::APFloat::getSNaN(Sem, false, &fill);
7957 Result = llvm::APFloat::getQNaN(Sem, false, &fill);
7965 Result = llvm::APFloat::getQNaN(Sem, false, &fill);
7967 Result = llvm::APFloat::getSNaN(Sem, false, &fill);
7986 Result = llvm::APFloat::getInf(Sem);
7994 true, Result))
8004 false, Result))
8011 if (!EvaluateFloat(E->getArg(0), Result, Info))
8014 if (Result.isNegative())
8015 Result.changeSign();
8026 if (!EvaluateFloat(E->getArg(0), Result, Info) ||
8029 Result.copySign(RHS);
8040 Result = CV.FloatReal;
8052 Result = CV.FloatImag;
8058 Result = llvm::APFloat::getZero(Sem);
8066 return EvaluateFloat(E->getSubExpr(), Result, Info);
8068 if (!EvaluateFloat(E->getSubExpr(), Result, Info))
8070 Result.changeSign();
8080 bool LHSOK = EvaluateFloat(E->getLHS(), Result, Info);
8084 handleFloatFloatBinOp(Info, E, Result, E->getOpcode(), RHS);
8088 Result = E->getValue();
8103 E->getType(), Result);
8110 Result);
8117 Result = V.getComplexFloatReal();
8130 ComplexValue &Result;
8133 ComplexExprEvaluator(EvalInfo &info, ComplexValue &Result)
8134 : ExprEvaluatorBaseTy(info), Result(Result) {}
8137 Result.setFrom(V);
8155 static bool EvaluateComplex(const Expr *E, ComplexValue &Result,
8158 return ComplexExprEvaluator(Info, Result).Visit(E);
8164 Result.makeComplexFloat();
8166 Result.FloatReal = Zero;
8167 Result.FloatImag = Zero;
8169 Result.makeComplexInt();
8171 Result.IntReal = Zero;
8172 Result.IntImag = Zero;
8181 Result.makeComplexFloat();
8182 APFloat &Imag = Result.FloatImag;
8186 Result.FloatReal = APFloat(Imag.getSemantics());
8192 Result.makeComplexInt();
8193 APSInt &Imag = Result.IntImag;
8197 Result.IntReal = APSInt(Imag.getBitWidth(), !Imag.isSigned());
8261 APFloat &Real = Result.FloatReal;
8265 Result.makeComplexFloat();
8266 Result.FloatImag = APFloat(Real.getSemantics());
8278 return HandleFloatToFloatCast(Info, E, From, To, Result.FloatReal) &&
8279 HandleFloatToFloatCast(Info, E, From, To, Result.FloatImag);
8289 Result.makeComplexInt();
8290 return HandleFloatToIntCast(Info, E, From, Result.FloatReal,
8291 To, Result.IntReal) &&
8292 HandleFloatToIntCast(Info, E, From, Result.FloatImag,
8293 Result.IntImag);
8297 APSInt &Real = Result.IntReal;
8301 Result.makeComplexInt();
8302 Result.IntImag = APSInt(Real.getBitWidth(), !Real.isSigned());
8314 Result.IntReal = HandleIntToIntCast(Info, E, To, From, Result.IntReal);
8315 Result.IntImag = HandleIntToIntCast(Info, E, To, From, Result.IntImag);
8326 Result.makeComplexFloat();
8327 return HandleIntToFloatCast(Info, E, From, Result.IntReal,
8328 To, Result.FloatReal) &&
8329 HandleIntToFloatCast(Info, E, From, Result.IntImag,
8330 To, Result.FloatImag);
8348 APFloat &Real = Result.FloatReal;
8351 Result.makeComplexFloat();
8352 Result.FloatImag = APFloat(Real.getSemantics());
8376 if (Result.isComplexFloat()) {
8377 Result.getComplexFloatReal().add(RHS.getComplexFloatReal(),
8380 Result.getComplexFloatImag() = RHS.getComplexFloatImag();
8382 Result.getComplexFloatImag().add(RHS.getComplexFloatImag(),
8385 Result.getComplexIntReal() += RHS.getComplexIntReal();
8386 Result.getComplexIntImag() += RHS.getComplexIntImag();
8390 if (Result.isComplexFloat()) {
8391 Result.getComplexFloatReal().subtract(RHS.getComplexFloatReal(),
8394 Result.getComplexFloatImag() = RHS.getComplexFloatImag();
8395 Result.getComplexFloatImag().changeSign();
8397 Result.getComplexFloatImag().subtract(RHS.getComplexFloatImag(),
8401 Result.getComplexIntReal() -= RHS.getComplexIntReal();
8402 Result.getComplexIntImag() -= RHS.getComplexIntImag();
8406 if (Result.isComplexFloat()) {
8411 ComplexValue LHS = Result;
8416 APFloat &ResR = Result.getComplexFloatReal();
8417 APFloat &ResI = Result.getComplexFloatImag();
8477 ComplexValue LHS = Result;
8478 Result.getComplexIntReal() =
8481 Result.getComplexIntImag() =
8487 if (Result.isComplexFloat()) {
8492 ComplexValue LHS = Result;
8497 APFloat &ResR = Result.getComplexFloatReal();
8498 APFloat &ResI = Result.getComplexFloatImag();
8543 ComplexValue LHS = Result;
8546 Result.getComplexIntReal() =
8549 Result.getComplexIntImag() =
8560 // Get the operand value into 'Result'.
8570 // The result is always just the subexpr.
8573 if (Result.isComplexFloat()) {
8574 Result.getComplexFloatReal().changeSign();
8575 Result.getComplexFloatImag().changeSign();
8578 Result.getComplexIntReal() = -Result.getComplexIntReal();
8579 Result.getComplexIntImag() = -Result.getComplexIntImag();
8583 if (Result.isComplexFloat())
8584 Result.getComplexFloatImag().changeSign();
8586 Result.getComplexIntImag() = -Result.getComplexIntImag();
8594 Result.makeComplexFloat();
8595 if (!EvaluateFloat(E->getInit(0), Result.FloatReal, Info))
8597 if (!EvaluateFloat(E->getInit(1), Result.FloatImag, Info))
8600 Result.makeComplexInt();
8601 if (!EvaluateInteger(E->getInit(0), Result.IntReal, Info))
8603 if (!EvaluateInteger(E->getInit(1), Result.IntImag, Info))
8619 APValue &Result;
8621 AtomicExprEvaluator(EvalInfo &Info, APValue &Result)
8622 : ExprEvaluatorBaseTy(Info), Result(Result) {}
8625 Result = V;
8632 return Evaluate(Result, Info, &VIE);
8640 return Evaluate(Result, Info, E->getSubExpr());
8646 static bool EvaluateAtomic(const Expr *E, APValue &Result, EvalInfo &Info) {
8648 return AtomicExprEvaluator(Info, Result).Visit(E);
8696 static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
8704 LV.moveInto(Result);
8706 if (!EvaluateVector(E, Result, Info))
8709 if (!IntExprEvaluator(Info, Result).Visit(E))
8715 LV.moveInto(Result);
8720 Result = APValue(F);
8725 C.moveInto(Result);
8730 P.moveInto(Result);
8738 Result = Value;
8745 Result = Value;
8753 if (!EvaluateAtomic(E, Result, Info))
8769 static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This,
8780 return EvaluateArray(E, This, Result, Info);
8782 return EvaluateRecord(E, This, Result, Info);
8786 return Evaluate(Result, Info, E);
8791 static bool EvaluateAsRValue(EvalInfo &Info, const Expr *E, APValue &Result) {
8798 if (!::Evaluate(Result, Info, E))
8803 LV.setFrom(Info.Ctx, Result);
8804 if (!handleLValueToRValueConversion(Info, E, E->getType(), LV, Result))
8809 return CheckConstantExpression(Info, E->getExprLoc(), E->getType(), Result);
8812 static bool FastEvaluateAsRValue(const Expr *Exp, Expr::EvalResult &Result,
8817 Result.Val = APValue(APSInt(L->getValue(),
8845 /// in Result. If this expression is a glvalue, an lvalue-to-rvalue conversion
8846 /// will be applied to the result.
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);
8853 return ::EvaluateAsRValue(Info, this, Result.Val);
8856 bool Expr::EvaluateAsBooleanCondition(bool &Result,
8860 HandleConversionToBool(Scratch.Val, Result);
8863 static bool hasUnacceptableSideEffect(Expr::EvalStatus &Result,
8865 return (SEK < Expr::SE_AllowSideEffects && Result.HasSideEffects) ||
8866 (SEK < Expr::SE_AllowUndefinedBehavior && Result.HasUndefinedBehavior);
8869 bool Expr::EvaluateAsInt(APSInt &Result, const ASTContext &Ctx,
8879 Result = ExprResult.Val.getInt();
8883 bool Expr::EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx) const {
8884 EvalInfo Info(Ctx, Result, EvalInfo::EM_ConstantFold);
8887 if (!EvaluateLValue(this, LV, Info) || Result.HasSideEffects ||
8892 LV.moveInto(Result.Val);
8938 /// constant folded, but discard the result.
8940 EvalResult Result;
8941 return EvaluateAsRValue(Result, Ctx) &&
8942 !hasUnacceptableSideEffect(Result, SEK);
8949 bool Result = EvaluateAsRValue(EvalResult, Ctx);
8950 (void)Result;
8951 assert(Result && "Could not evaluate expression");
9410 APValue Result;
9411 if (!E->isCXX11ConstantExpr(Ctx, &Result, Loc))
9414 if (!Result.isInt()) {
9419 if (Value) *Value = Result.getInt();
9456 bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result,
9469 bool IsConstExpr = ::EvaluateAsRValue(Info, this, Result ? *Result : Scratch);
9570 bool Expr::tryEvaluateObjectSize(uint64_t &Result, ASTContext &Ctx,
9577 return ::tryEvaluateBuiltinObjectSize(this, Type, Info, Result);