diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2015-10-30 18:50:12 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2015-10-30 18:50:12 +0000 |
commit | 16fd7511b23a8e7a83d6fb7a2a0f345b7e55b721 (patch) | |
tree | 000e08d82b55904964048f90b07bab220d9e7830 | |
parent | a8125350eaad29f9d13afe4397ad79d4a47d3fa7 (diff) | |
download | bcm5719-llvm-16fd7511b23a8e7a83d6fb7a2a0f345b7e55b721.tar.gz bcm5719-llvm-16fd7511b23a8e7a83d6fb7a2a0f345b7e55b721.zip |
Fix Clang-tidy modernize-use-nullptr warnings in source/Breakpoint; other minor fixes.
llvm-svn: 251716
-rw-r--r-- | lldb/source/Breakpoint/Breakpoint.cpp | 50 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointID.cpp | 17 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointIDList.cpp | 20 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointLocation.cpp | 62 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointLocationList.cpp | 16 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointOptions.cpp | 28 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointResolverName.cpp | 59 | ||||
-rw-r--r-- | lldb/source/Breakpoint/BreakpointSite.cpp | 17 | ||||
-rw-r--r-- | lldb/source/Breakpoint/StoppointCallbackContext.cpp | 7 | ||||
-rw-r--r-- | lldb/source/Breakpoint/Watchpoint.cpp | 50 | ||||
-rw-r--r-- | lldb/source/Breakpoint/WatchpointOptions.cpp | 25 |
11 files changed, 142 insertions, 209 deletions
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index 23d484f0f68..f9f0ffbd53b 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// - // C Includes // C++ Includes // Other libraries and framework includes -// Project includes +#include "llvm/Support/Casting.h" +// Project includes #include "lldb/Core/Address.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" @@ -31,7 +31,6 @@ #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadSpec.h" -#include "llvm/Support/Casting.h" using namespace lldb; using namespace lldb_private; @@ -83,9 +82,7 @@ Breakpoint::Breakpoint (Target &new_target, Breakpoint &source_bp) : //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- -Breakpoint::~Breakpoint() -{ -} +Breakpoint::~Breakpoint() = default; const lldb::TargetSP Breakpoint::GetTargetSP () @@ -236,7 +233,7 @@ Breakpoint::SetThreadID (lldb::tid_t thread_id) lldb::tid_t Breakpoint::GetThreadID () const { - if (m_options.GetThreadSpecNoCreate() == NULL) + if (m_options.GetThreadSpecNoCreate() == nullptr) return LLDB_INVALID_THREAD_ID; else return m_options.GetThreadSpecNoCreate()->GetTID(); @@ -255,7 +252,7 @@ Breakpoint::SetThreadIndex (uint32_t index) uint32_t Breakpoint::GetThreadIndex() const { - if (m_options.GetThreadSpecNoCreate() == NULL) + if (m_options.GetThreadSpecNoCreate() == nullptr) return 0; else return m_options.GetThreadSpecNoCreate()->GetIndex(); @@ -264,7 +261,7 @@ Breakpoint::GetThreadIndex() const void Breakpoint::SetThreadName (const char *thread_name) { - if (m_options.GetThreadSpec()->GetName() != NULL + if (m_options.GetThreadSpec()->GetName() != nullptr && ::strcmp (m_options.GetThreadSpec()->GetName(), thread_name) == 0) return; @@ -275,8 +272,8 @@ Breakpoint::SetThreadName (const char *thread_name) const char * Breakpoint::GetThreadName () const { - if (m_options.GetThreadSpecNoCreate() == NULL) - return NULL; + if (m_options.GetThreadSpecNoCreate() == nullptr) + return nullptr; else return m_options.GetThreadSpecNoCreate()->GetName(); } @@ -284,7 +281,7 @@ Breakpoint::GetThreadName () const void Breakpoint::SetQueueName (const char *queue_name) { - if (m_options.GetThreadSpec()->GetQueueName() != NULL + if (m_options.GetThreadSpec()->GetQueueName() != nullptr && ::strcmp (m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0) return; @@ -295,8 +292,8 @@ Breakpoint::SetQueueName (const char *queue_name) const char * Breakpoint::GetQueueName () const { - if (m_options.GetThreadSpecNoCreate() == NULL) - return NULL; + if (m_options.GetThreadSpecNoCreate() == nullptr) + return nullptr; else return m_options.GetThreadSpecNoCreate()->GetQueueName(); } @@ -456,7 +453,6 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_loca if (!seen) new_modules.AppendIfNeeded (module_sp); - } if (new_modules.GetSize() > 0) @@ -474,7 +470,7 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_loca removed_locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsRemoved, shared_from_this()); else - removed_locations_event = NULL; + removed_locations_event = nullptr; size_t num_modules = module_list.GetSize(); for (size_t i = 0; i < num_modules; i++) @@ -502,7 +498,6 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_loca } if (delete_locations) locations_to_remove.Add (break_loc_sp); - } } @@ -568,7 +563,7 @@ SymbolContextsMightBeEquivalent(SymbolContext &old_sc, SymbolContext &new_sc) } return equivalent_scs; } -} +} // anonymous namespace void Breakpoint::ModuleReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp) @@ -740,7 +735,7 @@ Breakpoint::ModuleReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp) locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsRemoved, shared_from_this()); else - locations_event = NULL; + locations_event = nullptr; for (BreakpointLocationSP loc_sp : locations_to_remove.BreakpointLocations()) { @@ -804,7 +799,7 @@ Breakpoint::AddName (const char *new_name, Error &error) void Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_locations) { - assert (s != NULL); + assert (s != nullptr); if (!m_kind_description.empty()) { @@ -876,7 +871,7 @@ Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_l { s->Printf ("no locations (pending)."); } - else if (num_locations == 1 && show_locations == false) + else if (num_locations == 1 && !show_locations) { // There is only one location, so we'll just print that location information. GetLocationAtIndex(0)->GetDescription(s, level); @@ -922,7 +917,6 @@ Breakpoint::GetResolverDescription (Stream *s) m_resolver_sp->GetDescription (s); } - bool Breakpoint::GetMatchingFileLine (const ConstString &filename, uint32_t line_number, BreakpointLocationCollection &loc_coll) { @@ -993,8 +987,7 @@ Breakpoint::SendBreakpointChangedEvent (lldb::BreakpointEventType eventKind) void Breakpoint::SendBreakpointChangedEvent (BreakpointEventData *data) { - - if (data == NULL) + if (data == nullptr) return; if (!m_being_created @@ -1013,9 +1006,7 @@ Breakpoint::BreakpointEventData::BreakpointEventData (BreakpointEventType sub_ty { } -Breakpoint::BreakpointEventData::~BreakpointEventData () -{ -} +Breakpoint::BreakpointEventData::~BreakpointEventData() = default; const ConstString & Breakpoint::BreakpointEventData::GetFlavorString () @@ -1030,7 +1021,6 @@ Breakpoint::BreakpointEventData::GetFlavor () const return BreakpointEventData::GetFlavorString (); } - BreakpointSP & Breakpoint::BreakpointEventData::GetBreakpoint () { @@ -1057,7 +1047,7 @@ Breakpoint::BreakpointEventData::GetEventDataFromEvent (const Event *event) if (event_data && event_data->GetFlavor() == BreakpointEventData::GetFlavorString()) return static_cast <const BreakpointEventData *> (event->GetData()); } - return NULL; + return nullptr; } BreakpointEventType @@ -1065,7 +1055,7 @@ Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (const EventSP { const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get()); - if (data == NULL) + if (data == nullptr) return eBreakpointEventTypeInvalidType; else return data->GetBreakpointEventType(); diff --git a/lldb/source/Breakpoint/BreakpointID.cpp b/lldb/source/Breakpoint/BreakpointID.cpp index 31823886dd9..81a3dfe50d9 100644 --- a/lldb/source/Breakpoint/BreakpointID.cpp +++ b/lldb/source/Breakpoint/BreakpointID.cpp @@ -7,14 +7,12 @@ // //===----------------------------------------------------------------------===// - // C Includes #include <stdio.h> // C++ Includes // Other libraries and framework includes // Project includes - #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/Stream.h" @@ -29,11 +27,9 @@ BreakpointID::BreakpointID (break_id_t bp_id, break_id_t loc_id) : { } -BreakpointID::~BreakpointID () -{ -} +BreakpointID::~BreakpointID() = default; -const char *BreakpointID::g_range_specifiers[] = { "-", "to", "To", "TO", NULL }; +const char *BreakpointID::g_range_specifiers[] = { "-", "to", "To", "TO", nullptr }; // Tells whether or not STR is valid to use between two strings representing breakpoint IDs, to // indicate a range of breakpoint IDs. This is broken out into a separate function so that we can @@ -43,7 +39,7 @@ bool BreakpointID::IsRangeIdentifier (const char *str) { int specifier_count = 0; - for (int i = 0; g_range_specifiers[i] != NULL; ++i) + for (int i = 0; g_range_specifiers[i] != nullptr; ++i) ++specifier_count; for (int i = 0; i < specifier_count; ++i) @@ -62,10 +58,7 @@ BreakpointID::IsValidIDExpression (const char *str) break_id_t loc_id; BreakpointID::ParseCanonicalReference (str, &bp_id, &loc_id); - if (bp_id == LLDB_INVALID_BREAK_ID) - return false; - else - return true; + return (bp_id != LLDB_INVALID_BREAK_ID); } void @@ -99,7 +92,7 @@ BreakpointID::ParseCanonicalReference (const char *input, break_id_t *break_id_p *break_id_ptr = LLDB_INVALID_BREAK_ID; *break_loc_id_ptr = LLDB_INVALID_BREAK_ID; - if (input == NULL || *input == '\0') + if (input == nullptr || *input == '\0') return false; const char *format = "%i%n.%i%n"; diff --git a/lldb/source/Breakpoint/BreakpointIDList.cpp b/lldb/source/Breakpoint/BreakpointIDList.cpp index b8b506750b3..ebf0697c271 100644 --- a/lldb/source/Breakpoint/BreakpointIDList.cpp +++ b/lldb/source/Breakpoint/BreakpointIDList.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/Breakpoint/BreakpointIDList.h" #include "lldb/Breakpoint/Breakpoint.h" @@ -27,9 +31,7 @@ m_invalid_id (LLDB_INVALID_BREAK_ID, LLDB_INVALID_BREAK_ID) { } -BreakpointIDList::~BreakpointIDList () -{ -} +BreakpointIDList::~BreakpointIDList() = default; size_t BreakpointIDList::GetSize() @@ -38,12 +40,9 @@ BreakpointIDList::GetSize() } BreakpointID & -BreakpointIDList::GetBreakpointIDAtIndex (size_t index) +BreakpointIDList::GetBreakpointIDAtIndex(size_t index) { - if (index < m_breakpoint_ids.size()) - return m_breakpoint_ids[index]; - else - return m_invalid_id; + return ((index < m_breakpoint_ids.size()) ? m_breakpoint_ids[index] : m_invalid_id); } bool @@ -124,7 +123,7 @@ BreakpointIDList::FindBreakpointID (const char *bp_id_str, size_t *position) void BreakpointIDList::InsertStringArray (const char **string_array, size_t array_size, CommandReturnObject &result) { - if (string_array == NULL) + if (string_array == nullptr) return; for (uint32_t i = 0; i < array_size; ++i) @@ -385,7 +384,6 @@ BreakpointIDList::FindAndReplaceIDRanges (Args &old_args, } result.SetStatus (eReturnStatusSuccessFinishNoResult); - return; } bool @@ -402,7 +400,7 @@ BreakpointIDList::StringContainsIDRangeExpression (const char *in_string, *range_end_pos = 0; int specifiers_size = 0; - for (int i = 0; BreakpointID::g_range_specifiers[i] != NULL; ++i) + for (int i = 0; BreakpointID::g_range_specifiers[i] != nullptr; ++i) ++specifiers_size; for (int i = 0; i < specifiers_size && !is_range_expression; ++i) diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index d691405862d..2ec8dc8005b 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -9,8 +9,6 @@ // C Includes // C++ Includes -#include <string> - // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointLocation.h" @@ -101,7 +99,7 @@ BreakpointLocation::IsEnabled () const { if (!m_owner.IsEnabled()) return false; - else if (m_options_ap.get() != NULL) + else if (m_options_ap.get() != nullptr) return m_options_ap->IsEnabled(); else return true; @@ -131,7 +129,7 @@ BreakpointLocation::SetThreadID (lldb::tid_t thread_id) { // If we're resetting this to an invalid thread id, then // don't make an options pointer just to do that. - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) m_options_ap->SetThreadID (thread_id); } SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); @@ -155,11 +153,10 @@ BreakpointLocation::SetThreadIndex (uint32_t index) { // If we're resetting this to an invalid thread id, then // don't make an options pointer just to do that. - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) m_options_ap->GetThreadSpec()->SetIndex(index); } SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); - } uint32_t @@ -174,13 +171,13 @@ BreakpointLocation::GetThreadIndex() const void BreakpointLocation::SetThreadName (const char *thread_name) { - if (thread_name != NULL) + if (thread_name != nullptr) GetLocationOptions()->GetThreadSpec()->SetName(thread_name); else { // If we're resetting this to an invalid thread id, then // don't make an options pointer just to do that. - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) m_options_ap->GetThreadSpec()->SetName(thread_name); } SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); @@ -192,19 +189,19 @@ BreakpointLocation::GetThreadName () const if (GetOptionsNoCreate()->GetThreadSpecNoCreate()) return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetName(); else - return NULL; + return nullptr; } void BreakpointLocation::SetQueueName (const char *queue_name) { - if (queue_name != NULL) + if (queue_name != nullptr) GetLocationOptions()->GetThreadSpec()->SetQueueName(queue_name); else { // If we're resetting this to an invalid thread id, then // don't make an options pointer just to do that. - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) m_options_ap->GetThreadSpec()->SetQueueName(queue_name); } SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); @@ -216,13 +213,13 @@ BreakpointLocation::GetQueueName () const if (GetOptionsNoCreate()->GetThreadSpecNoCreate()) return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetQueueName(); else - return NULL; + return nullptr; } bool BreakpointLocation::InvokeCallback (StoppointCallbackContext *context) { - if (m_options_ap.get() != NULL && m_options_ap->HasCallback()) + if (m_options_ap.get() != nullptr && m_options_ap->HasCallback()) return m_options_ap->InvokeCallback (context, m_owner.GetID(), GetID()); else return m_owner.InvokeCallback (context, GetID()); @@ -246,7 +243,6 @@ BreakpointLocation::SetCallback (BreakpointHitCallback callback, const BatonSP & SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged); } - void BreakpointLocation::ClearCallback () { @@ -294,10 +290,10 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error) Error error; m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(condition_text, - NULL, - language, - Expression::eResultTypeAny, - error)); + nullptr, + language, + Expression::eResultTypeAny, + error)); if (error.Fail()) { if (log) @@ -305,8 +301,7 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error) m_user_expression_sp.reset(); return true; } - - + StreamString errors; if (!m_user_expression_sp->Parse(errors, @@ -364,10 +359,7 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error) Scalar scalar_value; if (result_value_sp->ResolveValue (scalar_value)) { - if (scalar_value.ULongLong(1) == 0) - ret = false; - else - ret = true; + ret = (scalar_value.ULongLong(1) != 0); if (log) log->Printf("Condition successfully evaluated, result is %s.\n", ret ? "true" : "false"); @@ -409,7 +401,7 @@ BreakpointLocation::SetIgnoreCount (uint32_t n) void BreakpointLocation::DecrementIgnoreCount() { - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) { uint32_t loc_ignore = m_options_ap->GetIgnoreCount(); if (loc_ignore != 0) @@ -420,7 +412,7 @@ BreakpointLocation::DecrementIgnoreCount() bool BreakpointLocation::IgnoreCountShouldStop() { - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) { uint32_t loc_ignore = m_options_ap->GetIgnoreCount(); if (loc_ignore != 0) @@ -437,7 +429,7 @@ BreakpointLocation::IgnoreCountShouldStop() const BreakpointOptions * BreakpointLocation::GetOptionsNoCreate () const { - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) return m_options_ap.get(); else return m_owner.GetOptions (); @@ -449,7 +441,7 @@ BreakpointLocation::GetLocationOptions () // If we make the copy we don't copy the callbacks because that is potentially // expensive and we don't want to do that for the simple case where someone is // just disabling the location. - if (m_options_ap.get() == NULL) + if (m_options_ap.get() == nullptr) m_options_ap.reset(BreakpointOptions::CopyOptionsNoCallback(*m_owner.GetOptions ())); return m_options_ap.get(); @@ -521,7 +513,7 @@ BreakpointLocation::UndoBumpHitCount() bool BreakpointLocation::IsResolved () const { - return m_bp_site_sp.get() != NULL; + return m_bp_site_sp.get() != nullptr; } lldb::BreakpointSiteSP @@ -537,7 +529,7 @@ BreakpointLocation::ResolveBreakpointSite () return true; Process *process = m_owner.GetTarget().GetProcessSP().get(); - if (process == NULL) + if (process == nullptr) return false; lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), m_owner.IsHardware()); @@ -625,13 +617,13 @@ BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level) sc.module_sp->GetFileSpec().Dump (s); } - if (sc.comp_unit != NULL) + if (sc.comp_unit != nullptr) { s->EOL(); s->Indent("compile unit = "); static_cast<FileSpec*>(sc.comp_unit)->GetFilename().Dump (s); - if (sc.function != NULL) + if (sc.function != nullptr) { s->EOL(); s->Indent("function = "); @@ -672,11 +664,11 @@ BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level) s->Printf (", "); s->Printf ("address = "); - ExecutionContextScope *exe_scope = NULL; + ExecutionContextScope *exe_scope = nullptr; Target *target = &m_owner.GetTarget(); if (target) exe_scope = target->GetProcessSP().get(); - if (exe_scope == NULL) + if (exe_scope == nullptr) exe_scope = target; if (level == eDescriptionLevelInitial) @@ -734,7 +726,7 @@ BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level) void BreakpointLocation::Dump(Stream *s) const { - if (s == NULL) + if (s == nullptr) return; s->Printf("BreakpointLocation %u: tid = %4.4" PRIx64 " load addr = 0x%8.8" PRIx64 " state = %s type = %s breakpoint " diff --git a/lldb/source/Breakpoint/BreakpointLocationList.cpp b/lldb/source/Breakpoint/BreakpointLocationList.cpp index 06b270a08ce..d57cfa68fb8 100644 --- a/lldb/source/Breakpoint/BreakpointLocationList.cpp +++ b/lldb/source/Breakpoint/BreakpointLocationList.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// - // C Includes // C++ Includes // Other libraries and framework includes @@ -22,7 +21,6 @@ #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" - using namespace lldb; using namespace lldb_private; @@ -32,13 +30,11 @@ BreakpointLocationList::BreakpointLocationList(Breakpoint &owner) : m_address_to_location (), m_mutex (Mutex::eMutexTypeRecursive), m_next_id (0), - m_new_location_recorder (NULL) + m_new_location_recorder (nullptr) { } -BreakpointLocationList::~BreakpointLocationList() -{ -} +BreakpointLocationList::~BreakpointLocationList() = default; BreakpointLocationSP BreakpointLocationList::Create (const Address &addr, bool resolve_indirect_symbols) @@ -163,7 +159,6 @@ BreakpointLocationList::Dump (Stream *s) const s->IndentLess(); } - BreakpointLocationSP BreakpointLocationList::GetByIndex (size_t i) { @@ -285,7 +280,6 @@ BreakpointLocationList::SwapLocation (BreakpointLocationSP to_location_sp, Break to_location_sp->ResolveBreakpointSite(); } - bool BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc_sp) { @@ -304,7 +298,7 @@ BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc return true; } } - } + } return false; } @@ -348,7 +342,7 @@ void BreakpointLocationList::StartRecordingNewLocations (BreakpointLocationCollection &new_locations) { Mutex::Locker locker (m_mutex); - assert (m_new_location_recorder == NULL); + assert(m_new_location_recorder == nullptr); m_new_location_recorder = &new_locations; } @@ -356,7 +350,7 @@ void BreakpointLocationList::StopRecordingNewLocations () { Mutex::Locker locker (m_mutex); - m_new_location_recorder = NULL; + m_new_location_recorder = nullptr; } void diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp index 99a4d47a8d9..d2a91975685 100644 --- a/lldb/source/Breakpoint/BreakpointOptions.cpp +++ b/lldb/source/Breakpoint/BreakpointOptions.cpp @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/BreakpointOptions.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/BreakpointOptions.h" + #include "lldb/Core/Stream.h" #include "lldb/Core/StringList.h" #include "lldb/Core/Value.h" @@ -58,7 +58,7 @@ BreakpointOptions::BreakpointOptions(const BreakpointOptions& rhs) : m_ignore_count (rhs.m_ignore_count), m_thread_spec_ap () { - if (rhs.m_thread_spec_ap.get() != NULL) + if (rhs.m_thread_spec_ap.get() != nullptr) m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get())); m_condition_text = rhs.m_condition_text; m_condition_text_hash = rhs.m_condition_text_hash; @@ -76,7 +76,7 @@ BreakpointOptions::operator=(const BreakpointOptions& rhs) m_enabled = rhs.m_enabled; m_one_shot = rhs.m_one_shot; m_ignore_count = rhs.m_ignore_count; - if (rhs.m_thread_spec_ap.get() != NULL) + if (rhs.m_thread_spec_ap.get() != nullptr) m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get())); m_condition_text = rhs.m_condition_text; m_condition_text_hash = rhs.m_condition_text_hash; @@ -101,9 +101,7 @@ BreakpointOptions::CopyOptionsNoCallback (BreakpointOptions &orig) //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- -BreakpointOptions::~BreakpointOptions() -{ -} +BreakpointOptions::~BreakpointOptions() = default; //------------------------------------------------------------------ // Callbacks @@ -143,10 +141,10 @@ BreakpointOptions::InvokeCallback (StoppointCallbackContext *context, { if (m_callback && context->is_synchronous == IsCallbackSynchronous()) { - return m_callback (m_callback_baton_sp ? m_callback_baton_sp->m_data : NULL, - context, - break_id, - break_loc_id); + return m_callback(m_callback_baton_sp ? m_callback_baton_sp->m_data : nullptr, + context, + break_id, + break_loc_id); } else return true; @@ -181,7 +179,7 @@ BreakpointOptions::GetConditionText (size_t *hash) const } else { - return NULL; + return nullptr; } } @@ -194,7 +192,7 @@ BreakpointOptions::GetThreadSpecNoCreate () const ThreadSpec * BreakpointOptions::GetThreadSpec () { - if (m_thread_spec_ap.get() == NULL) + if (m_thread_spec_ap.get() == nullptr) m_thread_spec_ap.reset (new ThreadSpec()); return m_thread_spec_ap.get(); @@ -209,11 +207,10 @@ BreakpointOptions::SetThreadID (lldb::tid_t thread_id) void BreakpointOptions::GetDescription (Stream *s, lldb::DescriptionLevel level) const { - // Figure out if there are any options not at their default value, and only print // anything if there are: - if (m_ignore_count != 0 || !m_enabled || m_one_shot || (GetThreadSpecNoCreate() != NULL && GetThreadSpecNoCreate()->HasSpecification ())) + if (m_ignore_count != 0 || !m_enabled || m_one_shot || (GetThreadSpecNoCreate() != nullptr && GetThreadSpecNoCreate()->HasSpecification ())) { if (level == lldb::eDescriptionLevelVerbose) { @@ -293,4 +290,3 @@ BreakpointOptions::CommandBaton::GetDescription (Stream *s, lldb::DescriptionLev s->IndentLess (); s->IndentLess (); } - diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp index 7567d948c3b..7bfa35d43f3 100644 --- a/lldb/source/Breakpoint/BreakpointResolverName.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/BreakpointResolverName.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/BreakpointResolverName.h" + #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" @@ -39,7 +39,6 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, m_language (language), m_skip_prologue (skip_prologue) { - if (m_match_type == Breakpoint::Regexp) { if (!m_regex.Compile (name_cstr)) @@ -93,7 +92,7 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, RegularExpression &func_regex, bool skip_prologue) : BreakpointResolver (bkpt, BreakpointResolver::NameResolver), - m_class_name (NULL), + m_class_name (nullptr), m_regex (func_regex), m_match_type (Breakpoint::Regexp), m_language (eLanguageTypeUnknown), @@ -101,14 +100,11 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, { } -BreakpointResolverName::BreakpointResolverName -( - Breakpoint *bkpt, - const char *class_name, - const char *method, - Breakpoint::MatchType type, - bool skip_prologue -) : +BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt, + const char *class_name, + const char *method, + Breakpoint::MatchType type, + bool skip_prologue ) : BreakpointResolver (bkpt, BreakpointResolver::NameResolver), m_class_name (class_name), m_regex (), @@ -124,9 +120,7 @@ BreakpointResolverName::BreakpointResolverName m_lookups.push_back (lookup); } -BreakpointResolverName::~BreakpointResolverName () -{ -} +BreakpointResolverName::~BreakpointResolverName() = default; BreakpointResolverName::BreakpointResolverName(const BreakpointResolverName &rhs) : BreakpointResolver(rhs.m_breakpoint, BreakpointResolver::NameResolver), @@ -137,7 +131,6 @@ BreakpointResolverName::BreakpointResolverName(const BreakpointResolverName &rhs m_language (rhs.m_language), m_skip_prologue (rhs.m_skip_prologue) { - } void @@ -167,7 +160,6 @@ BreakpointResolverName::AddNameLookup (const ConstString &name, uint32_t name_ty } } - void BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t start_idx) const { @@ -180,7 +172,7 @@ BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t st if (!sc_list.GetContextAtIndex(i, sc)) break; ConstString full_name (sc.GetFunctionName()); - if (full_name && ::strstr(full_name.GetCString(), name.GetCString()) == NULL) + if (full_name && ::strstr(full_name.GetCString(), name.GetCString()) == nullptr) { sc_list.RemoveContextAtIndex(i); } @@ -192,19 +184,15 @@ BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t st } } - // FIXME: Right now we look at the module level, and call the module's "FindFunctions". // Greg says he will add function tables, maybe at the CompileUnit level to accelerate function // lookup. At that point, we should switch the depth to CompileUnit, and look in these tables. Searcher::CallbackReturn -BreakpointResolverName::SearchCallback -( - SearchFilter &filter, - SymbolContext &context, - Address *addr, - bool containing -) +BreakpointResolverName::SearchCallback(SearchFilter &filter, + SymbolContext &context, + Address *addr, + bool containing) { SymbolContextList func_list; //SymbolContextList sym_list; @@ -212,7 +200,7 @@ BreakpointResolverName::SearchCallback uint32_t i; bool new_location; Address break_addr; - assert (m_breakpoint != NULL); + assert (m_breakpoint != nullptr); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); @@ -223,7 +211,7 @@ BreakpointResolverName::SearchCallback return Searcher::eCallbackReturnStop; } bool filter_by_cu = (filter.GetFilterRequiredItems() & eSymbolContextCompUnit) != 0; - const bool include_symbols = filter_by_cu == false; + const bool include_symbols = !filter_by_cu; const bool include_inlines = true; const bool append = true; @@ -235,13 +223,13 @@ BreakpointResolverName::SearchCallback for (const LookupInfo &lookup : m_lookups) { const size_t start_func_idx = func_list.GetSize(); - context.module_sp->FindFunctions (lookup.lookup_name, - NULL, - lookup.name_type_mask, - include_symbols, - include_inlines, - append, - func_list); + context.module_sp->FindFunctions(lookup.lookup_name, + nullptr, + lookup.name_type_mask, + include_symbols, + include_inlines, + append, + func_list); const size_t end_func_idx = func_list.GetSize(); if (start_func_idx < end_func_idx) @@ -387,7 +375,6 @@ BreakpointResolverName::GetDescription (Stream *s) void BreakpointResolverName::Dump (Stream *s) const { - } lldb::BreakpointResolverSP diff --git a/lldb/source/Breakpoint/BreakpointSite.cpp b/lldb/source/Breakpoint/BreakpointSite.cpp index 27e56d3fb9a..d2aaea098cd 100644 --- a/lldb/source/Breakpoint/BreakpointSite.cpp +++ b/lldb/source/Breakpoint/BreakpointSite.cpp @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/BreakpointSite.h" - // C Includes // C++ Includes #include <inttypes.h> // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/BreakpointSite.h" + #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointSiteList.h" @@ -23,13 +23,10 @@ using namespace lldb; using namespace lldb_private; -BreakpointSite::BreakpointSite -( - BreakpointSiteList *list, - const BreakpointLocationSP& owner, - lldb::addr_t addr, - bool use_hardware -) : +BreakpointSite::BreakpointSite(BreakpointSiteList *list, + const BreakpointLocationSP& owner, + lldb::addr_t addr, + bool use_hardware) : StoppointLocation(GetNextID(), addr, 0, use_hardware), m_type (eSoftware), // Process subclasses need to set this correctly using SetType() m_saved_opcode(), @@ -85,7 +82,7 @@ BreakpointSite::IsBreakpointAtThisSite (lldb::break_id_t bp_id) void BreakpointSite::Dump(Stream *s) const { - if (s == NULL) + if (s == nullptr) return; s->Printf("BreakpointSite %u: addr = 0x%8.8" PRIx64 " type = %s breakpoint hw_index = %i hit_count = %-4u", diff --git a/lldb/source/Breakpoint/StoppointCallbackContext.cpp b/lldb/source/Breakpoint/StoppointCallbackContext.cpp index 2266c3e429c..9932843714f 100644 --- a/lldb/source/Breakpoint/StoppointCallbackContext.cpp +++ b/lldb/source/Breakpoint/StoppointCallbackContext.cpp @@ -7,17 +7,16 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/StoppointCallbackContext.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/StoppointCallbackContext.h" using namespace lldb_private; StoppointCallbackContext::StoppointCallbackContext() : - event (NULL), + event (nullptr), exe_ctx_ref (), is_synchronous (false) { @@ -33,7 +32,7 @@ StoppointCallbackContext::StoppointCallbackContext(Event *e, const ExecutionCont void StoppointCallbackContext::Clear() { - event = NULL; + event = nullptr; exe_ctx_ref.Clear(); is_synchronous = false; } diff --git a/lldb/source/Breakpoint/Watchpoint.cpp b/lldb/source/Breakpoint/Watchpoint.cpp index f1cb679c61d..afc217f2a73 100644 --- a/lldb/source/Breakpoint/Watchpoint.cpp +++ b/lldb/source/Breakpoint/Watchpoint.cpp @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/Watchpoint.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/Watchpoint.h" + #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Stream.h" #include "lldb/Core/Value.h" @@ -67,9 +67,7 @@ Watchpoint::Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const m_being_created = false; } -Watchpoint::~Watchpoint() -{ -} +Watchpoint::~Watchpoint() = default; // This function is used when "baton" doesn't need to be freed void @@ -102,7 +100,6 @@ void Watchpoint::SetDeclInfo (const std::string &str) { m_decl_str = str; - return; } std::string @@ -115,7 +112,6 @@ void Watchpoint::SetWatchSpec (const std::string &str) { m_watch_spec_str = str; - return; } // Override default impl of StoppointLocation::IsHardware() since m_is_hardware @@ -154,10 +150,7 @@ Watchpoint::CaptureWatchedValue (const ExecutionContext &exe_ctx) } m_new_value_sp = ValueObjectMemory::Create (exe_ctx.GetBestExecutionContextScope(), watch_name.AsCString(), watch_address, m_type); m_new_value_sp = m_new_value_sp->CreateConstantValue(watch_name); - if (m_new_value_sp && m_new_value_sp->GetError().Success()) - return true; - else - return false; + return (m_new_value_sp && m_new_value_sp->GetError().Success()); } void @@ -200,7 +193,6 @@ void Watchpoint::GetDescription (Stream *s, lldb::DescriptionLevel level) { DumpWithLevel(s, level); - return; } void @@ -209,7 +201,7 @@ Watchpoint::Dump(Stream *s) const DumpWithLevel(s, lldb::eDescriptionLevelBrief); } -// If prefix is NULL, we display the watch id and ignore the prefix altogether. +// If prefix is nullptr, we display the watch id and ignore the prefix altogether. void Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const { @@ -249,7 +241,7 @@ Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const void Watchpoint::DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const { - if (s == NULL) + if (s == nullptr) return; assert(description_level >= lldb::eDescriptionLevelBrief && @@ -351,11 +343,13 @@ Watchpoint::WatchpointRead () const { return m_watch_read != 0; } + bool Watchpoint::WatchpointWrite () const { return m_watch_write != 0; } + uint32_t Watchpoint::GetIgnoreCount () const { @@ -380,20 +374,20 @@ Watchpoint::InvokeCallback (StoppointCallbackContext *context) void Watchpoint::SetCondition (const char *condition) { - if (condition == NULL || condition[0] == '\0') + if (condition == nullptr || condition[0] == '\0') { if (m_condition_ap.get()) m_condition_ap.reset(); } else { - // Pass NULL for expr_prefix (no translation-unit level definitions). + // Pass nullptr for expr_prefix (no translation-unit level definitions). Error error; - m_condition_ap.reset(m_target.GetUserExpressionForLanguage (condition, - NULL, - lldb::eLanguageTypeUnknown, - UserExpression::eResultTypeAny, - error)); + m_condition_ap.reset(m_target.GetUserExpressionForLanguage(condition, + nullptr, + lldb::eLanguageTypeUnknown, + UserExpression::eResultTypeAny, + error)); if (error.Fail()) { // FIXME: Log something... @@ -409,7 +403,7 @@ Watchpoint::GetConditionText () const if (m_condition_ap.get()) return m_condition_ap->GetUserText(); else - return NULL; + return nullptr; } void @@ -426,8 +420,7 @@ Watchpoint::SendWatchpointChangedEvent (lldb::WatchpointEventType eventKind) void Watchpoint::SendWatchpointChangedEvent (WatchpointEventData *data) { - - if (data == NULL) + if (data == nullptr) return; if (!m_being_created @@ -445,9 +438,7 @@ Watchpoint::WatchpointEventData::WatchpointEventData (WatchpointEventType sub_ty { } -Watchpoint::WatchpointEventData::~WatchpointEventData () -{ -} +Watchpoint::WatchpointEventData::~WatchpointEventData() = default; const ConstString & Watchpoint::WatchpointEventData::GetFlavorString () @@ -462,7 +453,6 @@ Watchpoint::WatchpointEventData::GetFlavor () const return WatchpointEventData::GetFlavorString (); } - WatchpointSP & Watchpoint::WatchpointEventData::GetWatchpoint () { @@ -489,7 +479,7 @@ Watchpoint::WatchpointEventData::GetEventDataFromEvent (const Event *event) if (event_data && event_data->GetFlavor() == WatchpointEventData::GetFlavorString()) return static_cast <const WatchpointEventData *> (event->GetData()); } - return NULL; + return nullptr; } WatchpointEventType @@ -497,7 +487,7 @@ Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent (const EventSP { const WatchpointEventData *data = GetEventDataFromEvent (event_sp.get()); - if (data == NULL) + if (data == nullptr) return eWatchpointEventTypeInvalidType; else return data->GetWatchpointEventType(); diff --git a/lldb/source/Breakpoint/WatchpointOptions.cpp b/lldb/source/Breakpoint/WatchpointOptions.cpp index d11c8f74f94..365d884691e 100644 --- a/lldb/source/Breakpoint/WatchpointOptions.cpp +++ b/lldb/source/Breakpoint/WatchpointOptions.cpp @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/WatchpointOptions.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/WatchpointOptions.h" + #include "lldb/Core/Stream.h" #include "lldb/Core/StringList.h" #include "lldb/Core/Value.h" @@ -50,7 +50,7 @@ WatchpointOptions::WatchpointOptions(const WatchpointOptions& rhs) : m_callback_is_synchronous (rhs.m_callback_is_synchronous), m_thread_spec_ap () { - if (rhs.m_thread_spec_ap.get() != NULL) + if (rhs.m_thread_spec_ap.get() != nullptr) m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get())); } @@ -63,7 +63,7 @@ WatchpointOptions::operator=(const WatchpointOptions& rhs) m_callback = rhs.m_callback; m_callback_baton_sp = rhs.m_callback_baton_sp; m_callback_is_synchronous = rhs.m_callback_is_synchronous; - if (rhs.m_thread_spec_ap.get() != NULL) + if (rhs.m_thread_spec_ap.get() != nullptr) m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get())); return *this; } @@ -86,9 +86,7 @@ WatchpointOptions::CopyOptionsNoCallback (WatchpointOptions &orig) //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- -WatchpointOptions::~WatchpointOptions() -{ -} +WatchpointOptions::~WatchpointOptions() = default; //------------------------------------------------------------------ // Callbacks @@ -127,9 +125,9 @@ WatchpointOptions::InvokeCallback (StoppointCallbackContext *context, { if (m_callback && context->is_synchronous == IsCallbackSynchronous()) { - return m_callback (m_callback_baton_sp ? m_callback_baton_sp->m_data : NULL, - context, - watch_id); + return m_callback(m_callback_baton_sp ? m_callback_baton_sp->m_data : nullptr, + context, + watch_id); } else return true; @@ -150,7 +148,7 @@ WatchpointOptions::GetThreadSpecNoCreate () const ThreadSpec * WatchpointOptions::GetThreadSpec () { - if (m_thread_spec_ap.get() == NULL) + if (m_thread_spec_ap.get() == nullptr) m_thread_spec_ap.reset (new ThreadSpec()); return m_thread_spec_ap.get(); @@ -171,14 +169,14 @@ WatchpointOptions::GetCallbackDescription (Stream *s, lldb::DescriptionLevel lev m_callback_baton_sp->GetDescription (s, level); } } + void WatchpointOptions::GetDescription (Stream *s, lldb::DescriptionLevel level) const { - // Figure out if there are any options not at their default value, and only print // anything if there are: - if ((GetThreadSpecNoCreate() != NULL && GetThreadSpecNoCreate()->HasSpecification ())) + if ((GetThreadSpecNoCreate() != nullptr && GetThreadSpecNoCreate()->HasSpecification ())) { if (level == lldb::eDescriptionLevelVerbose) { @@ -237,4 +235,3 @@ WatchpointOptions::CommandBaton::GetDescription (Stream *s, lldb::DescriptionLev s->IndentLess (); s->IndentLess (); } - |