Author: eugenezelenko Date: Fri Oct 30 20:22:59 2015 New Revision: 251733 URL: http://llvm.org/viewvc/llvm-project?rev=251733&view=rev Log: Fix Clang-tidy modernize-use-nullptr warnings in include/lldb/API and source/API; other minor fixes.
Other fixes should reduce number of readability-redundant-smartptr-get and readability-implicit-bool-cast. Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h lldb/trunk/include/lldb/API/SBCommandReturnObject.h lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/API/SBCommandReturnObject.cpp lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBFrame.cpp Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=251733&r1=251732&r2=251733&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original) +++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Fri Oct 30 20:22:59 2015 @@ -10,6 +10,12 @@ #ifndef LLDB_SBCommandInterpreter_h_ #define LLDB_SBCommandInterpreter_h_ +// C Includes +// C++ Includes +#include <memory> + +// Other libraries and framework includes +// Project includes #include "lldb/API/SBDefines.h" #include "lldb/API/SBDebugger.h" @@ -59,6 +65,7 @@ public: void SetAddToHistory (bool); + private: lldb_private::CommandInterpreterRunOptions * get () const; @@ -84,11 +91,11 @@ public: SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs); + ~SBCommandInterpreter (); + const lldb::SBCommandInterpreter & operator = (const lldb::SBCommandInterpreter &rhs); - ~SBCommandInterpreter (); - static const char * GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); @@ -187,7 +194,7 @@ public: lldb::CommandOverrideCallback callback, void *baton); - SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter(); + SBCommandInterpreter(lldb_private::CommandInterpreter *interpreter_ptr = nullptr); // Access using SBDebugger::GetCommandInterpreter(); //---------------------------------------------------------------------- /// Return true if the command interpreter is the active IO handler. @@ -213,7 +220,7 @@ public: /// /// @return /// The string that should be written into the file handle that is - /// feeding the input stream for the debugger, or NULL if there is + /// feeding the input stream for the debugger, or nullptr if there is /// no string for this control key. //---------------------------------------------------------------------- const char * @@ -233,7 +240,6 @@ public: ResolveCommand(const char *command_line, SBCommandReturnObject &result); protected: - lldb_private::CommandInterpreter & ref (); @@ -242,6 +248,7 @@ protected: void reset (lldb_private::CommandInterpreter *); + private: friend class SBDebugger; @@ -254,6 +261,9 @@ private: class SBCommandPluginInterface { public: + virtual + ~SBCommandPluginInterface() = default; + virtual bool DoExecute (lldb::SBDebugger /*debugger*/, char** /*command*/, @@ -261,16 +271,11 @@ public: { return false; } - - virtual - ~SBCommandPluginInterface () - {} }; class SBCommand { public: - SBCommand (); bool @@ -298,13 +303,12 @@ public: SetFlags (uint32_t flags); lldb::SBCommand - AddMultiwordCommand (const char* name, const char* help = NULL); + AddMultiwordCommand(const char* name, const char* help = nullptr); lldb::SBCommand - AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help = NULL); + AddCommand(const char* name, lldb::SBCommandPluginInterface* impl, const char* help = nullptr); private: - friend class SBDebugger; friend class SBCommandInterpreter; Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=251733&r1=251732&r2=251733&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original) +++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Fri Oct 30 20:22:59 2015 @@ -10,8 +10,14 @@ #ifndef LLDB_SBCommandReturnObject_h_ #define LLDB_SBCommandReturnObject_h_ +// C Includes #include <stdio.h> +// C++ Includes +#include <memory> + +// Other libraries and framework includes +// Project includes #include "lldb/API/SBDefines.h" namespace lldb { @@ -19,22 +25,20 @@ namespace lldb { class LLDB_API SBCommandReturnObject { public: - SBCommandReturnObject (); SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs); + ~SBCommandReturnObject (); + const lldb::SBCommandReturnObject & operator = (const lldb::SBCommandReturnObject &rhs); - SBCommandReturnObject (lldb_private::CommandReturnObject *ptr); lldb_private::CommandReturnObject * Release (); - ~SBCommandReturnObject (); - bool IsValid() const; @@ -99,8 +103,8 @@ public: GetError (bool only_if_no_immediate); void - SetError (lldb::SBError &error, - const char *fallback_error_cstr = NULL); + SetError(lldb::SBError &error, + const char *fallback_error_cstr = nullptr); void SetError (const char* error_cstr); @@ -124,10 +128,10 @@ protected: void SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr); - private: +private: std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_ap; }; } // namespace lldb -#endif // LLDB_SBCommandReturnObject_h_ +#endif // LLDB_SBCommandReturnObject_h_ Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=251733&r1=251732&r2=251733&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Fri Oct 30 20:22:59 2015 @@ -16,13 +16,13 @@ #include "lldb/API/SBPlatform.h" namespace lldb { - class LLDB_API SBInputReader { public: - SBInputReader(); - ~SBInputReader(); + SBInputReader() = default; + ~SBInputReader() = default; + SBError Initialize(lldb::SBDebugger&, unsigned long (*)(void*, lldb::SBInputReader*, lldb::InputReaderAction, char const*, unsigned long), void*, lldb::InputReaderGranularity, char const*, char const*, bool); void SetIsDone(bool); bool IsActive() const; @@ -31,6 +31,16 @@ public: class LLDB_API SBDebugger { public: + SBDebugger(); + + SBDebugger(const lldb::SBDebugger &rhs); + + SBDebugger(const lldb::DebuggerSP &debugger_sp); + + ~SBDebugger(); + + lldb::SBDebugger & + operator = (const lldb::SBDebugger &rhs); static void Initialize(); @@ -54,17 +64,6 @@ public: static void MemoryPressureDetected (); - SBDebugger(); - - SBDebugger(const lldb::SBDebugger &rhs); - - SBDebugger(const lldb::DebuggerSP &debugger_sp); - - lldb::SBDebugger & - operator = (const lldb::SBDebugger &rhs); - - ~SBDebugger(); - bool IsValid() const; @@ -332,8 +331,8 @@ public: SBError RunREPL (lldb::LanguageType language, const char *repl_options); -private: +private: friend class SBCommandInterpreter; friend class SBInputReader; friend class SBListener; @@ -360,7 +359,6 @@ private: }; // class SBDebugger - } // namespace lldb #endif // LLDB_SBDebugger_h_ Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=251733&r1=251732&r2=251733&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Fri Oct 30 20:22:59 2015 @@ -10,6 +10,10 @@ #ifndef LLDB_SBTarget_h_ #define LLDB_SBTarget_h_ +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/API/SBDefines.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBAttachInfo.h" @@ -50,14 +54,14 @@ public: SBTarget (const lldb::TargetSP& target_sp); - const lldb::SBTarget& - operator = (const lldb::SBTarget& rhs); - //------------------------------------------------------------------ // Destructor //------------------------------------------------------------------ ~SBTarget(); + const lldb::SBTarget& + operator = (const lldb::SBTarget& rhs); + bool IsValid() const; @@ -135,17 +139,17 @@ public: /// /// @param[in] stdin_path /// The path to use when re-directing the STDIN of the new - /// process. If all stdXX_path arguments are NULL, a pseudo + /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// /// @param[in] stdout_path /// The path to use when re-directing the STDOUT of the new - /// process. If all stdXX_path arguments are NULL, a pseudo + /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// /// @param[in] stderr_path /// The path to use when re-directing the STDERR of the new - /// process. If all stdXX_path arguments are NULL, a pseudo + /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// /// @param[in] working_directory @@ -175,8 +179,7 @@ public: uint32_t launch_flags, // See LaunchFlags bool stop_at_entry, lldb::SBError& error); - - + //------------------------------------------------------------------ /// Launch a new process with sensible defaults. /// @@ -248,6 +251,7 @@ public: ::pid_t pid, // 32 bit int process ID lldb::SBError& error); // DEPRECATED #endif + //------------------------------------------------------------------ /// Attach to process with name. /// @@ -288,7 +292,7 @@ public: /// The url to connect to, e.g., 'connect://localhost:12345'. /// /// @param[in] plugin_name - /// The plugin name to be used; can be NULL. + /// The plugin name to be used; can be nullptr. /// /// @param[out] error /// An error explaining what went wrong if the connect fails. @@ -421,7 +425,6 @@ public: lldb::SBError SetModuleLoadAddress (lldb::SBModule module, int64_t sections_offset); - //------------------------------------------------------------------ /// Clear the section base load addresses for all sections in a module. @@ -618,7 +621,7 @@ public: BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); lldb::SBBreakpoint - BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); + BreakpointCreateByName(const char *symbol_name, const char *module_name = nullptr); // This version uses name_type_mask = eFunctionNameTypeAuto lldb::SBBreakpoint @@ -640,7 +643,7 @@ public: const SBFileSpecList &comp_unit_list); lldb::SBBreakpoint - BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); + BreakpointCreateByRegex(const char *symbol_name_regex, const char *module_name = nullptr); lldb::SBBreakpoint BreakpointCreateByRegex (const char *symbol_name_regex, @@ -648,9 +651,9 @@ public: const SBFileSpecList &comp_unit_list); lldb::SBBreakpoint - BreakpointCreateBySourceRegex (const char *source_regex, - const SBFileSpec &source_file, - const char *module_name = NULL); + BreakpointCreateBySourceRegex(const char *source_regex, + const SBFileSpec &source_file, + const char *module_name = nullptr); lldb::SBBreakpoint BreakpointCreateBySourceRegex (const char *source_regex, @@ -808,15 +811,10 @@ protected: void SetSP (const lldb::TargetSP& target_sp); - private: - //------------------------------------------------------------------ - // For Target only - //------------------------------------------------------------------ - lldb::TargetSP m_opaque_sp; }; } // namespace lldb -#endif // LLDB_SBTarget_h_ +#endif // LLDB_SBTarget_h_ Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=251733&r1=251732&r2=251733&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Fri Oct 30 20:22:59 2015 @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBDebugger.h" @@ -32,7 +36,6 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" - #include "lldb/lldb-enumerations.h" using namespace lldb; @@ -47,7 +50,6 @@ struct CallbackData class SBBreakpointCallbackBaton : public Baton { public: - SBBreakpointCallbackBaton (SBBreakpoint::BreakpointHitCallback callback, void *baton) : Baton (new CallbackData) { @@ -56,19 +58,18 @@ public: data->callback_baton = baton; } - virtual ~SBBreakpointCallbackBaton() + ~SBBreakpointCallbackBaton() override { CallbackData *data = (CallbackData *)m_data; if (data) { delete data; - m_data = NULL; + m_data = nullptr; } } }; - SBBreakpoint::SBBreakpoint () : m_opaque_sp () { @@ -79,15 +80,12 @@ SBBreakpoint::SBBreakpoint (const SBBrea { } - SBBreakpoint::SBBreakpoint (const lldb::BreakpointSP &bp_sp) : m_opaque_sp (bp_sp) { } -SBBreakpoint::~SBBreakpoint() -{ -} +SBBreakpoint::~SBBreakpoint() = default; const SBBreakpoint & SBBreakpoint::operator = (const SBBreakpoint& rhs) @@ -135,7 +133,6 @@ SBBreakpoint::GetID () const return break_id; } - bool SBBreakpoint::IsValid() const { @@ -169,7 +166,7 @@ SBBreakpoint::FindLocationByAddress (add Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); Address address; Target &target = m_opaque_sp->GetTarget(); - if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) + if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) { address.SetRawAddress (vm_addr); } @@ -189,7 +186,7 @@ SBBreakpoint::FindLocationIDByAddress (a Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); Address address; Target &target = m_opaque_sp->GetTarget(); - if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) + if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) { address.SetRawAddress (vm_addr); } @@ -329,7 +326,7 @@ SBBreakpoint::GetCondition () Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetConditionText (); } - return NULL; + return nullptr; } uint32_t @@ -380,7 +377,6 @@ SBBreakpoint::SetThreadID (tid_t tid) if (log) log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")", static_cast<void*>(m_opaque_sp.get()), tid); - } tid_t @@ -422,7 +418,7 @@ SBBreakpoint::GetThreadIndex() const { Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); - if (thread_spec != NULL) + if (thread_spec != nullptr) thread_idx = thread_spec->GetIndex(); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -451,12 +447,12 @@ SBBreakpoint::SetThreadName (const char const char * SBBreakpoint::GetThreadName () const { - const char *name = NULL; + const char *name = nullptr; if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); - if (thread_spec != NULL) + if (thread_spec != nullptr) name = thread_spec->GetName(); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -484,7 +480,7 @@ SBBreakpoint::SetQueueName (const char * const char * SBBreakpoint::GetQueueName () const { - const char *name = NULL; + const char *name = nullptr; if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); @@ -552,13 +548,10 @@ SBBreakpoint::GetDescription (SBStream & } bool -SBBreakpoint::PrivateBreakpointHitCallback -( - void *baton, - StoppointCallbackContext *ctx, - lldb::user_id_t break_id, - lldb::user_id_t break_loc_id -) +SBBreakpoint::PrivateBreakpointHitCallback(void *baton, + StoppointCallbackContext *ctx, + lldb::user_id_t break_id, + lldb::user_id_t break_loc_id) { ExecutionContext exe_ctx (ctx->exe_ctx_ref); BreakpointSP bp_sp(exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id)); @@ -758,8 +751,7 @@ SBBreakpoint::operator *() const bool SBBreakpoint::EventIsBreakpointEvent (const lldb::SBEvent &event) { - return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != NULL; - + return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != nullptr; } BreakpointEventType @@ -796,5 +788,3 @@ SBBreakpoint::GetNumBreakpointLocationsF num_locations = (Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent (event.GetSP())); return num_locations; } - - Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=251733&r1=251732&r2=251733&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Fri Oct 30 20:22:59 2015 @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/lldb-types.h" #include "lldb/Core/Listener.h" @@ -34,10 +38,7 @@ SBCommandInterpreterRunOptions::SBComman m_opaque_up.reset(new CommandInterpreterRunOptions()); } -SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() -{ - -} +SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default; bool SBCommandInterpreterRunOptions::GetStopOnContinue () const @@ -126,21 +127,24 @@ SBCommandInterpreterRunOptions::ref () c class CommandPluginInterfaceImplementation : public CommandObjectParsed { public: - CommandPluginInterfaceImplementation (CommandInterpreter &interpreter, - const char *name, - lldb::SBCommandPluginInterface* backend, - const char *help = NULL, - const char *syntax = NULL, - uint32_t flags = 0) : + CommandPluginInterfaceImplementation(CommandInterpreter &interpreter, + const char *name, + lldb::SBCommandPluginInterface* backend, + const char *help = nullptr, + const char *syntax = nullptr, + uint32_t flags = 0) : CommandObjectParsed (interpreter, name, help, syntax, flags), m_backend(backend) {} - virtual bool - IsRemovable() const { return true; } + bool + IsRemovable() const override + { + return true; + } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute(Args& command, CommandReturnObject &result) override { SBCommandReturnObject sb_return(&result); SBCommandInterpreter sb_interpreter(&m_interpreter); @@ -169,6 +173,8 @@ SBCommandInterpreter::SBCommandInterpret { } +SBCommandInterpreter::~SBCommandInterpreter() = default; + const SBCommandInterpreter & SBCommandInterpreter::operator = (const SBCommandInterpreter &rhs) { @@ -176,47 +182,34 @@ SBCommandInterpreter::operator = (const return *this; } -SBCommandInterpreter::~SBCommandInterpreter () -{ -} - bool SBCommandInterpreter::IsValid() const { - return m_opaque_ptr != NULL; + return m_opaque_ptr != nullptr; } - bool -SBCommandInterpreter::CommandExists (const char *cmd) +SBCommandInterpreter::CommandExists(const char *cmd) { - if (cmd && m_opaque_ptr) - return m_opaque_ptr->CommandExists (cmd); - return false; + return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->CommandExists(cmd) : false); } bool SBCommandInterpreter::AliasExists (const char *cmd) { - if (cmd && m_opaque_ptr) - return m_opaque_ptr->AliasExists (cmd); - return false; + return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->AliasExists(cmd) : false); } bool -SBCommandInterpreter::IsActive () +SBCommandInterpreter::IsActive() { - if (m_opaque_ptr) - return m_opaque_ptr->IsActive (); - return false; + return (IsValid() ? m_opaque_ptr->IsActive() : false); } const char * SBCommandInterpreter::GetIOHandlerControlSequence(char ch) { - if (m_opaque_ptr) - return m_opaque_ptr->GetDebugger().GetTopIOHandlerControlSequence (ch).GetCString(); - return NULL; + return (IsValid() ? m_opaque_ptr->GetDebugger().GetTopIOHandlerControlSequence(ch).GetCString() : nullptr); } lldb::ReturnStatus @@ -247,7 +240,7 @@ SBCommandInterpreter::HandleCommand (con result.Clear(); - if (command_line && m_opaque_ptr) + if (command_line && IsValid()) { result.ref().SetInteractive(false); m_opaque_ptr->HandleCommand (command_line, add_to_history ? eLazyBoolYes : eLazyBoolNo, result.ref(), ctx_ptr); @@ -290,7 +283,7 @@ SBCommandInterpreter::HandleCommandsFrom static_cast<void*>(result.get())); } - if (!m_opaque_ptr) + if (!IsValid()) { result->AppendError ("SBCommandInterpreter is not valid."); result->SetStatus (eReturnStatusFailed); @@ -315,12 +308,9 @@ SBCommandInterpreter::HandleCommandsFrom else ctx_ptr = nullptr; - m_opaque_ptr->HandleCommandsFromFile (tmp_spec, ctx_ptr, options.ref(), result.ref()); - } - int SBCommandInterpreter::HandleCompletion (const char *current_line, const char *cursor, @@ -334,7 +324,7 @@ SBCommandInterpreter::HandleCompletion ( // Sanity check the arguments that are passed in: // cursor & last_char have to be within the current_line. - if (current_line == NULL || cursor == NULL || last_char == NULL) + if (current_line == nullptr || cursor == nullptr || last_char == nullptr) return 0; if (cursor < current_line || last_char < current_line) @@ -352,11 +342,11 @@ SBCommandInterpreter::HandleCompletion ( static_cast<uint64_t>(last_char - current_line), match_start_point, max_return_elements); - if (m_opaque_ptr) + if (IsValid()) { lldb_private::StringList lldb_matches; - num_completions = m_opaque_ptr->HandleCompletion (current_line, cursor, last_char, match_start_point, - max_return_elements, lldb_matches); + num_completions = m_opaque_ptr->HandleCompletion(current_line, cursor, last_char, match_start_point, + max_return_elements, lldb_matches); SBStringList temp_list (&lldb_matches); matches.AppendList (temp_list); @@ -381,27 +371,21 @@ SBCommandInterpreter::HandleCompletion ( } bool -SBCommandInterpreter::HasCommands () +SBCommandInterpreter::HasCommands() { - if (m_opaque_ptr) - return m_opaque_ptr->HasCommands(); - return false; + return (IsValid() ? m_opaque_ptr->HasCommands() : false); } bool -SBCommandInterpreter::HasAliases () +SBCommandInterpreter::HasAliases() { - if (m_opaque_ptr) - return m_opaque_ptr->HasAliases(); - return false; + return (IsValid() ? m_opaque_ptr->HasAliases() : false); } bool -SBCommandInterpreter::HasAliasOptions () +SBCommandInterpreter::HasAliasOptions() { - if (m_opaque_ptr) - return m_opaque_ptr->HasAliasOptions (); - return false; + return (IsValid() ? m_opaque_ptr->HasAliasOptions() : false); } SBProcess @@ -409,7 +393,7 @@ SBCommandInterpreter::GetProcess () { SBProcess sb_process; ProcessSP process_sp; - if (m_opaque_ptr) + if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); if (target_sp) @@ -433,7 +417,7 @@ SBDebugger SBCommandInterpreter::GetDebugger () { SBDebugger sb_debugger; - if (m_opaque_ptr) + if (IsValid()) sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this()); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -448,15 +432,13 @@ SBCommandInterpreter::GetDebugger () bool SBCommandInterpreter::GetPromptOnQuit() { - if (m_opaque_ptr) - return m_opaque_ptr->GetPromptOnQuit(); - return false; + return (IsValid() ? m_opaque_ptr->GetPromptOnQuit() : false); } void SBCommandInterpreter::SetPromptOnQuit (bool b) { - if (m_opaque_ptr) + if (IsValid()) m_opaque_ptr->SetPromptOnQuit(b); } @@ -464,7 +446,7 @@ void SBCommandInterpreter::ResolveCommand(const char *command_line, SBCommandReturnObject &result) { result.Clear(); - if (command_line && m_opaque_ptr) + if (command_line && IsValid()) { m_opaque_ptr->ResolveCommand(command_line, result.ref()); } @@ -475,7 +457,6 @@ SBCommandInterpreter::ResolveCommand(con } } - CommandInterpreter * SBCommandInterpreter::get () { @@ -499,7 +480,7 @@ void SBCommandInterpreter::SourceInitFileInHomeDirectory (SBCommandReturnObject &result) { result.Clear(); - if (m_opaque_ptr) + if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); Mutex::Locker api_locker; @@ -524,7 +505,7 @@ void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnObject &result) { result.Clear(); - if (m_opaque_ptr) + if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); Mutex::Locker api_locker; @@ -588,7 +569,7 @@ SBCommandInterpreter::SetCommandOverride lldb::CommandOverrideCallback callback, void *baton) { - if (command_name && command_name[0] && m_opaque_ptr) + if (command_name && command_name[0] && IsValid()) { std::string command_name_str (command_name); CommandObject *cmd_obj = m_opaque_ptr->GetCommandObjectForCommand(command_name_str); @@ -605,7 +586,7 @@ SBCommandInterpreter::SetCommandOverride lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand (const char* name, const char* help) { - CommandObjectMultiword *new_command = new CommandObjectMultiword(*m_opaque_ptr,name,help); + CommandObjectMultiword *new_command = new CommandObjectMultiword(*m_opaque_ptr, name, help); new_command->SetRemovable (true); lldb::CommandObjectSP new_command_sp(new_command); if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) @@ -617,47 +598,40 @@ lldb::SBCommand SBCommandInterpreter::AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help) { lldb::CommandObjectSP new_command_sp; - new_command_sp.reset(new CommandPluginInterfaceImplementation(*m_opaque_ptr,name,impl,help)); + new_command_sp.reset(new CommandPluginInterfaceImplementation(*m_opaque_ptr,name, impl, help)); if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) return lldb::SBCommand(new_command_sp); return lldb::SBCommand(); } -SBCommand::SBCommand () -{} +SBCommand::SBCommand() = default; SBCommand::SBCommand (lldb::CommandObjectSP cmd_sp) : m_opaque_sp (cmd_sp) {} bool -SBCommand::IsValid () +SBCommand::IsValid() { - return (bool)m_opaque_sp; + return m_opaque_sp.get() != nullptr; } const char* -SBCommand::GetName () +SBCommand::GetName() { - if (IsValid ()) - return m_opaque_sp->GetCommandName (); - return NULL; + return (IsValid() ? m_opaque_sp->GetCommandName() : nullptr); } const char* -SBCommand::GetHelp () +SBCommand::GetHelp() { - if (IsValid ()) - return m_opaque_sp->GetHelp (); - return NULL; + return (IsValid() ? m_opaque_sp->GetHelp() : nullptr); } const char* -SBCommand::GetHelpLong () +SBCommand::GetHelpLong() { - if (IsValid ()) - return m_opaque_sp->GetHelpLong (); - return NULL; + return (IsValid() ? m_opaque_sp->GetHelpLong() : nullptr); } void @@ -679,7 +653,7 @@ SBCommand::AddMultiwordCommand (const ch { if (!IsValid ()) return lldb::SBCommand(); - if (m_opaque_sp->IsMultiwordObject() == false) + if (!m_opaque_sp->IsMultiwordObject()) return lldb::SBCommand(); CommandObjectMultiword *new_command = new CommandObjectMultiword(m_opaque_sp->GetCommandInterpreter(),name,help); new_command->SetRemovable (true); @@ -694,7 +668,7 @@ SBCommand::AddCommand (const char* name, { if (!IsValid ()) return lldb::SBCommand(); - if (m_opaque_sp->IsMultiwordObject() == false) + if (!m_opaque_sp->IsMultiwordObject()) return lldb::SBCommand(); lldb::CommandObjectSP new_command_sp; new_command_sp.reset(new CommandPluginInterfaceImplementation(m_opaque_sp->GetCommandInterpreter(),name,impl,help)); @@ -706,9 +680,7 @@ SBCommand::AddCommand (const char* name, uint32_t SBCommand::GetFlags () { - if (!IsValid()) - return 0; - return m_opaque_sp->GetFlags().Get(); + return (IsValid() ? m_opaque_sp->GetFlags().Get() : 0); } void Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=251733&r1=251732&r2=251733&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandReturnObject.cpp (original) +++ lldb/trunk/source/API/SBCommandReturnObject.cpp Fri Oct 30 20:22:59 2015 @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/API/SBCommandReturnObject.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" @@ -26,7 +30,7 @@ SBCommandReturnObject::SBCommandReturnOb SBCommandReturnObject::SBCommandReturnObject (const SBCommandReturnObject &rhs): m_opaque_ap () { - if (rhs.m_opaque_ap.get()) + if (rhs.m_opaque_ap) m_opaque_ap.reset (new CommandReturnObject (*rhs.m_opaque_ap)); } @@ -35,6 +39,8 @@ SBCommandReturnObject::SBCommandReturnOb { } +SBCommandReturnObject::~SBCommandReturnObject() = default; + CommandReturnObject * SBCommandReturnObject::Release () { @@ -46,7 +52,7 @@ SBCommandReturnObject::operator = (const { if (this != &rhs) { - if (rhs.m_opaque_ap.get()) + if (rhs.m_opaque_ap) m_opaque_ap.reset (new CommandReturnObject (*rhs.m_opaque_ap)); else m_opaque_ap.reset(); @@ -54,25 +60,18 @@ SBCommandReturnObject::operator = (const return *this; } - -SBCommandReturnObject::~SBCommandReturnObject () -{ - // m_opaque_ap will automatically delete any pointer it owns -} - bool SBCommandReturnObject::IsValid() const { - return m_opaque_ap.get() != NULL; + return m_opaque_ap.get() != nullptr; } - const char * SBCommandReturnObject::GetOutput () { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - if (m_opaque_ap.get()) + if (m_opaque_ap) { if (log) log->Printf ("SBCommandReturnObject(%p)::GetOutput () => \"%s\"", @@ -83,10 +82,10 @@ SBCommandReturnObject::GetOutput () } if (log) - log->Printf ("SBCommandReturnObject(%p)::GetOutput () => NULL", + log->Printf ("SBCommandReturnObject(%p)::GetOutput () => nullptr", static_cast<void*>(m_opaque_ap.get())); - return NULL; + return nullptr; } const char * @@ -94,7 +93,7 @@ SBCommandReturnObject::GetError () { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - if (m_opaque_ap.get()) + if (m_opaque_ap) { if (log) log->Printf ("SBCommandReturnObject(%p)::GetError () => \"%s\"", @@ -105,26 +104,22 @@ SBCommandReturnObject::GetError () } if (log) - log->Printf ("SBCommandReturnObject(%p)::GetError () => NULL", + log->Printf ("SBCommandReturnObject(%p)::GetError () => nullptr", static_cast<void*>(m_opaque_ap.get())); - return NULL; + return nullptr; } size_t -SBCommandReturnObject::GetOutputSize () +SBCommandReturnObject::GetOutputSize() { - if (m_opaque_ap.get()) - return strlen (m_opaque_ap->GetOutputData()); - return 0; + return (m_opaque_ap ? strlen(m_opaque_ap->GetOutputData()) : 0); } size_t -SBCommandReturnObject::GetErrorSize () +SBCommandReturnObject::GetErrorSize() { - if (m_opaque_ap.get()) - return strlen(m_opaque_ap->GetErrorData()); - return 0; + return (m_opaque_ap ? strlen(m_opaque_ap->GetErrorData()) : 0); } size_t @@ -154,52 +149,46 @@ SBCommandReturnObject::PutError (FILE *f void SBCommandReturnObject::Clear() { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->Clear(); } lldb::ReturnStatus SBCommandReturnObject::GetStatus() { - if (m_opaque_ap.get()) - return m_opaque_ap->GetStatus(); - return lldb::eReturnStatusInvalid; + return (m_opaque_ap ? m_opaque_ap->GetStatus() : lldb::eReturnStatusInvalid); } void SBCommandReturnObject::SetStatus(lldb::ReturnStatus status) { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->SetStatus(status); } bool -SBCommandReturnObject::Succeeded () +SBCommandReturnObject::Succeeded() { - if (m_opaque_ap.get()) - return m_opaque_ap->Succeeded(); - return false; + return (m_opaque_ap ? m_opaque_ap->Succeeded() : false); } bool -SBCommandReturnObject::HasResult () +SBCommandReturnObject::HasResult() { - if (m_opaque_ap.get()) - return m_opaque_ap->HasResult(); - return false; + return (m_opaque_ap ? m_opaque_ap->HasResult() : false); } void SBCommandReturnObject::AppendMessage (const char *message) { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->AppendMessage (message); } void SBCommandReturnObject::AppendWarning (const char *message) { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->AppendWarning (message); } @@ -222,7 +211,6 @@ SBCommandReturnObject::operator *() cons return *(m_opaque_ap.get()); } - CommandReturnObject & SBCommandReturnObject::ref() const { @@ -230,11 +218,10 @@ SBCommandReturnObject::ref() const return *(m_opaque_ap.get()); } - void SBCommandReturnObject::SetLLDBObjectPtr (CommandReturnObject *ptr) { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap.reset (ptr); } @@ -243,7 +230,7 @@ SBCommandReturnObject::GetDescription (S { Stream &strm = description.ref(); - if (m_opaque_ap.get()) + if (m_opaque_ap) { description.Printf ("Status: "); lldb::ReturnStatus status = m_opaque_ap->GetStatus(); @@ -269,25 +256,25 @@ SBCommandReturnObject::GetDescription (S } void -SBCommandReturnObject::SetImmediateOutputFile (FILE *fh) +SBCommandReturnObject::SetImmediateOutputFile(FILE *fh) { - if (m_opaque_ap.get()) - m_opaque_ap->SetImmediateOutputFile (fh); + if (m_opaque_ap) + m_opaque_ap->SetImmediateOutputFile(fh); } void -SBCommandReturnObject::SetImmediateErrorFile (FILE *fh) +SBCommandReturnObject::SetImmediateErrorFile(FILE *fh) { - if (m_opaque_ap.get()) - m_opaque_ap->SetImmediateErrorFile (fh); + if (m_opaque_ap) + m_opaque_ap->SetImmediateErrorFile(fh); } void SBCommandReturnObject::PutCString(const char* string, int len) { - if (m_opaque_ap.get()) + if (m_opaque_ap) { - if (len == 0 || string == NULL || *string == 0) + if (len == 0 || string == nullptr || *string == 0) { return; } @@ -304,27 +291,27 @@ SBCommandReturnObject::PutCString(const const char * SBCommandReturnObject::GetOutput (bool only_if_no_immediate) { - if (!m_opaque_ap.get()) - return NULL; - if (only_if_no_immediate == false || m_opaque_ap->GetImmediateOutputStream().get() == NULL) + if (!m_opaque_ap) + return nullptr; + if (!only_if_no_immediate || m_opaque_ap->GetImmediateOutputStream().get() == nullptr) return GetOutput(); - return NULL; + return nullptr; } const char * SBCommandReturnObject::GetError (bool only_if_no_immediate) { - if (!m_opaque_ap.get()) - return NULL; - if (only_if_no_immediate == false || m_opaque_ap->GetImmediateErrorStream().get() == NULL) + if (!m_opaque_ap) + return nullptr; + if (!only_if_no_immediate || m_opaque_ap->GetImmediateErrorStream().get() == nullptr) return GetError(); - return NULL; + return nullptr; } size_t SBCommandReturnObject::Printf(const char* format, ...) { - if (m_opaque_ap.get()) + if (m_opaque_ap) { va_list args; va_start (args, format); @@ -338,7 +325,7 @@ SBCommandReturnObject::Printf(const char void SBCommandReturnObject::SetError (lldb::SBError &error, const char *fallback_error_cstr) { - if (m_opaque_ap.get()) + if (m_opaque_ap) { if (error.IsValid()) m_opaque_ap->SetError(error.ref(), fallback_error_cstr); @@ -350,7 +337,6 @@ SBCommandReturnObject::SetError (lldb::S void SBCommandReturnObject::SetError (const char *error_cstr) { - if (m_opaque_ap.get() && error_cstr) + if (m_opaque_ap && error_cstr) m_opaque_ap->SetError(error_cstr); } - Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=251733&r1=251732&r2=251733&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Fri Oct 30 20:22:59 2015 @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/API/SBDebugger.h" #include "lldb/lldb-private.h" @@ -50,7 +54,6 @@ using namespace lldb; using namespace lldb_private; - static llvm::sys::DynamicLibrary LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& error) { @@ -87,13 +90,6 @@ LoadPlugin (const lldb::DebuggerSP &debu static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime; -SBInputReader::SBInputReader() -{ -} -SBInputReader::~SBInputReader() -{ -} - SBError SBInputReader::Initialize(lldb::SBDebugger &sb_debugger, unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction, char const *, @@ -107,12 +103,37 @@ void SBInputReader::SetIsDone(bool) { } + bool SBInputReader::IsActive() const { return false; } +SBDebugger::SBDebugger() = default; + +SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) : + m_opaque_sp(debugger_sp) +{ +} + +SBDebugger::SBDebugger(const SBDebugger &rhs) : + m_opaque_sp (rhs.m_opaque_sp) +{ +} + +SBDebugger::~SBDebugger() = default; + +SBDebugger & +SBDebugger::operator = (const SBDebugger &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + void SBDebugger::Initialize () { @@ -148,13 +169,13 @@ SBDebugger::Clear () SBDebugger SBDebugger::Create() { - return SBDebugger::Create(false, NULL, NULL); + return SBDebugger::Create(false, nullptr, nullptr); } SBDebugger SBDebugger::Create(bool source_init_files) { - return SBDebugger::Create (source_init_files, NULL, NULL); + return SBDebugger::Create (source_init_files, nullptr, nullptr); } SBDebugger @@ -216,7 +237,7 @@ SBDebugger::Destroy (SBDebugger &debugge Debugger::Destroy (debugger.m_opaque_sp); - if (debugger.m_opaque_sp.get() != NULL) + if (debugger.m_opaque_sp.get() != nullptr) debugger.m_opaque_sp.reset(); } @@ -238,42 +259,12 @@ SBDebugger::MemoryPressureDetected () ModuleList::RemoveOrphanSharedModules(mandatory); } -SBDebugger::SBDebugger () : - m_opaque_sp () -{ -} - -SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) : - m_opaque_sp(debugger_sp) -{ -} - -SBDebugger::SBDebugger(const SBDebugger &rhs) : - m_opaque_sp (rhs.m_opaque_sp) -{ -} - -SBDebugger & -SBDebugger::operator = (const SBDebugger &rhs) -{ - if (this != &rhs) - { - m_opaque_sp = rhs.m_opaque_sp; - } - return *this; -} - -SBDebugger::~SBDebugger () -{ -} - bool SBDebugger::IsValid() const { - return m_opaque_sp.get() != NULL; + return m_opaque_sp.get() != nullptr; } - void SBDebugger::SetAsync (bool b) { @@ -282,12 +273,9 @@ SBDebugger::SetAsync (bool b) } bool -SBDebugger::GetAsync () +SBDebugger::GetAsync() { - if (m_opaque_sp) - return m_opaque_sp->GetAsyncExecution(); - else - return false; + return (m_opaque_sp ? m_opaque_sp->GetAsyncExecution() : false); } void @@ -359,7 +347,7 @@ SBDebugger::GetInputFileHandle () if (stream_file_sp) return stream_file_sp->GetFile().GetStream(); } - return NULL; + return nullptr; } FILE * @@ -371,20 +359,19 @@ SBDebugger::GetOutputFileHandle () if (stream_file_sp) return stream_file_sp->GetFile().GetStream(); } - return NULL; + return nullptr; } FILE * SBDebugger::GetErrorFileHandle () { if (m_opaque_sp) - if (m_opaque_sp) - { - StreamFileSP stream_file_sp (m_opaque_sp->GetErrorFile()); - if (stream_file_sp) - return stream_file_sp->GetFile().GetStream(); - } - return NULL; + { + StreamFileSP stream_file_sp(m_opaque_sp->GetErrorFile()); + if (stream_file_sp) + return stream_file_sp->GetFile().GetStream(); + } + return nullptr; } void @@ -433,12 +420,12 @@ SBDebugger::HandleCommand (const char *c sb_interpreter.HandleCommand (command, result, false); - if (GetErrorFileHandle() != NULL) + if (GetErrorFileHandle() != nullptr) result.PutError (GetErrorFileHandle()); - if (GetOutputFileHandle() != NULL) + if (GetOutputFileHandle() != nullptr) result.PutOutput (GetOutputFileHandle()); - if (m_opaque_sp->GetAsyncExecution() == false) + if (!m_opaque_sp->GetAsyncExecution()) { SBProcess process(GetCommandInterpreter().GetProcess ()); ProcessSP process_sp (process.GetSP()); @@ -493,7 +480,7 @@ SBDebugger::HandleProcessEvent (const SB { // Drain stdout when we stop just in case we have any bytes while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0) - if (out != NULL) + if (out != nullptr) ::fwrite (stdio_buffer, 1, len, out); } @@ -501,7 +488,7 @@ SBDebugger::HandleProcessEvent (const SB { // Drain stderr when we stop just in case we have any bytes while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0) - if (err != NULL) + if (err != nullptr) ::fwrite (stdio_buffer, 1, len, err); } @@ -525,7 +512,6 @@ SBDebugger::GetSourceManager () return sb_source_manager; } - bool SBDebugger::GetDefaultArchitecture (char *arch_name, size_t arch_name_len) { @@ -548,7 +534,6 @@ SBDebugger::GetDefaultArchitecture (char return false; } - bool SBDebugger::SetDefaultArchitecture (const char *arch_name) { @@ -565,12 +550,11 @@ SBDebugger::SetDefaultArchitecture (cons } ScriptLanguage -SBDebugger::GetScriptingLanguage (const char *script_language_name) +SBDebugger::GetScriptingLanguage(const char *script_language_name) { - - return Args::StringToScriptLanguage (script_language_name, - eScriptLanguageDefault, - NULL); + return Args::StringToScriptLanguage(script_language_name, + eScriptLanguageDefault, + nullptr); } const char * @@ -660,12 +644,12 @@ SBDebugger::CreateTargetWithFileAndTarge if (m_opaque_sp) { const bool add_dependent_modules = true; - Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, - filename, - target_triple, - add_dependent_modules, - NULL, - target_sp)); + Error error (m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, + filename, + target_triple, + add_dependent_modules, + nullptr, + target_sp)); sb_target.SetSP (target_sp); } @@ -690,12 +674,12 @@ SBDebugger::CreateTargetWithFileAndArch Error error; const bool add_dependent_modules = true; - error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, - filename, - arch_cstr, - add_dependent_modules, - NULL, - target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, + filename, + arch_cstr, + add_dependent_modules, + nullptr, + target_sp); if (error.Success()) { @@ -721,12 +705,12 @@ SBDebugger::CreateTarget (const char *fi { Error error; const bool add_dependent_modules = true; - error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, - filename, - NULL, - add_dependent_modules, - NULL, - target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, + filename, + nullptr, + add_dependent_modules, + nullptr, + target_sp); if (error.Success()) { @@ -768,6 +752,7 @@ SBDebugger::DeleteTarget (lldb::SBTarget return result; } + SBTarget SBDebugger::GetTargetAtIndex (uint32_t idx) { @@ -814,7 +799,7 @@ SBDebugger::FindTargetWithFileAndArch (c { // No need to lock, the target list is thread safe ArchSpec arch (arch_name, m_opaque_sp->GetPlatformList().GetSelectedPlatform().get()); - TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename, false), arch_name ? &arch : NULL)); + TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture(FileSpec(filename, false), arch_name ? &arch : nullptr)); sb_target.SetSP (target_sp); } return sb_target; @@ -832,7 +817,6 @@ SBDebugger::FindTargetWithLLDBProcess (c return sb_target; } - uint32_t SBDebugger::GetNumTargets () { @@ -1051,10 +1035,7 @@ SBDebugger::FindDebuggerWithID (int id) const char * SBDebugger::GetInstanceName() { - if (m_opaque_sp) - return m_opaque_sp->GetInstanceName().AsCString(); - else - return NULL; + return (m_opaque_sp ? m_opaque_sp->GetInstanceName().AsCString() : nullptr); } SBError @@ -1110,11 +1091,9 @@ SBDebugger::GetInternalVariableValue (co } uint32_t -SBDebugger::GetTerminalWidth () const +SBDebugger::GetTerminalWidth() const { - if (m_opaque_sp) - return m_opaque_sp->GetTerminalWidth (); - return 0; + return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0); } void @@ -1134,9 +1113,7 @@ SBDebugger::GetPrompt() const static_cast<void*>(m_opaque_sp.get()), (m_opaque_sp ? m_opaque_sp->GetPrompt() : "")); - if (m_opaque_sp) - return m_opaque_sp->GetPrompt (); - return 0; + return (m_opaque_sp ? m_opaque_sp->GetPrompt() : nullptr); } void @@ -1145,14 +1122,11 @@ SBDebugger::SetPrompt (const char *promp if (m_opaque_sp) m_opaque_sp->SetPrompt (prompt); } - ScriptLanguage SBDebugger::GetScriptLanguage() const { - if (m_opaque_sp) - return m_opaque_sp->GetScriptLanguage (); - return eScriptLanguageNone; + return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone); } void @@ -1165,35 +1139,27 @@ SBDebugger::SetScriptLanguage (ScriptLan } bool -SBDebugger::SetUseExternalEditor (bool value) +SBDebugger::SetUseExternalEditor(bool value) { - if (m_opaque_sp) - return m_opaque_sp->SetUseExternalEditor (value); - return false; + return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false); } bool -SBDebugger::GetUseExternalEditor () +SBDebugger::GetUseExternalEditor() { - if (m_opaque_sp) - return m_opaque_sp->GetUseExternalEditor (); - return false; + return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false); } bool -SBDebugger::SetUseColor (bool value) +SBDebugger::SetUseColor(bool value) { - if (m_opaque_sp) - return m_opaque_sp->SetUseColor (value); - return false; + return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false); } bool -SBDebugger::GetUseColor () const +SBDebugger::GetUseColor() const { - if (m_opaque_sp) - return m_opaque_sp->GetUseColor (); - return false; + return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false); } bool @@ -1216,12 +1182,9 @@ SBDebugger::GetDescription (SBStream &de user_id_t SBDebugger::GetID() { - if (m_opaque_sp) - return m_opaque_sp->GetID(); - return LLDB_INVALID_UID; + return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID); } - SBError SBDebugger::SetCurrentPlatform (const char *platform_name_cstr) { @@ -1279,11 +1242,9 @@ SBDebugger::SetCurrentPlatformSDKRoot (c } bool -SBDebugger::GetCloseInputOnEOF () const +SBDebugger::GetCloseInputOnEOF() const { - if (m_opaque_sp) - return m_opaque_sp->GetCloseInputOnEOF (); - return false; + return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false); } void @@ -1361,7 +1322,7 @@ SBDebugger::GetFormatForType (SBTypeName SBTypeSummary SBDebugger::GetSummaryForType (SBTypeNameSpecifier type_name) { - if (type_name.IsValid() == false) + if (!type_name.IsValid()) return SBTypeSummary(); return SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP())); } @@ -1370,7 +1331,7 @@ SBDebugger::GetSummaryForType (SBTypeNam SBTypeFilter SBDebugger::GetFilterForType (SBTypeNameSpecifier type_name) { - if (type_name.IsValid() == false) + if (!type_name.IsValid()) return SBTypeFilter(); return SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP())); } @@ -1379,7 +1340,7 @@ SBDebugger::GetFilterForType (SBTypeName SBTypeSynthetic SBDebugger::GetSyntheticForType (SBTypeNameSpecifier type_name) { - if (type_name.IsValid() == false) + if (!type_name.IsValid()) return SBTypeSynthetic(); return SBTypeSynthetic(DataVisualization::GetSyntheticForType(type_name.GetSP())); } @@ -1392,8 +1353,7 @@ SBDebugger::EnableLog (const char *chann { uint32_t log_options = LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME; StreamString errors; - return m_opaque_sp->EnableLog (channel, categories, NULL, log_options, errors); - + return m_opaque_sp->EnableLog(channel, categories, nullptr, log_options, errors); } else return false; @@ -1407,5 +1367,3 @@ SBDebugger::SetLoggingCallback (lldb::Lo return m_opaque_sp->SetLoggingCallback (log_callback, baton); } } - - Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=251733&r1=251732&r2=251733&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Fri Oct 30 20:22:59 2015 @@ -7,10 +7,14 @@ // //===----------------------------------------------------------------------===// -#include "lldb/API/SBFrame.h" - -#include <string> +// C Includes +// C++ Includes #include <algorithm> +#include <string> + +// Other libraries and framework includes +// Project includes +#include "lldb/API/SBFrame.h" #include "lldb/lldb-types.h" @@ -50,7 +54,6 @@ using namespace lldb; using namespace lldb_private; - SBFrame::SBFrame () : m_opaque_sp (new ExecutionContextRef()) { @@ -76,6 +79,8 @@ SBFrame::SBFrame(const SBFrame &rhs) : { } +SBFrame::~SBFrame() = default; + const SBFrame & SBFrame::operator = (const SBFrame &rhs) { @@ -84,16 +89,10 @@ SBFrame::operator = (const SBFrame &rhs) return *this; } -SBFrame::~SBFrame() -{ -} - StackFrameSP SBFrame::GetFrameSP() const { - if (m_opaque_sp) - return m_opaque_sp->GetFrameSP(); - return StackFrameSP(); + return (m_opaque_sp ? m_opaque_sp->GetFrameSP() : StackFrameSP()); } void @@ -105,7 +104,7 @@ SBFrame::SetFrameSP (const StackFrameSP bool SBFrame::IsValid() const { - return GetFrameSP().get() != NULL; + return GetFrameSP().get() != nullptr; } SBSymbolContext @@ -116,7 +115,7 @@ SBFrame::GetSymbolContext (uint32_t reso Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -159,7 +158,7 @@ SBFrame::GetModule () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -202,7 +201,7 @@ SBFrame::GetCompileUnit () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -243,7 +242,7 @@ SBFrame::GetFunction () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -284,7 +283,7 @@ SBFrame::GetSymbol () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -324,7 +323,7 @@ SBFrame::GetBlock () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -364,7 +363,7 @@ SBFrame::GetFrameBlock () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); Process *process = exe_ctx.GetProcessPtr(); @@ -405,7 +404,7 @@ SBFrame::GetLineEntry () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -464,7 +463,6 @@ SBFrame::GetCFA () const return LLDB_INVALID_ADDRESS; } - addr_t SBFrame::GetPC () const { @@ -473,7 +471,7 @@ SBFrame::GetPC () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -514,7 +512,7 @@ SBFrame::SetPC (addr_t new_pc) Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -555,7 +553,7 @@ SBFrame::GetSP () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -587,7 +585,6 @@ SBFrame::GetSP () const return addr; } - addr_t SBFrame::GetFP () const { @@ -596,7 +593,7 @@ SBFrame::GetFP () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -628,7 +625,6 @@ SBFrame::GetFP () const return addr; } - SBAddress SBFrame::GetPCAddress () const { @@ -696,7 +692,7 @@ SBFrame::GetValueForVariablePath (const SBValue sb_value; Mutex::Locker api_locker; Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - if (var_path == NULL || var_path[0] == '\0') + if (var_path == nullptr || var_path[0] == '\0') { if (log) log->Printf ("SBFrame::GetValueForVariablePath called with empty variable path."); @@ -705,7 +701,7 @@ SBFrame::GetValueForVariablePath (const ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -762,7 +758,7 @@ SBFrame::FindVariable (const char *name, VariableSP var_sp; SBValue sb_value; - if (name == NULL || name[0] == '\0') + if (name == nullptr || name[0] == '\0') { if (log) log->Printf ("SBFrame::FindVariable called with empty name"); @@ -773,7 +769,7 @@ SBFrame::FindVariable (const char *name, Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -850,7 +846,7 @@ SBFrame::FindValue (const char *name, Va Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBValue sb_value; - if (name == NULL || name[0] == '\0') + if (name == nullptr || name[0] == '\0') { if (log) log->Printf ("SBFrame::FindValue called with empty name."); @@ -861,7 +857,7 @@ SBFrame::FindValue (const char *name, Va Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1035,11 +1031,11 @@ const char * SBFrame::Disassemble () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - const char *disassembly = NULL; + const char *disassembly = nullptr; Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1072,7 +1068,6 @@ SBFrame::Disassemble () const return disassembly; } - SBValueList SBFrame::GetVariables (bool arguments, bool locals, @@ -1130,7 +1125,7 @@ SBFrame::GetVariables (const lldb::SBVar Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); const bool statics = options.GetIncludeStatics(); @@ -1156,7 +1151,7 @@ SBFrame::GetVariables (const lldb::SBVar if (frame) { size_t i; - VariableList *variable_list = NULL; + VariableList *variable_list = nullptr; variable_list = frame->GetVariableList(true); if (variable_list) { @@ -1194,9 +1189,9 @@ SBFrame::GetVariables (const lldb::SBVar ValueObjectSP valobj_sp(frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues)); - if (false == include_runtime_support_values && - valobj_sp && - true == valobj_sp->IsRuntimeSupportValue()) + if (!include_runtime_support_values && + valobj_sp != nullptr && + valobj_sp->IsRuntimeSupportValue()) continue; SBValue value_sb; @@ -1238,7 +1233,7 @@ SBFrame::GetRegisters () Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1290,7 +1285,7 @@ SBFrame::FindRegister (const char *name) Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1427,7 +1422,7 @@ SBFrame::EvaluateExpression (const char ExpressionResults exe_results = eExpressionSetupError; SBValue expr_result; - if (expr == NULL || expr[0] == '\0') + if (expr == nullptr || expr[0] == '\0') { if (log) log->Printf ("SBFrame::EvaluateExpression called with an empty expression"); @@ -1442,7 +1437,7 @@ SBFrame::EvaluateExpression (const char if (log) log->Printf ("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); @@ -1469,7 +1464,7 @@ SBFrame::EvaluateExpression (const char expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); if (target->GetDisplayExpressionsInCrashlogs()) - Host::SetCrashDescription (NULL); + Host::SetCrashDescription(nullptr); } else { @@ -1509,7 +1504,7 @@ SBFrame::IsInlined() const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); ExecutionContext exe_ctx(m_opaque_sp.get()); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1523,7 +1518,7 @@ SBFrame::IsInlined() const Block *block = frame->GetSymbolContext(eSymbolContextBlock).block; if (block) - return block->GetContainingInlinedBlock () != NULL; + return block->GetContainingInlinedBlock() != nullptr; } else { @@ -1551,9 +1546,9 @@ const char * SBFrame::GetFunctionName() const { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - const char *name = NULL; + const char *name = nullptr; ExecutionContext exe_ctx(m_opaque_sp.get()); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1575,13 +1570,13 @@ SBFrame::GetFunctionName() const } } - if (name == NULL) + if (name == nullptr) { if (sc.function) name = sc.function->GetName().GetCString(); } - if (name == NULL) + if (name == nullptr) { if (sc.symbol) name = sc.symbol->GetName().GetCString(); @@ -1607,9 +1602,9 @@ const char * SBFrame::GetDisplayFunctionName() { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - const char *name = NULL; + const char *name = nullptr; ExecutionContext exe_ctx(m_opaque_sp.get()); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1631,13 +1626,13 @@ SBFrame::GetDisplayFunctionName() } } - if (name == NULL) + if (name == nullptr) { if (sc.function) name = sc.function->GetDisplayName().GetCString(); } - if (name == NULL) + if (name == nullptr) { if (sc.symbol) name = sc.symbol->GetDisplayName().GetCString(); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits