[cfe-commits] r68763 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/ExprConstant.cpp
Anders Carlsson
andersca at mac.com
Thu Apr 9 21:54:13 PDT 2009
Author: andersca
Date: Thu Apr 9 23:54:13 2009
New Revision: 68763
URL: http://llvm.org/viewvc/llvm-project?rev=68763&view=rev
Log:
Add Expr::EvaluateAsLValue which will (believe it or not) try to evaluate an Expr as an LValue.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/ExprConstant.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=68763&r1=68762&r2=68763&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Apr 9 23:54:13 2009
@@ -229,6 +229,9 @@
/// 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*.
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=68763&r1=68762&r2=68763&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Apr 9 23:54:13 2009
@@ -1651,6 +1651,12 @@
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 {
More information about the cfe-commits
mailing list