LLDB mainline
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
lldb_private::ClangExpressionSourceCode Class Reference

#include <ClangExpressionSourceCode.h>

Inheritance diagram for lldb_private::ClangExpressionSourceCode:
Inheritance graph
[legend]

Public Types

enum class  WrapKind { CppMemberFunction , ObjCInstanceMethod , ObjCStaticMethod , Function }
 The possible ways an expression can be wrapped. More...
 

Public Member Functions

bool GetText (std::string &text, ExecutionContext &exe_ctx, bool add_locals, bool force_add_all_locals, llvm::ArrayRef< std::string > modules) const
 Generates the source code that will evaluate the expression.
 
bool GetOriginalBodyBounds (std::string transformed_text, size_t &start_loc, size_t &end_loc)
 
- Public Member Functions inherited from lldb_private::ExpressionSourceCode
bool NeedsWrapping () const
 
const char * GetName () const
 

Static Public Member Functions

static ClangExpressionSourceCodeCreateWrapped (llvm::StringRef filename, llvm::StringRef prefix, llvm::StringRef body, WrapKind wrap_kind)
 

Static Public Attributes

static const llvm::StringRef g_prefix_file_name = PREFIX_NAME
 The file name we use for the wrapper code that we inject before the user expression.
 
static const char * g_expression_prefix
 
static const char * g_expression_suffix
 

Protected Member Functions

 ClangExpressionSourceCode (llvm::StringRef filename, llvm::StringRef name, llvm::StringRef prefix, llvm::StringRef body, Wrapping wrap, WrapKind wrap_kind)
 
- Protected Member Functions inherited from lldb_private::ExpressionSourceCode
 ExpressionSourceCode (llvm::StringRef name, llvm::StringRef prefix, llvm::StringRef body, Wrapping wrap)
 

Private Member Functions

void AddLocalVariableDecls (StreamString &stream, const std::string &expr, StackFrame *frame) const
 Writes "using" declarations for local variables into the specified stream.
 

Private Attributes

std::string m_start_marker
 String marking the start of the user expression.
 
std::string m_end_marker
 String marking the end of the user expression.
 
const WrapKind m_wrap_kind
 How the expression has been wrapped.
 

Additional Inherited Members

- Protected Types inherited from lldb_private::ExpressionSourceCode
enum  Wrapping : bool { Wrap = true , NoWrap = false }
 
- Protected Attributes inherited from lldb_private::ExpressionSourceCode
std::string m_name
 
std::string m_prefix
 
std::string m_body
 
Wrapping m_wrap
 

Detailed Description

Definition at line 24 of file ClangExpressionSourceCode.h.

Member Enumeration Documentation

◆ WrapKind

The possible ways an expression can be wrapped.

Enumerator
CppMemberFunction 

Wrapped in a non-static member function of a C++ class.

ObjCInstanceMethod 

Wrapped in an instance Objective-C method.

ObjCStaticMethod 

Wrapped in a static Objective-C method.

Function 

Wrapped in a non-member function.

Note that this is also used for static member functions of a C++ class.

Definition at line 33 of file ClangExpressionSourceCode.h.

Constructor & Destructor Documentation

◆ ClangExpressionSourceCode()

lldb_private::ClangExpressionSourceCode::ClangExpressionSourceCode ( llvm::StringRef  filename,
llvm::StringRef  name,
llvm::StringRef  prefix,
llvm::StringRef  body,
Wrapping  wrap,
WrapKind  wrap_kind 
)
protected

Definition at line 193 of file ClangExpressionSourceCode.cpp.

References g_expression_suffix, m_end_marker, and m_start_marker.

Member Function Documentation

◆ AddLocalVariableDecls()

void ClangExpressionSourceCode::AddLocalVariableDecls ( StreamString stream,
const std::string &  expr,
StackFrame frame 
) const
private

Writes "using" declarations for local variables into the specified stream.

Behaviour is undefined if 'frame == nullptr'.

Parameters
[out]streamStream that this function generates "using" declarations into.
[in]exprExpression source that we're evaluating.
[in]frameStackFrame which carries information about the local variables that we're generating "using" declarations for.

Definition at line 310 of file ClangExpressionSourceCode.cpp.

References lldb_private::ConstString::AsCString(), CppMemberFunction, lldb_private::StackFrame::GetInScopeVariableList(), lldb_private::ConstString::GetStringRef(), m_wrap_kind, ObjCInstanceMethod, ObjCStaticMethod, and lldb_private::Stream::Printf().

Referenced by GetText().

◆ CreateWrapped()

static ClangExpressionSourceCode * lldb_private::ClangExpressionSourceCode::CreateWrapped ( llvm::StringRef  filename,
llvm::StringRef  prefix,
llvm::StringRef  body,
WrapKind  wrap_kind 
)
inlinestatic

◆ GetOriginalBodyBounds()

bool ClangExpressionSourceCode::GetOriginalBodyBounds ( std::string  transformed_text,
size_t &  start_loc,
size_t &  end_loc 
)

Definition at line 521 of file ClangExpressionSourceCode.cpp.

References m_end_marker, and m_start_marker.

◆ GetText()

bool ClangExpressionSourceCode::GetText ( std::string &  text,
ExecutionContext exe_ctx,
bool  add_locals,
bool  force_add_all_locals,
llvm::ArrayRef< std::string >  modules 
) const

Generates the source code that will evaluate the expression.

Parameters
textoutput parameter containing the source code string.
exe_ctxThe execution context in which the expression will be evaluated.
add_localsTrue iff local variables should be injected into the expression source code.
force_add_all_localsTrue iff all local variables should be injected even if they are not used in the expression.
modulesA list of (C++) modules that the expression should import.
Returns
true iff the source code was successfully generated.

Definition at line 346 of file ClangExpressionSourceCode.cpp.

References AddLocalVariableDecls(), AddMacros(), lldb_private::SymbolContext::comp_unit, CppMemberFunction, lldb::eLanguageTypeC, Function, g_expression_prefix, lldb_private::Target::GetArchitecture(), lldb_private::StreamString::GetData(), lldb_private::CompileUnit::GetDebugMacros(), lldb_private::TargetProperties::GetEnableAutoImportClangModules(), lldb_private::LineEntry::GetFile(), lldb_private::StackFrame::GetFrameBlock(), lldb_private::ExecutionContext::GetFramePtr(), lldb_private::TargetProperties::GetInjectLocalVariables(), lldb_private::ArchSpec::GetMachine(), lldb_private::Target::GetPersistentExpressionStateForLanguage(), lldb_private::Target::GetPlatform(), lldb_private::StreamString::GetString(), lldb_private::StackFrame::GetSymbolContext(), lldb_private::ExecutionContext::GetTargetPtr(), lldb_private::LineEntry::IsValid(), lldb_private::LineEntry::line, lldb_private::SymbolContext::line_entry, lldb_private::ExpressionSourceCode::m_body, m_end_marker, lldb_private::ExpressionSourceCode::m_name, lldb_private::ExpressionSourceCode::m_prefix, m_start_marker, lldb_private::ExpressionSourceCode::m_wrap, m_wrap_kind, ObjCInstanceMethod, ObjCStaticMethod, and lldb_private::Stream::Printf().

Member Data Documentation

◆ g_expression_prefix

const char * ClangExpressionSourceCode::g_expression_prefix
static

◆ g_expression_suffix

const char * ClangExpressionSourceCode::g_expression_suffix
static
Initial value:
=
"\n;\n#line 1 \"" SUFFIX_NAME "\"\n"
#define SUFFIX_NAME

Definition at line 30 of file ClangExpressionSourceCode.h.

Referenced by ClangExpressionSourceCode(), and lldb_private::ClangUtilityFunction::ClangUtilityFunction().

◆ g_prefix_file_name

const llvm::StringRef ClangExpressionSourceCode::g_prefix_file_name = PREFIX_NAME
static

The file name we use for the wrapper code that we inject before the user expression.

Definition at line 28 of file ClangExpressionSourceCode.h.

Referenced by lldb_private::ClangExpressionParser::LLDBPreprocessorCallbacks::moduleImport().

◆ m_end_marker

std::string lldb_private::ClangExpressionSourceCode::m_end_marker
private

String marking the end of the user expression.

Definition at line 98 of file ClangExpressionSourceCode.h.

Referenced by ClangExpressionSourceCode(), GetOriginalBodyBounds(), and GetText().

◆ m_start_marker

std::string lldb_private::ClangExpressionSourceCode::m_start_marker
private

String marking the start of the user expression.

Definition at line 96 of file ClangExpressionSourceCode.h.

Referenced by ClangExpressionSourceCode(), GetOriginalBodyBounds(), and GetText().

◆ m_wrap_kind

const WrapKind lldb_private::ClangExpressionSourceCode::m_wrap_kind
private

How the expression has been wrapped.

Definition at line 100 of file ClangExpressionSourceCode.h.

Referenced by AddLocalVariableDecls(), and GetText().


The documentation for this class was generated from the following files: