[cfe-commits] r53974 - /cfe/trunk/include/clang/AST/Expr.h

Daniel Dunbar daniel at zuster.org
Wed Jul 23 18:08:37 PDT 2008


Author: ddunbar
Date: Wed Jul 23 20:08:37 2008
New Revision: 53974

URL: http://llvm.org/viewvc/llvm-project?rev=53974&view=rev
Log:
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...

Modified:
    cfe/trunk/include/clang/AST/Expr.h

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=53974&r1=53973&r2=53974&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Jul 23 20:08:37 2008
@@ -95,6 +95,16 @@
   
   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





More information about the cfe-commits mailing list