]> granicus.if.org Git - clang/commitdiff
Add a CastInfo struct that will be used for cast information when constructing cast...
authorAnders Carlsson <andersca@mac.com>
Mon, 10 Aug 2009 21:30:22 +0000 (21:30 +0000)
committerAnders Carlsson <andersca@mac.com>
Mon, 10 Aug 2009 21:30:22 +0000 (21:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78599 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
include/clang/AST/ExprCXX.h
lib/Sema/Sema.cpp
lib/Sema/Sema.h

index 23fd420914f461b85b6210373faf3af0f8ec4334..e5aca24f5a50a9f76e3fbe6d69101c3aedf1b4be 100644 (file)
@@ -1184,11 +1184,20 @@ public:
     CK_ArrayToPointerDecay
   };
   
+  struct CastInfo {
+    const CastKind Kind;
+    
+    // FIXME: This should assert that the CastKind does not require extra
+    // information.
+    CastInfo(CastKind Kind)
+      : Kind(Kind) { }
+  };
+  
 private:
   CastKind Kind;
   Stmt *Op;
 protected:
-  CastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op) : 
+  CastExpr(StmtClass SC, QualType ty, const CastInfo &info, Expr *op) : 
     Expr(SC, ty,
          // Cast expressions are type-dependent if the type is
          // dependent (C++ [temp.dep.expr]p3).
@@ -1196,7 +1205,7 @@ protected:
          // Cast expressions are value-dependent if the type is
          // dependent or if the subexpression is value-dependent.
          ty->isDependentType() || (op && op->isValueDependent())), 
-    Kind(kind), Op(op) {}
+    Kind(info.Kind), Op(op) {}
   
   /// \brief Construct an empty cast.
   CastExpr(StmtClass SC, EmptyShell Empty) 
@@ -1248,8 +1257,8 @@ class ImplicitCastExpr : public CastExpr {
   bool LvalueCast;
 
 public:
-  ImplicitCastExpr(QualType ty, CastKind kind, Expr *op, bool Lvalue) : 
-    CastExpr(ImplicitCastExprClass, ty, kind, op), LvalueCast(Lvalue) { }
+  ImplicitCastExpr(QualType ty, const CastInfo &info, Expr *op, bool Lvalue) : 
+    CastExpr(ImplicitCastExprClass, ty, info, op), LvalueCast(Lvalue) { }
 
   /// \brief Construct an empty implicit cast.
   explicit ImplicitCastExpr(EmptyShell Shell) 
@@ -1294,9 +1303,9 @@ class ExplicitCastExpr : public CastExpr {
   QualType TypeAsWritten;
 
 protected:
-  ExplicitCastExpr(StmtClass SC, QualType exprTy, CastKind kind, Expr *op, 
-                   QualType writtenTy) 
-    : CastExpr(SC, exprTy, kind, op), TypeAsWritten(writtenTy) {}
+  ExplicitCastExpr(StmtClass SC, QualType exprTy, const CastInfo &info,
+                   Expr *op, QualType writtenTy) 
+    : CastExpr(SC, exprTy, info, op), TypeAsWritten(writtenTy) {}
 
   /// \brief Construct an empty explicit cast.
   ExplicitCastExpr(StmtClass SC, EmptyShell Shell) 
index a254e9914ad80041c2b5ffd14cc830134e591f5d..c80169269bbaf6891298423511e397baa6f5a7c3 100644 (file)
@@ -112,9 +112,9 @@ private:
   SourceLocation Loc; // the location of the casting op
 
 protected:
-  CXXNamedCastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op, 
+  CXXNamedCastExpr(StmtClass SC, QualType ty, const CastInfo &info, Expr *op, 
                    QualType writtenTy, SourceLocation l)
-    : ExplicitCastExpr(SC, ty, kind, op, writtenTy), Loc(l) {}
+    : ExplicitCastExpr(SC, ty, info, op, writtenTy), Loc(l) {}
 
 public:
   const char *getCastName() const;
@@ -148,9 +148,9 @@ public:
 /// @c static_cast<int>(1.0).
 class CXXStaticCastExpr : public CXXNamedCastExpr {
 public:
-  CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy
-                    SourceLocation l)
-    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, writtenTy, l) {}
+  CXXStaticCastExpr(QualType ty, const CastInfo &info, Expr *op
+                    QualType writtenTy, SourceLocation l)
+    : CXXNamedCastExpr(CXXStaticCastExprClass, ty, info, op, writtenTy, l) {}
 
   static bool classof(const Stmt *T) { 
     return T->getStmtClass() == CXXStaticCastExprClass;
index b839e769691dc478b333f1169c780ef4aff8d988..53a5f6d80f8a472f67be17778bbaa8c516a2aa17 100644 (file)
@@ -195,7 +195,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
 /// If there is already an implicit cast, merge into the existing one.
 /// If isLvalue, the result of the cast is an lvalue.
 void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty, 
-                             CastExpr::CastKind Kind, bool isLvalue) {
+                             const CastExpr::CastInfo &Info, bool isLvalue) {
   QualType ExprTy = Context.getCanonicalType(Expr->getType());
   QualType TypeTy = Context.getCanonicalType(Ty);
   
@@ -218,7 +218,7 @@ void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty,
     ImpCast->setType(Ty);
     ImpCast->setLvalueCast(isLvalue);
   } else 
-    Expr = new (Context) ImplicitCastExpr(Ty, Kind, Expr, 
+    Expr = new (Context) ImplicitCastExpr(Ty, Info, Expr, 
                                           isLvalue);
 }
 
index 4f7ae7ec0d1e427e0d27b7c38f23b6bb6aab7c90..b237ac3b81b72e9e3ca40ff0c051a1e1ff50d6fe 100644 (file)
@@ -3016,7 +3016,8 @@ public:
   /// cast.  If there is already an implicit cast, merge into the existing one.
   /// If isLvalue, the result of the cast is an lvalue.
   void ImpCastExprToType(Expr *&Expr, QualType Type, 
-                         CastExpr::CastKind Kind = CastExpr::CK_Unknown,
+                         const CastExpr::CastInfo &Info = 
+                         CastExpr::CastInfo(CastExpr::CK_Unknown),
                          bool isLvalue = false);
 
   // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts