Store inheritance paths after CastExprs instead of inside them.
This takes some trickery since CastExpr has subclasses (and indeed,
is abstract).

Also, smoosh the CastKind into the bitfield from Expr.

Drops two words of storage from Expr in the common case of expressions
which don't need inheritance paths.  Avoids a separate allocation and
another word of overhead in cases needing inheritance paths.  Also has
the advantage of not leaking memory, since destructors for AST nodes are
never run.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110507 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 173aadc..9424776 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -142,7 +142,7 @@
   
   union {
     struct {
-      const CXXBaseSpecifierArray *BasePath;
+      const CastExpr *BasePath;
       const CXXRecordDecl *DerivedClass;
     } DerivedToBase;
     
@@ -152,7 +152,7 @@
     } Field;
   };
   
-  SubobjectAdjustment(const CXXBaseSpecifierArray *BasePath, 
+  SubobjectAdjustment(const CastExpr *BasePath, 
                       const CXXRecordDecl *DerivedClass)
     : Kind(DerivedToBaseAdjustment) 
   {
@@ -236,8 +236,7 @@
           E = CE->getSubExpr();
           CXXRecordDecl *Derived 
             = cast<CXXRecordDecl>(E->getType()->getAs<RecordType>()->getDecl());
-          Adjustments.push_back(SubobjectAdjustment(&CE->getBasePath(), 
-                                                    Derived));
+          Adjustments.push_back(SubobjectAdjustment(CE, Derived));
           continue;
         }
 
@@ -291,7 +290,8 @@
           Object = 
               CGF.GetAddressOfBaseClass(Object, 
                                         Adjustment.DerivedToBase.DerivedClass, 
-                                        *Adjustment.DerivedToBase.BasePath, 
+                              Adjustment.DerivedToBase.BasePath->path_begin(),
+                              Adjustment.DerivedToBase.BasePath->path_end(),
                                         /*NullCheckValue=*/false);
           break;
             
@@ -1820,7 +1820,8 @@
     // Perform the derived-to-base conversion
     llvm::Value *Base = 
       GetAddressOfBaseClass(This, DerivedClassDecl, 
-                            E->getBasePath(), /*NullCheckValue=*/false);
+                            E->path_begin(), E->path_end(),
+                            /*NullCheckValue=*/false);
     
     return LValue::MakeAddr(Base, MakeQualifiers(E->getType()));
   }
@@ -1836,7 +1837,8 @@
     // Perform the base-to-derived conversion
     llvm::Value *Derived = 
       GetAddressOfDerivedClass(LV.getAddress(), DerivedClassDecl, 
-                               E->getBasePath(),/*NullCheckValue=*/false);
+                               E->path_begin(), E->path_end(),
+                               /*NullCheckValue=*/false);
     
     return LValue::MakeAddr(Derived, MakeQualifiers(E->getType()));
   }