From: Eugene Zelenko Date: Mon, 29 Feb 2016 19:41:30 +0000 (+0000) Subject: Fix Clang-tidy modernize-use-nullptr warnings in source/Plugins/Language; other minor... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bbd16815b02ca6345598b523c1b07fa814c73dd2;p=platform%2Fupstream%2Fllvm.git Fix Clang-tidy modernize-use-nullptr warnings in source/Plugins/Language; other minor fixes. llvm-svn: 262246 --- diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 048ed58..232470c 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1,4 +1,4 @@ -//===-- CPlusPlusLanguage.cpp --------------------------------------*- C++ -*-===// +//===-- CPlusPlusLanguage.cpp -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -9,9 +9,17 @@ #include "CPlusPlusLanguage.h" +// C Includes +// C++ Includes +#include +#include +#include +#include +// Other libraries and framework includes #include "llvm/ADT/StringRef.h" +// Project includes #include "lldb/Core/ConstString.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/RegularExpression.h" @@ -26,11 +34,6 @@ #include "LibCxxAtomic.h" #include "LibStdcpp.h" -#include -#include -#include -#include - using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; @@ -56,10 +59,10 @@ CPlusPlusLanguage::GetPluginNameStatic() return g_name; } - //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ + lldb_private::ConstString CPlusPlusLanguage::GetPluginName() { @@ -75,6 +78,7 @@ CPlusPlusLanguage::GetPluginVersion() //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ + Language * CPlusPlusLanguage::CreateInstance (lldb::LanguageType language) { @@ -320,10 +324,7 @@ CPlusPlusLanguage::IsCPPMangledName (const char *name) // this is a C++ mangled name, but we can put that off till there is actually more than one // we care about. - if (name && name[0] == '_' && name[1] == 'Z') - return true; - else - return false; + return (name != nullptr && name[0] == '_' && name[1] == 'Z'); } bool @@ -345,7 +346,6 @@ class CPPRuntimeEquivalents public: CPPRuntimeEquivalents () { - m_impl.Append(ConstString("std::basic_string, std::allocator >").AsCString(), ConstString("basic_string")); // these two (with a prefixed std::) occur when c++stdlib string class occurs as a template argument in some STL container @@ -365,11 +365,10 @@ public: FindExactMatches (ConstString& type_name, std::vector& equivalents) { - uint32_t count = 0; for (ImplData match = m_impl.FindFirstValueForName(type_name.AsCString()); - match != NULL; + match != nullptr; match = m_impl.FindNextValueForName(match)) { equivalents.push_back(match->value); @@ -388,7 +387,6 @@ public: FindPartialMatches (ConstString& type_name, std::vector& equivalents) { - uint32_t count = 0; const char* type_name_cstr = type_name.AsCString(); @@ -407,11 +405,9 @@ public: } return count; - } private: - std::string& replace (std::string& target, std::string& pattern, std::string& with) @@ -430,14 +426,13 @@ private: const char *matching_key, std::vector& equivalents) { - std::string matching_key_str(matching_key); ConstString original_const(original); uint32_t count = 0; for (ImplData match = m_impl.FindFirstValueForName(matching_key); - match != NULL; + match != nullptr; match = m_impl.FindNextValueForName(match)) { std::string target(original); @@ -471,7 +466,6 @@ GetEquivalentsMap () return g_equivalents_map; } - uint32_t CPlusPlusLanguage::FindEquivalentNames(ConstString type_name, std::vector& equivalents) { @@ -479,8 +473,8 @@ CPlusPlusLanguage::FindEquivalentNames(ConstString type_name, std::vector') != NULL); // angle brackets in the type_name before trying to scan for partial matches + && (strchr(type_name.AsCString(), '<') != nullptr // we should only have partial matches when templates are involved, check that we have + && strchr(type_name.AsCString(), '>') != nullptr); // angle brackets in the type_name before trying to scan for partial matches if ( might_have_partials ) count = GetEquivalentsMap().FindPartialMatches(type_name, equivalents); @@ -806,4 +800,3 @@ CPlusPlusLanguage::GetHardcodedSynthetics () return g_formatters; } - diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 950bd62..beb89b8 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -9,6 +9,10 @@ #include "LibCxx.h" +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Error.h" @@ -74,12 +78,12 @@ lldb_private::formatters::LibcxxSmartPointerSummaryProvider (ValueObject& valobj } lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::LibcxxVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_bool_type(), -m_exe_ctx_ref(), -m_count(0), -m_base_data_address(0), -m_children() + SyntheticChildrenFrontEnd(*valobj_sp), + m_bool_type(), + m_exe_ctx_ref(), + m_count(0), + m_base_data_address(0), + m_children() { if (valobj_sp) { @@ -141,7 +145,7 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex (si return ValueObjectSP(); } bool bit_set = ((byte & mask) != 0); - DataBufferSP buffer_sp(new DataBufferHeap(m_bool_type.GetByteSize(nullptr),0)); + DataBufferSP buffer_sp(new DataBufferHeap(m_bool_type.GetByteSize(nullptr), 0)); if (bit_set && buffer_sp && buffer_sp->GetBytes()) *(buffer_sp->GetBytes()) = 1; // regardless of endianness, anything non-zero is true StreamString name; name.Printf("[%" PRIu64 "]", (uint64_t)idx); @@ -208,15 +212,12 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetIndexOfChildWith return idx; } -lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::~LibcxxVectorBoolSyntheticFrontEnd () -{} +lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::~LibcxxVectorBoolSyntheticFrontEnd() = default; SyntheticChildrenFrontEnd* lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp) { - if (!valobj_sp) - return NULL; - return (new LibcxxVectorBoolSyntheticFrontEnd(valobj_sp)); + return (valobj_sp ? new LibcxxVectorBoolSyntheticFrontEnd(valobj_sp) : nullptr); } /* @@ -238,8 +239,8 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator (CXXSynthetic */ lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::LibCxxMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_pair_ptr() + SyntheticChildrenFrontEnd(*valobj_sp), + m_pair_ptr() { if (valobj_sp) Update(); @@ -264,11 +265,11 @@ lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() // it if were a ValueObjectSP, we would end up with a loop (iterator -> synthetic -> child -> parent == iterator) // and that would in turn leak memory by never allowing the ValueObjects to die and free their memory m_pair_ptr = valobj_sp->GetValueForExpressionPath(".__i_.__ptr_->__value_", - NULL, - NULL, - NULL, - ValueObject::GetValueForExpressionPathOptions().DontCheckDotVsArrowSyntax().SetSyntheticChildrenTraversal(ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal::None), - NULL).get(); + nullptr, + nullptr, + nullptr, + ValueObject::GetValueForExpressionPathOptions().DontCheckDotVsArrowSyntax().SetSyntheticChildrenTraversal(ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal::None), + nullptr).get(); return false; } @@ -312,9 +313,7 @@ lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::~LibCxxMapIterator SyntheticChildrenFrontEnd* lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp) { - if (!valobj_sp) - return NULL; - return (new LibCxxMapIteratorSyntheticFrontEnd(valobj_sp)); + return (valobj_sp ? new LibCxxMapIteratorSyntheticFrontEnd(valobj_sp) : nullptr); } /* @@ -332,18 +331,16 @@ lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator (CXXSynth static ConstString g_item_name; if (!g_item_name) g_item_name.SetCString("__i"); - if (!valobj_sp) - return NULL; - return (new VectorIteratorSyntheticFrontEnd(valobj_sp,g_item_name)); + return (valobj_sp ? new VectorIteratorSyntheticFrontEnd(valobj_sp, g_item_name) : nullptr); } lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::LibcxxSharedPtrSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_cntrl(NULL), -m_count_sp(), -m_weak_count_sp(), -m_ptr_size(0), -m_byte_order(lldb::eByteOrderInvalid) + SyntheticChildrenFrontEnd(*valobj_sp), + m_cntrl(nullptr), + m_count_sp(), + m_weak_count_sp(), + m_ptr_size(0), + m_byte_order(lldb::eByteOrderInvalid) { if (valobj_sp) Update(); @@ -404,7 +401,7 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { m_count_sp.reset(); m_weak_count_sp.reset(); - m_cntrl = NULL; + m_cntrl = nullptr; ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) @@ -441,15 +438,12 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetIndexOfChildWithN return UINT32_MAX; } -lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::~LibcxxSharedPtrSyntheticFrontEnd () -{} +lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::~LibcxxSharedPtrSyntheticFrontEnd() = default; SyntheticChildrenFrontEnd* lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp) { - if (!valobj_sp) - return NULL; - return (new LibcxxSharedPtrSyntheticFrontEnd(valobj_sp)); + return (valobj_sp ? new LibcxxSharedPtrSyntheticFrontEnd(valobj_sp) : nullptr); } bool @@ -462,7 +456,7 @@ lldb_private::formatters::LibcxxContainerSummaryProvider (ValueObject& valobj, S return false; stream.Printf("0x%016" PRIx64 " ", value); } - return FormatEntity::FormatStringRef("size=${svar%#}", stream, NULL, NULL, NULL, &valobj, false, false); + return FormatEntity::FormatStringRef("size=${svar%#}", stream, nullptr, nullptr, nullptr, &valobj, false, false); } // the field layout in a libc++ string (cap, side, data or data, size, cap) @@ -551,7 +545,7 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options) { uint64_t size = 0; - ValueObjectSP location_sp((ValueObject*)nullptr); + ValueObjectSP location_sp; if (!ExtractLibcxxStringInfo(valobj, location_sp, size)) return false; if (size == 0) @@ -613,7 +607,7 @@ bool lldb_private::formatters::LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options) { uint64_t size = 0; - ValueObjectSP location_sp((ValueObject*)nullptr); + ValueObjectSP location_sp; if (!ExtractLibcxxStringInfo(valobj, location_sp, size)) return false; @@ -643,7 +637,7 @@ lldb_private::formatters::LibcxxStringSummaryProvider (ValueObject& valobj, Stre options.SetData(extractor); options.SetStream(&stream); - options.SetPrefixToken(0); + options.SetPrefixToken(nullptr); options.SetQuote('"'); options.SetSourceSize(size); options.SetBinaryZeroIsTerminator(false); diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp index 9970d49..71a94b7 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp @@ -56,12 +56,12 @@ namespace lldb_private { } // namespace lldb_private lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::LibcxxInitializerListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_start(NULL), -m_element_type(), -m_element_size(0), -m_num_elements(0), -m_children() + SyntheticChildrenFrontEnd(*valobj_sp), + m_start(nullptr), + m_element_type(), + m_element_size(0), + m_num_elements(0), + m_children() { if (valobj_sp) Update(); @@ -113,7 +113,7 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::Update() m_children.clear(); lldb::TemplateArgumentKind kind; m_element_type = m_backend.GetCompilerType().GetTemplateArgument(0, kind); - if (kind != lldb::eTemplateArgumentKindType || false == m_element_type.IsValid()) + if (kind != lldb::eTemplateArgumentKindType || !m_element_type.IsValid()) return false; m_element_size = m_element_type.GetByteSize(nullptr); @@ -141,7 +141,5 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::GetIndexOfChil lldb_private::SyntheticChildrenFrontEnd* lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp) { - if (!valobj_sp) - return NULL; - return (new LibcxxInitializerListSyntheticFrontEnd(valobj_sp)); + return (valobj_sp ? new LibcxxInitializerListSyntheticFrontEnd(valobj_sp) : nullptr); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp index f86f968e..8e089ae 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp @@ -34,7 +34,7 @@ namespace { public: ListEntry() = default; ListEntry (ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {} - ListEntry (const ListEntry& rhs) : m_entry_sp(rhs.m_entry_sp) {} + ListEntry(const ListEntry& rhs) = default; ListEntry (ValueObject* entry) : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {} ListEntry @@ -69,7 +69,7 @@ namespace { explicit operator bool () { - return GetEntry().get() != nullptr && null() == false; + return GetEntry() && !null(); } ValueObjectSP @@ -106,7 +106,7 @@ namespace { ListIterator() = default; ListIterator (ListEntry entry) : m_entry(entry) {} ListIterator (ValueObjectSP entry) : m_entry(entry) {} - ListIterator (const ListIterator& rhs) : m_entry(rhs.m_entry) {} + ListIterator(const ListIterator& rhs) = default; ListIterator (ValueObject* entry) : m_entry(entry) {} ValueObjectSP @@ -207,16 +207,16 @@ namespace lldb_private { } // namespace lldb_private lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::LibcxxStdListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_list_capping_size(0), -m_loop_detected(0), -m_node_address(), -m_head(NULL), -m_tail(NULL), -m_element_type(), -m_count(UINT32_MAX), -m_children(), -m_iterators() + SyntheticChildrenFrontEnd(*valobj_sp), + m_list_capping_size(0), + m_loop_detected(0), + m_node_address(), + m_head(nullptr), + m_tail(nullptr), + m_element_type(), + m_count(UINT32_MAX), + m_children(), + m_iterators() { if (valobj_sp) Update(); @@ -225,7 +225,7 @@ m_iterators() bool lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::HasLoop(size_t count) { - if (g_use_loop_detect == false) + if (!g_use_loop_detect) return false; // don't bother checking for a loop if we won't actually need to jump nodes if (m_count < 2) @@ -358,7 +358,7 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::Update() { m_children.clear(); m_iterators.clear(); - m_head = m_tail = NULL; + m_head = m_tail = nullptr; m_node_address = 0; m_count = UINT32_MAX; m_loop_detected = 0; @@ -372,7 +372,7 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::Update() m_list_capping_size = m_backend.GetTargetSP()->GetMaximumNumberOfChildrenToDisplay(); if (m_list_capping_size == 0) m_list_capping_size = 255; - if (err.Fail() || backend_addr.get() == NULL) + if (err.Fail() || !backend_addr) return false; m_node_address = backend_addr->GetValueAsUnsigned(0); if (!m_node_address || m_node_address == LLDB_INVALID_ADDRESS) @@ -408,7 +408,5 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::GetIndexOfChildWithNam SyntheticChildrenFrontEnd* lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp) { - if (!valobj_sp) - return NULL; - return (new LibcxxStdListSyntheticFrontEnd(valobj_sp)); + return (valobj_sp ? new LibcxxStdListSyntheticFrontEnd(valobj_sp) : nullptr); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp index aa82557..7e50c21 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -32,7 +32,7 @@ class MapEntry public: MapEntry() = default; explicit MapEntry (ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {} - MapEntry (const MapEntry& rhs) : m_entry_sp(rhs.m_entry_sp) {} + MapEntry(const MapEntry& rhs) = default; explicit MapEntry (ValueObject* entry) : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {} ValueObjectSP @@ -124,7 +124,7 @@ public: ValueObjectSP advance (size_t count) { - ValueObjectSP fail(nullptr); + ValueObjectSP fail; if (m_error) return fail; size_t steps = 0; @@ -147,7 +147,7 @@ protected: if (m_entry.null()) return; MapEntry right(m_entry.right()); - if (right.null() == false) + if (!right.null()) { m_entry = tree_min(std::move(right)); return; @@ -179,7 +179,7 @@ private: return MapEntry(); MapEntry left(x.left()); size_t steps = 0; - while (left.null() == false) + while (!left.null()) { if (left.error()) { @@ -253,14 +253,14 @@ namespace lldb_private { } // namespace lldb_private lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::LibcxxStdMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_tree(NULL), -m_root_node(NULL), -m_element_type(), -m_skip_size(UINT32_MAX), -m_count(UINT32_MAX), -m_children(), -m_iterators() + SyntheticChildrenFrontEnd(*valobj_sp), + m_tree(nullptr), + m_root_node(nullptr), + m_element_type(), + m_skip_size(UINT32_MAX), + m_count(UINT32_MAX), + m_children(), + m_iterators() { if (valobj_sp) Update(); @@ -274,7 +274,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::CalculateNumChildren () if (m_count != UINT32_MAX) return m_count; - if (m_tree == NULL) + if (m_tree == nullptr) return 0; ValueObjectSP m_item(m_tree->GetChildMemberWithName(g___pair3_, true)); if (!m_item) @@ -315,7 +315,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset (const l return; CompilerType node_type(node->GetCompilerType()); uint64_t bit_offset; - if (node_type.GetIndexOfFieldWithName("__value_", NULL, &bit_offset) == UINT32_MAX) + if (node_type.GetIndexOfFieldWithName("__value_", nullptr, &bit_offset) == UINT32_MAX) return; m_skip_size = bit_offset / 8u; } @@ -327,10 +327,9 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t static ConstString g___nc("__nc"); static ConstString g___value_("__value_"); - if (idx >= CalculateNumChildren()) return lldb::ValueObjectSP(); - if (m_tree == NULL || m_root_node == NULL) + if (m_tree == nullptr || m_root_node == nullptr) return lldb::ValueObjectSP(); auto cached = m_children.find(idx); @@ -352,10 +351,10 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t } ValueObjectSP iterated_sp(iterator.advance(actual_advancde)); - if (iterated_sp.get() == NULL) + if (!iterated_sp) { // this tree is garbage - stop - m_tree = NULL; // this will stop all future searches until an Update() happens + m_tree = nullptr; // this will stop all future searches until an Update() happens return iterated_sp; } if (GetDataType()) @@ -366,14 +365,14 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t iterated_sp = iterated_sp->Dereference(error); if (!iterated_sp || error.Fail()) { - m_tree = NULL; + m_tree = nullptr; return lldb::ValueObjectSP(); } GetValueOffset(iterated_sp); iterated_sp = iterated_sp->GetChildMemberWithName(g___value_, true); if (!iterated_sp) { - m_tree = NULL; + m_tree = nullptr; return lldb::ValueObjectSP(); } } @@ -385,20 +384,20 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t GetChildAtIndex(0); if (m_skip_size == UINT32_MAX) { - m_tree = NULL; + m_tree = nullptr; return lldb::ValueObjectSP(); } iterated_sp = iterated_sp->GetSyntheticChildAtOffset(m_skip_size, m_element_type, true); if (!iterated_sp) { - m_tree = NULL; + m_tree = nullptr; return lldb::ValueObjectSP(); } } } else { - m_tree = NULL; + m_tree = nullptr; return lldb::ValueObjectSP(); } // at this point we have a valid @@ -408,7 +407,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t iterated_sp->GetData(data, error); if (error.Fail()) { - m_tree = NULL; + m_tree = nullptr; return lldb::ValueObjectSP(); } StreamString name; @@ -447,7 +446,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::Update() static ConstString g___tree_("__tree_"); static ConstString g___begin_node_("__begin_node_"); m_count = UINT32_MAX; - m_tree = m_root_node = NULL; + m_tree = m_root_node = nullptr; m_children.clear(); m_iterators.clear(); m_tree = m_backend.GetChildMemberWithName(g___tree_, true).get(); @@ -472,7 +471,5 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetIndexOfChildWithName SyntheticChildrenFrontEnd* lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp) { - if (!valobj_sp) - return NULL; - return (new LibcxxStdMapSyntheticFrontEnd(valobj_sp)); + return (valobj_sp ? new LibcxxStdMapSyntheticFrontEnd(valobj_sp) : nullptr); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index 8ad806d..54e91f1 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -62,12 +62,12 @@ namespace lldb_private { } // namespace lldb_private lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::LibcxxStdUnorderedMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_tree(NULL), -m_num_elements(0), -m_next_element(nullptr), -m_children(), -m_elements_cache() + SyntheticChildrenFrontEnd(*valobj_sp), + m_tree(nullptr), + m_num_elements(0), + m_next_element(nullptr), + m_children(), + m_elements_cache() { if (valobj_sp) Update(); @@ -86,7 +86,7 @@ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::GetChildAtInde { if (idx >= CalculateNumChildren()) return lldb::ValueObjectSP(); - if (m_tree == NULL) + if (m_tree == nullptr) return lldb::ValueObjectSP(); auto cached = m_children.find(idx); @@ -166,7 +166,5 @@ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::GetIndexOfChil SyntheticChildrenFrontEnd* lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp) { - if (!valobj_sp) - return NULL; - return (new LibcxxStdUnorderedMapSyntheticFrontEnd(valobj_sp)); + return (valobj_sp ? new LibcxxStdUnorderedMapSyntheticFrontEnd(valobj_sp) : nullptr); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index 9fb4f48e..b39ea51 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -56,12 +56,12 @@ namespace lldb_private { } // namespace lldb_private lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::LibcxxStdVectorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_start(NULL), -m_finish(NULL), -m_element_type(), -m_element_size(0), -m_children() + SyntheticChildrenFrontEnd(*valobj_sp), + m_start(nullptr), + m_finish(nullptr), + m_element_type(), + m_element_size(0), + m_children() { if (valobj_sp) Update(); @@ -116,7 +116,7 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::GetChildAtIndex (siz bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() { - m_start = m_finish = NULL; + m_start = m_finish = nullptr; m_children.clear(); ValueObjectSP data_type_finder_sp(m_backend.GetChildMemberWithName(ConstString("__end_cap_"),true)); if (!data_type_finder_sp) @@ -153,7 +153,5 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::GetIndexOfChildWithN lldb_private::SyntheticChildrenFrontEnd* lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp) { - if (!valobj_sp) - return NULL; - return (new LibcxxStdVectorSyntheticFrontEnd(valobj_sp)); + return (valobj_sp ? new LibcxxStdVectorSyntheticFrontEnd(valobj_sp) : nullptr); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index ed89c5c..1fa53b9 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -1,4 +1,4 @@ -//===-- LibStdcpp.cpp ---------------------------------------------*- C++ -*-===// +//===-- LibStdcpp.cpp -------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -9,6 +9,10 @@ #include "LibStdcpp.h" +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Error.h" #include "lldb/Core/Stream.h" @@ -28,7 +32,9 @@ class LibstdcppMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: LibstdcppMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - + + ~LibstdcppMapIteratorSyntheticFrontEnd() override = default; + size_t CalculateNumChildren() override; @@ -44,8 +50,6 @@ public: size_t GetIndexOfChildWithName (const ConstString &name) override; - ~LibstdcppMapIteratorSyntheticFrontEnd() override; - private: ExecutionContextRef m_exe_ctx_ref; lldb::addr_t m_pair_address; @@ -66,7 +70,7 @@ private: */ LibstdcppMapIteratorSyntheticFrontEnd::LibstdcppMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : - SyntheticChildrenFrontEnd(*valobj_sp.get()), + SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_pair_address(0), m_pair_type(), @@ -159,15 +163,10 @@ LibstdcppMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName (const ConstStrin return UINT32_MAX; } -LibstdcppMapIteratorSyntheticFrontEnd::~LibstdcppMapIteratorSyntheticFrontEnd () -{} - SyntheticChildrenFrontEnd* lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp) { - if (!valobj_sp) - return NULL; - return (new LibstdcppMapIteratorSyntheticFrontEnd(valobj_sp)); + return (valobj_sp ? new LibstdcppMapIteratorSyntheticFrontEnd(valobj_sp) : nullptr); } /* @@ -185,17 +184,15 @@ lldb_private::formatters::LibStdcppVectorIteratorSyntheticFrontEndCreator (CXXSy static ConstString g_item_name; if (!g_item_name) g_item_name.SetCString("_M_current"); - if (!valobj_sp) - return NULL; - return (new VectorIteratorSyntheticFrontEnd(valobj_sp,g_item_name)); + return (valobj_sp ? new VectorIteratorSyntheticFrontEnd(valobj_sp, g_item_name) : nullptr); } lldb_private::formatters::VectorIteratorSyntheticFrontEnd::VectorIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp, ConstString item_name) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_exe_ctx_ref(), -m_item_name(item_name), -m_item_sp() + SyntheticChildrenFrontEnd(*valobj_sp), + m_exe_ctx_ref(), + m_item_name(item_name), + m_item_sp() { if (valobj_sp) Update(); @@ -254,9 +251,7 @@ lldb_private::formatters::VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithNa return UINT32_MAX; } -lldb_private::formatters::VectorIteratorSyntheticFrontEnd::~VectorIteratorSyntheticFrontEnd () -{ -} +lldb_private::formatters::VectorIteratorSyntheticFrontEnd::~VectorIteratorSyntheticFrontEnd() = default; bool lldb_private::formatters::LibStdcppStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options) diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp index cfc2064..1922de3 100644 --- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp +++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp @@ -50,7 +50,7 @@ lldb_private::formatters::NSBundleSummaryProvider (ValueObject& valobj, Stream& ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; uint32_t ptr_size = process_sp->GetAddressByteSize(); @@ -71,7 +71,7 @@ lldb_private::formatters::NSBundleSummaryProvider (ValueObject& valobj, Stream& ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID), true)); StreamString summary_stream; - bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream, options); + bool was_nsstring_ok = NSStringSummaryProvider(*text, summary_stream, options); if (was_nsstring_ok && summary_stream.GetSize() > 0) { stream.Printf("%s",summary_stream.GetData()); @@ -97,7 +97,7 @@ lldb_private::formatters::NSTimeZoneSummaryProvider (ValueObject& valobj, Stream ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; uint32_t ptr_size = process_sp->GetAddressByteSize(); @@ -117,7 +117,7 @@ lldb_private::formatters::NSTimeZoneSummaryProvider (ValueObject& valobj, Stream uint64_t offset = ptr_size; ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetCompilerType(), true)); StreamString summary_stream; - bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream, options); + bool was_nsstring_ok = NSStringSummaryProvider(*text, summary_stream, options); if (was_nsstring_ok && summary_stream.GetSize() > 0) { stream.Printf("%s",summary_stream.GetData()); @@ -141,7 +141,7 @@ lldb_private::formatters::NSNotificationSummaryProvider (ValueObject& valobj, St ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; uint32_t ptr_size = process_sp->GetAddressByteSize(); @@ -161,7 +161,7 @@ lldb_private::formatters::NSNotificationSummaryProvider (ValueObject& valobj, St uint64_t offset = ptr_size; ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, valobj.GetCompilerType(), true)); StreamString summary_stream; - bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream, options); + bool was_nsstring_ok = NSStringSummaryProvider(*text, summary_stream, options); if (was_nsstring_ok && summary_stream.GetSize() > 0) { stream.Printf("%s",summary_stream.GetData()); @@ -187,7 +187,7 @@ lldb_private::formatters::NSMachPortSummaryProvider (ValueObject& valobj, Stream ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; uint32_t ptr_size = process_sp->GetAddressByteSize(); @@ -236,7 +236,7 @@ lldb_private::formatters::NSIndexSetSummaryProvider (ValueObject& valobj, Stream ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; uint32_t ptr_size = process_sp->GetAddressByteSize(); @@ -458,7 +458,7 @@ lldb_private::formatters::NSNumberSummaryProvider (ValueObject& valobj, Stream& ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; uint32_t ptr_size = process_sp->GetAddressByteSize(); @@ -582,7 +582,7 @@ lldb_private::formatters::NSURLSummaryProvider (ValueObject& valobj, Stream& str ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; uint32_t ptr_size = process_sp->GetAddressByteSize(); @@ -647,7 +647,7 @@ lldb_private::formatters::NSDateSummaryProvider (ValueObject& valobj, Stream& st ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; uint32_t ptr_size = process_sp->GetAddressByteSize(); @@ -694,7 +694,7 @@ lldb_private::formatters::NSDateSummaryProvider (ValueObject& valobj, Stream& st } else { - if (ExtractValueFromObjCExpression(valobj, "NSTimeInterval", "ExtractValueFromObjCExpression", date_value_bits) == false) + if (!ExtractValueFromObjCExpression(valobj, "NSTimeInterval", "ExtractValueFromObjCExpression", date_value_bits)) return false; date_value = *((double*)&date_value_bits); } @@ -732,7 +732,7 @@ lldb_private::formatters::ObjCClassSummaryProvider (ValueObject& valobj, Stream& ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptorFromISA(valobj.GetValueAsUnsigned(0))); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; ConstString class_name = descriptor->GetClassName(); @@ -751,7 +751,7 @@ class ObjCClassSyntheticChildrenFrontEnd : public SyntheticChildrenFrontEnd { public: ObjCClassSyntheticChildrenFrontEnd (lldb::ValueObjectSP valobj_sp) : - SyntheticChildrenFrontEnd(*valobj_sp.get()) + SyntheticChildrenFrontEnd(*valobj_sp) { } @@ -809,7 +809,7 @@ lldb_private::formatters::NSDataSummaryProvider (ValueObject& valobj, Stream& st ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; bool is_64bit = (process_sp->GetAddressByteSize() == 8); @@ -936,7 +936,7 @@ lldb_private::formatters::GetOSXEpoch () tm_epoch.tm_year = 2001-1900; // for some reason, we need to subtract 1900 from this field. not sure why. tm_epoch.tm_isdst = -1; tm_epoch.tm_gmtoff = 0; - tm_epoch.tm_zone = NULL; + tm_epoch.tm_zone = nullptr; epoch = timegm(&tm_epoch); #endif } diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp index 28b5ab6..a1bce4d 100644 --- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp @@ -103,7 +103,7 @@ namespace lldb_private { struct DataDescriptor_32 { uint32_t _used; - uint32_t _priv1 : 2 ; + uint32_t _priv1 : 2; uint32_t _size : 30; uint32_t _priv2 : 2; uint32_t _offset : 30; @@ -114,7 +114,7 @@ namespace lldb_private { struct DataDescriptor_64 { uint64_t _used; - uint64_t _priv1 : 2 ; + uint64_t _priv1 : 2; uint64_t _size : 62; uint64_t _priv2 : 2; uint64_t _offset : 62; @@ -246,7 +246,7 @@ lldb_private::formatters::NSArraySummaryProvider (ValueObject& valobj, Stream& s ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; uint32_t ptr_size = process_sp->GetAddressByteSize(); @@ -289,7 +289,7 @@ lldb_private::formatters::NSArraySummaryProvider (ValueObject& valobj, Stream& s return false; } else - return false; + return false; std::string prefix,suffix; if (Language* language = Language::FindPlugin(options.GetLanguage())) @@ -328,16 +328,16 @@ m_children() } lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::NSArrayMSyntheticFrontEnd_109 (lldb::ValueObjectSP valobj_sp) : -NSArrayMSyntheticFrontEnd(valobj_sp), -m_data_32(NULL), -m_data_64(NULL) + NSArrayMSyntheticFrontEnd(valobj_sp), + m_data_32(nullptr), + m_data_64(nullptr) { } lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::NSArrayMSyntheticFrontEnd_1010 (lldb::ValueObjectSP valobj_sp) : -NSArrayMSyntheticFrontEnd(valobj_sp), -m_data_32(NULL), -m_data_64(NULL) + NSArrayMSyntheticFrontEnd(valobj_sp), + m_data_32(nullptr), + m_data_64(nullptr) { } @@ -375,9 +375,9 @@ lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::Update() ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; if (!valobj_sp) return false; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); @@ -410,9 +410,9 @@ lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::Update() ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; if (!valobj_sp) return false; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); @@ -457,9 +457,9 @@ lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetIndexOfChildWithName (co lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::~NSArrayMSyntheticFrontEnd_109() { delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; } lldb::addr_t @@ -501,9 +501,9 @@ lldb_private::formatters::NSArrayMSyntheticFrontEnd_109::GetSize () lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::~NSArrayMSyntheticFrontEnd_1010() { delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; } lldb::addr_t @@ -543,11 +543,11 @@ lldb_private::formatters::NSArrayMSyntheticFrontEnd_1010::GetSize () } lldb_private::formatters::NSArrayISyntheticFrontEnd::NSArrayISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd (*valobj_sp.get()), -m_exe_ctx_ref (), -m_ptr_size (8), -m_items (0), -m_data_ptr (0) + SyntheticChildrenFrontEnd(*valobj_sp), + m_exe_ctx_ref(), + m_ptr_size(8), + m_items(0), + m_data_ptr(0) { if (valobj_sp) { @@ -632,7 +632,7 @@ lldb_private::formatters::NSArrayISyntheticFrontEnd::GetChildAtIndex (size_t idx } lldb_private::formatters::NSArray0SyntheticFrontEnd::NSArray0SyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd (*valobj_sp.get()) + SyntheticChildrenFrontEnd(*valobj_sp) { } @@ -673,10 +673,10 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCre lldb::ProcessSP process_sp (valobj_sp->GetProcessSP()); if (!process_sp) - return NULL; + return nullptr; AppleObjCRuntime *runtime = llvm::dyn_cast_or_null(process_sp->GetObjCLanguageRuntime()); if (!runtime) - return NULL; + return nullptr; CompilerType valobj_type(valobj_sp->GetCompilerType()); Flags flags(valobj_type.GetTypeInfo()); @@ -686,18 +686,18 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCre Error error; valobj_sp = valobj_sp->AddressOf(error); if (error.Fail() || !valobj_sp) - return NULL; + return nullptr; } - ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get())); + ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp)); - if (!descriptor.get() || !descriptor->IsValid()) - return NULL; + if (!descriptor || !descriptor->IsValid()) + return nullptr; const char* class_name = descriptor->GetClassName().GetCString(); if (!class_name || !*class_name) - return NULL; + return nullptr; if (!strcmp(class_name,"__NSArrayI")) { diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp index 7f8f5ec..627eb2c 100644 --- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp @@ -63,7 +63,7 @@ GetLLDBNSPairType (TargetSP target_sp) if (!compiler_type) { - compiler_type = target_ast_context->CreateRecordType(NULL, lldb::eAccessPublic, g___lldb_autogen_nspair.GetCString(), clang::TTK_Struct, lldb::eLanguageTypeC); + compiler_type = target_ast_context->CreateRecordType(nullptr, lldb::eAccessPublic, g___lldb_autogen_nspair.GetCString(), clang::TTK_Struct, lldb::eLanguageTypeC); if (compiler_type) { @@ -209,7 +209,7 @@ lldb_private::formatters::NSDictionarySummaryProvider (ValueObject& valobj, Stre ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; uint32_t ptr_size = process_sp->GetAddressByteSize(); @@ -286,10 +286,10 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSDictionarySyntheticFrontE { lldb::ProcessSP process_sp (valobj_sp->GetProcessSP()); if (!process_sp) - return NULL; + return nullptr; ObjCLanguageRuntime *runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC); if (!runtime) - return NULL; + return nullptr; CompilerType valobj_type(valobj_sp->GetCompilerType()); Flags flags(valobj_type.GetTypeInfo()); @@ -299,19 +299,19 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSDictionarySyntheticFrontE Error error; valobj_sp = valobj_sp->AddressOf(error); if (error.Fail() || !valobj_sp) - return NULL; + return nullptr; } - ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get())); + ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp)); - if (!descriptor.get() || !descriptor->IsValid()) - return NULL; + if (!descriptor || !descriptor->IsValid()) + return nullptr; ConstString class_name_cs = descriptor->GetClassName(); const char* class_name = class_name_cs.GetCString(); if (!class_name || !*class_name) - return NULL; + return nullptr; if (!strcmp(class_name,"__NSDictionaryI")) { @@ -333,22 +333,22 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSDictionarySyntheticFrontE } lldb_private::formatters::NSDictionaryISyntheticFrontEnd::NSDictionaryISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_exe_ctx_ref(), -m_ptr_size(8), -m_order(lldb::eByteOrderInvalid), -m_data_32(NULL), -m_data_64(NULL), -m_pair_type() + SyntheticChildrenFrontEnd(*valobj_sp), + m_exe_ctx_ref(), + m_ptr_size(8), + m_order(lldb::eByteOrderInvalid), + m_data_32(nullptr), + m_data_64(nullptr), + m_pair_type() { } lldb_private::formatters::NSDictionaryISyntheticFrontEnd::~NSDictionaryISyntheticFrontEnd () { delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; } size_t @@ -374,9 +374,9 @@ lldb_private::formatters::NSDictionaryISyntheticFrontEnd::Update() { m_children.clear(); delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; m_ptr_size = 0; ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) @@ -498,22 +498,22 @@ lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetChildAtIndex (size_ } lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::NSDictionaryMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_exe_ctx_ref(), -m_ptr_size(8), -m_order(lldb::eByteOrderInvalid), -m_data_32(NULL), -m_data_64(NULL), -m_pair_type() + SyntheticChildrenFrontEnd(*valobj_sp), + m_exe_ctx_ref(), + m_ptr_size(8), + m_order(lldb::eByteOrderInvalid), + m_data_32(nullptr), + m_data_64(nullptr), + m_pair_type() { } lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::~NSDictionaryMSyntheticFrontEnd () { delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; } size_t @@ -541,9 +541,9 @@ lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::Update() ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; if (!valobj_sp) return false; m_exe_ctx_ref = valobj_sp->GetExecutionContextRef(); diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp b/lldb/source/Plugins/Language/ObjC/NSSet.cpp index 8adf92c..226716b 100644 --- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp @@ -215,7 +215,7 @@ lldb_private::formatters::NSSetSummaryProvider (ValueObject& valobj, Stream& str ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj)); - if (!descriptor.get() || !descriptor->IsValid()) + if (!descriptor || !descriptor->IsValid()) return false; uint32_t ptr_size = process_sp->GetAddressByteSize(); @@ -304,10 +304,10 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSSetSyntheticFrontEndCreat { lldb::ProcessSP process_sp (valobj_sp->GetProcessSP()); if (!process_sp) - return NULL; + return nullptr; ObjCLanguageRuntime *runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC); if (!runtime) - return NULL; + return nullptr; CompilerType valobj_type(valobj_sp->GetCompilerType()); Flags flags(valobj_type.GetTypeInfo()); @@ -317,19 +317,19 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSSetSyntheticFrontEndCreat Error error; valobj_sp = valobj_sp->AddressOf(error); if (error.Fail() || !valobj_sp) - return NULL; + return nullptr; } - ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get())); + ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp)); - if (!descriptor.get() || !descriptor->IsValid()) - return NULL; + if (!descriptor || !descriptor->IsValid()) + return nullptr; ConstString class_name_cs = descriptor->GetClassName(); const char* class_name = class_name_cs.GetCString(); if (!class_name || !*class_name) - return NULL; + return nullptr; if (!strcmp(class_name,"__NSSetI")) { @@ -354,11 +354,11 @@ SyntheticChildrenFrontEnd* lldb_private::formatters::NSSetSyntheticFrontEndCreat } lldb_private::formatters::NSSetISyntheticFrontEnd::NSSetISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_exe_ctx_ref(), -m_ptr_size(8), -m_data_32(NULL), -m_data_64(NULL) + SyntheticChildrenFrontEnd(*valobj_sp), + m_exe_ctx_ref(), + m_ptr_size(8), + m_data_32(nullptr), + m_data_64(nullptr) { if (valobj_sp) Update(); @@ -367,9 +367,9 @@ m_data_64(NULL) lldb_private::formatters::NSSetISyntheticFrontEnd::~NSSetISyntheticFrontEnd () { delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; } size_t @@ -395,9 +395,9 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::Update() { m_children.clear(); delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; m_ptr_size = 0; ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) @@ -521,11 +521,11 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex (size_t idx) } lldb_private::formatters::NSSetMSyntheticFrontEnd::NSSetMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_exe_ctx_ref(), -m_ptr_size(8), -m_data_32(NULL), -m_data_64(NULL) + SyntheticChildrenFrontEnd(*valobj_sp), + m_exe_ctx_ref(), + m_ptr_size(8), + m_data_32(nullptr), + m_data_64(nullptr) { if (valobj_sp) Update (); @@ -534,9 +534,9 @@ m_data_64(NULL) lldb_private::formatters::NSSetMSyntheticFrontEnd::~NSSetMSyntheticFrontEnd () { delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; } size_t @@ -564,9 +564,9 @@ lldb_private::formatters::NSSetMSyntheticFrontEnd::Update() ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; delete m_data_32; - m_data_32 = NULL; + m_data_32 = nullptr; delete m_data_64; - m_data_64 = NULL; + m_data_64 = nullptr; if (!valobj_sp) return false; if (!valobj_sp) @@ -689,10 +689,11 @@ lldb_private::formatters::NSSetMSyntheticFrontEnd::GetChildAtIndex (size_t idx) } lldb_private::formatters::NSOrderedSetSyntheticFrontEnd::NSOrderedSetSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_count(UINT32_MAX), -m_children() -{} + SyntheticChildrenFrontEnd(*valobj_sp), + m_count(UINT32_MAX), + m_children() +{ +} size_t lldb_private::formatters::NSOrderedSetSyntheticFrontEnd::CalculateNumChildren () diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index 91a3a0f..90e7582 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -61,6 +61,7 @@ ObjCLanguage::GetPluginNameStatic() //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ + lldb_private::ConstString ObjCLanguage::GetPluginName() { @@ -76,6 +77,7 @@ ObjCLanguage::GetPluginVersion() //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ + Language * ObjCLanguage::CreateInstance (lldb::LanguageType language) { @@ -192,7 +194,7 @@ ObjCLanguage::MethodName::GetClassNameWithCategory () m_class_category.SetCStringWithLength (class_start, space_pos - class_start); // If m_class hasn't been filled in and the class with category doesn't // contain a '(', then we can also fill in the m_class - if (!m_class && strchr (m_class_category.GetCString(), '(') == NULL) + if (!m_class && strchr(m_class_category.GetCString(), '(') == nullptr) { m_class = m_class_category; // No '(' was found in the full name, we can definitively say @@ -732,7 +734,7 @@ ObjCLanguage::GetTypeScavenger () ConstString key_cs(key); if (clang_modules_decl_vendor->FindDecls(key_cs, false, UINT32_MAX, decls) > 0 && - decls.size() > 0) + !decls.empty()) { CompilerType module_type = ClangASTContext::GetTypeForDecl(decls.front()); result = true; diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h index e30aa18..b1435d2 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h @@ -12,6 +12,7 @@ // C Includes // C++ Includes +#include #include // Other libraries and framework includes @@ -187,7 +188,7 @@ public: if (!name) return false; - if (strchr(name, ':') == NULL) + if (strchr(name, ':') == nullptr) return true; else if (name[strlen(name) - 1] == ':') return true;