diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-14 22:35:28 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-14 22:35:28 +0000 |
commit | 26f2cac83eeb4317738d74b9e567d3d58aa04ed9 (patch) | |
tree | db514805ff48e91bd6aced379235297f345770a9 /lib/AST/ExprConstant.cpp | |
parent | c6889e7ed16604c51994e1f11becf213fdc64eb3 (diff) |
constexpr: evaluation support for nullptr comparisons.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150521 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 787e722a7c..e33ca6dc65 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -4612,6 +4612,16 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { return Success(E->getOpcode() == BO_EQ ? Equal : !Equal, E); } + if (LHSTy->isNullPtrType()) { + assert(E->isComparisonOp() && "unexpected nullptr operation"); + assert(RHSTy->isNullPtrType() && "missing pointer conversion"); + // C++11 [expr.rel]p4, [expr.eq]p3: If two operands of type std::nullptr_t + // are compared, the result is true of the operator is <=, >= or ==, and + // false otherwise. + BinaryOperator::Opcode Opcode = E->getOpcode(); + return Success(Opcode == BO_EQ || Opcode == BO_LE || Opcode == BO_GE, E); + } + if (!LHSTy->isIntegralOrEnumerationType() || !RHSTy->isIntegralOrEnumerationType()) { // We can't continue from here for non-integral types. |