[LLDB] Add some declarations related to REPL support for mojo
This simple diff declares some enum values needed to create a REPL for the mojo language. Differential Revision: https://reviews.llvm.org/D150303
This commit is contained in:
parent
991ecfb83d
commit
f237513cda
@ -11,35 +11,25 @@
|
||||
#define LLDB_EXPRESSION_EXPRESSIONTYPESYSTEMHELPER_H
|
||||
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/ExtensibleRTTI.h"
|
||||
|
||||
namespace lldb_private {
|
||||
|
||||
/// \class ExpressionTypeSystemHelper ExpressionTypeSystemHelper.h
|
||||
/// "lldb/Expression/ExpressionTypeSystemHelper.h"
|
||||
/// A helper object that the Expression can pass to its ExpressionParser
|
||||
/// to provide generic information that
|
||||
/// any type of expression will need to supply. It's only job is to support
|
||||
/// dyn_cast so that the expression parser can cast it back to the requisite
|
||||
/// specific type.
|
||||
/// to provide generic information that any type of expression will need to
|
||||
/// supply. It's only job is to support dyn_cast so that the expression parser
|
||||
/// can cast it back to the requisite specific type.
|
||||
///
|
||||
|
||||
class ExpressionTypeSystemHelper {
|
||||
class ExpressionTypeSystemHelper
|
||||
: public llvm::RTTIExtends<ExpressionTypeSystemHelper, llvm::RTTIRoot> {
|
||||
public:
|
||||
enum LLVMCastKind {
|
||||
eKindClangHelper,
|
||||
eKindSwiftHelper,
|
||||
eKindGoHelper,
|
||||
kNumKinds
|
||||
};
|
||||
/// LLVM RTTI support
|
||||
static char ID;
|
||||
|
||||
LLVMCastKind getKind() const { return m_kind; }
|
||||
|
||||
ExpressionTypeSystemHelper(LLVMCastKind kind) : m_kind(kind) {}
|
||||
|
||||
~ExpressionTypeSystemHelper() = default;
|
||||
|
||||
protected:
|
||||
LLVMCastKind m_kind;
|
||||
virtual ~ExpressionTypeSystemHelper() = default;
|
||||
};
|
||||
|
||||
} // namespace lldb_private
|
||||
|
||||
@ -18,19 +18,20 @@
|
||||
#include "lldb/Core/ValueObject.h"
|
||||
#include "lldb/Utility/ConstString.h"
|
||||
#include "lldb/lldb-public.h"
|
||||
#include "llvm/Support/ExtensibleRTTI.h"
|
||||
|
||||
namespace lldb_private {
|
||||
|
||||
class ExpressionVariable
|
||||
: public std::enable_shared_from_this<ExpressionVariable> {
|
||||
: public std::enable_shared_from_this<ExpressionVariable>,
|
||||
public llvm::RTTIExtends<ExpressionVariable, llvm::RTTIRoot> {
|
||||
public:
|
||||
// See TypeSystem.h for how to add subclasses to this.
|
||||
enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
|
||||
/// LLVM RTTI support
|
||||
static char ID;
|
||||
|
||||
LLVMCastKind getKind() const { return m_kind; }
|
||||
ExpressionVariable();
|
||||
|
||||
ExpressionVariable(LLVMCastKind kind);
|
||||
virtual ~ExpressionVariable();
|
||||
virtual ~ExpressionVariable() = default;
|
||||
|
||||
std::optional<uint64_t> GetByteSize() { return m_frozen_sp->GetByteSize(); }
|
||||
|
||||
@ -109,7 +110,6 @@ public:
|
||||
// these should be private
|
||||
lldb::ValueObjectSP m_frozen_sp;
|
||||
lldb::ValueObjectSP m_live_sp;
|
||||
LLVMCastKind m_kind;
|
||||
};
|
||||
|
||||
/// \class ExpressionVariableList ExpressionVariable.h
|
||||
@ -200,14 +200,13 @@ private:
|
||||
std::vector<lldb::ExpressionVariableSP> m_variables;
|
||||
};
|
||||
|
||||
class PersistentExpressionState : public ExpressionVariableList {
|
||||
class PersistentExpressionState
|
||||
: public ExpressionVariableList,
|
||||
public llvm::RTTIExtends<PersistentExpressionState, llvm::RTTIRoot> {
|
||||
public:
|
||||
// See TypeSystem.h for how to add subclasses to this.
|
||||
enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
|
||||
/// LLVM RTTI support
|
||||
static char ID;
|
||||
|
||||
LLVMCastKind getKind() const { return m_kind; }
|
||||
|
||||
PersistentExpressionState(LLVMCastKind kind);
|
||||
virtual ~PersistentExpressionState();
|
||||
|
||||
virtual lldb::ExpressionVariableSP
|
||||
@ -237,8 +236,6 @@ protected:
|
||||
GetPersistentVariablePrefix(bool is_error = false) const = 0;
|
||||
|
||||
private:
|
||||
LLVMCastKind m_kind;
|
||||
|
||||
typedef std::set<lldb::IRExecutionUnitSP> ExecutionUnitSet;
|
||||
ExecutionUnitSet
|
||||
m_execution_units; ///< The execution units that contain valuable symbols.
|
||||
|
||||
@ -15,17 +15,17 @@
|
||||
#include "lldb/Interpreter/OptionGroupFormat.h"
|
||||
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
|
||||
#include "lldb/Target/Target.h"
|
||||
#include "llvm/Support/ExtensibleRTTI.h"
|
||||
|
||||
namespace lldb_private {
|
||||
|
||||
class REPL : public IOHandlerDelegate {
|
||||
class REPL : public IOHandlerDelegate,
|
||||
public llvm::RTTIExtends<REPL, llvm::RTTIRoot> {
|
||||
public:
|
||||
// See TypeSystem.h for how to add subclasses to this.
|
||||
enum LLVMCastKind { eKindClang, eKindSwift, eKindGo, kNumKinds };
|
||||
/// LLVM RTTI support
|
||||
static char ID;
|
||||
|
||||
LLVMCastKind getKind() const { return m_kind; }
|
||||
|
||||
REPL(LLVMCastKind kind, Target &target);
|
||||
REPL(Target &target);
|
||||
|
||||
~REPL() override;
|
||||
|
||||
@ -168,7 +168,6 @@ protected:
|
||||
|
||||
Target &m_target;
|
||||
lldb::IOHandlerSP m_io_handler_sp;
|
||||
LLVMCastKind m_kind;
|
||||
|
||||
private:
|
||||
std::string GetSourcePath();
|
||||
|
||||
@ -3,6 +3,7 @@ add_lldb_library(lldbExpression NO_PLUGIN_DEPENDENCIES
|
||||
DWARFExpression.cpp
|
||||
DWARFExpressionList.cpp
|
||||
Expression.cpp
|
||||
ExpressionTypeSystemHelper.cpp
|
||||
ExpressionVariable.cpp
|
||||
FunctionCaller.cpp
|
||||
IRExecutionUnit.cpp
|
||||
|
||||
13
lldb/source/Expression/ExpressionTypeSystemHelper.cpp
Normal file
13
lldb/source/Expression/ExpressionTypeSystemHelper.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
//===-- ExpressionTypeSystemHelper.cpp ------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "lldb/Expression/ExpressionTypeSystemHelper.h"
|
||||
|
||||
using namespace lldb_private;
|
||||
|
||||
char ExpressionTypeSystemHelper::ID;
|
||||
@ -15,9 +15,9 @@
|
||||
|
||||
using namespace lldb_private;
|
||||
|
||||
ExpressionVariable::ExpressionVariable(LLVMCastKind kind)
|
||||
: m_flags(0), m_kind(kind) {}
|
||||
ExpressionVariable::~ExpressionVariable() = default;
|
||||
char ExpressionVariable::ID;
|
||||
|
||||
ExpressionVariable::ExpressionVariable() : m_flags(0) {}
|
||||
|
||||
uint8_t *ExpressionVariable::GetValueBytes() {
|
||||
std::optional<uint64_t> byte_size = m_frozen_sp->GetByteSize();
|
||||
@ -32,8 +32,8 @@ uint8_t *ExpressionVariable::GetValueBytes() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PersistentExpressionState::PersistentExpressionState(LLVMCastKind kind)
|
||||
: m_kind(kind) {}
|
||||
char PersistentExpressionState::ID;
|
||||
|
||||
PersistentExpressionState::~PersistentExpressionState() = default;
|
||||
|
||||
lldb::addr_t PersistentExpressionState::LookupSymbol(ConstString name) {
|
||||
|
||||
@ -22,7 +22,9 @@
|
||||
|
||||
using namespace lldb_private;
|
||||
|
||||
REPL::REPL(LLVMCastKind kind, Target &target) : m_target(target), m_kind(kind) {
|
||||
char REPL::ID;
|
||||
|
||||
REPL::REPL(Target &target) : m_target(target) {
|
||||
// Make sure all option values have sane defaults
|
||||
Debugger &debugger = m_target.GetDebugger();
|
||||
debugger.SetShowProgress(false);
|
||||
|
||||
@ -7,6 +7,7 @@ add_lldb_library(lldbPluginExpressionParserClang
|
||||
ClangASTSource.cpp
|
||||
ClangDeclVendor.cpp
|
||||
ClangExpressionDeclMap.cpp
|
||||
ClangExpressionHelper.cpp
|
||||
ClangExpressionParser.cpp
|
||||
ClangExpressionSourceCode.cpp
|
||||
ClangExpressionUtil.cpp
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
//===-- ClangExpressionHelper.cpp -----------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "ClangExpressionHelper.h"
|
||||
|
||||
using namespace lldb_private;
|
||||
|
||||
char ClangExpressionHelper::ID;
|
||||
@ -27,18 +27,12 @@ class ClangExpressionDeclMap;
|
||||
class RecordingMemoryManager;
|
||||
|
||||
// ClangExpressionHelper
|
||||
class ClangExpressionHelper : public ExpressionTypeSystemHelper {
|
||||
class ClangExpressionHelper
|
||||
: public llvm::RTTIExtends<ClangExpressionHelper,
|
||||
ExpressionTypeSystemHelper> {
|
||||
public:
|
||||
static bool classof(const ExpressionTypeSystemHelper *ts) {
|
||||
return ts->getKind() == eKindClangHelper;
|
||||
}
|
||||
|
||||
ClangExpressionHelper()
|
||||
: ExpressionTypeSystemHelper(
|
||||
ExpressionTypeSystemHelper::LLVMCastKind::eKindClangHelper) {}
|
||||
|
||||
/// Destructor
|
||||
virtual ~ClangExpressionHelper() = default;
|
||||
// LLVM RTTI support
|
||||
static char ID;
|
||||
|
||||
/// Return the object that the parser should use when resolving external
|
||||
/// values. May be NULL if everything should be self-contained.
|
||||
@ -54,8 +48,6 @@ public:
|
||||
ASTTransformer(clang::ASTConsumer *passthrough) = 0;
|
||||
|
||||
virtual void CommitPersistentDecls() {}
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
} // namespace lldb_private
|
||||
|
||||
@ -20,11 +20,12 @@
|
||||
using namespace lldb_private;
|
||||
using namespace clang;
|
||||
|
||||
char ClangExpressionVariable::ID;
|
||||
|
||||
ClangExpressionVariable::ClangExpressionVariable(
|
||||
ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order,
|
||||
uint32_t addr_byte_size)
|
||||
: ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(),
|
||||
m_jit_vars() {
|
||||
: m_parser_vars(), m_jit_vars() {
|
||||
m_flags = EVNone;
|
||||
m_frozen_sp =
|
||||
ValueObjectConstResult::Create(exe_scope, byte_order, addr_byte_size);
|
||||
@ -33,16 +34,14 @@ ClangExpressionVariable::ClangExpressionVariable(
|
||||
ClangExpressionVariable::ClangExpressionVariable(
|
||||
ExecutionContextScope *exe_scope, Value &value, ConstString name,
|
||||
uint16_t flags)
|
||||
: ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(),
|
||||
m_jit_vars() {
|
||||
: m_parser_vars(), m_jit_vars() {
|
||||
m_flags = flags;
|
||||
m_frozen_sp = ValueObjectConstResult::Create(exe_scope, value, name);
|
||||
}
|
||||
|
||||
ClangExpressionVariable::ClangExpressionVariable(
|
||||
const lldb::ValueObjectSP &valobj_sp)
|
||||
: ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(),
|
||||
m_jit_vars() {
|
||||
: m_parser_vars(), m_jit_vars() {
|
||||
m_flags = EVNone;
|
||||
m_frozen_sp = valobj_sp;
|
||||
}
|
||||
@ -51,8 +50,7 @@ ClangExpressionVariable::ClangExpressionVariable(
|
||||
ExecutionContextScope *exe_scope, ConstString name,
|
||||
const TypeFromUser &user_type, lldb::ByteOrder byte_order,
|
||||
uint32_t addr_byte_size)
|
||||
: ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(),
|
||||
m_jit_vars() {
|
||||
: m_parser_vars(), m_jit_vars() {
|
||||
m_flags = EVNone;
|
||||
m_frozen_sp =
|
||||
ValueObjectConstResult::Create(exe_scope, byte_order, addr_byte_size);
|
||||
|
||||
@ -57,8 +57,12 @@ class ValueObjectConstResult;
|
||||
///
|
||||
/// This class supports all of these use cases using simple type polymorphism,
|
||||
/// and provides necessary support methods. Its interface is RTTI-neutral.
|
||||
class ClangExpressionVariable : public ExpressionVariable {
|
||||
class ClangExpressionVariable
|
||||
: public llvm::RTTIExtends<ClangExpressionVariable, ExpressionVariable> {
|
||||
public:
|
||||
// LLVM RTTI support
|
||||
static char ID;
|
||||
|
||||
ClangExpressionVariable(ExecutionContextScope *exe_scope,
|
||||
lldb::ByteOrder byte_order, uint32_t addr_byte_size);
|
||||
|
||||
@ -197,11 +201,6 @@ public:
|
||||
|
||||
TypeFromUser GetTypeFromUser();
|
||||
|
||||
// llvm casting support
|
||||
static bool classof(const ExpressionVariable *ev) {
|
||||
return ev->getKind() == ExpressionVariable::eKindClang;
|
||||
}
|
||||
|
||||
/// Members
|
||||
ClangExpressionVariable(const ClangExpressionVariable &) = delete;
|
||||
const ClangExpressionVariable &
|
||||
|
||||
@ -207,6 +207,8 @@ ClangFunctionCaller::CompileFunction(lldb::ThreadSP thread_to_use_sp,
|
||||
return num_errors;
|
||||
}
|
||||
|
||||
char ClangFunctionCaller::ClangFunctionCallerHelper::ID;
|
||||
|
||||
clang::ASTConsumer *
|
||||
ClangFunctionCaller::ClangFunctionCallerHelper::ASTTransformer(
|
||||
clang::ASTConsumer *passthrough) {
|
||||
|
||||
@ -57,11 +57,14 @@ class ASTStructExtractor;
|
||||
class ClangFunctionCaller : public FunctionCaller {
|
||||
friend class ASTStructExtractor;
|
||||
|
||||
class ClangFunctionCallerHelper : public ClangExpressionHelper {
|
||||
class ClangFunctionCallerHelper
|
||||
: public llvm::RTTIExtends<ClangFunctionCallerHelper,
|
||||
ClangExpressionHelper> {
|
||||
public:
|
||||
ClangFunctionCallerHelper(ClangFunctionCaller &owner) : m_owner(owner) {}
|
||||
// LLVM RTTI support
|
||||
static char ID;
|
||||
|
||||
~ClangFunctionCallerHelper() override = default;
|
||||
ClangFunctionCallerHelper(ClangFunctionCaller &owner) : m_owner(owner) {}
|
||||
|
||||
/// Return the object that the parser should use when resolving external
|
||||
/// values. May be NULL if everything should be self-contained.
|
||||
|
||||
@ -26,10 +26,11 @@
|
||||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
|
||||
char ClangPersistentVariables::ID;
|
||||
|
||||
ClangPersistentVariables::ClangPersistentVariables(
|
||||
std::shared_ptr<Target> target_sp)
|
||||
: lldb_private::PersistentExpressionState(LLVMCastKind::eKindClang),
|
||||
m_target_sp(target_sp) {}
|
||||
: m_target_sp(target_sp) {}
|
||||
|
||||
ExpressionVariableSP ClangPersistentVariables::CreatePersistentVariable(
|
||||
const lldb::ValueObjectSP &valobj_sp) {
|
||||
|
||||
@ -31,17 +31,17 @@ class TypeSystemClang;
|
||||
/// A list of variables that can be accessed and updated by any expression. See
|
||||
/// ClangPersistentVariable for more discussion. Also provides an increasing,
|
||||
/// 0-based counter for naming result variables.
|
||||
class ClangPersistentVariables : public PersistentExpressionState {
|
||||
class ClangPersistentVariables
|
||||
: public llvm::RTTIExtends<ClangPersistentVariables,
|
||||
PersistentExpressionState> {
|
||||
public:
|
||||
// LLVM RTTI support
|
||||
static char ID;
|
||||
|
||||
ClangPersistentVariables(std::shared_ptr<Target> target_sp);
|
||||
|
||||
~ClangPersistentVariables() override = default;
|
||||
|
||||
// llvm casting support
|
||||
static bool classof(const PersistentExpressionState *pv) {
|
||||
return pv->getKind() == PersistentExpressionState::eKindClang;
|
||||
}
|
||||
|
||||
std::shared_ptr<ClangASTImporter> GetClangASTImporter();
|
||||
std::shared_ptr<ClangModulesDeclVendor> GetClangModulesDeclVendor();
|
||||
|
||||
|
||||
@ -981,6 +981,8 @@ lldb::ExpressionVariableSP ClangUserExpression::GetResultAfterDematerialization(
|
||||
return m_result_delegate.GetVariable();
|
||||
}
|
||||
|
||||
char ClangUserExpression::ClangUserExpressionHelper::ID;
|
||||
|
||||
void ClangUserExpression::ClangUserExpressionHelper::ResetDeclMap(
|
||||
ExecutionContext &exe_ctx,
|
||||
Materializer::PersistentVariableDelegate &delegate,
|
||||
|
||||
@ -51,13 +51,16 @@ public:
|
||||
|
||||
enum { kDefaultTimeout = 500000u };
|
||||
|
||||
class ClangUserExpressionHelper : public ClangExpressionHelper {
|
||||
class ClangUserExpressionHelper
|
||||
: public llvm::RTTIExtends<ClangUserExpressionHelper,
|
||||
ClangExpressionHelper> {
|
||||
public:
|
||||
// LLVM RTTI support
|
||||
static char ID;
|
||||
|
||||
ClangUserExpressionHelper(Target &target, bool top_level)
|
||||
: m_target(target), m_top_level(top_level) {}
|
||||
|
||||
~ClangUserExpressionHelper() override = default;
|
||||
|
||||
/// Return the object that the parser should use when resolving external
|
||||
/// values. May be NULL if everything should be self-contained.
|
||||
ClangExpressionDeclMap *DeclMap() override {
|
||||
|
||||
@ -176,6 +176,8 @@ bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager,
|
||||
}
|
||||
}
|
||||
|
||||
char ClangUtilityFunction::ClangUtilityFunctionHelper::ID;
|
||||
|
||||
void ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap(
|
||||
ExecutionContext &exe_ctx, bool keep_result_in_memory) {
|
||||
std::shared_ptr<ClangASTImporter> ast_importer;
|
||||
|
||||
@ -72,11 +72,12 @@ public:
|
||||
ExecutionContext &exe_ctx) override;
|
||||
|
||||
private:
|
||||
class ClangUtilityFunctionHelper : public ClangExpressionHelper {
|
||||
class ClangUtilityFunctionHelper
|
||||
: public llvm::RTTIExtends<ClangUtilityFunctionHelper,
|
||||
ClangExpressionHelper> {
|
||||
public:
|
||||
ClangUtilityFunctionHelper() = default;
|
||||
|
||||
~ClangUtilityFunctionHelper() override = default;
|
||||
// LLVM RTTI support
|
||||
static char ID;
|
||||
|
||||
/// Return the object that the parser should use when resolving external
|
||||
/// values. May be NULL if everything should be self-contained.
|
||||
|
||||
@ -15,8 +15,10 @@ using namespace lldb_private;
|
||||
|
||||
LLDB_PLUGIN_DEFINE(ClangREPL)
|
||||
|
||||
char ClangREPL::ID;
|
||||
|
||||
ClangREPL::ClangREPL(lldb::LanguageType language, Target &target)
|
||||
: REPL(eKindClang, target), m_language(language),
|
||||
: llvm::RTTIExtends<ClangREPL, REPL>(target), m_language(language),
|
||||
m_implicit_expr_result_regex("\\$[0-9]+") {}
|
||||
|
||||
ClangREPL::~ClangREPL() = default;
|
||||
|
||||
@ -14,8 +14,11 @@
|
||||
namespace lldb_private {
|
||||
/// Implements a Clang-based REPL for C languages on top of LLDB's REPL
|
||||
/// framework.
|
||||
class ClangREPL : public REPL {
|
||||
class ClangREPL : public llvm::RTTIExtends<ClangREPL, REPL> {
|
||||
public:
|
||||
// LLVM RTTI support
|
||||
static char ID;
|
||||
|
||||
ClangREPL(lldb::LanguageType language, Target &target);
|
||||
|
||||
~ClangREPL() override;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user