LLDB  mainline
Public Member Functions | List of all members
lldb_private::ASTStructExtractor Class Reference

"lldb/Expression/ASTStructExtractor.h" Extracts and describes the argument structure for a wrapped function. More...

#include <ASTStructExtractor.h>

Inheritance diagram for lldb_private::ASTStructExtractor:
Inheritance graph
[legend]
Collaboration diagram for lldb_private::ASTStructExtractor:
Collaboration graph
[legend]

Public Member Functions

 ASTStructExtractor (clang::ASTConsumer *passthrough, const char *struct_name, ClangFunctionCaller &function)
 Constructor. More...
 
 ~ASTStructExtractor () override
 Destructor. More...
 
void Initialize (clang::ASTContext &Context) override
 Link this consumer with a particular AST context. More...
 
bool HandleTopLevelDecl (clang::DeclGroupRef D) override
 Examine a list of Decls to find the function $__lldb_expr and transform its code. More...
 
void HandleTranslationUnit (clang::ASTContext &Ctx) override
 Passthrough stub. More...
 
void HandleTagDeclDefinition (clang::TagDecl *D) override
 Passthrough stub. More...
 
void CompleteTentativeDefinition (clang::VarDecl *D) override
 Passthrough stub. More...
 
void HandleVTable (clang::CXXRecordDecl *RD) override
 Passthrough stub. More...
 
void PrintStats () override
 Passthrough stub. More...
 
void InitializeSema (clang::Sema &S) override
 Set the Sema object to use when performing transforms, and pass it on. More...
 
void ForgetSema () override
 Reset the Sema to NULL now that transformations are done. More...
 

Detailed Description

"lldb/Expression/ASTStructExtractor.h" Extracts and describes the argument structure for a wrapped function.

This pass integrates with ClangFunctionCaller, which calls functions with custom sets of arguments. To avoid having to implement the full calling convention for the target's architecture, ClangFunctionCaller writes a simple wrapper function that takes a pointer to an argument structure that contains room for the address of the function to be called, the values of all its arguments, and room for the function's return value.

The definition of this struct is itself in the body of the wrapper function, so Clang does the structure layout itself. ASTStructExtractor reads through the AST for the wrapper function and finds the struct.

Definition at line 34 of file ASTStructExtractor.h.

Constructor & Destructor Documentation

◆ ASTStructExtractor()

ASTStructExtractor::ASTStructExtractor ( clang::ASTConsumer *  passthrough,
const char *  struct_name,
ClangFunctionCaller function 
)

Constructor.

Parameters
[in]passthroughSince the ASTs must typically go through to the Clang code generator in order to produce LLVM IR, this SemaConsumer must allow them to pass to the next step in the chain after processing. Passthrough is the next ASTConsumer, or NULL if none is required.
[in]struct_nameThe name of the structure to extract from the wrapper function.
[in]functionThe caller object whose members should be populated with information about the argument struct. ClangFunctionCaller friends ASTStructExtractor for this purpose.

Definition at line 29 of file ASTStructExtractor.cpp.

◆ ~ASTStructExtractor()

ASTStructExtractor::~ASTStructExtractor ( )
override

Destructor.

Definition at line 41 of file ASTStructExtractor.cpp.

Member Function Documentation

◆ CompleteTentativeDefinition()

void ASTStructExtractor::CompleteTentativeDefinition ( clang::VarDecl *  D)
override

Passthrough stub.

Definition at line 156 of file ASTStructExtractor.cpp.

◆ ForgetSema()

void ASTStructExtractor::ForgetSema ( )
override

Reset the Sema to NULL now that transformations are done.

Definition at line 179 of file ASTStructExtractor.cpp.

◆ HandleTagDeclDefinition()

void ASTStructExtractor::HandleTagDeclDefinition ( clang::TagDecl *  D)
override

Passthrough stub.

Definition at line 151 of file ASTStructExtractor.cpp.

◆ HandleTopLevelDecl()

bool ASTStructExtractor::HandleTopLevelDecl ( clang::DeclGroupRef  D)
override

Examine a list of Decls to find the function $__lldb_expr and transform its code.

Parameters
[in]DThe list of Decls to search. These may contain LinkageSpecDecls, which need to be searched recursively. That job falls to TransformTopLevelDecl.

Definition at line 132 of file ASTStructExtractor.cpp.

◆ HandleTranslationUnit()

void ASTStructExtractor::HandleTranslationUnit ( clang::ASTContext &  Ctx)
override

Passthrough stub.

Definition at line 146 of file ASTStructExtractor.cpp.

◆ HandleVTable()

void ASTStructExtractor::HandleVTable ( clang::CXXRecordDecl *  RD)
override

Passthrough stub.

Definition at line 161 of file ASTStructExtractor.cpp.

◆ Initialize()

void ASTStructExtractor::Initialize ( clang::ASTContext &  Context)
override

Link this consumer with a particular AST context.

Parameters
[in]ContextThis AST context will be used for types and identifiers, and also forwarded to the passthrough consumer, if one exists.

Definition at line 43 of file ASTStructExtractor.cpp.

References lldb_private::FunctionCaller::m_member_offsets, lldb_private::FunctionCaller::m_return_offset, lldb_private::FunctionCaller::m_return_size, lldb_private::FunctionCaller::m_struct_size, lldb_private::FunctionCaller::m_struct_valid, and lldb_private::FunctionCaller::m_wrapper_function_name.

◆ InitializeSema()

void ASTStructExtractor::InitializeSema ( clang::Sema &  S)
override

Set the Sema object to use when performing transforms, and pass it on.

Parameters
[in]SThe Sema to use. Because Sema isn't externally visible, this class casts it to an Action for actual use.

Definition at line 171 of file ASTStructExtractor.cpp.

◆ PrintStats()

void ASTStructExtractor::PrintStats ( )
override

Passthrough stub.

Definition at line 166 of file ASTStructExtractor.cpp.


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