Fix Clang-tidy modernize-use-override warnings in include/lldb/Disassembler and OperatingSystem; other minor fixes.

Second attempt which should work for MSVC.

llvm-svn: 251066
This commit is contained in:
Eugene Zelenko 2015-10-22 21:24:37 +00:00
parent e2dd2fd7c7
commit 45a4014a50
4 changed files with 130 additions and 132 deletions

View File

@ -7,8 +7,9 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "DisassemblerLLVMC.h" // C Includes
// C++ Includes
// Project includes
#include "llvm-c/Disassembler.h" #include "llvm-c/Disassembler.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
@ -25,6 +26,8 @@
#include "llvm/Support/TargetSelect.h" #include "llvm/Support/TargetSelect.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
// Other libraries and framework includes
#include "DisassemblerLLVMC.h"
#include "lldb/Core/Address.h" #include "lldb/Core/Address.h"
#include "lldb/Core/DataExtractor.h" #include "lldb/Core/DataExtractor.h"
@ -58,13 +61,10 @@ public:
{ {
} }
virtual ~InstructionLLVMC() override = default;
~InstructionLLVMC ()
{
}
virtual bool bool
DoesBranch () DoesBranch() override
{ {
if (m_does_branch == eLazyBoolCalculate) if (m_does_branch == eLazyBoolCalculate)
{ {
@ -100,8 +100,8 @@ public:
return m_does_branch == eLazyBoolYes; return m_does_branch == eLazyBoolYes;
} }
virtual bool bool
HasDelaySlot () HasDelaySlot() override
{ {
if (m_has_delay_slot == eLazyBoolCalculate) if (m_has_delay_slot == eLazyBoolCalculate)
{ {
@ -155,10 +155,10 @@ public:
return llvm_disasm.m_disasm_ap.get(); return llvm_disasm.m_disasm_ap.get();
} }
virtual size_t size_t
Decode(const lldb_private::Disassembler &disassembler, Decode(const lldb_private::Disassembler &disassembler,
const lldb_private::DataExtractor &data, const lldb_private::DataExtractor &data,
lldb::offset_t data_offset) lldb::offset_t data_offset) override
{ {
// All we have to do is read the opcode which can be easy for some // All we have to do is read the opcode which can be easy for some
// architectures // architectures
@ -272,8 +272,8 @@ public:
} }
} }
virtual void void
CalculateMnemonicOperandsAndComment (const lldb_private::ExecutionContext *exe_ctx) CalculateMnemonicOperandsAndComment(const lldb_private::ExecutionContext *exe_ctx) override
{ {
DataExtractor data; DataExtractor data;
const AddressClass address_class = GetAddressClass (); const AddressClass address_class = GetAddressClass ();
@ -452,8 +452,6 @@ protected:
bool m_using_file_addr; bool m_using_file_addr;
}; };
DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, const char *cpu, const char *features_str, unsigned flavor, DisassemblerLLVMC &owner): DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, const char *cpu, const char *features_str, unsigned flavor, DisassemblerLLVMC &owner):
m_is_valid(true) m_is_valid(true)
{ {
@ -521,9 +519,7 @@ DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, con
m_is_valid = false; m_is_valid = false;
} }
DisassemblerLLVMC::LLVMCDisassembler::~LLVMCDisassembler() DisassemblerLLVMC::LLVMCDisassembler::~LLVMCDisassembler() = default;
{
}
uint64_t uint64_t
DisassemblerLLVMC::LLVMCDisassembler::GetMCInst (const uint8_t *opcode_data, DisassemblerLLVMC::LLVMCDisassembler::GetMCInst (const uint8_t *opcode_data,
@ -587,38 +583,6 @@ DisassemblerLLVMC::LLVMCDisassembler::HasDelaySlot (llvm::MCInst &mc_inst)
return m_instr_info_ap->get(mc_inst.getOpcode()).hasDelaySlot(); return m_instr_info_ap->get(mc_inst.getOpcode()).hasDelaySlot();
} }
bool
DisassemblerLLVMC::FlavorValidForArchSpec (const lldb_private::ArchSpec &arch, const char *flavor)
{
llvm::Triple triple = arch.GetTriple();
if (flavor == NULL || strcmp (flavor, "default") == 0)
return true;
if (triple.getArch() == llvm::Triple::x86 || triple.getArch() == llvm::Triple::x86_64)
{
if (strcmp (flavor, "intel") == 0 || strcmp (flavor, "att") == 0)
return true;
else
return false;
}
else
return false;
}
Disassembler *
DisassemblerLLVMC::CreateInstance (const ArchSpec &arch, const char *flavor)
{
if (arch.GetTriple().getArch() != llvm::Triple::UnknownArch)
{
std::unique_ptr<DisassemblerLLVMC> disasm_ap (new DisassemblerLLVMC(arch, flavor));
if (disasm_ap.get() && disasm_ap->IsValid())
return disasm_ap.release();
}
return NULL;
}
DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_string) : DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_string) :
Disassembler(arch, flavor_string), Disassembler(arch, flavor_string),
m_exe_ctx (NULL), m_exe_ctx (NULL),
@ -782,8 +746,19 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s
} }
} }
DisassemblerLLVMC::~DisassemblerLLVMC() DisassemblerLLVMC::~DisassemblerLLVMC() = default;
Disassembler *
DisassemblerLLVMC::CreateInstance (const ArchSpec &arch, const char *flavor)
{ {
if (arch.GetTriple().getArch() != llvm::Triple::UnknownArch)
{
std::unique_ptr<DisassemblerLLVMC> disasm_ap (new DisassemblerLLVMC(arch, flavor));
if (disasm_ap.get() && disasm_ap->IsValid())
return disasm_ap.release();
}
return NULL;
} }
size_t size_t
@ -888,6 +863,24 @@ const char *DisassemblerLLVMC::SymbolLookupCallback (void *disassembler,
name); name);
} }
bool
DisassemblerLLVMC::FlavorValidForArchSpec (const lldb_private::ArchSpec &arch, const char *flavor)
{
llvm::Triple triple = arch.GetTriple();
if (flavor == NULL || strcmp (flavor, "default") == 0)
return true;
if (triple.getArch() == llvm::Triple::x86 || triple.getArch() == llvm::Triple::x86_64)
{
if (strcmp (flavor, "intel") == 0 || strcmp (flavor, "att") == 0)
return true;
else
return false;
}
else
return false;
}
int DisassemblerLLVMC::OpInfo (uint64_t PC, int DisassemblerLLVMC::OpInfo (uint64_t PC,
uint64_t Offset, uint64_t Offset,
uint64_t Size, uint64_t Size,

View File

@ -10,10 +10,20 @@
#ifndef liblldb_DisassemblerLLVMC_h_ #ifndef liblldb_DisassemblerLLVMC_h_
#define liblldb_DisassemblerLLVMC_h_ #define liblldb_DisassemblerLLVMC_h_
// C Includes
// C++ Includes
#include <memory>
#include <string> #include <string>
// Other libraries and framework includes
#include "llvm-c/Disassembler.h" #include "llvm-c/Disassembler.h"
// Project includes
#include "lldb/Core/Address.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/Mutex.h"
// Opaque references to C++ Objects in LLVM's MC. // Opaque references to C++ Objects in LLVM's MC.
namespace llvm namespace llvm
{ {
@ -25,12 +35,7 @@ namespace llvm
class MCInstPrinter; class MCInstPrinter;
class MCAsmInfo; class MCAsmInfo;
class MCSubtargetInfo; class MCSubtargetInfo;
} } // namespace llvm
#include "lldb/Core/Address.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/Mutex.h"
class InstructionLLVMC; class InstructionLLVMC;
@ -67,6 +72,10 @@ class DisassemblerLLVMC : public lldb_private::Disassembler
}; };
public: public:
DisassemblerLLVMC(const lldb_private::ArchSpec &arch, const char *flavor /* = NULL */);
~DisassemblerLLVMC() override;
//------------------------------------------------------------------ //------------------------------------------------------------------
// Static Functions // Static Functions
//------------------------------------------------------------------ //------------------------------------------------------------------
@ -82,33 +91,28 @@ public:
static lldb_private::Disassembler * static lldb_private::Disassembler *
CreateInstance(const lldb_private::ArchSpec &arch, const char *flavor); CreateInstance(const lldb_private::ArchSpec &arch, const char *flavor);
DisassemblerLLVMC(const lldb_private::ArchSpec &arch, const char *flavor /* = NULL */); size_t
virtual
~DisassemblerLLVMC();
virtual size_t
DecodeInstructions(const lldb_private::Address &base_addr, DecodeInstructions(const lldb_private::Address &base_addr,
const lldb_private::DataExtractor& data, const lldb_private::DataExtractor& data,
lldb::offset_t data_offset, lldb::offset_t data_offset,
size_t num_instructions, size_t num_instructions,
bool append, bool append,
bool data_from_file); bool data_from_file) override;
//------------------------------------------------------------------ //------------------------------------------------------------------
// PluginInterface protocol // PluginInterface protocol
//------------------------------------------------------------------ //------------------------------------------------------------------
virtual lldb_private::ConstString lldb_private::ConstString
GetPluginName(); GetPluginName() override;
virtual uint32_t uint32_t
GetPluginVersion(); GetPluginVersion() override;
protected: protected:
friend class InstructionLLVMC; friend class InstructionLLVMC;
virtual bool bool
FlavorValidForArchSpec (const lldb_private::ArchSpec &arch, const char *flavor); FlavorValidForArchSpec(const lldb_private::ArchSpec &arch, const char *flavor) override;
bool bool
IsValid() IsValid()

View File

@ -1,4 +1,4 @@
//===-- OperatingSystemGo.cpp --------------------------------*- C++ -*-===// //===-- OperatingSystemGo.cpp -----------------------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -6,13 +6,15 @@
// License. See LICENSE.TXT for details. // License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "OperatingSystemGo.h"
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <unordered_map> #include <unordered_map>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes
#include "OperatingSystemGo.h"
#include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Debugger.h" #include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h" #include "lldb/Core/Module.h"
@ -57,12 +59,6 @@ enum
class PluginProperties : public Properties class PluginProperties : public Properties
{ {
public: public:
static ConstString
GetSettingName()
{
return OperatingSystemGo::GetPluginNameStatic();
}
PluginProperties() PluginProperties()
: Properties() : Properties()
{ {
@ -70,7 +66,13 @@ class PluginProperties : public Properties
m_collection_sp->Initialize(g_properties); m_collection_sp->Initialize(g_properties);
} }
virtual ~PluginProperties() {} ~PluginProperties() override = default;
static ConstString
GetSettingName()
{
return OperatingSystemGo::GetPluginNameStatic();
}
bool bool
GetEnableGoroutines() GetEnableGoroutines()
@ -101,9 +103,6 @@ GetGlobalPluginProperties()
class RegisterContextGo : public RegisterContextMemory class RegisterContextGo : public RegisterContextMemory
{ {
public: public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
RegisterContextGo(lldb_private::Thread &thread, uint32_t concrete_frame_idx, DynamicRegisterInfo &reg_info, RegisterContextGo(lldb_private::Thread &thread, uint32_t concrete_frame_idx, DynamicRegisterInfo &reg_info,
lldb::addr_t reg_data_addr) lldb::addr_t reg_data_addr)
: RegisterContextMemory(thread, concrete_frame_idx, reg_info, reg_data_addr) : RegisterContextMemory(thread, concrete_frame_idx, reg_info, reg_data_addr)
@ -118,10 +117,11 @@ class RegisterContextGo : public RegisterContextMemory
m_reg_data.SetData(reg_data_sp); m_reg_data.SetData(reg_data_sp);
} }
virtual ~RegisterContextGo() {} ~RegisterContextGo() override = default;
virtual bool bool
ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &reg_value) ReadRegister(const lldb_private::RegisterInfo *reg_info,
lldb_private::RegisterValue &reg_value) override
{ {
switch (reg_info->kinds[eRegisterKindGeneric]) switch (reg_info->kinds[eRegisterKindGeneric])
{ {
@ -134,8 +134,9 @@ class RegisterContextGo : public RegisterContextMemory
} }
} }
virtual bool bool
WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &reg_value) WriteRegister(const lldb_private::RegisterInfo *reg_info,
const lldb_private::RegisterValue &reg_value) override
{ {
switch (reg_info->kinds[eRegisterKindGeneric]) switch (reg_info->kinds[eRegisterKindGeneric])
{ {
@ -151,7 +152,7 @@ class RegisterContextGo : public RegisterContextMemory
DISALLOW_COPY_AND_ASSIGN(RegisterContextGo); DISALLOW_COPY_AND_ASSIGN(RegisterContextGo);
}; };
} // namespace } // anonymous namespace
struct OperatingSystemGo::Goroutine struct OperatingSystemGo::Goroutine
{ {
@ -219,6 +220,14 @@ OperatingSystemGo::CreateInstance(Process *process, bool force)
return new OperatingSystemGo(process); return new OperatingSystemGo(process);
} }
OperatingSystemGo::OperatingSystemGo(lldb_private::Process *process)
: OperatingSystem(process)
, m_reginfo(new DynamicRegisterInfo)
{
}
OperatingSystemGo::~OperatingSystemGo() = default;
ConstString ConstString
OperatingSystemGo::GetPluginNameStatic() OperatingSystemGo::GetPluginNameStatic()
{ {
@ -232,16 +241,6 @@ OperatingSystemGo::GetPluginDescriptionStatic()
return "Operating system plug-in that reads runtime data-structures for goroutines."; return "Operating system plug-in that reads runtime data-structures for goroutines.";
} }
OperatingSystemGo::OperatingSystemGo(lldb_private::Process *process)
: OperatingSystem(process)
, m_reginfo(new DynamicRegisterInfo)
{
}
OperatingSystemGo::~OperatingSystemGo()
{
}
bool bool
OperatingSystemGo::Init(ThreadList &threads) OperatingSystemGo::Init(ThreadList &threads)
{ {

View File

@ -1,17 +1,21 @@
//===-- OperatingSystemGo.h ----------------------------------*- C++ -*-===// //===-- OperatingSystemGo.h -------------------------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file is distributed under the University of Illinois Open Source // This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details. // License. See LICENSE.TXT for details.
// //
//===-------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef _liblldb_OperatingSystemGo_h_ #ifndef _liblldb_OperatingSystemGo_h_
#define _liblldb_OperatingSystemGo_h_ #define _liblldb_OperatingSystemGo_h_
#include <iostream> // C Includes
// C++ Includes
#include <memory>
// Other libraries and framework includes
// Project includes
#include "lldb/Target/OperatingSystem.h" #include "lldb/Target/OperatingSystem.h"
class DynamicRegisterInfo; class DynamicRegisterInfo;
@ -19,6 +23,10 @@ class DynamicRegisterInfo;
class OperatingSystemGo : public lldb_private::OperatingSystem class OperatingSystemGo : public lldb_private::OperatingSystem
{ {
public: public:
OperatingSystemGo(lldb_private::Process *process);
~OperatingSystemGo() override;
//------------------------------------------------------------------ //------------------------------------------------------------------
// Static Functions // Static Functions
//------------------------------------------------------------------ //------------------------------------------------------------------
@ -34,37 +42,31 @@ class OperatingSystemGo : public lldb_private::OperatingSystem
static const char *GetPluginDescriptionStatic(); static const char *GetPluginDescriptionStatic();
//------------------------------------------------------------------
// Class Methods
//------------------------------------------------------------------
OperatingSystemGo(lldb_private::Process *process);
virtual ~OperatingSystemGo();
//------------------------------------------------------------------ //------------------------------------------------------------------
// lldb_private::PluginInterface Methods // lldb_private::PluginInterface Methods
//------------------------------------------------------------------ //------------------------------------------------------------------
virtual lldb_private::ConstString GetPluginName(); lldb_private::ConstString GetPluginName() override;
virtual uint32_t GetPluginVersion(); uint32_t GetPluginVersion() override;
//------------------------------------------------------------------ //------------------------------------------------------------------
// lldb_private::OperatingSystem Methods // lldb_private::OperatingSystem Methods
//------------------------------------------------------------------ //------------------------------------------------------------------
virtual bool UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &real_thread_list, bool UpdateThreadList(lldb_private::ThreadList &old_thread_list,
lldb_private::ThreadList &new_thread_list); lldb_private::ThreadList &real_thread_list,
lldb_private::ThreadList &new_thread_list) override;
virtual void ThreadWasSelected(lldb_private::Thread *thread); void ThreadWasSelected(lldb_private::Thread *thread) override;
virtual lldb::RegisterContextSP CreateRegisterContextForThread(lldb_private::Thread *thread, lldb::RegisterContextSP CreateRegisterContextForThread(lldb_private::Thread *thread,
lldb::addr_t reg_data_addr); lldb::addr_t reg_data_addr) override;
virtual lldb::StopInfoSP CreateThreadStopReason(lldb_private::Thread *thread); lldb::StopInfoSP CreateThreadStopReason(lldb_private::Thread *thread) override;
//------------------------------------------------------------------ //------------------------------------------------------------------
// Method for lazy creation of threads on demand // Method for lazy creation of threads on demand
//------------------------------------------------------------------ //------------------------------------------------------------------
virtual lldb::ThreadSP CreateThread(lldb::tid_t tid, lldb::addr_t context); lldb::ThreadSP CreateThread(lldb::tid_t tid, lldb::addr_t context) override;
private: private:
struct Goroutine; struct Goroutine;
@ -82,4 +84,4 @@ class OperatingSystemGo : public lldb_private::OperatingSystem
lldb::ValueObjectSP m_allglen_sp; lldb::ValueObjectSP m_allglen_sp;
}; };
#endif // #ifndef liblldb_OperatingSystemGo_h_ #endif // liblldb_OperatingSystemGo_h_