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]
Collaboration diagram for lldb_private::ClangExpressionSourceCode:
Collaboration graph
[legend]

Public Types

enum  WrapKind { WrapKind::CppMemberFunction, WrapKind::ObjCInstanceMethod, WrapKind::ObjCStaticMethod, WrapKind::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. More...
 
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. More...
 
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 (const lldb::VariableListSP &var_list_sp, StreamString &stream, const std::string &expr) const
 

Private Attributes

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

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 179 of file ClangExpressionSourceCode.cpp.

References g_expression_suffix, m_end_marker, and m_start_marker.

Referenced by CreateWrapped().

Member Function Documentation

◆ AddLocalVariableDecls()

void ClangExpressionSourceCode::AddLocalVariableDecls ( const lldb::VariableListSP &  var_list_sp,
StreamString stream,
const std::string expr 
) const
private

◆ 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 477 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 299 of file ClangExpressionSourceCode.cpp.

References AddLocalVariableDecls(), AddMacros(), lldb_private::SymbolContext::comp_unit, CppMemberFunction, lldb::eLanguageTypeC, lldb_private::LineEntry::file, Function, g_expression_prefix, lldb_private::Target::GetArchitecture(), lldb_private::StreamString::GetData(), lldb_private::CompileUnit::GetDebugMacros(), lldb_private::TargetProperties::GetEnableAutoImportClangModules(), 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::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, lldb_private::Stream::Printf(), and string().

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"

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.

◆ m_end_marker

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

String marking the end of the user expression.

Definition at line 88 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 86 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 90 of file ClangExpressionSourceCode.h.

Referenced by AddLocalVariableDecls(), and GetText().


The documentation for this class was generated from the following files:
SUFFIX_NAME
#define SUFFIX_NAME
Definition: ClangExpressionSourceCode.cpp:34