diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-10-31 22:28:05 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-10-31 22:28:05 +0000 |
commit | c6be94b3defcd3594df7951e16090834b58224af (patch) | |
tree | 18575441e450cd9a63006f81e17585e7d4976853 /clang/lib/AST/ExprConstant.cpp | |
parent | ce6a5718ce92f4a595b355de60101f15ed10c05d (diff) | |
download | bcm5719-llvm-c6be94b3defcd3594df7951e16090834b58224af.tar.gz bcm5719-llvm-c6be94b3defcd3594df7951e16090834b58224af.zip |
Don't try to fold comparisons between the address of an object and an arbitrary integer constant. Fixes regression from r143334.
llvm-svn: 143374
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index b34b59d9079..5a65038a5f4 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -1981,6 +1981,12 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { // unspecified or undefined behavior. if (!E->isEqualityOp()) return false; + // A constant address may compare equal to the address of a symbol. + // The one exception is that address of an object cannot compare equal + // to the null pointer. + if ((!LHSValue.Base && !LHSValue.Offset.isZero()) || + (!RHSValue.Base && !RHSValue.Offset.isZero())) + return false; // It's implementation-defined whether distinct literals will have // distinct addresses. We define it to be unspecified. if (IsLiteralLValue(LHSValue) || IsLiteralLValue(RHSValue)) |