diff options
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 8913d6e4596..623cb54a6fe 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -3328,12 +3328,12 @@ static bool handleAssignment(EvalInfo &Info, const Expr *E, const LValue &LVal, } CompleteObject Obj = findCompleteObject(Info, E, AK_Assign, LVal, LValType); - return Obj && modifySubobject(Info, E, Obj, LVal.Designator, Val);
-}
-
-namespace {
-struct CompoundAssignSubobjectHandler {
- EvalInfo &Info;
+ return Obj && modifySubobject(Info, E, Obj, LVal.Designator, Val); +} + +namespace { +struct CompoundAssignSubobjectHandler { + EvalInfo &Info; const Expr *E; QualType PromotedLHSType; BinaryOperatorKind Opcode; @@ -3449,13 +3449,13 @@ static bool handleCompoundAssignment( return Obj && findSubobject(Info, E, Obj, LVal.Designator, Handler); } -namespace {
-struct IncDecSubobjectHandler {
- EvalInfo &Info;
- const UnaryOperator *E;
- AccessKinds AccessKind;
- APValue *Old;
-
+namespace { +struct IncDecSubobjectHandler { + EvalInfo &Info; + const UnaryOperator *E; + AccessKinds AccessKind; + APValue *Old; + typedef bool result_type; bool checkConst(QualType QT) { @@ -3521,20 +3521,20 @@ struct IncDecSubobjectHandler { } bool WasNegative = Value.isNegative(); - if (AccessKind == AK_Increment) {
- ++Value;
-
- if (!WasNegative && Value.isNegative() && E->canOverflow()) {
- APSInt ActualValue(Value, /*IsUnsigned*/true);
- return HandleOverflow(Info, E, ActualValue, SubobjType);
- }
- } else {
- --Value;
-
- if (WasNegative && !Value.isNegative() && E->canOverflow()) {
- unsigned BitWidth = Value.getBitWidth();
- APSInt ActualValue(Value.sext(BitWidth + 1), /*IsUnsigned*/false);
- ActualValue.setBit(BitWidth);
+ if (AccessKind == AK_Increment) { + ++Value; + + if (!WasNegative && Value.isNegative() && E->canOverflow()) { + APSInt ActualValue(Value, /*IsUnsigned*/true); + return HandleOverflow(Info, E, ActualValue, SubobjType); + } + } else { + --Value; + + if (WasNegative && !Value.isNegative() && E->canOverflow()) { + unsigned BitWidth = Value.getBitWidth(); + APSInt ActualValue(Value.sext(BitWidth + 1), /*IsUnsigned*/false); + ActualValue.setBit(BitWidth); return HandleOverflow(Info, E, ActualValue, SubobjType); } } @@ -3589,13 +3589,13 @@ static bool handleIncDec(EvalInfo &Info, const Expr *E, const LValue &LVal, Info.FFDiag(E); return false; } -
- AccessKinds AK = IsIncrement ? AK_Increment : AK_Decrement;
- CompleteObject Obj = findCompleteObject(Info, E, AK, LVal, LValType);
- IncDecSubobjectHandler Handler = {Info, cast<UnaryOperator>(E), AK, Old};
- return Obj && findSubobject(Info, E, Obj, LVal.Designator, Handler);
-}
-
+ + AccessKinds AK = IsIncrement ? AK_Increment : AK_Decrement; + CompleteObject Obj = findCompleteObject(Info, E, AK, LVal, LValType); + IncDecSubobjectHandler Handler = {Info, cast<UnaryOperator>(E), AK, Old}; + return Obj && findSubobject(Info, E, Obj, LVal.Designator, Handler); +} + /// Build an lvalue for the object argument of a member function call. static bool EvaluateObjectArgument(EvalInfo &Info, const Expr *Object, LValue &This) { @@ -9006,13 +9006,13 @@ bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) { return Visit(E->getSubExpr()); case UO_Minus: { if (!Visit(E->getSubExpr())) - return false;
- if (!Result.isInt()) return Error(E);
- const APSInt &Value = Result.getInt();
- if (Value.isSigned() && Value.isMinSignedValue() && E->canOverflow() &&
- !HandleOverflow(Info, E, -Value.extend(Value.getBitWidth() + 1),
- E->getType()))
- return false;
+ return false; + if (!Result.isInt()) return Error(E); + const APSInt &Value = Result.getInt(); + if (Value.isSigned() && Value.isMinSignedValue() && E->canOverflow() && + !HandleOverflow(Info, E, -Value.extend(Value.getBitWidth() + 1), + E->getType())) + return false; return Success(-Value, E); } case UO_Not: { |

