[cfe-commits] r77652 - in /cfe/trunk: include/clang/AST/Expr.h lib/Sema/Sema.cpp lib/Sema/Sema.h lib/Sema/SemaChecking.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaOverload.cpp

Anders Carlsson andersca at mac.com
Thu Jul 30 18:23:52 PDT 2009


Author: andersca
Date: Thu Jul 30 20:23:52 2009
New Revision: 77652

URL: http://llvm.org/viewvc/llvm-project?rev=77652&view=rev
Log:
Add CK_DerivedToBase and use it PerformObjectMemberConversion.

Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Jul 30 20:23:52 2009
@@ -1167,7 +1167,10 @@
     CK_BitCast,
     
     /// CK_NoOp - Used for const_cast.
-    CK_NoOp
+    CK_NoOp,
+    
+    /// CK_DerivedToBase - Derived to base class casts.
+    CK_DerivedToBase
   };
   
 private:

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Thu Jul 30 20:23:52 2009
@@ -194,7 +194,8 @@
 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast. 
 /// 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, bool isLvalue) {
+void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty, 
+                             CastExpr::CastKind Kind, bool isLvalue) {
   QualType ExprTy = Context.getCanonicalType(Expr->getType());
   QualType TypeTy = Context.getCanonicalType(Ty);
   
@@ -217,7 +218,7 @@
     ImpCast->setType(Ty);
     ImpCast->setLvalueCast(isLvalue);
   } else 
-    Expr = new (Context) ImplicitCastExpr(Ty, CastExpr::CK_Unknown, Expr, 
+    Expr = new (Context) ImplicitCastExpr(Ty, Kind, Expr, 
                                           isLvalue);
 }
 

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=77652&r1=77651&r2=77652&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Thu Jul 30 20:23:52 2009
@@ -2972,7 +2972,9 @@
   /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
   /// 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, bool isLvalue = false);
+  void ImpCastExprToType(Expr *&Expr, QualType Type, 
+                         CastExpr::CastKind Kind = CastExpr::CK_Unknown,
+                         bool isLvalue = false);
 
   // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
   // functions and arrays to their respective pointers (C99 6.3.2.1).

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jul 30 20:23:52 2009
@@ -348,7 +348,8 @@
   
   // If the first type needs to be converted (e.g. void** -> int*), do it now.
   if (BuiltinFT->getArgType(0) != FirstArg->getType()) {
-    ImpCastExprToType(FirstArg, BuiltinFT->getArgType(0), false);
+    ImpCastExprToType(FirstArg, BuiltinFT->getArgType(0), CastExpr::CK_Unknown,
+                      /*isLvalue=*/false);
     TheCall->setArg(0, FirstArg);
   }
   
@@ -376,7 +377,8 @@
     // pass in 42.  The 42 gets converted to char.  This is even more strange
     // for things like 45.123 -> char, etc.
     // FIXME: Do this check.  
-    ImpCastExprToType(Arg, ValType, false);
+    ImpCastExprToType(Arg, ValType, CastExpr::CK_Unknown,
+                      /*isLvalue=*/false);
     TheCall->setArg(i+1, Arg);
   }
   

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jul 30 20:23:52 2009
@@ -2727,7 +2727,7 @@
       // Perform the conversion.
       // FIXME: Binding to a subobject of the lvalue is going to require more
       // AST annotation than this.
-      ImpCastExprToType(Init, T1, /*isLvalue=*/true);    
+      ImpCastExprToType(Init, T1, CastExpr::CK_Unknown, /*isLvalue=*/true);    
     }
   }
 
@@ -2786,7 +2786,7 @@
         // Perform the conversion.
         // FIXME: Binding to a subobject of the lvalue is going to require more
         // AST annotation than this.
-        ImpCastExprToType(Init, T1, /*isLvalue=*/true);
+        ImpCastExprToType(Init, T1, CastExpr::CK_Unknown, /*isLvalue=*/true);
       }
       break;
 
@@ -2874,7 +2874,7 @@
     } else {
       // FIXME: Binding to a subobject of the rvalue is going to require more
       // AST annotation than this.
-      ImpCastExprToType(Init, T1, /*isLvalue=*/false);
+      ImpCastExprToType(Init, T1, CastExpr::CK_Unknown, /*isLvalue=*/false);
     }
     return false;
   }

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jul 30 20:23:52 2009
@@ -1045,7 +1045,8 @@
                                        From->getSourceRange().getBegin(),
                                        From->getSourceRange()))
         return true;
-      ImpCastExprToType(From, DestType, /*isLvalue=*/true);
+      ImpCastExprToType(From, DestType, CastExpr::CK_DerivedToBase,
+                        /*isLvalue=*/true);
     }
   return false;
 }

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Jul 30 20:23:52 2009
@@ -875,6 +875,7 @@
     // constructor or conversion operator, and then cope with the standard
     // conversions.
     ImpCastExprToType(From, ToType.getNonReferenceType(), 
+                      CastExpr::CK_Unknown,
                       ToType->isLValueReferenceType());
     return false;
 
@@ -1008,6 +1009,7 @@
     // FIXME: Not sure about lvalue vs rvalue here in the presence of rvalue
     // references.
     ImpCastExprToType(From, ToType.getNonReferenceType(), 
+                      CastExpr::CK_Unknown,
                       ToType->isLValueReferenceType());
     break;
 

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jul 30 20:23:52 2009
@@ -2016,7 +2016,7 @@
                                    From->getSourceRange()))
     return true;
 
-  ImpCastExprToType(From, DestType, /*isLvalue=*/true);
+  ImpCastExprToType(From, DestType, CastExpr::CK_Unknown, /*isLvalue=*/true);
   return false;
 }
 
@@ -4476,6 +4476,7 @@
     // FIXME: Represent the user-defined conversion in the AST!
     ImpCastExprToType(Object,
                       Conv->getConversionType().getNonReferenceType(),
+                      CastExpr::CK_Unknown,
                       Conv->getConversionType()->isLValueReferenceType());
     return ActOnCallExpr(S, ExprArg(*this, Object), LParenLoc,
                          MultiExprArg(*this, (ExprTy**)Args, NumArgs),





More information about the cfe-commits mailing list