22#include "clang/AST/ASTContext.h"
23#include "clang/Basic/SourceManager.h"
38class ScopedLexicalDeclEraser {
40 ScopedLexicalDeclEraser(std::set<const clang::Decl *> &decls,
41 const clang::Decl *decl)
42 : m_active_lexical_decls(decls), m_decl(decl) {}
44 ~ScopedLexicalDeclEraser() { m_active_lexical_decls.erase(m_decl); }
47 std::set<const clang::Decl *> &m_active_lexical_decls;
48 const clang::Decl *m_decl;
54 const std::shared_ptr<ClangASTImporter> &importer)
86 llvm::cast<ScratchTypeSystemClang>(scratch_ts_sp.get());
95 m_ast_context->getTranslationUnitDecl()->setHasExternalVisibleStorage();
96 m_ast_context->getTranslationUnitDecl()->setHasExternalLexicalStorage();
101 const DeclContext *decl_ctx, DeclarationName clang_decl_name,
102 const clang::DeclContext *original_dc) {
104 SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
108 std::string decl_name(clang_decl_name.getAsString());
110 switch (clang_decl_name.getNameKind()) {
112 case DeclarationName::Identifier: {
113 clang::IdentifierInfo *identifier_info =
114 clang_decl_name.getAsIdentifierInfo();
116 if (!identifier_info || identifier_info->getBuiltinID() != 0) {
117 SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
123 case DeclarationName::CXXOperatorName:
124 case DeclarationName::CXXLiteralOperatorName:
129 case DeclarationName::CXXUsingDirective:
130 SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
133 case DeclarationName::ObjCZeroArgSelector:
134 case DeclarationName::ObjCOneArgSelector:
135 case DeclarationName::ObjCMultiArgSelector: {
136 llvm::SmallVector<NamedDecl *, 1> method_decls;
139 clang_decl_name, decl_ctx);
143 SetExternalVisibleDeclsForName(decl_ctx, clang_decl_name, method_decls);
144 return (method_decls.size() > 0);
147 case DeclarationName::CXXConstructorName:
148 case DeclarationName::CXXDestructorName:
149 case DeclarationName::CXXConversionFunctionName:
150 case DeclarationName::CXXDeductionGuideName:
151 SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
158 if (!decl_name.empty() && decl_name[0] ==
'$') {
161 SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
168 const char *uniqued_const_decl_name = const_decl_name.
GetCString();
172 SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
176 llvm::SmallVector<NamedDecl *, 4> name_decls;
178 clang_decl_name, decl_ctx);
180 SetExternalVisibleDeclsForName(decl_ctx, clang_decl_name, name_decls);
182 return (name_decls.size() != 0);
188 if (
const NamespaceDecl *namespace_context =
189 dyn_cast<NamespaceDecl>(decl->getDeclContext())) {
197 " CTD Inspecting namespace map{0:x} ({1} entries)",
198 namespace_map.get(), namespace_map->size());
201 LLDB_LOG(log,
" CTD Searching namespace {0} in module {1}",
202 item.second.GetName(), item.first->GetFileSpec().GetFilename());
211 item.first->FindTypes(query, results);
214 CompilerType clang_type(type_sp->GetFullCompilerType());
219 const TagType *tag_type =
225 TagDecl *candidate_tag_decl =
226 tag_type->getDecl()->getDefinitionOrSelf();
229 &candidate_tag_decl->getASTContext(), candidate_tag_decl))
230 return candidate_tag_decl;
239 module_list.
FindTypes(
nullptr, query, results);
242 CompilerType clang_type(type_sp->GetFullCompilerType());
247 const TagType *tag_type =
253 TagDecl *candidate_tag_decl = tag_type->getDecl()->getDefinitionOrSelf();
257 return candidate_tag_decl;
267 " CompleteTagDecl on (ASTContext*){0} Completing "
268 "(TagDecl*){1:x} named {2}",
270 tag_decl->getName());
294 " [CompleteObjCInterfaceDecl] on (ASTContext*){0:x} '{1}' "
295 "Completing an ObjCInterfaceDecl named {2}",
297 interface_decl->getName());
298 LLDB_LOG(log,
" [COID] Before:\n{0}",
303 if (original.
Valid()) {
304 if (ObjCInterfaceDecl *original_iface_decl =
305 dyn_cast<ObjCInterfaceDecl>(original.
decl)) {
306 ObjCInterfaceDecl *complete_iface_decl =
309 if (complete_iface_decl && (complete_iface_decl != original_iface_decl)) {
317 if (interface_decl->getSuperClass() &&
318 interface_decl->getSuperClass() != interface_decl)
326 const clang::ObjCInterfaceDecl *interface_decl) {
334 if (!language_runtime)
337 ConstString class_name(interface_decl->getNameAsString().c_str());
342 if (!complete_type_sp)
350 if (!complete_opaque_type)
353 const clang::Type *complete_clang_type =
354 QualType::getFromOpaquePtr(complete_opaque_type).getTypePtr();
355 const ObjCInterfaceType *complete_interface_type =
356 dyn_cast<ObjCInterfaceType>(complete_clang_type);
358 if (!complete_interface_type)
361 ObjCInterfaceDecl *complete_iface_decl(complete_interface_type->getDecl());
363 return complete_iface_decl;
367 const DeclContext *decl_context,
368 llvm::function_ref<
bool(Decl::Kind)> predicate,
373 const Decl *context_decl = dyn_cast<Decl>(decl_context);
385 if (
const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl))
387 "FindExternalLexicalDecls on (ASTContext*){0:x} '{1}' in "
388 "'{2}' ({3}Decl*){4}",
390 context_named_decl->getNameAsString().c_str(),
391 context_decl->getDeclKindName(),
392 static_cast<const void *
>(context_decl));
393 else if (context_decl)
395 "FindExternalLexicalDecls on (ASTContext*){0:x} '{1}' in "
398 context_decl->getDeclKindName(),
399 static_cast<const void *
>(context_decl));
402 "FindExternalLexicalDecls on (ASTContext*){0:x} '{1}' in a "
409 if (!original.
Valid())
412 LLDB_LOG(log,
" FELD Original decl (ASTContext*){0:x} (Decl*){1:x}:\n{2}",
413 static_cast<void *
>(original.
ctx),
414 static_cast<void *
>(original.
decl),
417 if (ObjCInterfaceDecl *original_iface_decl =
418 dyn_cast<ObjCInterfaceDecl>(original.
decl)) {
419 ObjCInterfaceDecl *complete_iface_decl =
422 if (complete_iface_decl && (complete_iface_decl != original_iface_decl)) {
423 original.
decl = complete_iface_decl;
424 original.
ctx = &complete_iface_decl->getASTContext();
430 if (TagDecl *original_tag_decl = dyn_cast<TagDecl>(original.
decl)) {
431 ExternalASTSource *external_source = original.
ctx->getExternalSource();
434 external_source->CompleteType(original_tag_decl);
437 const DeclContext *original_decl_context =
438 dyn_cast<DeclContext>(original.
decl);
440 if (!original_decl_context)
444 bool SkippedDecls =
false;
445 for (Decl *decl : original_decl_context->decls()) {
449 if (predicate(decl->getKind())) {
452 if (
const NamedDecl *context_named_decl =
453 dyn_cast<NamedDecl>(context_decl))
454 LLDB_LOG(log,
" FELD Adding [to {0}Decl {1}] lexical {2}Decl {3}",
455 context_named_decl->getDeclKindName(),
456 context_named_decl->getName(), decl->getDeclKindName(),
459 LLDB_LOG(log,
" FELD Adding lexical {0}Decl {1}",
460 decl->getDeclKindName(), ast_dump);
477 if (FieldDecl *copied_field = dyn_cast<FieldDecl>(copied_decl)) {
478 QualType copied_field_type = copied_field->getType();
491 decl_context->setHasExternalLexicalStorage(
true);
495 const_cast<DeclContext *
>(decl_context)->setMustBuildLookupTable();
509 "ClangASTSource::FindExternalVisibleDecls on "
510 "(ASTContext*){0:x} '{1}' for '{2}' in a NULL DeclContext",
512 else if (
const NamedDecl *context_named_decl =
515 "ClangASTSource::FindExternalVisibleDecls on "
516 "(ASTContext*){0:x} '{1}' for '{2}' in '{3}'",
518 context_named_decl->getName());
521 "ClangASTSource::FindExternalVisibleDecls on "
522 "(ASTContext*){0:x} '{1}' for '{2}' in a '{3}'",
537 LLDB_LOG(log,
" CAS::FEVD Searching the root namespace");
544 log,
" CAS::FEVD Registering namespace map {0:x} ({1} entries)",
547 NamespaceDecl *clang_namespace_decl =
AddNamespace(context);
549 if (clang_namespace_decl)
550 clang_namespace_decl->setHasExternalVisibleStorage();
559 bool ignore_all_dollar_names) {
564 if (name == id_name || name == Class_name)
570 return name_string_ref.empty() ||
571 (ignore_all_dollar_names && name_string_ref.starts_with(
"$")) ||
572 name_string_ref.starts_with(
"_$");
598 if (module_sp && namespace_decl) {
600 TypeQuery query(namespace_decl, name, TypeQueryOptions::e_find_one);
601 module_sp->FindTypes(query, results);
606 TypeQueryOptions::e_find_one);
607 m_target->GetImages().FindTypes(
nullptr, query, results);
613 const char *name_string = type_sp->GetName().GetCString();
615 LLDB_LOG(log,
" CAS::FEVD Matching type found for \"{0}\": {1}", name,
616 (name_string ? name_string :
"<anonymous>"));
619 CompilerType full_type = type_sp->GetFullCompilerType();
623 if (!copied_clang_type) {
624 LLDB_LOG(log,
" CAS::FEVD - Couldn't export a type");
652 if (module_sp && namespace_decl) {
655 if (
SymbolFile *symbol_file = module_sp->GetSymbolFile()) {
656 found_namespace_decl = symbol_file->FindNamespace(name, namespace_decl);
658 if (found_namespace_decl) {
660 std::pair<lldb::ModuleSP, CompilerDeclContext>(
661 module_sp, found_namespace_decl));
663 LLDB_LOG(log,
" CAS::FEVD Found namespace {0} in module {1}", name,
664 module_sp->GetFileSpec().GetFilename());
676 SymbolFile *symbol_file = image->GetSymbolFile();
688 const bool find_root_namespaces =
692 name, namespace_decl, find_root_namespaces);
694 if (found_namespace_decl) {
696 std::pair<lldb::ModuleSP, CompilerDeclContext>(image,
697 found_namespace_decl));
699 LLDB_LOG(log,
" CAS::FEVD Found namespace {0} in module {1}", name,
700 image->GetFileSpec().GetFilename());
707 const char *log_info) {
708 const DeclarationName &decl_name(context.
m_decl_name);
709 clang::ASTContext *original_ctx = &original_interface_decl->getASTContext();
711 Selector original_selector;
713 if (decl_name.isObjCZeroArgSelector()) {
714 const IdentifierInfo *ident =
715 &original_ctx->Idents.get(decl_name.getAsString());
716 original_selector = original_ctx->Selectors.getSelector(0, &ident);
717 }
else if (decl_name.isObjCOneArgSelector()) {
718 const std::string &decl_name_string = decl_name.getAsString();
719 std::string decl_name_string_without_colon(decl_name_string.c_str(),
720 decl_name_string.length() - 1);
721 const IdentifierInfo *ident =
722 &original_ctx->Idents.get(decl_name_string_without_colon);
723 original_selector = original_ctx->Selectors.getSelector(1, &ident);
725 SmallVector<const IdentifierInfo *, 4> idents;
727 clang::Selector sel = decl_name.getObjCSelector();
729 unsigned num_args = sel.getNumArgs();
731 for (
unsigned i = 0; i != num_args; ++i) {
732 idents.push_back(&original_ctx->Idents.get(sel.getNameForSlot(i)));
736 original_ctx->Selectors.getSelector(num_args, idents.data());
739 DeclarationName original_decl_name(original_selector);
741 llvm::SmallVector<NamedDecl *, 1> methods;
745 if (ObjCMethodDecl *instance_method_decl =
746 original_interface_decl->lookupInstanceMethod(original_selector)) {
747 methods.push_back(instance_method_decl);
748 }
else if (ObjCMethodDecl *class_method_decl =
749 original_interface_decl->lookupClassMethod(
750 original_selector)) {
751 methods.push_back(class_method_decl);
754 if (methods.empty()) {
758 for (NamedDecl *named_decl : methods) {
762 ObjCMethodDecl *result_method = dyn_cast<ObjCMethodDecl>(named_decl);
767 Decl *copied_decl =
CopyDecl(result_method);
772 ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl>(copied_decl);
774 if (!copied_method_decl)
779 LLDB_LOG(log,
" CAS::FOMD found ({0}) {1}", log_info,
792 std::shared_ptr<ClangModulesDeclVendor> modules_decl_vendor =
794 if (!modules_decl_vendor)
798 uint32_t max_matches = 1;
799 std::vector<CompilerDecl> decls;
801 if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls))
804 LLDB_LOG(log,
" CAS::FEVD Matching entity found for \"{0}\" in the modules",
807 auto *
const decl_from_modules =
810 if (llvm::isa<clang::TypeDecl>(decl_from_modules) ||
811 llvm::isa<clang::ObjCContainerDecl>(decl_from_modules) ||
812 llvm::isa<clang::EnumConstantDecl>(decl_from_modules)) {
813 clang::Decl *copied_decl =
CopyDecl(decl_from_modules);
814 clang::NamedDecl *copied_named_decl =
815 copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) :
nullptr;
817 if (!copied_named_decl) {
818 LLDB_LOG(log,
" CAS::FEVD - Couldn't export a type from the modules");
840 if (!language_runtime)
849 uint32_t max_matches = 1;
850 std::vector<CompilerDecl> decls;
852 auto *clang_decl_vendor = llvm::cast<DeclVendor>(decl_vendor);
853 if (!clang_decl_vendor->FindDecls(name, append, max_matches, decls))
856 LLDB_LOG(log,
" CAS::FEVD Matching type found for \"{0}\" in the runtime",
860 clang::NamedDecl *copied_named_decl =
861 copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) :
nullptr;
863 if (!copied_named_decl) {
864 LLDB_LOG(log,
" CAS::FEVD - Couldn't export a type from the runtime");
875 const DeclarationName &decl_name(context.
m_decl_name);
878 const ObjCInterfaceDecl *interface_decl =
879 dyn_cast<ObjCInterfaceDecl>(decl_ctx);
887 if (!original.
Valid())
890 ObjCInterfaceDecl *original_interface_decl =
891 dyn_cast<ObjCInterfaceDecl>(original.
decl);
900 if (decl_name.isObjCZeroArgSelector()) {
901 ss.
Printf(
"%s", decl_name.getAsString().c_str());
902 }
else if (decl_name.isObjCOneArgSelector()) {
903 ss.
Printf(
"%s", decl_name.getAsString().c_str());
905 clang::Selector sel = decl_name.getObjCSelector();
907 for (
unsigned i = 0, e = sel.getNumArgs(); i != e; ++i) {
908 llvm::StringRef r = sel.getNameForSlot(i);
909 ss.
Printf(
"%s:", r.str().c_str());
920 "ClangASTSource::FindObjCMethodDecls on (ASTContext*){0:x} '{1}' "
921 "for selector [{2} {3}]",
923 interface_decl->getName(), selector_name);
930 std::string interface_name = interface_decl->getNameAsString();
934 ms.
Printf(
"-[%s %s]", interface_name.c_str(), selector_name.
AsCString());
939 m_target->GetImages().FindFunctions(instance_method_name,
940 lldb::eFunctionNameTypeFull,
941 function_options, sc_list);
947 ms.
Printf(
"+[%s %s]", interface_name.c_str(), selector_name.
AsCString());
952 m_target->GetImages().FindFunctions(class_method_name,
953 lldb::eFunctionNameTypeFull,
954 function_options, sc_list);
965 m_target->GetImages().FindFunctions(selector_name,
966 lldb::eFunctionNameTypeSelector,
967 function_options, candidate_sc_list);
969 for (
const SymbolContext &candidate_sc : candidate_sc_list) {
970 if (!candidate_sc.function)
973 const char *candidate_name = candidate_sc.function->GetName().AsCString();
975 const char *cursor = candidate_name;
977 if (*cursor !=
'+' && *cursor !=
'-')
987 size_t interface_len = interface_name.length();
989 if (strncmp(cursor, interface_name.c_str(), interface_len))
992 cursor += interface_len;
994 if (*cursor ==
' ' || *cursor ==
'(')
995 sc_list.
Append(candidate_sc);
1007 if (!function_decl_ctx)
1010 ObjCMethodDecl *method_decl =
1016 ObjCInterfaceDecl *found_interface_decl =
1017 method_decl->getClassInterface();
1019 if (!found_interface_decl)
1022 if (found_interface_decl->getName() == interface_decl->getName()) {
1023 Decl *copied_decl =
CopyDecl(method_decl);
1028 ObjCMethodDecl *copied_method_decl =
1029 dyn_cast<ObjCMethodDecl>(copied_decl);
1031 if (!copied_method_decl)
1034 LLDB_LOG(log,
" CAS::FOMD found (in symbols)\n{0}",
1048 const_cast<ObjCInterfaceDecl *
>(interface_decl));
1050 if (!complete_interface_decl)
1057 complete_interface_decl);
1059 if (complete_interface_decl == interface_decl)
1063 "CAS::FOPD trying origin "
1064 "(ObjCInterfaceDecl*){0:x}/(ASTContext*){1:x}...",
1065 complete_interface_decl, &complete_iface_decl->getASTContext());
1077 if (std::shared_ptr<ClangModulesDeclVendor> modules_decl_vendor =
1079 ConstString interface_name(interface_decl->getNameAsString().c_str());
1080 bool append =
false;
1081 uint32_t max_matches = 1;
1082 std::vector<CompilerDecl> decls;
1084 if (!modules_decl_vendor->FindDecls(interface_name, append, max_matches,
1088 ObjCInterfaceDecl *interface_decl_from_modules =
1091 if (!interface_decl_from_modules)
1111 if (!language_runtime)
1119 ConstString interface_name(interface_decl->getNameAsString().c_str());
1120 bool append =
false;
1121 uint32_t max_matches = 1;
1122 std::vector<CompilerDecl> decls;
1124 auto *clang_decl_vendor = llvm::cast<DeclVendor>(decl_vendor);
1125 if (!clang_decl_vendor->FindDecls(interface_name, append, max_matches,
1129 ObjCInterfaceDecl *runtime_interface_decl =
1132 if (!runtime_interface_decl)
1148 std::string name_str = context.
m_decl_name.getAsString();
1149 StringRef name(name_str);
1150 IdentifierInfo &name_identifier(
1151 origin_iface_decl->getASTContext().Idents.get(name));
1154 origin_iface_decl->FindPropertyDeclaration(
1155 &name_identifier, ObjCPropertyQueryKind::OBJC_PR_query_instance));
1159 if (origin_property_decl.
IsValid()) {
1162 if (parser_property_decl.
IsValid()) {
1163 LLDB_LOG(log,
" CAS::FOPD found\n{0}",
1172 origin_iface_decl->getIvarDecl(&name_identifier));
1174 if (origin_ivar_decl.
IsValid()) {
1177 if (parser_ivar_decl.
IsValid()) {
1178 LLDB_LOG(log,
" CAS::FOPD found\n{0}",
1197 ConstString class_name(parser_iface_decl->getNameAsString().c_str());
1200 "ClangASTSource::FindObjCPropertyAndIvarDecls on "
1201 "(ASTContext*){0:x} '{1}' for '{2}.{3}'",
1203 parser_iface_decl->getName(), context.
m_decl_name.getAsString());
1209 "CAS::FOPD couldn't find the property on origin "
1210 "(ObjCInterfaceDecl*){0:x}/(ASTContext*){1:x}, searching "
1212 origin_iface_decl.
decl, &origin_iface_decl->getASTContext());
1219 const_cast<ObjCInterfaceDecl *
>(parser_iface_decl.
decl));
1221 if (!complete_interface_decl)
1228 complete_interface_decl);
1230 if (complete_iface_decl.
decl == origin_iface_decl.
decl)
1234 "CAS::FOPD trying origin "
1235 "(ObjCInterfaceDecl*){0:x}/(ASTContext*){1:x}...",
1236 complete_iface_decl.
decl, &complete_iface_decl->getASTContext());
1247 std::shared_ptr<ClangModulesDeclVendor> modules_decl_vendor =
1250 if (!modules_decl_vendor)
1253 bool append =
false;
1254 uint32_t max_matches = 1;
1255 std::vector<CompilerDecl> decls;
1257 if (!modules_decl_vendor->FindDecls(class_name, append, max_matches, decls))
1263 if (!interface_decl_from_modules.
IsValid())
1267 "CAS::FOPD[{0:x}] trying module "
1268 "(ObjCInterfaceDecl*){0:x}/(ASTContext*){1:x}...",
1269 interface_decl_from_modules.
decl,
1270 &interface_decl_from_modules->getASTContext());
1273 interface_decl_from_modules))
1288 if (!language_runtime)
1296 bool append =
false;
1297 uint32_t max_matches = 1;
1298 std::vector<CompilerDecl> decls;
1300 auto *clang_decl_vendor = llvm::cast<DeclVendor>(decl_vendor);
1301 if (!clang_decl_vendor->FindDecls(class_name, append, max_matches, decls))
1307 if (!interface_decl_from_runtime.
IsValid())
1311 "CAS::FOPD[{0:x}] trying runtime "
1312 "(ObjCInterfaceDecl*){0:x}/(ASTContext*){1:x}...",
1313 interface_decl_from_runtime.
decl,
1314 &interface_decl_from_runtime->getASTContext());
1317 interface_decl_from_runtime))
1323 const NamespaceDecl *namespace_context =
1332 " CAS::FEVD Inspecting namespace map {0:x} ({1} entries)",
1333 namespace_map.get(), namespace_map->size());
1338 for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
1339 e = namespace_map->end();
1341 LLDB_LOG(log,
" CAS::FEVD Searching namespace {0} in module {1}",
1342 i->second.GetName(), i->first->GetFileSpec().GetFilename());
1349 const RecordDecl *record, uint64_t &size, uint64_t &alignment,
1350 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
1351 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
1353 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
1354 &virtual_base_offsets) {
1356 record, size, alignment, field_offsets, base_offsets,
1357 virtual_base_offsets);
1367 if (parent_map && parent_map->size())
1369 "CompleteNamespaceMap on (ASTContext*){0:x} '{1}' Searching "
1370 "for namespace {2} in namespace {3}",
1372 parent_map->begin()->second.GetName());
1375 "CompleteNamespaceMap on (ASTContext*){0} '{1}' Searching "
1376 "for namespace {2}",
1381 for (ClangASTImporter::NamespaceMap::iterator i = parent_map->begin(),
1382 e = parent_map->end();
1389 SymbolFile *symbol_file = module_sp->GetSymbolFile();
1394 found_namespace_decl =
1395 symbol_file->
FindNamespace(name, module_parent_namespace_decl);
1397 if (!found_namespace_decl)
1400 namespace_map->push_back(std::pair<lldb::ModuleSP, CompilerDeclContext>(
1401 module_sp, found_namespace_decl));
1403 LLDB_LOG(log,
" CMN Found namespace {0} in module {1}", name,
1404 module_sp->GetFileSpec().GetFilename());
1414 SymbolFile *symbol_file = image->GetSymbolFile();
1419 found_namespace_decl =
1422 if (!found_namespace_decl)
1425 namespace_map->push_back(std::pair<lldb::ModuleSP, CompilerDeclContext>(
1426 image, found_namespace_decl));
1428 LLDB_LOG(log,
" CMN[{0}] Found namespace {0} in module {1}", name,
1429 image->GetFileSpec().GetFilename());
1441 clang::ASTContext *src_ast =
1445 clang::NamespaceDecl *src_namespace_decl =
1448 if (!src_namespace_decl)
1451 Decl *copied_decl =
CopyDecl(src_namespace_decl);
1456 NamespaceDecl *copied_namespace_decl = dyn_cast<NamespaceDecl>(copied_decl);
1458 if (!copied_namespace_decl)
1461 context.
m_decls.push_back(copied_namespace_decl);
1466 return dyn_cast<NamespaceDecl>(copied_decl);
1485 if (copied_qual_type.getAsOpaquePtr() &&
1486 copied_qual_type->getCanonicalTypeInternal().isNull())
1494std::shared_ptr<ClangModulesDeclVendor>
1496 auto persistent_vars = llvm::cast<ClangPersistentVariables>(
1498 return persistent_vars->GetClangModulesDeclVendor();
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOG_VERBOSE(log,...)
std::shared_ptr< NamespaceMap > NamespaceMapSP
std::pair< lldb::ModuleSP, CompilerDeclContext > NamespaceMapItem
std::set< const char * > m_active_lookups
void LookupInNamespace(NameSearchContext &context)
Performs lookup into a namespace.
void SetLookupsEnabled(bool lookups_enabled)
clang::TagDecl * FindCompleteType(const clang::TagDecl *decl)
clang::ASTContext * m_ast_context
The AST context requests are coming in for.
ClangASTSource(const lldb::TargetSP &target, const std::shared_ptr< ClangASTImporter > &importer)
Constructor.
std::set< const clang::Decl * > m_active_lexical_decls
void FindExternalLexicalDecls(const clang::DeclContext *DC, llvm::function_ref< bool(clang::Decl::Kind)> IsKindWeWant, llvm::SmallVectorImpl< clang::Decl * > &Decls) override
Enumerate all Decls in a given lexical context.
bool layoutRecordType(const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &FieldOffsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &BaseOffsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &VirtualBaseOffsets) override
Specify the layout of the contents of a RecordDecl.
clang::Decl * CopyDecl(clang::Decl *src_decl)
Copies a single Decl into the parser's AST context.
bool IgnoreName(const ConstString name, bool ignore_all_dollar_names)
Returns true if a name should be ignored by name lookup.
virtual void FindExternalVisibleDecls(NameSearchContext &context)
The worker function for FindExternalVisibleDeclsByName.
void FindObjCPropertyAndIvarDecls(NameSearchContext &context)
Find all Objective-C properties and ivars with a given name.
clang::NamespaceDecl * AddNamespace(NameSearchContext &context)
friend struct NameSearchContext
ClangASTImporter::DeclOrigin GetDeclOrigin(const clang::Decl *decl)
Determined the origin of a single Decl, if it can be found.
bool FindObjCPropertyAndIvarDeclsWithOrigin(NameSearchContext &context, DeclFromUser< const clang::ObjCInterfaceDecl > &origin_iface_decl)
bool FindObjCMethodDeclsWithOrigin(NameSearchContext &context, clang::ObjCInterfaceDecl *original_interface_decl, const char *log_info)
std::shared_ptr< ClangModulesDeclVendor > GetClangModulesDeclVendor()
void CompleteNamespaceMap(ClangASTImporter::NamespaceMapSP &namespace_map, ConstString name, ClangASTImporter::NamespaceMapSP &parent_map) const override
Look up the modules containing a given namespace and put the appropriate entries in the namespace map...
void FindDeclInObjCRuntime(NameSearchContext &context, ConstString name)
void CompleteType(clang::TagDecl *Tag) override
Complete a TagDecl.
~ClangASTSource() override
Destructor.
void FillNamespaceMap(NameSearchContext &context, lldb::ModuleSP module_sp, const CompilerDeclContext &namespace_decl)
Fills the namespace map of the given NameSearchContext.
CompilerType GuardedCopyType(const CompilerType &src_type)
A wrapper for TypeSystemClang::CopyType that sets a flag that indicates that we should not respond to...
void FindDeclInModules(NameSearchContext &context, ConstString name)
bool FindExternalVisibleDeclsByName(const clang::DeclContext *DC, clang::DeclarationName Name, const clang::DeclContext *OriginalDC) override
Look up all Decls that match a particular name.
std::shared_ptr< ClangASTImporter > m_ast_importer_sp
The target's AST importer.
void InstallASTContext(TypeSystemClang &ast_context)
TypeSystemClang * m_clang_ast_context
The TypeSystemClang for m_ast_context.
void FindObjCMethodDecls(NameSearchContext &context)
Find all Objective-C methods matching a given selector.
const lldb::TargetSP m_target
The target to use in finding variables and types.
clang::ObjCInterfaceDecl * GetCompleteObjCInterface(const clang::ObjCInterfaceDecl *interface_decl)
Look for the complete version of an Objective-C interface, and return it if found.
void StartTranslationUnit(clang::ASTConsumer *Consumer) override
Called on entering a translation unit.
clang::FileManager * m_file_manager
The file manager paired with the AST context.
Represents a generic declaration context in a program.
Represents a generic declaration such as a function declaration.
Generic representation of a type in a programming language.
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
DeclFromUser< D > GetOrigin(ClangASTImporter &importer)
DeclFromParser< D > Import(clang::ASTContext *dest_ctx, ClangASTImporter &importer)
virtual DeclVendor * GetDeclVendor()
A collection class for Module objects.
void FindTypes(Module *search_first, const TypeQuery &query, lldb_private::TypeResults &results) const
Find types using a type-matching object that contains all search parameters.
lldb::TypeSP LookupInCompleteClassCache(ConstString &name)
static ObjCLanguageRuntime * Get(Process &process)
The TypeSystemClang instance used for the scratch ASTContext in a lldb::Target.
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
void ForgetSource(clang::ASTContext *src_ctx, ClangASTImporter &importer)
Unregisters the given ASTContext as a source from the scratch AST (and all sub-ASTs).
static const std::nullopt_t DefaultAST
Alias for requesting the default scratch TypeSystemClang in GetForTarget.
void Flush() override
Flush the stream.
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
void Clear()
Clear the object's state.
Defines a symbol context baton that can be handed other debug core functions.
Provides public interface for all SymbolFiles.
virtual CompilerDeclContext FindNamespace(ConstString name, const CompilerDeclContext &parent_decl_ctx, bool only_root_namespaces=false)
Finds a namespace of name name and whose parent context is parent_decl_ctx.
TypeIterable Types() const
A class that contains all state required for type lookups.
This class tracks the state and results of a TypeQuery.
lldb::TypeSP GetFirstType() const
A TypeSystem implementation based on Clang.
llvm::StringRef getDisplayName() const
Returns the display name of this TypeSystemClang that indicates what purpose it serves in LLDB.
static clang::ASTContext * DeclContextGetTypeSystemClang(const CompilerDeclContext &dc)
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
static clang::NamespaceDecl * DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc)
bool GetCompleteDecl(clang::Decl *decl)
clang::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
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.
TaggedASTType< 1 > TypeFromUser
void * opaque_compiler_type_t
@ eLanguageTypeC
Non-standardized C, such as K&R.
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
static clang::QualType GetQualType(const CompilerType &ct)
static std::string DumpDecl(const clang::Decl *d)
Returns a textual representation of the given Decl's AST.
static clang::Decl * GetDecl(const CompilerDecl &decl)
Returns the clang::Decl of the given CompilerDecl.
static bool IsClangType(const CompilerType &ct)
Options used by Module::FindFunctions.
bool include_inlines
Include inlined functions.
bool include_symbols
Include the symbol table.
clang::NamedDecl * AddTypeDecl(const CompilerType &compiler_type)
Create a TypeDecl with the name being searched for and the provided type and register it in the right...
const clang::DeclarationName m_decl_name
The name being looked for.
llvm::SmallVectorImpl< clang::NamedDecl * > & m_decls
The list of declarations already constructed.
const clang::DeclContext * m_decl_context
The DeclContext to put declarations into.
void AddNamedDecl(clang::NamedDecl *decl)
Add a NamedDecl to the list of results.
ClangASTImporter::NamespaceMapSP m_namespace_map
The mapping of all namespaces found for this request back to their modules.