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.

llvm-svn: 251733
This commit is contained in:
Eugene Zelenko
2015-10-31 01:22:59 +00:00
parent 2ef8822951
commit dbb0abbf47
9 changed files with 334 additions and 429 deletions

View File

@@ -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 &debugger_sp, const FileSpec& spec, Error& er
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 &debugger)
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 *command)
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 SBProcess &process, const SBEvent &event,
{
// 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 SBProcess &process, const SBEvent &event,
{
// 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 *arch_name, size_t arch_name_len)
return false;
}
bool
SBDebugger::SetDefaultArchitecture (const char *arch_name)
{
@@ -565,12 +550,11 @@ SBDebugger::SetDefaultArchitecture (const char *arch_name)
}
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::CreateTargetWithFileAndTargetTriple (const char *filename,
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 (const char *filename, const char *arch_
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 *filename)
{
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 &target)
return result;
}
SBTarget
SBDebugger::GetTargetAtIndex (uint32_t idx)
{
@@ -814,7 +799,7 @@ SBDebugger::FindTargetWithFileAndArch (const char *filename, const char *arch_na
{
// 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 (const ProcessSP &process_sp)
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 (const char *var_name, const char *debugger
}
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 *prompt)
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 (ScriptLanguage script_lang)
}
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 &description)
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 (const char *sysroot)
}
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 (SBTypeNameSpecifier type_name)
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 (SBTypeNameSpecifier type_name)
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 (SBTypeNameSpecifier type_name)
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 *channel, const char **categories)
{
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::LogOutputCallback log_callback, void *bato
return m_opaque_sp->SetLoggingCallback (log_callback, baton);
}
}