[cfe-commits] r143391 - /cfe/trunk/lib/AST/ExprConstant.cpp
Eli Friedman
eli.friedman at gmail.com
Mon Oct 31 15:54:30 PDT 2011
Author: efriedma
Date: Mon Oct 31 17:54:30 2011
New Revision: 143391
URL: http://llvm.org/viewvc/llvm-project?rev=143391&view=rev
Log:
Some minor comment changes in constant-folding comparisons.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=143391&r1=143390&r2=143391&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Oct 31 17:54:30 2011
@@ -1983,12 +1983,13 @@
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 @@
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);
}
More information about the cfe-commits
mailing list