Switching back to using std::tr1::shared_ptr. We originally switched away
due to RTTI worries since llvm and clang don't use RTTI, but I was able to 
switch back with no issues as far as I can tell. Once the RTTI issue wasn't
an issue, we were looking for a way to properly track weak pointers to objects
to solve some of the threading issues we have been running into which naturally
led us back to std::tr1::weak_ptr. We also wanted the ability to make a shared 
pointer from just a pointer, which is also easily solved using the 
std::tr1::enable_shared_from_this class. 

The main reason for this move back is so we can start properly having weak
references to objects. Currently a lldb_private::Thread class has a refrence
to its parent lldb_private::Process. This doesn't work well when we now hand
out a SBThread object that contains a shared pointer to a lldb_private::Thread
as this SBThread can be held onto by external clients and if they end up
using one of these objects we can easily crash.

So the next task is to start adopting std::tr1::weak_ptr where ever it makes
sense which we can do with lldb_private::Debugger, lldb_private::Target,
lldb_private::Process, lldb_private::Thread, lldb_private::StackFrame, and
many more objects now that they are no longer using intrusive ref counted
pointer objects (you can't do std::tr1::weak_ptr functionality with intrusive
pointers).



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@149207 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index e395ccc..0d1e74b 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -122,7 +122,7 @@
     }
     else
     {
-        Module *module = inst_addr.GetModule();
+        Module *module = inst_addr.GetModulePtr();
         if (module)
         {
             if (module->ResolveFileAddress(operand_value, so_addr))
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index d74bdf1..4f915a9 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -1255,12 +1255,12 @@
         AddressRange *ar = sym_ctx.symbol->GetAddressRangePtr();
         if (ar)
         {
-            module_sp = ar->GetBaseAddress().GetModule();
+            module_sp = ar->GetBaseAddress().GetModuleSP();
         }
     }
     if (module_sp.get() == NULL && sym_ctx.function)
     {
-        module_sp = sym_ctx.function->GetAddressRange().GetBaseAddress().GetModule();
+        module_sp = sym_ctx.function->GetAddressRange().GetBaseAddress().GetModuleSP();
     }
     if (module_sp.get() == NULL)
         return false;
@@ -1522,7 +1522,7 @@
                         
                         Module* module_to_add = sc.symbol->CalculateSymbolContextModule();
                         if (module_to_add)
-                             modules_to_search.AppendIfNeeded(static_cast<ModuleSP>(module_to_add));
+                             modules_to_search.AppendIfNeeded(module_to_add->shared_from_this());
                     }
                     
                     // If the original stub symbol is a resolver, then we don't want to break on the symbol with the
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 7df812c..c6e0819 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -220,7 +220,7 @@
 {
     // Maybe check here and if we have a handler already, and the UUID of this module is the same as the one in the
     // current module, then we don't have to reread it?
-    m_objc_trampoline_handler_ap.reset(new AppleObjCTrampolineHandler (m_process->GetSP(), module_sp));
+    m_objc_trampoline_handler_ap.reset(new AppleObjCTrampolineHandler (m_process->shared_from_this(), module_sp));
     if (m_objc_trampoline_handler_ap.get() != NULL)
     {
         m_read_objc_library = true;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp
index b7c7a1d..13dc7d7 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp
@@ -19,7 +19,7 @@
 
 AppleObjCSymbolVendor::AppleObjCSymbolVendor(Process *process) :
     SymbolVendor(NULL),
-    m_process(process->GetSP()),
+    m_process(process->shared_from_this()),
     m_ast_ctx(process->GetTarget().GetArchitecture().GetTriple().getTriple().c_str())
 {
 }
diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
index def3f73..6501c5a 100644
--- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
+++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
@@ -118,7 +118,7 @@
     class Archive
     {
     public:
-        typedef lldb::SharedPtr<Archive>::Type shared_ptr;
+        typedef SHARED_PTR(Archive) shared_ptr;
         typedef std::multimap<lldb_private::FileSpec, shared_ptr> Map;
 
         static Map &
diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp b/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp
index 199b55c..6e230fb 100644
--- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp
+++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp
@@ -104,7 +104,7 @@
     // Now make a new log with this stream if one was provided
     if (log_stream_sp)
     {
-        log = make_shared<Log>(log_stream_sp);
+        log.reset (new Log(log_stream_sp));
         GetLog () = log;
     }
 
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 3dc2102..3ae19f9 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -126,7 +126,7 @@
         {
             m_current_offset = frame_sp->GetFrameCodeAddress().GetOffset() - m_start_pc.GetOffset();
         }
-        else if (frame_sp->GetFrameCodeAddress().GetModule() == m_start_pc.GetModule())
+        else if (frame_sp->GetFrameCodeAddress().GetModulePtr() == m_start_pc.GetModulePtr())
         {
             // This means that whatever symbol we kicked up isn't really correct
             // as no should cross section boundaries... We really should NULL out
@@ -284,7 +284,7 @@
 
     // If we don't have a Module for some reason, we're not going to find symbol/function information - just
     // stick in some reasonable defaults and hope we can unwind past this frame.
-    if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL)
+    if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL)
     {
         if (log)
         {
@@ -397,7 +397,7 @@
     }
 
     // We require that eSymbolContextSymbol be successfully filled in or this context is of no use to us.
-    if ((m_current_pc.GetModule()->ResolveSymbolContextForAddress (m_current_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
+    if ((m_current_pc.GetModulePtr()->ResolveSymbolContextForAddress (m_current_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
     {
         m_sym_ctx_valid = true;
     }
@@ -436,7 +436,7 @@
         temporary_pc.SetOffset(m_current_pc.GetOffset() - 1);
         m_sym_ctx.Clear();
         m_sym_ctx_valid = false;
-        if ((m_current_pc.GetModule()->ResolveSymbolContextForAddress (temporary_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
+        if ((m_current_pc.GetModulePtr()->ResolveSymbolContextForAddress (temporary_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
         {
             m_sym_ctx_valid = true;
         }
@@ -619,13 +619,13 @@
 RegisterContextLLDB::GetFastUnwindPlanForFrame ()
 {
     UnwindPlanSP unwind_plan_sp;
-    if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL || m_current_pc.GetModule()->GetObjectFile() == NULL)
+    if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL || m_current_pc.GetModulePtr()->GetObjectFile() == NULL)
         return unwind_plan_sp;
 
     if (IsFrameZero ())
         return unwind_plan_sp;
 
-    FuncUnwindersSP func_unwinders_sp (m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx));
+    FuncUnwindersSP func_unwinders_sp (m_current_pc.GetModulePtr()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx));
     if (!func_unwinders_sp)
         return unwind_plan_sp;
 
@@ -712,7 +712,7 @@
     }
 
     // No Module for the current pc, try using the architecture default unwind.
-    if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL || m_current_pc.GetModule()->GetObjectFile() == NULL)
+    if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL || m_current_pc.GetModulePtr()->GetObjectFile() == NULL)
     {
         m_frame_type = eNormalFrame;
         return arch_default_unwind_plan_sp;
@@ -721,7 +721,7 @@
     FuncUnwindersSP func_unwinders_sp;
     if (m_sym_ctx_valid)
     {
-        func_unwinders_sp = m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
+        func_unwinders_sp = m_current_pc.GetModulePtr()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
     }
 
     // No FuncUnwinders available for this pc, try using architectural default unwind.
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.h b/source/Plugins/Process/Utility/RegisterContextLLDB.h
index a578fd7..cdb0ccb 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.h
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.h
@@ -25,7 +25,7 @@
 class RegisterContextLLDB : public lldb_private::RegisterContext
 {
 public:
-    typedef lldb::SharedPtr<RegisterContextLLDB>::Type SharedPtr;
+    typedef SHARED_PTR(RegisterContextLLDB) SharedPtr;
 
     RegisterContextLLDB (lldb_private::Thread &thread,
                          const SharedPtr& next_frame,
diff --git a/source/Plugins/Process/Utility/UnwindLLDB.cpp b/source/Plugins/Process/Utility/UnwindLLDB.cpp
index 954ad8b..bf71b00 100644
--- a/source/Plugins/Process/Utility/UnwindLLDB.cpp
+++ b/source/Plugins/Process/Utility/UnwindLLDB.cpp
@@ -69,10 +69,10 @@
 {
     // First, set up the 0th (initial) frame
     CursorSP first_cursor_sp(new Cursor ());
-    RegisterContextLLDBSharedPtr reg_ctx_sp (new RegisterContextLLDB (m_thread, 
-                                                                        RegisterContextLLDBSharedPtr(), 
-                                                                        first_cursor_sp->sctx, 
-                                                                        0, *this));
+    RegisterContextLLDBSP reg_ctx_sp (new RegisterContextLLDB (m_thread, 
+                                                               RegisterContextLLDBSP(), 
+                                                               first_cursor_sp->sctx, 
+                                                               0, *this));
     if (reg_ctx_sp.get() == NULL)
         return false;
     
@@ -87,7 +87,7 @@
 
     // Everything checks out, so release the auto pointer value and let the
     // cursor own it in its shared pointer
-    first_cursor_sp->reg_ctx = reg_ctx_sp;
+    first_cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp;
     m_frames.push_back (first_cursor_sp);
     return true;
 }
@@ -104,10 +104,11 @@
         return false;
 
     uint32_t cur_idx = m_frames.size ();
-    RegisterContextLLDBSharedPtr reg_ctx_sp(new RegisterContextLLDB (m_thread, 
-                                                                       m_frames[cur_idx - 1]->reg_ctx, 
-                                                                       cursor_sp->sctx, 
-                                                                       cur_idx, *this));
+    RegisterContextLLDBSP reg_ctx_sp(new RegisterContextLLDB (m_thread, 
+                                                              m_frames[cur_idx - 1]->reg_ctx_lldb_sp, 
+                                                              cursor_sp->sctx, 
+                                                              cur_idx, 
+                                                              *this));
     if (reg_ctx_sp.get() == NULL)
         return false;
 
@@ -171,7 +172,7 @@
             }
         }
     }
-    cursor_sp->reg_ctx = reg_ctx_sp;
+    cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp;
     m_frames.push_back (cursor_sp);
     return true;
 }
@@ -218,21 +219,27 @@
 
     ABI *abi = m_thread.GetProcess().GetABI().get();
 
-    while (idx >= m_frames.size() && AddOneMoreFrame (abi))
-        ;
+    while (idx >= m_frames.size())
+    {
+        if (!AddOneMoreFrame (abi))
+            break;
+    }
 
-    if (idx < m_frames.size ())
-        reg_ctx_sp = m_frames[idx]->reg_ctx;
+    const uint32_t num_frames = m_frames.size();
+    if (idx < num_frames)
+    {
+        Cursor *frame_cursor = m_frames[idx].get();
+        reg_ctx_sp = frame_cursor->reg_ctx_lldb_sp->shared_from_this();
+    }
     return reg_ctx_sp;
 }
 
-UnwindLLDB::RegisterContextLLDBSharedPtr
+UnwindLLDB::RegisterContextLLDBSP
 UnwindLLDB::GetRegisterContextForFrameNum (uint32_t frame_num)
 {
-    RegisterContextLLDBSharedPtr reg_ctx_sp;
-    if (frame_num >= m_frames.size())
-        return reg_ctx_sp;
-    reg_ctx_sp = m_frames[frame_num]->reg_ctx;
+    RegisterContextLLDBSP reg_ctx_sp;
+    if (frame_num < m_frames.size())
+        reg_ctx_sp = m_frames[frame_num]->reg_ctx_lldb_sp;
     return reg_ctx_sp;
 }
 
@@ -244,7 +251,7 @@
         return false;
     while (frame_num >= 0)
     {
-        if (m_frames[frame_num]->reg_ctx->SavedLocationForRegister (lldb_regnum, regloc, false))
+        if (m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister (lldb_regnum, regloc, false))
             return true;
         frame_num--;
     }
diff --git a/source/Plugins/Process/Utility/UnwindLLDB.h b/source/Plugins/Process/Utility/UnwindLLDB.h
index ec9271b..b9352b6 100644
--- a/source/Plugins/Process/Utility/UnwindLLDB.h
+++ b/source/Plugins/Process/Utility/UnwindLLDB.h
@@ -69,11 +69,11 @@
     lldb::RegisterContextSP
     DoCreateRegisterContextForFrame (lldb_private::StackFrame *frame);
 
-    typedef lldb::SharedPtr<lldb_private::RegisterContextLLDB>::Type RegisterContextLLDBSharedPtr;
+    typedef SHARED_PTR(RegisterContextLLDB) RegisterContextLLDBSP;
 
     // Needed to retrieve the "next" frame (e.g. frame 2 needs to retrieve frame 1's RegisterContextLLDB)
     // The RegisterContext for frame_num must already exist or this returns an empty shared pointer.
-    RegisterContextLLDBSharedPtr
+    RegisterContextLLDBSP
     GetRegisterContextForFrameNum (uint32_t frame_num);
 
     // Iterate over the RegisterContextLLDB's in our m_frames vector, look for the first one that
@@ -89,14 +89,14 @@
         lldb::addr_t start_pc;  // The start address of the function/symbol for this frame - current pc if unknown
         lldb::addr_t cfa;       // The canonical frame address for this stack frame
         lldb_private::SymbolContext sctx;  // A symbol context we'll contribute to & provide to the StackFrame creation
-        RegisterContextLLDBSharedPtr reg_ctx; // These are all RegisterContextLLDB's
+        RegisterContextLLDBSP reg_ctx_lldb_sp; // These are all RegisterContextLLDB's
 
-        Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { }
+        Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx_lldb_sp() { }
     private:
         DISALLOW_COPY_AND_ASSIGN (Cursor);
     };
 
-    typedef lldb::SharedPtr<Cursor>::Type CursorSP;
+    typedef SHARED_PTR(Cursor) CursorSP;
     std::vector<CursorSP> m_frames;
 
     bool AddOneMoreFrame (ABI *abi);
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
index a605221..7fd5802 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
@@ -104,7 +104,7 @@
     // Now make a new log with this stream if one was provided
     if (log_stream_sp)
     {
-        log = make_shared<Log>(log_stream_sp);
+        log.reset (new Log(log_stream_sp));
         GetLog () = log;
     }
 
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index e71d319..f4ee96b 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -21,7 +21,7 @@
 typedef CStringToDIEMap::iterator CStringToDIEMapIter;
 typedef CStringToDIEMap::const_iterator CStringToDIEMapConstIter;
 
-typedef lldb::SharedPtr<DWARFCompileUnit>::Type DWARFCompileUnitSP;
+typedef SHARED_PTR(DWARFCompileUnit) DWARFCompileUnitSP;
 
 class DWARFDebugInfo
 {
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
index 51e0062..843d081 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
@@ -68,7 +68,7 @@
         {
         }
 
-        typedef lldb::SharedPtr<Prologue>::Type shared_ptr;
+        typedef SHARED_PTR(Prologue) shared_ptr;
 
         uint32_t    total_length;   // The size in bytes of the statement information for this compilation unit (not including the total_length field itself).
         uint16_t    version;        // Version identifier for the statement information format.
@@ -135,7 +135,7 @@
     //------------------------------------------------------------------
     struct LineTable
     {
-        typedef lldb::SharedPtr<LineTable>::Type shared_ptr;
+        typedef SHARED_PTR(LineTable) shared_ptr;
 
         LineTable() :
             prologue(),
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 816cd64..5e96350 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2031,7 +2031,7 @@
         
     if (sc.function)
     {        
-        sc.module_sp = sc.function->CalculateSymbolContextModule();
+        sc.module_sp = sc.function->CalculateSymbolContextModule()->shared_from_this();
         return true;
     }
     
@@ -2449,7 +2449,7 @@
     if (num_matches)
     {
         SymbolContext sc;
-        sc.module_sp = m_obj_file->GetModule();
+        sc.module_sp = m_obj_file->GetModule()->shared_from_this();
         assert (sc.module_sp);
         
         DWARFDebugInfo* debug_info = DebugInfo();
@@ -2535,7 +2535,7 @@
     }
 
     SymbolContext sc;
-    sc.module_sp = m_obj_file->GetModule();
+    sc.module_sp = m_obj_file->GetModule()->shared_from_this();
     assert (sc.module_sp);
     
     DWARFCompileUnit* dwarf_cu = NULL;
@@ -3149,7 +3149,7 @@
                 if (matching_type)
                 {
                     // We found a type pointer, now find the shared pointer form our type list
-                    types.InsertUnique (TypeSP (matching_type));
+                    types.InsertUnique (matching_type->shared_from_this());
                     if (types.GetSize() >= max_matches)
                         break;
                 }
@@ -3267,7 +3267,7 @@
         if (matching_type)
         {
             // We found a type pointer, now find the shared pointer form our type list
-            types.InsertUnique (TypeSP (matching_type));
+            types.InsertUnique (matching_type->shared_from_this());
             ++num_matches;
             if (num_matches >= max_matches)
                 break;
@@ -3282,7 +3282,6 @@
 size_t
 SymbolFileDWARF::ParseChildParameters (const SymbolContext& sc,
                                        clang::DeclContext *containing_decl_ctx,
-                                       TypeSP& type_sp,
                                        DWARFCompileUnit* dwarf_cu,
                                        const DWARFDebugInfoEntry *parent_die,
                                        bool skip_artificial,
@@ -3676,7 +3675,7 @@
         else if (type_ptr != DIE_IS_BEING_PARSED)
         {
             // Grab the existing type from the master types lists
-            type_sp = type_ptr;
+            type_sp = type_ptr->shared_from_this();
         }
 
     }
@@ -4026,7 +4025,7 @@
                             
                             if (die)
                                 m_die_to_type[die] = resolved_type;
-                            type_sp = resolved_type;
+                            type_sp = resolved_type->shared_from_this();
                             break;
                         }
                     }
@@ -4148,7 +4147,7 @@
                                       MakeUserID(type_cu->GetOffset()));
                         
                         m_die_to_type[die] = resolved_type;
-                        type_sp = resolved_type;
+                        type_sp = resolved_type->shared_from_this();
                         break;
                     }
                 }
@@ -4934,7 +4933,6 @@
                         bool skip_artificial = true;
                         ParseChildParameters (sc, 
                                               containing_decl_ctx,
-                                              type_sp, 
                                               dwarf_cu, 
                                               die, 
                                               skip_artificial,
@@ -5120,7 +5118,7 @@
                                                 type_ptr = m_die_to_type[die];
                                                 if (type_ptr)
                                                 {
-                                                    type_sp = type_ptr;
+                                                    type_sp = type_ptr->shared_from_this();
                                                     break;
                                                 }
                                             }
@@ -5343,7 +5341,7 @@
         }
         else if (type_ptr != DIE_IS_BEING_PARSED)
         {
-            type_sp = type_ptr;
+            type_sp = type_ptr->shared_from_this();
         }
     }
     return type_sp;
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 7f4b16e..72ac346 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -347,7 +347,6 @@
     size_t                  ParseChildParameters(
                                 const lldb_private::SymbolContext& sc,
                                 clang::DeclContext *containing_decl_ctx,
-                                lldb::TypeSP& type_sp,
                                 DWARFCompileUnit* dwarf_cu,
                                 const DWARFDebugInfoEntry *parent_die,
                                 bool skip_artificial,
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 5c4fba2..2fa5a93 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -172,10 +172,10 @@
             // use the debug map, to add new sections to each .o file and
             // even though a .o file might not have changed, the sections
             // that get added to the .o file can change.
-            comp_unit_info->oso_module_sp = new Module (oso_file_spec, 
-                                                        m_obj_file->GetModule()->GetArchitecture(),
-                                                        NULL, 
-                                                        0);
+            comp_unit_info->oso_module_sp.reset (new Module (oso_file_spec, 
+                                                             m_obj_file->GetModule()->GetArchitecture(),
+                                                             NULL, 
+                                                             0));
         }
     }
     return comp_unit_info->oso_module_sp.get();
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index 6d80d77..8dca2c5 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -141,7 +141,7 @@
         lldb_private::SymbolVendor *oso_symbol_vendor;
         std::vector<uint32_t> function_indexes;
         std::vector<uint32_t> static_indexes;
-        lldb::SharedPtr<lldb_private::SectionList>::Type debug_map_sections_sp;
+        SHARED_PTR(lldb_private::SectionList) debug_map_sections_sp;
 
         CompileUnitInfo() :
             so_file (),
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index d560bc3..6fc5968 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -411,7 +411,7 @@
         
         Declaration decl;
         
-        lldb::TypeSP type(new Type (iter->second,
+        lldb::TypeSP type(new Type (match->value,
                                     this,
                                     name,
                                     0,      // byte_size - don't change this from 0, we currently use that to identify these "synthetic" ObjC class types.
diff --git a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
index 1224367..fce609b 100644
--- a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -162,7 +162,7 @@
             // Just create our symbol vendor using the current objfile as this is either
             // an executable with no dSYM (that we could locate), an executable with
             // a dSYM that has a UUID that doesn't match.
-            symbol_vendor->AddSymbolFileRepresentation(obj_file->GetSP());
+            symbol_vendor->AddSymbolFileRepresentation(obj_file->shared_from_this());
         }
     }
     return symbol_vendor;