diff options
author | Hans Wennborg <hans@hanshq.net> | 2019-03-06 10:26:19 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2019-03-06 10:26:19 +0000 |
commit | dd1ea8abb791d274ae574a478937aa0e77cc405f (patch) | |
tree | b1245fa18b95148a743b90909794e1b763b8c701 /clang/lib/AST/ExprConstant.cpp | |
parent | 2a0f2c5ef3330846149598220467d9f3c6e8b99c (diff) | |
download | bcm5719-llvm-dd1ea8abb791d274ae574a478937aa0e77cc405f.tar.gz bcm5719-llvm-dd1ea8abb791d274ae574a478937aa0e77cc405f.zip |
Inline asm constraints: allow ICE-like pointers for the "n" constraint (PR40890)
Apparently GCC allows this, and there's code relying on it (see bug).
The idea is to allow expression that would have been allowed if they
were cast to int. So I based the code on how such a cast would be done
(the CK_PointerToIntegral case in IntExprEvaluator::VisitCastExpr()).
Differential Revision: https://reviews.llvm.org/D58821
llvm-svn: 355491
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 1a21ad2539d..111cffe373e 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -9872,13 +9872,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); } |