diff options
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
| -rw-r--r-- | lib/AST/ExprConstant.cpp | 11 | 
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index da093ff22c12..1f82b4add0c4 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -9821,13 +9821,12 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {        return true;      } -    uint64_t V; -    if (LV.isNullPointer()) -      V = Info.Ctx.getTargetNullPointerValue(SrcType); -    else -      V = LV.getLValueOffset().getQuantity(); +    APSInt AsInt; +    APValue V; +    LV.moveInto(V); +    if (!V.toIntegralConstant(AsInt, SrcType, Info.Ctx)) +      llvm_unreachable("Can't cast this!"); -    APSInt AsInt = Info.Ctx.MakeIntValue(V, SrcType);      return Success(HandleIntToIntCast(Info, E, DestType, SrcType, AsInt), E);    }  | 
