Fix Clang-tidy modernize-use-override warnings in include/lldb/Expression, source/Expression and tools/lldb-mi; other minor fixes.

llvm-svn: 251730
This commit is contained in:
Eugene Zelenko
2015-10-31 00:43:59 +00:00
parent a174241cf1
commit adb5b1dfc2
7 changed files with 122 additions and 155 deletions

View File

@@ -7,10 +7,15 @@
//
//===----------------------------------------------------------------------===//
#ifndef lldb_REPL_h
#define lldb_REPL_h
// C Includes
// C++ Includes
#include <string>
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/OptionGroupFormat.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
#include "lldb/../../source/Commands/CommandObjectExpression.h"
@@ -35,7 +40,7 @@ public:
REPL(LLVMCastKind kind, Target &target);
virtual ~REPL();
~REPL() override;
//------------------------------------------------------------------
/// Get a REPL with an existing target (or, failing that, a debugger to use), and (optional) extra arguments for the compiler.
@@ -47,7 +52,7 @@ public:
/// The language to create a REPL for.
///
/// @param[in] debugger
/// If provided, and target is NULL, the debugger to use when setting up a top-level REPL.
/// If provided, and target is nullptr, the debugger to use when setting up a top-level REPL.
///
/// @param[in] target
/// If provided, the target to put the REPL inside.
@@ -139,10 +144,6 @@ public:
int max_matches,
StringList &matches) override;
private:
std::string
GetSourcePath();
protected:
static int
CalculateActualIndentation (const StringList &lines);
@@ -199,8 +200,12 @@ protected:
Target &m_target;
lldb::IOHandlerSP m_io_handler_sp;
LLVMCastKind m_kind;
private:
std::string
GetSourcePath();
};
}
} // namespace lldb_private
#endif /* REPL_h */
#endif // lldb_REPL_h

View File

@@ -1,4 +1,4 @@
//===-- IRDynamicChecks.cpp -------------------------------------------*- C++ -*-===//
//===-- IRDynamicChecks.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,6 +7,18 @@
//
//===----------------------------------------------------------------------===//
// C Includes
// C++ Includes
// Other libraries and framework includes
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Value.h"
// Project includes
#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Core/ConstString.h"
@@ -18,14 +30,6 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Value.h"
using namespace llvm;
using namespace lldb_private;
@@ -41,13 +45,9 @@ static const char g_valid_pointer_check_text[] =
" unsigned char $__lldb_local_val = *$__lldb_arg_ptr;\n"
"}";
DynamicCheckerFunctions::DynamicCheckerFunctions ()
{
}
DynamicCheckerFunctions::DynamicCheckerFunctions() = default;
DynamicCheckerFunctions::~DynamicCheckerFunctions ()
{
}
DynamicCheckerFunctions::~DynamicCheckerFunctions() = default;
bool
DynamicCheckerFunctions::Install(Stream &error_stream,
@@ -87,12 +87,12 @@ DynamicCheckerFunctions::DoCheckersExplainStop (lldb::addr_t addr, Stream &messa
{
// FIXME: We have to get the checkers to know why they scotched the call in more detail,
// so we can print a better message here.
if (m_valid_pointer_check.get() != NULL && m_valid_pointer_check->ContainsAddress(addr))
if (m_valid_pointer_check && m_valid_pointer_check->ContainsAddress(addr))
{
message.Printf ("Attempted to dereference an invalid pointer.");
return true;
}
else if (m_objc_object_check.get() != NULL && m_objc_object_check->ContainsAddress(addr))
else if (m_objc_object_check && m_objc_object_check->ContainsAddress(addr))
{
message.Printf ("Attempted to dereference an invalid ObjC Object or send it an unrecognized selector");
return true;
@@ -100,7 +100,6 @@ DynamicCheckerFunctions::DoCheckersExplainStop (lldb::addr_t addr, Stream &messa
return false;
}
static std::string
PrintValue(llvm::Value *V, bool truncate = false)
{
@@ -153,14 +152,12 @@ public:
DynamicCheckerFunctions &checker_functions) :
m_module(module),
m_checker_functions(checker_functions),
m_i8ptr_ty(NULL),
m_intptr_ty(NULL)
m_i8ptr_ty(nullptr),
m_intptr_ty(nullptr)
{
}
virtual~Instrumenter ()
{
}
virtual ~Instrumenter() = default;
//------------------------------------------------------------------
/// Inspect a function to find instructions to instrument
@@ -194,6 +191,7 @@ public:
return true;
}
protected:
//------------------------------------------------------------------
/// Add instrumentation to a single instruction
@@ -351,6 +349,7 @@ protected:
InstVector m_to_instrument; ///< List of instructions the inspector found
llvm::Module &m_module; ///< The module which is being instrumented
DynamicCheckerFunctions &m_checker_functions; ///< The dynamic checker functions for the process
private:
PointerType *m_i8ptr_ty;
IntegerType *m_intptr_ty;
@@ -362,15 +361,14 @@ public:
ValidPointerChecker (llvm::Module &module,
DynamicCheckerFunctions &checker_functions) :
Instrumenter(module, checker_functions),
m_valid_pointer_check_func(NULL)
m_valid_pointer_check_func(nullptr)
{
}
virtual ~ValidPointerChecker ()
{
}
private:
bool InstrumentInstruction(llvm::Instruction *inst)
~ValidPointerChecker() override = default;
protected:
bool InstrumentInstruction(llvm::Instruction *inst) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -381,7 +379,7 @@ private:
if (!m_valid_pointer_check_func)
m_valid_pointer_check_func = BuildPointerValidatorFunc(m_checker_functions.m_valid_pointer_check->StartAddress());
llvm::Value *dereferenced_ptr = NULL;
llvm::Value *dereferenced_ptr = nullptr;
if (llvm::LoadInst *li = dyn_cast<llvm::LoadInst> (inst))
dereferenced_ptr = li->getPointerOperand();
@@ -413,7 +411,7 @@ private:
return true;
}
bool InspectInstruction(llvm::Instruction &i)
bool InspectInstruction(llvm::Instruction &i) override
{
if (dyn_cast<llvm::LoadInst> (&i) ||
dyn_cast<llvm::StoreInst> (&i))
@@ -422,6 +420,7 @@ private:
return true;
}
private:
llvm::Value *m_valid_pointer_check_func;
};
@@ -431,14 +430,11 @@ public:
ObjcObjectChecker(llvm::Module &module,
DynamicCheckerFunctions &checker_functions) :
Instrumenter(module, checker_functions),
m_objc_object_check_func(NULL)
m_objc_object_check_func(nullptr)
{
}
virtual
~ObjcObjectChecker ()
{
}
~ObjcObjectChecker() override = default;
enum msgSend_type
{
@@ -451,13 +447,13 @@ public:
std::map <llvm::Instruction *, msgSend_type> msgSend_types;
private:
bool InstrumentInstruction(llvm::Instruction *inst)
protected:
bool InstrumentInstruction(llvm::Instruction *inst) override
{
CallInst *call_inst = dyn_cast<CallInst>(inst);
if (!call_inst)
return false; // call_inst really shouldn't be NULL, because otherwise InspectInstruction wouldn't have registered it
return false; // call_inst really shouldn't be nullptr, because otherwise InspectInstruction wouldn't have registered it
if (!m_objc_object_check_func)
m_objc_object_check_func = BuildObjectCheckerFunc(m_checker_functions.m_objc_object_check->StartAddress());
@@ -511,7 +507,7 @@ private:
return true;
}
bool InspectInstruction(llvm::Instruction &i)
bool InspectInstruction(llvm::Instruction &i) override
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -600,6 +596,7 @@ private:
return true;
}
private:
llvm::Value *m_objc_object_check_func;
};
@@ -611,9 +608,7 @@ IRDynamicChecks::IRDynamicChecks(DynamicCheckerFunctions &checker_functions,
{
}
IRDynamicChecks::~IRDynamicChecks()
{
}
IRDynamicChecks::~IRDynamicChecks() = default;
bool
IRDynamicChecks::runOnModule(llvm::Module &M)
@@ -630,7 +625,7 @@ IRDynamicChecks::runOnModule(llvm::Module &M)
return false;
}
if (m_checker_functions.m_valid_pointer_check.get())
if (m_checker_functions.m_valid_pointer_check)
{
ValidPointerChecker vpc(M, m_checker_functions);
@@ -641,7 +636,7 @@ IRDynamicChecks::runOnModule(llvm::Module &M)
return false;
}
if (m_checker_functions.m_objc_object_check.get())
if (m_checker_functions.m_objc_object_check)
{
ObjcObjectChecker ooc(M, m_checker_functions);
@@ -657,7 +652,7 @@ IRDynamicChecks::runOnModule(llvm::Module &M)
std::string s;
raw_string_ostream oss(s);
M.print(oss, NULL);
M.print(oss, nullptr);
oss.flush();

View File

@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamFile.h"
@@ -22,6 +26,25 @@
using namespace lldb_private;
REPL::REPL(LLVMCastKind kind, Target &target) :
m_target(target),
m_kind(kind)
{
// Make sure all option values have sane defaults
Debugger &debugger = m_target.GetDebugger();
CommandInterpreter &ci = debugger.GetCommandInterpreter();
m_format_options.OptionParsingStarting(ci);
m_varobj_options.OptionParsingStarting(ci);
m_command_options.OptionParsingStarting(ci);
// Default certain settings for REPL regardless of the global settings.
m_command_options.unwind_on_error = false;
m_command_options.ignore_breakpoints = false;
m_command_options.debug = false;
}
REPL::~REPL() = default;
lldb::REPLSP
REPL::Create(Error &err, lldb::LanguageType language, Debugger *debugger, Target *target, const char *repl_options)
{
@@ -40,23 +63,6 @@ REPL::Create(Error &err, lldb::LanguageType language, Debugger *debugger, Target
return ret;
}
REPL::REPL(LLVMCastKind kind, Target &target) :
m_target(target),
m_kind(kind)
{
// Make sure all option values have sane defaults
Debugger &debugger = m_target.GetDebugger();
CommandInterpreter &ci = debugger.GetCommandInterpreter();
m_format_options.OptionParsingStarting(ci);
m_varobj_options.OptionParsingStarting(ci);
m_command_options.OptionParsingStarting(ci);
// Default certain settings for REPL regardless of the global settings.
m_command_options.unwind_on_error = false;
m_command_options.ignore_breakpoints = false;
m_command_options.debug = false;
}
std::string
REPL::GetSourcePath()
{
@@ -66,7 +72,7 @@ REPL::GetSourcePath()
if (HostInfo::GetLLDBPath (lldb::ePathTypeLLDBTempSystemDir, tmpdir_file_spec))
{
tmpdir_file_spec.GetFilename().SetCString(file_basename.AsCString());
m_repl_source_path = std::move(tmpdir_file_spec.GetPath());
m_repl_source_path = tmpdir_file_spec.GetPath();
}
else
{
@@ -77,10 +83,6 @@ REPL::GetSourcePath()
return tmpdir_file_spec.GetPath();
}
REPL::~REPL()
{
}
lldb::IOHandlerSP
REPL::GetIOHandler()
{
@@ -139,11 +141,9 @@ REPL::IOHandlerInputInterrupted (IOHandler &io_handler,
}
const char *
REPL::IOHandlerGetFixIndentationCharacters ()
REPL::IOHandlerGetFixIndentationCharacters()
{
if (m_enable_auto_indent)
return GetAutoIndentCharacters();
return NULL;
return (m_enable_auto_indent ? GetAutoIndentCharacters() : nullptr);
}
ConstString
@@ -352,7 +352,7 @@ REPL::IOHandlerInputComplete (IOHandler &io_handler, std::string &code)
const size_t var_count_before = persistent_state->GetSize();
const char *expr_prefix = NULL;
const char *expr_prefix = nullptr;
lldb::ValueObjectSP result_valobj_sp;
Error error;
lldb::ModuleSP jit_module_sp;
@@ -401,8 +401,7 @@ REPL::IOHandlerInputComplete (IOHandler &io_handler, std::string &code)
PrintOneVariable(debugger, output_sp, valobj_sp, persistent_var_sp.get());
}
}
if (!handled)
{
bool useColors = error_sp->GetFile().GetIsTerminalWithColors();

View File

@@ -9,10 +9,12 @@
#pragma once
// Third party headers:
// C Includes
// C++ Includes
#include <vector>
// In-house headers:
// Other libraries and framework includes
// Project includes
#include "MICmnBase.h"
#include "MICmdArgContext.h"
@@ -49,16 +51,14 @@ class CMICmdArgSet : public CMICmnBase
virtual bool GetValid() const = 0;
virtual bool Validate(CMICmdArgContext &vwArgContext) = 0;
/* dtor */ virtual ~IArg(){}
virtual ~IArg() = default;
};
// Typedefs:
public:
typedef std::vector<CMICmdArgValBase *> SetCmdArgs_t;
// Methods:
public:
/* ctor */ CMICmdArgSet();
CMICmdArgSet();
void Add(CMICmdArgValBase *vArg);
bool GetArg(const CMIUtilString &vArgName, CMICmdArgValBase *&vpArg) const;
@@ -71,8 +71,7 @@ class CMICmdArgSet : public CMICmnBase
bool Validate(const CMIUtilString &vStrMiCmd, CMICmdArgContext &vwCmdArgsText);
// Overrideable:
public:
/* dtor */ virtual ~CMICmdArgSet();
~CMICmdArgSet() override;
// Methods:
private:
@@ -82,7 +81,6 @@ class CMICmdArgSet : public CMICmnBase
bool ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText);
// Attributes:
private:
bool m_bIsArgsPresentButNotHandledByCmd; // True = The driver's client presented the command with options recognised but not handled by
// a command, false = all args handled
SetCmdArgs_t m_setCmdArgs; // The set of arguments that are that the command is expecting to find in the options string

View File

@@ -7,7 +7,10 @@
//
//===----------------------------------------------------------------------===//
// In-house headers:
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "MICmdArgValBase.h"
#include "MIUtilString.h"
#include "MICmdArgContext.h"
@@ -47,17 +50,6 @@ CMICmdArgValBase::CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vb
{
}
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValBase destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
CMICmdArgValBase::~CMICmdArgValBase()
{
}
//++ ------------------------------------------------------------------------------------
// Details: Retrieve the state flag of whether the argument is handled by the command or
// not.

View File

@@ -9,7 +9,10 @@
#pragma once
// In-house headers:
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "MIUtilString.h"
#include "MICmdArgSet.h"
@@ -35,15 +38,13 @@ class CMICmdArgValBase : public CMICmdArgSet::IArg
{
// Methods:
public:
/* ctor */ CMICmdArgValBase();
/* ctor */ CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
CMICmdArgValBase();
CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
// Overrideable:
public:
/* dtor */ ~CMICmdArgValBase() override;
~CMICmdArgValBase() override = default;
// Overridden:
public:
// From CMICmdArgSet::IArg
bool GetFound() const override;
bool GetIsHandledByCmd() const override;
@@ -70,31 +71,19 @@ template <class T> class CMICmdArgValBaseTemplate : public CMICmdArgValBase
{
// Methods:
public:
/* ctor */ CMICmdArgValBaseTemplate();
/* ctor */ CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
CMICmdArgValBaseTemplate() = default;
CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
//
const T &GetValue() const;
// Overrideable:
public:
/* dtor */ virtual ~CMICmdArgValBaseTemplate();
~CMICmdArgValBaseTemplate() override = default;
// Attributes:
protected:
T m_argValue;
};
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValBaseTemplate constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
template <class T> CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate()
{
}
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValBaseTemplate constructor.
// Type: Method.
@@ -110,17 +99,6 @@ CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate(const CMIUtilString &vrArg
{
}
//++ ------------------------------------------------------------------------------------
// Details: CMICmdArgValBaseTemplate destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
template <class T> CMICmdArgValBaseTemplate<T>::~CMICmdArgValBaseTemplate()
{
}
//++ ------------------------------------------------------------------------------------
// Details: Retrieve the value the argument parsed from the command's argument / options
// text string.

View File

@@ -9,7 +9,10 @@
#pragma once
// In-house headers:
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "MIUtilString.h"
#include "MICmnBase.h"
#include "MICmnResources.h"
@@ -47,29 +50,27 @@ class CMICmdBase : public CMICmnBase, public CMICmdInvoker::ICmd, public CMICmdF
{
// Methods:
public:
/* ctor */ CMICmdBase();
CMICmdBase();
// Overridden:
public:
// From CMICmdInvoker::ICmd
virtual const SMICmdData &GetCmdData() const;
virtual const CMIUtilString &GetErrorDescription() const;
virtual void SetCmdData(const SMICmdData &vCmdData);
virtual void CmdFinishedTellInvoker() const;
virtual const CMIUtilString &GetMIResultRecord() const;
virtual const CMIUtilString &GetMIResultRecordExtra() const;
virtual bool HasMIResultRecordExtra() const;
virtual bool ParseArgs();
const SMICmdData &GetCmdData() const override;
const CMIUtilString &GetErrorDescription() const override;
void SetCmdData(const SMICmdData &vCmdData) override;
void CmdFinishedTellInvoker() const override;
const CMIUtilString &GetMIResultRecord() const override;
const CMIUtilString &GetMIResultRecordExtra() const override;
bool HasMIResultRecordExtra() const override;
bool ParseArgs() override;
// From CMICmdFactory::ICmd
virtual const CMIUtilString &GetMiCmd() const;
virtual CMICmdFactory::CmdCreatorFnPtr GetCmdCreatorFn() const;
const CMIUtilString &GetMiCmd() const override;
CMICmdFactory::CmdCreatorFnPtr GetCmdCreatorFn() const override;
virtual MIuint GetGUID();
void AddCommonArgs();
// Overrideable:
public:
/* dtor */ virtual ~CMICmdBase();
~CMICmdBase() override;
virtual bool GetExitAppOnCommandFailure() const;
// Methods:
@@ -79,7 +80,6 @@ class CMICmdBase : public CMICmnBase, public CMICmdInvoker::ICmd, public CMICmdF
bool ParseValidateCmdOptions();
// Attributes:
protected:
CMICmdFactory::CmdCreatorFnPtr m_pSelfCreatorFn;
CMIUtilString m_strCurrentErrDescription; // Reason for Execute or Acknowledge function failure
SMICmdData m_cmdData; // Holds information/status of *this command. Used by other MI code to report or determine state of a command.
@@ -116,7 +116,7 @@ class CMICmdBase : public CMICmnBase, public CMICmdInvoker::ICmd, public CMICmdF
// Args: vStrOptionName - (R) The text name of the argument or option to search for in
// the list of the command's possible arguments or options.
// Return: T * - CMICmdArgValBase derived object.
// - NULL = function has failed, unable to retrieve the option/arg object.
// - nullptr = function has failed, unable to retrieve the option/arg object.
// Throws: None.
//--
template <class T>
@@ -143,7 +143,7 @@ CMICmdBase::GetOption(const CMIUtilString &vStrOptionName)
// c - (R) The text name of the argument or option to search for in the list of
// the command's possible arguments or options.
// Return: T * - CMICmdArgValBase derived object.
// - NULL = function has failed, unable to retrieve the option/arg object.
// - nullptr = function has failed, unable to retrieve the option/arg object.
// Throws: None.
//--
#define CMICMDBASE_GETOPTION(a, b, c) \