LLDB mainline
|
"lldb/Expression/ASTStructExtractor.h" Extracts and describes the argument structure for a wrapped function. More...
#include <ASTStructExtractor.h>
Public Member Functions | |
ASTStructExtractor (clang::ASTConsumer *passthrough, const char *struct_name, ClangFunctionCaller &function) | |
Constructor. | |
~ASTStructExtractor () override | |
Destructor. | |
void | Initialize (clang::ASTContext &Context) override |
Link this consumer with a particular AST context. | |
bool | HandleTopLevelDecl (clang::DeclGroupRef D) override |
Examine a list of Decls to find the function $__lldb_expr and transform its code. | |
void | HandleTranslationUnit (clang::ASTContext &Ctx) override |
Passthrough stub. | |
void | HandleTagDeclDefinition (clang::TagDecl *D) override |
Passthrough stub. | |
void | CompleteTentativeDefinition (clang::VarDecl *D) override |
Passthrough stub. | |
void | HandleVTable (clang::CXXRecordDecl *RD) override |
Passthrough stub. | |
void | PrintStats () override |
Passthrough stub. | |
void | InitializeSema (clang::Sema &S) override |
Set the Sema object to use when performing transforms, and pass it on. | |
void | ForgetSema () override |
Reset the Sema to NULL now that transformations are done. | |
Private Member Functions | |
void | ExtractFromFunctionDecl (clang::FunctionDecl *F) |
Hunt the given FunctionDecl for the argument struct and place information about it into m_function. | |
void | ExtractFromTopLevelDecl (clang::Decl *D) |
Hunt the given Decl for FunctionDecls named the same as the wrapper function name, recursing as necessary through LinkageSpecDecls, and calling ExtractFromFunctionDecl on anything that was found. | |
Private Attributes | |
clang::ASTContext * | m_ast_context |
The AST context to use for identifiers and types. | |
clang::ASTConsumer * | m_passthrough |
The ASTConsumer down the chain, for passthrough. | |
clang::SemaConsumer * | m_passthrough_sema |
The SemaConsumer down the chain, for passthrough. | |
clang::Sema * | m_sema |
The Sema to use. | |
ClangFunctionCaller & | m_function |
The function to populate with information about the argument structure. | |
std::string | m_struct_name |
The name of the structure to extract. | |
"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 33 of file ASTStructExtractor.h.
ASTStructExtractor::ASTStructExtractor | ( | clang::ASTConsumer * | passthrough, |
const char * | struct_name, | ||
ClangFunctionCaller & | function | ||
) |
Constructor.
[in] | passthrough | Since 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_name | The name of the structure to extract from the wrapper function. |
[in] | function | The 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.
References m_passthrough, and m_passthrough_sema.
|
overridedefault |
Destructor.
|
override |
|
private |
Hunt the given FunctionDecl for the argument struct and place information about it into m_function.
[in] | F | The FunctionDecl to hunt. |
Definition at line 50 of file ASTStructExtractor.cpp.
References m_ast_context, m_function, lldb_private::FunctionCaller::m_member_offsets, lldb_private::FunctionCaller::m_return_offset, lldb_private::FunctionCaller::m_return_size, m_struct_name, lldb_private::FunctionCaller::m_struct_size, and lldb_private::FunctionCaller::m_struct_valid.
Referenced by ExtractFromTopLevelDecl().
|
private |
Hunt the given Decl for FunctionDecls named the same as the wrapper function name, recursing as necessary through LinkageSpecDecls, and calling ExtractFromFunctionDecl on anything that was found.
[in] | D | The Decl to hunt. |
Definition at line 111 of file ASTStructExtractor.cpp.
References ExtractFromFunctionDecl(), ExtractFromTopLevelDecl(), m_ast_context, m_function, and lldb_private::FunctionCaller::m_wrapper_function_name.
Referenced by ExtractFromTopLevelDecl(), and HandleTopLevelDecl().
|
override |
Reset the Sema to NULL now that transformations are done.
Definition at line 178 of file ASTStructExtractor.cpp.
References m_passthrough_sema, and m_sema.
|
override |
|
override |
Examine a list of Decls to find the function $__lldb_expr and transform its code.
[in] | D | The 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.
References ExtractFromTopLevelDecl(), and m_passthrough.
|
override |
|
override |
|
override |
Link this consumer with a particular AST context.
[in] | Context | This 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 m_ast_context, and m_passthrough.
|
override |
Set the Sema object to use when performing transforms, and pass it on.
[in] | S | The 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.
References m_passthrough_sema, and m_sema.
|
override |
|
private |
The AST context to use for identifiers and types.
Definition at line 115 of file ASTStructExtractor.h.
Referenced by ExtractFromFunctionDecl(), ExtractFromTopLevelDecl(), and Initialize().
|
private |
The function to populate with information about the argument structure.
Definition at line 124 of file ASTStructExtractor.h.
Referenced by ExtractFromFunctionDecl(), and ExtractFromTopLevelDecl().
|
private |
The ASTConsumer down the chain, for passthrough.
NULL if it's a SemaConsumer.
Definition at line 116 of file ASTStructExtractor.h.
Referenced by ASTStructExtractor(), CompleteTentativeDefinition(), HandleTagDeclDefinition(), HandleTopLevelDecl(), HandleTranslationUnit(), HandleVTable(), Initialize(), and PrintStats().
|
private |
The SemaConsumer down the chain, for passthrough.
NULL if it's an ASTConsumer.
Definition at line 119 of file ASTStructExtractor.h.
Referenced by ASTStructExtractor(), ForgetSema(), and InitializeSema().
|
private |
The Sema to use.
Definition at line 122 of file ASTStructExtractor.h.
Referenced by ForgetSema(), and InitializeSema().
|
private |
The name of the structure to extract.
Definition at line 126 of file ASTStructExtractor.h.
Referenced by ExtractFromFunctionDecl().