]> granicus.if.org Git - clang/commitdiff
Remove getIntegerConstantExprValue in favor of using EvaluateAsInt.
authorEli Friedman <eli.friedman@gmail.com>
Sun, 26 Apr 2009 19:19:15 +0000 (19:19 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sun, 26 Apr 2009 19:19:15 +0000 (19:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70145 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 122d9b9433b4472bfc15e6937d7229f3be7264dd..1366450b52743b7a25df745e95ea5243169f56d6 100644 (file)
@@ -177,17 +177,6 @@ public:
   
   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 @@ public:
   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 @@ public:
 
   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
index 95bb1ba04b8ab292f9ce5cb7e4a79066325fde0b..58fc42b036b073f206f9cec504e6a55432147283 100644 (file)
@@ -549,8 +549,7 @@ void ASTRecordLayout::LayoutField(const FieldDecl *FD, unsigned FieldNo,
   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 @@ static void EncodeBitField(const ASTContext *Context, std::string& S,
   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);
 }
index 053117d35bec796d3e25f52bc33bd6e9d42d61c6..acf119ab7974bc584f0855de7fb497700e62bf07 100644 (file)
@@ -1536,7 +1536,7 @@ void ObjCMessageExpr::setClassInfo(const ObjCMessageExpr::ClassInfo &CI) {
 
 
 bool ChooseExpr::isConditionTrue(ASTContext &C) const {
-  return getCond()->getIntegerConstantExprValue(C) != 0;
+  return getCond()->EvaluateAsInt(C) != 0;
 }
 
 void ShuffleVectorExpr::setExprs(Expr ** Exprs, unsigned NumExprs) {
index e7adf721909b2ef323397c3eb07b72e2de5f1c3e..2b9a17845d6bb70e84e5310b4c8f4ebb1231460c 100644 (file)
@@ -196,8 +196,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
   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;
index 5427466cdf9a2b3f59b5fc26a7282314bde2eb11..41d4d7c90b90fb9c5fb728dddb95462234da0914 100644 (file)
@@ -785,8 +785,7 @@ void X86_64ABIInfo::classify(QualType Ty,
       // 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;
index a652ede1c1f2c348bcbce193ca9be86c365cf43d..eeaa197cf3bd953b5cfb2cd78fef2ab3f1c5cf74 100644 (file)
@@ -320,8 +320,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
       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 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
       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);
     }
 
index faab3cfe10859a5b514e66968c78a54b3d6afa56..ae3c26719050ad79ef9742dff4b9206a9093f9fb 100644 (file)
@@ -3085,7 +3085,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
                                                        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 @@ void CGObjCNonFragileABIMac::GetClassSizeInfo(const ObjCInterfaceDecl *OID,
   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
index 79aa705971cfaf7a670ef03c99c8f2c77bf40359..f0bc6f696135e1b14eeb04c9f3168c83aef10b66 100644 (file)
@@ -577,7 +577,7 @@ void RecordOrganizer::layoutUnionFields(const ASTRecordLayout &RL) {
     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);
index 968fddd1af685a228206d0d7a56a18ef428e050c..da50573f23bff4580658239eacce0f903c421763 100644 (file)
@@ -722,8 +722,8 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
     } 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);