Bunch of cleanups for warnings found by the llvm static analyzer.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@165808 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/lldb/Symbol/VariableList.h b/include/lldb/Symbol/VariableList.h
index 27d6b28..21f37e4 100644
--- a/include/lldb/Symbol/VariableList.h
+++ b/include/lldb/Symbol/VariableList.h
@@ -50,11 +50,6 @@
     lldb::VariableSP
     FindVariable (const ConstString& name);
 
-    // Find the argument variable that represents the language specific
-    // object pointer ("this" in C++, or "self" in Objective C).
-    lldb::VariableSP
-    FindArtificialObjectVariable (lldb::LanguageType language) const;
-
     uint32_t
     FindVariableIndex (const lldb::VariableSP &var_sp);
 
diff --git a/lldb.xcodeproj/project.pbxproj b/lldb.xcodeproj/project.pbxproj
index e5f870b..4f52df6 100644
--- a/lldb.xcodeproj/project.pbxproj
+++ b/lldb.xcodeproj/project.pbxproj
@@ -4544,7 +4544,6 @@
 				);
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
 				OTHER_CFLAGS = "";
 				OTHER_LDFLAGS = "";
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -4562,7 +4561,6 @@
 				CURRENT_PROJECT_VERSION = 168;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
 				OTHER_CFLAGS = "";
 				OTHER_LDFLAGS = "";
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -4580,7 +4578,6 @@
 				CURRENT_PROJECT_VERSION = 168;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
 				OTHER_CFLAGS = "";
 				OTHER_LDFLAGS = "";
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -4604,7 +4601,6 @@
 				HEADER_SEARCH_PATHS = /usr/include/libxml2;
 				LD_DYLIB_INSTALL_NAME = "$(DEVELOPER_DIR)/Library/PrivateFrameworks/LLDB.framework/Resources/lldb-core.a";
 				MACH_O_TYPE = staticlib;
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
 				OTHER_CPLUSPLUSFLAGS = (
 					"-fno-rtti",
 					"-Wglobal-constructors",
@@ -4635,7 +4631,6 @@
 				HEADER_SEARCH_PATHS = /usr/include/libxml2;
 				LD_DYLIB_INSTALL_NAME = "$(DEVELOPER_DIR)/Library/PrivateFrameworks/LLDB.framework/Resources/lldb-core.a";
 				MACH_O_TYPE = staticlib;
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
 				OTHER_CPLUSPLUSFLAGS = (
 					"-fno-rtti",
 					"-Wglobal-constructors",
@@ -4666,7 +4661,6 @@
 				HEADER_SEARCH_PATHS = /usr/include/libxml2;
 				LD_DYLIB_INSTALL_NAME = "$(DEVELOPER_DIR)/Library/PrivateFrameworks/LLDB.framework/Resources/lldb-core.a";
 				MACH_O_TYPE = staticlib;
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
 				OTHER_CPLUSPLUSFLAGS = (
 					"-fno-rtti",
 					"-Wglobal-constructors",
@@ -5363,7 +5357,6 @@
 				HEADER_SEARCH_PATHS = /usr/include/libxml2;
 				LD_DYLIB_INSTALL_NAME = "$(DEVELOPER_DIR)/Library/PrivateFrameworks/LLDB.framework/Resources/lldb-core.a";
 				MACH_O_TYPE = staticlib;
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
 				OTHER_CPLUSPLUSFLAGS = (
 					"-fno-rtti",
 					"-Wglobal-constructors",
@@ -5532,7 +5525,6 @@
 				);
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
-				MACOSX_DEPLOYMENT_TARGET = 10.7;
 				OTHER_CFLAGS = "";
 				OTHER_LDFLAGS = "";
 				PRODUCT_NAME = "$(TARGET_NAME)";
diff --git a/source/API/SBTypeNameSpecifier.cpp b/source/API/SBTypeNameSpecifier.cpp
index 49a8b41..bc3c63e 100644
--- a/source/API/SBTypeNameSpecifier.cpp
+++ b/source/API/SBTypeNameSpecifier.cpp
@@ -116,6 +116,8 @@
     
     if (IsRegex() != rhs.IsRegex())
         return false;
+    if (GetName() == NULL || rhs.GetName() == NULL)
+        return false;
     
     return (strcmp(GetName(), rhs.GetName()) == 0);
 }
diff --git a/source/API/SBTypeSummary.cpp b/source/API/SBTypeSummary.cpp
index 4108da0..fd6e929 100644
--- a/source/API/SBTypeSummary.cpp
+++ b/source/API/SBTypeSummary.cpp
@@ -233,7 +233,7 @@
     if (IsFunctionName() != rhs.IsFunctionName())
         return false;
     
-    if ( strcmp(GetData(), rhs.GetData()) )
+    if ( GetData() == NULL || rhs.GetData() == NULL || strcmp(GetData(), rhs.GetData()) )
         return false;
     
     return GetOptions() == rhs.GetOptions();
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index 82f7cf3..6f77106 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -1227,7 +1227,7 @@
 static void
 DumpModuleUUID (Stream &strm, Module *module)
 {
-    if (module->GetUUID().IsValid())
+    if (module && module->GetUUID().IsValid())
         module->GetUUID().Dump (&strm);
     else
         strm.PutCString("                                    ");
@@ -2720,8 +2720,14 @@
                     }
                     else
                     {
-                        module->GetFileSpec().GetPath (path, sizeof(path));
-                        result.AppendErrorWithFormat ("invalid module '%s'.\n", path);
+                        FileSpec *module_spec_file = module_spec.GetFileSpecPtr();
+                        if (module_spec_file)
+                        {
+                            module_spec_file->GetPath (path, sizeof(path));
+                            result.AppendErrorWithFormat ("invalid module '%s'.\n", path);
+                        }
+                        else
+                            result.AppendError ("no module spec");
                         result.SetStatus (eReturnStatusFailed);
                     }
                 }
@@ -3033,6 +3039,12 @@
     PrintModule (Target *target, Module *module, uint32_t idx, int indent, Stream &strm)
     {
 
+        if (module == NULL)
+        {
+            strm.PutCString("Null module");
+            return;
+        }
+        
         bool dump_object_name = false;
         if (m_options.m_format_array.empty())
         {
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 5166300..5a575bd 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -117,12 +117,14 @@
              ++entity_index)
         {
             ClangExpressionVariableSP var_sp(m_found_entities.GetVariableAtIndex(entity_index));
-            if (var_sp && 
-                var_sp->m_parser_vars.get() && 
-                var_sp->m_parser_vars->m_lldb_value)
+            if (var_sp)
+            {
+                if (var_sp->m_parser_vars.get() &&
+                    var_sp->m_parser_vars->m_lldb_value)
                 delete var_sp->m_parser_vars->m_lldb_value;
             
-            var_sp->DisableParserVars();
+                var_sp->DisableParserVars();
+            }
         }
         
         for (size_t pvar_index = 0, num_pvars = m_parser_vars->m_persistent_vars->GetSize();
@@ -2706,7 +2708,7 @@
                                          append,
                                          sc_list);
             }
-            else if (!namespace_decl)
+            else if (target && !namespace_decl)
             {
                 const bool include_symbols = true;
                 
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 1bf791b..3d82b12 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -755,6 +755,7 @@
     {
         ret.SetErrorToGenericError();
         ret.SetErrorString("Couldn't find the target");
+        return ret;
     }
     
     lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second, 0));
diff --git a/source/Expression/ClangUserExpression.cpp b/source/Expression/ClangUserExpression.cpp
index 877c8d7..c037d02 100644
--- a/source/Expression/ClangUserExpression.cpp
+++ b/source/Expression/ClangUserExpression.cpp
@@ -552,7 +552,7 @@
 
     if (m_jit_start_addr != LLDB_INVALID_ADDRESS)
     {
-        lldb::addr_t struct_address;
+        lldb::addr_t struct_address = LLDB_INVALID_ADDRESS;
                 
         lldb::addr_t object_ptr = 0;
         lldb::addr_t cmd_ptr = 0;
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index 02b901d..e0342c9 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -78,11 +78,14 @@
 PrintValue(const Value *value, bool truncate = false)
 {
     std::string s;
-    raw_string_ostream rso(s);
-    value->print(rso);
-    rso.flush();
-    if (truncate)
-        s.resize(s.length() - 1);
+    if (value)
+    {
+        raw_string_ostream rso(s);
+        value->print(rso);
+        rso.flush();
+        if (truncate)
+            s.resize(s.length() - 1);
+    }
     return s;
 }
 
@@ -238,7 +241,7 @@
                 // Check for an alternate mangling for "std::basic_string<char>"
                 // that is part of the itanium C++ name mangling scheme
                 const char *name_cstr = name.GetCString();
-                if (strncmp(name_cstr, "_ZNKSbIcE", strlen("_ZNKSbIcE")) == 0)
+                if (name_cstr && strncmp(name_cstr, "_ZNKSbIcE", strlen("_ZNKSbIcE")) == 0)
                 {
                     std::string alternate_mangling("_ZNKSs");
                     alternate_mangling.append (name_cstr + strlen("_ZNKSbIcE"));
@@ -492,6 +495,9 @@
         }
     }
     
+    if (!original_load)
+        return;
+    
     Value *loaded_value = original_load->getPointerOperand();
     GlobalVariable *loaded_global = dyn_cast<GlobalVariable>(loaded_value);
     
diff --git a/source/Interpreter/CommandObjectScript.cpp b/source/Interpreter/CommandObjectScript.cpp
index 76bfe6e..ce097b7 100644
--- a/source/Interpreter/CommandObjectScript.cpp
+++ b/source/Interpreter/CommandObjectScript.cpp
@@ -55,6 +55,7 @@
     {
         result.AppendError("no script interpreter");
         result.SetStatus (eReturnStatusFailed);
+        return false;
     }
 
     DataVisualization::ForceUpdate(); // script might change Python code we use for formatting.. make sure we keep up to date with it
diff --git a/source/Interpreter/Options.cpp b/source/Interpreter/Options.cpp
index daf631f..484e778 100644
--- a/source/Interpreter/Options.cpp
+++ b/source/Interpreter/Options.cpp
@@ -439,7 +439,8 @@
 
         // Different option sets may require different args.
         StreamString args_str;
-        cmd->GetFormattedCommandArguments(args_str, opt_set_mask);
+        if (cmd)
+            cmd->GetFormattedCommandArguments(args_str, opt_set_mask);
 
         // First go through and print all options that take no arguments as
         // a single string. If a command has "-a" "-b" and "-c", this will show
@@ -569,7 +570,8 @@
         }
     }
     
-    if (cmd->WantsRawCommandString() &&
+    if (cmd &&
+        cmd->WantsRawCommandString() &&
         arguments_str.GetSize() > 0)
     {        
         strm.PutChar('\n');
diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
index e3b4ae6..9b4c056 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -618,9 +618,8 @@
 
                 unsigned char buffer[16];
                 ByteOrder byte_order = data.GetByteOrder();
-                uint32_t return_bytes;
                 
-                return_bytes = data.CopyByteOrderedData (0, num_bytes, buffer, 16, byte_order);
+                data.CopyByteOrderedData (0, num_bytes, buffer, 16, byte_order);
                 xmm0_value.SetBytes(buffer, 16, byte_order);
                 reg_ctx->WriteRegister(xmm0_info, xmm0_value);
                 set_it_simple = true;
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
index fd091fe..378d9c5 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
@@ -178,11 +178,15 @@
         uint32_t addr_nibble_size = 8;
         addr_t base_addr = LLDB_INVALID_ADDRESS;
         Target *target = exe_ctx ? exe_ctx->GetTargetPtr() : NULL;
-        if (target && !target->GetSectionLoadList().IsEmpty())
-            base_addr = GetAddress().GetLoadAddress (target);
+        if (target)
+        {
+            addr_nibble_size = target->GetArchitecture().GetAddressByteSize() * 2;
+            if (!target->GetSectionLoadList().IsEmpty())
+                base_addr = GetAddress().GetLoadAddress (target);
+        }
+        
         if (base_addr == LLDB_INVALID_ADDRESS)
             base_addr = GetAddress().GetFileAddress ();
-        addr_nibble_size = target->GetArchitecture().GetAddressByteSize() * 2;
 
         lldb::addr_t PC = base_addr + EDInstByteSize(m_inst);
         
diff --git a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index a7ec411..247eb16 100644
--- a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -446,7 +446,7 @@
             }
         }
 
-        if (m_kernel.IsLoaded())
+        if (m_kernel.IsLoaded() && m_kernel.module_sp)
         {
             static ConstString kext_summary_symbol ("gLoadedKextSummaries");
             const Symbol *symbol = m_kernel.module_sp->FindFirstSymbolWithNameAndType (kext_summary_symbol, eSymbolTypeData);
diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index f44f185..9d288a4 100644
--- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -3570,24 +3570,27 @@
             GetNumThreadContexts ();
 
         const FileRangeArray::Entry *thread_context_file_range = m_thread_context_offsets.GetEntryAtIndex (idx);
-        
-        DataExtractor data (m_data, 
-                            thread_context_file_range->GetRangeBase(), 
-                            thread_context_file_range->GetByteSize());
-
-        switch (m_header.cputype)
+        if (thread_context_file_range)
         {
-            case llvm::MachO::CPUTypeARM:
-                reg_ctx_sp.reset (new RegisterContextDarwin_arm_Mach (thread, data));
-                break;
-                
-            case llvm::MachO::CPUTypeI386:
-                reg_ctx_sp.reset (new RegisterContextDarwin_i386_Mach (thread, data));
-                break;
-                
-            case llvm::MachO::CPUTypeX86_64:
-                reg_ctx_sp.reset (new RegisterContextDarwin_x86_64_Mach (thread, data));
-                break;
+        
+            DataExtractor data (m_data, 
+                                thread_context_file_range->GetRangeBase(), 
+                                thread_context_file_range->GetByteSize());
+
+            switch (m_header.cputype)
+            {
+                case llvm::MachO::CPUTypeARM:
+                    reg_ctx_sp.reset (new RegisterContextDarwin_arm_Mach (thread, data));
+                    break;
+                    
+                case llvm::MachO::CPUTypeI386:
+                    reg_ctx_sp.reset (new RegisterContextDarwin_i386_Mach (thread, data));
+                    break;
+                    
+                case llvm::MachO::CPUTypeX86_64:
+                    reg_ctx_sp.reset (new RegisterContextDarwin_x86_64_Mach (thread, data));
+                    break;
+            }
         }
     }
     return reg_ctx_sp;
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index d811fee..96b8129 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -779,7 +779,7 @@
     // right thing.  It'd be nice if there was a way to ask the eh_frame directly if it is asynchronous
     // (can be trusted at every instruction point) or synchronous (the normal case - only at call sites).
     // But there is not.
-    if (process->GetDynamicLoader() && process->GetDynamicLoader()->AlwaysRelyOnEHUnwindInfo (m_sym_ctx))
+    if (process && process->GetDynamicLoader() && process->GetDynamicLoader()->AlwaysRelyOnEHUnwindInfo (m_sym_ctx))
     {
         unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one);
         if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc))
diff --git a/source/Plugins/Process/Utility/UnwindLLDB.cpp b/source/Plugins/Process/Utility/UnwindLLDB.cpp
index b993c95..5581496 100644
--- a/source/Plugins/Process/Utility/UnwindLLDB.cpp
+++ b/source/Plugins/Process/Utility/UnwindLLDB.cpp
@@ -175,7 +175,7 @@
         {
             if (m_frames.back()->cfa == cursor_sp->cfa)
                 goto unwind_done; // Infinite loop where the current cursor is the same as the previous one...
-            else if (abi->StackUsesFrames())
+            else if (abi && abi->StackUsesFrames())
             {
                 // We might have a CFA that is not using the frame pointer and
                 // we want to validate that the frame pointer is valid.
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index 60f349c..1d0814c 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -386,7 +386,9 @@
     // down.
     const bool clear_dies = ExtractDIEsIfNeeded (false) > 1;
     
-    DIE()->BuildAddressRangeTable(dwarf2Data, this, debug_aranges);
+    const DWARFDebugInfoEntry* die = DIE();
+    if (die)
+        die->BuildAddressRangeTable(dwarf2Data, this, debug_aranges);
     
     // Keep memory down by clearing DIEs if this generate function
     // caused them to be parsed
@@ -410,7 +412,9 @@
                                                                     "DWARFCompileUnit::GetFunctionAranges() for compile unit at .debug_info[0x%8.8x]",
                                                                     GetOffset());
         }
-        DIE()->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get());
+        const DWARFDebugInfoEntry* die = DIE();
+        if (die)
+            die->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get());
         const bool minimize = false;
         m_func_aranges_ap->Sort(minimize);
     }
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
index 41a3d86..ec212fd 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
@@ -117,10 +117,11 @@
     for (size_t i=0; i<num_entries; ++i)
     {
         const RangeToDIE::Entry *entry = m_aranges.GetEntryAtIndex(i);
-        log->Printf ("0x%8.8x: [0x%llx - 0x%llx)", 
-                     entry->data,
-                     entry->GetRangeBase(),
-                     entry->GetRangeEnd());
+        if (entry)
+            log->Printf ("0x%8.8x: [0x%llx - 0x%llx)", 
+                         entry->data,
+                         entry->GetRangeBase(),
+                         entry->GetRangeEnd());
     }
 }
 
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 68b9516..5395a6a 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -701,7 +701,10 @@
     {
         const DWARFCompileUnitSP& cu_sp = *pos;
         DumpCallback(m_dwarf2Data, (DWARFCompileUnitSP&)cu_sp, NULL, 0, curr_depth, &dumpInfo);
-        cu_sp->DIE()->Dump(m_dwarf2Data, cu_sp.get(), *s, recurse_depth);
+        
+        const DWARFDebugInfoEntry* die = cu_sp->DIE();
+        if (die)
+            die->Dump(m_dwarf2Data, cu_sp.get(), *s, recurse_depth);
     }
 }
 
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 9343f8c..529ba9b 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -1035,6 +1035,7 @@
 {
     bool verbose    = s.GetVerbose();
     bool show_form  = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm);
+    
     const DataExtractor* debug_str_data = dwarf2Data ? &dwarf2Data->get_debug_str_data() : NULL;
     if (verbose)
         s.Offset (*offset_ptr);
@@ -1158,7 +1159,8 @@
                 form_value.Dump(s, debug_str_data, cu);
             uint32_t ranges_offset = form_value.Unsigned();
             dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
-            DWARFDebugRanges::Dump(s, dwarf2Data->get_debug_ranges_data(), &ranges_offset, base_addr);
+            if (dwarf2Data)
+                DWARFDebugRanges::Dump(s, dwarf2Data->get_debug_ranges_data(), &ranges_offset, base_addr);
         }
         break;
 
@@ -1509,6 +1511,9 @@
 ) const
 {
     const char* name = NULL;
+    if (!dwarf2Data)
+        return name;
+    
     DWARFFormValue form_value;
 
     if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value))
@@ -1546,6 +1551,12 @@
     Stream &s
 )
 {
+    if (dwarf2Data == NULL)
+    {
+        s.PutCString("NULL");
+        return false;
+    }
+    
     DWARFDebugInfoEntry die;
     uint32_t offset = die_offset;
     if (die.Extract(dwarf2Data, cu, &offset))
@@ -1589,6 +1600,12 @@
     Stream &s
 )
 {
+    if (dwarf2Data == NULL)
+    {
+        s.PutCString("NULL");
+        return false;
+    }
+    
     DWARFDebugInfoEntry die;
     uint32_t offset = die_offset;
     if (die.Extract(dwarf2Data, cu, &offset))
@@ -1609,6 +1626,9 @@
             {
                 bool result = true;
                 const DWARFAbbreviationDeclaration* abbrevDecl = die.GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
+                
+                if (abbrevDecl == NULL)
+                    return false;
 
                 switch (abbrevDecl->Tag())
                 {
@@ -2142,23 +2162,26 @@
                                                     const DWARFCompileUnit *cu,
                                                     dw_offset_t &offset) const
 {
-    offset = GetOffset();
-    
-    const DWARFAbbreviationDeclaration* abbrev_decl = cu->GetAbbreviations()->GetAbbreviationDeclaration (m_abbr_idx);
-    if (abbrev_decl)
+    if (dwarf2Data)
     {
-        // Make sure the abbreviation code still matches. If it doesn't and
-        // the DWARF data was mmap'ed, the backing file might have been modified
-        // which is bad news.
-        const uint64_t abbrev_code = dwarf2Data->get_debug_info_data().GetULEB128 (&offset);
-    
-        if (abbrev_decl->Code() == abbrev_code)
-            return abbrev_decl;
+        offset = GetOffset();
         
-        dwarf2Data->GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("0x%8.8x: the DWARF debug information has been modified (abbrev code was %u, and is now %u)", 
-                                                                               GetOffset(),
-                                                                               (uint32_t)abbrev_decl->Code(),
-                                                                               (uint32_t)abbrev_code);
+        const DWARFAbbreviationDeclaration* abbrev_decl = cu->GetAbbreviations()->GetAbbreviationDeclaration (m_abbr_idx);
+        if (abbrev_decl)
+        {
+            // Make sure the abbreviation code still matches. If it doesn't and
+            // the DWARF data was mmap'ed, the backing file might have been modified
+            // which is bad news.
+            const uint64_t abbrev_code = dwarf2Data->get_debug_info_data().GetULEB128 (&offset);
+        
+            if (abbrev_decl->Code() == abbrev_code)
+                return abbrev_decl;
+            
+            dwarf2Data->GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("0x%8.8x: the DWARF debug information has been modified (abbrev code was %u, and is now %u)", 
+                                                                                   GetOffset(),
+                                                                                   (uint32_t)abbrev_decl->Code(),
+                                                                                   (uint32_t)abbrev_code);
+        }
     }
     offset = DW_INVALID_OFFSET;
     return NULL;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp b/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp
index ef53eb5..ff65d08 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp
@@ -34,11 +34,12 @@
 
         s.PutCString("\n            ");
         s.Indent();
-        s.AddressRange (start_addr + base_addr, 
-                        end_addr + base_addr, 
-                        cu->GetAddressByteSize(), 
-                        NULL,
-                        ": ");
+        if (cu)
+            s.AddressRange (start_addr + base_addr, 
+                            end_addr + base_addr, 
+                            cu->GetAddressByteSize(), 
+                            NULL,
+                            ": ");
         uint32_t loc_length = debug_loc_data.GetU16(&offset);
 
         DataExtractor locationData(debug_loc_data, offset, loc_length);
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 80c98b0..bb96eae 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -921,9 +921,12 @@
     if (dwarf_cu)
     {
         const DWARFDebugInfoEntry *die = dwarf_cu->GetCompileUnitDIEOnly();
-        const uint32_t language = die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0);
-        if (language)
-            return (lldb::LanguageType)language;
+        if (die)
+        {
+            const uint32_t language = die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0);
+            if (language)
+                return (lldb::LanguageType)language;
+        }
     }
     return eLanguageTypeUnknown;
 }
diff --git a/source/Symbol/ClangASTImporter.cpp b/source/Symbol/ClangASTImporter.cpp
index b1328aa..b121284 100644
--- a/source/Symbol/ClangASTImporter.cpp
+++ b/source/Symbol/ClangASTImporter.cpp
@@ -316,6 +316,7 @@
 void 
 ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl)
 {
+    assert (decl);
     ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
 
     const DeclContext *parent_context = decl->getDeclContext();
diff --git a/source/Symbol/Function.cpp b/source/Symbol/Function.cpp
index 9ee35e3..0f060dd 100644
--- a/source/Symbol/Function.cpp
+++ b/source/Symbol/Function.cpp
@@ -343,7 +343,9 @@
 Function::GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target)
 {
     Type* func_type = GetType();
-    *s << "id = " << (const UserID&)*this << ", name = \"" << func_type->GetName() << "\", range = ";
+    const char *name = func_type ? func_type->GetName().AsCString() : "<unknown>";
+    
+    *s << "id = " << (const UserID&)*this << ", name = \"" << name << "\", range = ";
     
     Address::DumpStyle fallback_style;
     if (level == eDescriptionLevelVerbose)
@@ -493,10 +495,14 @@
 clang_type_t
 Function::GetReturnClangType ()
 {
-    clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType()));
-    const clang::FunctionType *function_type = llvm::dyn_cast<clang::FunctionType> (clang_type);
-    if (function_type)
-        return function_type->getResultType().getAsOpaquePtr();
+    Type *type = GetType();
+    if (type)
+    {
+        clang::QualType clang_type (clang::QualType::getFromOpaquePtr(type->GetClangFullType()));
+        const clang::FunctionType *function_type = llvm::dyn_cast<clang::FunctionType> (clang_type);
+        if (function_type)
+            return function_type->getResultType().getAsOpaquePtr();
+    }
     return NULL;
 }
 
diff --git a/source/Symbol/VariableList.cpp b/source/Symbol/VariableList.cpp
index 251fea8..11eb46c 100644
--- a/source/Symbol/VariableList.cpp
+++ b/source/Symbol/VariableList.cpp
@@ -178,41 +178,3 @@
         (*pos)->Dump(s, show_context);
     }
 }
-
-lldb::VariableSP
-VariableList::FindArtificialObjectVariable (lldb::LanguageType language) const
-{
-    lldb::VariableSP object_variable_sp;
-    ConstString object_variable_name;
-    switch (language)
-    {
-        case eLanguageTypeC_plus_plus:
-            object_variable_name.SetCString("this");
-            break;
-
-        case eLanguageTypeObjC:
-        case eLanguageTypeObjC_plus_plus:
-            object_variable_name.SetCString("self");
-            break;
-
-        default:
-            break;
-    }
-    if (object_variable_name)
-    {
-        const_iterator pos, end = m_variables.end();
-        for (pos = m_variables.begin(); pos != end; ++pos)
-        {
-            Variable *variable = pos->get();
-            if (variable->IsArtificial() &&
-                variable->GetScope() == eValueTypeVariableArgument &&
-                variable->GetName() == object_variable_name)
-            {
-                object_variable_sp = *pos;
-                break;
-            }
-        }
-    }
-    return object_variable_sp;
-}
-
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index 801bbc3..575063e 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -274,8 +274,6 @@
                 if (end_idx > 0)
                     end_idx += inlined_depth;
             }
-            else
-                inlined_depth = 0;
         }
         
         StackFrameSP unwind_frame_sp;
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 5a48a0a..6e505f2 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -1451,6 +1451,7 @@
         if (!abi)
         {
             return_error.SetErrorString("Could not find ABI to set return value.");
+            return return_error;
         }
         SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextFunction);
         
diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp
index 87e5e19..ab61c3c 100644
--- a/source/Target/ThreadPlanTracer.cpp
+++ b/source/Target/ThreadPlanTracer.cpp
@@ -72,9 +72,12 @@
     bool show_fullpaths = false;
     
     Stream *stream = GetLogStream();
-    m_thread.GetStackFrameAtIndex(0)->Dump (stream, show_frame_index, show_fullpaths);
-    stream->Printf("\n");
-    stream->Flush();
+    if (stream)
+    {
+        m_thread.GetStackFrameAtIndex(0)->Dump (stream, show_frame_index, show_fullpaths);
+        stream->Printf("\n");
+        stream->Flush();
+    }
     
 }
 
diff --git a/test/functionalities/abbreviation/TestAbbreviations.py b/test/functionalities/abbreviation/TestAbbreviations.py
index e79aa8e..b6c124a 100644
--- a/test/functionalities/abbreviation/TestAbbreviations.py
+++ b/test/functionalities/abbreviation/TestAbbreviations.py
@@ -89,7 +89,7 @@
                     patterns = [ "Current executable set to .*a.out.*" ])
 
         # By default, the setting interpreter.expand-regex-aliases is false.
-        self.expect("_regexp-b product", matching=False,
+        self.expect("_regexp-br product", matching=False,
                     substrs = [ "breakpoint set --name" ])
 
         match_object = lldbutil.run_break_set_command (self, "br s -n sum")