diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-09-25 04:25:58 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-09-25 04:25:58 +0000 |
commit | ce94049b69f75b44c18584fe79cd238978b6b0d5 (patch) | |
tree | e7075c52e30004d24fb813d4847b32e6a1d9f76d /include | |
parent | d52025366666647e3f876e3615200dcf8c80279c (diff) |
Fix checking for a null pointer constant when the expression itself is
value-dependent. Audit (and fixed) all calls to
Expr::isNullPointerConstant() to provide the correct behavior with
value-dependent expressions. Fixes PR5041 and a crash in libstdc++
<locale>.
In the same vein, properly compute value- and type-dependence for
ChooseExpr. Fixes PR4996.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82748 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/Expr.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 39a23a1570..5c594cab35 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -257,10 +257,26 @@ public: /// also succeeds on stack based, immutable address lvalues. bool EvaluateAsAnyLValue(EvalResult &Result, ASTContext &Ctx) const; + /// \brief Enumeration used to describe how \c isNullPointerConstant() + /// should cope with value-dependent expressions. + enum NullPointerConstantValueDependence { + /// \brief Specifies that the expression should never be value-dependent. + NPC_NeverValueDependent = 0, + + /// \brief Specifies that a value-dependent expression of integral or + /// dependent type should be considered a null pointer constant. + NPC_ValueDependentIsNull, + + /// \brief Specifies that a value-dependent expression should be considered + /// to never be a null pointer constant. + NPC_ValueDependentIsNotNull + }; + /// isNullPointerConstant - C99 6.3.2.3p3 - Return true if this is either an /// integer constant expression with the value zero, or if this is one that is /// cast to void*. - bool isNullPointerConstant(ASTContext &Ctx) const; + bool isNullPointerConstant(ASTContext &Ctx, + NullPointerConstantValueDependence NPC) const; /// isOBJCGCCandidate - Return true if this expression may be used in a read/ /// write barrier. @@ -2004,8 +2020,8 @@ class ChooseExpr : public Expr { SourceLocation BuiltinLoc, RParenLoc; public: ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t, - SourceLocation RP) - : Expr(ChooseExprClass, t), + SourceLocation RP, bool TypeDependent, bool ValueDependent) + : Expr(ChooseExprClass, t, TypeDependent, ValueDependent), BuiltinLoc(BLoc), RParenLoc(RP) { SubExprs[COND] = cond; SubExprs[LHS] = lhs; |