12#include "clang/AST/ASTContext.h"
13#include "clang/AST/Decl.h"
14#include "clang/AST/DeclCXX.h"
15#include "clang/AST/DeclGroup.h"
16#include "clang/AST/Expr.h"
17#include "clang/AST/RecordLayout.h"
18#include "clang/AST/Stmt.h"
19#include "clang/Parse/Parser.h"
20#include "clang/Sema/Sema.h"
21#include "llvm/Support/Casting.h"
22#include "llvm/Support/raw_ostream.h"
30 const char *struct_name,
32 : m_ast_context(nullptr), m_passthrough(passthrough),
33 m_passthrough_sema(nullptr), m_sema(nullptr), m_function(function),
34 m_struct_name(struct_name) {
54 Stmt *body_stmt = F->getBody();
55 CompoundStmt *body_compound_stmt = dyn_cast<CompoundStmt>(body_stmt);
57 if (!body_compound_stmt)
60 RecordDecl *struct_decl =
nullptr;
64 for (CompoundStmt::const_body_iterator bi = body_compound_stmt->body_begin(),
65 be = body_compound_stmt->body_end();
67 Stmt *curr_stmt = *bi;
68 DeclStmt *curr_decl_stmt = dyn_cast<DeclStmt>(curr_stmt);
71 DeclGroupRef decl_group = curr_decl_stmt->getDeclGroup();
72 for (Decl *candidate_decl : decl_group) {
73 RecordDecl *candidate_record_decl = dyn_cast<RecordDecl>(candidate_decl);
74 if (!candidate_record_decl)
76 if (candidate_record_decl->getName() == desired_name) {
77 struct_decl = candidate_record_decl;
88 const ASTRecordLayout *struct_layout(
95 struct_layout->getSize()
98 struct_layout->getFieldOffset(struct_layout->getFieldCount() - 1) / 8;
102 for (
unsigned field_index = 0, num_fields = struct_layout->getFieldCount();
103 field_index < num_fields; ++field_index) {
105 struct_layout->getFieldOffset(field_index) / 8);
112 LinkageSpecDecl *linkage_spec_decl = dyn_cast<LinkageSpecDecl>(D);
114 if (linkage_spec_decl) {
115 RecordDecl::decl_iterator decl_iterator;
117 for (decl_iterator = linkage_spec_decl->decls_begin();
118 decl_iterator != linkage_spec_decl->decls_end(); ++decl_iterator) {
123 FunctionDecl *function_decl = dyn_cast<FunctionDecl>(D);
127 function_decl->getNameAsString())) {
133 DeclGroupRef::iterator decl_iterator;
135 for (decl_iterator = D.begin(); decl_iterator != D.end(); ++decl_iterator) {
136 Decl *decl = *decl_iterator;
"lldb/Expression/ClangFunctionCaller.h" Encapsulates a function that can be called.
size_t m_struct_size
These values are populated by the ASTStructExtractor.
uint64_t m_return_offset
The offset of the result variable in the struct, in bytes.
bool m_struct_valid
True if the ASTStructExtractor has populated the variables below.
std::string m_wrapper_function_name
The name of the wrapper function.
uint64_t m_return_size
The size of the result variable, in bytes.
std::vector< uint64_t > m_member_offsets
The offset of each member in the struct, in bytes.
A class that represents a running process on the host machine.