[cfe-commits] r54771 - in /cfe/trunk/lib: AST/ASTContext.cpp AST/Expr.cpp CodeGen/CodeGenTypes.cpp Sema/SemaStmt.cpp

Daniel Dunbar daniel at zuster.org
Wed Aug 13 16:47:15 PDT 2008


Author: ddunbar
Date: Wed Aug 13 18:47:13 2008
New Revision: 54771

URL: http://llvm.org/viewvc/llvm-project?rev=54771&view=rev
Log:
Update some isIntegerConstantExpr uses to use
  getIntegerConstantExprValue where appropriate.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp

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

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Aug 13 18:47:13 2008
@@ -370,11 +370,8 @@
   if (const Expr *BitWidthExpr = FD->getBitWidth()) {
     // TODO: Need to check this algorithm on other targets!
     //       (tested on Linux-X86)
-    llvm::APSInt I(32);
-    bool BitWidthIsICE = 
-      BitWidthExpr->isIntegerConstantExpr(I, Context);
-    assert (BitWidthIsICE  && "Invalid BitField size expression");
-    FieldSize = I.getZExtValue();
+    FieldSize = 
+      BitWidthExpr->getIntegerConstantExprValue(Context).getZExtValue();
     
     std::pair<uint64_t, unsigned> FieldInfo = 
       Context.getTypeInfo(FD->getType());

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

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Aug 13 18:47:13 2008
@@ -1195,10 +1195,7 @@
 }
 
 bool ChooseExpr::isConditionTrue(ASTContext &C) const {
-  llvm::APSInt CondVal(32);
-  bool IsConst = getCond()->isIntegerConstantExpr(CondVal, C);
-  assert(IsConst && "Condition of choose expr must be i-c-e"); IsConst=IsConst;
-  return CondVal != 0;
+  return getCond()->getIntegerConstantExprValue(C) != 0;
 }
 
 static int64_t evaluateOffsetOf(ASTContext& C, const Expr *E)
@@ -1220,12 +1217,9 @@
     return RL.getFieldOffset(i) + evaluateOffsetOf(C, ME->getBase());
   } else if (const ArraySubscriptExpr *ASE = dyn_cast<ArraySubscriptExpr>(E)) {
     const Expr *Base = ASE->getBase();
-    llvm::APSInt Idx(32);
-    bool ICE = ASE->getIdx()->isIntegerConstantExpr(Idx, C);
-    assert(ICE && "Array index is not a constant integer!");
     
     int64_t size = C.getTypeSize(ASE->getType());
-    size *= Idx.getSExtValue();
+    size *= ASE->getIdx()->getIntegerConstantExprValue(C).getSExtValue();
     
     return size + evaluateOffsetOf(C, Base);
   } else if (isa<CompoundLiteralExpr>(E))

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Wed Aug 13 18:47:13 2008
@@ -553,11 +553,8 @@
 
     if (FD->isBitField()) {
       Expr *BitWidth = FD->getBitWidth();
-      llvm::APSInt FieldSize(32);
-      bool isBitField =
-        BitWidth->isIntegerConstantExpr(FieldSize, CGT.getContext());
-      assert (isBitField  && "Invalid BitField size expression");
-      uint64_t BitFieldSize =  FieldSize.getZExtValue();
+      uint64_t BitFieldSize =  
+        BitWidth->getIntegerConstantExprValue(CGT.getContext()).getZExtValue();
 
       CGT.addFieldInfo(FD, 0);
       CGT.addBitFieldInfo(FD, offset, BitFieldSize);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Aug 13 18:47:13 2008
@@ -347,9 +347,8 @@
       
       // We already verified that the expression has a i-c-e value (C99
       // 6.8.4.2p3) - get that value now.
-      llvm::APSInt LoVal(32);
       Expr *Lo = CS->getLHS();
-      Lo->isIntegerConstantExpr(LoVal, Context);
+      llvm::APSInt LoVal = Lo->getIntegerConstantExprValue(Context);
       
       // Convert the value to the same width/sign as the condition.
       ConvertIntegerToTypeWarnOnOverflow(LoVal, CondWidth, CondIsSigned,
@@ -398,9 +397,8 @@
     std::vector<llvm::APSInt> HiVals;
     for (unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
       CaseStmt *CR = CaseRanges[i].second;
-      llvm::APSInt HiVal(32);
       Expr *Hi = CR->getRHS();
-      Hi->isIntegerConstantExpr(HiVal, Context);
+      llvm::APSInt HiVal = Hi->getIntegerConstantExprValue(Context);
 
       // Convert the value to the same width/sign as the condition.
       ConvertIntegerToTypeWarnOnOverflow(HiVal, CondWidth, CondIsSigned,





More information about the cfe-commits mailing list