Add Expr::EvaluateAsLValue which will (believe it or not) try to evaluate an Expr as an LValue.

llvm-svn: 68763
This commit is contained in:
Anders Carlsson 2009-04-10 04:54:13 +00:00
parent 0e6d2b3a70
commit 43168129d0
2 changed files with 9 additions and 0 deletions

View File

@ -229,6 +229,9 @@ public:
/// must be called on an expression that constant folds to an integer.
llvm::APSInt EvaluateAsInt(ASTContext &Ctx) const;
/// EvaluateAsLValue - Evaluate an expression to see if it's a valid LValue.
bool EvaluateAsLValue(EvalResult &Result, ASTContext &Ctx) const;
/// 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*.

View File

@ -1651,6 +1651,12 @@ bool Expr::Evaluate(EvalResult &Result, ASTContext &Ctx) const {
return true;
}
bool Expr::EvaluateAsLValue(EvalResult &Result, ASTContext &Ctx) const {
EvalInfo Info(Ctx, Result);
return EvaluateLValue(this, Result.Val, Info) && !Result.HasSideEffects;
}
/// isEvaluatable - Call Evaluate to see if this expression can be constant
/// folded, but discard the result.
bool Expr::isEvaluatable(ASTContext &Ctx) const {