aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-10-31 22:54:30 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-10-31 22:54:30 +0000
commitc45061bd0c0fdad4df8eea7e9e5af186d11427e5 (patch)
tree27084bd05a00b0ffebbeae081910551396bbc3df /lib/AST/ExprConstant.cpp
parentffbda40a1fb7169591dc01771f3511178a2f727c (diff)
Some minor comment changes in constant-folding comparisons.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143391 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r--lib/AST/ExprConstant.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 5a65038a5f..574474df91 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -1983,12 +1983,13 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
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.
+ // to a null pointer constant.
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.
+ // distinct addresses. In clang, we do not guarantee the addresses are
+ // distinct.
if (IsLiteralLValue(LHSValue) || IsLiteralLValue(RHSValue))
return false;
// We can't tell whether weak symbols will end up pointing to the same
@@ -1996,6 +1997,9 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
if (IsWeakLValue(LHSValue) || IsWeakLValue(RHSValue))
return false;
// Pointers with different bases cannot represent the same object.
+ // (Note that clang defaults to -fmerge-all-constants, which can
+ // lead to inconsistent results for comparisons involving the address
+ // of a constant; this generally doesn't matter in practice.)
return Success(E->getOpcode() == BO_NE, E);
}