From: Eugene Zelenko Date: Thu, 18 Feb 2016 18:52:47 +0000 (+0000) Subject: Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Target; other... X-Git-Tag: llvmorg-3.9.0-rc1~13814 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d70a6e71a9f04d12b155ca561f8ef92b3b227a40;p=platform%2Fupstream%2Fllvm.git Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Target; other minor fixes. llvm-svn: 261242 --- diff --git a/lldb/source/Target/ProcessInfo.cpp b/lldb/source/Target/ProcessInfo.cpp index 22da2c6a2a29..1adb93333fc8 100644 --- a/lldb/source/Target/ProcessInfo.cpp +++ b/lldb/source/Target/ProcessInfo.cpp @@ -7,10 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/ProcessInfo.h" - // C Includes -#include +// C++ Includes +#include + +// Other libraries and framework includes +// Project includes +#include "lldb/Target/ProcessInfo.h" using namespace lldb; using namespace lldb_private; @@ -83,9 +86,7 @@ ProcessInfo::SetExecutableFile (const FileSpec &exe_file, bool add_exe_file_as_f const char * ProcessInfo::GetArg0 () const { - if (m_arg0.empty()) - return NULL; - return m_arg0.c_str(); + return (m_arg0.empty() ? nullptr : m_arg0.c_str()); } void @@ -116,6 +117,7 @@ ProcessInfo::SetArguments (char const **argv, bool first_arg_is_executable) } } } + void ProcessInfo::SetArguments (const Args& args, bool first_arg_is_executable) { diff --git a/lldb/source/Target/Queue.cpp b/lldb/source/Target/Queue.cpp index 7cfa6fa5582f..9d4032a29e6f 100644 --- a/lldb/source/Target/Queue.cpp +++ b/lldb/source/Target/Queue.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/Target/Process.h" #include "lldb/Target/Queue.h" #include "lldb/Target/QueueList.h" @@ -32,9 +36,7 @@ Queue::Queue (ProcessSP process_sp, lldb::queue_id_t queue_id, const char *queue m_process_wp = process_sp; } -Queue::~Queue () -{ -} +Queue::~Queue() = default; queue_id_t Queue::GetID () @@ -45,10 +47,7 @@ Queue::GetID () const char * Queue::GetName () { - const char *result = NULL; - if (m_queue_name.size() > 0) - result = m_queue_name.c_str(); - return result; + return (m_queue_name.empty() ? nullptr : m_queue_name.c_str()); } uint32_t @@ -62,7 +61,7 @@ Queue::GetThreads () { std::vector result; ProcessSP process_sp = m_process_wp.lock(); - if (process_sp.get ()) + if (process_sp) { for (ThreadSP thread_sp : process_sp->Threads()) { @@ -87,7 +86,6 @@ Queue::GetNumRunningWorkItems () const return m_running_work_items_count; } - void Queue::SetNumPendingWorkItems (uint32_t count) { @@ -112,11 +110,10 @@ Queue::GetLibdispatchQueueAddress () const return m_dispatch_queue_t_addr; } - const std::vector & Queue::GetPendingItems () { - if (m_pending_items.size() == 0) + if (m_pending_items.empty()) { ProcessSP process_sp = m_process_wp.lock(); if (process_sp && process_sp->GetSystemRuntime()) diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index e3e0b4468422..43ca4b3f97ae 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/StackFrame.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/StackFrame.h" #include "lldb/Core/Module.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Disassembler.h" @@ -58,7 +57,7 @@ StackFrame::StackFrame (const ThreadSP &thread_sp, m_frame_index (frame_idx), m_concrete_frame_index (unwind_frame_index), m_reg_context_sp (), - m_id (pc, cfa, NULL), + m_id(pc, cfa, nullptr), m_frame_code_addr (pc), m_sc (), m_flags (), @@ -75,12 +74,12 @@ StackFrame::StackFrame (const ThreadSP &thread_sp, { // If we don't have a CFA value, use the frame index for our StackID so that recursive // functions properly aren't confused with one another on a history stack. - if (m_is_history_frame && m_cfa_is_valid == false) + if (m_is_history_frame && !m_cfa_is_valid) { m_id.SetCFA (m_frame_index); } - if (sc_ptr != NULL) + if (sc_ptr != nullptr) { m_sc = *sc_ptr; m_flags.Set(m_sc.GetResolvedMask ()); @@ -98,7 +97,7 @@ StackFrame::StackFrame (const ThreadSP &thread_sp, m_frame_index (frame_idx), m_concrete_frame_index (unwind_frame_index), m_reg_context_sp (reg_context_sp), - m_id (pc, cfa, NULL), + m_id(pc, cfa, nullptr), m_frame_code_addr (pc), m_sc (), m_flags (), @@ -113,7 +112,7 @@ StackFrame::StackFrame (const ThreadSP &thread_sp, m_disassembly (), m_mutex (Mutex::eMutexTypeRecursive) { - if (sc_ptr != NULL) + if (sc_ptr != nullptr) { m_sc = *sc_ptr; m_flags.Set(m_sc.GetResolvedMask ()); @@ -138,7 +137,7 @@ StackFrame::StackFrame (const ThreadSP &thread_sp, m_frame_index (frame_idx), m_concrete_frame_index (unwind_frame_index), m_reg_context_sp (reg_context_sp), - m_id (pc_addr.GetLoadAddress (thread_sp->CalculateTarget().get()), cfa, NULL), + m_id(pc_addr.GetLoadAddress(thread_sp->CalculateTarget().get()), cfa, nullptr), m_frame_code_addr (pc_addr), m_sc (), m_flags (), @@ -153,13 +152,13 @@ StackFrame::StackFrame (const ThreadSP &thread_sp, m_disassembly (), m_mutex (Mutex::eMutexTypeRecursive) { - if (sc_ptr != NULL) + if (sc_ptr != nullptr) { m_sc = *sc_ptr; m_flags.Set(m_sc.GetResolvedMask ()); } - if (m_sc.target_sp.get() == NULL && reg_context_sp) + if (!m_sc.target_sp && reg_context_sp) { m_sc.target_sp = reg_context_sp->CalculateTarget(); if (m_sc.target_sp) @@ -181,13 +180,7 @@ StackFrame::StackFrame (const ThreadSP &thread_sp, } } - -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -StackFrame::~StackFrame() -{ -} +StackFrame::~StackFrame() = default; StackID& StackFrame::GetStackID() @@ -209,13 +202,13 @@ StackFrame::GetStackID() // Calculate the frame block and use this for the stack ID symbol // context scope if we have one. SymbolContextScope *scope = GetFrameBlock (); - if (scope == NULL) + if (scope == nullptr) { // We don't have a block, so use the symbol if (m_flags.IsClear (eSymbolContextSymbol)) GetSymbolContext (eSymbolContextSymbol); - // It is ok if m_sc.symbol is NULL here + // It is ok if m_sc.symbol is nullptr here scope = m_sc.symbol; } // Set the symbol context scope (the accessor will set the @@ -301,8 +294,8 @@ StackFrame::Disassemble () Target *target = exe_ctx.GetTargetPtr(); if (target) { - const char *plugin_name = NULL; - const char *flavor = NULL; + const char *plugin_name = nullptr; + const char *flavor = nullptr; Disassembler::Disassemble (target->GetDebugger(), target->GetArchitecture(), plugin_name, @@ -314,7 +307,7 @@ StackFrame::Disassemble () m_disassembly); } if (m_disassembly.GetSize() == 0) - return NULL; + return nullptr; } return m_disassembly.GetData(); } @@ -322,7 +315,7 @@ StackFrame::Disassemble () Block * StackFrame::GetFrameBlock () { - if (m_sc.block == NULL && m_flags.IsClear (eSymbolContextBlock)) + if (m_sc.block == nullptr && m_flags.IsClear(eSymbolContextBlock)) GetSymbolContext (eSymbolContextBlock); if (m_sc.block) @@ -342,7 +335,7 @@ StackFrame::GetFrameBlock () return &m_sc.function->GetBlock (false); } } - return NULL; + return nullptr; } //---------------------------------------------------------------------- @@ -368,7 +361,6 @@ StackFrame::GetSymbolContext (uint32_t resolve_scope) resolved |= eSymbolContextTarget; } - // Resolve our PC to section offset if we haven't already done so // and if we don't have a module. The resolved address section will // contain the module to which it belongs @@ -411,7 +403,6 @@ StackFrame::GetSymbolContext (uint32_t resolve_scope) } } - if (m_sc.module_sp) { // We have something in our stack frame symbol context, lets check @@ -487,13 +478,13 @@ StackFrame::GetSymbolContext (uint32_t resolve_scope) // Only replace what we didn't already have as we may have // information for an inlined function scope that won't match // what a standard lookup by address would match - if ((resolved & eSymbolContextCompUnit) && m_sc.comp_unit == NULL) + if ((resolved & eSymbolContextCompUnit) && m_sc.comp_unit == nullptr) m_sc.comp_unit = sc.comp_unit; - if ((resolved & eSymbolContextFunction) && m_sc.function == NULL) + if ((resolved & eSymbolContextFunction) && m_sc.function == nullptr) m_sc.function = sc.function; - if ((resolved & eSymbolContextBlock) && m_sc.block == NULL) + if ((resolved & eSymbolContextBlock) && m_sc.block == nullptr) m_sc.block = sc.block; - if ((resolved & eSymbolContextSymbol) && m_sc.symbol == NULL) + if ((resolved & eSymbolContextSymbol) && m_sc.symbol == nullptr) m_sc.symbol = sc.symbol; if ((resolved & eSymbolContextLineEntry) && !m_sc.line_entry.IsValid()) { @@ -533,7 +524,6 @@ StackFrame::GetSymbolContext (uint32_t resolve_scope) return m_sc; } - VariableList * StackFrame::GetVariableList (bool get_file_globals) { @@ -607,7 +597,6 @@ StackFrame::GetInScopeVariableList (bool get_file_globals) return var_list_sp; } - ValueObjectSP StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, DynamicValueType use_dynamic, @@ -736,7 +725,6 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, const char separator_type = var_path[0]; switch (separator_type) { - case '-': if (var_path.size() >= 2 && var_path[1] != '>') return ValueObjectSP(); @@ -745,7 +733,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, { // Make sure we aren't trying to deref an objective // C ivar if this is not allowed - const uint32_t pointer_type_flags = valobj_sp->GetCompilerType().GetTypeInfo (NULL); + const uint32_t pointer_type_flags = valobj_sp->GetCompilerType().GetTypeInfo(nullptr); if ((pointer_type_flags & eTypeIsObjC) && (pointer_type_flags & eTypeIsPointer)) { @@ -800,7 +788,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); if (!child_valobj_sp) { - if (no_synth_child == false) + if (!no_synth_child) { child_valobj_sp = valobj_sp->GetSyntheticValue(); if (child_valobj_sp) @@ -854,7 +842,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, // Array member access, or treating pointer as an array if (var_path.size() > 2) // Need at least two brackets and a number { - char *end = NULL; + char *end = nullptr; long child_index = ::strtol (&var_path[1], &end, 0); if (end && *end == ']' && *(end-1) != '[') // this code forces an error in the case of arr[]. as bitfield[] is not a good syntax we're good to go @@ -919,7 +907,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, { // dereferencing ObjC variables is not valid.. so let's try and recur to synthetic children ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(); - if (synthetic.get() == NULL /* no synthetic */ + if (!synthetic /* no synthetic */ || synthetic == valobj_sp) /* synthetic is the same as the original object */ { valobj_sp->GetExpressionPath (var_expr_path_strm, false); @@ -961,12 +949,12 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, } } } - else if (valobj_sp->GetCompilerType().IsArrayType (NULL, NULL, &is_incomplete_array)) + else if (valobj_sp->GetCompilerType().IsArrayType(nullptr, nullptr, &is_incomplete_array)) { // Pass false to dynamic_value here so we can tell the difference between // no dynamic value and no member of this type... child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); - if (!child_valobj_sp && (is_incomplete_array || no_synth_child == false)) + if (!child_valobj_sp && (is_incomplete_array || !no_synth_child)) child_valobj_sp = valobj_sp->GetSyntheticArrayMember (child_index, true); if (!child_valobj_sp) @@ -995,7 +983,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, { ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(); if (no_synth_child /* synthetic is forbidden */ || - synthetic.get() == NULL /* no synthetic */ + !synthetic /* no synthetic */ || synthetic == valobj_sp) /* synthetic is the same as the original object */ { valobj_sp->GetExpressionPath (var_expr_path_strm, false); @@ -1048,7 +1036,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, else if (end && *end == '-') { // this is most probably a BitField, let's take a look - char *real_end = NULL; + char *real_end = nullptr; long final_index = ::strtol (end+1, &real_end, 0); bool expand_bitfield = true; if (real_end && *real_end == ']') @@ -1174,7 +1162,6 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, if (var_path.empty()) break; - } if (valobj_sp) { @@ -1209,7 +1196,7 @@ bool StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr) { Mutex::Locker locker(m_mutex); - if (m_cfa_is_valid == false) + if (!m_cfa_is_valid) { m_frame_base_error.SetErrorString("No frame base available for this historical stack frame."); return false; @@ -1229,7 +1216,8 @@ StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr) if (m_sc.function->GetFrameBaseExpression().IsLocationList()) loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.GetTargetPtr()); - if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, NULL, NULL, NULL, loclist_base_addr, NULL, expr_value, &m_frame_base_error) == false) + if (!m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, nullptr, nullptr, nullptr, loclist_base_addr, + nullptr, expr_value, &m_frame_base_error)) { // We should really have an error if evaluate returns, but in case // we don't, lets set the error to something at least. @@ -1275,7 +1263,6 @@ StackFrame::HasDebugInformation () return m_sc.line_entry.IsValid(); } - ValueObjectSP StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic) { @@ -1294,7 +1281,7 @@ StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, Dynam if (var_idx < num_variables) { valobj_sp = m_variable_list_value_objects.GetValueObjectAtIndex (var_idx); - if (valobj_sp.get() == NULL) + if (!valobj_sp) { if (m_variable_list_value_objects.GetSize() < num_variables) m_variable_list_value_objects.Resize(num_variables); @@ -1326,7 +1313,7 @@ StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, DynamicValueType // We aren't already tracking this global VariableList *var_list = GetVariableList (true); // If this frame has no variables, create a new list - if (var_list == NULL) + if (var_list == nullptr) m_variable_list_sp.reset (new VariableList()); // Add the global/static variable to this frame @@ -1341,10 +1328,10 @@ StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, DynamicValueType bool StackFrame::IsInlined () { - if (m_sc.block == NULL) + if (m_sc.block == nullptr) GetSymbolContext (eSymbolContextBlock); if (m_sc.block) - return m_sc.block->GetContainingInlinedBlock() != NULL; + return m_sc.block->GetContainingInlinedBlock() != nullptr; return false; } @@ -1393,7 +1380,6 @@ StackFrame::CalculateStackFrame () return shared_from_this(); } - void StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx) { @@ -1403,7 +1389,7 @@ StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx) void StackFrame::DumpUsingSettingsFormat (Stream *strm, const char *frame_marker) { - if (strm == NULL) + if (strm == nullptr) return; GetSymbolContext(eSymbolContextEverything); @@ -1413,11 +1399,11 @@ StackFrame::DumpUsingSettingsFormat (Stream *strm, const char *frame_marker) if (frame_marker) s.PutCString(frame_marker); - const FormatEntity::Entry *frame_format = NULL; + const FormatEntity::Entry *frame_format = nullptr; Target *target = exe_ctx.GetTargetPtr(); if (target) frame_format = target->GetDebugger().GetFrameFormat(); - if (frame_format && FormatEntity::Format(*frame_format, s, &m_sc, &exe_ctx, NULL, NULL, false, false)) + if (frame_format && FormatEntity::Format(*frame_format, s, &m_sc, &exe_ctx, nullptr, nullptr, false, false)) { strm->Write(s.GetData(), s.GetSize()); } @@ -1431,7 +1417,7 @@ StackFrame::DumpUsingSettingsFormat (Stream *strm, const char *frame_marker) void StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths) { - if (strm == NULL) + if (strm == nullptr) return; if (show_frame_index) @@ -1466,7 +1452,6 @@ StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame) if (!m_disassembly.GetString().empty()) m_disassembly.GetString().swap (m_disassembly.GetString()); } - void StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame) @@ -1479,10 +1464,10 @@ StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame) m_concrete_frame_index = curr_frame.m_concrete_frame_index; m_reg_context_sp = curr_frame.m_reg_context_sp; m_frame_code_addr = curr_frame.m_frame_code_addr; - assert (m_sc.target_sp.get() == NULL || curr_frame.m_sc.target_sp.get() == NULL || m_sc.target_sp.get() == curr_frame.m_sc.target_sp.get()); - assert (m_sc.module_sp.get() == NULL || curr_frame.m_sc.module_sp.get() == NULL || m_sc.module_sp.get() == curr_frame.m_sc.module_sp.get()); - assert (m_sc.comp_unit == NULL || curr_frame.m_sc.comp_unit == NULL || m_sc.comp_unit == curr_frame.m_sc.comp_unit); - assert (m_sc.function == NULL || curr_frame.m_sc.function == NULL || m_sc.function == curr_frame.m_sc.function); + assert (!m_sc.target_sp || !curr_frame.m_sc.target_sp || m_sc.target_sp.get() == curr_frame.m_sc.target_sp.get()); + assert (!m_sc.module_sp || !curr_frame.m_sc.module_sp || m_sc.module_sp.get() == curr_frame.m_sc.module_sp.get()); + assert (m_sc.comp_unit == nullptr || curr_frame.m_sc.comp_unit == nullptr || m_sc.comp_unit == curr_frame.m_sc.comp_unit); + assert (m_sc.function == nullptr || curr_frame.m_sc.function == nullptr || m_sc.function == curr_frame.m_sc.function); m_sc = curr_frame.m_sc; m_flags.Clear(GOT_FRAME_BASE | eSymbolContextEverything); m_flags.Set (m_sc.GetResolvedMask()); @@ -1490,11 +1475,10 @@ StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame) m_frame_base_error.Clear(); } - bool StackFrame::HasCachedData () const { - if (m_variable_list_sp.get()) + if (m_variable_list_sp) return true; if (m_variable_list_value_objects.GetSize() > 0) return true; @@ -1571,8 +1555,8 @@ StackFrame::GetStatus (Stream& strm, AddressRange pc_range; pc_range.GetBaseAddress() = GetFrameCodeAddress(); pc_range.SetByteSize(disasm_lines * target_arch.GetMaximumOpcodeByteSize()); - const char *plugin_name = NULL; - const char *flavor = NULL; + const char *plugin_name = nullptr; + const char *flavor = nullptr; Disassembler::Disassemble (target->GetDebugger(), target_arch, plugin_name, @@ -1591,4 +1575,3 @@ StackFrame::GetStatus (Stream& strm, } return true; } - diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp index f2f3cad471fe..ed0a0e6d8f06 100644 --- a/lldb/source/Target/StackFrameList.cpp +++ b/lldb/source/Target/StackFrameList.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/StackFrameList.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/StackFrameList.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/Log.h" @@ -60,9 +59,6 @@ StackFrameList::StackFrameList } } -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- StackFrameList::~StackFrameList() { // Call clear since this takes a lock and clears the stack frame list @@ -110,7 +106,7 @@ StackFrameList::ResetCurrentInlinedDepth () if (m_show_inlined_frames) { GetFramesUpTo(0); - if (m_frames.size() == 0) + if (m_frames.empty()) return; if (!m_frames[0]->IsInlined()) { @@ -199,7 +195,7 @@ StackFrameList::ResetCurrentInlinedDepth () int num_inlined_functions = 0; for (Block *container_ptr = block_ptr->GetInlinedParent(); - container_ptr != NULL; + container_ptr != nullptr; container_ptr = container_ptr->GetInlinedParent()) { if (!container_ptr->GetRangeContainingAddress(pc_as_address, containing_range)) @@ -258,7 +254,7 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) { // this makes sure we do not fetch frames for an invalid thread - if (m_thread.IsValid() == false) + if (!m_thread.IsValid()) return; // We've already gotten more frames than asked for, or we've already finished unwinding, return. @@ -304,7 +300,6 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx) if (reg_ctx_sp) { - const bool success = unwinder && unwinder->GetFrameInfoAtIndex(idx, cfa, pc); // There shouldn't be any way not to get the frame info for frame 0. // But if the unwinder can't make one, lets make one by hand with the @@ -315,13 +310,13 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx) pc = reg_ctx_sp->GetPC(); } - unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(), - m_frames.size(), - idx, - reg_ctx_sp, - cfa, - pc, - NULL)); + unwind_frame_sp.reset(new StackFrame(m_thread.shared_from_this(), + m_frames.size(), + idx, + reg_ctx_sp, + cfa, + pc, + nullptr)); m_frames.push_back (unwind_frame_sp); } } @@ -343,7 +338,8 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx) const bool cfa_is_valid = true; const bool stop_id_is_valid = false; const bool is_history_frame = false; - unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(), m_frames.size(), idx, cfa, cfa_is_valid, pc, 0, stop_id_is_valid, is_history_frame, NULL)); + unwind_frame_sp.reset(new StackFrame(m_thread.shared_from_this(), m_frames.size(), idx, cfa, cfa_is_valid, pc, + 0, stop_id_is_valid, is_history_frame, nullptr)); m_frames.push_back (unwind_frame_sp); } @@ -439,7 +435,7 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx) StackFrame *curr_frame = curr_frame_sp.get(); StackFrame *prev_frame = prev_frame_sp.get(); - if (curr_frame == NULL || prev_frame == NULL) + if (curr_frame == nullptr || prev_frame == nullptr) break; // Check the stack ID to make sure they are equal @@ -502,7 +498,7 @@ StackFrameList::GetNumFrames (bool can_create) void StackFrameList::Dump (Stream *s) { - if (s == NULL) + if (s == nullptr) return; Mutex::Locker locker (m_mutex); @@ -562,7 +558,8 @@ StackFrameList::GetFrameAtIndex (uint32_t idx) const bool cfa_is_valid = true; const bool stop_id_is_valid = false; const bool is_history_frame = false; - frame_sp.reset (new StackFrame (m_thread.shared_from_this(), idx, idx, cfa, cfa_is_valid, pc, 0, stop_id_is_valid, is_history_frame, NULL)); + frame_sp.reset(new StackFrame(m_thread.shared_from_this(), idx, idx, cfa, cfa_is_valid, pc, 0, + stop_id_is_valid, is_history_frame, nullptr)); Function *function = frame_sp->GetSymbolContext (eSymbolContextFunction).function; if (function) @@ -573,7 +570,7 @@ StackFrameList::GetFrameAtIndex (uint32_t idx) } else { - // Set the symbol scope from the symbol regardless if it is NULL or valid. + // Set the symbol scope from the symbol regardless if it is nullptr or valid. frame_sp->SetSymbolContextScope (frame_sp->GetSymbolContext (eSymbolContextSymbol).symbol); } SetFrameAtIndex(idx, frame_sp); @@ -586,17 +583,16 @@ StackFrameList::GetFrameAtIndex (uint32_t idx) // There should ALWAYS be a frame at index 0. If something went wrong with the CurrentInlinedDepth such that // there weren't as many frames as we thought taking that into account, then reset the current inlined depth // and return the real zeroth frame. - if (m_frames.size() > 0) - { - ResetCurrentInlinedDepth(); - frame_sp = m_frames[original_idx]; - } - else + if (m_frames.empty()) { // Why do we have a thread with zero frames, that should not ever happen... if (m_thread.IsValid()) assert ("A valid thread has no frames."); - + } + else + { + ResetCurrentInlinedDepth(); + frame_sp = m_frames[original_idx]; } } @@ -686,7 +682,6 @@ StackFrameList::GetSelectedFrameIndex () const return m_selected_frame_idx; } - uint32_t StackFrameList::SetSelectedFrame (lldb_private::StackFrame *frame) { @@ -773,25 +768,25 @@ StackFrameList::InvalidateFrames (uint32_t start_idx) void StackFrameList::Merge (std::unique_ptr& curr_ap, lldb::StackFrameListSP& prev_sp) { - Mutex::Locker curr_locker (curr_ap.get() ? &curr_ap->m_mutex : NULL); - Mutex::Locker prev_locker (prev_sp.get() ? &prev_sp->m_mutex : NULL); + Mutex::Locker curr_locker(curr_ap ? &curr_ap->m_mutex : nullptr); + Mutex::Locker prev_locker(prev_sp ? &prev_sp->m_mutex : nullptr); #if defined (DEBUG_STACK_FRAMES) StreamFile s(stdout, false); s.PutCString("\n\nStackFrameList::Merge():\nPrev:\n"); - if (prev_sp.get()) + if (prev_sp) prev_sp->Dump (&s); else s.PutCString ("NULL"); s.PutCString("\nCurr:\n"); - if (curr_ap.get()) + if (curr_ap) curr_ap->Dump (&s); else s.PutCString ("NULL"); s.EOL(); #endif - if (curr_ap.get() == NULL || curr_ap->GetNumFrames (false) == 0) + if (!curr_ap || curr_ap->GetNumFrames(false) == 0) { #if defined (DEBUG_STACK_FRAMES) s.PutCString("No current frames, leave previous frames alone...\n"); @@ -800,7 +795,7 @@ StackFrameList::Merge (std::unique_ptr& curr_ap, lldb::StackFram return; } - if (prev_sp.get() == NULL || prev_sp->GetNumFrames (false) == 0) + if (!prev_sp || prev_sp->GetNumFrames(false) == 0) { #if defined (DEBUG_STACK_FRAMES) s.PutCString("No previous frames, so use current frames...\n"); @@ -866,8 +861,6 @@ StackFrameList::Merge (std::unique_ptr& curr_ap, lldb::StackFram s.PutCString("\nMerged:\n"); prev_sp->Dump (&s); #endif - - } lldb::StackFrameSP @@ -913,7 +906,7 @@ StackFrameList::GetStatus (Stream& strm, last_frame = first_frame + num_frames; StackFrameSP selected_frame_sp = m_thread.GetSelectedFrame(); - const char *unselected_marker = NULL; + const char *unselected_marker = nullptr; std::string buffer; if (selected_frame_marker) { @@ -921,15 +914,15 @@ StackFrameList::GetStatus (Stream& strm, buffer.insert(buffer.begin(), len, ' '); unselected_marker = buffer.c_str(); } - const char *marker = NULL; + const char *marker = nullptr; for (frame_idx = first_frame; frame_idx < last_frame; ++frame_idx) { frame_sp = GetFrameAtIndex(frame_idx); - if (frame_sp.get() == NULL) + if (!frame_sp) break; - if (selected_frame_marker != NULL) + if (selected_frame_marker != nullptr) { if (frame_sp == selected_frame_sp) marker = selected_frame_marker; @@ -947,4 +940,3 @@ StackFrameList::GetStatus (Stream& strm, strm.IndentLess(); return num_frames_displayed; } - diff --git a/lldb/source/Target/StackID.cpp b/lldb/source/Target/StackID.cpp index ca337f914406..222b2d3f2aa8 100644 --- a/lldb/source/Target/StackID.cpp +++ b/lldb/source/Target/StackID.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/StackID.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/StackID.h" #include "lldb/Core/Stream.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Symbol.h" @@ -20,7 +19,6 @@ using namespace lldb_private; - void StackID::Dump (Stream *s) { @@ -48,8 +46,8 @@ lldb_private::operator== (const StackID& lhs, const StackID& rhs) SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope(); SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope(); - // Only compare the PC values if both symbol context scopes are NULL - if (lhs_scope == NULL && rhs_scope == NULL) + // Only compare the PC values if both symbol context scopes are nullptr + if (lhs_scope == nullptr && rhs_scope == nullptr) return lhs.GetPC() == rhs.GetPC(); return lhs_scope == rhs_scope; @@ -64,7 +62,7 @@ lldb_private::operator!= (const StackID& lhs, const StackID& rhs) SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope(); SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope(); - if (lhs_scope == NULL && rhs_scope == NULL) + if (lhs_scope == nullptr && rhs_scope == nullptr) return lhs.GetPC() != rhs.GetPC(); return lhs_scope != rhs_scope; @@ -88,7 +86,7 @@ lldb_private::operator< (const StackID& lhs, const StackID& rhs) SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope(); SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope(); - if (lhs_scope != NULL && rhs_scope != NULL) + if (lhs_scope != nullptr && rhs_scope != nullptr) { // Same exact scope, lhs is not less than (younger than rhs) if (lhs_scope == rhs_scope) @@ -101,8 +99,8 @@ lldb_private::operator< (const StackID& lhs, const StackID& rhs) // Items with the same function can only be compared if (lhs_sc.function == rhs_sc.function && - lhs_sc.function != NULL && lhs_sc.block != NULL && - rhs_sc.function != NULL && rhs_sc.block != NULL) + lhs_sc.function != nullptr && lhs_sc.block != nullptr && + rhs_sc.function != nullptr && rhs_sc.block != nullptr) { return rhs_sc.block->Contains (lhs_sc.block); } diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp index e88b6467f7c6..a7b1b8eeeb27 100644 --- a/lldb/source/Target/StopInfo.cpp +++ b/lldb/source/Target/StopInfo.cpp @@ -228,7 +228,7 @@ public: break; } } - return all_internal == false; + return !all_internal; } } return true; @@ -254,7 +254,7 @@ public: for (size_t idx = 0; idx < num_owners; idx++) { const char *kind = bp_site_sp->GetOwnerAtIndex(idx)->GetBreakpoint().GetBreakpointKind(); - if (kind != NULL) + if (kind != nullptr) { m_description.assign (kind); return kind; @@ -467,7 +467,7 @@ protected: // Next run the condition for the breakpoint. If that says we should stop, then we'll run // the callback for the breakpoint. If the callback says we shouldn't stop that will win. - if (bp_loc_sp->GetConditionText() != NULL) + if (bp_loc_sp->GetConditionText() != nullptr) { Error condition_error; bool condition_says_stop = bp_loc_sp->ConditionSaysStop(exe_ctx, condition_error); @@ -544,7 +544,6 @@ protected: } // We've figured out what this stop wants to do, so mark it as valid so we don't compute it again. m_should_stop_is_valid = true; - } else { @@ -733,7 +732,7 @@ protected: new_plan_sp->SetOkayToDiscard (false); new_plan_sp->SetPrivate (true); process->GetThreadList().SetSelectedThreadByID (thread_sp->GetID()); - process->ResumeSynchronous(NULL); + process->ResumeSynchronous(nullptr); process->GetThreadList().SetSelectedThreadByID (thread_sp->GetID()); thread_sp->SetStopInfo(stored_stop_info_sp); } @@ -769,7 +768,7 @@ protected: if (wp_sp->GetHitCount() <= wp_sp->GetIgnoreCount()) m_should_stop = false; - if (m_should_stop && wp_sp->GetConditionText() != NULL) + if (m_should_stop && wp_sp->GetConditionText() != nullptr) { // We need to make sure the user sees any parse errors in their condition, so we'll hook the // constructor errors up to the debugger's Async I/O. @@ -779,12 +778,12 @@ protected: expr_options.SetIgnoreBreakpoints(true); ValueObjectSP result_value_sp; Error error; - result_code = UserExpression::Evaluate (exe_ctx, - expr_options, - wp_sp->GetConditionText(), - NULL, - result_value_sp, - error); + result_code = UserExpression::Evaluate(exe_ctx, + expr_options, + wp_sp->GetConditionText(), + nullptr, + result_value_sp, + error); if (result_code == eExpressionCompleted) { @@ -951,7 +950,7 @@ public: ThreadSP thread_sp (m_thread_wp.lock()); if (thread_sp) { - if (thread_sp->GetProcess()->GetUnixSignals()->GetShouldSuppress(m_value) == false) + if (!thread_sp->GetProcess()->GetUnixSignals()->GetShouldSuppress(m_value)) thread_sp->SetResumeSignal(m_value); } } diff --git a/lldb/source/Target/SystemRuntime.cpp b/lldb/source/Target/SystemRuntime.cpp index c3fb9c8091fd..522b535039ff 100644 --- a/lldb/source/Target/SystemRuntime.cpp +++ b/lldb/source/Target/SystemRuntime.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Target/SystemRuntime.h" #include "lldb/Target/Process.h" @@ -18,17 +22,16 @@ using namespace lldb_private; SystemRuntime* SystemRuntime::FindPlugin (Process *process) { - SystemRuntimeCreateInstance create_callback = NULL; - for (uint32_t idx = 0; (create_callback = PluginManager::GetSystemRuntimeCreateCallbackAtIndex(idx)) != NULL; ++idx) + SystemRuntimeCreateInstance create_callback = nullptr; + for (uint32_t idx = 0; (create_callback = PluginManager::GetSystemRuntimeCreateCallbackAtIndex(idx)) != nullptr; ++idx) { std::unique_ptr instance_ap(create_callback(process)); - if (instance_ap.get()) + if (instance_ap) return instance_ap.release(); } - return NULL; + return nullptr; } - //---------------------------------------------------------------------- // SystemRuntime constructor //---------------------------------------------------------------------- @@ -38,12 +41,7 @@ SystemRuntime::SystemRuntime(Process *process) : { } -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -SystemRuntime::~SystemRuntime() -{ -} +SystemRuntime::~SystemRuntime() = default; void SystemRuntime::DidAttach () diff --git a/lldb/source/Target/UnixSignals.cpp b/lldb/source/Target/UnixSignals.cpp index 3edd424fa959..cf244ba8f7d3 100644 --- a/lldb/source/Target/UnixSignals.cpp +++ b/lldb/source/Target/UnixSignals.cpp @@ -7,15 +7,14 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Target/UnixSignals.h" // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/UnixSignals.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Host/StringConvert.h" - #include "Plugins/Process/Utility/FreeBSDSignals.h" #include "Plugins/Process/Utility/LinuxSignals.h" #include "Plugins/Process/Utility/MipsLinuxSignals.h" @@ -23,15 +22,12 @@ using namespace lldb_private; -UnixSignals::Signal::Signal -( - const char *name, - bool default_suppress, - bool default_stop, - bool default_notify, - const char *description, - const char *alias -) : +UnixSignals::Signal::Signal(const char *name, + bool default_suppress, + bool default_stop, + bool default_notify, + const char *description, + const char *alias) : m_name (name), m_alias (alias), m_description (), @@ -85,12 +81,7 @@ UnixSignals::UnixSignals(const UnixSignals &rhs) { } -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -UnixSignals::~UnixSignals () -{ -} +UnixSignals::~UnixSignals() = default; void UnixSignals::Reset () @@ -135,16 +126,13 @@ UnixSignals::Reset () } void -UnixSignals::AddSignal -( - int signo, - const char *name, - bool default_suppress, - bool default_stop, - bool default_notify, - const char *description, - const char *alias -) +UnixSignals::AddSignal(int signo, + const char *name, + bool default_suppress, + bool default_stop, + bool default_notify, + const char *description, + const char *alias) { Signal new_signal (name, default_suppress, default_stop, default_notify, description, alias); m_signals.insert (std::make_pair(signo, new_signal)); @@ -163,12 +151,11 @@ UnixSignals::GetSignalAsCString (int signo) const { collection::const_iterator pos = m_signals.find (signo); if (pos == m_signals.end()) - return NULL; + return nullptr; else return pos->second.m_name.GetCString (); } - bool UnixSignals::SignalIsValid (int32_t signo) const { @@ -232,17 +219,14 @@ UnixSignals::GetNextSignalNumber (int32_t current_signal) const } const char * -UnixSignals::GetSignalInfo -( - int32_t signo, - bool &should_suppress, - bool &should_stop, - bool &should_notify -) const +UnixSignals::GetSignalInfo(int32_t signo, + bool &should_suppress, + bool &should_stop, + bool &should_notify) const { collection::const_iterator pos = m_signals.find (signo); if (pos == m_signals.end()) - return NULL; + return nullptr; else { const Signal &signal = pos->second; diff --git a/lldb/source/Target/UnwindAssembly.cpp b/lldb/source/Target/UnwindAssembly.cpp index af7f86fe492a..3dc443599016 100644 --- a/lldb/source/Target/UnwindAssembly.cpp +++ b/lldb/source/Target/UnwindAssembly.cpp @@ -1,4 +1,4 @@ -//===-- UnwindAssembly.cpp ------------------------------*- C++ -*-===// +//===-- UnwindAssembly.cpp --------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginInterface.h" @@ -21,14 +25,14 @@ UnwindAssembly::FindPlugin (const ArchSpec &arch) UnwindAssemblyCreateInstance create_callback; for (uint32_t idx = 0; - (create_callback = PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(idx)) != NULL; + (create_callback = PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(idx)) != nullptr; ++idx) { UnwindAssemblySP assembly_profiler_ap (create_callback (arch)); - if (assembly_profiler_ap.get ()) + if (assembly_profiler_ap) return assembly_profiler_ap; } - return NULL; + return nullptr; } UnwindAssembly::UnwindAssembly (const ArchSpec &arch) : @@ -36,6 +40,4 @@ UnwindAssembly::UnwindAssembly (const ArchSpec &arch) : { } -UnwindAssembly::~UnwindAssembly () -{ -} +UnwindAssembly::~UnwindAssembly() = default;