clang::Decl *DeportDecl(clang::ASTContext *dst_ctx,
clang::ASTContext *src_ctx, clang::Decl *decl);
- void InsertRecordDecl(clang::RecordDecl *decl, const LayoutInfo &layout);
+ /// Sets the layout for the given RecordDecl. The layout will later be
+ /// used by Clang's during code generation. Not calling this function for
+ /// a RecordDecl will cause that Clang's codegen tries to layout the
+ /// record by itself.
+ ///
+ /// \param decl The RecordDecl to set the layout for.
+ /// \param layout The layout for the record.
+ void SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo &layout);
bool LayoutRecordType(
const clang::RecordDecl *record_decl, uint64_t &bit_size,
ClangASTContext::GetAsRecordDecl(clang_type);
if (record_decl) {
- GetClangASTImporter().InsertRecordDecl(
+ GetClangASTImporter().SetRecordLayout(
record_decl, ClangASTImporter::LayoutInfo());
}
}
clang::CXXRecordDecl *record_decl =
m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
if (record_decl)
- GetClangASTImporter().InsertRecordDecl(record_decl, layout_info);
+ GetClangASTImporter().SetRecordLayout(record_decl, layout_info);
}
return (bool)clang_type;
ClangASTContext::CompleteTagDeclarationDefinition(m_derived_ct);
if (auto *record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(&m_tag_decl)) {
- m_ast_builder.importer().InsertRecordDecl(record_decl, m_layout);
+ m_ast_builder.importer().SetRecordLayout(record_decl, m_layout);
}
}
if (!record_decl)
return static_cast<bool>(compiler_type);
- GetClangASTImporter().InsertRecordDecl(record_decl, layout_info);
+ GetClangASTImporter().SetRecordLayout(record_decl, layout_info);
return static_cast<bool>(compiler_type);
}
return success;
}
-void ClangASTImporter::InsertRecordDecl(clang::RecordDecl *decl,
+void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl,
const LayoutInfo &layout) {
m_record_decl_to_layout_map.insert(std::make_pair(decl, layout));
}
layout_info.bit_size = 15;
layout_info.alignment = 2;
layout_info.field_offsets[field] = 1;
- importer.InsertRecordDecl(source_record, layout_info);
+ importer.SetRecordLayout(source_record, layout_info);
uint64_t bit_size;
uint64_t alignment;