From 4af5961caaeec5162f90f7471853fe109689d8d4 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Fri, 19 Dec 2014 19:20:44 +0000 Subject: [PATCH] Audit uses of ConstString::AsCString() to make sure they weren't assuming they would always get a non-NULL string back. llvm-svn: 224602 --- lldb/source/Core/Address.cpp | 4 +++- lldb/source/Core/AddressRange.cpp | 2 +- lldb/source/Core/AddressResolverFileLine.cpp | 2 +- lldb/source/Core/SearchFilter.cpp | 10 +++++----- lldb/source/Interpreter/CommandInterpreter.cpp | 2 +- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp | 2 +- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 4 ++-- lldb/source/Target/Target.cpp | 4 ++-- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index 8f5e19f..a79becb 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -433,7 +433,9 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum case DumpStyleModuleWithFileAddress: if (section_sp) - s->Printf("%s[", section_sp->GetModule()->GetFileSpec().GetFilename().AsCString()); + { + s->Printf("%s[", section_sp->GetModule()->GetFileSpec().GetFilename().AsCString("")); + } // Fall through case DumpStyleFileAddress: { diff --git a/lldb/source/Core/AddressRange.cpp b/lldb/source/Core/AddressRange.cpp index 3505d56..ac64833 100644 --- a/lldb/source/Core/AddressRange.cpp +++ b/lldb/source/Core/AddressRange.cpp @@ -179,7 +179,7 @@ AddressRange::Dump(Stream *s, Target *target, Address::DumpStyle style, Address: { ModuleSP module_sp (GetBaseAddress().GetModule()); if (module_sp) - s->Printf("%s", module_sp->GetFileSpec().GetFilename().AsCString()); + s->Printf("%s", module_sp->GetFileSpec().GetFilename().AsCString("")); } s->AddressRange(vmaddr, vmaddr + GetByteSize(), addr_size); return true; diff --git a/lldb/source/Core/AddressResolverFileLine.cpp b/lldb/source/Core/AddressResolverFileLine.cpp index f7004c8..6089abd 100644 --- a/lldb/source/Core/AddressResolverFileLine.cpp +++ b/lldb/source/Core/AddressResolverFileLine.cpp @@ -96,7 +96,7 @@ AddressResolverFileLine::GetDepth() void AddressResolverFileLine::GetDescription (Stream *s) { - s->Printf ("File and line address - file: \"%s\" line: %u", m_file_spec.GetFilename().AsCString(), m_line_number); + s->Printf ("File and line address - file: \"%s\" line: %u", m_file_spec.GetFilename().AsCString(""), m_line_number); } diff --git a/lldb/source/Core/SearchFilter.cpp b/lldb/source/Core/SearchFilter.cpp index 8e3d8d0..9c3412a 100644 --- a/lldb/source/Core/SearchFilter.cpp +++ b/lldb/source/Core/SearchFilter.cpp @@ -450,7 +450,7 @@ SearchFilterByModule::GetDescription (Stream *s) } else { - s->PutCString(m_module_spec.GetFilename().AsCString("")); + s->PutCString(m_module_spec.GetFilename().AsCString("")); } } @@ -612,7 +612,7 @@ SearchFilterByModuleList::GetDescription (Stream *s) } else { - s->PutCString(m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString("")); + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString("")); } } else @@ -628,7 +628,7 @@ SearchFilterByModuleList::GetDescription (Stream *s) } else { - s->PutCString(m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString("")); + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString("")); } if (i != num_modules - 1) s->PutCString (", "); @@ -811,7 +811,7 @@ SearchFilterByModuleListAndCU::GetDescription (Stream *s) } else { - s->PutCString(m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString("")); + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString("")); } } else if (num_modules > 0) @@ -827,7 +827,7 @@ SearchFilterByModuleListAndCU::GetDescription (Stream *s) } else { - s->PutCString(m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString("")); + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString("")); } if (i != num_modules - 1) s->PutCString (", "); diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 895106a..2b68f5c 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2776,7 +2776,7 @@ CommandInterpreter::HandleCommandsFromFile (FileSpec &cmd_file, else { result.AppendErrorWithFormat ("Error reading commands from file %s - file not found.\n", - cmd_file.GetFilename().AsCString()); + cmd_file.GetFilename().AsCString("")); result.SetStatus (eReturnStatusFailed); return; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index 6bf5b22..10b51ff 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -1030,7 +1030,7 @@ DWARFDebugInfoEntry::DumpLocation const char *obj_file_name = NULL; ObjectFile *obj_file = dwarf2Data->GetObjectFile(); if (obj_file) - obj_file_name = obj_file->GetFileSpec().GetFilename().AsCString(); + obj_file_name = obj_file->GetFileSpec().GetFilename().AsCString(""); const char *die_name = GetName (dwarf2Data, cu); s.Printf ("0x%8.8x/0x%8.8x: %-30s (from %s in %s)", cu->GetOffset(), diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index eeebb8a..e184159 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3033,7 +3033,7 @@ SymbolFileDWARF::Index () m_indexed = true; Timer scoped_timer (__PRETTY_FUNCTION__, "SymbolFileDWARF::Index (%s)", - GetObjectFile()->GetFileSpec().GetFilename().AsCString()); + GetObjectFile()->GetFileSpec().GetFilename().AsCString("")); DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) @@ -4929,7 +4929,7 @@ SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry { DEBUG_PRINTF ("resolved 0x%8.8" PRIx64 " from %s to 0x%8.8" PRIx64 " (cu 0x%8.8" PRIx64 ")\n", MakeUserID(die->GetOffset()), - m_obj_file->GetFileSpec().GetFilename().AsCString(), + m_obj_file->GetFileSpec().GetFilename().AsCString(""), MakeUserID(type_die->GetOffset()), MakeUserID(type_cu->GetOffset())); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 76a89a4..9d605ed 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -1383,9 +1383,9 @@ Target::ReadMemory (const Address& addr, ModuleSP addr_module_sp (resolved_addr.GetModule()); if (addr_module_sp && addr_module_sp->GetFileSpec()) error.SetErrorStringWithFormat("%s[0x%" PRIx64 "] can't be resolved, %s in not currently loaded", - addr_module_sp->GetFileSpec().GetFilename().AsCString(), + addr_module_sp->GetFileSpec().GetFilename().AsCString(""), resolved_addr.GetFileAddress(), - addr_module_sp->GetFileSpec().GetFilename().AsCString()); + addr_module_sp->GetFileSpec().GetFilename().AsCString("")); else error.SetErrorStringWithFormat("0x%" PRIx64 " can't be resolved", resolved_addr.GetFileAddress()); } -- 2.7.4