diff options
| author | Anders Carlsson <andersca@mac.com> | 2008-11-30 16:19:46 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2008-11-30 16:19:46 +0000 |
| commit | 94deaf675ae60e11c2d9475c6dbfd0c7123160f5 (patch) | |
| tree | 6fa34fc7c7417e907fb8a39e62958fdba69e9429 | |
| parent | 34a83474c89ba23481a8cfcde33693ae17487b8f (diff) | |
| download | clang-94deaf675ae60e11c2d9475c6dbfd0c7123160f5.tar.gz clang-94deaf675ae60e11c2d9475c6dbfd0c7123160f5.tar.bz2 clang-94deaf675ae60e11c2d9475c6dbfd0c7123160f5.tar.xz | |
Add Expr::EvalResult struct. (Not used just yet)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60295 91177308-0d34-0410-b5e6-96231b3b80d8
| -rw-r--r-- | include/clang/AST/Expr.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index dfdca82c74..05c0cebff0 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_AST_EXPR_H #define LLVM_CLANG_AST_EXPR_H +#include "clang/AST/APValue.h" #include "clang/AST/Stmt.h" #include "clang/AST/Type.h" #include "llvm/ADT/APSInt.h" @@ -137,6 +138,30 @@ public: /// isConstantExpr - Return true if this expression is a valid constant expr. bool isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const; + /// EvalResult is a struct with detailed info about an evaluated expression. + struct EvalResult { + /// Val - This is the scalar value the expression can be folded to. + APValue Val; + + /// HasSideEffects - Whether the evaluated expression has side effects. + /// For example, (f() && 0) can be folded, but it still has side effects. + bool HasSideEffects; + + /// Diag - If the expression is unfoldable, then Diag contains a note + /// diagnostic indicating why it's not foldable. DiagLoc indicates a caret + /// position for the error, and DiagExpr is the expression that caused + /// the error. + /// If the expression is foldable, but not an integer constant expression, + /// Diag contains a note diagnostic that describes why it isn't an integer + /// constant expression. If the expression *is* an integer constant + /// expression, then Diag will be zero. + unsigned Diag; + const Expr *DiagExpr; + SourceLocation DiagLoc; + + EvalResult() : HasSideEffects(false), Diag(0), DiagExpr(0) {} + }; + /// Evaluate - Return true if this is a constant which we can fold using /// any crazy technique (that has nothing to do with language standards) that /// we want to. If this function returns true, it returns the folded constant |
