[cfe-commits] r70145 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/ASTContext.cpp lib/AST/Expr.cpp lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGCall.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGObjCMac.cpp lib/CodeGen/CodeGenTypes.cpp lib/Sema/SemaDeclObjC.cpp

Eli Friedman eli.friedman at gmail.com
Sun Apr 26 12:19:16 PDT 2009


Author: efriedma
Date: Sun Apr 26 14:19:15 2009
New Revision: 70145

URL: http://llvm.org/viewvc/llvm-project?rev=70145&view=rev
Log:
Remove getIntegerConstantExprValue in favor of using EvaluateAsInt.


Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/CodeGen/CGBuiltin.cpp
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun Apr 26 14:19:15 2009
@@ -177,17 +177,6 @@
   
   bool isBitField();
 
-  /// 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;
-    bool success = isIntegerConstantExpr(X, Ctx);
-    success = success;
-    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
@@ -195,9 +184,6 @@
   bool isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
                              SourceLocation *Loc = 0,
                              bool isEvaluated = true) const;
-  bool isIntegerConstantExprInternal(llvm::APSInt &Result, ASTContext &Ctx,
-                             SourceLocation *Loc = 0,
-                             bool isEvaluated = true) const;
   bool isIntegerConstantExpr(ASTContext &Ctx, SourceLocation *Loc = 0) const {
     llvm::APSInt X;
     return isIntegerConstantExpr(X, Ctx, Loc);
@@ -1722,7 +1708,7 @@
 
   unsigned getShuffleMaskIdx(ASTContext &Ctx, unsigned N) {
     assert((N < NumExprs - 2) && "Shuffle idx out of range!");
-    return getExpr(N+2)->getIntegerConstantExprValue(Ctx).getZExtValue();
+    return getExpr(N+2)->EvaluateAsInt(Ctx).getZExtValue();
   }
   
   // Iterators

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=70145&r1=70144&r2=70145&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Apr 26 14:19:15 2009
@@ -549,8 +549,7 @@
   if (const Expr *BitWidthExpr = FD->getBitWidth()) {
     // TODO: Need to check this algorithm on other targets!
     //       (tested on Linux-X86)
-    FieldSize = 
-      BitWidthExpr->getIntegerConstantExprValue(Context).getZExtValue();
+    FieldSize = BitWidthExpr->EvaluateAsInt(Context).getZExtValue();
     
     std::pair<uint64_t, unsigned> FieldInfo = 
       Context.getTypeInfo(FD->getType());
@@ -2263,7 +2262,7 @@
   const Expr *E = FD->getBitWidth();
   assert(E && "bitfield width not there - getObjCEncodingForTypeImpl");
   ASTContext *Ctx = const_cast<ASTContext*>(Context);
-  unsigned N = E->getIntegerConstantExprValue(*Ctx).getZExtValue();
+  unsigned N = E->EvaluateAsInt(*Ctx).getZExtValue();
   S += 'b';
   S += llvm::utostr(N);
 }

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=70145&r1=70144&r2=70145&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sun Apr 26 14:19:15 2009
@@ -1536,7 +1536,7 @@
 
 
 bool ChooseExpr::isConditionTrue(ASTContext &C) const {
-  return getCond()->getIntegerConstantExprValue(C) != 0;
+  return getCond()->EvaluateAsInt(C) != 0;
 }
 
 void ShuffleVectorExpr::setExprs(Expr ** Exprs, unsigned NumExprs) {

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=70145&r1=70144&r2=70145&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Apr 26 14:19:15 2009
@@ -196,8 +196,7 @@
   case Builtin::BI__builtin_object_size: {
     // FIXME: Implement. For now we just always fail and pretend we
     // don't know the object size.
-    llvm::APSInt TypeArg = 
-      E->getArg(1)->getIntegerConstantExprValue(CGM.getContext());
+    llvm::APSInt TypeArg = E->getArg(1)->EvaluateAsInt(CGM.getContext());
     const llvm::Type *ResType = ConvertType(E->getType());
     //    bool UseSubObject = TypeArg.getZExtValue() & 1;
     bool UseMinimum = TypeArg.getZExtValue() & 2;

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=70145&r1=70144&r2=70145&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Sun Apr 26 14:19:15 2009
@@ -785,8 +785,7 @@
       // therefore they can straddle an eightbyte.
       if (BitField) {
         uint64_t Offset = OffsetBase + Layout.getFieldOffset(idx);
-        uint64_t Size = 
-          i->getBitWidth()->getIntegerConstantExprValue(Context).getZExtValue();
+        uint64_t Size = i->getBitWidth()->EvaluateAsInt(Context).getZExtValue();
 
         uint64_t EB_Lo = Offset / 64;
         uint64_t EB_Hi = (Offset + Size - 1) / 64;

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=70145&r1=70144&r2=70145&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sun Apr 26 14:19:15 2009
@@ -320,8 +320,7 @@
       FieldSize = M->getContext().getTypeSize(FType);
       Expr *BitWidth = Field->getBitWidth();
       if (BitWidth)
-        FieldSize = 
-          BitWidth->getIntegerConstantExprValue(M->getContext()).getZExtValue();
+        FieldSize = BitWidth->EvaluateAsInt(M->getContext()).getZExtValue();
       
       FieldAlign =  M->getContext().getTypeAlign(FType);
     }
@@ -432,9 +431,8 @@
       FieldSize = M->getContext().getTypeSize(FType);
       Expr *BitWidth = Field->getBitWidth();
       if (BitWidth)
-        FieldSize = 
-          BitWidth->getIntegerConstantExprValue(M->getContext()).getZExtValue();
-      
+        FieldSize = BitWidth->EvaluateAsInt(M->getContext()).getZExtValue();
+
       FieldAlign =  M->getContext().getTypeAlign(FType);
     }
 

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=70145&r1=70144&r2=70145&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sun Apr 26 14:19:15 2009
@@ -3085,7 +3085,7 @@
                                                        LastFieldBitfield);
     Expr *BitWidth = LastFieldBitfield->getBitWidth();
     uint64_t BitFieldSize =
-      BitWidth->getIntegerConstantExprValue(CGM.getContext()).getZExtValue();
+      BitWidth->EvaluateAsInt(CGM.getContext()).getZExtValue();
     skivar.ivar_size = (BitFieldSize / ByteSizeInBits) 
                          + ((BitFieldSize % ByteSizeInBits) != 0);
     SkipIvars.push_back(skivar);    
@@ -4293,7 +4293,7 @@
   if (Last->isBitField()) {
     Expr *BitWidth = Last->getBitWidth();
     uint64_t BitFieldSize =
-      BitWidth->getIntegerConstantExprValue(CGM.getContext()).getZExtValue();
+      BitWidth->EvaluateAsInt(CGM.getContext()).getZExtValue();
     Size = (BitFieldSize / 8) + ((BitFieldSize % 8) != 0);
   }
 #endif

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=70145&r1=70144&r2=70145&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Sun Apr 26 14:19:15 2009
@@ -577,7 +577,7 @@
     if (Field->isBitField()) {
       Expr *BitWidth = Field->getBitWidth();
       uint64_t BitFieldSize =  
-        BitWidth->getIntegerConstantExprValue(CGT.getContext()).getZExtValue();
+        BitWidth->EvaluateAsInt(CGT.getContext()).getZExtValue();
 
       CGT.addFieldInfo(*Field, 0);
       CGT.addBitFieldInfo(*Field, offset, BitFieldSize);

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=70145&r1=70144&r2=70145&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sun Apr 26 14:19:15 2009
@@ -722,8 +722,8 @@
     } else if (ImplIvar->isBitField() && ClsIvar->isBitField()) {
       Expr *ImplBitWidth = ImplIvar->getBitWidth();
       Expr *ClsBitWidth = ClsIvar->getBitWidth();
-      if (ImplBitWidth->getIntegerConstantExprValue(Context).getZExtValue() !=
-          ClsBitWidth->getIntegerConstantExprValue(Context).getZExtValue()) {
+      if (ImplBitWidth->EvaluateAsInt(Context).getZExtValue() !=
+          ClsBitWidth->EvaluateAsInt(Context).getZExtValue()) {
         Diag(ImplBitWidth->getLocStart(), diag::err_conflicting_ivar_bitwidth)
           << ImplIvar->getIdentifier();
         Diag(ClsBitWidth->getLocStart(), diag::note_previous_definition);





More information about the cfe-commits mailing list