diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 33 | ||||
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 3 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 8 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Sema/SemaType.cpp | 2 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp | 4 |
14 files changed, 38 insertions, 35 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 6e2e15c6cb6..bba7d5e5790 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -2912,7 +2912,7 @@ bool ComplexExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) { } //===----------------------------------------------------------------------===// -// Top level Expr::Evaluate method. +// Top level Expr::EvaluateAsRValue method. //===----------------------------------------------------------------------===// static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) { @@ -2951,12 +2951,12 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) { } -/// Evaluate - Return true if this is a constant which we can fold using +/// EvaluateAsRValue - Return true if this is a constant which we can fold using /// any crazy technique (that has nothing to do with language standards) that /// we want to. If this function returns true, it returns the folded constant /// in Result. If this expression is a glvalue, an lvalue-to-rvalue conversion /// will be applied to the result. -bool Expr::Evaluate(EvalResult &Result, const ASTContext &Ctx) const { +bool Expr::EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const { EvalInfo Info(Ctx, Result); if (!::Evaluate(Result.Val, Info, this)) @@ -2968,20 +2968,21 @@ bool Expr::Evaluate(EvalResult &Result, const ASTContext &Ctx) const { return HandleLValueToRValueConversion(Info, getType(), LV, Result.Val); } - // FIXME: We don't allow expressions to fold to pointers or references to - // locals. Code which calls Evaluate() isn't ready for that yet. + // FIXME: We don't allow expressions to fold to pointers to locals. Code which + // calls EvaluateAsRValue() isn't ready for that yet. return !Result.Val.isLValue() || IsGlobalLValue(Result.Val.getLValueBase()); } bool Expr::EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx) const { EvalResult Scratch; - return Evaluate(Scratch, Ctx) && HandleConversionToBool(Scratch.Val, Result); + return EvaluateAsRValue(Scratch, Ctx) && + HandleConversionToBool(Scratch.Val, Result); } bool Expr::EvaluateAsInt(APSInt &Result, const ASTContext &Ctx) const { EvalResult ExprResult; - if (!Evaluate(ExprResult, Ctx) || ExprResult.HasSideEffects || + if (!EvaluateAsRValue(ExprResult, Ctx) || ExprResult.HasSideEffects || !ExprResult.Val.isInt()) { return false; } @@ -3013,11 +3014,11 @@ bool Expr::EvaluateAsAnyLValue(EvalResult &Result, return false; } -/// isEvaluatable - Call Evaluate to see if this expression can be constant -/// folded, but discard the result. +/// isEvaluatable - Call EvaluateAsRValue to see if this expression can be +/// constant folded, but discard the result. bool Expr::isEvaluatable(const ASTContext &Ctx) const { EvalResult Result; - return Evaluate(Result, Ctx) && !Result.HasSideEffects; + return EvaluateAsRValue(Result, Ctx) && !Result.HasSideEffects; } bool Expr::HasSideEffects(const ASTContext &Ctx) const { @@ -3026,7 +3027,7 @@ bool Expr::HasSideEffects(const ASTContext &Ctx) const { APSInt Expr::EvaluateKnownConstInt(const ASTContext &Ctx) const { EvalResult EvalResult; - bool Result = Evaluate(EvalResult, Ctx); + bool Result = EvaluateAsRValue(EvalResult, Ctx); (void)Result; assert(Result && "Could not evaluate expression"); assert(EvalResult.Val.isInt() && "Expression did not evaluate to integer"); @@ -3058,7 +3059,7 @@ APSInt Expr::EvaluateKnownConstInt(const ASTContext &Ctx) const { // value, it calls into Evalute. // // Meanings of Val: -// 0: This expression is an ICE if it can be evaluated by Evaluate. +// 0: This expression is an ICE. // 1: This expression is not an ICE, but if it isn't evaluated, it's // a legal subexpression for an ICE. This return value is used to handle // the comma operator in C99 mode. @@ -3081,7 +3082,7 @@ static ICEDiag NoDiag() { return ICEDiag(); } static ICEDiag CheckEvalInICE(const Expr* E, ASTContext &Ctx) { Expr::EvalResult EVResult; - if (!E->Evaluate(EVResult, Ctx) || EVResult.HasSideEffects || + if (!E->EvaluateAsRValue(EVResult, Ctx) || EVResult.HasSideEffects || !EVResult.Val.isInt()) { return ICEDiag(2, E->getLocStart()); } @@ -3272,7 +3273,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { } case Expr::OffsetOfExprClass: { // Note that per C99, offsetof must be an ICE. And AFAIK, using - // Evaluate matches the proposed gcc behavior for cases like + // EvaluateAsRValue matches the proposed gcc behavior for cases like // "offsetof(struct s{int x[4];}, x[1.0])". This doesn't affect // compliance: we should warn earlier for offsetof expressions with // array subscripts that aren't ICEs, and if the array subscripts @@ -3328,7 +3329,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { ICEDiag RHSResult = CheckICE(Exp->getRHS(), Ctx); if (Exp->getOpcode() == BO_Div || Exp->getOpcode() == BO_Rem) { - // Evaluate gives an error for undefined Div/Rem, so make sure + // EvaluateAsRValue gives an error for undefined Div/Rem, so make sure // we don't evaluate one. if (LHSResult.Val == 0 && RHSResult.Val == 0) { llvm::APSInt REval = Exp->getRHS()->EvaluateKnownConstInt(Ctx); @@ -3433,7 +3434,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { = dyn_cast<CallExpr>(Exp->getCond()->IgnoreParenCasts())) if (CallCE->isBuiltinCall(Ctx) == Builtin::BI__builtin_constant_p) { Expr::EvalResult EVResult; - if (!E->Evaluate(EVResult, Ctx) || EVResult.HasSideEffects || + if (!E->EvaluateAsRValue(EVResult, Ctx) || EVResult.HasSideEffects || !EVResult.Val.isInt()) { return ICEDiag(2, E->getLocStart()); } diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 83c7384db0f..4095fe925ec 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -431,7 +431,7 @@ private: return false; return !S->isTypeDependent() && !S->isValueDependent() && - S->Evaluate(outResult, *Context); + S->EvaluateAsRValue(outResult, *Context); } /// tryEvaluateBool - Try and evaluate the Stmt and return 0 or 1 diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index ec0ca424220..bdf49a1e790 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -176,7 +176,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, unsigned BuiltinID, const CallExpr *E) { // See if we can constant fold this builtin. If so, don't emit it at all. Expr::EvalResult Result; - if (E->Evaluate(Result, CGM.getContext()) && + if (E->EvaluateAsRValue(Result, CGM.getContext()) && !Result.hasSideEffects()) { if (Result.Val.isInt()) return RValue::get(llvm::ConstantInt::get(getLLVMContext(), diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index b7107d5883a..920eb5578e4 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1112,7 +1112,8 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty) { if (const VarDecl *V = dyn_cast<VarDecl>(*I)) { if (const Expr *Init = V->getInit()) { Expr::EvalResult Result; - if (Init->Evaluate(Result, CGM.getContext()) && Result.Val.isInt()) { + if (Init->EvaluateAsRValue(Result, CGM.getContext()) && + Result.Val.isInt()) { llvm::ConstantInt *CI = llvm::ConstantInt::get(CGM.getLLVMContext(), Result.Val.getInt()); diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 31e0f2c3b0e..0622c101651 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -957,7 +957,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, if (DestType->isReferenceType()) Success = E->EvaluateAsLValue(Result, Context); else - Success = E->Evaluate(Result, Context); + Success = E->EvaluateAsRValue(Result, Context); if (Success && !Result.HasSideEffects) { switch (Result.Val.getKind()) { diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 25b4a0a0e77..50c5057f3eb 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -208,7 +208,7 @@ public: // l-values. Value *VisitDeclRefExpr(DeclRefExpr *E) { Expr::EvalResult Result; - if (!E->Evaluate(Result, CGF.getContext())) + if (!E->EvaluateAsRValue(Result, CGF.getContext())) return EmitLoadOfLValue(E); assert(!Result.HasSideEffects && "Constant declref with side-effect?!"); @@ -801,7 +801,7 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { } Value *ScalarExprEmitter::VisitMemberExpr(MemberExpr *E) { Expr::EvalResult Result; - if (E->Evaluate(Result, CGF.getContext()) && Result.Val.isInt()) { + if (E->EvaluateAsRValue(Result, CGF.getContext()) && Result.Val.isInt()) { if (E->isArrow()) CGF.EmitScalarExpr(E->getBase()); else @@ -1474,7 +1474,7 @@ Value *ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *E) { Value *ScalarExprEmitter::VisitOffsetOfExpr(OffsetOfExpr *E) { // Try folding the offsetof to a constant. Expr::EvalResult EvalResult; - if (E->Evaluate(EvalResult, CGF.getContext())) + if (E->EvaluateAsRValue(EvalResult, CGF.getContext())) return Builder.getInt(EvalResult.Val.getInt()); // Loop over the components of the offsetof to compute the value. @@ -1597,7 +1597,7 @@ ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr( // If this isn't sizeof(vla), the result must be constant; use the constant // folding logic so we don't have to duplicate it here. Expr::EvalResult Result; - E->Evaluate(Result, CGF.getContext()); + E->EvaluateAsRValue(Result, CGF.getContext()); return Builder.getInt(Result.Val.getInt()); } diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 3da4bd1f987..03469361462 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -513,7 +513,7 @@ ConstantFoldsToSimpleInteger(const Expr *Cond, llvm::APInt &ResultInt) { // FIXME: Rename and handle conversion of other evaluatable things // to bool. Expr::EvalResult Result; - if (!Cond->Evaluate(Result, getContext()) || !Result.Val.isInt() || + if (!Cond->EvaluateAsRValue(Result, getContext()) || !Result.Val.isInt() || Result.HasSideEffects) return false; // Not foldable, not integer or not fully evaluatable. diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 715abb9c0a2..8cae0408f06 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2994,7 +2994,7 @@ IntRange GetExprRange(ASTContext &C, Expr *E, unsigned MaxWidth) { // Try a full evaluation first. Expr::EvalResult result; - if (E->Evaluate(result, C)) + if (E->EvaluateAsRValue(result, C)) return GetValueRange(C, result.Val, E->getType(), MaxWidth); // I think we only want to look through implicit casts here; if the @@ -3405,7 +3405,7 @@ bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, Expr *OriginalInit = Init->IgnoreParenImpCasts(); Expr::EvalResult InitValue; - if (!OriginalInit->Evaluate(InitValue, S.Context) || + if (!OriginalInit->EvaluateAsRValue(InitValue, S.Context) || !InitValue.Val.isInt()) return false; @@ -3576,7 +3576,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, // Don't warn about float constants that are precisely // representable in the target type. Expr::EvalResult result; - if (E->Evaluate(result, S.Context)) { + if (E->EvaluateAsRValue(result, S.Context)) { // Value might be a float, a float vector, or a float complex. if (IsSameFloatAfterCast(result.Val, S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)), diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index fb00c918ab5..6bd0d25f754 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3445,7 +3445,7 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T, Expr::EvalResult EvalResult; if (!VLATy->getSizeExpr() || - !VLATy->getSizeExpr()->Evaluate(EvalResult, Context) || + !VLATy->getSizeExpr()->EvaluateAsRValue(EvalResult, Context) || !EvalResult.Val.isInt()) return QualType(); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 1e890eef1e3..21d0309377c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -9121,7 +9121,7 @@ bool Sema::VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result){ Expr::EvalResult EvalResult; - if (!E->Evaluate(EvalResult, Context) || !EvalResult.Val.isInt() || + if (!E->EvaluateAsRValue(EvalResult, Context) || !EvalResult.Val.isInt() || EvalResult.HasSideEffects) { Diag(E->getExprLoc(), diag::err_expr_not_ice) << E->getSourceRange(); diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 77cfe6c2de5..a24e708b1e7 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2526,7 +2526,7 @@ bool InitializationSequence::endsWithNarrowing(ASTContext &Ctx, Expr::EvalResult InitializerValue; // FIXME: Check whether Initializer is a constant expression according // to C++0x [expr.const], rather than just whether it can be folded. - if (Initializer->Evaluate(InitializerValue, Ctx) && + if (Initializer->EvaluateAsRValue(InitializerValue, Ctx) && !InitializerValue.HasSideEffects && InitializerValue.Val.isFloat()) { // Constant! (Except for FIXME above.) llvm::APFloat FloatVal = InitializerValue.Val.getFloat(); diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 6dcfbbab847..8c99e8a4de4 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -666,7 +666,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, bool ShouldCheckConstantCond = false; if (!HasDependentValue && !TheDefaultStmt) { Expr::EvalResult Result; - HasConstantCond = CondExprBeforePromotion->Evaluate(Result, Context); + HasConstantCond + = CondExprBeforePromotion->EvaluateAsRValue(Result, Context); if (HasConstantCond) { assert(Result.Val.isInt() && "switch condition evaluated to non-int"); ConstantCondValue = Result.Val.getInt(); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 802b36db078..09d47e8e179 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1180,7 +1180,7 @@ static bool isArraySizeVLA(Expr *ArraySize, llvm::APSInt &SizeVal, Sema &S) { // If we're in a GNU mode (like gnu99, but not c99) accept any evaluatable // value as an extension. Expr::EvalResult Result; - if (S.LangOpts.GNUMode && ArraySize->Evaluate(Result, S.Context)) { + if (S.LangOpts.GNUMode && ArraySize->EvaluateAsRValue(Result, S.Context)) { if (!Result.hasSideEffects() && Result.Val.isInt()) { SizeVal = Result.Val.getInt(); S.Diag(ArraySize->getLocStart(), diag::ext_vla_folded_to_constant); diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp index 1769ba35b3e..bf97b8bbadd 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -489,7 +489,7 @@ VisitOffsetOfExpr(const OffsetOfExpr *OOE, ExplodedNode *Pred, ExplodedNodeSet &Dst) { StmtNodeBuilder B(Pred, Dst, *currentBuilderContext); Expr::EvalResult Res; - if (OOE->Evaluate(Res, getContext()) && Res.Val.isInt()) { + if (OOE->EvaluateAsRValue(Res, getContext()) && Res.Val.isInt()) { const APSInt &IV = Res.Val.getInt(); assert(IV.getBitWidth() == getContext().getTypeSize(OOE->getType())); assert(OOE->getType()->isIntegerType()); @@ -526,7 +526,7 @@ VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Ex, } Expr::EvalResult Result; - Ex->Evaluate(Result, getContext()); + Ex->EvaluateAsRValue(Result, getContext()); CharUnits amt = CharUnits::fromQuantity(Result.Val.getInt().getZExtValue()); const ProgramState *state = Pred->getState(); |