13#include "clang/AST/Decl.h"
14#include "clang/AST/DeclCXX.h"
15#include "clang/AST/DeclObjC.h"
16#include "clang/Sema/Lookup.h"
17#include "clang/Sema/Sema.h"
18#include "llvm/Support/raw_ostream.h"
41 clang::ASTContext &src_clang_ast = src_ast->getASTContext();
51 llvm::Expected<QualType> ret_or_error = delegate_sp->Import(src_qual_type);
55 "Couldn't import type: {0}");
62 return CompilerType(dst_ast.weak_from_this(), dst_clang_type);
70 clang::ASTContext *src_ast = &decl->getASTContext();
78 llvm::Expected<clang::Decl *> result = delegate_sp->Import(decl);
81 LLDB_LOG_ERROR(log, result.takeError(),
"Couldn't import decl: {0}");
88 if (NamedDecl *named_decl = dyn_cast<NamedDecl>(decl))
90 " [ClangASTImporter] WARNING: Failed to import a {0} "
91 "'{1}', metadata {2}",
92 decl->getDeclKindName(), named_decl->getNameAsString(),
96 " [ClangASTImporter] WARNING: Failed to import a {0}, "
98 decl->getDeclKindName(), user_id);
116 if (m_backups.contains(decl)) {
120 m_backups[decl] = {decl->getDeclContext(), decl->getLexicalDeclContext()};
122 decl->setDeclContext(decl->getASTContext().getTranslationUnitDecl());
123 decl->setLexicalDeclContext(decl->getASTContext().getTranslationUnitDecl());
127 clang::Decl *decl, clang::DeclContext *base,
128 clang::DeclContext *(clang::Decl::*contextFromDecl)(),
129 clang::DeclContext *(clang::DeclContext::*contextFromContext)()) {
130 for (DeclContext *decl_ctx = (decl->*contextFromDecl)(); decl_ctx;
131 decl_ctx = (decl_ctx->*contextFromContext)()) {
132 if (decl_ctx == base) {
141 clang::DeclContext *base =
nullptr) {
145 if (!ChainPassesThrough(decl, base, &clang::Decl::getDeclContext,
146 &clang::DeclContext::getParent) ||
147 !ChainPassesThrough(decl, base, &clang::Decl::getLexicalDeclContext,
148 &clang::DeclContext::getLexicalParent)) {
152 base = clang::dyn_cast<clang::DeclContext>(decl);
159 if (clang::DeclContext *context =
160 clang::dyn_cast<clang::DeclContext>(decl)) {
161 for (clang::Decl *decl : context->decls()) {
162 if (clang::Decl *escaped_child = GetEscapedChild(decl)) {
163 return escaped_child;
172 if (clang::Decl *escaped_child = GetEscapedChild(decl)) {
176 " [ClangASTImporter] DeclContextOverride couldn't "
177 "override ({0}Decl*){1} - its child ({2}Decl*){3} escapes",
178 decl->getDeclKindName(), decl, escaped_child->getDeclKindName(),
190 for (DeclContext *decl_context = decl->getLexicalDeclContext();
191 decl_context; decl_context = decl_context->getLexicalParent()) {
192 DeclContext *redecl_context = decl_context->getRedeclContext();
194 if (llvm::isa<FunctionDecl>(redecl_context) &&
195 llvm::isa<TranslationUnitDecl>(redecl_context->getLexicalParent())) {
196 for (clang::Decl *child_decl : decl_context->decls()) {
197 Override(child_decl);
204 for (
const std::pair<clang::Decl *, Backup> &backup : m_backups) {
205 backup.first->setDeclContext(backup.second.decl_context);
206 backup.first->setLexicalDeclContext(backup.second.lexical_decl_context);
222 llvm::SetVector<NamedDecl *> m_decls_to_complete;
225 llvm::SmallPtrSet<NamedDecl *, 32> m_decls_already_completed;
226 clang::ASTContext *m_dst_ctx;
227 clang::ASTContext *m_src_ctx;
236 clang::ASTContext *dst_ctx,
237 clang::ASTContext *src_ctx)
238 : m_delegate(importer.GetDelegate(dst_ctx, src_ctx)), m_dst_ctx(dst_ctx),
239 m_src_ctx(src_ctx), importer(importer) {
240 m_delegate->SetImportListener(
this);
243 ~CompleteTagDeclsScope()
override {
248 while (!m_decls_to_complete.empty()) {
249 NamedDecl *decl = m_decls_to_complete.pop_back_val();
250 m_decls_already_completed.insert(decl);
254 assert(to_context_md->hasOrigin(decl));
256 assert(to_context_md->getOrigin(decl).ctx == m_src_ctx);
258 Decl *original_decl = to_context_md->getOrigin(decl).decl;
262 if (
auto *tag_decl = dyn_cast<TagDecl>(decl)) {
263 if (
auto *original_tag_decl = dyn_cast<TagDecl>(original_decl)) {
264 if (original_tag_decl->isCompleteDefinition()) {
265 m_delegate->ImportDefinitionTo(tag_decl, original_tag_decl);
266 tag_decl->setCompleteDefinition(
true);
270 tag_decl->setHasExternalLexicalStorage(
false);
271 tag_decl->setHasExternalVisibleStorage(
false);
272 }
else if (
auto *container_decl = dyn_cast<ObjCContainerDecl>(decl)) {
273 container_decl->setHasExternalLexicalStorage(
false);
274 container_decl->setHasExternalVisibleStorage(
false);
277 to_context_md->removeOrigin(decl);
282 m_delegate->RemoveImportListener();
285 void NewDeclImported(clang::Decl *from, clang::Decl *to)
override {
287 if (!isa<TagDecl>(to) && !isa<ObjCInterfaceDecl>(to))
289 RecordDecl *from_record_decl = dyn_cast<RecordDecl>(from);
291 if (from_record_decl && from_record_decl->isInjectedClassName())
294 NamedDecl *to_named_decl = dyn_cast<NamedDecl>(to);
296 if (m_decls_already_completed.contains(to_named_decl))
299 m_decls_to_complete.insert(to_named_decl);
313 " [ClangASTImporter] DeportType called on ({0}Type*){1} "
314 "from (ASTContext*){2} to (ASTContext*){3}",
323 CompleteTagDeclsScope complete_scope(*
this, &dst.
getASTContext(),
324 &src_ctxt->getASTContext());
332 clang::ASTContext *src_ctx = &decl->getASTContext();
334 " [ClangASTImporter] DeportDecl called on ({0}Decl*){1} from "
335 "(ASTContext*){2} to (ASTContext*){3}",
336 decl->getDeclKindName(), decl, src_ctx, dst_ctx);
344 CompleteTagDeclsScope complete_scope(*
this, dst_ctx, src_ctx);
352 " [ClangASTImporter] DeportDecl deported ({0}Decl*){1} to "
354 decl->getDeclKindName(), decl, result->getDeclKindName(), result);
363 clang::QualType qual_type(
366 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
367 switch (type_class) {
368 case clang::Type::Record: {
369 const clang::CXXRecordDecl *cxx_record_decl =
370 qual_type->getAsCXXRecordDecl();
371 if (cxx_record_decl) {
377 case clang::Type::Enum: {
378 clang::EnumDecl *enum_decl =
379 llvm::cast<clang::EnumType>(qual_type)->getDecl();
386 case clang::Type::ObjCObject:
387 case clang::Type::ObjCInterface: {
388 const clang::ObjCObjectType *objc_class_type =
389 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
390 if (objc_class_type) {
391 clang::ObjCInterfaceDecl *class_interface_decl =
392 objc_class_type->getInterface();
395 if (class_interface_decl) {
402 case clang::Type::Typedef:
404 llvm::cast<clang::TypedefType>(qual_type)
406 ->getUnderlyingType()
409 case clang::Type::Auto:
411 llvm::cast<clang::AutoType>(qual_type)
415 case clang::Type::Elaborated:
417 llvm::cast<clang::ElaboratedType>(qual_type)
421 case clang::Type::Paren:
424 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
437 clang::QualType qual_type(
440 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
441 switch (type_class) {
442 case clang::Type::Record: {
443 const clang::CXXRecordDecl *cxx_record_decl =
444 qual_type->getAsCXXRecordDecl();
445 if (cxx_record_decl) {
451 case clang::Type::Enum: {
452 clang::EnumDecl *enum_decl =
453 llvm::cast<clang::EnumType>(qual_type)->getDecl();
460 case clang::Type::ObjCObject:
461 case clang::Type::ObjCInterface: {
462 const clang::ObjCObjectType *objc_class_type =
463 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
464 if (objc_class_type) {
465 clang::ObjCInterfaceDecl *class_interface_decl =
466 objc_class_type->getInterface();
469 if (class_interface_decl) {
476 case clang::Type::Typedef:
478 llvm::cast<clang::TypedefType>(qual_type)
480 ->getUnderlyingType()
483 case clang::Type::Auto:
485 llvm::cast<clang::AutoType>(qual_type)
489 case clang::Type::Elaborated:
491 llvm::cast<clang::ElaboratedType>(qual_type)
495 case clang::Type::Paren:
498 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
510 if (
Import(compiler_type)) {
521 const clang::RecordDecl *record_decl, uint64_t &bit_size,
523 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
524 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
526 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
528 RecordDeclToLayoutMap::iterator pos =
530 bool success =
false;
531 base_offsets.clear();
532 vbase_offsets.clear();
534 bit_size = pos->second.bit_size;
535 alignment = pos->second.alignment;
536 field_offsets.swap(pos->second.field_offsets);
537 base_offsets.swap(pos->second.base_offsets);
538 vbase_offsets.swap(pos->second.vbase_offsets);
544 field_offsets.clear();
557 if (!decl_origin.
Valid())
567 &decl->getASTContext());
569 delegate_sp->ImportDefinitionTo(decl, decl_origin.
decl);
575 clang::TagDecl *origin_decl) {
576 clang::ASTContext *origin_ast_ctx = &origin_decl->getASTContext();
582 GetDelegate(&decl->getASTContext(), origin_ast_ctx));
585 delegate_sp->ImportDefinitionTo(decl, origin_decl);
589 context_md->setOrigin(decl,
DeclOrigin(origin_ast_ctx, origin_decl));
594 clang::ObjCInterfaceDecl *interface_decl) {
597 if (!decl_origin.
Valid())
607 delegate_sp->ImportDefinitionTo(interface_decl, decl_origin.
decl);
609 if (ObjCInterfaceDecl *super_class = interface_decl->getSuperClass())
621 if (
const TagType *tag_type = type->getAs<TagType>()) {
622 TagDecl *tag_decl = tag_type->getDecl();
626 if (!decl_origin.
Valid())
633 &tag_decl->getASTContext());
635 TagDecl *origin_tag_decl = llvm::dyn_cast<TagDecl>(decl_origin.
decl);
637 for (Decl *origin_child_decl : origin_tag_decl->decls()) {
638 llvm::Expected<Decl *> imported_or_err =
639 delegate_sp->Import(origin_child_decl);
640 if (!imported_or_err) {
642 "Couldn't import decl: {0}");
647 if (RecordDecl *record_decl = dyn_cast<RecordDecl>(origin_tag_decl))
648 record_decl->setHasLoadedFieldsFromExternalStorage(
true);
653 if (
const ObjCObjectType *objc_object_type = type->getAs<ObjCObjectType>()) {
654 if (ObjCInterfaceDecl *objc_interface_decl =
655 objc_object_type->getInterface()) {
658 if (!decl_origin.
Valid())
662 GetDelegate(&objc_interface_decl->getASTContext(), decl_origin.
ctx));
664 ObjCInterfaceDecl *origin_interface_decl =
665 llvm::dyn_cast<ObjCInterfaceDecl>(decl_origin.
decl);
667 for (Decl *origin_child_decl : origin_interface_decl->decls()) {
668 llvm::Expected<Decl *> imported_or_err =
669 delegate_sp->Import(origin_child_decl);
670 if (!imported_or_err) {
672 "Couldn't import decl: {0}");
689 if (
const TagType *tag_type = type->getAs<TagType>()) {
690 TagDecl *tag_decl = tag_type->getDecl();
692 if (tag_decl->getDefinition() || tag_decl->isBeingDefined())
697 if (
const ObjCObjectType *objc_object_type = type->getAs<ObjCObjectType>()) {
698 if (ObjCInterfaceDecl *objc_interface_decl =
699 objc_object_type->getInterface())
703 if (
const ArrayType *array_type = type->getAsArrayTypeUnsafe())
705 if (
const AtomicType *atomic_type = type->getAs<AtomicType>())
714 if (decl_origin.
Valid()) {
726 return context_md->getOrigin(decl);
730 clang::Decl *original_decl) {
732 context_md->setOrigin(
733 decl,
DeclOrigin(&original_decl->getASTContext(), original_decl));
740 context_md->m_namespace_maps[decl] = namespace_map;
749 NamespaceMetaMap::iterator iter = namespace_maps.find(decl);
751 if (iter != namespace_maps.end())
760 const DeclContext *parent_context = decl->getDeclContext();
761 const NamespaceDecl *parent_namespace =
762 dyn_cast<NamespaceDecl>(parent_context);
765 if (parent_namespace)
770 new_map = std::make_shared<NamespaceMap>();
772 if (context_md->m_map_completer) {
773 std::string namespace_string = decl->getDeclName().getAsString();
775 context_md->m_map_completer->CompleteNamespaceMap(
776 new_map,
ConstString(namespace_string.c_str()), parent_map);
779 context_md->m_namespace_maps[decl] = new_map;
786 " [ClangASTImporter] Forgetting destination (ASTContext*){0}",
793 clang::ASTContext *src_ast) {
799 " [ClangASTImporter] Forgetting source->dest "
800 "(ASTContext*){0}->(ASTContext*){1}",
806 md->m_delegates.erase(src_ast);
807 md->removeOriginsWithContext(src_ast);
812llvm::Expected<Decl *>
831 assert(origin.
decl != From &&
"Origin points to itself?");
842 if (origin.
Valid() && origin.
ctx == &getToContext()) {
843 RegisterImportedDecl(From, origin.
decl);
856 if (origin.
Valid()) {
859 RegisterImportedDecl(From, R);
867 auto *td = dyn_cast<TagDecl>(From);
871 "[ClangASTImporter] Searching for a complete definition of {0} in "
874 Expected<DeclContext *> dc_or_err = ImportContext(td->getDeclContext());
876 return dc_or_err.takeError();
877 Expected<DeclarationName> dn_or_err =
Import(td->getDeclName());
879 return dn_or_err.takeError();
880 DeclContext *dc = *dc_or_err;
881 DeclContext::lookup_result lr = dc->lookup(*dn_or_err);
882 for (clang::Decl *candidate : lr) {
883 if (candidate->getKind() == From->getKind()) {
884 RegisterImportedDecl(From, candidate);
889 LLDB_LOG(log,
"[ClangASTImporter] Complete definition not found");
892 return ASTImporter::ImportImpl(From);
896 clang::Decl *to, clang::Decl *from) {
904 MapImported(from, to);
908 if (llvm::Error err = ImportDefinition(from)) {
910 "[ClangASTImporter] Error during importing definition: {0}");
914 if (clang::TagDecl *to_tag = dyn_cast<clang::TagDecl>(to)) {
915 if (clang::TagDecl *from_tag = dyn_cast<clang::TagDecl>(from)) {
916 to_tag->setCompleteDefinition(from_tag->isCompleteDefinition());
919 std::string name_string;
920 if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from)) {
921 llvm::raw_string_ostream name_stream(name_string);
922 from_named_decl->printName(name_stream);
925 LLDB_LOG(log_ast,
"==== [ClangASTImporter][TUDecl: {0}] Imported "
926 "({1}Decl*){2}, named {3} (from "
928 static_cast<void *
>(to->getTranslationUnitDecl()),
929 from->getDeclKindName(),
static_cast<void *
>(to), name_string,
930 static_cast<void *
>(from));
933 std::string ast_string;
934 llvm::raw_string_ostream ast_stream(ast_string);
935 to->getTranslationUnitDecl()->dump(ast_stream);
936 LLDB_LOG(log_ast,
"{0}", ast_string);
945 if (ObjCInterfaceDecl *to_objc_interface = dyn_cast<ObjCInterfaceDecl>(to)) {
947 ObjCInterfaceDecl *to_superclass = to_objc_interface->getSuperClass();
952 ObjCInterfaceDecl *from_objc_interface =
953 dyn_cast<ObjCInterfaceDecl>(from);
955 if (!from_objc_interface)
958 ObjCInterfaceDecl *from_superclass = from_objc_interface->getSuperClass();
960 if (!from_superclass)
963 llvm::Expected<Decl *> imported_from_superclass_decl =
966 if (!imported_from_superclass_decl) {
968 "Couldn't import decl: {0}");
972 ObjCInterfaceDecl *imported_from_superclass =
973 dyn_cast<ObjCInterfaceDecl>(*imported_from_superclass_decl);
975 if (!imported_from_superclass)
978 if (!to_objc_interface->hasDefinition())
979 to_objc_interface->startDefinition();
981 to_objc_interface->setSuperClass(m_source_ctx->getTrivialTypeSourceInfo(
982 m_source_ctx->getObjCInterfaceType(imported_from_superclass)));
992 CXXMethodDecl *to_method) {
993 if (!to_method->isVirtual())
995 QualType return_type = to_method->getReturnType();
996 if (!return_type->isPointerType() && !return_type->isReferenceType())
999 clang::RecordDecl *rd = return_type->getPointeeType()->getAsRecordDecl();
1002 if (rd->getDefinition())
1017 from_source.
GetIDForModule(module->Parent), from_source, to_source);
1020 module->IsExplicit);
1029 if (m_decls_to_ignore.count(to))
1033 auto *from_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1034 getFromContext().getExternalSource());
1036 auto *to_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1037 getToContext().getExternalSource());
1038 if (from_source && to_source) {
1052 if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from)) {
1053 std::string name_string;
1054 llvm::raw_string_ostream name_stream(name_string);
1055 from_named_decl->printName(name_stream);
1056 name_stream.flush();
1059 " [ClangASTImporter] Imported ({0}Decl*){1}, named {2} (from "
1060 "(Decl*){3}), metadata {4}",
1061 from->getDeclKindName(), to, name_string, from, user_id);
1064 " [ClangASTImporter] Imported ({0}Decl*){1} (from "
1065 "(Decl*){2}), metadata {3}",
1066 from->getDeclKindName(), to, from, user_id);
1071 m_main.GetContextMetadata(&to->getASTContext());
1073 m_main.MaybeGetContextMetadata(m_source_ctx);
1075 if (from_context_md) {
1076 DeclOrigin origin = from_context_md->getOrigin(from);
1078 if (origin.
Valid()) {
1079 if (origin.
ctx != &to->getASTContext()) {
1081 to_context_md->setOrigin(to, origin);
1084 " [ClangASTImporter] Propagated origin "
1085 "(Decl*){0}/(ASTContext*){1} from (ASTContext*){2} to "
1087 origin.
decl, origin.
ctx, &from->getASTContext(),
1088 &to->getASTContext());
1091 if (m_new_decl_listener)
1092 m_new_decl_listener->NewDeclImported(from, to);
1095 to_context_md->setOrigin(to,
DeclOrigin(m_source_ctx, from));
1098 " [ClangASTImporter] Decl has no origin information in "
1100 &from->getASTContext());
1103 if (
auto *to_namespace = dyn_cast<clang::NamespaceDecl>(to)) {
1104 auto *from_namespace = cast<clang::NamespaceDecl>(from);
1108 NamespaceMetaMap::iterator namespace_map_iter =
1109 namespace_maps.find(from_namespace);
1111 if (namespace_map_iter != namespace_maps.end())
1112 to_context_md->m_namespace_maps[to_namespace] =
1113 namespace_map_iter->second;
1116 to_context_md->setOrigin(to,
DeclOrigin(m_source_ctx, from));
1119 " [ClangASTImporter] Sourced origin "
1120 "(Decl*){0}/(ASTContext*){1} into (ASTContext*){2}",
1121 from, m_source_ctx, &to->getASTContext());
1124 if (
auto *to_tag_decl = dyn_cast<TagDecl>(to)) {
1125 to_tag_decl->setHasExternalLexicalStorage();
1126 to_tag_decl->getPrimaryContext()->setMustBuildLookupTable();
1127 auto from_tag_decl = cast<TagDecl>(from);
1131 " [ClangASTImporter] To is a TagDecl - attributes {0}{1} [{2}->{3}]",
1132 (to_tag_decl->hasExternalLexicalStorage() ?
" Lexical" :
""),
1133 (to_tag_decl->hasExternalVisibleStorage() ?
" Visible" :
""),
1134 (from_tag_decl->isCompleteDefinition() ?
"complete" :
"incomplete"),
1135 (to_tag_decl->isCompleteDefinition() ?
"complete" :
"incomplete"));
1138 if (
auto *to_namespace_decl = dyn_cast<NamespaceDecl>(to)) {
1139 m_main.BuildNamespaceMap(to_namespace_decl);
1140 to_namespace_decl->setHasExternalVisibleStorage();
1143 if (
auto *to_container_decl = dyn_cast<ObjCContainerDecl>(to)) {
1144 to_container_decl->setHasExternalLexicalStorage();
1145 to_container_decl->setHasExternalVisibleStorage();
1148 if (ObjCInterfaceDecl *to_interface_decl =
1149 llvm::dyn_cast<ObjCInterfaceDecl>(to_container_decl)) {
1152 " [ClangASTImporter] To is an ObjCInterfaceDecl - attributes "
1154 (to_interface_decl->hasExternalLexicalStorage() ?
" Lexical" :
""),
1155 (to_interface_decl->hasExternalVisibleStorage() ?
" Visible" :
""),
1156 (to_interface_decl->hasDefinition() ?
" HasDefinition" :
""));
1159 log,
" [ClangASTImporter] To is an {0}Decl - attributes {1}{2}",
1160 ((Decl *)to_container_decl)->getDeclKindName(),
1161 (to_container_decl->hasExternalLexicalStorage() ?
" Lexical" :
""),
1162 (to_container_decl->hasExternalVisibleStorage() ?
" Visible" :
""));
1167 if (clang::CXXMethodDecl *to_method = dyn_cast<CXXMethodDecl>(to))
1173 return m_main.GetDeclOrigin(To).decl;
static OptionalClangModuleID RemapModule(OptionalClangModuleID from_id, ClangExternalASTSourceCallbacks &from_source, ClangExternalASTSourceCallbacks &to_source)
Recreate a module with its parents in to_source and return its id.
static void MaybeCompleteReturnType(ClangASTImporter &importer, CXXMethodDecl *to_method)
Takes a CXXMethodDecl and completes the return type if necessary.
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOG_ERROR(log, error,...)
DeclContextOverride()=default
void Override(clang::Decl *decl)
llvm::DenseMap< clang::Decl *, Backup > m_backups
void OverrideAllDeclsFromContainingFunction(clang::Decl *decl)
void OverrideOne(clang::Decl *decl)
clang::Decl * GetEscapedChild(clang::Decl *decl, clang::DeclContext *base=nullptr)
bool ChainPassesThrough(clang::Decl *decl, clang::DeclContext *base, clang::DeclContext *(clang::Decl::*contextFromDecl)(), clang::DeclContext *(clang::DeclContext::*contextFromContext)())
Scope guard that attaches a CxxModuleHandler to an ASTImporterDelegate and deattaches it at the end o...
Manages and observes all Clang AST node importing in LLDB.
bool CompleteTagDecl(clang::TagDecl *decl)
clang::Decl * DeportDecl(clang::ASTContext *dst_ctx, clang::Decl *decl)
Copies the given decl to the destination type system.
void BuildNamespaceMap(const clang::NamespaceDecl *decl)
void RegisterNamespaceMap(const clang::NamespaceDecl *decl, NamespaceMapSP &namespace_map)
void ForgetDestination(clang::ASTContext *dst_ctx)
CompilerType CopyType(TypeSystemClang &dst, const CompilerType &src_type)
Copies the given type and the respective declarations to the destination type system.
clang::Decl * CopyDecl(clang::ASTContext *dst_ctx, clang::Decl *decl)
DeclOrigin GetDeclOrigin(const clang::Decl *decl)
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &bit_size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets)
bool CompleteTagDeclWithOrigin(clang::TagDecl *decl, clang::TagDecl *origin)
bool CanImport(const CompilerType &type)
Returns true iff the given type was copied from another TypeSystemClang and the original type in this...
ASTContextMetadataSP GetContextMetadata(clang::ASTContext *dst_ctx)
void ForgetSource(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx)
bool CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *interface_decl)
ASTContextMetadataSP MaybeGetContextMetadata(clang::ASTContext *dst_ctx)
std::shared_ptr< NamespaceMap > NamespaceMapSP
NamespaceMapSP GetNamespaceMap(const clang::NamespaceDecl *decl)
std::shared_ptr< ASTImporterDelegate > ImporterDelegateSP
llvm::DenseMap< const clang::NamespaceDecl *, NamespaceMapSP > NamespaceMetaMap
bool CompleteType(const CompilerType &compiler_type)
void SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo &layout)
Sets the layout for the given RecordDecl.
ContextMetadataMap m_metadata_map
ClangASTMetadata * GetDeclMetadata(const clang::Decl *decl)
bool RequireCompleteType(clang::QualType type)
CompilerType DeportType(TypeSystemClang &dst, const CompilerType &src_type)
Copies the given type and the respective declarations to the destination type system.
RecordDeclToLayoutMap m_record_decl_to_layout_map
bool Import(const CompilerType &type)
If the given type was copied from another TypeSystemClang then copy over all missing information (e....
ImporterDelegateSP GetDelegate(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx)
void SetDeclOrigin(const clang::Decl *decl, clang::Decl *original_decl)
Updates the internal origin-tracking information so that the given 'original' decl is from now on use...
std::shared_ptr< ASTContextMetadata > ASTContextMetadataSP
bool CompleteAndFetchChildren(clang::QualType type)
TypeSystemClang & GetTypeSystem() const
OptionalClangModuleID GetIDForModule(clang::Module *module)
clang::Module * getModule(unsigned ID) override
std::shared_ptr< TypeSystemType > dyn_cast_or_null()
Return a shared_ptr<TypeSystemType> if dyn_cast succeeds.
Generic representation of a type in a programming language.
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
ConstString GetTypeName(bool BaseOnly=false) const
A uniqued constant string class.
std::optional< clang::Decl * > Import(clang::Decl *d)
Attempts to import the given decl into the target ASTContext by deserializing it from the 'std' modul...
unsigned GetValue() const
A TypeSystem implementation based on Clang.
static void SetOwningModule(clang::Decl *decl, OptionalClangModuleID owning_module)
Set the owning module for decl.
OptionalClangModuleID GetOrCreateClangModule(llvm::StringRef name, OptionalClangModuleID parent, bool is_framework=false, bool is_explicit=false)
Synthesize a clang::Module and return its ID or a default-constructed ID.
static TypeSystemClang * GetASTContext(clang::ASTContext *ast_ctx)
clang::ASTContext & getASTContext()
Returns the clang::ASTContext instance managed by this TypeSystemClang.
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
ClangASTMetadata * GetMetadata(const clang::Decl *object)
bool GetCompleteDecl(clang::Decl *decl)
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
void * opaque_compiler_type_t
clang::DeclContext * decl_context
clang::DeclContext * lexical_decl_context
clang::Decl * GetOriginalDecl(clang::Decl *To) override
llvm::Expected< clang::Decl * > ImportImpl(clang::Decl *From) override
llvm::SmallPtrSet< clang::Decl *, 16 > m_decls_to_ignore
Decls we should ignore when mapping decls back to their original ASTContext.
CxxModuleHandler * m_std_handler
void Imported(clang::Decl *from, clang::Decl *to) override
void ImportDefinitionTo(clang::Decl *to, clang::Decl *from)
ClangASTImporter & m_main
Listener interface used by the ASTImporterDelegate to inform other code about decls that have been im...
static clang::QualType GetQualType(const CompilerType &ct)
static clang::QualType GetCanonicalQualType(const CompilerType &ct)
static bool IsClangType(const CompilerType &ct)
static CompilerType RemoveFastQualifiers(const CompilerType &ct)