From 9a028519e8e759ecd5157fa8e7bdadae6da54651 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Thu, 9 Aug 2012 00:50:26 +0000 Subject: [PATCH] Removed explicit NULL checks for shared pointers and instead made us use implicit casts to bool. This generated a warning in C++11. llvm-svn: 161559 --- lldb/source/Commands/CommandObjectDisassemble.cpp | 2 +- lldb/source/Core/Debugger.cpp | 2 +- lldb/source/Expression/ClangExpressionDeclMap.cpp | 2 +- lldb/source/Expression/ClangExpressionParser.cpp | 2 +- lldb/source/Expression/ClangFunction.cpp | 2 +- lldb/source/Expression/ClangUserExpression.cpp | 2 +- lldb/source/Expression/IRInterpreter.cpp | 4 ++-- lldb/source/Interpreter/CommandInterpreter.cpp | 8 ++++---- .../DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp | 2 +- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 4 ++-- .../Plugins/Process/Utility/RegisterContextLLDB.cpp | 2 +- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 2 +- lldb/source/Target/Process.cpp | 2 +- lldb/source/Target/Thread.cpp | 2 +- lldb/source/Target/ThreadPlanCallFunction.cpp | 2 +- lldb/source/Target/ThreadPlanStepUntil.cpp | 2 +- 16 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 029fc2e28664..5247743f6add 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -245,7 +245,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) const char *plugin_name = m_options.GetPluginName (); DisassemblerSP disassembler = Disassembler::FindPlugin(m_options.arch, plugin_name); - if (disassembler == NULL) + if (!disassembler) { if (plugin_name) result.AppendErrorWithFormat ("Unable to find Disassembler plug-in named '%s' that supports the '%s' architecture.\n", diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 9cefaa30f14b..1220ef4f5adc 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -2327,7 +2327,7 @@ Debugger::EnableLog (const char *channel, const char **categories, const char *l Log::Callbacks log_callbacks; StreamSP log_stream_sp; - if (m_log_callback_stream_sp != NULL) + if (m_log_callback_stream_sp) { log_stream_sp = m_log_callback_stream_sp; // For now when using the callback mode you always get thread & timestamp. diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index e4c5a179439e..68467a708ea6 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -2657,7 +2657,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, err); // If we found a variable in scope, no need to pull up function names - if (err.Success() && var != NULL) + if (err.Success() && var) { AddOneVariable(context, var, valobj, current_id); context.m_found.variable = true; diff --git a/lldb/source/Expression/ClangExpressionParser.cpp b/lldb/source/Expression/ClangExpressionParser.cpp index 22fae9112b88..88e7323e3a67 100644 --- a/lldb/source/Expression/ClangExpressionParser.cpp +++ b/lldb/source/Expression/ClangExpressionParser.cpp @@ -756,7 +756,7 @@ ClangExpressionParser::DisassembleFunction (Stream &stream, ExecutionContext &ex lldb::DisassemblerSP disassembler = Disassembler::FindPlugin(arch, NULL); - if (disassembler == NULL) + if (!disassembler) { ret.SetErrorToGenericError(); ret.SetErrorStringWithFormat("Unable to find disassembler plug-in for %s architecture.", arch.GetArchitectureName()); diff --git a/lldb/source/Expression/ClangFunction.cpp b/lldb/source/Expression/ClangFunction.cpp index f716f6731dbb..ad6f0db1f61d 100644 --- a/lldb/source/Expression/ClangFunction.cpp +++ b/lldb/source/Expression/ClangFunction.cpp @@ -499,7 +499,7 @@ ClangFunction::ExecuteFunction ( stop_others, discard_on_error, this_arg)); - if (call_plan_sp == NULL) + if (!call_plan_sp) return eExecutionSetupError; call_plan_sp->SetPrivate(true); diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp index 029b1539529d..b1bef73415d3 100644 --- a/lldb/source/Expression/ClangUserExpression.cpp +++ b/lldb/source/Expression/ClangUserExpression.cpp @@ -572,7 +572,7 @@ ClangUserExpression::Execute (Stream &error_stream, ((m_needs_object_ptr && m_objectivec) ? &cmd_ptr : NULL), shared_ptr_to_me)); - if (call_plan_sp == NULL || !call_plan_sp->ValidatePlan (NULL)) + if (!call_plan_sp || !call_plan_sp->ValidatePlan (NULL)) return eExecutionSetupError; lldb::addr_t function_stack_pointer = static_cast(call_plan_sp.get())->GetFunctionStackPointer(); diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp index 8ff34cf6f990..5d2c09724f7e 100644 --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -159,12 +159,12 @@ public: bool IsValid () { - return m_allocation != NULL; + return m_allocation; } bool IsInvalid () { - return m_allocation == NULL; + return !m_allocation; } }; diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 9c6f722d7ef5..a7c63e7ea647 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -464,7 +464,7 @@ CommandInterpreter::GetCommandSP (const char *cmd_cstr, bool include_aliases, bo ret_val = pos->second; } - if (!exact && ret_val == NULL) + if (!exact && !ret_val) { // We will only get into here if we didn't find any exact matches. @@ -534,7 +534,7 @@ CommandInterpreter::GetCommandSP (const char *cmd_cstr, bool include_aliases, bo return user_match_sp; } } - else if (matches && ret_val != NULL) + else if (matches && ret_val) { matches->AppendString (cmd_cstr); } @@ -762,7 +762,7 @@ CommandInterpreter::GetAliasHelp (const char *alias_name, const char *command_na help_string.Printf ("'%s", command_name); OptionArgVectorSP option_arg_vector_sp = GetAliasOptions (alias_name); - if (option_arg_vector_sp != NULL) + if (option_arg_vector_sp) { OptionArgVector *options = option_arg_vector_sp.get(); for (int i = 0; i < options->size(); ++i) @@ -1936,7 +1936,7 @@ CommandInterpreter::CrossRegisterCommand (const char * dest_cmd, const char * ob { CommandObjectSP cmd_obj_sp = GetCommandSPExact (dest_cmd, true); - if (cmd_obj_sp != NULL) + if (cmd_obj_sp) { CommandObject *cmd_obj = cmd_obj_sp.get(); if (cmd_obj->IsCrossRefObject ()) diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp index 3fd2c2d1e128..5c1bfc107585 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -582,7 +582,7 @@ DynamicLoaderMacOSXDYLD::NotifyBreakpointHit (void *baton, ExecutionContext exe_ctx (context->exe_ctx_ref); Process *process = exe_ctx.GetProcessPtr(); const lldb::ABISP &abi = process->GetABI(); - if (abi != NULL) + if (abi) { // Build up the value array to store the three arguments given above, then get the values from the ABI: diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index cd0f10f9ee55..3e2d76551455 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1133,7 +1133,7 @@ public: { SectionSP section_sp (m_section_list->FindSectionByID (n_sect)); m_section_infos[n_sect].section_sp = section_sp; - if (section_sp != NULL) + if (section_sp) { m_section_infos[n_sect].vm_range.SetBaseAddress (section_sp->GetFileAddress()); m_section_infos[n_sect].vm_range.SetByteSize (section_sp->GetByteSize()); @@ -2716,7 +2716,7 @@ struct lldb_copy_dyld_cache_local_symbols_entry { symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); - if (symbol_section == NULL) + if (!symbol_section) { // TODO: warn about this? add_nlist = false; diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp index e8633358e28a..7c35a4ff97dc 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -256,7 +256,7 @@ RegisterContextLLDB::InitializeNonZerothFrame() m_frame_type = eNotAValidFrame; return; } - if (m_thread.GetRegisterContext() == NULL) + if (!m_thread.GetRegisterContext()) { m_frame_type = eNotAValidFrame; return; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 8882c9187bce..d0def9535ce9 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1012,7 +1012,7 @@ ParseDWARFLineTableCallback(dw_offset_t offset, const DWARFDebugLine::State& sta // this address is resolved. If they are the same, then the // function for this address didn't make it into the final // executable. - bool curr_in_final_executable = info->curr_section_sp->GetLinkedSection () != NULL; + bool curr_in_final_executable = info->curr_section_sp->GetLinkedSection (); // If we are doing DWARF with debug map, then we need to carefully // add each line table entry as there may be gaps as functions diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 03f40f0f8c70..57cc3ea1bb03 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -4515,7 +4515,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx, StopPrivateStateThread(); Error error; m_private_state_thread = backup_private_state_thread; - if (stopper_base_plan_sp != NULL) + if (stopper_base_plan_sp) { thread->DiscardThreadPlansUpToPlan(stopper_base_plan_sp); } diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index cbd751367f77..dc8d133c1001 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -136,7 +136,7 @@ Thread::SetStopInfoToNothing() bool Thread::ThreadStoppedForAReason (void) { - return GetPrivateStopReason () != NULL; + return GetPrivateStopReason (); } bool diff --git a/lldb/source/Target/ThreadPlanCallFunction.cpp b/lldb/source/Target/ThreadPlanCallFunction.cpp index 3ab2a56f2868..c7ee7996b0ac 100644 --- a/lldb/source/Target/ThreadPlanCallFunction.cpp +++ b/lldb/source/Target/ThreadPlanCallFunction.cpp @@ -398,7 +398,7 @@ ThreadPlanCallFunction::PlanExplainsStop () // If we want to discard the plan, then we say we explain the stop // but if we are going to be discarded, let whoever is above us // explain the stop. - if (m_subplan_sp != NULL) + if (m_subplan_sp) { if (m_discard_on_error) { diff --git a/lldb/source/Target/ThreadPlanStepUntil.cpp b/lldb/source/Target/ThreadPlanStepUntil.cpp index ae0047af9910..b48c5f169991 100644 --- a/lldb/source/Target/ThreadPlanStepUntil.cpp +++ b/lldb/source/Target/ThreadPlanStepUntil.cpp @@ -317,7 +317,7 @@ ThreadPlanStepUntil::ShouldStop (Event *event_ptr) // we will stop. StopInfoSP stop_info_sp = GetPrivateStopReason(); - if (stop_info_sp == NULL || stop_info_sp->GetStopReason() == eStopReasonNone) + if (!stop_info_sp || stop_info_sp->GetStopReason() == eStopReasonNone) return false; AnalyzeStop();