[cfe-commits] r54955 - in /cfe/trunk: Driver/RewriteObjC.cpp include/clang/AST/Expr.h include/clang/AST/StmtNodes.def lib/AST/Expr.cpp lib/AST/ExprConstant.cpp lib/AST/StmtPrinter.cpp lib/AST/StmtSerialization.cpp lib/Analysis/Environment.cpp lib/Analysis/GRExprEngine.cpp lib/CodeGen/CGExprConstant.cpp lib/Sema/SemaChecking.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Mon Aug 18 16:02:00 PDT 2008


Author: akirtzidis
Date: Mon Aug 18 18:01:59 2008
New Revision: 54955

URL: http://llvm.org/viewvc/llvm-project?rev=54955&view=rev
Log:
Add ExplicitCastExpr to replace the current CastExpr, and have ImplicitCastExpr and ExplicitCastExpr derive from a common base class (CastExpr):

Expr
  -> CastExpr
     -> ExplicitCastExpr
     -> ImplicitCastExpr 

Modified:
    cfe/trunk/Driver/RewriteObjC.cpp
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/include/clang/AST/StmtNodes.def
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/AST/ExprConstant.cpp
    cfe/trunk/lib/AST/StmtPrinter.cpp
    cfe/trunk/lib/AST/StmtSerialization.cpp
    cfe/trunk/lib/Analysis/Environment.cpp
    cfe/trunk/lib/Analysis/GRExprEngine.cpp
    cfe/trunk/lib/CodeGen/CGExprConstant.cpp
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=54955&r1=54954&r2=54955&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Mon Aug 18 18:01:59 2008
@@ -883,7 +883,8 @@
                                           SourceLocation(), II, 0);
       assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
       QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
-      CastExpr *castExpr = new CastExpr(castT, IV->getBase(), SourceLocation());
+      CastExpr *castExpr = new ExplicitCastExpr(castT, IV->getBase(),
+                                                SourceLocation());
       // Don't forget the parens to enforce the proper binding.
       ParenExpr *PE = new ParenExpr(IV->getBase()->getLocStart(),
                                     IV->getBase()->getLocEnd(),
@@ -924,7 +925,8 @@
                                           SourceLocation(), II, 0);
       assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
       QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
-      CastExpr *castExpr = new CastExpr(castT, IV->getBase(), SourceLocation());
+      CastExpr *castExpr = new ExplicitCastExpr(castT, IV->getBase(),
+                                                SourceLocation());
       // Don't forget the parens to enforce the proper binding.
       ParenExpr *PE = new ParenExpr(IV->getBase()->getLocStart(),
                                     IV->getBase()->getLocEnd(), castExpr);
@@ -1023,7 +1025,7 @@
   // Need to check for protocol refs (id <P>, Foo <P> *) in variable decls and cast exprs.
   if (DeclStmt *DS = dyn_cast<DeclStmt>(S))
     RewriteObjCQualifiedInterfaceTypes(DS->getDecl());
-  if (CastExpr *CE = dyn_cast<CastExpr>(S))
+  if (ExplicitCastExpr *CE = dyn_cast<ExplicitCastExpr>(S))
     RewriteObjCQualifiedInterfaceTypes(CE);
   
   if (isa<SwitchStmt>(S) || isa<WhileStmt>(S) || 
@@ -1931,7 +1933,7 @@
                                  Context->getPointerType(DRE->getType()), 
                                  SourceLocation());
   // cast to NSConstantString *
-  CastExpr *cast = new CastExpr(Exp->getType(), Unop, SourceLocation());
+  CastExpr *cast = new ExplicitCastExpr(Exp->getType(), Unop, SourceLocation());
   ReplaceStmt(Exp, cast);
   delete Exp;
   return cast;
@@ -2067,7 +2069,7 @@
                                                    ClsExprs.size());
       // To turn off a warning, type-cast to 'id'
       InitExprs.push_back(
-        new CastExpr(Context->getObjCIdType(), 
+        new ExplicitCastExpr(Context->getObjCIdType(), 
         Cls, SourceLocation())); // set 'super class', using objc_getClass().
       // struct objc_super
       QualType superType = getSuperStructType();
@@ -2116,7 +2118,7 @@
       llvm::SmallVector<Expr*, 4> InitExprs;
       
       InitExprs.push_back(
-        new CastExpr(Context->getObjCIdType(), 
+        new ExplicitCastExpr(Context->getObjCIdType(), 
                      new DeclRefExpr(CurMethodDecl->getSelfDecl(), 
                                      Context->getObjCIdType(),
                                      SourceLocation()), 
@@ -2133,7 +2135,7 @@
                                                    ClsExprs.size());
       // To turn off a warning, type-cast to 'id'
       InitExprs.push_back(
-        new CastExpr(Context->getObjCIdType(), 
+        new ExplicitCastExpr(Context->getObjCIdType(), 
         Cls, SourceLocation())); // set 'super class', using objc_getClass().
       // struct objc_super
       QualType superType = getSuperStructType();
@@ -2161,9 +2163,10 @@
     } else {
       // Remove all type-casts because it may contain objc-style types; e.g.
       // Foo<Proto> *.
-      while (CastExpr *CE = dyn_cast<CastExpr>(recExpr))
+      while (ExplicitCastExpr *CE = dyn_cast<ExplicitCastExpr>(recExpr))
         recExpr = CE->getSubExpr();
-      recExpr = new CastExpr(Context->getObjCIdType(), recExpr, SourceLocation());
+      recExpr = new ExplicitCastExpr(Context->getObjCIdType(), recExpr,
+                                     SourceLocation());
       MsgExprs.push_back(recExpr);
     }
   }
@@ -2184,16 +2187,16 @@
     // Make all implicit casts explicit...ICE comes in handy:-)
     if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(userExpr)) {
       // Reuse the ICE type, it is exactly what the doctor ordered.
-      userExpr = new CastExpr(ICE->getType()->isObjCQualifiedIdType()
+      userExpr = new ExplicitCastExpr(ICE->getType()->isObjCQualifiedIdType()
                                 ? Context->getObjCIdType()
                                 : ICE->getType(), userExpr, SourceLocation());
     }
     // Make id<P...> cast into an 'id' cast.
-    else if (CastExpr *CE = dyn_cast<CastExpr>(userExpr)) {
+    else if (ExplicitCastExpr *CE = dyn_cast<ExplicitCastExpr>(userExpr)) {
       if (CE->getType()->isObjCQualifiedIdType()) {
-        while ((CE = dyn_cast<CastExpr>(userExpr)))
+        while ((CE = dyn_cast<ExplicitCastExpr>(userExpr)))
           userExpr = CE->getSubExpr();
-        userExpr = new CastExpr(Context->getObjCIdType(), 
+        userExpr = new ExplicitCastExpr(Context->getObjCIdType(), 
                                 userExpr, SourceLocation());
       }
     } 
@@ -2237,7 +2240,7 @@
   // If we don't do this cast, we get the following bizarre warning/note:
   // xx.m:13: warning: function called through a non-compatible type
   // xx.m:13: note: if this code is reached, the program will abort
-  cast = new CastExpr(Context->getPointerType(Context->VoidTy), DRE, 
+  cast = new ExplicitCastExpr(Context->getPointerType(Context->VoidTy), DRE, 
                       SourceLocation());
     
   // Now do the "normal" pointer to function cast.
@@ -2246,7 +2249,7 @@
     // If we don't have a method decl, force a variadic cast.
     Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : true);
   castType = Context->getPointerType(castType);
-  cast = new CastExpr(castType, cast, SourceLocation());
+  cast = new ExplicitCastExpr(castType, cast, SourceLocation());
 
   // Don't forget the parens to enforce the proper binding.
   ParenExpr *PE = new ParenExpr(SourceLocation(), SourceLocation(), cast);
@@ -2265,14 +2268,14 @@
     DeclRefExpr *STDRE = new DeclRefExpr(MsgSendStretFlavor, msgSendType, 
                                          SourceLocation());
     // Need to cast objc_msgSend_stret to "void *" (see above comment).
-    cast = new CastExpr(Context->getPointerType(Context->VoidTy), STDRE, 
+    cast = new ExplicitCastExpr(Context->getPointerType(Context->VoidTy), STDRE, 
                         SourceLocation());
     // Now do the "normal" pointer to function cast.
     castType = Context->getFunctionType(returnType, 
       &ArgTypes[0], ArgTypes.size(),
       Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false);
     castType = Context->getPointerType(castType);
-    cast = new CastExpr(castType, cast, SourceLocation());
+    cast = new ExplicitCastExpr(castType, cast, SourceLocation());
     
     // Don't forget the parens to enforce the proper binding.
     PE = new ParenExpr(SourceLocation(), SourceLocation(), cast);

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

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon Aug 18 18:01:59 2008
@@ -837,61 +837,80 @@
   static CompoundLiteralExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
+/// CastExpr - Base class for Cast Operators (explicit, implicit, etc.).
+/// Classes that derive from CastExpr are:
+///
+///   ImplicitCastExpr
+///   ExplicitCastExpr
+///
+class CastExpr : public Expr {
+  Stmt *Op;
+protected:
+  CastExpr(StmtClass SC, QualType ty, Expr *op) : 
+    Expr(SC, ty), Op(op) {}
+  
+public:
+  Expr *getSubExpr() { return cast<Expr>(Op); }
+  const Expr *getSubExpr() const { return cast<Expr>(Op); }
+  
+  static bool classof(const Stmt *T) { 
+    switch (T->getStmtClass()) {
+    case ImplicitCastExprClass:
+    case ExplicitCastExprClass:
+      return true;
+    default:
+      return false;
+    }
+  }
+  static bool classof(const CastExpr *) { return true; }
+  
+  // Iterators
+  virtual child_iterator child_begin();
+  virtual child_iterator child_end();
+};
+
 /// ImplicitCastExpr - Allows us to explicitly represent implicit type 
 /// conversions. For example: converting T[]->T*, void f()->void (*f)(), 
 /// float->double, short->int, etc.
 ///
-class ImplicitCastExpr : public Expr {
-  Stmt *Op;
+class ImplicitCastExpr : public CastExpr {
 public:
   ImplicitCastExpr(QualType ty, Expr *op) : 
-    Expr(ImplicitCastExprClass, ty), Op(op) {}
-    
-  Expr *getSubExpr() { return cast<Expr>(Op); }
-  const Expr *getSubExpr() const { return cast<Expr>(Op); }
+    CastExpr(ImplicitCastExprClass, ty, op) {}
 
-  virtual SourceRange getSourceRange() const { return Op->getSourceRange(); }
+  virtual SourceRange getSourceRange() const {
+    return getSubExpr()->getSourceRange();
+  }
 
   static bool classof(const Stmt *T) { 
     return T->getStmtClass() == ImplicitCastExprClass; 
   }
   static bool classof(const ImplicitCastExpr *) { return true; }
   
-  // Iterators
-  virtual child_iterator child_begin();
-  virtual child_iterator child_end();
-  
   virtual void EmitImpl(llvm::Serializer& S) const;
   static ImplicitCastExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
-/// CastExpr - [C99 6.5.4] Cast Operators.
+/// ExplicitCastExpr - [C99 6.5.4] Cast Operators.
 ///
-class CastExpr : public Expr {
-  Stmt *Op;
+class ExplicitCastExpr : public CastExpr {
   SourceLocation Loc; // the location of the left paren
 public:
-  CastExpr(QualType ty, Expr *op, SourceLocation l) : 
-    Expr(CastExprClass, ty), Op(op), Loc(l) {}
+  ExplicitCastExpr(QualType ty, Expr *op, SourceLocation l) : 
+    CastExpr(ExplicitCastExprClass, ty, op), Loc(l) {}
 
   SourceLocation getLParenLoc() const { return Loc; }
   
-  Expr *getSubExpr() const { return cast<Expr>(Op); }
-  
   virtual SourceRange getSourceRange() const {
     return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
   }
   static bool classof(const Stmt *T) { 
-    return T->getStmtClass() == CastExprClass; 
+    return T->getStmtClass() == ExplicitCastExprClass; 
   }
-  static bool classof(const CastExpr *) { return true; }
-  
-  // Iterators
-  virtual child_iterator child_begin();
-  virtual child_iterator child_end();
+  static bool classof(const ExplicitCastExpr *) { return true; }
   
   virtual void EmitImpl(llvm::Serializer& S) const;
-  static CastExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
+  static ExplicitCastExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 class BinaryOperator : public Expr {

Modified: cfe/trunk/include/clang/AST/StmtNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtNodes.def?rev=54955&r1=54954&r2=54955&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/StmtNodes.def (original)
+++ cfe/trunk/include/clang/AST/StmtNodes.def Mon Aug 18 18:01:59 2008
@@ -75,11 +75,12 @@
 STMT(46, BinaryOperator        , Expr)
 STMT(47, CompoundAssignOperator, BinaryOperator)
 STMT(48, ConditionalOperator   , Expr)
-STMT(49, ImplicitCastExpr      , Expr)
-STMT(50, CompoundLiteralExpr   , Expr)
-STMT(51, ExtVectorElementExpr  , Expr)
-STMT(52, InitListExpr          , Expr)
-STMT(53, VAArgExpr             , Expr)
+STMT(49, ImplicitCastExpr      , CastExpr)
+STMT(50, ExplicitCastExpr      , CastExpr)
+STMT(51, CompoundLiteralExpr   , Expr)
+STMT(52, ExtVectorElementExpr  , Expr)
+STMT(53, InitListExpr          , Expr)
+STMT(54, VAArgExpr             , Expr)
 
 // GNU Extensions.
 STMT(55, AddrLabelExpr        , Expr)

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

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Aug 18 18:01:59 2008
@@ -359,7 +359,7 @@
         return E->hasLocalSideEffect();
     return false;
   }
-  case CastExprClass:
+  case ExplicitCastExprClass:
     // If this is a cast to void, check the operand.  Otherwise, the result of
     // the cast is unused.
     if (getType()->isVoidType())
@@ -534,8 +534,6 @@
       E = P->getSubExpr();
     else if (CastExpr *P = dyn_cast<CastExpr>(E))
       E = P->getSubExpr();
-    else if (ImplicitCastExpr *P = dyn_cast<ImplicitCastExpr>(E))
-      E = P->getSubExpr();
     else
       return E;
   }
@@ -645,16 +643,9 @@
     return true;
   }
   case ImplicitCastExprClass:
-  case CastExprClass: {
-    const Expr *SubExpr;
-    SourceLocation CastLoc;
-    if (const CastExpr *C = dyn_cast<CastExpr>(this)) {
-      SubExpr = C->getSubExpr();
-      CastLoc = C->getLParenLoc();
-    } else {
-      SubExpr = cast<ImplicitCastExpr>(this)->getSubExpr();
-      CastLoc = getLocStart();
-    }
+  case ExplicitCastExprClass: {
+    const Expr *SubExpr = cast<CastExpr>(this)->getSubExpr();
+    SourceLocation CastLoc = getLocStart();
     if (!SubExpr->isConstantExpr(Ctx, Loc)) {
       if (Loc) *Loc = SubExpr->getLocStart();
       return false;
@@ -940,16 +931,9 @@
     break;
   }
   case ImplicitCastExprClass:
-  case CastExprClass: {
-    const Expr *SubExpr;
-    SourceLocation CastLoc;
-    if (const CastExpr *C = dyn_cast<CastExpr>(this)) {
-      SubExpr = C->getSubExpr();
-      CastLoc = C->getLParenLoc();
-    } else {
-      SubExpr = cast<ImplicitCastExpr>(this)->getSubExpr();
-      CastLoc = getLocStart();
-    }
+  case ExplicitCastExprClass: {
+    const Expr *SubExpr = cast<CastExpr>(this)->getSubExpr();
+    SourceLocation CastLoc = getLocStart();
     
     // C99 6.6p6: shall only convert arithmetic types to integer types.
     if (!SubExpr->getType()->isArithmeticType() ||
@@ -1043,7 +1027,7 @@
 /// cast to void*.
 bool Expr::isNullPointerConstant(ASTContext &Ctx) const {
   // Strip off a cast to void*, if it exists.
-  if (const CastExpr *CE = dyn_cast<CastExpr>(this)) {
+  if (const ExplicitCastExpr *CE = dyn_cast<ExplicitCastExpr>(this)) {
     // Check that it is a cast to void*.
     if (const PointerType *PT = CE->getType()->getAsPointerType()) {
       QualType Pointee = PT->getPointeeType();
@@ -1326,10 +1310,6 @@
 Stmt::child_iterator CompoundLiteralExpr::child_begin() { return &Init; }
 Stmt::child_iterator CompoundLiteralExpr::child_end() { return &Init+1; }
 
-// ImplicitCastExpr
-Stmt::child_iterator ImplicitCastExpr::child_begin() { return &Op; }
-Stmt::child_iterator ImplicitCastExpr::child_end() { return &Op+1; }
-
 // CastExpr
 Stmt::child_iterator CastExpr::child_begin() { return &Op; }
 Stmt::child_iterator CastExpr::child_end() { return &Op+1; }

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

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Aug 18 18:01:59 2008
@@ -216,9 +216,6 @@
   bool VisitUnaryOperator(const UnaryOperator *E);
 
   bool VisitCastExpr(CastExpr* E) {
-    return HandleCast(E->getLParenLoc(), E->getSubExpr(), E->getType());
-  }
-  bool VisitImplicitCastExpr(ImplicitCastExpr* E) {
     return HandleCast(E->getLocStart(), E->getSubExpr(), E->getType());
   }
   bool VisitSizeOfAlignOfTypeExpr(const SizeOfAlignOfTypeExpr *E) {

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

==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Aug 18 18:01:59 2008
@@ -689,7 +689,10 @@
   OS << ".";
   OS << Node->getAccessor().getName();
 }
-void StmtPrinter::VisitCastExpr(CastExpr *Node) {
+void StmtPrinter::VisitCastExpr(CastExpr *) {
+  assert(0 && "CastExpr is an abstract class");
+}
+void StmtPrinter::VisitExplicitCastExpr(ExplicitCastExpr *Node) {
   OS << "(" << Node->getType().getAsString() << ")";
   PrintExpr(Node->getSubExpr());
 }

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

==============================================================================
--- cfe/trunk/lib/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/lib/AST/StmtSerialization.cpp Mon Aug 18 18:01:59 2008
@@ -57,9 +57,6 @@
       
     case CaseStmtClass:
       return CaseStmt::CreateImpl(D, C);
-    
-    case CastExprClass:
-      return CastExpr::CreateImpl(D, C);
       
     case CharacterLiteralClass:
       return CharacterLiteral::CreateImpl(D, C);
@@ -108,6 +105,9 @@
       
     case ImplicitCastExprClass:
       return ImplicitCastExpr::CreateImpl(D, C);
+
+    case ExplicitCastExprClass:
+      return ExplicitCastExpr::CreateImpl(D, C);
       
     case IndirectGotoStmtClass:
       return IndirectGotoStmt::CreateImpl(D, C);
@@ -358,17 +358,17 @@
   return stmt;
 }
 
-void CastExpr::EmitImpl(Serializer& S) const {
+void ExplicitCastExpr::EmitImpl(Serializer& S) const {
   S.Emit(getType());
   S.Emit(Loc);
-  S.EmitOwnedPtr(Op);
+  S.EmitOwnedPtr(getSubExpr());
 }
 
-CastExpr* CastExpr::CreateImpl(Deserializer& D, ASTContext& C) {
+ExplicitCastExpr* ExplicitCastExpr::CreateImpl(Deserializer& D, ASTContext& C) {
   QualType t = QualType::ReadVal(D);
   SourceLocation Loc = SourceLocation::ReadVal(D);
   Expr* Op = D.ReadOwnedPtr<Expr>(C);
-  return new CastExpr(t,Op,Loc);
+  return new ExplicitCastExpr(t,Op,Loc);
 }
   
 
@@ -631,7 +631,7 @@
 
 void ImplicitCastExpr::EmitImpl(Serializer& S) const {
   S.Emit(getType());
-  S.EmitOwnedPtr(Op);
+  S.EmitOwnedPtr(getSubExpr());
 }
 
 ImplicitCastExpr* ImplicitCastExpr::CreateImpl(Deserializer& D, ASTContext& C) {

Modified: cfe/trunk/lib/Analysis/Environment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Environment.cpp?rev=54955&r1=54954&r2=54955&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/Environment.cpp (original)
+++ cfe/trunk/lib/Analysis/Environment.cpp Mon Aug 18 18:01:59 2008
@@ -47,19 +47,8 @@
         // are no-ops.  We blast through these to get the descendant
         // subexpression that has a value.
         
-      case Stmt::ImplicitCastExprClass: {
-        ImplicitCastExpr* C = cast<ImplicitCastExpr>(E);
-        QualType CT = C->getType();
-        
-        if (CT->isVoidType())
-          return UnknownVal();
-        
-        QualType ST = C->getSubExpr()->getType();
-        
-        break;
-      }
-        
-      case Stmt::CastExprClass: {
+      case Stmt::ImplicitCastExprClass:
+      case Stmt::ExplicitCastExprClass: {
         CastExpr* C = cast<CastExpr>(E);
         QualType CT = C->getType();
         QualType ST = C->getSubExpr()->getType();

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=54955&r1=54954&r2=54955&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Mon Aug 18 18:01:59 2008
@@ -356,12 +356,6 @@
       break;      
     }
       
-    case Stmt::CastExprClass: {
-      CastExpr* C = cast<CastExpr>(S);
-      VisitCast(C, C->getSubExpr(), Pred, Dst);
-      break;
-    }
-      
       // FIXME: ChooseExpr is really a constant.  We need to fix
       //        the CFG do not model them as explicit control-flow.
       
@@ -389,8 +383,9 @@
       VisitDeclStmt(cast<DeclStmt>(S), Pred, Dst);
       break;
       
-    case Stmt::ImplicitCastExprClass: {
-      ImplicitCastExpr* C = cast<ImplicitCastExpr>(S);
+    case Stmt::ImplicitCastExprClass:
+    case Stmt::ExplicitCastExprClass: {
+      CastExpr* C = cast<CastExpr>(S);
       VisitCast(C, C->getSubExpr(), Pred, Dst);
       break;
     }

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Mon Aug 18 18:01:59 2008
@@ -72,7 +72,7 @@
     return Visit(E->getInitializer());
   }
   
-  llvm::Constant *VisitCastExpr(const CastExpr* E) {
+  llvm::Constant *VisitCastExpr(CastExpr* E) {
     llvm::Constant *C = Visit(E->getSubExpr());
     
     return EmitConversion(C, E->getSubExpr()->getType(), E->getType());    

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Aug 18 18:01:59 2008
@@ -783,16 +783,10 @@
     
   // For casts, we need to handle conversions from arrays to
   // pointer values, and pointer-to-pointer conversions.
-  case Stmt::CastExprClass:
+  case Stmt::ExplicitCastExprClass:
   case Stmt::ImplicitCastExprClass: {
     
-    Expr* SubExpr;
-    
-    if (ImplicitCastExpr *IE = dyn_cast<ImplicitCastExpr>(E))
-      SubExpr = IE->getSubExpr();
-    else
-      SubExpr = cast<CastExpr>(E)->getSubExpr();
-    
+    Expr* SubExpr = cast<CastExpr>(E)->getSubExpr();
     QualType T = SubExpr->getType();
     
     if (T->isPointerType() || T->isObjCQualifiedIdType())

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Aug 18 18:01:59 2008
@@ -946,7 +946,7 @@
          diag::err_init_element_not_constant, Init->getSourceRange());
     return true;
   }
-  case Expr::CastExprClass: {
+  case Expr::ExplicitCastExprClass: {
     const Expr* SubExpr = cast<CastExpr>(Init)->getSubExpr();
 
     // Check for pointer->pointer cast
@@ -1058,7 +1058,7 @@
     // if we don't, we'll figure it out later
     return 0;
   }
-  case Expr::CastExprClass: {
+  case Expr::ExplicitCastExprClass: {
     const Expr* SubExpr = cast<CastExpr>(E)->getSubExpr();
 
     // Check for pointer->pointer cast
@@ -1183,14 +1183,8 @@
     return true;
   }
   case Expr::ImplicitCastExprClass:
-  case Expr::CastExprClass: {
-    const Expr *SubExpr;
-    if (const CastExpr *C = dyn_cast<CastExpr>(Init)) {
-      SubExpr = C->getSubExpr();
-    } else {
-      SubExpr = cast<ImplicitCastExpr>(Init)->getSubExpr();
-    }
-
+  case Expr::ExplicitCastExprClass: {
+    const Expr *SubExpr = cast<CastExpr>(Init)->getSubExpr();
     if (SubExpr->getType()->isArithmeticType())
       return CheckArithmeticConstantExpression(SubExpr);
 
@@ -1267,9 +1261,7 @@
       }
     } else if (InitTy->isIntegralType()) {
       Expr* SubE = 0;
-      if (ImplicitCastExpr* ICE = dyn_cast<ImplicitCastExpr>(Init))
-        SubE = ICE->getSubExpr();
-      else if (CastExpr* CE = dyn_cast<CastExpr>(Init))
+      if (CastExpr* CE = dyn_cast<CastExpr>(Init))
         SubE = CE->getSubExpr();
       // Special check for pointer cast to int; we allow as an extension
       // an address constant cast to an integer if the integer

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Aug 18 18:01:59 2008
@@ -1154,7 +1154,7 @@
 
   if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), castType, castExpr))
     return true;
-  return new CastExpr(castType, castExpr, LParenLoc);
+  return new ExplicitCastExpr(castType, castExpr, LParenLoc);
 }
 
 /// Note that lex is not null here, even if this is the gnu "x ?: y" extension.





More information about the cfe-commits mailing list