Fix Clang-tidy modernize-use-nullptr warnings in include/lldb/Interpreter; other minor fixes.

Differential Revision: http://reviews.llvm.org/D14025

llvm-svn: 251162
This commit is contained in:
Eugene Zelenko 2015-10-24 00:20:14 +00:00
parent 79c4ee4d98
commit fe4ae5e7a4
11 changed files with 101 additions and 124 deletions

View File

@ -265,8 +265,8 @@ public:
bool include_aliases);
CommandObject *
GetCommandObject (const char *cmd,
StringList *matches = NULL);
GetCommandObject(const char *cmd,
StringList *matches = nullptr);
bool
CommandExists (const char *cmd);
@ -322,12 +322,12 @@ public:
CommandReturnObject &result);
bool
HandleCommand (const char *command_line,
LazyBool add_to_history,
CommandReturnObject &result,
ExecutionContext *override_context = NULL,
bool repeat_on_empty_command = true,
bool no_context_switching = false);
HandleCommand(const char *command_line,
LazyBool add_to_history,
CommandReturnObject &result,
ExecutionContext *override_context = nullptr,
bool repeat_on_empty_command = true,
bool no_context_switching = false);
//------------------------------------------------------------------
/// Execute a list of commands in sequence.
@ -335,7 +335,7 @@ public:
/// @param[in] commands
/// The list of commands to execute.
/// @param[in,out] context
/// The execution context in which to run the commands. Can be NULL in which case the default
/// The execution context in which to run the commands. Can be nullptr in which case the default
/// context will be used.
/// @param[in] options
/// This object holds the options used to control when to stop, whether to execute commands,
@ -356,7 +356,7 @@ public:
/// @param[in] file
/// The file from which to read in commands.
/// @param[in,out] context
/// The execution context in which to run the commands. Can be NULL in which case the default
/// The execution context in which to run the commands. Can be nullptr in which case the default
/// context will be used.
/// @param[in] options
/// This object holds the options used to control when to stop, whether to execute commands,
@ -643,7 +643,7 @@ public:
}
lldb::IOHandlerSP
GetIOHandler(bool force_create = false, CommandInterpreterRunOptions *options = NULL);
GetIOHandler(bool force_create = false, CommandInterpreterRunOptions *options = nullptr);
bool
GetStoppedForCrash () const
@ -682,7 +682,7 @@ protected:
SetSynchronous (bool value);
lldb::CommandObjectSP
GetCommandSP (const char *cmd, bool include_aliases = true, bool exact = true, StringList *matches = NULL);
GetCommandSP(const char *cmd, bool include_aliases = true, bool exact = true, StringList *matches = nullptr);
private:
Error

View File

@ -46,7 +46,7 @@ public:
explicit operator bool() const
{
return (help_callback != NULL);
return (help_callback != nullptr);
}
};
@ -77,11 +77,11 @@ public:
typedef std::map<std::string, lldb::CommandObjectSP> CommandMap;
CommandObject (CommandInterpreter &interpreter,
const char *name,
const char *help = NULL,
const char *syntax = NULL,
uint32_t flags = 0);
CommandObject(CommandInterpreter &interpreter,
const char *name,
const char *help = nullptr,
const char *syntax = nullptr,
uint32_t flags = 0);
virtual
~CommandObject ();
@ -141,15 +141,15 @@ public:
IsMultiwordObject () { return false; }
virtual lldb::CommandObjectSP
GetSubcommandSP (const char *sub_cmd, StringList *matches = NULL)
GetSubcommandSP(const char *sub_cmd, StringList *matches = nullptr)
{
return lldb::CommandObjectSP();
}
virtual CommandObject *
GetSubcommandObject (const char *sub_cmd, StringList *matches = NULL)
GetSubcommandObject(const char *sub_cmd, StringList *matches = nullptr)
{
return NULL;
return nullptr;
}
virtual void
@ -373,13 +373,13 @@ public:
/// The complete current command line.
///
/// @return
/// NULL if there is no special repeat command - it will use the current command line.
/// nullptr if there is no special repeat command - it will use the current command line.
/// Otherwise a pointer to the command to be repeated.
/// If the returned string is the empty string, the command won't be repeated.
//------------------------------------------------------------------
virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
{
return NULL;
return nullptr;
}
bool
@ -492,11 +492,11 @@ protected:
class CommandObjectParsed : public CommandObject
{
public:
CommandObjectParsed (CommandInterpreter &interpreter,
const char *name,
const char *help = NULL,
const char *syntax = NULL,
uint32_t flags = 0) :
CommandObjectParsed(CommandInterpreter &interpreter,
const char *name,
const char *help = nullptr,
const char *syntax = nullptr,
uint32_t flags = 0) :
CommandObject (interpreter, name, help, syntax, flags) {}
~CommandObjectParsed() override = default;
@ -519,11 +519,11 @@ protected:
class CommandObjectRaw : public CommandObject
{
public:
CommandObjectRaw (CommandInterpreter &interpreter,
const char *name,
const char *help = NULL,
const char *syntax = NULL,
uint32_t flags = 0) :
CommandObjectRaw(CommandInterpreter &interpreter,
const char *name,
const char *help = nullptr,
const char *syntax = nullptr,
uint32_t flags = 0) :
CommandObject (interpreter, name, help, syntax, flags) {}
~CommandObjectRaw() override = default;

View File

@ -28,11 +28,11 @@ class CommandObjectMultiword : public CommandObject
friend class CommandInterpreter;
friend class CommandObjectSyntax;
public:
CommandObjectMultiword (CommandInterpreter &interpreter,
const char *name,
const char *help = NULL,
const char *syntax = NULL,
uint32_t flags = 0);
CommandObjectMultiword(CommandInterpreter &interpreter,
const char *name,
const char *help = nullptr,
const char *syntax = nullptr,
uint32_t flags = 0);
~CommandObjectMultiword() override;
@ -50,10 +50,10 @@ public:
GenerateHelpText(Stream &output_stream) override;
lldb::CommandObjectSP
GetSubcommandSP(const char *sub_cmd, StringList *matches = NULL) override;
GetSubcommandSP(const char *sub_cmd, StringList *matches = nullptr) override;
CommandObject *
GetSubcommandObject(const char *sub_cmd, StringList *matches = NULL) override;
GetSubcommandObject(const char *sub_cmd, StringList *matches = nullptr) override;
void
AproposAllSubCommands(const char *prefix,
@ -104,11 +104,11 @@ protected:
class CommandObjectProxy : public CommandObject
{
public:
CommandObjectProxy (CommandInterpreter &interpreter,
const char *name,
const char *help = NULL,
const char *syntax = NULL,
uint32_t flags = 0);
CommandObjectProxy(CommandInterpreter &interpreter,
const char *name,
const char *help = nullptr,
const char *syntax = nullptr,
uint32_t flags = 0);
~CommandObjectProxy() override;
@ -127,10 +127,10 @@ public:
IsMultiwordObject() override;
lldb::CommandObjectSP
GetSubcommandSP(const char *sub_cmd, StringList *matches = NULL) override;
GetSubcommandSP(const char *sub_cmd, StringList *matches = nullptr) override;
CommandObject *
GetSubcommandObject(const char *sub_cmd, StringList *matches = NULL) override;
GetSubcommandObject(const char *sub_cmd, StringList *matches = nullptr) override;
void
AproposAllSubCommands(const char *prefix,

View File

@ -22,11 +22,9 @@
namespace lldb_private {
class CommandReturnObject
{
public:
CommandReturnObject ();
~CommandReturnObject ();
@ -142,8 +140,8 @@ public:
AppendErrorWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
void
SetError (const Error &error,
const char *fallback_error_cstr = NULL);
SetError(const Error &error,
const char *fallback_error_cstr = nullptr);
void
SetError (const char *error_cstr);
@ -189,4 +187,4 @@ private:
} // namespace lldb_private
#endif // liblldb_CommandReturnObject_h_
#endif // liblldb_CommandReturnObject_h_

View File

@ -26,7 +26,6 @@ namespace lldb_private {
class OptionGroupArchitecture : public OptionGroup
{
public:
OptionGroupArchitecture ();
~OptionGroupArchitecture() override;
@ -55,15 +54,12 @@ public:
}
const char *
GetArchitectureName ()
GetArchitectureName()
{
if (m_arch_str.empty())
return NULL;
return m_arch_str.c_str();
return (m_arch_str.empty() ? nullptr : m_arch_str.c_str());
}
protected:
std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture
};

View File

@ -1,4 +1,4 @@
//===-- OptionValue.h --------------------------------------*- C++ -*-===//
//===-- OptionValue.h -------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -61,7 +61,6 @@ namespace lldb_private {
eDumpGroupHelp = (eDumpOptionName | eDumpOptionType | eDumpOptionDescription)
};
OptionValue () :
m_callback (nullptr),
m_baton(nullptr),
@ -76,9 +75,8 @@ namespace lldb_private {
{
}
virtual ~OptionValue ()
{
}
virtual ~OptionValue() = default;
//-----------------------------------------------------------------
// Subclasses should override these functions
//-----------------------------------------------------------------
@ -99,7 +97,6 @@ namespace lldb_private {
return GetBuiltinTypeAsCString(GetType());
}
static const char *
GetBuiltinTypeAsCString (Type t);
@ -156,6 +153,7 @@ namespace lldb_private {
virtual bool
DumpQualifiedName (Stream &strm) const;
//-----------------------------------------------------------------
// Subclasses should NOT override these functions as they use the
// above functions to implement functionality
@ -376,7 +374,7 @@ namespace lldb_private {
SetSInt64Value (int64_t new_value);
const char *
GetStringValue (const char *fail_value = NULL) const;
GetStringValue(const char *fail_value = nullptr) const;
bool
SetStringValue (const char *new_value);
@ -415,7 +413,7 @@ namespace lldb_private {
SetValueChangedCallback (OptionValueChangedCallback callback,
void *baton)
{
assert (m_callback == NULL);
assert (m_callback == nullptr);
m_callback = callback;
m_baton = baton;
}
@ -426,6 +424,7 @@ namespace lldb_private {
if (m_callback)
m_callback (m_baton, this);
}
protected:
lldb::OptionValueWP m_parent_wp;
OptionValueChangedCallback m_callback;
@ -436,9 +435,8 @@ namespace lldb_private {
// the command line or as a setting, versus if we
// just have the default value that was already
// populated in the option value.
};
} // namespace lldb_private
#endif // liblldb_OptionValue_h_
#endif // liblldb_OptionValue_h_

View File

@ -1,4 +1,4 @@
//===-- OptionValueProperties.h --------------------------------------*- C++ -*-===//
//===-- OptionValueProperties.h ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -12,6 +12,8 @@
// C Includes
// C++ Includes
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ConstString.h"
@ -27,10 +29,6 @@ class OptionValueProperties :
public std::enable_shared_from_this<OptionValueProperties>
{
public:
//---------------------------------------------------------------------
// OptionValueProperties
//---------------------------------------------------------------------
OptionValueProperties () :
OptionValue(),
m_name (),
@ -42,11 +40,9 @@ public:
OptionValueProperties (const ConstString &name);
OptionValueProperties (const OptionValueProperties &global_properties);
~OptionValueProperties() override
{
}
~OptionValueProperties() override = default;
Type
GetType() const override
{
@ -256,21 +252,16 @@ public:
void *baton);
protected:
Property *
ProtectedGetPropertyAtIndex (uint32_t idx)
ProtectedGetPropertyAtIndex(uint32_t idx)
{
if (idx < m_properties.size())
return &m_properties[idx];
return NULL;
return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
}
const Property *
ProtectedGetPropertyAtIndex (uint32_t idx) const
ProtectedGetPropertyAtIndex(uint32_t idx) const
{
if (idx < m_properties.size())
return &m_properties[idx];
return NULL;
return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
}
typedef UniqueCStringMap<size_t> NameToIndex;

View File

@ -12,8 +12,6 @@
// C Includes
// C++ Includes
#include <string>
// Other libraries and framework includes
// Project includes
#include "lldb/Core/RegularExpression.h"
@ -24,16 +22,14 @@ namespace lldb_private {
class OptionValueRegex : public OptionValue
{
public:
OptionValueRegex (const char *value = NULL) :
OptionValueRegex(const char *value = nullptr) :
OptionValue(),
m_regex (value)
{
}
~OptionValueRegex() override
{
}
~OptionValueRegex() override = default;
//---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------
@ -68,9 +64,7 @@ public:
const RegularExpression *
GetCurrentValue() const
{
if (m_regex.IsValid())
return &m_regex;
return NULL;
return (m_regex.IsValid() ? &m_regex : nullptr);
}
void

View File

@ -1,4 +1,4 @@
//===-- OptionValueString.h --------------------------------------*- C++ -*-===//
//===-- OptionValueString.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -24,7 +24,6 @@ namespace lldb_private {
class OptionValueString : public OptionValue
{
public:
typedef Error (*ValidatorCallback) (const char* string,
void* baton);
@ -43,8 +42,8 @@ public:
{
}
OptionValueString (ValidatorCallback validator,
void* baton = NULL) :
OptionValueString(ValidatorCallback validator,
void* baton = nullptr) :
OptionValue(),
m_current_value (),
m_default_value (),
@ -84,9 +83,9 @@ public:
m_default_value.assign (default_value);
}
OptionValueString (const char *value,
ValidatorCallback validator,
void* baton = NULL) :
OptionValueString(const char *value,
ValidatorCallback validator,
void* baton = nullptr) :
OptionValue(),
m_current_value (),
m_default_value (),
@ -101,10 +100,10 @@ public:
}
}
OptionValueString (const char *current_value,
const char *default_value,
ValidatorCallback validator,
void* baton = NULL) :
OptionValueString(const char *current_value,
const char *default_value,
ValidatorCallback validator,
void* baton = nullptr) :
OptionValue(),
m_current_value (),
m_default_value (),
@ -118,10 +117,8 @@ public:
m_default_value.assign (default_value);
}
~OptionValueString() override
{
}
~OptionValueString() override = default;
//---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
//---------------------------------------------------------------------

View File

@ -70,7 +70,7 @@ namespace lldb_private {
/// case 'g': debug = true; break;
/// case 'v': verbose = true; break;
/// case 'l': log_file = option_arg; break;
/// case 'f': log_flags = strtoull(option_arg, NULL, 0); break;
/// case 'f': log_flags = strtoull(option_arg, nullptr, 0); break;
/// default:
/// error.SetErrorStringWithFormat("unrecognized short option %c", option_val);
/// break;
@ -93,11 +93,11 @@ namespace lldb_private {
///
/// struct option CommandOptions::g_options[] =
/// {
/// { "debug", no_argument, NULL, 'g' },
/// { "log-file", required_argument, NULL, 'l' },
/// { "log-flags", required_argument, NULL, 'f' },
/// { "verbose", no_argument, NULL, 'v' },
/// { NULL, 0, NULL, 0 }
/// { "debug", no_argument, nullptr, 'g' },
/// { "log-file", required_argument, nullptr, 'l' },
/// { "log-flags", required_argument, nullptr, 'f' },
/// { "verbose", no_argument, nullptr, 'v' },
/// { nullptr, 0, nullptr, 0 }
/// };
///
/// int main (int argc, const char **argv, const char **envp)
@ -169,7 +169,10 @@ public:
// class that inherits from this class.
virtual const OptionDefinition*
GetDefinitions () { return NULL; }
GetDefinitions()
{
return nullptr;
}
// Call this prior to parsing any options. This call will call the
// subclass OptionParsingStarting() and will avoid the need for all
@ -191,7 +194,7 @@ public:
///
/// @param[in] option_arg
/// The argument value for the option that the user entered, or
/// NULL if there is no argument for the current option.
/// nullptr if there is no argument for the current option.
///
///
/// @see Args::ParseOptions (Options&)

View File

@ -173,13 +173,13 @@ public:
}
virtual bool
GenerateTypeScriptFunction (const char* oneliner, std::string& output, const void* name_token = NULL)
GenerateTypeScriptFunction(const char* oneliner, std::string& output, const void* name_token = nullptr)
{
return false;
}
virtual bool
GenerateTypeScriptFunction (StringList &input, std::string& output, const void* name_token = NULL)
GenerateTypeScriptFunction(StringList &input, std::string& output, const void* name_token = nullptr)
{
return false;
}
@ -191,13 +191,13 @@ public:
}
virtual bool
GenerateTypeSynthClass (StringList &input, std::string& output, const void* name_token = NULL)
GenerateTypeSynthClass(StringList &input, std::string& output, const void* name_token = nullptr)
{
return false;
}
virtual bool
GenerateTypeSynthClass (const char* oneliner, std::string& output, const void* name_token = NULL)
GenerateTypeSynthClass(const char* oneliner, std::string& output, const void* name_token = nullptr)
{
return false;
}