Index: lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- lib/AST/RecordLayoutBuilder.cpp	(revision 111068)
+++ lib/AST/RecordLayoutBuilder.cpp	(working copy)
@@ -73,22 +73,11 @@
   /// member subobject that is empty.
   void ComputeEmptySubobjectSizes();
   
-  bool CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD, 
-                                 uint64_t Offset) const;
-
   void AddSubobjectAtOffset(const CXXRecordDecl *RD, uint64_t Offset);
   
-  bool CanPlaceBaseSubobjectAtOffset(const BaseSubobjectInfo *Info,
-                                     uint64_t Offset);
   void UpdateEmptyBaseSubobjects(const BaseSubobjectInfo *Info,
                                  uint64_t Offset, bool PlacingEmptyBase);
   
-  bool CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD, 
-                                      const CXXRecordDecl *Class,
-                                      uint64_t Offset) const;
-  bool CanPlaceFieldSubobjectAtOffset(const FieldDecl *FD,
-                                      uint64_t Offset) const;
-  
   void UpdateEmptyFieldSubobjects(const CXXRecordDecl *RD, 
                                   const CXXRecordDecl *Class,
                                   uint64_t Offset);
@@ -100,6 +89,19 @@
     return Offset <= MaxEmptyClassOffset;
   }
 
+protected:
+  virtual bool CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD, 
+                                         uint64_t Offset) const;
+
+  virtual bool CanPlaceBaseSubobjectAtOffset(const BaseSubobjectInfo *Info,
+                                             uint64_t Offset);
+
+  virtual bool CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD, 
+                                              const CXXRecordDecl *Class,
+                                              uint64_t Offset) const;
+  virtual bool CanPlaceFieldSubobjectAtOffset(const FieldDecl *FD,
+                                              uint64_t Offset) const;
+
 public:
   /// This holds the size of the largest empty subobject (either a base
   /// or a member). Will be zero if the record being built doesn't contain
@@ -513,6 +515,7 @@
 }
 
 class RecordLayoutBuilder {
+protected:
   // FIXME: Remove this and make the appropriate fields public.
   friend class clang::ASTContext;
 
@@ -586,13 +589,13 @@
       PrimaryBaseIsVirtual(false), FirstNearlyEmptyVBase(0) { }
 
   void Layout(const RecordDecl *D);
-  void Layout(const CXXRecordDecl *D);
+  virtual void Layout(const CXXRecordDecl *D);
   void Layout(const ObjCInterfaceDecl *D);
 
-  void LayoutFields(const RecordDecl *D);
-  void LayoutField(const FieldDecl *D);
-  void LayoutWideBitField(uint64_t FieldSize, uint64_t TypeSize);
-  void LayoutBitField(const FieldDecl *D);
+  virtual void LayoutFields(const RecordDecl *D);
+  virtual void LayoutField(const FieldDecl *D);
+  virtual void LayoutWideBitField(uint64_t FieldSize, uint64_t TypeSize);
+  virtual void LayoutBitField(const FieldDecl *D);
 
   /// BaseSubobjectInfoAllocator - Allocator for BaseSubobjectInfo objects.
   llvm::SpecificBumpPtrAllocator<BaseSubobjectInfo> BaseSubobjectInfoAllocator;
@@ -628,35 +631,35 @@
   /// base class.
   void IdentifyPrimaryBases(const CXXRecordDecl *RD);
 
-  bool IsNearlyEmpty(const CXXRecordDecl *RD) const;
+  virtual bool IsNearlyEmpty(const CXXRecordDecl *RD) const;
 
   /// LayoutNonVirtualBases - Determines the primary base class (if any) and
   /// lays it out. Will then proceed to lay out all non-virtual base clasess.
-  void LayoutNonVirtualBases(const CXXRecordDecl *RD);
+  virtual void LayoutNonVirtualBases(const CXXRecordDecl *RD);
 
   /// LayoutNonVirtualBase - Lays out a single non-virtual base.
-  void LayoutNonVirtualBase(const BaseSubobjectInfo *Base);
+  virtual void LayoutNonVirtualBase(const BaseSubobjectInfo *Base);
 
-  void AddPrimaryVirtualBaseOffsets(const BaseSubobjectInfo *Info, 
-                                    uint64_t Offset);
+  virtual void AddPrimaryVirtualBaseOffsets(const BaseSubobjectInfo *Info, 
+                                            uint64_t Offset);
 
   /// LayoutVirtualBases - Lays out all the virtual bases.
-  void LayoutVirtualBases(const CXXRecordDecl *RD,
+  virtual void LayoutVirtualBases(const CXXRecordDecl *RD,
                           const CXXRecordDecl *MostDerivedClass);
 
   /// LayoutVirtualBase - Lays out a single virtual base.
-  void LayoutVirtualBase(const BaseSubobjectInfo *Base);
+  virtual void LayoutVirtualBase(const BaseSubobjectInfo *Base);
 
   /// LayoutBase - Will lay out a base and return the offset where it was
   /// placed, in bits.
-  uint64_t LayoutBase(const BaseSubobjectInfo *Base);
+  virtual uint64_t LayoutBase(const BaseSubobjectInfo *Base);
 
   /// InitializeLayout - Initialize record layout for the given record decl.
   void InitializeLayout(const Decl *D);
 
   /// FinishLayout - Finalize record layout. Adjust record size based on the
   /// alignment.
-  void FinishLayout();
+  virtual void FinishLayout();
 
   void UpdateAlignment(unsigned NewAlignment);
 
