diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-07-24 01:08:37 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-07-24 01:08:37 +0000 |
commit | cd8f646eca128f52a7bce0103c51ff82ce96f374 (patch) | |
tree | fdac8e542ee9133eff0cbdb8767e3b4e7a8156ba | |
parent | 624b9365b1a2f67a5367c2c9f45f0649f36e5217 (diff) |
Add Expr::getIntegerConstantExprValue helper method
- For getting an APSInt from a known integer constant Expr.
- TODO: Many users of Expr::isIntegerConstantExpr in codegen should
probably be using this instead...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53974 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Expr.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 692a0ea85f..5569bb6c73 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -95,6 +95,16 @@ public: bool isNullPointerConstant(ASTContext &Ctx) const; + /// getIntegerConstantExprValue() - Return the value of an integer + /// constant expression. The expression must be a valid integer + /// constant expression as determined by isIntegerConstantExpr. + llvm::APSInt getIntegerConstantExprValue(ASTContext &Ctx) const { + llvm::APSInt X(32); + bool success = isIntegerConstantExpr(X, Ctx); + assert(success && "Illegal argument to getIntegerConstantExpr"); + return X; + } + /// isIntegerConstantExpr - Return true if this expression is a valid integer /// constant expression, and, if so, return its value in Result. If not a /// valid i-c-e, return false and fill in Loc (if specified) with the location |