Add an InheritancePath parameter to the ImplicitCastExpr constructor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102218 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp
index a97536c..9766d3a 100644
--- a/lib/AST/ASTImporter.cpp
+++ b/lib/AST/ASTImporter.cpp
@@ -2887,6 +2887,7 @@
   
   return new (Importer.getToContext()) ImplicitCastExpr(T, E->getCastKind(),
                                                         SubExpr, 
+                                                        /* FIXME: */0,
                                                         E->isLvalueCast());
 }
 
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index 46bb90b..fa21a39 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -381,7 +381,7 @@
     if (getContext().getCanonicalType(Ivar->getType()) !=
         getContext().getCanonicalType(ArgDecl->getType())) {
       ImplicitCastExpr ArgCasted(Ivar->getType(), CastExpr::CK_BitCast, &Arg,
-                                 false);
+                                 0, false);
       BinaryOperator Assign(&IvarRef, &ArgCasted, BinaryOperator::Assign,
                             Ivar->getType(), Loc);
       EmitStmt(&Assign);
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp
index 65b57d6..66b8d39 100644
--- a/lib/Frontend/RewriteObjC.cpp
+++ b/lib/Frontend/RewriteObjC.cpp
@@ -2087,10 +2087,10 @@
 
   // Now, we cast the reference to a pointer to the objc_msgSend type.
   QualType pToFunc = Context->getPointerType(msgSendType);
-  ImplicitCastExpr *ICE = new (Context) ImplicitCastExpr(pToFunc,
-                                                         CastExpr::CK_Unknown,
-                                                         DRE,
-                                               /*isLvalue=*/false);
+  ImplicitCastExpr *ICE = 
+    new (Context) ImplicitCastExpr(pToFunc, CastExpr::CK_Unknown,
+                                   DRE, /*InheritancePath=*/0,
+                                   /*isLvalue=*/false);
 
   const FunctionType *FT = msgSendType->getAs<FunctionType>();
 
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 2bb1ed8..62fbe94 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -158,7 +158,9 @@
 /// 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) {
+                             CastExpr::CastKind Kind, 
+                             CastExpr::CXXBaseVector *InheritancePath,
+                             bool isLvalue) {
   QualType ExprTy = Context.getCanonicalType(Expr->getType());
   QualType TypeTy = Context.getCanonicalType(Ty);
 
@@ -178,13 +180,15 @@
 
   if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(Expr)) {
     if (ImpCast->getCastKind() == Kind) {
+      assert(!InheritancePath && "FIXME: Merge paths!");
       ImpCast->setType(Ty);
       ImpCast->setLvalueCast(isLvalue);
       return;
     }
   }
 
-  Expr = new (Context) ImplicitCastExpr(Ty, Kind, Expr, isLvalue);
+  Expr = new (Context) ImplicitCastExpr(Ty, Kind, Expr, InheritancePath,
+                                        isLvalue);
 }
 
 void Sema::DeleteExpr(ExprTy *E) {
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 65f7444..1065fc4 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -3958,6 +3958,7 @@
   /// 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::CXXBaseVector *InheritancePath = 0,
                          bool isLvalue = false);
 
   // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 5056e31..0b66c10 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -432,7 +432,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, Kind, /*isLvalue=*/false);
+    ImpCastExprToType(Arg, ValType, Kind, /*InheritancePath=*/0,
+                      /*isLvalue=*/false);
     TheCall->setArg(i+1, Arg);
   }
 
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 7d2d866..4800337 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -6518,6 +6518,7 @@
       ECD->setInitExpr(new (Context) ImplicitCastExpr(NewTy,
                                                       CastExpr::CK_IntegralCast,
                                                       ECD->getInitExpr(),
+                                                      /*InheritancePath=*/0,
                                                       /*isLvalue=*/false));
     if (getLangOptions().CPlusPlus)
       // C++ [dcl.enum]p4: Following the closing brace of an
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 7b09ddd..f5ecff8 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1443,7 +1443,8 @@
       if (PointerConversions)
         QType = Context.getPointerType(QType);
       ImpCastExprToType(From, QType, CastExpr::CK_UncheckedDerivedToBase,
-                        /*isLvalue*/ !PointerConversions);
+                        /*FIXME: InheritancePath=*/0,
+                        /*isLvalue=*/!PointerConversions);
 
       FromType = QType;
       FromRecordType = QRecordType;
@@ -1479,6 +1480,7 @@
       if (PointerConversions)
         UType = Context.getPointerType(UType);
       ImpCastExprToType(From, UType, CastExpr::CK_UncheckedDerivedToBase,
+                        /*FIXME: InheritancePath=*/0,
                         /*isLvalue*/ !PointerConversions);
       FromType = UType;
       FromRecordType = URecordType;
@@ -1497,7 +1499,8 @@
     return true;
 
   ImpCastExprToType(From, DestType, CastExpr::CK_UncheckedDerivedToBase,
-                    /*isLvalue=*/ !PointerConversions);
+                    /*FIXME: InheritancePath=*/0,
+                    /*isLvalue=*/!PointerConversions);
   return false;
 }
 
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 007eecd..6983a1e 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -341,7 +341,7 @@
       //   type.
       if (T.hasQualifiers()) {
         ImpCastExprToType(E, T.getUnqualifiedType(), CastExpr::CK_NoOp,
-                          E->isLvalue(Context));
+                          /*InheritancePath=*/0, E->isLvalue(Context));
         TyOrExpr = E;
       }
     }
@@ -392,6 +392,7 @@
   //   or "pointer to function returning T", [...]
   if (E->getType().hasQualifiers())
     ImpCastExprToType(E, E->getType().getUnqualifiedType(), CastExpr::CK_NoOp,
+                      /*InheritancePath=*/0,
                       E->isLvalue(Context) == Expr::LV_Valid);
   
   DefaultFunctionArrayConversion(E);
@@ -1791,7 +1792,7 @@
     // FIXME: Not sure about lvalue vs rvalue here in the presence of rvalue
     // references.
     ImpCastExprToType(From, ToType.getNonReferenceType(),
-                      CastExpr::CK_NoOp,
+                      CastExpr::CK_NoOp, /*InheritancePath=*/0,
                       ToType->isLValueReferenceType());
 
     if (SCS.DeprecatedStringLiteralToCharPtr)
@@ -1886,7 +1887,8 @@
     // Cast LHS to type of use.
     QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
     bool isLValue = !isIndirect && lex->isLvalue(Context) == Expr::LV_Valid;
-    ImpCastExprToType(lex, UseType, CastExpr::CK_DerivedToBase, isLValue);
+    ImpCastExprToType(lex, UseType, CastExpr::CK_DerivedToBase, 
+                      /*FIXME: InheritancePath=*/0, isLValue);
   }
 
   if (isa<CXXZeroInitValueExpr>(rex->IgnoreParens())) {
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index eae5f63..904489c 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -3467,7 +3467,8 @@
         
       CurInit = S.Owned(new (S.Context) ImplicitCastExpr(Step->Type,
                                                     CastExpr::CK_DerivedToBase,
-                                                      (Expr*)CurInit.release(),
+                                                    (Expr*)CurInit.release(),
+                                                    /*FIXME:InheritancePath=*/0,
                                      Step->Kind == SK_CastDerivedToBaseLValue));
       break;
     }
@@ -3587,6 +3588,7 @@
       CurInit = S.Owned(new (S.Context) ImplicitCastExpr(CurInitExpr->getType(),
                                                          CastKind, 
                                                          CurInitExpr,
+                                                         /*InheritancePath=*/0,
                                                          IsLvalue));
       
       if (RequiresCopy)
@@ -3599,7 +3601,7 @@
     case SK_QualificationConversionRValue:
       // Perform a qualification conversion; these can never go wrong.
       S.ImpCastExprToType(CurInitExpr, Step->Type,
-                          CastExpr::CK_NoOp, 
+                          CastExpr::CK_NoOp, /*InheritancePath=*/0,
                           Step->Kind == SK_QualificationConversionLValue);
       CurInit.release();
       CurInit = S.Owned(CurInitExpr);
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 2e35adb..732b9ee 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -2675,7 +2675,7 @@
     return PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
 
   if (!Context.hasSameType(From->getType(), DestType))
-    ImpCastExprToType(From, DestType, CastExpr::CK_NoOp,
+    ImpCastExprToType(From, DestType, CastExpr::CK_NoOp, /*InheritancePath=*/0,
                       /*isLvalue=*/!From->getType()->getAs<PointerType>());
   return false;
 }
@@ -3157,7 +3157,7 @@
                             From->getLocStart());
   ImplicitCastExpr ConversionFn(Context.getPointerType(Conversion->getType()),
                                 CastExpr::CK_FunctionToPointerDecay,
-                                &ConversionRef, false);
+                                &ConversionRef, /*InheritancePath=*/0, false);
 
   // Note that it is safe to allocate CallExpr on the stack here because
   // there are 0 arguments (i.e., nothing is allocated using ASTContext's
@@ -6860,6 +6860,7 @@
     return new (Context) ImplicitCastExpr(ICE->getType(), 
                                           ICE->getCastKind(),
                                           SubExpr,
+                                          /*InheritancePath=*/0,
                                           ICE->isLvalueCast());
   } 
   
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index a239a41..7a3e83a 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -2868,6 +2868,7 @@
 
     if (IsQualificationConversion(ArgType, ParamType.getNonReferenceType())) {
       ImpCastExprToType(Arg, ParamType, CastExpr::CK_NoOp,
+                        /*InheritancePath=*/0,
                         Arg->isLvalue(Context) == Expr::LV_Valid);
     } else if (!Context.hasSameUnqualifiedType(ArgType,
                                            ParamType.getNonReferenceType())) {
@@ -2932,6 +2933,7 @@
     // Types match exactly: nothing more to do here.
   } else if (IsQualificationConversion(ArgType, ParamType)) {
     ImpCastExprToType(Arg, ParamType, CastExpr::CK_NoOp,
+                      /*InheritancePath=*/0,
                       Arg->isLvalue(Context) == Expr::LV_Valid);
   } else {
     // We can't perform this conversion.