diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-04 01:10:57 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-04 01:10:57 +0000 |
commit | 74f4634781cee06e28eb741bda5d0f936fdd1948 (patch) | |
tree | 4cea4808213f72cd6c501b4b930b7d1d6368acdc /lib/AST/ExprConstant.cpp | |
parent | 49cf8847ef4d9caebdd162d2a5d7d055333d8b5c (diff) |
Constant expression evaluation: although we don't know whether a literal will
be at the same address as another object, we do know it won't alias a null
pointer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143674 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 781ffa6fb4..3e82c4ce8a 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -1970,8 +1970,10 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { return false; // It's implementation-defined whether distinct literals will have // distinct addresses. In clang, we do not guarantee the addresses are - // distinct. - if (IsLiteralLValue(LHSValue) || IsLiteralLValue(RHSValue)) + // distinct. However, we do know that the address of a literal will be + // non-null. + if ((IsLiteralLValue(LHSValue) || IsLiteralLValue(RHSValue)) && + LHSValue.Base && RHSValue.Base) return false; // We can't tell whether weak symbols will end up pointing to the same // object. |