11#include "clang/AST/DeclBase.h"
12#include "clang/AST/ExprCXX.h"
13#include "clang/Frontend/ASTConsumers.h"
14#include "llvm/ADT/ScopeExit.h"
15#include "llvm/Support/Casting.h"
16#include "llvm/Support/FormatAdapters.h"
17#include "llvm/Support/FormatVariadic.h"
24#include "clang/AST/ASTContext.h"
25#include "clang/AST/ASTImporter.h"
26#include "clang/AST/Attr.h"
27#include "clang/AST/CXXInheritance.h"
28#include "clang/AST/DeclObjC.h"
29#include "clang/AST/DeclTemplate.h"
30#include "clang/AST/Mangle.h"
31#include "clang/AST/QualTypeNames.h"
32#include "clang/AST/RecordLayout.h"
33#include "clang/AST/Type.h"
34#include "clang/AST/VTableBuilder.h"
35#include "clang/Basic/Builtins.h"
36#include "clang/Basic/Diagnostic.h"
37#include "clang/Basic/FileManager.h"
38#include "clang/Basic/FileSystemOptions.h"
39#include "clang/Basic/LangStandard.h"
40#include "clang/Basic/SourceManager.h"
41#include "clang/Basic/TargetInfo.h"
42#include "clang/Basic/TargetOptions.h"
43#include "clang/Frontend/FrontendOptions.h"
44#include "clang/Lex/HeaderSearch.h"
45#include "clang/Lex/HeaderSearchOptions.h"
46#include "clang/Lex/ModuleMap.h"
47#include "clang/Sema/Sema.h"
49#include "llvm/Support/Signals.h"
50#include "llvm/Support/Threading.h"
94using namespace llvm::dwarf;
96using llvm::StringSwitch;
101static void VerifyDecl(clang::Decl *decl) {
102 assert(decl &&
"VerifyDecl called with nullptr?");
128bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) {
130 lldbassert(&m1->getASTContext() == &m2->getASTContext() &&
131 "Methods should have the same AST context");
132 clang::ASTContext &context = m1->getASTContext();
134 const auto *m1Type = llvm::cast<clang::FunctionProtoType>(
135 context.getCanonicalType(m1->getType()));
137 const auto *m2Type = llvm::cast<clang::FunctionProtoType>(
138 context.getCanonicalType(m2->getType()));
140 auto compareArgTypes = [&context](
const clang::QualType &m1p,
141 const clang::QualType &m2p) {
142 return context.hasSameType(m1p.getUnqualifiedType(),
143 m2p.getUnqualifiedType());
148 return (m1->getNumParams() != m2->getNumParams()) ||
149 !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(),
150 m2Type->param_type_begin(), compareArgTypes);
156void addOverridesForMethod(clang::CXXMethodDecl *decl) {
157 if (!decl->isVirtual())
160 clang::CXXBasePaths paths;
161 llvm::SmallVector<clang::NamedDecl *, 4> decls;
163 auto find_overridden_methods =
164 [&decls, decl](
const clang::CXXBaseSpecifier *specifier,
165 clang::CXXBasePath &path) {
166 if (
auto *base_record = specifier->getType()->getAsCXXRecordDecl()) {
168 clang::DeclarationName name = decl->getDeclName();
172 if (name.getNameKind() == clang::DeclarationName::CXXDestructorName)
173 if (
auto *baseDtorDecl = base_record->getDestructor()) {
174 if (baseDtorDecl->isVirtual()) {
175 decls.push_back(baseDtorDecl);
182 for (path.Decls = base_record->lookup(name).begin();
183 path.Decls != path.Decls.end(); ++path.Decls) {
184 if (
auto *method_decl =
185 llvm::dyn_cast<clang::CXXMethodDecl>(*path.Decls))
186 if (method_decl->isVirtual() && !isOverload(decl, method_decl)) {
187 decls.push_back(method_decl);
196 if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) {
197 for (
auto *overridden_decl : decls)
198 decl->addOverriddenMethod(
199 llvm::cast<clang::CXXMethodDecl>(overridden_decl));
205 VTableContextBase &vtable_ctx,
207 const ASTRecordLayout &record_layout) {
211 uint32_t type_info = this_type.
GetTypeInfo(&pointee_type);
216 bool ptr_or_ref =
false;
217 if (type_info & (eTypeIsPointer | eTypeIsReference)) {
223 const uint32_t cpp_class = eTypeIsClass | eTypeIsCPlusPlus;
224 if ((type_info & cpp_class) != cpp_class)
229 vtable_ctx.isMicrosoft() ? record_layout.getVBPtrOffset().getQuantity()
243 vbtable_ptr_addr += vbtable_ptr_offset;
254 auto size = valobj.
GetData(data, err);
262 VTableContextBase &vtable_ctx,
264 const CXXRecordDecl *cxx_record_decl,
265 const CXXRecordDecl *base_class_decl) {
266 if (vtable_ctx.isMicrosoft()) {
267 clang::MicrosoftVTableContext &msoft_vtable_ctx =
268 static_cast<clang::MicrosoftVTableContext &
>(vtable_ctx);
272 const unsigned vbtable_index =
273 msoft_vtable_ctx.getVBTableIndex(cxx_record_decl, base_class_decl);
274 const lldb::addr_t base_offset_addr = vtable_ptr + vbtable_index * 4;
280 clang::ItaniumVTableContext &itanium_vtable_ctx =
281 static_cast<clang::ItaniumVTableContext &
>(vtable_ctx);
283 clang::CharUnits base_offset_offset =
284 itanium_vtable_ctx.getVirtualBaseOffsetOffset(cxx_record_decl,
287 vtable_ptr + base_offset_offset.getQuantity();
296 const ASTRecordLayout &record_layout,
297 const CXXRecordDecl *cxx_record_decl,
298 const CXXRecordDecl *base_class_decl,
299 int32_t &bit_offset) {
311 *process, vtable_ctx, vtable_ptr, cxx_record_decl, base_class_decl);
312 if (base_offset == INT64_MAX)
315 bit_offset = base_offset * 8;
325 static llvm::once_flag g_once_flag;
326 llvm::call_once(g_once_flag, []() {
333 bool is_complete_objc_class)
346 const clang::Decl *parent) {
347 if (!member || !parent)
354 member->setFromASTFile();
355 member->setOwningModuleID(
id.GetValue());
356 member->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
357 if (llvm::isa<clang::NamedDecl>(member))
358 if (
auto *dc = llvm::dyn_cast<clang::DeclContext>(parent)) {
359 dc->setHasExternalVisibleStorage(
true);
362 dc->setHasExternalLexicalStorage(
true);
369 clang::OverloadedOperatorKind &op_kind) {
371 if (!name.consume_front(
"operator"))
376 bool space_after_operator = name.consume_front(
" ");
378 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
379 .Case(
"+", clang::OO_Plus)
380 .Case(
"+=", clang::OO_PlusEqual)
381 .Case(
"++", clang::OO_PlusPlus)
382 .Case(
"-", clang::OO_Minus)
383 .Case(
"-=", clang::OO_MinusEqual)
384 .Case(
"--", clang::OO_MinusMinus)
385 .Case(
"->", clang::OO_Arrow)
386 .Case(
"->*", clang::OO_ArrowStar)
387 .Case(
"*", clang::OO_Star)
388 .Case(
"*=", clang::OO_StarEqual)
389 .Case(
"/", clang::OO_Slash)
390 .Case(
"/=", clang::OO_SlashEqual)
391 .Case(
"%", clang::OO_Percent)
392 .Case(
"%=", clang::OO_PercentEqual)
393 .Case(
"^", clang::OO_Caret)
394 .Case(
"^=", clang::OO_CaretEqual)
395 .Case(
"&", clang::OO_Amp)
396 .Case(
"&=", clang::OO_AmpEqual)
397 .Case(
"&&", clang::OO_AmpAmp)
398 .Case(
"|", clang::OO_Pipe)
399 .Case(
"|=", clang::OO_PipeEqual)
400 .Case(
"||", clang::OO_PipePipe)
401 .Case(
"~", clang::OO_Tilde)
402 .Case(
"!", clang::OO_Exclaim)
403 .Case(
"!=", clang::OO_ExclaimEqual)
404 .Case(
"=", clang::OO_Equal)
405 .Case(
"==", clang::OO_EqualEqual)
406 .Case(
"<", clang::OO_Less)
407 .Case(
"<=>", clang::OO_Spaceship)
408 .Case(
"<<", clang::OO_LessLess)
409 .Case(
"<<=", clang::OO_LessLessEqual)
410 .Case(
"<=", clang::OO_LessEqual)
411 .Case(
">", clang::OO_Greater)
412 .Case(
">>", clang::OO_GreaterGreater)
413 .Case(
">>=", clang::OO_GreaterGreaterEqual)
414 .Case(
">=", clang::OO_GreaterEqual)
415 .Case(
"()", clang::OO_Call)
416 .Case(
"[]", clang::OO_Subscript)
417 .Case(
",", clang::OO_Comma)
418 .Default(clang::NUM_OVERLOADED_OPERATORS);
421 if (op_kind != clang::NUM_OVERLOADED_OPERATORS)
433 if (!space_after_operator)
438 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
439 .Case(
"new", clang::OO_New)
440 .Case(
"new[]", clang::OO_Array_New)
441 .Case(
"delete", clang::OO_Delete)
442 .Case(
"delete[]", clang::OO_Array_Delete)
444 .Default(clang::NUM_OVERLOADED_OPERATORS);
449clang::AccessSpecifier
469 std::vector<std::string> Includes;
470 LangOptions::setLangDefaults(Opts, clang::Language::ObjCXX, arch.
GetTriple(),
471 Includes, clang::LangStandard::lang_gnucxx98);
473 Opts.setValueVisibilityMode(DefaultVisibility);
477 Opts.Trigraphs = !Opts.GNUMode;
482 Opts.ModulesLocalVisibility = 1;
486 llvm::Triple target_triple) {
488 if (!target_triple.str().empty())
498 ASTContext &existing_ctxt) {
514 if (!TypeSystemClangSupportsLanguage(language))
518 arch =
module->GetArchitecture();
528 if (triple.getVendor() == llvm::Triple::Apple &&
529 triple.getOS() == llvm::Triple::UnknownOS) {
530 if (triple.getArch() == llvm::Triple::arm ||
531 triple.getArch() == llvm::Triple::aarch64 ||
532 triple.getArch() == llvm::Triple::aarch64_32 ||
533 triple.getArch() == llvm::Triple::thumb) {
534 triple.setOS(llvm::Triple::IOS);
536 triple.setOS(llvm::Triple::MacOSX);
541 std::string ast_name =
542 "ASTContext for '" +
module->GetFileSpec().GetPath() + "'";
543 return std::make_shared<TypeSystemClang>(ast_name, triple);
544 }
else if (target && target->
IsValid())
545 return std::make_shared<ScratchTypeSystemClang>(*target, triple);
607 assert(s ==
nullptr || &s->getASTContext() ==
m_ast_up.get());
620 llvm::IntrusiveRefCntPtr<ExternalASTSource> ast_source_sp) {
622 ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(
true);
623 ast.setExternalSource(std::move(ast_source_sp));
636 const clang::Diagnostic &info)
override {
638 llvm::SmallVector<char, 32> diag_str(10);
639 info.FormatDiagnostic(diag_str);
640 diag_str.push_back(
'\0');
645 DiagnosticConsumer *
clone(DiagnosticsEngine &Diags)
const {
666 clang::FileSystemOptions file_system_options;
676 m_ast_up = std::make_unique<ASTContext>(
688 m_ast_up->InitBuiltinTypes(*target_info);
692 "Failed to initialize builtin ASTContext types for target '{0}'. "
693 "Printing variables may behave unexpectedly.",
699 static std::once_flag s_uninitialized_target_warning;
701 &s_uninitialized_target_warning);
707 llvm::makeIntrusiveRefCnt<ClangExternalASTSourceCallbacks>(*
this);
739#pragma mark Basic Types
742 ASTContext &ast, QualType qual_type) {
743 uint64_t qual_type_bit_size = ast.getTypeSize(qual_type);
744 return qual_type_bit_size == bit_size;
763 return GetType(ast.UnsignedCharTy);
765 return GetType(ast.UnsignedShortTy);
767 return GetType(ast.UnsignedIntTy);
769 return GetType(ast.UnsignedLongTy);
771 return GetType(ast.UnsignedLongLongTy);
773 return GetType(ast.UnsignedInt128Ty);
778 return GetType(ast.SignedCharTy);
786 return GetType(ast.LongLongTy);
797 return GetType(ast.LongDoubleTy);
801 return GetType(ast.Float128Ty);
806 if (bit_size && !(bit_size & 0x7u))
807 return GetType(ast.getExtVectorType(ast.UnsignedCharTy, bit_size / 8));
815 static const llvm::StringMap<lldb::BasicType> g_type_map = {
868 auto iter = g_type_map.find(name);
869 if (iter == g_type_map.end())
896 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
915 return GetType(ast.UnsignedCharTy);
917 return GetType(ast.UnsignedShortTy);
919 return GetType(ast.UnsignedIntTy);
924 if (type_name.contains(
"complex")) {
933 case DW_ATE_complex_float: {
934 CanQualType FloatComplexTy = ast.getComplexType(ast.FloatTy);
936 return GetType(FloatComplexTy);
938 CanQualType DoubleComplexTy = ast.getComplexType(ast.DoubleTy);
940 return GetType(DoubleComplexTy);
942 CanQualType LongDoubleComplexTy = ast.getComplexType(ast.LongDoubleTy);
944 return GetType(LongDoubleComplexTy);
954 if (type_name ==
"float" &&
957 if (type_name ==
"double" &&
960 if (type_name ==
"long double" &&
962 return GetType(ast.LongDoubleTy);
966 if ((type_name ==
"__float128" || type_name ==
"_Float128" ||
967 type_name ==
"f128") &&
969 return GetType(ast.Float128Ty);
976 return GetType(ast.LongDoubleTy);
980 return GetType(ast.Float128Ty);
984 if (!type_name.empty()) {
985 if (type_name ==
"wchar_t" &&
990 if (type_name ==
"void" &&
993 if (type_name.contains(
"long long") &&
995 return GetType(ast.LongLongTy);
996 if (type_name.contains(
"long") &&
999 if (type_name.contains(
"short") &&
1002 if (type_name.contains(
"char")) {
1006 return GetType(ast.SignedCharTy);
1008 if (type_name.contains(
"int")) {
1025 return GetType(ast.LongLongTy);
1030 case DW_ATE_signed_char:
1031 if (type_name ==
"char") {
1036 return GetType(ast.SignedCharTy);
1039 case DW_ATE_unsigned:
1040 if (!type_name.empty()) {
1041 if (type_name ==
"wchar_t") {
1048 if (type_name.contains(
"long long")) {
1050 return GetType(ast.UnsignedLongLongTy);
1051 }
else if (type_name.contains(
"long")) {
1053 return GetType(ast.UnsignedLongTy);
1054 }
else if (type_name.contains(
"short")) {
1056 return GetType(ast.UnsignedShortTy);
1057 }
else if (type_name.contains(
"char")) {
1059 return GetType(ast.UnsignedCharTy);
1060 }
else if (type_name.contains(
"int")) {
1062 return GetType(ast.UnsignedIntTy);
1064 return GetType(ast.UnsignedInt128Ty);
1069 return GetType(ast.UnsignedCharTy);
1071 return GetType(ast.UnsignedShortTy);
1073 return GetType(ast.UnsignedIntTy);
1075 return GetType(ast.UnsignedLongTy);
1077 return GetType(ast.UnsignedLongLongTy);
1079 return GetType(ast.UnsignedInt128Ty);
1082 case DW_ATE_unsigned_char:
1083 if (type_name ==
"char") {
1088 return GetType(ast.UnsignedCharTy);
1090 return GetType(ast.UnsignedShortTy);
1093 case DW_ATE_imaginary_float:
1105 if (!type_name.empty()) {
1106 if (type_name ==
"char16_t")
1108 if (type_name ==
"char32_t")
1110 if (type_name ==
"char8_t")
1119 "error: need to add support for DW_TAG_base_type '{0}' "
1120 "encoded with DW_ATE = {1:x}, bit_size = {2}",
1121 type_name, dw_ate, bit_size);
1127 QualType char_type(ast.CharTy);
1130 char_type.addConst();
1132 return GetType(ast.getPointerType(char_type));
1136 bool ignore_qualifiers) {
1147 if (ignore_qualifiers) {
1148 type1_qual = type1_qual.getUnqualifiedType();
1149 type2_qual = type2_qual.getUnqualifiedType();
1152 return ast->getASTContext().hasSameType(type1_qual, type2_qual);
1159 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
1160 if (
auto *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl))
1172 if (clang::ObjCInterfaceDecl *interface_decl =
1173 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
1175 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
1177 if (clang::ValueDecl *value_decl = llvm::dyn_cast<clang::ValueDecl>(decl))
1191 return GetType(value_decl->getType());
1194#pragma mark Structure, Unions, Classes
1198 if (!decl || !owning_module.
HasValue())
1201 decl->setFromASTFile();
1202 decl->setOwningModuleID(owning_module.
GetValue());
1203 decl->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
1209 bool is_framework,
bool is_explicit) {
1211 auto *ast_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1213 assert(ast_source &&
"external ast source was lost");
1231 clang::Module *module;
1232 auto parent_desc = ast_source->getSourceDescriptor(parent.
GetValue());
1234 name, parent_desc ? parent_desc->getModuleOrNull() :
nullptr,
1235 is_framework, is_explicit);
1237 return ast_source->GetIDForModule(module);
1239 return ast_source->RegisterModule(module);
1244 AccessType access_type, llvm::StringRef name,
int kind,
1245 LanguageType language, std::optional<ClangASTMetadata> metadata,
1246 bool exports_symbols) {
1249 if (decl_ctx ==
nullptr)
1250 decl_ctx = ast.getTranslationUnitDecl();
1254 bool isInternal =
false;
1255 return CreateObjCClass(name, decl_ctx, owning_module, isInternal, metadata);
1264 bool has_name = !name.empty();
1265 CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1266 decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1267 decl->setDeclContext(decl_ctx);
1269 decl->setDeclName(&ast.Idents.get(name));
1297 if (isa<CXXRecordDecl>(decl_ctx) && exports_symbols)
1298 decl->setAnonymousStructOrUnion(
true);
1308 decl_ctx->addDecl(decl);
1310 return GetType(ast.getCanonicalTagType(decl));
1317QualType GetValueParamType(
const clang::TemplateArgument &argument) {
1318 switch (argument.getKind()) {
1319 case TemplateArgument::Integral:
1320 return argument.getIntegralType();
1321 case TemplateArgument::StructuralValue:
1322 return argument.getStructuralValueType();
1328void AddAccessSpecifierDecl(clang::CXXRecordDecl *cxx_record_decl,
1330 clang::AccessSpecifier previous_access,
1331 clang::AccessSpecifier access_specifier) {
1332 if (!cxx_record_decl->isClass() && !cxx_record_decl->isStruct())
1334 if (previous_access != access_specifier) {
1337 if ((cxx_record_decl->isStruct() &&
1338 previous_access == clang::AccessSpecifier::AS_none &&
1339 access_specifier == clang::AccessSpecifier::AS_public) ||
1340 (cxx_record_decl->isClass() &&
1341 previous_access == clang::AccessSpecifier::AS_none &&
1342 access_specifier == clang::AccessSpecifier::AS_private)) {
1345 cxx_record_decl->addDecl(
1346 AccessSpecDecl::Create(ct, access_specifier, cxx_record_decl,
1347 SourceLocation(), SourceLocation()));
1355 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1356 const bool parameter_pack =
false;
1357 const bool is_typename =
false;
1358 const unsigned depth = 0;
1359 const size_t num_template_params = template_param_infos.
Size();
1360 DeclContext *
const decl_context =
1361 ast.getTranslationUnitDecl();
1363 auto const &args = template_param_infos.
GetArgs();
1364 auto const &names = template_param_infos.
GetNames();
1365 for (
size_t i = 0; i < num_template_params; ++i) {
1366 const char *name = names[i];
1368 IdentifierInfo *identifier_info =
nullptr;
1369 if (name && name[0])
1370 identifier_info = &ast.Idents.get(name);
1371 TemplateArgument
const &targ = args[i];
1372 QualType template_param_type = GetValueParamType(targ);
1373 if (!template_param_type.isNull()) {
1374 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1375 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1376 identifier_info, template_param_type, parameter_pack,
1377 ast.getTrivialTypeSourceInfo(template_param_type)));
1379 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1380 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1381 identifier_info, is_typename, parameter_pack));
1386 IdentifierInfo *identifier_info =
nullptr;
1388 identifier_info = &ast.Idents.get(template_param_infos.
GetPackName());
1389 const bool parameter_pack_true =
true;
1391 QualType template_param_type =
1395 if (!template_param_type.isNull()) {
1396 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1397 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1398 num_template_params, identifier_info, template_param_type,
1399 parameter_pack_true,
1400 ast.getTrivialTypeSourceInfo(template_param_type)));
1402 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1403 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1404 num_template_params, identifier_info, is_typename,
1405 parameter_pack_true));
1408 clang::Expr *
const requires_clause =
nullptr;
1409 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1410 ast, SourceLocation(), SourceLocation(), template_param_decls,
1411 SourceLocation(), requires_clause);
1412 return template_param_list;
1417 clang::FunctionDecl *func_decl,
1422 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1424 ast, template_param_infos, template_param_decls);
1425 FunctionTemplateDecl *func_tmpl_decl =
1426 FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1427 func_tmpl_decl->setDeclContext(decl_ctx);
1428 func_tmpl_decl->setLocation(func_decl->getLocation());
1429 func_tmpl_decl->setDeclName(func_decl->getDeclName());
1430 func_tmpl_decl->setTemplateParameters(template_param_list);
1431 func_tmpl_decl->init(func_decl);
1434 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1435 i < template_param_decl_count; ++i) {
1437 template_param_decls[i]->setDeclContext(func_decl);
1442 if (decl_ctx->isRecord())
1443 func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
1445 return func_tmpl_decl;
1449 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1451 TemplateArgumentList *template_args_ptr = TemplateArgumentList::CreateCopy(
1452 func_decl->getASTContext(), infos.
GetArgs());
1454 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
1455 template_args_ptr,
nullptr);
1462 const TemplateArgument &value) {
1463 if (llvm::isa<TemplateTypeParmDecl>(param)) {
1465 if (value.getKind() != TemplateArgument::Type)
1467 }
else if (
auto *type_param =
1468 llvm::dyn_cast<NonTypeTemplateParmDecl>(param)) {
1470 QualType value_param_type = GetValueParamType(value);
1471 if (value_param_type.isNull())
1475 if (type_param->getType() != value_param_type)
1483 "Don't know how to compare template parameter to passed"
1484 " value. Decl kind of parameter is: {0}",
1485 param->getDeclKindName());
1486 lldbassert(
false &&
"Can't compare this TemplateParmDecl subclass");
1501 ClassTemplateDecl *class_template_decl,
1504 TemplateParameterList ¶ms = *class_template_decl->getTemplateParameters();
1510 std::optional<NamedDecl *> pack_parameter;
1512 size_t non_pack_params = params.size();
1513 for (
size_t i = 0; i < params.size(); ++i) {
1514 NamedDecl *param = params.getParam(i);
1515 if (param->isParameterPack()) {
1516 pack_parameter = param;
1517 non_pack_params = i;
1525 if (non_pack_params != instantiation_values.
Size())
1543 for (
const auto pair :
1544 llvm::zip_first(instantiation_values.
GetArgs(), params)) {
1545 const TemplateArgument &passed_arg = std::get<0>(pair);
1546 NamedDecl *found_param = std::get<1>(pair);
1551 return class_template_decl;
1560 ClassTemplateDecl *class_template_decl =
nullptr;
1561 if (decl_ctx ==
nullptr)
1562 decl_ctx = ast.getTranslationUnitDecl();
1564 IdentifierInfo &identifier_info = ast.Idents.get(class_name);
1565 DeclarationName decl_name(&identifier_info);
1568 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1569 for (NamedDecl *decl : result) {
1570 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1571 if (!class_template_decl)
1580 template_param_infos))
1582 return class_template_decl;
1585 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1588 ast, template_param_infos, template_param_decls);
1590 CXXRecordDecl *template_cxx_decl =
1591 CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1592 template_cxx_decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1594 template_cxx_decl->setDeclContext(decl_ctx);
1595 template_cxx_decl->setDeclName(decl_name);
1598 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1599 i < template_param_decl_count; ++i) {
1600 template_param_decls[i]->setDeclContext(template_cxx_decl);
1608 class_template_decl =
1609 ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1611 class_template_decl->setDeclContext(decl_ctx);
1612 class_template_decl->setDeclName(decl_name);
1613 class_template_decl->setTemplateParameters(template_param_list);
1614 class_template_decl->init(template_cxx_decl);
1615 template_cxx_decl->setDescribedClassTemplate(class_template_decl);
1619 class_template_decl->setAccess(
1622 decl_ctx->addDecl(class_template_decl);
1624 VerifyDecl(class_template_decl);
1626 return class_template_decl;
1629TemplateTemplateParmDecl *
1633 auto *decl_ctx = ast.getTranslationUnitDecl();
1635 IdentifierInfo &identifier_info = ast.Idents.get(template_name);
1636 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1640 ast, template_param_infos, template_param_decls);
1646 return TemplateTemplateParmDecl::Create(
1647 ast, decl_ctx, SourceLocation(),
1649 false, &identifier_info,
1650 TemplateNameKind::TNK_Type_template,
true,
1651 template_param_list);
1654ClassTemplateSpecializationDecl *
1657 ClassTemplateDecl *class_template_decl,
int kind,
1660 llvm::SmallVector<clang::TemplateArgument, 2> args(
1661 template_param_infos.
Size() +
1664 auto const &orig_args = template_param_infos.
GetArgs();
1665 std::copy(orig_args.begin(), orig_args.end(), args.begin());
1667 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1670 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1671 ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
1672 class_template_specialization_decl->setTagKind(
1673 static_cast<TagDecl::TagKind
>(kind));
1674 class_template_specialization_decl->setDeclContext(decl_ctx);
1675 class_template_specialization_decl->setInstantiationOf(class_template_decl);
1676 class_template_specialization_decl->setTemplateArgs(
1677 TemplateArgumentList::CreateCopy(ast, args));
1678 class_template_specialization_decl->setDeclName(
1679 class_template_decl->getDeclName());
1684 class_template_specialization_decl->setStrictPackMatch(
false);
1687 decl_ctx->addDecl(class_template_specialization_decl);
1689 class_template_specialization_decl->setSpecializationKind(
1690 TSK_ExplicitSpecialization);
1692 return class_template_specialization_decl;
1696 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1697 if (class_template_specialization_decl) {
1699 return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
1705 clang::OverloadedOperatorKind op_kind,
1706 bool unary,
bool binary,
1707 uint32_t num_params) {
1709 if (op_kind == OO_Call)
1715 if (num_params == 1)
1717 if (num_params == 2)
1724 bool is_method, clang::OverloadedOperatorKind op_kind,
1725 uint32_t num_params) {
1733 case OO_Array_Delete:
1737#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1739 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1741#include "clang/Basic/OperatorKinds.def"
1748clang::AccessSpecifier
1750 clang::AccessSpecifier rhs) {
1753 if (lhs == AS_none || rhs == AS_none)
1755 if (lhs == AS_private || rhs == AS_private)
1757 if (lhs == AS_protected || rhs == AS_protected)
1758 return AS_protected;
1763 uint32_t &bitfield_bit_size) {
1765 if (field ==
nullptr)
1768 if (field->isBitField()) {
1769 Expr *bit_width_expr = field->getBitWidth();
1770 if (bit_width_expr) {
1771 if (std::optional<llvm::APSInt> bit_width_apsint =
1772 bit_width_expr->getIntegerConstantExpr(ast)) {
1773 bitfield_bit_size = bit_width_apsint->getLimitedValue(
UINT32_MAX);
1782 if (record_decl ==
nullptr)
1785 if (!record_decl->field_empty())
1789 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1790 if (cxx_record_decl) {
1791 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1792 for (base_class = cxx_record_decl->bases_begin(),
1793 base_class_end = cxx_record_decl->bases_end();
1794 base_class != base_class_end; ++base_class) {
1806 if (std::optional<ClangASTMetadata> meta_data =
GetMetadata(record_decl);
1807 meta_data && meta_data->IsForcefullyCompleted())
1813#pragma mark Objective-C Classes
1816 llvm::StringRef name, clang::DeclContext *decl_ctx,
1818 std::optional<ClangASTMetadata> metadata) {
1820 assert(!name.empty());
1822 decl_ctx = ast.getTranslationUnitDecl();
1824 ObjCInterfaceDecl *decl =
1825 ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
1826 decl->setDeclContext(decl_ctx);
1827 decl->setDeclName(&ast.Idents.get(name));
1828 decl->setImplicit(isInternal);
1834 return GetType(ast.getObjCInterfaceType(decl));
1843 bool omit_empty_base_classes) {
1844 uint32_t num_bases = 0;
1845 if (cxx_record_decl) {
1846 if (omit_empty_base_classes) {
1847 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1848 for (base_class = cxx_record_decl->bases_begin(),
1849 base_class_end = cxx_record_decl->bases_end();
1850 base_class != base_class_end; ++base_class) {
1857 num_bases = cxx_record_decl->getNumBases();
1862#pragma mark Namespace Declarations
1865 const char *name, clang::DeclContext *decl_ctx,
1867 NamespaceDecl *namespace_decl =
nullptr;
1869 TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
1871 decl_ctx = translation_unit_decl;
1874 IdentifierInfo &identifier_info = ast.Idents.get(name);
1875 DeclarationName decl_name(&identifier_info);
1876 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1877 for (NamedDecl *decl : result) {
1878 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1880 return namespace_decl;
1883 namespace_decl = NamespaceDecl::Create(ast, decl_ctx, is_inline,
1884 SourceLocation(), SourceLocation(),
1885 &identifier_info,
nullptr,
false);
1887 decl_ctx->addDecl(namespace_decl);
1889 if (decl_ctx == translation_unit_decl) {
1890 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1892 return namespace_decl;
1895 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1896 SourceLocation(),
nullptr,
nullptr,
false);
1897 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1898 translation_unit_decl->addDecl(namespace_decl);
1899 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace());
1901 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1902 if (parent_namespace_decl) {
1903 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1905 return namespace_decl;
1907 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1908 SourceLocation(),
nullptr,
nullptr,
false);
1909 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1910 parent_namespace_decl->addDecl(namespace_decl);
1911 assert(namespace_decl ==
1912 parent_namespace_decl->getAnonymousNamespace());
1914 assert(
false &&
"GetUniqueNamespaceDeclaration called with no name and "
1915 "no namespace as decl_ctx");
1923 VerifyDecl(namespace_decl);
1924 return namespace_decl;
1931 clang::BlockDecl *decl =
1932 clang::BlockDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1933 decl->setDeclContext(ctx);
1942 clang::DeclContext *right,
1943 clang::DeclContext *root) {
1944 if (root ==
nullptr)
1947 std::set<clang::DeclContext *> path_left;
1948 for (clang::DeclContext *d = left; d !=
nullptr; d = d->getParent())
1949 path_left.insert(d);
1951 for (clang::DeclContext *d = right; d !=
nullptr; d = d->getParent())
1952 if (path_left.find(d) != path_left.end())
1960 clang::NamespaceDecl *ns_decl) {
1961 if (decl_ctx && ns_decl) {
1962 auto *translation_unit =
getASTContext().getTranslationUnitDecl();
1963 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
1965 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
1966 clang::SourceLocation(), ns_decl,
1969 decl_ctx->addDecl(using_decl);
1979 clang::NamedDecl *target) {
1980 if (current_decl_ctx && target) {
1981 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
1983 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(),
false);
1985 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
1987 target->getDeclName(), using_decl, target);
1989 using_decl->addShadowDecl(shadow_decl);
1990 current_decl_ctx->addDecl(using_decl);
1998 const char *name, clang::QualType type) {
2000 clang::VarDecl *var_decl =
2001 clang::VarDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
2002 var_decl->setDeclContext(decl_context);
2003 if (name && name[0])
2004 var_decl->setDeclName(&
getASTContext().Idents.getOwn(name));
2005 var_decl->setType(type);
2007 var_decl->setAccess(clang::AS_public);
2008 decl_context->addDecl(var_decl);
2017 switch (basic_type) {
2019 return ast->VoidTy.getAsOpaquePtr();
2021 return ast->CharTy.getAsOpaquePtr();
2023 return ast->SignedCharTy.getAsOpaquePtr();
2025 return ast->UnsignedCharTy.getAsOpaquePtr();
2027 return ast->getWCharType().getAsOpaquePtr();
2029 return ast->getSignedWCharType().getAsOpaquePtr();
2031 return ast->getUnsignedWCharType().getAsOpaquePtr();
2033 return ast->Char8Ty.getAsOpaquePtr();
2035 return ast->Char16Ty.getAsOpaquePtr();
2037 return ast->Char32Ty.getAsOpaquePtr();
2039 return ast->ShortTy.getAsOpaquePtr();
2041 return ast->UnsignedShortTy.getAsOpaquePtr();
2043 return ast->IntTy.getAsOpaquePtr();
2045 return ast->UnsignedIntTy.getAsOpaquePtr();
2047 return ast->LongTy.getAsOpaquePtr();
2049 return ast->UnsignedLongTy.getAsOpaquePtr();
2051 return ast->LongLongTy.getAsOpaquePtr();
2053 return ast->UnsignedLongLongTy.getAsOpaquePtr();
2055 return ast->Int128Ty.getAsOpaquePtr();
2057 return ast->UnsignedInt128Ty.getAsOpaquePtr();
2059 return ast->BoolTy.getAsOpaquePtr();
2061 return ast->HalfTy.getAsOpaquePtr();
2063 return ast->FloatTy.getAsOpaquePtr();
2065 return ast->DoubleTy.getAsOpaquePtr();
2067 return ast->LongDoubleTy.getAsOpaquePtr();
2069 return ast->Float128Ty.getAsOpaquePtr();
2071 return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
2073 return ast->getComplexType(ast->DoubleTy).getAsOpaquePtr();
2075 return ast->getComplexType(ast->LongDoubleTy).getAsOpaquePtr();
2077 return ast->getObjCIdType().getAsOpaquePtr();
2079 return ast->getObjCClassType().getAsOpaquePtr();
2081 return ast->getObjCSelType().getAsOpaquePtr();
2083 return ast->NullPtrTy.getAsOpaquePtr();
2089#pragma mark Function Types
2091clang::DeclarationName
2094 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2095 if (!
IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2104 const clang::FunctionProtoType *function_type =
2105 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2106 if (function_type ==
nullptr)
2107 return clang::DeclarationName();
2109 const bool is_method =
false;
2110 const unsigned int num_params = function_type->getNumParams();
2112 is_method, op_kind, num_params))
2113 return clang::DeclarationName();
2115 return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
2119 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
2120 printing_policy.SuppressTagKeyword =
true;
2123 printing_policy.SuppressInlineNamespace =
false;
2124 printing_policy.SuppressUnwrittenScope =
false;
2136 printing_policy.SuppressDefaultTemplateArgs =
false;
2137 return printing_policy;
2144 llvm::raw_string_ostream os(result);
2145 named_decl->getNameForDiagnostic(os, printing_policy, qualified);
2151 llvm::StringRef name,
const CompilerType &function_clang_type,
2152 clang::StorageClass storage,
bool is_inline, llvm::StringRef asm_label) {
2153 FunctionDecl *func_decl =
nullptr;
2156 decl_ctx = ast.getTranslationUnitDecl();
2158 const bool hasWrittenPrototype =
true;
2159 const bool isConstexprSpecified =
false;
2161 clang::DeclarationName declarationName =
2163 func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
2164 func_decl->setDeclContext(decl_ctx);
2165 func_decl->setDeclName(declarationName);
2167 func_decl->setStorageClass(storage);
2168 func_decl->setInlineSpecified(is_inline);
2169 func_decl->setHasWrittenPrototype(hasWrittenPrototype);
2170 func_decl->setConstexprKind(isConstexprSpecified
2171 ? ConstexprSpecKind::Constexpr
2172 : ConstexprSpecKind::Unspecified);
2184 if (!asm_label.empty())
2185 func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label));
2188 decl_ctx->addDecl(func_decl);
2190 VerifyDecl(func_decl);
2196 const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
2197 bool is_variadic,
unsigned type_quals, clang::CallingConv cc,
2198 clang::RefQualifierKind ref_qual) {
2202 std::vector<QualType> qual_type_args;
2204 for (
const auto &arg : args) {
2219 FunctionProtoType::ExtProtoInfo proto_info;
2220 proto_info.ExtInfo = cc;
2221 proto_info.Variadic = is_variadic;
2222 proto_info.ExceptionSpec = EST_None;
2223 proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
2224 proto_info.RefQualifier = ref_qual;
2232 const char *name,
const CompilerType ¶m_type,
int storage,
2235 auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
2236 decl->setDeclContext(decl_ctx);
2237 if (name && name[0])
2238 decl->setDeclName(&ast.Idents.get(name));
2240 decl->setStorageClass(
static_cast<clang::StorageClass
>(storage));
2243 decl_ctx->addDecl(decl);
2250 QualType block_type =
m_ast_up->getBlockPointerType(
2256#pragma mark Array Types
2260 std::optional<size_t> element_count,
2273 clang::ArraySizeModifier::Normal, 0));
2279 llvm::APInt ap_element_count(64, *element_count);
2281 ap_element_count,
nullptr,
2282 clang::ArraySizeModifier::Normal, 0));
2286 llvm::StringRef type_name,
2287 const std::initializer_list<std::pair<const char *, CompilerType>>
2294 lldbassert(0 &&
"Trying to create a type for an existing name");
2302 for (
const auto &field : type_fields)
2312 llvm::StringRef type_name,
2313 const std::initializer_list<std::pair<const char *, CompilerType>>
2325#pragma mark Enumeration Types
2328 llvm::StringRef name, clang::DeclContext *decl_ctx,
2330 const CompilerType &integer_clang_type,
bool is_scoped,
2331 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind) {
2338 EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
2339 enum_decl->setDeclContext(decl_ctx);
2341 enum_decl->setDeclName(&ast.Idents.get(name));
2342 enum_decl->setScoped(is_scoped);
2343 enum_decl->setScopedUsingClassTag(is_scoped);
2344 enum_decl->setFixed(
false);
2347 decl_ctx->addDecl(enum_decl);
2351 clang::EnumExtensibilityAttr::CreateImplicit(ast, *enum_kind));
2356 enum_decl->setAccess(AS_public);
2358 return GetType(ast.getCanonicalTagType(enum_decl));
2369 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
2370 return GetType(ast.SignedCharTy);
2372 if (bit_size == ast.getTypeSize(ast.ShortTy))
2375 if (bit_size == ast.getTypeSize(ast.IntTy))
2378 if (bit_size == ast.getTypeSize(ast.LongTy))
2381 if (bit_size == ast.getTypeSize(ast.LongLongTy))
2382 return GetType(ast.LongLongTy);
2384 if (bit_size == ast.getTypeSize(ast.Int128Ty))
2387 if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
2388 return GetType(ast.UnsignedCharTy);
2390 if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
2391 return GetType(ast.UnsignedShortTy);
2393 if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
2394 return GetType(ast.UnsignedIntTy);
2396 if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
2397 return GetType(ast.UnsignedLongTy);
2399 if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
2400 return GetType(ast.UnsignedLongLongTy);
2402 if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
2403 return GetType(ast.UnsignedInt128Ty);
2420 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2422 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2423 named_decl->getDeclName().getAsString().c_str());
2425 printf(
"%20s\n", decl_ctx->getDeclKindName());
2431 if (decl ==
nullptr)
2435 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2437 bool is_injected_class_name =
2438 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2439 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2440 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2441 record_decl->getDeclName().getAsString().c_str(),
2442 is_injected_class_name ?
" (injected class name)" :
"");
2445 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2447 printf(
"%20s: %s\n", decl->getDeclKindName(),
2448 named_decl->getDeclName().getAsString().c_str());
2450 printf(
"%20s\n", decl->getDeclKindName());
2456 clang::Decl *decl) {
2460 ExternalASTSource *ast_source = ast->getExternalSource();
2465 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2466 if (tag_decl->isCompleteDefinition())
2469 if (!tag_decl->hasExternalLexicalStorage())
2472 ast_source->CompleteType(tag_decl);
2474 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2475 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2476 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2477 if (objc_interface_decl->getDefinition())
2480 if (!objc_interface_decl->hasExternalLexicalStorage())
2483 ast_source->CompleteType(objc_interface_decl);
2485 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2515std::optional<ClangASTMetadata>
2521 return std::nullopt;
2524std::optional<ClangASTMetadata>
2530 return std::nullopt;
2534 clang::AccessSpecifier access) {
2535 if (access == clang::AccessSpecifier::AS_none)
2541clang::AccessSpecifier
2546 return clang::AccessSpecifier::AS_none;
2568 if (find(mask, type->getTypeClass()) != mask.end())
2570 switch (type->getTypeClass()) {
2573 case clang::Type::Atomic:
2574 type = cast<clang::AtomicType>(type)->getValueType();
2576 case clang::Type::Auto:
2577 case clang::Type::Decltype:
2578 case clang::Type::Paren:
2579 case clang::Type::SubstTemplateTypeParm:
2580 case clang::Type::TemplateSpecialization:
2581 case clang::Type::Typedef:
2582 case clang::Type::TypeOf:
2583 case clang::Type::TypeOfExpr:
2584 case clang::Type::Using:
2585 case clang::Type::PredefinedSugar:
2586 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2600 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2601 switch (type_class) {
2602 case clang::Type::ObjCInterface:
2603 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2605 case clang::Type::ObjCObjectPointer:
2607 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2608 ->getPointeeType());
2609 case clang::Type::Enum:
2610 case clang::Type::Record:
2611 return llvm::cast<clang::TagType>(qual_type)
2613 ->getDefinitionOrSelf();
2626 clang::QualType qual_type,
2627 bool allow_completion) {
2628 assert(qual_type->isRecordType());
2630 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2632 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2636 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2639 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2640 const bool fields_loaded =
2641 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2644 if (is_complete && fields_loaded)
2647 if (!allow_completion)
2655 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2656 if (external_ast_source) {
2657 external_ast_source->CompleteType(cxx_record_decl);
2658 if (cxx_record_decl->isCompleteDefinition()) {
2659 cxx_record_decl->field_begin();
2660 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
2672 clang::QualType qual_type,
2673 bool allow_completion) {
2674 assert(qual_type->isEnumeralType());
2677 const clang::EnumType *enum_type =
2678 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2680 auto *tag_decl = enum_type->getAsTagDecl();
2684 if (tag_decl->getDefinition())
2687 if (!allow_completion)
2691 if (!tag_decl->hasExternalLexicalStorage())
2695 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2696 if (!external_ast_source)
2699 external_ast_source->CompleteType(tag_decl);
2707static const clang::ObjCObjectType *
2709 bool allow_completion) {
2710 assert(qual_type->isObjCObjectType());
2713 const clang::ObjCObjectType *objc_class_type =
2714 llvm::cast<clang::ObjCObjectType>(qual_type);
2716 clang::ObjCInterfaceDecl *class_interface_decl =
2717 objc_class_type->getInterface();
2720 if (!class_interface_decl)
2721 return objc_class_type;
2724 if (class_interface_decl->getDefinition())
2725 return objc_class_type;
2727 if (!allow_completion)
2731 if (!class_interface_decl->hasExternalLexicalStorage())
2735 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2736 if (!external_ast_source)
2739 external_ast_source->CompleteType(class_interface_decl);
2740 return objc_class_type;
2744 clang::QualType qual_type,
2745 bool allow_completion =
true) {
2747 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2748 switch (type_class) {
2749 case clang::Type::ConstantArray:
2750 case clang::Type::IncompleteArray:
2751 case clang::Type::VariableArray: {
2752 const clang::ArrayType *array_type =
2753 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2759 case clang::Type::Record: {
2760 if (
const auto *RT =
2762 return !RT->isIncompleteType();
2767 case clang::Type::Enum: {
2769 return !ET->isIncompleteType();
2773 case clang::Type::ObjCObject:
2774 case clang::Type::ObjCInterface: {
2775 if (
const auto *OT =
2777 return !OT->isIncompleteType();
2782 case clang::Type::Attributed:
2784 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType(),
2787 case clang::Type::MemberPointer:
2790 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2791 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2792 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2796 return !qual_type.getTypePtr()->isIncompleteType();
2807static clang::ObjCIvarDecl::AccessControl
2811 return clang::ObjCIvarDecl::None;
2813 return clang::ObjCIvarDecl::Public;
2815 return clang::ObjCIvarDecl::Private;
2817 return clang::ObjCIvarDecl::Protected;
2819 return clang::ObjCIvarDecl::Package;
2821 return clang::ObjCIvarDecl::None;
2828 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2835 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2836 switch (type_class) {
2837 case clang::Type::IncompleteArray:
2838 case clang::Type::VariableArray:
2839 case clang::Type::ConstantArray:
2840 case clang::Type::ExtVector:
2841 case clang::Type::Vector:
2842 case clang::Type::Record:
2843 case clang::Type::ObjCObject:
2844 case clang::Type::ObjCInterface:
2856 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2857 switch (type_class) {
2858 case clang::Type::Record: {
2859 if (
const clang::RecordType *record_type =
2860 llvm::dyn_cast_or_null<clang::RecordType>(
2861 qual_type.getTypePtrOrNull())) {
2862 if (
const clang::RecordDecl *record_decl =
2863 record_type->getOriginalDecl()) {
2864 return record_decl->isAnonymousStructOrUnion();
2878 uint64_t *size,
bool *is_incomplete) {
2881 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2882 switch (type_class) {
2886 case clang::Type::ConstantArray:
2887 if (element_type_ptr)
2889 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2893 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2895 .getLimitedValue(ULLONG_MAX);
2897 *is_incomplete =
false;
2900 case clang::Type::IncompleteArray:
2901 if (element_type_ptr)
2903 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2909 *is_incomplete =
true;
2912 case clang::Type::VariableArray:
2913 if (element_type_ptr)
2915 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2921 *is_incomplete =
false;
2924 case clang::Type::DependentSizedArray:
2925 if (element_type_ptr)
2928 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2934 *is_incomplete =
false;
2937 if (element_type_ptr)
2938 element_type_ptr->
Clear();
2942 *is_incomplete =
false;
2950 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2951 switch (type_class) {
2952 case clang::Type::Vector: {
2953 const clang::VectorType *vector_type =
2954 qual_type->getAs<clang::VectorType>();
2957 *size = vector_type->getNumElements();
2959 *element_type =
GetType(vector_type->getElementType());
2963 case clang::Type::ExtVector: {
2964 const clang::ExtVectorType *ext_vector_type =
2965 qual_type->getAs<clang::ExtVectorType>();
2966 if (ext_vector_type) {
2968 *size = ext_vector_type->getNumElements();
2972 ext_vector_type->getElementType().getAsOpaquePtr());
2988 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
2991 clang::ObjCInterfaceDecl *result_iface_decl =
2992 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
2994 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
2998 return (ast_metadata->GetISAPtr() != 0);
3002 return GetQualType(type).getUnqualifiedType()->isCharType();
3011 const bool allow_completion =
true;
3026 if (!pointee_or_element_clang_type.
IsValid())
3029 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
3030 if (pointee_or_element_clang_type.
IsCharType()) {
3031 if (type_flags.
Test(eTypeIsArray)) {
3034 length = llvm::cast<clang::ConstantArrayType>(
3048 if (
auto pointer_auth = qual_type.getPointerAuth())
3049 return pointer_auth.getKey();
3058 if (
auto pointer_auth = qual_type.getPointerAuth())
3059 return pointer_auth.getExtraDiscriminator();
3068 if (
auto pointer_auth = qual_type.getPointerAuth())
3069 return pointer_auth.isAddressDiscriminated();
3075 auto isFunctionType = [&](clang::QualType qual_type) {
3076 return qual_type->isFunctionType();
3090 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3091 switch (type_class) {
3092 case clang::Type::Record:
3094 const clang::CXXRecordDecl *cxx_record_decl =
3095 qual_type->getAsCXXRecordDecl();
3096 if (cxx_record_decl) {
3097 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3100 const clang::RecordType *record_type =
3101 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3103 if (
const clang::RecordDecl *record_decl =
3104 record_type->getOriginalDecl()->getDefinition()) {
3107 clang::RecordDecl::field_iterator field_pos,
3108 field_end = record_decl->field_end();
3109 uint32_t num_fields = 0;
3110 bool is_hva =
false;
3111 bool is_hfa =
false;
3112 clang::QualType base_qual_type;
3113 uint64_t base_bitwidth = 0;
3114 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3116 clang::QualType field_qual_type = field_pos->getType();
3117 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3118 if (field_qual_type->isFloatingType()) {
3119 if (field_qual_type->isComplexType())
3122 if (num_fields == 0)
3123 base_qual_type = field_qual_type;
3128 if (field_qual_type.getTypePtr() !=
3129 base_qual_type.getTypePtr())
3133 }
else if (field_qual_type->isVectorType() ||
3134 field_qual_type->isExtVectorType()) {
3135 if (num_fields == 0) {
3136 base_qual_type = field_qual_type;
3137 base_bitwidth = field_bitwidth;
3142 if (base_bitwidth != field_bitwidth)
3144 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3153 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3170 const clang::FunctionProtoType *func =
3171 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3173 return func->getNumParams();
3180 const size_t index) {
3183 const clang::FunctionProtoType *func =
3184 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3186 if (index < func->getNumParams())
3187 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3195 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3199 if (predicate(qual_type))
3202 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3203 switch (type_class) {
3207 case clang::Type::LValueReference:
3208 case clang::Type::RValueReference: {
3209 const clang::ReferenceType *reference_type =
3210 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3212 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3221 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3222 return qual_type->isMemberFunctionPointerType();
3225 return IsTypeImpl(type, isMemberFunctionPointerType);
3229 auto isFunctionPointerType = [](clang::QualType qual_type) {
3230 return qual_type->isFunctionPointerType();
3233 return IsTypeImpl(type, isFunctionPointerType);
3239 auto isBlockPointerType = [&](clang::QualType qual_type) {
3240 if (qual_type->isBlockPointerType()) {
3241 if (function_pointer_type_ptr) {
3242 const clang::BlockPointerType *block_pointer_type =
3243 qual_type->castAs<clang::BlockPointerType>();
3244 QualType pointee_type = block_pointer_type->getPointeeType();
3245 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3247 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3264 const clang::BuiltinType *builtin_type =
3265 llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3268 if (builtin_type->isInteger()) {
3269 is_signed = builtin_type->isSignedInteger();
3280 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3285 ->getDefinitionOrSelf()
3299 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3303 return enum_type->isScopedEnumeralType();
3314 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3315 switch (type_class) {
3316 case clang::Type::Builtin:
3317 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3320 case clang::BuiltinType::ObjCId:
3321 case clang::BuiltinType::ObjCClass:
3325 case clang::Type::ObjCObjectPointer:
3329 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3333 case clang::Type::BlockPointer:
3336 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3340 case clang::Type::Pointer:
3343 llvm::cast<clang::PointerType>(qual_type)
3347 case clang::Type::MemberPointer:
3350 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3359 pointee_type->
Clear();
3367 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3368 switch (type_class) {
3369 case clang::Type::Builtin:
3370 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3373 case clang::BuiltinType::ObjCId:
3374 case clang::BuiltinType::ObjCClass:
3378 case clang::Type::ObjCObjectPointer:
3382 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3386 case clang::Type::BlockPointer:
3389 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3393 case clang::Type::Pointer:
3396 llvm::cast<clang::PointerType>(qual_type)
3400 case clang::Type::MemberPointer:
3403 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3407 case clang::Type::LValueReference:
3410 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3414 case clang::Type::RValueReference:
3417 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3426 pointee_type->
Clear();
3435 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3437 switch (type_class) {
3438 case clang::Type::LValueReference:
3441 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3447 case clang::Type::RValueReference:
3450 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3462 pointee_type->
Clear();
3467 uint32_t &count,
bool &is_complex) {
3471 if (
const clang::BuiltinType *BT = llvm::dyn_cast<clang::BuiltinType>(
3472 qual_type->getCanonicalTypeInternal())) {
3473 clang::BuiltinType::Kind kind = BT->getKind();
3474 if (kind >= clang::BuiltinType::Float &&
3475 kind <= clang::BuiltinType::LongDouble) {
3480 }
else if (
const clang::ComplexType *CT =
3481 llvm::dyn_cast<clang::ComplexType>(
3482 qual_type->getCanonicalTypeInternal())) {
3489 }
else if (
const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(
3490 qual_type->getCanonicalTypeInternal())) {
3493 count = VT->getNumElements();
3509 const clang::TagType *tag_type =
3510 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3512 if (clang::TagDecl *tag_decl = tag_type->getOriginalDecl()->getDefinition())
3513 return tag_decl->isCompleteDefinition();
3516 const clang::ObjCObjectType *objc_class_type =
3517 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3518 if (objc_class_type) {
3519 clang::ObjCInterfaceDecl *class_interface_decl =
3520 objc_class_type->getInterface();
3521 if (class_interface_decl)
3522 return class_interface_decl->getDefinition() !=
nullptr;
3533 const clang::ObjCObjectPointerType *obj_pointer_type =
3534 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3536 if (obj_pointer_type)
3537 return obj_pointer_type->isObjCClassType();
3552 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3553 return (type_class == clang::Type::Record);
3560 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3561 return (type_class == clang::Type::Enum);
3567 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3568 switch (type_class) {
3569 case clang::Type::Record:
3571 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3578 return cxx_record_decl->isDynamicClass();
3592 bool check_cplusplus,
3594 if (dynamic_pointee_type)
3595 dynamic_pointee_type->
Clear();
3599 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3600 if (dynamic_pointee_type)
3602 type.getAsOpaquePtr());
3605 clang::QualType pointee_qual_type;
3607 switch (qual_type->getTypeClass()) {
3608 case clang::Type::Builtin:
3609 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3610 clang::BuiltinType::ObjCId) {
3611 set_dynamic_pointee_type(qual_type);
3616 case clang::Type::ObjCObjectPointer:
3619 if (
const auto *objc_pointee_type =
3620 qual_type->getPointeeType().getTypePtrOrNull()) {
3621 if (
const auto *objc_object_type =
3622 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3623 objc_pointee_type)) {
3624 if (objc_object_type->isObjCClass())
3628 set_dynamic_pointee_type(
3629 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3632 case clang::Type::Pointer:
3634 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3637 case clang::Type::LValueReference:
3638 case clang::Type::RValueReference:
3640 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3650 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3651 case clang::Type::Builtin:
3652 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3653 case clang::BuiltinType::UnknownAny:
3654 case clang::BuiltinType::Void:
3655 set_dynamic_pointee_type(pointee_qual_type);
3661 case clang::Type::Record: {
3662 if (!check_cplusplus)
3664 clang::CXXRecordDecl *cxx_record_decl =
3665 pointee_qual_type->getAsCXXRecordDecl();
3666 if (!cxx_record_decl)
3670 if (cxx_record_decl->isCompleteDefinition())
3671 success = cxx_record_decl->isDynamicClass();
3673 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3674 std::optional<bool> is_dynamic =
3675 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3677 success = *is_dynamic;
3679 success = cxx_record_decl->isDynamicClass();
3685 set_dynamic_pointee_type(pointee_qual_type);
3689 case clang::Type::ObjCObject:
3690 case clang::Type::ObjCInterface:
3692 set_dynamic_pointee_type(pointee_qual_type);
3707 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3714 ->getTypeClass() == clang::Type::Typedef;
3724 if (
auto *record_decl =
3726 return record_decl->canPassInRegisters();
3732 return TypeSystemClangSupportsLanguage(language);
3735std::optional<std::string>
3738 return std::nullopt;
3741 if (qual_type.isNull())
3742 return std::nullopt;
3744 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3745 if (!cxx_record_decl)
3746 return std::nullopt;
3748 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3756 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3763 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3765 return tag_type->getOriginalDecl()->isEntityBeingDefined();
3776 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3777 if (class_type_ptr) {
3778 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3779 const clang::ObjCObjectPointerType *obj_pointer_type =
3780 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3781 if (obj_pointer_type ==
nullptr)
3782 class_type_ptr->
Clear();
3786 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3793 class_type_ptr->
Clear();
3802 const bool allow_completion =
true;
3822 {clang::Type::Typedef, clang::Type::Atomic});
3825 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3826 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3833 if (
auto *named_decl = qual_type->getAsTagDecl())
3845 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3846 printing_policy.SuppressTagKeyword =
true;
3847 printing_policy.SuppressScope =
false;
3848 printing_policy.SuppressUnwrittenScope =
true;
3849 printing_policy.SuppressInlineNamespace =
true;
3850 return ConstString(qual_type.getAsString(printing_policy));
3859 if (pointee_or_element_clang_type)
3860 pointee_or_element_clang_type->
Clear();
3862 clang::QualType qual_type =
3865 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3866 switch (type_class) {
3867 case clang::Type::Attributed:
3868 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3871 pointee_or_element_clang_type);
3872 case clang::Type::Builtin: {
3873 const clang::BuiltinType *builtin_type =
3874 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3876 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3877 switch (builtin_type->getKind()) {
3878 case clang::BuiltinType::ObjCId:
3879 case clang::BuiltinType::ObjCClass:
3880 if (pointee_or_element_clang_type)
3884 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3887 case clang::BuiltinType::ObjCSel:
3888 if (pointee_or_element_clang_type)
3891 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3894 case clang::BuiltinType::Bool:
3895 case clang::BuiltinType::Char_U:
3896 case clang::BuiltinType::UChar:
3897 case clang::BuiltinType::WChar_U:
3898 case clang::BuiltinType::Char16:
3899 case clang::BuiltinType::Char32:
3900 case clang::BuiltinType::UShort:
3901 case clang::BuiltinType::UInt:
3902 case clang::BuiltinType::ULong:
3903 case clang::BuiltinType::ULongLong:
3904 case clang::BuiltinType::UInt128:
3905 case clang::BuiltinType::Char_S:
3906 case clang::BuiltinType::SChar:
3907 case clang::BuiltinType::WChar_S:
3908 case clang::BuiltinType::Short:
3909 case clang::BuiltinType::Int:
3910 case clang::BuiltinType::Long:
3911 case clang::BuiltinType::LongLong:
3912 case clang::BuiltinType::Int128:
3913 case clang::BuiltinType::Float:
3914 case clang::BuiltinType::Double:
3915 case clang::BuiltinType::LongDouble:
3916 builtin_type_flags |= eTypeIsScalar;
3917 if (builtin_type->isInteger()) {
3918 builtin_type_flags |= eTypeIsInteger;
3919 if (builtin_type->isSignedInteger())
3920 builtin_type_flags |= eTypeIsSigned;
3921 }
else if (builtin_type->isFloatingPoint())
3922 builtin_type_flags |= eTypeIsFloat;
3927 return builtin_type_flags;
3930 case clang::Type::BlockPointer:
3931 if (pointee_or_element_clang_type)
3933 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3934 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3936 case clang::Type::Complex: {
3937 uint32_t complex_type_flags =
3938 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3939 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3940 qual_type->getCanonicalTypeInternal());
3942 clang::QualType complex_element_type(complex_type->getElementType());
3943 if (complex_element_type->isIntegerType())
3944 complex_type_flags |= eTypeIsFloat;
3945 else if (complex_element_type->isFloatingType())
3946 complex_type_flags |= eTypeIsInteger;
3948 return complex_type_flags;
3951 case clang::Type::ConstantArray:
3952 case clang::Type::DependentSizedArray:
3953 case clang::Type::IncompleteArray:
3954 case clang::Type::VariableArray:
3955 if (pointee_or_element_clang_type)
3957 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
3960 return eTypeHasChildren | eTypeIsArray;
3962 case clang::Type::DependentName:
3964 case clang::Type::DependentSizedExtVector:
3965 return eTypeHasChildren | eTypeIsVector;
3967 case clang::Type::Enum:
3968 if (pointee_or_element_clang_type)
3970 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
3972 ->getDefinitionOrSelf()
3975 return eTypeIsEnumeration | eTypeHasValue;
3977 case clang::Type::FunctionProto:
3978 return eTypeIsFuncPrototype | eTypeHasValue;
3979 case clang::Type::FunctionNoProto:
3980 return eTypeIsFuncPrototype | eTypeHasValue;
3981 case clang::Type::InjectedClassName:
3984 case clang::Type::LValueReference:
3985 case clang::Type::RValueReference:
3986 if (pointee_or_element_clang_type)
3989 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
3992 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
3994 case clang::Type::MemberPointer:
3995 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
3997 case clang::Type::ObjCObjectPointer:
3998 if (pointee_or_element_clang_type)
4000 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4001 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
4004 case clang::Type::ObjCObject:
4005 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4006 case clang::Type::ObjCInterface:
4007 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4009 case clang::Type::Pointer:
4010 if (pointee_or_element_clang_type)
4012 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4013 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
4015 case clang::Type::Record:
4016 if (qual_type->getAsCXXRecordDecl())
4017 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
4019 return eTypeHasChildren | eTypeIsStructUnion;
4021 case clang::Type::SubstTemplateTypeParm:
4022 return eTypeIsTemplate;
4023 case clang::Type::TemplateTypeParm:
4024 return eTypeIsTemplate;
4025 case clang::Type::TemplateSpecialization:
4026 return eTypeIsTemplate;
4028 case clang::Type::Typedef:
4029 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
4031 ->getUnderlyingType())
4033 case clang::Type::UnresolvedUsing:
4036 case clang::Type::ExtVector:
4037 case clang::Type::Vector: {
4038 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
4039 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
4040 qual_type->getCanonicalTypeInternal());
4042 if (vector_type->isIntegerType())
4043 vector_type_flags |= eTypeIsFloat;
4044 else if (vector_type->isFloatingType())
4045 vector_type_flags |= eTypeIsInteger;
4047 return vector_type_flags;
4062 if (qual_type->isAnyPointerType()) {
4063 if (qual_type->isObjCObjectPointerType())
4065 if (qual_type->getPointeeCXXRecordDecl())
4068 clang::QualType pointee_type(qual_type->getPointeeType());
4069 if (pointee_type->getPointeeCXXRecordDecl())
4071 if (pointee_type->isObjCObjectOrInterfaceType())
4073 if (pointee_type->isObjCClassType())
4075 if (pointee_type.getTypePtr() ==
4079 if (qual_type->isObjCObjectOrInterfaceType())
4081 if (qual_type->getAsCXXRecordDecl())
4083 switch (qual_type->getTypeClass()) {
4086 case clang::Type::Builtin:
4087 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4089 case clang::BuiltinType::Void:
4090 case clang::BuiltinType::Bool:
4091 case clang::BuiltinType::Char_U:
4092 case clang::BuiltinType::UChar:
4093 case clang::BuiltinType::WChar_U:
4094 case clang::BuiltinType::Char16:
4095 case clang::BuiltinType::Char32:
4096 case clang::BuiltinType::UShort:
4097 case clang::BuiltinType::UInt:
4098 case clang::BuiltinType::ULong:
4099 case clang::BuiltinType::ULongLong:
4100 case clang::BuiltinType::UInt128:
4101 case clang::BuiltinType::Char_S:
4102 case clang::BuiltinType::SChar:
4103 case clang::BuiltinType::WChar_S:
4104 case clang::BuiltinType::Short:
4105 case clang::BuiltinType::Int:
4106 case clang::BuiltinType::Long:
4107 case clang::BuiltinType::LongLong:
4108 case clang::BuiltinType::Int128:
4109 case clang::BuiltinType::Float:
4110 case clang::BuiltinType::Double:
4111 case clang::BuiltinType::LongDouble:
4114 case clang::BuiltinType::NullPtr:
4117 case clang::BuiltinType::ObjCId:
4118 case clang::BuiltinType::ObjCClass:
4119 case clang::BuiltinType::ObjCSel:
4122 case clang::BuiltinType::Dependent:
4123 case clang::BuiltinType::Overload:
4124 case clang::BuiltinType::BoundMember:
4125 case clang::BuiltinType::UnknownAny:
4129 case clang::Type::Typedef:
4130 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4132 ->getUnderlyingType())
4142 return lldb::eTypeClassInvalid;
4144 clang::QualType qual_type =
4147 switch (qual_type->getTypeClass()) {
4148 case clang::Type::Atomic:
4149 case clang::Type::Auto:
4150 case clang::Type::CountAttributed:
4151 case clang::Type::Decltype:
4152 case clang::Type::Paren:
4153 case clang::Type::TypeOf:
4154 case clang::Type::TypeOfExpr:
4155 case clang::Type::Using:
4156 case clang::Type::PredefinedSugar:
4157 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4158 case clang::Type::UnaryTransform:
4160 case clang::Type::FunctionNoProto:
4161 return lldb::eTypeClassFunction;
4162 case clang::Type::FunctionProto:
4163 return lldb::eTypeClassFunction;
4164 case clang::Type::IncompleteArray:
4165 return lldb::eTypeClassArray;
4166 case clang::Type::VariableArray:
4167 return lldb::eTypeClassArray;
4168 case clang::Type::ConstantArray:
4169 return lldb::eTypeClassArray;
4170 case clang::Type::DependentSizedArray:
4171 return lldb::eTypeClassArray;
4172 case clang::Type::ArrayParameter:
4173 return lldb::eTypeClassArray;
4174 case clang::Type::DependentSizedExtVector:
4175 return lldb::eTypeClassVector;
4176 case clang::Type::DependentVector:
4177 return lldb::eTypeClassVector;
4178 case clang::Type::ExtVector:
4179 return lldb::eTypeClassVector;
4180 case clang::Type::Vector:
4181 return lldb::eTypeClassVector;
4182 case clang::Type::Builtin:
4184 case clang::Type::BitInt:
4185 case clang::Type::DependentBitInt:
4186 return lldb::eTypeClassBuiltin;
4187 case clang::Type::ObjCObjectPointer:
4188 return lldb::eTypeClassObjCObjectPointer;
4189 case clang::Type::BlockPointer:
4190 return lldb::eTypeClassBlockPointer;
4191 case clang::Type::Pointer:
4192 return lldb::eTypeClassPointer;
4193 case clang::Type::LValueReference:
4194 return lldb::eTypeClassReference;
4195 case clang::Type::RValueReference:
4196 return lldb::eTypeClassReference;
4197 case clang::Type::MemberPointer:
4198 return lldb::eTypeClassMemberPointer;
4199 case clang::Type::Complex:
4200 if (qual_type->isComplexType())
4201 return lldb::eTypeClassComplexFloat;
4203 return lldb::eTypeClassComplexInteger;
4204 case clang::Type::ObjCObject:
4205 return lldb::eTypeClassObjCObject;
4206 case clang::Type::ObjCInterface:
4207 return lldb::eTypeClassObjCInterface;
4208 case clang::Type::Record: {
4209 const clang::RecordType *record_type =
4210 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4211 const clang::RecordDecl *record_decl = record_type->getOriginalDecl();
4212 if (record_decl->isUnion())
4213 return lldb::eTypeClassUnion;
4214 else if (record_decl->isStruct())
4215 return lldb::eTypeClassStruct;
4217 return lldb::eTypeClassClass;
4219 case clang::Type::Enum:
4220 return lldb::eTypeClassEnumeration;
4221 case clang::Type::Typedef:
4222 return lldb::eTypeClassTypedef;
4223 case clang::Type::UnresolvedUsing:
4226 case clang::Type::Attributed:
4227 case clang::Type::BTFTagAttributed:
4229 case clang::Type::TemplateTypeParm:
4231 case clang::Type::SubstTemplateTypeParm:
4233 case clang::Type::SubstTemplateTypeParmPack:
4235 case clang::Type::InjectedClassName:
4237 case clang::Type::DependentName:
4239 case clang::Type::PackExpansion:
4242 case clang::Type::TemplateSpecialization:
4244 case clang::Type::DeducedTemplateSpecialization:
4246 case clang::Type::Pipe:
4250 case clang::Type::Decayed:
4252 case clang::Type::Adjusted:
4254 case clang::Type::ObjCTypeParam:
4257 case clang::Type::DependentAddressSpace:
4259 case clang::Type::MacroQualified:
4263 case clang::Type::ConstantMatrix:
4264 case clang::Type::DependentSizedMatrix:
4268 case clang::Type::PackIndexing:
4271 case clang::Type::HLSLAttributedResource:
4273 case clang::Type::HLSLInlineSpirv:
4275 case clang::Type::SubstBuiltinTemplatePack:
4279 return lldb::eTypeClassOther;
4284 return GetQualType(type).getQualifiers().getCVRQualifiers();
4296 const clang::Type *array_eletype =
4297 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4302 return GetType(clang::QualType(array_eletype, 0));
4313 return GetType(ast_ctx.getConstantArrayType(
4314 qual_type, llvm::APInt(64, size),
nullptr,
4315 clang::ArraySizeModifier::Normal, 0));
4317 return GetType(ast_ctx.getIncompleteArrayType(
4318 qual_type, clang::ArraySizeModifier::Normal, 0));
4332 clang::QualType qual_type) {
4333 if (qual_type->isPointerType())
4334 qual_type = ast->getPointerType(
4336 else if (
const ConstantArrayType *arr =
4337 ast->getAsConstantArrayType(qual_type)) {
4338 qual_type = ast->getConstantArrayType(
4340 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4341 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4343 qual_type = qual_type.getUnqualifiedType();
4344 qual_type.removeLocalConst();
4345 qual_type.removeLocalRestrict();
4346 qual_type.removeLocalVolatile();
4368 const clang::FunctionProtoType *func =
4371 return func->getNumParams();
4379 const clang::FunctionProtoType *func =
4380 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4382 const uint32_t num_args = func->getNumParams();
4384 return GetType(func->getParamType(idx));
4394 const clang::FunctionProtoType *func =
4395 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4397 return GetType(func->getReturnType());
4404 size_t num_functions = 0;
4407 switch (qual_type->getTypeClass()) {
4408 case clang::Type::Record:
4410 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4411 num_functions = std::distance(cxx_record_decl->method_begin(),
4412 cxx_record_decl->method_end());
4415 case clang::Type::ObjCObjectPointer: {
4416 const clang::ObjCObjectPointerType *objc_class_type =
4417 qual_type->castAs<clang::ObjCObjectPointerType>();
4418 const clang::ObjCInterfaceType *objc_interface_type =
4419 objc_class_type->getInterfaceType();
4420 if (objc_interface_type &&
4422 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4423 clang::ObjCInterfaceDecl *class_interface_decl =
4424 objc_interface_type->getDecl();
4425 if (class_interface_decl) {
4426 num_functions = std::distance(class_interface_decl->meth_begin(),
4427 class_interface_decl->meth_end());
4433 case clang::Type::ObjCObject:
4434 case clang::Type::ObjCInterface:
4436 const clang::ObjCObjectType *objc_class_type =
4437 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4438 if (objc_class_type) {
4439 clang::ObjCInterfaceDecl *class_interface_decl =
4440 objc_class_type->getInterface();
4441 if (class_interface_decl)
4442 num_functions = std::distance(class_interface_decl->meth_begin(),
4443 class_interface_decl->meth_end());
4452 return num_functions;
4464 switch (qual_type->getTypeClass()) {
4465 case clang::Type::Record:
4467 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4468 auto method_iter = cxx_record_decl->method_begin();
4469 auto method_end = cxx_record_decl->method_end();
4471 static_cast<size_t>(std::distance(method_iter, method_end))) {
4472 std::advance(method_iter, idx);
4473 clang::CXXMethodDecl *cxx_method_decl =
4474 method_iter->getCanonicalDecl();
4475 if (cxx_method_decl) {
4476 name = cxx_method_decl->getDeclName().getAsString();
4477 if (cxx_method_decl->isStatic())
4479 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4481 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4485 clang_type =
GetType(cxx_method_decl->getType());
4493 case clang::Type::ObjCObjectPointer: {
4494 const clang::ObjCObjectPointerType *objc_class_type =
4495 qual_type->castAs<clang::ObjCObjectPointerType>();
4496 const clang::ObjCInterfaceType *objc_interface_type =
4497 objc_class_type->getInterfaceType();
4498 if (objc_interface_type &&
4500 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4501 clang::ObjCInterfaceDecl *class_interface_decl =
4502 objc_interface_type->getDecl();
4503 if (class_interface_decl) {
4504 auto method_iter = class_interface_decl->meth_begin();
4505 auto method_end = class_interface_decl->meth_end();
4507 static_cast<size_t>(std::distance(method_iter, method_end))) {
4508 std::advance(method_iter, idx);
4509 clang::ObjCMethodDecl *objc_method_decl =
4510 method_iter->getCanonicalDecl();
4511 if (objc_method_decl) {
4513 name = objc_method_decl->getSelector().getAsString();
4514 if (objc_method_decl->isClassMethod())
4525 case clang::Type::ObjCObject:
4526 case clang::Type::ObjCInterface:
4528 const clang::ObjCObjectType *objc_class_type =
4529 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4530 if (objc_class_type) {
4531 clang::ObjCInterfaceDecl *class_interface_decl =
4532 objc_class_type->getInterface();
4533 if (class_interface_decl) {
4534 auto method_iter = class_interface_decl->meth_begin();
4535 auto method_end = class_interface_decl->meth_end();
4537 static_cast<size_t>(std::distance(method_iter, method_end))) {
4538 std::advance(method_iter, idx);
4539 clang::ObjCMethodDecl *objc_method_decl =
4540 method_iter->getCanonicalDecl();
4541 if (objc_method_decl) {
4543 name = objc_method_decl->getSelector().getAsString();
4544 if (objc_method_decl->isClassMethod())
4577 return GetType(qual_type.getTypePtr()->getPointeeType());
4587 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4588 case clang::Type::ObjCObject:
4589 case clang::Type::ObjCInterface:
4636 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4637 clang::QualType result =
4638 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4648 result.addVolatile();
4658 result.addRestrict();
4667 if (type && typedef_name && typedef_name[0]) {
4671 clang::DeclContext *decl_ctx =
4676 clang::TypedefDecl *decl =
4677 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4678 decl->setDeclContext(decl_ctx);
4679 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4680 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4681 decl_ctx->addDecl(decl);
4684 clang::TagDecl *tdecl =
nullptr;
4685 if (!qual_type.isNull()) {
4686 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4687 tdecl = rt->getOriginalDecl();
4688 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4689 tdecl = et->getOriginalDecl();
4695 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4696 tdecl->setTypedefNameForAnonDecl(decl);
4698 decl->setAccess(clang::AS_public);
4701 NestedNameSpecifier Qualifier =
4702 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4704 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4712 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4715 return GetType(typedef_type->getDecl()->getUnderlyingType());
4728 const FunctionType::ExtInfo generic_ext_info(
4737 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4742const llvm::fltSemantics &
4745 const size_t bit_size = byte_size * 8;
4746 if (bit_size == ast.getTypeSize(ast.FloatTy))
4747 return ast.getFloatTypeSemantics(ast.FloatTy);
4748 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4749 return ast.getFloatTypeSemantics(ast.DoubleTy);
4751 bit_size == ast.getTypeSize(ast.Float128Ty))
4752 return ast.getFloatTypeSemantics(ast.Float128Ty);
4753 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4754 bit_size == llvm::APFloat::semanticsSizeInBits(
4755 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4756 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4757 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4758 return ast.getFloatTypeSemantics(ast.HalfTy);
4759 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4760 return ast.getFloatTypeSemantics(ast.Float128Ty);
4761 return llvm::APFloatBase::Bogus();
4764llvm::Expected<uint64_t>
4767 assert(qual_type->isObjCObjectOrInterfaceType());
4772 if (std::optional<uint64_t> bit_size =
4773 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4777 static bool g_printed =
false;
4782 llvm::outs() <<
"warning: trying to determine the size of type ";
4784 llvm::outs() <<
"without a valid ExecutionContext. this is not "
4785 "reliable. please file a bug against LLDB.\n";
4786 llvm::outs() <<
"backtrace:\n";
4787 llvm::sys::PrintStackTrace(llvm::outs());
4788 llvm::outs() <<
"\n";
4797llvm::Expected<uint64_t>
4800 const bool base_name_only =
true;
4802 return llvm::createStringError(
4803 "could not complete type %s",
4807 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4808 switch (type_class) {
4809 case clang::Type::ConstantArray:
4810 case clang::Type::FunctionProto:
4811 case clang::Type::Record:
4813 case clang::Type::ObjCInterface:
4814 case clang::Type::ObjCObject:
4816 case clang::Type::IncompleteArray: {
4817 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4820 qual_type->getArrayElementTypeNoTypeQual()
4821 ->getCanonicalTypeUnqualified());
4826 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4830 return llvm::createStringError(
4831 "could not get size of type %s",
4835std::optional<size_t>
4851 switch (qual_type->getTypeClass()) {
4852 case clang::Type::Atomic:
4853 case clang::Type::Auto:
4854 case clang::Type::CountAttributed:
4855 case clang::Type::Decltype:
4856 case clang::Type::Paren:
4857 case clang::Type::Typedef:
4858 case clang::Type::TypeOf:
4859 case clang::Type::TypeOfExpr:
4860 case clang::Type::Using:
4861 case clang::Type::PredefinedSugar:
4862 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4864 case clang::Type::UnaryTransform:
4867 case clang::Type::FunctionNoProto:
4868 case clang::Type::FunctionProto:
4871 case clang::Type::IncompleteArray:
4872 case clang::Type::VariableArray:
4873 case clang::Type::ArrayParameter:
4876 case clang::Type::ConstantArray:
4879 case clang::Type::DependentVector:
4880 case clang::Type::ExtVector:
4881 case clang::Type::Vector:
4885 case clang::Type::BitInt:
4886 case clang::Type::DependentBitInt:
4890 case clang::Type::Builtin:
4891 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4892 case clang::BuiltinType::Void:
4895 case clang::BuiltinType::Char_S:
4896 case clang::BuiltinType::SChar:
4897 case clang::BuiltinType::WChar_S:
4898 case clang::BuiltinType::Short:
4899 case clang::BuiltinType::Int:
4900 case clang::BuiltinType::Long:
4901 case clang::BuiltinType::LongLong:
4902 case clang::BuiltinType::Int128:
4905 case clang::BuiltinType::Bool:
4906 case clang::BuiltinType::Char_U:
4907 case clang::BuiltinType::UChar:
4908 case clang::BuiltinType::WChar_U:
4909 case clang::BuiltinType::Char8:
4910 case clang::BuiltinType::Char16:
4911 case clang::BuiltinType::Char32:
4912 case clang::BuiltinType::UShort:
4913 case clang::BuiltinType::UInt:
4914 case clang::BuiltinType::ULong:
4915 case clang::BuiltinType::ULongLong:
4916 case clang::BuiltinType::UInt128:
4920 case clang::BuiltinType::ShortAccum:
4921 case clang::BuiltinType::Accum:
4922 case clang::BuiltinType::LongAccum:
4923 case clang::BuiltinType::UShortAccum:
4924 case clang::BuiltinType::UAccum:
4925 case clang::BuiltinType::ULongAccum:
4926 case clang::BuiltinType::ShortFract:
4927 case clang::BuiltinType::Fract:
4928 case clang::BuiltinType::LongFract:
4929 case clang::BuiltinType::UShortFract:
4930 case clang::BuiltinType::UFract:
4931 case clang::BuiltinType::ULongFract:
4932 case clang::BuiltinType::SatShortAccum:
4933 case clang::BuiltinType::SatAccum:
4934 case clang::BuiltinType::SatLongAccum:
4935 case clang::BuiltinType::SatUShortAccum:
4936 case clang::BuiltinType::SatUAccum:
4937 case clang::BuiltinType::SatULongAccum:
4938 case clang::BuiltinType::SatShortFract:
4939 case clang::BuiltinType::SatFract:
4940 case clang::BuiltinType::SatLongFract:
4941 case clang::BuiltinType::SatUShortFract:
4942 case clang::BuiltinType::SatUFract:
4943 case clang::BuiltinType::SatULongFract:
4946 case clang::BuiltinType::Half:
4947 case clang::BuiltinType::Float:
4948 case clang::BuiltinType::Float16:
4949 case clang::BuiltinType::Float128:
4950 case clang::BuiltinType::Double:
4951 case clang::BuiltinType::LongDouble:
4952 case clang::BuiltinType::BFloat16:
4953 case clang::BuiltinType::Ibm128:
4956 case clang::BuiltinType::ObjCClass:
4957 case clang::BuiltinType::ObjCId:
4958 case clang::BuiltinType::ObjCSel:
4961 case clang::BuiltinType::NullPtr:
4964 case clang::BuiltinType::Kind::ARCUnbridgedCast:
4965 case clang::BuiltinType::Kind::BoundMember:
4966 case clang::BuiltinType::Kind::BuiltinFn:
4967 case clang::BuiltinType::Kind::Dependent:
4968 case clang::BuiltinType::Kind::OCLClkEvent:
4969 case clang::BuiltinType::Kind::OCLEvent:
4970 case clang::BuiltinType::Kind::OCLImage1dRO:
4971 case clang::BuiltinType::Kind::OCLImage1dWO:
4972 case clang::BuiltinType::Kind::OCLImage1dRW:
4973 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
4974 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
4975 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
4976 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
4977 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
4978 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
4979 case clang::BuiltinType::Kind::OCLImage2dRO:
4980 case clang::BuiltinType::Kind::OCLImage2dWO:
4981 case clang::BuiltinType::Kind::OCLImage2dRW:
4982 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
4983 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
4984 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
4985 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
4986 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
4987 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
4988 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
4989 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
4990 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
4991 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
4992 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
4993 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
4994 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
4995 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
4996 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
4997 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
4998 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
4999 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
5000 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
5001 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
5002 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
5003 case clang::BuiltinType::Kind::OCLImage3dRO:
5004 case clang::BuiltinType::Kind::OCLImage3dWO:
5005 case clang::BuiltinType::Kind::OCLImage3dRW:
5006 case clang::BuiltinType::Kind::OCLQueue:
5007 case clang::BuiltinType::Kind::OCLReserveID:
5008 case clang::BuiltinType::Kind::OCLSampler:
5009 case clang::BuiltinType::Kind::HLSLResource:
5010 case clang::BuiltinType::Kind::ArraySection:
5011 case clang::BuiltinType::Kind::OMPArrayShaping:
5012 case clang::BuiltinType::Kind::OMPIterator:
5013 case clang::BuiltinType::Kind::Overload:
5014 case clang::BuiltinType::Kind::PseudoObject:
5015 case clang::BuiltinType::Kind::UnknownAny:
5018 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
5019 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
5020 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
5021 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
5022 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
5023 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
5024 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
5025 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
5026 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
5027 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
5028 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
5029 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
5033 case clang::BuiltinType::VectorPair:
5034 case clang::BuiltinType::VectorQuad:
5035 case clang::BuiltinType::DMR1024:
5039#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5040#include "clang/Basic/AArch64ACLETypes.def"
5044#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5045#include "clang/Basic/RISCVVTypes.def"
5049 case clang::BuiltinType::WasmExternRef:
5052 case clang::BuiltinType::IncompleteMatrixIdx:
5055 case clang::BuiltinType::UnresolvedTemplate:
5059#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
5060 case clang::BuiltinType::Id:
5061#include "clang/Basic/AMDGPUTypes.def"
5067 case clang::Type::ObjCObjectPointer:
5068 case clang::Type::BlockPointer:
5069 case clang::Type::Pointer:
5070 case clang::Type::LValueReference:
5071 case clang::Type::RValueReference:
5072 case clang::Type::MemberPointer:
5074 case clang::Type::Complex: {
5076 if (qual_type->isComplexType())
5079 const clang::ComplexType *complex_type =
5080 qual_type->getAsComplexIntegerType();
5090 case clang::Type::ObjCInterface:
5092 case clang::Type::Record:
5094 case clang::Type::Enum:
5095 return qual_type->isUnsignedIntegerOrEnumerationType()
5098 case clang::Type::DependentSizedArray:
5099 case clang::Type::DependentSizedExtVector:
5100 case clang::Type::UnresolvedUsing:
5101 case clang::Type::Attributed:
5102 case clang::Type::BTFTagAttributed:
5103 case clang::Type::TemplateTypeParm:
5104 case clang::Type::SubstTemplateTypeParm:
5105 case clang::Type::SubstTemplateTypeParmPack:
5106 case clang::Type::InjectedClassName:
5107 case clang::Type::DependentName:
5108 case clang::Type::PackExpansion:
5109 case clang::Type::ObjCObject:
5111 case clang::Type::TemplateSpecialization:
5112 case clang::Type::DeducedTemplateSpecialization:
5113 case clang::Type::Adjusted:
5114 case clang::Type::Pipe:
5118 case clang::Type::Decayed:
5120 case clang::Type::ObjCTypeParam:
5123 case clang::Type::DependentAddressSpace:
5125 case clang::Type::MacroQualified:
5128 case clang::Type::ConstantMatrix:
5129 case clang::Type::DependentSizedMatrix:
5133 case clang::Type::PackIndexing:
5136 case clang::Type::HLSLAttributedResource:
5138 case clang::Type::HLSLInlineSpirv:
5140 case clang::Type::SubstBuiltinTemplatePack:
5153 switch (qual_type->getTypeClass()) {
5154 case clang::Type::Atomic:
5155 case clang::Type::Auto:
5156 case clang::Type::CountAttributed:
5157 case clang::Type::Decltype:
5158 case clang::Type::Paren:
5159 case clang::Type::Typedef:
5160 case clang::Type::TypeOf:
5161 case clang::Type::TypeOfExpr:
5162 case clang::Type::Using:
5163 case clang::Type::PredefinedSugar:
5164 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5165 case clang::Type::UnaryTransform:
5168 case clang::Type::FunctionNoProto:
5169 case clang::Type::FunctionProto:
5172 case clang::Type::IncompleteArray:
5173 case clang::Type::VariableArray:
5174 case clang::Type::ArrayParameter:
5177 case clang::Type::ConstantArray:
5180 case clang::Type::DependentVector:
5181 case clang::Type::ExtVector:
5182 case clang::Type::Vector:
5185 case clang::Type::BitInt:
5186 case clang::Type::DependentBitInt:
5190 case clang::Type::Builtin:
5191 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5192 case clang::BuiltinType::UnknownAny:
5193 case clang::BuiltinType::Void:
5194 case clang::BuiltinType::BoundMember:
5197 case clang::BuiltinType::Bool:
5199 case clang::BuiltinType::Char_S:
5200 case clang::BuiltinType::SChar:
5201 case clang::BuiltinType::WChar_S:
5202 case clang::BuiltinType::Char_U:
5203 case clang::BuiltinType::UChar:
5204 case clang::BuiltinType::WChar_U:
5206 case clang::BuiltinType::Char8:
5208 case clang::BuiltinType::Char16:
5210 case clang::BuiltinType::Char32:
5212 case clang::BuiltinType::UShort:
5214 case clang::BuiltinType::Short:
5216 case clang::BuiltinType::UInt:
5218 case clang::BuiltinType::Int:
5220 case clang::BuiltinType::ULong:
5222 case clang::BuiltinType::Long:
5224 case clang::BuiltinType::ULongLong:
5226 case clang::BuiltinType::LongLong:
5228 case clang::BuiltinType::UInt128:
5230 case clang::BuiltinType::Int128:
5232 case clang::BuiltinType::Half:
5233 case clang::BuiltinType::Float:
5234 case clang::BuiltinType::Double:
5235 case clang::BuiltinType::LongDouble:
5237 case clang::BuiltinType::Float128:
5243 case clang::Type::ObjCObjectPointer:
5245 case clang::Type::BlockPointer:
5247 case clang::Type::Pointer:
5249 case clang::Type::LValueReference:
5250 case clang::Type::RValueReference:
5252 case clang::Type::MemberPointer:
5254 case clang::Type::Complex: {
5255 if (qual_type->isComplexType())
5260 case clang::Type::ObjCInterface:
5262 case clang::Type::Record:
5264 case clang::Type::Enum:
5266 case clang::Type::DependentSizedArray:
5267 case clang::Type::DependentSizedExtVector:
5268 case clang::Type::UnresolvedUsing:
5269 case clang::Type::Attributed:
5270 case clang::Type::BTFTagAttributed:
5271 case clang::Type::TemplateTypeParm:
5272 case clang::Type::SubstTemplateTypeParm:
5273 case clang::Type::SubstTemplateTypeParmPack:
5274 case clang::Type::InjectedClassName:
5275 case clang::Type::DependentName:
5276 case clang::Type::PackExpansion:
5277 case clang::Type::ObjCObject:
5279 case clang::Type::TemplateSpecialization:
5280 case clang::Type::DeducedTemplateSpecialization:
5281 case clang::Type::Adjusted:
5282 case clang::Type::Pipe:
5286 case clang::Type::Decayed:
5288 case clang::Type::ObjCTypeParam:
5291 case clang::Type::DependentAddressSpace:
5293 case clang::Type::MacroQualified:
5297 case clang::Type::ConstantMatrix:
5298 case clang::Type::DependentSizedMatrix:
5302 case clang::Type::PackIndexing:
5305 case clang::Type::HLSLAttributedResource:
5307 case clang::Type::HLSLInlineSpirv:
5309 case clang::Type::SubstBuiltinTemplatePack:
5317 while (class_interface_decl) {
5318 if (class_interface_decl->ivar_size() > 0)
5321 class_interface_decl = class_interface_decl->getSuperClass();
5326static std::optional<SymbolFile::ArrayInfo>
5328 clang::QualType qual_type,
5330 if (qual_type->isIncompleteArrayType())
5331 if (std::optional<ClangASTMetadata> metadata =
5335 return std::nullopt;
5338llvm::Expected<uint32_t>
5340 bool omit_empty_base_classes,
5343 return llvm::createStringError(
"invalid clang type");
5345 uint32_t num_children = 0;
5347 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5348 switch (type_class) {
5349 case clang::Type::Builtin:
5350 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5351 case clang::BuiltinType::ObjCId:
5352 case clang::BuiltinType::ObjCClass:
5361 case clang::Type::Complex:
5363 case clang::Type::Record:
5365 const clang::RecordType *record_type =
5366 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5367 const clang::RecordDecl *record_decl =
5368 record_type->getOriginalDecl()->getDefinitionOrSelf();
5369 const clang::CXXRecordDecl *cxx_record_decl =
5370 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5374 num_children += std::distance(record_decl->field_begin(),
5375 record_decl->field_end());
5377 return llvm::createStringError(
5380 case clang::Type::ObjCObject:
5381 case clang::Type::ObjCInterface:
5383 const clang::ObjCObjectType *objc_class_type =
5384 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5385 assert(objc_class_type);
5386 if (objc_class_type) {
5387 clang::ObjCInterfaceDecl *class_interface_decl =
5388 objc_class_type->getInterface();
5390 if (class_interface_decl) {
5392 clang::ObjCInterfaceDecl *superclass_interface_decl =
5393 class_interface_decl->getSuperClass();
5394 if (superclass_interface_decl) {
5395 if (omit_empty_base_classes) {
5402 num_children += class_interface_decl->ivar_size();
5408 case clang::Type::LValueReference:
5409 case clang::Type::RValueReference:
5410 case clang::Type::ObjCObjectPointer: {
5413 uint32_t num_pointee_children = 0;
5415 auto num_children_or_err =
5416 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5417 if (!num_children_or_err)
5418 return num_children_or_err;
5419 num_pointee_children = *num_children_or_err;
5422 if (num_pointee_children == 0)
5425 num_children = num_pointee_children;
5428 case clang::Type::Vector:
5429 case clang::Type::ExtVector:
5431 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5434 case clang::Type::ConstantArray:
5435 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5439 case clang::Type::IncompleteArray:
5440 if (
auto array_info =
5443 num_children = array_info->element_orders.size()
5444 ? array_info->element_orders.back().value_or(0)
5448 case clang::Type::Pointer: {
5449 const clang::PointerType *pointer_type =
5450 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5451 clang::QualType pointee_type(pointer_type->getPointeeType());
5453 uint32_t num_pointee_children = 0;
5455 auto num_children_or_err =
5456 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5457 if (!num_children_or_err)
5458 return num_children_or_err;
5459 num_pointee_children = *num_children_or_err;
5461 if (num_pointee_children == 0) {
5466 num_children = num_pointee_children;
5472 return num_children;
5483 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5484 if (type_class == clang::Type::Builtin) {
5485 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5486 case clang::BuiltinType::Void:
5488 case clang::BuiltinType::Bool:
5490 case clang::BuiltinType::Char_S:
5492 case clang::BuiltinType::Char_U:
5494 case clang::BuiltinType::Char8:
5496 case clang::BuiltinType::Char16:
5498 case clang::BuiltinType::Char32:
5500 case clang::BuiltinType::UChar:
5502 case clang::BuiltinType::SChar:
5504 case clang::BuiltinType::WChar_S:
5506 case clang::BuiltinType::WChar_U:
5508 case clang::BuiltinType::Short:
5510 case clang::BuiltinType::UShort:
5512 case clang::BuiltinType::Int:
5514 case clang::BuiltinType::UInt:
5516 case clang::BuiltinType::Long:
5518 case clang::BuiltinType::ULong:
5520 case clang::BuiltinType::LongLong:
5522 case clang::BuiltinType::ULongLong:
5524 case clang::BuiltinType::Int128:
5526 case clang::BuiltinType::UInt128:
5529 case clang::BuiltinType::Half:
5531 case clang::BuiltinType::Float:
5533 case clang::BuiltinType::Double:
5535 case clang::BuiltinType::LongDouble:
5537 case clang::BuiltinType::Float128:
5540 case clang::BuiltinType::NullPtr:
5542 case clang::BuiltinType::ObjCId:
5544 case clang::BuiltinType::ObjCClass:
5546 case clang::BuiltinType::ObjCSel:
5560 const llvm::APSInt &value)>
const &callback) {
5561 const clang::EnumType *enum_type =
5564 const clang::EnumDecl *enum_decl =
5565 enum_type->getOriginalDecl()->getDefinitionOrSelf();
5569 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5570 for (enum_pos = enum_decl->enumerator_begin(),
5571 enum_end_pos = enum_decl->enumerator_end();
5572 enum_pos != enum_end_pos; ++enum_pos) {
5573 ConstString name(enum_pos->getNameAsString().c_str());
5574 if (!callback(integer_type, name, enum_pos->getInitVal()))
5581#pragma mark Aggregate Types
5589 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5590 switch (type_class) {
5591 case clang::Type::Record:
5593 const clang::RecordType *record_type =
5594 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5596 clang::RecordDecl *record_decl =
5597 record_type->getOriginalDecl()->getDefinition();
5599 count = std::distance(record_decl->field_begin(),
5600 record_decl->field_end());
5606 case clang::Type::ObjCObjectPointer: {
5607 const clang::ObjCObjectPointerType *objc_class_type =
5608 qual_type->castAs<clang::ObjCObjectPointerType>();
5609 const clang::ObjCInterfaceType *objc_interface_type =
5610 objc_class_type->getInterfaceType();
5611 if (objc_interface_type &&
5613 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5614 clang::ObjCInterfaceDecl *class_interface_decl =
5615 objc_interface_type->getDecl();
5616 if (class_interface_decl) {
5617 count = class_interface_decl->ivar_size();
5623 case clang::Type::ObjCObject:
5624 case clang::Type::ObjCInterface:
5626 const clang::ObjCObjectType *objc_class_type =
5627 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5628 if (objc_class_type) {
5629 clang::ObjCInterfaceDecl *class_interface_decl =
5630 objc_class_type->getInterface();
5632 if (class_interface_decl)
5633 count = class_interface_decl->ivar_size();
5646 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5647 std::string &name, uint64_t *bit_offset_ptr,
5648 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5649 if (class_interface_decl) {
5650 if (idx < (class_interface_decl->ivar_size())) {
5651 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5652 ivar_end = class_interface_decl->ivar_end();
5653 uint32_t ivar_idx = 0;
5655 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5656 ++ivar_pos, ++ivar_idx) {
5657 if (ivar_idx == idx) {
5658 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5660 clang::QualType ivar_qual_type(ivar_decl->getType());
5662 name.assign(ivar_decl->getNameAsString());
5664 if (bit_offset_ptr) {
5665 const clang::ASTRecordLayout &interface_layout =
5666 ast->getASTObjCInterfaceLayout(class_interface_decl);
5667 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5670 const bool is_bitfield = ivar_pos->isBitField();
5672 if (bitfield_bit_size_ptr) {
5673 *bitfield_bit_size_ptr = 0;
5675 if (is_bitfield && ast) {
5676 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5677 clang::Expr::EvalResult result;
5678 if (bitfield_bit_size_expr &&
5679 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5680 llvm::APSInt bitfield_apsint = result.Val.getInt();
5681 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5685 if (is_bitfield_ptr)
5686 *is_bitfield_ptr = is_bitfield;
5688 return ivar_qual_type.getAsOpaquePtr();
5697 size_t idx, std::string &name,
5698 uint64_t *bit_offset_ptr,
5699 uint32_t *bitfield_bit_size_ptr,
5700 bool *is_bitfield_ptr) {
5705 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5706 switch (type_class) {
5707 case clang::Type::Record:
5709 const clang::RecordType *record_type =
5710 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5711 const clang::RecordDecl *record_decl =
5712 record_type->getOriginalDecl()->getDefinitionOrSelf();
5713 uint32_t field_idx = 0;
5714 clang::RecordDecl::field_iterator field, field_end;
5715 for (field = record_decl->field_begin(),
5716 field_end = record_decl->field_end();
5717 field != field_end; ++field, ++field_idx) {
5718 if (idx == field_idx) {
5721 name.assign(field->getNameAsString());
5725 if (bit_offset_ptr) {
5726 const clang::ASTRecordLayout &record_layout =
5728 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5731 const bool is_bitfield = field->isBitField();
5733 if (bitfield_bit_size_ptr) {
5734 *bitfield_bit_size_ptr = 0;
5737 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5738 clang::Expr::EvalResult result;
5739 if (bitfield_bit_size_expr &&
5740 bitfield_bit_size_expr->EvaluateAsInt(result,
5742 llvm::APSInt bitfield_apsint = result.Val.getInt();
5743 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5747 if (is_bitfield_ptr)
5748 *is_bitfield_ptr = is_bitfield;
5750 return GetType(field->getType());
5756 case clang::Type::ObjCObjectPointer: {
5757 const clang::ObjCObjectPointerType *objc_class_type =
5758 qual_type->castAs<clang::ObjCObjectPointerType>();
5759 const clang::ObjCInterfaceType *objc_interface_type =
5760 objc_class_type->getInterfaceType();
5761 if (objc_interface_type &&
5763 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5764 clang::ObjCInterfaceDecl *class_interface_decl =
5765 objc_interface_type->getDecl();
5766 if (class_interface_decl) {
5770 name, bit_offset_ptr, bitfield_bit_size_ptr,
5777 case clang::Type::ObjCObject:
5778 case clang::Type::ObjCInterface:
5780 const clang::ObjCObjectType *objc_class_type =
5781 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5782 assert(objc_class_type);
5783 if (objc_class_type) {
5784 clang::ObjCInterfaceDecl *class_interface_decl =
5785 objc_class_type->getInterface();
5789 name, bit_offset_ptr, bitfield_bit_size_ptr,
5805 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5806 switch (type_class) {
5807 case clang::Type::Record:
5809 const clang::CXXRecordDecl *cxx_record_decl =
5810 qual_type->getAsCXXRecordDecl();
5811 if (cxx_record_decl)
5812 count = cxx_record_decl->getNumBases();
5816 case clang::Type::ObjCObjectPointer:
5820 case clang::Type::ObjCObject:
5822 const clang::ObjCObjectType *objc_class_type =
5823 qual_type->getAsObjCQualifiedInterfaceType();
5824 if (objc_class_type) {
5825 clang::ObjCInterfaceDecl *class_interface_decl =
5826 objc_class_type->getInterface();
5828 if (class_interface_decl && class_interface_decl->getSuperClass())
5833 case clang::Type::ObjCInterface:
5835 const clang::ObjCInterfaceType *objc_interface_type =
5836 qual_type->getAs<clang::ObjCInterfaceType>();
5837 if (objc_interface_type) {
5838 clang::ObjCInterfaceDecl *class_interface_decl =
5839 objc_interface_type->getInterface();
5841 if (class_interface_decl && class_interface_decl->getSuperClass())
5857 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5858 switch (type_class) {
5859 case clang::Type::Record:
5861 const clang::CXXRecordDecl *cxx_record_decl =
5862 qual_type->getAsCXXRecordDecl();
5863 if (cxx_record_decl)
5864 count = cxx_record_decl->getNumVBases();
5877 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5878 switch (type_class) {
5879 case clang::Type::Record:
5881 const clang::CXXRecordDecl *cxx_record_decl =
5882 qual_type->getAsCXXRecordDecl();
5883 if (cxx_record_decl) {
5884 uint32_t curr_idx = 0;
5885 clang::CXXRecordDecl::base_class_const_iterator base_class,
5887 for (base_class = cxx_record_decl->bases_begin(),
5888 base_class_end = cxx_record_decl->bases_end();
5889 base_class != base_class_end; ++base_class, ++curr_idx) {
5890 if (curr_idx == idx) {
5891 if (bit_offset_ptr) {
5892 const clang::ASTRecordLayout &record_layout =
5894 const clang::CXXRecordDecl *base_class_decl =
5895 llvm::cast<clang::CXXRecordDecl>(
5896 base_class->getType()
5897 ->castAs<clang::RecordType>()
5898 ->getOriginalDecl());
5899 if (base_class->isVirtual())
5901 record_layout.getVBaseClassOffset(base_class_decl)
5906 record_layout.getBaseClassOffset(base_class_decl)
5910 return GetType(base_class->getType());
5917 case clang::Type::ObjCObjectPointer:
5920 case clang::Type::ObjCObject:
5922 const clang::ObjCObjectType *objc_class_type =
5923 qual_type->getAsObjCQualifiedInterfaceType();
5924 if (objc_class_type) {
5925 clang::ObjCInterfaceDecl *class_interface_decl =
5926 objc_class_type->getInterface();
5928 if (class_interface_decl) {
5929 clang::ObjCInterfaceDecl *superclass_interface_decl =
5930 class_interface_decl->getSuperClass();
5931 if (superclass_interface_decl) {
5933 *bit_offset_ptr = 0;
5935 superclass_interface_decl));
5941 case clang::Type::ObjCInterface:
5943 const clang::ObjCObjectType *objc_interface_type =
5944 qual_type->getAs<clang::ObjCInterfaceType>();
5945 if (objc_interface_type) {
5946 clang::ObjCInterfaceDecl *class_interface_decl =
5947 objc_interface_type->getInterface();
5949 if (class_interface_decl) {
5950 clang::ObjCInterfaceDecl *superclass_interface_decl =
5951 class_interface_decl->getSuperClass();
5952 if (superclass_interface_decl) {
5954 *bit_offset_ptr = 0;
5956 superclass_interface_decl));
5972 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5973 switch (type_class) {
5974 case clang::Type::Record:
5976 const clang::CXXRecordDecl *cxx_record_decl =
5977 qual_type->getAsCXXRecordDecl();
5978 if (cxx_record_decl) {
5979 uint32_t curr_idx = 0;
5980 clang::CXXRecordDecl::base_class_const_iterator base_class,
5982 for (base_class = cxx_record_decl->vbases_begin(),
5983 base_class_end = cxx_record_decl->vbases_end();
5984 base_class != base_class_end; ++base_class, ++curr_idx) {
5985 if (curr_idx == idx) {
5986 if (bit_offset_ptr) {
5987 const clang::ASTRecordLayout &record_layout =
5989 const clang::CXXRecordDecl *base_class_decl =
5990 llvm::cast<clang::CXXRecordDecl>(
5991 base_class->getType()
5992 ->castAs<clang::RecordType>()
5993 ->getOriginalDecl());
5995 record_layout.getVBaseClassOffset(base_class_decl)
5999 return GetType(base_class->getType());
6014 llvm::StringRef name) {
6016 switch (qual_type->getTypeClass()) {
6017 case clang::Type::Record: {
6021 const clang::RecordType *record_type =
6022 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6023 const clang::RecordDecl *record_decl =
6024 record_type->getOriginalDecl()->getDefinitionOrSelf();
6026 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
6027 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
6028 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
6029 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
6053 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6054 switch (type_class) {
6055 case clang::Type::Builtin:
6056 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6057 case clang::BuiltinType::UnknownAny:
6058 case clang::BuiltinType::Void:
6059 case clang::BuiltinType::NullPtr:
6060 case clang::BuiltinType::OCLEvent:
6061 case clang::BuiltinType::OCLImage1dRO:
6062 case clang::BuiltinType::OCLImage1dWO:
6063 case clang::BuiltinType::OCLImage1dRW:
6064 case clang::BuiltinType::OCLImage1dArrayRO:
6065 case clang::BuiltinType::OCLImage1dArrayWO:
6066 case clang::BuiltinType::OCLImage1dArrayRW:
6067 case clang::BuiltinType::OCLImage1dBufferRO:
6068 case clang::BuiltinType::OCLImage1dBufferWO:
6069 case clang::BuiltinType::OCLImage1dBufferRW:
6070 case clang::BuiltinType::OCLImage2dRO:
6071 case clang::BuiltinType::OCLImage2dWO:
6072 case clang::BuiltinType::OCLImage2dRW:
6073 case clang::BuiltinType::OCLImage2dArrayRO:
6074 case clang::BuiltinType::OCLImage2dArrayWO:
6075 case clang::BuiltinType::OCLImage2dArrayRW:
6076 case clang::BuiltinType::OCLImage3dRO:
6077 case clang::BuiltinType::OCLImage3dWO:
6078 case clang::BuiltinType::OCLImage3dRW:
6079 case clang::BuiltinType::OCLSampler:
6080 case clang::BuiltinType::HLSLResource:
6082 case clang::BuiltinType::Bool:
6083 case clang::BuiltinType::Char_U:
6084 case clang::BuiltinType::UChar:
6085 case clang::BuiltinType::WChar_U:
6086 case clang::BuiltinType::Char16:
6087 case clang::BuiltinType::Char32:
6088 case clang::BuiltinType::UShort:
6089 case clang::BuiltinType::UInt:
6090 case clang::BuiltinType::ULong:
6091 case clang::BuiltinType::ULongLong:
6092 case clang::BuiltinType::UInt128:
6093 case clang::BuiltinType::Char_S:
6094 case clang::BuiltinType::SChar:
6095 case clang::BuiltinType::WChar_S:
6096 case clang::BuiltinType::Short:
6097 case clang::BuiltinType::Int:
6098 case clang::BuiltinType::Long:
6099 case clang::BuiltinType::LongLong:
6100 case clang::BuiltinType::Int128:
6101 case clang::BuiltinType::Float:
6102 case clang::BuiltinType::Double:
6103 case clang::BuiltinType::LongDouble:
6104 case clang::BuiltinType::Float128:
6105 case clang::BuiltinType::Dependent:
6106 case clang::BuiltinType::Overload:
6107 case clang::BuiltinType::ObjCId:
6108 case clang::BuiltinType::ObjCClass:
6109 case clang::BuiltinType::ObjCSel:
6110 case clang::BuiltinType::BoundMember:
6111 case clang::BuiltinType::Half:
6112 case clang::BuiltinType::ARCUnbridgedCast:
6113 case clang::BuiltinType::PseudoObject:
6114 case clang::BuiltinType::BuiltinFn:
6115 case clang::BuiltinType::ArraySection:
6122 case clang::Type::Complex:
6124 case clang::Type::Pointer:
6126 case clang::Type::BlockPointer:
6129 case clang::Type::LValueReference:
6131 case clang::Type::RValueReference:
6133 case clang::Type::MemberPointer:
6135 case clang::Type::ConstantArray:
6137 case clang::Type::IncompleteArray:
6139 case clang::Type::VariableArray:
6141 case clang::Type::DependentSizedArray:
6143 case clang::Type::DependentSizedExtVector:
6145 case clang::Type::Vector:
6147 case clang::Type::ExtVector:
6149 case clang::Type::FunctionProto:
6151 case clang::Type::FunctionNoProto:
6153 case clang::Type::UnresolvedUsing:
6155 case clang::Type::Record:
6157 case clang::Type::Enum:
6159 case clang::Type::TemplateTypeParm:
6161 case clang::Type::SubstTemplateTypeParm:
6163 case clang::Type::TemplateSpecialization:
6165 case clang::Type::InjectedClassName:
6167 case clang::Type::DependentName:
6169 case clang::Type::ObjCObject:
6171 case clang::Type::ObjCInterface:
6173 case clang::Type::ObjCObjectPointer:
6183 std::string &deref_name, uint32_t &deref_byte_size,
6184 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6188 return llvm::createStringError(
"not a pointer, reference or array type");
6189 uint32_t child_bitfield_bit_size = 0;
6190 uint32_t child_bitfield_bit_offset = 0;
6191 bool child_is_base_class;
6192 bool child_is_deref_of_parent;
6194 type, exe_ctx, 0,
false,
true,
false, deref_name, deref_byte_size,
6195 deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6196 child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
6201 bool transparent_pointers,
bool omit_empty_base_classes,
6202 bool ignore_array_bounds, std::string &child_name,
6203 uint32_t &child_byte_size, int32_t &child_byte_offset,
6204 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6205 bool &child_is_base_class,
bool &child_is_deref_of_parent,
6210 auto get_exe_scope = [&exe_ctx]() {
6214 clang::QualType parent_qual_type(
6216 const clang::Type::TypeClass parent_type_class =
6217 parent_qual_type->getTypeClass();
6218 child_bitfield_bit_size = 0;
6219 child_bitfield_bit_offset = 0;
6220 child_is_base_class =
false;
6223 auto num_children_or_err =
6225 if (!num_children_or_err)
6226 return num_children_or_err.takeError();
6228 const bool idx_is_valid = idx < *num_children_or_err;
6230 switch (parent_type_class) {
6231 case clang::Type::Builtin:
6233 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6234 case clang::BuiltinType::ObjCId:
6235 case clang::BuiltinType::ObjCClass:
6248 case clang::Type::Record:
6250 const clang::RecordType *record_type =
6251 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6252 const clang::RecordDecl *record_decl =
6253 record_type->getOriginalDecl()->getDefinitionOrSelf();
6254 const clang::ASTRecordLayout &record_layout =
6256 uint32_t child_idx = 0;
6258 const clang::CXXRecordDecl *cxx_record_decl =
6259 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6260 if (cxx_record_decl) {
6262 clang::CXXRecordDecl::base_class_const_iterator base_class,
6264 for (base_class = cxx_record_decl->bases_begin(),
6265 base_class_end = cxx_record_decl->bases_end();
6266 base_class != base_class_end; ++base_class) {
6267 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6270 if (omit_empty_base_classes) {
6271 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6272 base_class->getType()
6273 ->getAs<clang::RecordType>()
6274 ->getOriginalDecl())
6275 ->getDefinitionOrSelf();
6280 if (idx == child_idx) {
6281 if (base_class_decl ==
nullptr)
6282 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6283 base_class->getType()
6284 ->getAs<clang::RecordType>()
6285 ->getOriginalDecl())
6286 ->getDefinitionOrSelf();
6288 if (base_class->isVirtual()) {
6289 bool handled =
false;
6291 clang::VTableContextBase *vtable_ctx =
6295 record_layout, cxx_record_decl,
6296 base_class_decl, bit_offset);
6299 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6303 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6308 child_byte_offset = bit_offset / 8;
6312 base_class_clang_type.
GetBitSize(get_exe_scope());
6314 return llvm::joinErrors(
6315 llvm::createStringError(
"no size info for base class"),
6316 size_or_err.takeError());
6318 uint64_t base_class_clang_type_bit_size = *size_or_err;
6321 assert(base_class_clang_type_bit_size % 8 == 0);
6322 child_byte_size = base_class_clang_type_bit_size / 8;
6323 child_is_base_class =
true;
6324 return base_class_clang_type;
6332 uint32_t field_idx = 0;
6333 clang::RecordDecl::field_iterator field, field_end;
6334 for (field = record_decl->field_begin(),
6335 field_end = record_decl->field_end();
6336 field != field_end; ++field, ++field_idx, ++child_idx) {
6337 if (idx == child_idx) {
6340 child_name.assign(field->getNameAsString());
6345 assert(field_idx < record_layout.getFieldCount());
6346 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6348 return llvm::joinErrors(
6349 llvm::createStringError(
"no size info for field"),
6350 size_or_err.takeError());
6352 child_byte_size = *size_or_err;
6353 const uint32_t child_bit_size = child_byte_size * 8;
6357 bit_offset = record_layout.getFieldOffset(field_idx);
6359 child_bitfield_bit_offset = bit_offset % child_bit_size;
6360 const uint32_t child_bit_offset =
6361 bit_offset - child_bitfield_bit_offset;
6362 child_byte_offset = child_bit_offset / 8;
6364 child_byte_offset = bit_offset / 8;
6367 return field_clang_type;
6373 case clang::Type::ObjCObject:
6374 case clang::Type::ObjCInterface:
6376 const clang::ObjCObjectType *objc_class_type =
6377 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6378 assert(objc_class_type);
6379 if (objc_class_type) {
6380 uint32_t child_idx = 0;
6381 clang::ObjCInterfaceDecl *class_interface_decl =
6382 objc_class_type->getInterface();
6384 if (class_interface_decl) {
6386 const clang::ASTRecordLayout &interface_layout =
6387 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6388 clang::ObjCInterfaceDecl *superclass_interface_decl =
6389 class_interface_decl->getSuperClass();
6390 if (superclass_interface_decl) {
6391 if (omit_empty_base_classes) {
6394 superclass_interface_decl));
6395 if (llvm::expectedToStdOptional(
6397 omit_empty_base_classes, exe_ctx))
6400 clang::QualType ivar_qual_type(
6402 superclass_interface_decl));
6405 superclass_interface_decl->getNameAsString());
6407 clang::TypeInfo ivar_type_info =
6410 child_byte_size = ivar_type_info.Width / 8;
6411 child_byte_offset = 0;
6412 child_is_base_class =
true;
6414 return GetType(ivar_qual_type);
6423 const uint32_t superclass_idx = child_idx;
6425 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6426 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6427 ivar_end = class_interface_decl->ivar_end();
6429 for (ivar_pos = class_interface_decl->ivar_begin();
6430 ivar_pos != ivar_end; ++ivar_pos) {
6431 if (child_idx == idx) {
6432 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6434 clang::QualType ivar_qual_type(ivar_decl->getType());
6436 child_name.assign(ivar_decl->getNameAsString());
6438 clang::TypeInfo ivar_type_info =
6441 child_byte_size = ivar_type_info.Width / 8;
6457 if (objc_runtime !=
nullptr) {
6460 parent_ast_type, ivar_decl->getNameAsString().c_str());
6468 if (child_byte_offset ==
6470 bit_offset = interface_layout.getFieldOffset(child_idx -
6472 child_byte_offset = bit_offset / 8;
6483 bit_offset = interface_layout.getFieldOffset(
6484 child_idx - superclass_idx);
6486 child_bitfield_bit_offset = bit_offset % 8;
6488 return GetType(ivar_qual_type);
6498 case clang::Type::ObjCObjectPointer:
6503 child_is_deref_of_parent =
false;
6504 bool tmp_child_is_deref_of_parent =
false;
6506 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6507 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6508 child_bitfield_bit_size, child_bitfield_bit_offset,
6509 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6512 child_is_deref_of_parent =
true;
6513 const char *parent_name =
6516 child_name.assign(1,
'*');
6517 child_name += parent_name;
6522 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6524 return size_or_err.takeError();
6525 child_byte_size = *size_or_err;
6526 child_byte_offset = 0;
6527 return pointee_clang_type;
6533 case clang::Type::Vector:
6534 case clang::Type::ExtVector:
6536 const clang::VectorType *array =
6537 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6541 char element_name[64];
6542 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6543 static_cast<uint64_t
>(idx));
6544 child_name.assign(element_name);
6545 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6547 return size_or_err.takeError();
6548 child_byte_size = *size_or_err;
6549 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6550 return element_type;
6556 case clang::Type::ConstantArray:
6557 case clang::Type::IncompleteArray:
6558 if (ignore_array_bounds || idx_is_valid) {
6559 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6563 child_name = std::string(llvm::formatv(
"[{0}]", idx));
6564 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6566 return size_or_err.takeError();
6567 child_byte_size = *size_or_err;
6568 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6569 return element_type;
6575 case clang::Type::Pointer: {
6583 child_is_deref_of_parent =
false;
6584 bool tmp_child_is_deref_of_parent =
false;
6586 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6587 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6588 child_bitfield_bit_size, child_bitfield_bit_offset,
6589 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6592 child_is_deref_of_parent =
true;
6594 const char *parent_name =
6597 child_name.assign(1,
'*');
6598 child_name += parent_name;
6603 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6605 return size_or_err.takeError();
6606 child_byte_size = *size_or_err;
6607 child_byte_offset = 0;
6608 return pointee_clang_type;
6614 case clang::Type::LValueReference:
6615 case clang::Type::RValueReference:
6617 const clang::ReferenceType *reference_type =
6618 llvm::cast<clang::ReferenceType>(
6621 GetType(reference_type->getPointeeType());
6623 child_is_deref_of_parent =
false;
6624 bool tmp_child_is_deref_of_parent =
false;
6626 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6627 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6628 child_bitfield_bit_size, child_bitfield_bit_offset,
6629 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6632 const char *parent_name =
6635 child_name.assign(1,
'&');
6636 child_name += parent_name;
6641 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6643 return size_or_err.takeError();
6644 child_byte_size = *size_or_err;
6645 child_byte_offset = 0;
6646 return pointee_clang_type;
6659 const clang::RecordDecl *record_decl,
6660 const clang::CXXBaseSpecifier *base_spec,
6661 bool omit_empty_base_classes) {
6662 uint32_t child_idx = 0;
6664 const clang::CXXRecordDecl *cxx_record_decl =
6665 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6667 if (cxx_record_decl) {
6668 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6669 for (base_class = cxx_record_decl->bases_begin(),
6670 base_class_end = cxx_record_decl->bases_end();
6671 base_class != base_class_end; ++base_class) {
6672 if (omit_empty_base_classes) {
6677 if (base_class == base_spec)
6687 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6688 bool omit_empty_base_classes) {
6690 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6691 omit_empty_base_classes);
6693 clang::RecordDecl::field_iterator field, field_end;
6694 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6695 field != field_end; ++field, ++child_idx) {
6696 if (field->getCanonicalDecl() == canonical_decl)
6738 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6739 if (type && !name.empty()) {
6741 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6742 switch (type_class) {
6743 case clang::Type::Record:
6745 const clang::RecordType *record_type =
6746 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6747 const clang::RecordDecl *record_decl =
6748 record_type->getOriginalDecl()->getDefinitionOrSelf();
6750 assert(record_decl);
6751 uint32_t child_idx = 0;
6753 const clang::CXXRecordDecl *cxx_record_decl =
6754 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6757 clang::RecordDecl::field_iterator field, field_end;
6758 for (field = record_decl->field_begin(),
6759 field_end = record_decl->field_end();
6760 field != field_end; ++field, ++child_idx) {
6761 llvm::StringRef field_name = field->getName();
6762 if (field_name.empty()) {
6764 std::vector<uint32_t> save_indices = child_indexes;
6765 child_indexes.push_back(
6767 cxx_record_decl, omit_empty_base_classes));
6769 name, omit_empty_base_classes, child_indexes))
6770 return child_indexes.size();
6771 child_indexes = std::move(save_indices);
6772 }
else if (field_name == name) {
6774 child_indexes.push_back(
6776 cxx_record_decl, omit_empty_base_classes));
6777 return child_indexes.size();
6781 if (cxx_record_decl) {
6782 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6785 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6786 clang::DeclarationName decl_name(&ident_ref);
6788 clang::CXXBasePaths paths;
6789 if (cxx_record_decl->lookupInBases(
6790 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6791 clang::CXXBasePath &path) {
6792 CXXRecordDecl *record =
6793 specifier->getType()->getAsCXXRecordDecl();
6794 auto r = record->lookup(decl_name);
6795 path.Decls = r.begin();
6799 clang::CXXBasePaths::const_paths_iterator path,
6800 path_end = paths.end();
6801 for (path = paths.begin(); path != path_end; ++path) {
6802 const size_t num_path_elements = path->size();
6803 for (
size_t e = 0; e < num_path_elements; ++e) {
6804 clang::CXXBasePathElement elem = (*path)[e];
6807 omit_empty_base_classes);
6809 child_indexes.clear();
6812 child_indexes.push_back(child_idx);
6813 parent_record_decl = elem.Base->getType()
6814 ->castAs<clang::RecordType>()
6816 ->getDefinitionOrSelf();
6819 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6822 parent_record_decl, *I, omit_empty_base_classes);
6824 child_indexes.clear();
6827 child_indexes.push_back(child_idx);
6831 return child_indexes.size();
6837 case clang::Type::ObjCObject:
6838 case clang::Type::ObjCInterface:
6840 llvm::StringRef name_sref(name);
6841 const clang::ObjCObjectType *objc_class_type =
6842 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6843 assert(objc_class_type);
6844 if (objc_class_type) {
6845 uint32_t child_idx = 0;
6846 clang::ObjCInterfaceDecl *class_interface_decl =
6847 objc_class_type->getInterface();
6849 if (class_interface_decl) {
6850 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6851 ivar_end = class_interface_decl->ivar_end();
6852 clang::ObjCInterfaceDecl *superclass_interface_decl =
6853 class_interface_decl->getSuperClass();
6855 for (ivar_pos = class_interface_decl->ivar_begin();
6856 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6857 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6859 if (ivar_decl->getName() == name_sref) {
6860 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6861 (omit_empty_base_classes &&
6865 child_indexes.push_back(child_idx);
6866 return child_indexes.size();
6870 if (superclass_interface_decl) {
6874 child_indexes.push_back(0);
6878 superclass_interface_decl));
6880 name, omit_empty_base_classes, child_indexes)) {
6883 return child_indexes.size();
6888 child_indexes.pop_back();
6895 case clang::Type::ObjCObjectPointer: {
6897 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6898 ->getPointeeType());
6900 name, omit_empty_base_classes, child_indexes);
6903 case clang::Type::LValueReference:
6904 case clang::Type::RValueReference: {
6905 const clang::ReferenceType *reference_type =
6906 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
6907 clang::QualType pointee_type(reference_type->getPointeeType());
6912 name, omit_empty_base_classes, child_indexes);
6916 case clang::Type::Pointer: {
6921 name, omit_empty_base_classes, child_indexes);
6936llvm::Expected<uint32_t>
6938 llvm::StringRef name,
6939 bool omit_empty_base_classes) {
6940 if (type && !name.empty()) {
6943 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6945 switch (type_class) {
6946 case clang::Type::Record:
6948 const clang::RecordType *record_type =
6949 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6950 const clang::RecordDecl *record_decl =
6951 record_type->getOriginalDecl()->getDefinitionOrSelf();
6953 assert(record_decl);
6954 uint32_t child_idx = 0;
6956 const clang::CXXRecordDecl *cxx_record_decl =
6957 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6959 if (cxx_record_decl) {
6960 clang::CXXRecordDecl::base_class_const_iterator base_class,
6962 for (base_class = cxx_record_decl->bases_begin(),
6963 base_class_end = cxx_record_decl->bases_end();
6964 base_class != base_class_end; ++base_class) {
6966 clang::CXXRecordDecl *base_class_decl =
6967 llvm::cast<clang::CXXRecordDecl>(
6968 base_class->getType()
6969 ->castAs<clang::RecordType>()
6970 ->getOriginalDecl())
6971 ->getDefinitionOrSelf();
6972 if (omit_empty_base_classes &&
6977 std::string base_class_type_name(
6979 if (base_class_type_name == name)
6986 clang::RecordDecl::field_iterator field, field_end;
6987 for (field = record_decl->field_begin(),
6988 field_end = record_decl->field_end();
6989 field != field_end; ++field, ++child_idx) {
6990 if (field->getName() == name)
6996 case clang::Type::ObjCObject:
6997 case clang::Type::ObjCInterface:
6999 const clang::ObjCObjectType *objc_class_type =
7000 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
7001 assert(objc_class_type);
7002 if (objc_class_type) {
7003 uint32_t child_idx = 0;
7004 clang::ObjCInterfaceDecl *class_interface_decl =
7005 objc_class_type->getInterface();
7007 if (class_interface_decl) {
7008 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
7009 ivar_end = class_interface_decl->ivar_end();
7010 clang::ObjCInterfaceDecl *superclass_interface_decl =
7011 class_interface_decl->getSuperClass();
7013 for (ivar_pos = class_interface_decl->ivar_begin();
7014 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
7015 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
7017 if (ivar_decl->getName() == name) {
7018 if ((!omit_empty_base_classes && superclass_interface_decl) ||
7019 (omit_empty_base_classes &&
7027 if (superclass_interface_decl) {
7028 if (superclass_interface_decl->getName() == name)
7036 case clang::Type::ObjCObjectPointer: {
7038 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7039 ->getPointeeType());
7041 name, omit_empty_base_classes);
7044 case clang::Type::LValueReference:
7045 case clang::Type::RValueReference: {
7046 const clang::ReferenceType *reference_type =
7047 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7052 omit_empty_base_classes);
7056 case clang::Type::Pointer: {
7057 const clang::PointerType *pointer_type =
7058 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7063 omit_empty_base_classes);
7071 return llvm::createStringError(
"Type has no child named '%s'",
7072 name.str().c_str());
7077 llvm::StringRef name) {
7078 if (!type || name.empty())
7082 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7084 switch (type_class) {
7085 case clang::Type::Record: {
7088 const clang::RecordType *record_type =
7089 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7090 const clang::RecordDecl *record_decl =
7091 record_type->getOriginalDecl()->getDefinitionOrSelf();
7093 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7094 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7095 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7097 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7099 ElaboratedTypeKeyword::None, std::nullopt,
7115 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7116 return isa<clang::ClassTemplateSpecializationDecl>(
7117 cxx_record_decl->getOriginalDecl());
7128 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7129 switch (type_class) {
7130 case clang::Type::Record:
7132 const clang::CXXRecordDecl *cxx_record_decl =
7133 qual_type->getAsCXXRecordDecl();
7134 if (cxx_record_decl) {
7135 const clang::ClassTemplateSpecializationDecl *template_decl =
7136 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7138 if (template_decl) {
7139 const auto &template_arg_list = template_decl->getTemplateArgs();
7140 size_t num_args = template_arg_list.size();
7141 assert(num_args &&
"template specialization without any args");
7142 if (expand_pack && num_args) {
7143 const auto &pack = template_arg_list[num_args - 1];
7144 if (pack.getKind() == clang::TemplateArgument::Pack)
7145 num_args += pack.pack_size() - 1;
7160const clang::ClassTemplateSpecializationDecl *
7167 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7168 switch (type_class) {
7169 case clang::Type::Record: {
7172 const clang::CXXRecordDecl *cxx_record_decl =
7173 qual_type->getAsCXXRecordDecl();
7174 if (!cxx_record_decl)
7176 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7185const TemplateArgument *
7187 size_t idx,
bool expand_pack) {
7188 const auto &args = decl->getTemplateArgs();
7189 const size_t args_size = args.size();
7191 assert(args_size &&
"template specialization without any args");
7195 const size_t last_idx = args_size - 1;
7204 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7205 return idx >= args.size() ? nullptr : &args[idx];
7210 const auto &pack = args[last_idx];
7211 const size_t pack_idx = idx - last_idx;
7212 if (pack_idx >= pack.pack_size())
7214 return &pack.pack_elements()[pack_idx];
7219 size_t arg_idx,
bool expand_pack) {
7220 const clang::ClassTemplateSpecializationDecl *template_decl =
7229 switch (arg->getKind()) {
7230 case clang::TemplateArgument::Null:
7233 case clang::TemplateArgument::NullPtr:
7236 case clang::TemplateArgument::Type:
7239 case clang::TemplateArgument::Declaration:
7242 case clang::TemplateArgument::Integral:
7245 case clang::TemplateArgument::Template:
7248 case clang::TemplateArgument::TemplateExpansion:
7251 case clang::TemplateArgument::Expression:
7254 case clang::TemplateArgument::Pack:
7257 case clang::TemplateArgument::StructuralValue:
7260 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7265 size_t idx,
bool expand_pack) {
7266 const clang::ClassTemplateSpecializationDecl *template_decl =
7272 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7275 return GetType(arg->getAsType());
7278std::optional<CompilerType::IntegralTemplateArgument>
7280 size_t idx,
bool expand_pack) {
7281 const clang::ClassTemplateSpecializationDecl *template_decl =
7284 return std::nullopt;
7288 return std::nullopt;
7290 switch (arg->getKind()) {
7291 case clang::TemplateArgument::Integral:
7292 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7293 case clang::TemplateArgument::StructuralValue: {
7294 clang::APValue value = arg->getAsStructuralValue();
7297 if (value.isFloat())
7298 return {{value.getFloat(), type}};
7301 return {{value.getInt(), type}};
7303 return std::nullopt;
7306 return std::nullopt;
7317 const clang::EnumType *enutype =
7320 return enutype->getOriginalDecl()->getDefinitionOrSelf();
7325 const clang::RecordType *record_type =
7328 return record_type->getOriginalDecl()->getDefinitionOrSelf();
7336clang::TypedefNameDecl *
7338 const clang::TypedefType *typedef_type =
7341 return typedef_type->getDecl();
7345clang::CXXRecordDecl *
7350clang::ObjCInterfaceDecl *
7352 const clang::ObjCObjectType *objc_class_type =
7353 llvm::dyn_cast<clang::ObjCObjectType>(
7355 if (objc_class_type)
7356 return objc_class_type->getInterface();
7363 uint32_t bitfield_bit_size) {
7369 clang::ASTContext &clang_ast = ast->getASTContext();
7370 clang::IdentifierInfo *ident =
nullptr;
7372 ident = &clang_ast.Idents.get(name);
7374 clang::FieldDecl *field =
nullptr;
7376 clang::Expr *bit_width =
nullptr;
7377 if (bitfield_bit_size != 0) {
7378 if (clang_ast.IntTy.isNull()) {
7381 "{0} failed: builtin ASTContext types have not been initialized");
7385 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7387 bit_width =
new (clang_ast)
7388 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7389 clang_ast.IntTy, clang::SourceLocation());
7390 bit_width = clang::ConstantExpr::Create(
7391 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7394 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7396 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7397 field->setDeclContext(record_decl);
7398 field->setDeclName(ident);
7401 field->setBitWidth(bit_width);
7407 if (
const clang::TagType *TagT =
7408 field->getType()->getAs<clang::TagType>()) {
7409 if (clang::RecordDecl *Rec =
7410 llvm::dyn_cast<clang::RecordDecl>(TagT->getOriginalDecl()))
7411 if (!Rec->getDeclName()) {
7412 Rec->setAnonymousStructOrUnion(
true);
7413 field->setImplicit();
7419 clang::AccessSpecifier access_specifier =
7421 field->setAccess(access_specifier);
7423 if (clang::CXXRecordDecl *cxx_record_decl =
7424 llvm::dyn_cast<CXXRecordDecl>(record_decl)) {
7425 AddAccessSpecifierDecl(cxx_record_decl, ast->getASTContext(),
7426 ast->GetCXXRecordDeclAccess(cxx_record_decl),
7428 ast->SetCXXRecordDeclAccess(cxx_record_decl, access_specifier);
7430 record_decl->addDecl(field);
7435 clang::ObjCInterfaceDecl *class_interface_decl =
7436 ast->GetAsObjCInterfaceDecl(type);
7438 if (class_interface_decl) {
7439 const bool is_synthesized =
false;
7444 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7445 ivar->setDeclContext(class_interface_decl);
7446 ivar->setDeclName(ident);
7450 ivar->setBitWidth(bit_width);
7451 ivar->setSynthesize(is_synthesized);
7456 class_interface_decl->addDecl(field);
7473 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7478 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7480 IndirectFieldVector indirect_fields;
7481 clang::RecordDecl::field_iterator field_pos;
7482 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7483 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7484 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7485 last_field_pos = field_pos++) {
7486 if (field_pos->isAnonymousStructOrUnion()) {
7487 clang::QualType field_qual_type = field_pos->getType();
7489 const clang::RecordType *field_record_type =
7490 field_qual_type->getAs<clang::RecordType>();
7492 if (!field_record_type)
7495 clang::RecordDecl *field_record_decl =
7496 field_record_type->getOriginalDecl()->getDefinition();
7498 if (!field_record_decl)
7501 for (clang::RecordDecl::decl_iterator
7502 di = field_record_decl->decls_begin(),
7503 de = field_record_decl->decls_end();
7505 if (clang::FieldDecl *nested_field_decl =
7506 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7507 clang::NamedDecl **chain =
7508 new (ast->getASTContext()) clang::NamedDecl *[2];
7509 chain[0] = *field_pos;
7510 chain[1] = nested_field_decl;
7511 clang::IndirectFieldDecl *indirect_field =
7512 clang::IndirectFieldDecl::Create(
7513 ast->getASTContext(), record_decl, clang::SourceLocation(),
7514 nested_field_decl->getIdentifier(),
7515 nested_field_decl->getType(), {chain, 2});
7518 indirect_field->setImplicit();
7521 field_pos->getAccess(), nested_field_decl->getAccess()));
7523 indirect_fields.push_back(indirect_field);
7524 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7525 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7526 size_t nested_chain_size =
7527 nested_indirect_field_decl->getChainingSize();
7528 clang::NamedDecl **chain =
new (ast->getASTContext())
7529 clang::NamedDecl *[nested_chain_size + 1];
7530 chain[0] = *field_pos;
7532 int chain_index = 1;
7533 for (clang::IndirectFieldDecl::chain_iterator
7534 nci = nested_indirect_field_decl->chain_begin(),
7535 nce = nested_indirect_field_decl->chain_end();
7537 chain[chain_index] = *nci;
7541 clang::IndirectFieldDecl *indirect_field =
7542 clang::IndirectFieldDecl::Create(
7543 ast->getASTContext(), record_decl, clang::SourceLocation(),
7544 nested_indirect_field_decl->getIdentifier(),
7545 nested_indirect_field_decl->getType(),
7546 {chain, nested_chain_size + 1});
7549 indirect_field->setImplicit();
7552 field_pos->getAccess(), nested_indirect_field_decl->getAccess()));
7554 indirect_fields.push_back(indirect_field);
7562 if (last_field_pos != field_end_pos) {
7563 if (last_field_pos->getType()->isIncompleteArrayType())
7564 record_decl->hasFlexibleArrayMember();
7567 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7568 ife = indirect_fields.end();
7570 record_decl->addDecl(*ifi);
7583 record_decl->addAttr(
7584 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7599 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7603 clang::VarDecl *var_decl =
nullptr;
7604 clang::IdentifierInfo *ident =
nullptr;
7606 ident = &ast->getASTContext().Idents.get(name);
7609 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7610 var_decl->setDeclContext(record_decl);
7611 var_decl->setDeclName(ident);
7613 var_decl->setStorageClass(clang::SC_Static);
7618 var_decl->setAccess(
7620 record_decl->addDecl(var_decl);
7622 VerifyDecl(var_decl);
7628 VarDecl *var,
const llvm::APInt &init_value) {
7629 assert(!var->hasInit() &&
"variable already initialized");
7631 clang::ASTContext &ast = var->getASTContext();
7632 QualType qt = var->getType();
7633 assert(qt->isIntegralOrEnumerationType() &&
7634 "only integer or enum types supported");
7637 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7638 const EnumDecl *enum_decl =
7639 enum_type->getOriginalDecl()->getDefinitionOrSelf();
7640 qt = enum_decl->getIntegerType();
7644 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7645 var->setInit(CXXBoolLiteralExpr::Create(
7646 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7648 var->setInit(IntegerLiteral::Create(
7649 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7654 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7655 assert(!var->hasInit() &&
"variable already initialized");
7657 clang::ASTContext &ast = var->getASTContext();
7658 QualType qt = var->getType();
7659 assert(qt->isFloatingType() &&
"only floating point types supported");
7660 var->setInit(FloatingLiteral::Create(
7661 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7664llvm::SmallVector<clang::ParmVarDecl *>
7666 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7667 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7669 assert(parameter_names.empty() ||
7670 parameter_names.size() == prototype.getNumParams());
7672 llvm::SmallVector<clang::ParmVarDecl *> params;
7673 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7675 llvm::StringRef name =
7676 !parameter_names.empty() ? parameter_names[param_index] :
"";
7680 GetType(prototype.getParamType(param_index)),
7681 clang::SC_None,
false);
7684 params.push_back(param);
7692 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7694 bool is_explicit,
bool is_attr_used,
bool is_artificial) {
7695 if (!type || !method_clang_type.
IsValid() || name.empty())
7700 clang::CXXRecordDecl *cxx_record_decl =
7701 record_qual_type->getAsCXXRecordDecl();
7703 if (cxx_record_decl ==
nullptr)
7708 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7710 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7712 const clang::FunctionType *function_type =
7713 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7715 if (function_type ==
nullptr)
7718 const clang::FunctionProtoType *method_function_prototype(
7719 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7721 if (!method_function_prototype)
7724 unsigned int num_params = method_function_prototype->getNumParams();
7726 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7727 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7732 const clang::ExplicitSpecifier explicit_spec(
7733 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7734 : clang::ExplicitSpecKind::ResolvedFalse);
7736 if (name.starts_with(
"~")) {
7737 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7739 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7740 cxx_dtor_decl->setDeclName(
7743 cxx_dtor_decl->setType(method_qual_type);
7744 cxx_dtor_decl->setImplicit(is_artificial);
7745 cxx_dtor_decl->setInlineSpecified(is_inline);
7746 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7747 cxx_method_decl = cxx_dtor_decl;
7748 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7749 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7751 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7752 cxx_ctor_decl->setDeclName(
7755 cxx_ctor_decl->setType(method_qual_type);
7756 cxx_ctor_decl->setImplicit(is_artificial);
7757 cxx_ctor_decl->setInlineSpecified(is_inline);
7758 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7759 cxx_ctor_decl->setNumCtorInitializers(0);
7760 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7761 cxx_method_decl = cxx_ctor_decl;
7763 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7764 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7767 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7772 const bool is_method =
true;
7774 is_method, op_kind, num_params))
7776 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7778 cxx_method_decl->setDeclContext(cxx_record_decl);
7779 cxx_method_decl->setDeclName(
7780 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7781 cxx_method_decl->setType(method_qual_type);
7782 cxx_method_decl->setStorageClass(SC);
7783 cxx_method_decl->setInlineSpecified(is_inline);
7784 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7785 }
else if (num_params == 0) {
7787 auto *cxx_conversion_decl =
7788 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7790 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7791 cxx_conversion_decl->setDeclName(
7792 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7794 function_type->getReturnType())));
7795 cxx_conversion_decl->setType(method_qual_type);
7796 cxx_conversion_decl->setInlineSpecified(is_inline);
7797 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7798 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7799 cxx_method_decl = cxx_conversion_decl;
7803 if (cxx_method_decl ==
nullptr) {
7804 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7806 cxx_method_decl->setDeclContext(cxx_record_decl);
7807 cxx_method_decl->setDeclName(decl_name);
7808 cxx_method_decl->setType(method_qual_type);
7809 cxx_method_decl->setInlineSpecified(is_inline);
7810 cxx_method_decl->setStorageClass(SC);
7811 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7816 clang::AccessSpecifier access_specifier =
7819 cxx_method_decl->setAccess(access_specifier);
7820 cxx_method_decl->setVirtualAsWritten(is_virtual);
7823 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7825 if (!asm_label.empty())
7826 cxx_method_decl->addAttr(
7827 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7832 cxx_method_decl, *method_function_prototype, {}));
7839 cxx_record_decl->addDecl(cxx_method_decl);
7848 if (is_artificial) {
7849 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7850 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7851 (cxx_ctor_decl->isCopyConstructor() &&
7852 cxx_record_decl->hasTrivialCopyConstructor()) ||
7853 (cxx_ctor_decl->isMoveConstructor() &&
7854 cxx_record_decl->hasTrivialMoveConstructor()))) {
7855 cxx_ctor_decl->setDefaulted();
7856 cxx_ctor_decl->setTrivial(
true);
7857 }
else if (cxx_dtor_decl) {
7858 if (cxx_record_decl->hasTrivialDestructor()) {
7859 cxx_dtor_decl->setDefaulted();
7860 cxx_dtor_decl->setTrivial(
true);
7862 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7863 cxx_record_decl->hasTrivialCopyAssignment()) ||
7864 (cxx_method_decl->isMoveAssignmentOperator() &&
7865 cxx_record_decl->hasTrivialMoveAssignment())) {
7866 cxx_method_decl->setDefaulted();
7867 cxx_method_decl->setTrivial(
true);
7871 VerifyDecl(cxx_method_decl);
7873 return cxx_method_decl;
7879 for (
auto *method : record->methods())
7880 addOverridesForMethod(method);
7883#pragma mark C++ Base Classes
7885std::unique_ptr<clang::CXXBaseSpecifier>
7888 bool base_of_class) {
7892 return std::make_unique<clang::CXXBaseSpecifier>(
7893 clang::SourceRange(), is_virtual, base_of_class,
7896 clang::SourceLocation());
7901 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
7905 if (!cxx_record_decl)
7907 std::vector<clang::CXXBaseSpecifier *> raw_bases;
7908 raw_bases.reserve(bases.size());
7912 for (
auto &b : bases)
7913 raw_bases.push_back(b.get());
7914 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
7923 clang::ASTContext &clang_ast = ast->getASTContext();
7925 if (type && superclass_clang_type.
IsValid() &&
7927 clang::ObjCInterfaceDecl *class_interface_decl =
7929 clang::ObjCInterfaceDecl *super_interface_decl =
7931 if (class_interface_decl && super_interface_decl) {
7932 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
7933 clang_ast.getObjCInterfaceType(super_interface_decl)));
7942 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
7943 const char *property_setter_name,
const char *property_getter_name,
7945 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
7946 property_name[0] ==
'\0')
7951 clang::ASTContext &clang_ast = ast->getASTContext();
7954 if (!class_interface_decl)
7959 if (property_clang_type.
IsValid())
7960 property_clang_type_to_access = property_clang_type;
7962 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
7964 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
7967 clang::TypeSourceInfo *prop_type_source;
7969 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
7971 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
7974 clang::ObjCPropertyDecl *property_decl =
7975 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7976 property_decl->setDeclContext(class_interface_decl);
7977 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
7978 property_decl->setType(ivar_decl
7979 ? ivar_decl->getType()
7987 ast->SetMetadata(property_decl, metadata);
7989 class_interface_decl->addDecl(property_decl);
7991 clang::Selector setter_sel, getter_sel;
7993 if (property_setter_name) {
7994 std::string property_setter_no_colon(property_setter_name,
7995 strlen(property_setter_name) - 1);
7996 const clang::IdentifierInfo *setter_ident =
7997 &clang_ast.Idents.get(property_setter_no_colon);
7998 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
7999 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
8000 std::string setter_sel_string(
"set");
8001 setter_sel_string.push_back(::toupper(property_name[0]));
8002 setter_sel_string.append(&property_name[1]);
8003 const clang::IdentifierInfo *setter_ident =
8004 &clang_ast.Idents.get(setter_sel_string);
8005 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8007 property_decl->setSetterName(setter_sel);
8008 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
8010 if (property_getter_name !=
nullptr) {
8011 const clang::IdentifierInfo *getter_ident =
8012 &clang_ast.Idents.get(property_getter_name);
8013 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8015 const clang::IdentifierInfo *getter_ident =
8016 &clang_ast.Idents.get(property_name);
8017 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8019 property_decl->setGetterName(getter_sel);
8020 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
8023 property_decl->setPropertyIvarDecl(ivar_decl);
8025 if (property_attributes & DW_APPLE_PROPERTY_readonly)
8026 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
8027 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
8028 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
8029 if (property_attributes & DW_APPLE_PROPERTY_assign)
8030 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
8031 if (property_attributes & DW_APPLE_PROPERTY_retain)
8032 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
8033 if (property_attributes & DW_APPLE_PROPERTY_copy)
8034 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
8035 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8036 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
8037 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
8038 property_decl->setPropertyAttributes(
8039 ObjCPropertyAttribute::kind_nullability);
8040 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
8041 property_decl->setPropertyAttributes(
8042 ObjCPropertyAttribute::kind_null_resettable);
8043 if (property_attributes & ObjCPropertyAttribute::kind_class)
8044 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8046 const bool isInstance =
8047 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8049 clang::ObjCMethodDecl *getter =
nullptr;
8050 if (!getter_sel.isNull())
8051 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8052 : class_interface_decl->lookupClassMethod(getter_sel);
8053 if (!getter_sel.isNull() && !getter) {
8054 const bool isVariadic =
false;
8055 const bool isPropertyAccessor =
true;
8056 const bool isSynthesizedAccessorStub =
false;
8057 const bool isImplicitlyDeclared =
true;
8058 const bool isDefined =
false;
8059 const clang::ObjCImplementationControl impControl =
8060 clang::ObjCImplementationControl::None;
8061 const bool HasRelatedResultType =
false;
8064 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8065 getter->setDeclName(getter_sel);
8067 getter->setDeclContext(class_interface_decl);
8068 getter->setInstanceMethod(isInstance);
8069 getter->setVariadic(isVariadic);
8070 getter->setPropertyAccessor(isPropertyAccessor);
8071 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8072 getter->setImplicit(isImplicitlyDeclared);
8073 getter->setDefined(isDefined);
8074 getter->setDeclImplementation(impControl);
8075 getter->setRelatedResultType(HasRelatedResultType);
8079 ast->SetMetadata(getter, metadata);
8081 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8082 llvm::ArrayRef<clang::SourceLocation>());
8083 class_interface_decl->addDecl(getter);
8087 getter->setPropertyAccessor(
true);
8088 property_decl->setGetterMethodDecl(getter);
8091 clang::ObjCMethodDecl *setter =
nullptr;
8092 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8093 : class_interface_decl->lookupClassMethod(setter_sel);
8094 if (!setter_sel.isNull() && !setter) {
8095 clang::QualType result_type = clang_ast.VoidTy;
8096 const bool isVariadic =
false;
8097 const bool isPropertyAccessor =
true;
8098 const bool isSynthesizedAccessorStub =
false;
8099 const bool isImplicitlyDeclared =
true;
8100 const bool isDefined =
false;
8101 const clang::ObjCImplementationControl impControl =
8102 clang::ObjCImplementationControl::None;
8103 const bool HasRelatedResultType =
false;
8106 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8107 setter->setDeclName(setter_sel);
8108 setter->setReturnType(result_type);
8109 setter->setDeclContext(class_interface_decl);
8110 setter->setInstanceMethod(isInstance);
8111 setter->setVariadic(isVariadic);
8112 setter->setPropertyAccessor(isPropertyAccessor);
8113 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8114 setter->setImplicit(isImplicitlyDeclared);
8115 setter->setDefined(isDefined);
8116 setter->setDeclImplementation(impControl);
8117 setter->setRelatedResultType(HasRelatedResultType);
8121 ast->SetMetadata(setter, metadata);
8123 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8124 params.push_back(clang::ParmVarDecl::Create(
8125 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8128 clang::SC_Auto,
nullptr));
8130 setter->setMethodParams(clang_ast,
8131 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8132 llvm::ArrayRef<clang::SourceLocation>());
8134 class_interface_decl->addDecl(setter);
8138 setter->setPropertyAccessor(
true);
8139 property_decl->setSetterMethodDecl(setter);
8150 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8151 bool is_objc_direct_call) {
8152 if (!type || !method_clang_type.
IsValid())
8157 if (class_interface_decl ==
nullptr)
8160 if (lldb_ast ==
nullptr)
8162 clang::ASTContext &ast = lldb_ast->getASTContext();
8164 const char *selector_start = ::strchr(name,
' ');
8165 if (selector_start ==
nullptr)
8169 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8174 unsigned num_selectors_with_args = 0;
8175 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8177 len = ::strcspn(start,
":]");
8178 bool has_arg = (start[len] ==
':');
8180 ++num_selectors_with_args;
8181 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8186 if (selector_idents.size() == 0)
8189 clang::Selector method_selector = ast.Selectors.getSelector(
8190 num_selectors_with_args ? selector_idents.size() : 0,
8191 selector_idents.data());
8196 const clang::Type *method_type(method_qual_type.getTypePtr());
8198 if (method_type ==
nullptr)
8201 const clang::FunctionProtoType *method_function_prototype(
8202 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8204 if (!method_function_prototype)
8207 const bool isInstance = (name[0] ==
'-');
8208 const bool isVariadic = is_variadic;
8209 const bool isPropertyAccessor =
false;
8210 const bool isSynthesizedAccessorStub =
false;
8212 const bool isImplicitlyDeclared =
true;
8213 const bool isDefined =
false;
8214 const clang::ObjCImplementationControl impControl =
8215 clang::ObjCImplementationControl::None;
8216 const bool HasRelatedResultType =
false;
8218 const unsigned num_args = method_function_prototype->getNumParams();
8220 if (num_args != num_selectors_with_args)
8224 auto *objc_method_decl =
8225 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8226 objc_method_decl->setDeclName(method_selector);
8227 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8228 objc_method_decl->setDeclContext(
8230 objc_method_decl->setInstanceMethod(isInstance);
8231 objc_method_decl->setVariadic(isVariadic);
8232 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8233 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8234 objc_method_decl->setImplicit(isImplicitlyDeclared);
8235 objc_method_decl->setDefined(isDefined);
8236 objc_method_decl->setDeclImplementation(impControl);
8237 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8240 if (objc_method_decl ==
nullptr)
8244 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8246 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8247 params.push_back(clang::ParmVarDecl::Create(
8248 ast, objc_method_decl, clang::SourceLocation(),
8249 clang::SourceLocation(),
8251 method_function_prototype->getParamType(param_index),
nullptr,
8252 clang::SC_Auto,
nullptr));
8255 objc_method_decl->setMethodParams(
8256 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8257 llvm::ArrayRef<clang::SourceLocation>());
8260 if (is_objc_direct_call) {
8263 objc_method_decl->addAttr(
8264 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8269 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8272 class_interface_decl->addDecl(objc_method_decl);
8274 VerifyDecl(objc_method_decl);
8276 return objc_method_decl;
8286 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8287 switch (type_class) {
8288 case clang::Type::Record: {
8289 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8290 if (cxx_record_decl) {
8291 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8292 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8297 case clang::Type::Enum: {
8298 clang::EnumDecl *enum_decl =
8299 llvm::cast<clang::EnumType>(qual_type)->getOriginalDecl();
8301 enum_decl->setHasExternalLexicalStorage(has_extern);
8302 enum_decl->setHasExternalVisibleStorage(has_extern);
8307 case clang::Type::ObjCObject:
8308 case clang::Type::ObjCInterface: {
8309 const clang::ObjCObjectType *objc_class_type =
8310 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8311 assert(objc_class_type);
8312 if (objc_class_type) {
8313 clang::ObjCInterfaceDecl *class_interface_decl =
8314 objc_class_type->getInterface();
8316 if (class_interface_decl) {
8317 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8318 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8334 if (!qual_type.isNull()) {
8335 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8337 clang::TagDecl *tag_decl = tag_type->getOriginalDecl();
8339 tag_decl->startDefinition();
8344 const clang::ObjCObjectType *object_type =
8345 qual_type->getAs<clang::ObjCObjectType>();
8347 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8348 if (interface_decl) {
8349 interface_decl->startDefinition();
8360 if (qual_type.isNull())
8364 if (lldb_ast ==
nullptr)
8370 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8372 clang::TagDecl *tag_decl =
8373 tag_type->getOriginalDecl()->getDefinitionOrSelf();
8375 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8385 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8386 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8387 if (cxx_record_decl->needsImplicitCopyConstructor())
8388 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8389 if (cxx_record_decl->needsImplicitCopyAssignment())
8390 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8393 if (!cxx_record_decl->isCompleteDefinition())
8394 cxx_record_decl->completeDefinition();
8395 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8396 cxx_record_decl->setHasExternalLexicalStorage(
false);
8397 cxx_record_decl->setHasExternalVisibleStorage(
false);
8398 lldb_ast->SetCXXRecordDeclAccess(cxx_record_decl,
8399 clang::AccessSpecifier::AS_none);
8404 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8408 clang::EnumDecl *enum_decl =
8409 enutype->getOriginalDecl()->getDefinitionOrSelf();
8411 if (enum_decl->isCompleteDefinition())
8414 QualType integer_type(enum_decl->getIntegerType());
8415 if (!integer_type.isNull()) {
8416 clang::ASTContext &ast = lldb_ast->getASTContext();
8418 unsigned NumNegativeBits = 0;
8419 unsigned NumPositiveBits = 0;
8420 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8423 clang::QualType BestPromotionType;
8424 clang::QualType BestType;
8425 ast.computeBestEnumTypes(
false, NumNegativeBits,
8426 NumPositiveBits, BestType, BestPromotionType);
8428 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8429 BestPromotionType, NumPositiveBits,
8437 const llvm::APSInt &value) {
8448 if (!enum_opaque_compiler_type)
8451 clang::QualType enum_qual_type(
8454 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8459 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8464 clang::EnumConstantDecl *enumerator_decl =
8465 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8467 clang::EnumDecl *enum_decl =
8468 enutype->getOriginalDecl()->getDefinitionOrSelf();
8469 enumerator_decl->setDeclContext(enum_decl);
8470 if (name && name[0])
8471 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8472 enumerator_decl->setType(clang::QualType(enutype, 0));
8476 if (!enumerator_decl)
8479 enum_decl->addDecl(enumerator_decl);
8481 VerifyDecl(enumerator_decl);
8482 return enumerator_decl;
8487 uint64_t enum_value, uint32_t enum_value_bit_size) {
8489 llvm::APSInt value(enum_value_bit_size,
8498 const clang::Type *clang_type = qt.getTypePtrOrNull();
8499 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8504 enum_type->getOriginalDecl()->getDefinitionOrSelf()->getIntegerType());
8510 if (type && pointee_type.
IsValid() &&
8515 return ast->GetType(ast->getASTContext().getMemberPointerType(
8524#define DEPTH_INCREMENT 2
8527LLVM_DUMP_METHOD
void
8537struct ScopedASTColor {
8538 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8539 : ast(ast), old_show_colors(ast.getDiagnostics().getShowColors()) {
8540 ast.getDiagnostics().setShowColors(show_colors);
8543 ~ScopedASTColor() { ast.getDiagnostics().setShowColors(old_show_colors); }
8545 clang::ASTContext *
8546 const bool old_show_colors;
8555 clang::CreateASTDumper(output, filter,
8559 false, clang::ADOF_Default);
8562 consumer->HandleTranslationUnit(*
m_ast_up);
8566 llvm::StringRef symbol_name) {
8573 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8574 size_t ntypes = type_list.
GetSize();
8576 for (
size_t i = 0; i < ntypes; ++i) {
8579 if (!symbol_name.empty())
8580 if (symbol_name != type->GetName().GetStringRef())
8583 s << type->GetName().AsCString() <<
"\n";
8586 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8594 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8596 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8608 size_t byte_size, uint32_t bitfield_bit_offset,
8609 uint32_t bitfield_bit_size) {
8610 const clang::EnumType *enutype =
8611 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8612 const clang::EnumDecl *enum_decl =
8613 enutype->getOriginalDecl()->getDefinitionOrSelf();
8615 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8616 const uint64_t enum_svalue =
8619 bitfield_bit_offset)
8621 bitfield_bit_offset);
8622 bool can_be_bitfield =
true;
8623 uint64_t covered_bits = 0;
8624 int num_enumerators = 0;
8632 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8633 if (enumerators.empty())
8634 can_be_bitfield =
false;
8636 for (
auto *enumerator : enumerators) {
8637 llvm::APSInt init_val = enumerator->getInitVal();
8638 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8639 : init_val.getZExtValue();
8640 if (qual_type_is_signed)
8641 val = llvm::SignExtend64(val, 8 * byte_size);
8642 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8643 can_be_bitfield =
false;
8644 covered_bits |= val;
8646 if (val == enum_svalue) {
8655 offset = byte_offset;
8657 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8661 if (!can_be_bitfield) {
8662 if (qual_type_is_signed)
8663 s.
Printf(
"%" PRIi64, enum_svalue);
8665 s.
Printf(
"%" PRIu64, enum_uvalue);
8672 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8676 uint64_t remaining_value = enum_uvalue;
8677 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8678 values.reserve(num_enumerators);
8679 for (
auto *enumerator : enum_decl->enumerators())
8680 if (
auto val = enumerator->getInitVal().getZExtValue())
8681 values.emplace_back(val, enumerator->getName());
8686 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8687 return llvm::popcount(a.first) > llvm::popcount(b.first);
8690 for (
const auto &val : values) {
8691 if ((remaining_value & val.first) != val.first)
8693 remaining_value &= ~val.first;
8695 if (remaining_value)
8701 if (remaining_value)
8702 s.
Printf(
"0x%" PRIx64, remaining_value);
8710 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8719 switch (qual_type->getTypeClass()) {
8720 case clang::Type::Typedef: {
8721 clang::QualType typedef_qual_type =
8722 llvm::cast<clang::TypedefType>(qual_type)
8724 ->getUnderlyingType();
8727 format = typedef_clang_type.
GetFormat();
8728 clang::TypeInfo typedef_type_info =
8730 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8740 bitfield_bit_offset,
8745 case clang::Type::Enum:
8750 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8751 bitfield_bit_offset, bitfield_bit_size);
8759 uint32_t item_count = 1;
8799 item_count = byte_size;
8804 item_count = byte_size / 2;
8809 item_count = byte_size / 4;
8815 bitfield_bit_size, bitfield_bit_offset,
8831 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(clang_type)) {
8840 clang::QualType qual_type =
8843 llvm::SmallVector<char, 1024> buf;
8844 llvm::raw_svector_ostream llvm_ostrm(buf);
8846 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8847 switch (type_class) {
8848 case clang::Type::ObjCObject:
8849 case clang::Type::ObjCInterface: {
8852 auto *objc_class_type =
8853 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8854 assert(objc_class_type);
8855 if (!objc_class_type)
8857 clang::ObjCInterfaceDecl *class_interface_decl =
8858 objc_class_type->getInterface();
8859 if (!class_interface_decl)
8862 class_interface_decl->dump(llvm_ostrm);
8864 class_interface_decl->print(llvm_ostrm,
8869 case clang::Type::Typedef: {
8870 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8873 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
8875 typedef_decl->dump(llvm_ostrm);
8878 if (!clang_typedef_name.empty()) {
8885 case clang::Type::Record: {
8888 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
8889 const clang::RecordDecl *record_decl = record_type->getOriginalDecl();
8891 record_decl->dump(llvm_ostrm);
8893 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
8899 if (
auto *tag_type =
8900 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
8901 if (clang::TagDecl *tag_decl = tag_type->getOriginalDecl()) {
8903 tag_decl->dump(llvm_ostrm);
8905 tag_decl->print(llvm_ostrm, 0);
8911 std::string clang_type_name(qual_type.getAsString());
8912 if (!clang_type_name.empty())
8919 if (buf.size() > 0) {
8920 s.
Write(buf.data(), buf.size());
8927 clang::QualType qual_type(
8930 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8931 switch (type_class) {
8932 case clang::Type::Record: {
8933 const clang::CXXRecordDecl *cxx_record_decl =
8934 qual_type->getAsCXXRecordDecl();
8935 if (cxx_record_decl)
8936 printf(
"class %s", cxx_record_decl->getName().str().c_str());
8939 case clang::Type::Enum: {
8940 clang::EnumDecl *enum_decl =
8941 llvm::cast<clang::EnumType>(qual_type)->getOriginalDecl();
8943 printf(
"enum %s", enum_decl->getName().str().c_str());
8947 case clang::Type::ObjCObject:
8948 case clang::Type::ObjCInterface: {
8949 const clang::ObjCObjectType *objc_class_type =
8950 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
8951 if (objc_class_type) {
8952 clang::ObjCInterfaceDecl *class_interface_decl =
8953 objc_class_type->getInterface();
8957 if (class_interface_decl)
8958 printf(
"@class %s", class_interface_decl->getName().str().c_str());
8962 case clang::Type::Typedef:
8963 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
8970 case clang::Type::Auto:
8973 llvm::cast<clang::AutoType>(qual_type)
8975 .getAsOpaquePtr()));
8977 case clang::Type::Paren:
8981 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
8984 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
8994 if (template_param_infos.
IsValid()) {
8995 std::string template_basename(parent_name);
8997 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
8998 template_basename.erase(i);
9001 template_basename.c_str(), tag_decl_kind,
9002 template_param_infos);
9017 clang::ObjCInterfaceDecl *decl) {
9045 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9046 uint64_t &alignment,
9047 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9048 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9050 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9063 field_offsets, base_offsets, vbase_offsets);
9070 clang::NamedDecl *nd =
9071 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9081 if (!label_or_err) {
9082 llvm::consumeError(label_or_err.takeError());
9086 llvm::StringRef mangled = label_or_err->lookup_name;
9094 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9095 static_cast<clang::Decl *
>(opaque_decl));
9097 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9101 if (!mc || !mc->shouldMangleCXXName(nd))
9106 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9111 llvm::SmallVector<char, 1024> buf;
9112 llvm::raw_svector_ostream llvm_ostrm(buf);
9113 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9115 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9118 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9120 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9124 mc->mangleName(nd, llvm_ostrm);
9140 if (clang::FunctionDecl *func_decl =
9141 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9142 return GetType(func_decl->getReturnType());
9143 if (clang::ObjCMethodDecl *objc_method =
9144 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9145 return GetType(objc_method->getReturnType());
9151 if (clang::FunctionDecl *func_decl =
9152 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9153 return func_decl->param_size();
9154 if (clang::ObjCMethodDecl *objc_method =
9155 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9156 return objc_method->param_size();
9162 clang::DeclContext
const *decl_ctx) {
9163 switch (clang_kind) {
9164 case Decl::TranslationUnit:
9166 case Decl::Namespace:
9177 if (decl_ctx->isFunctionOrMethod())
9179 if (decl_ctx->isRecord())
9189 std::vector<lldb_private::CompilerContext> &context) {
9190 if (decl_ctx ==
nullptr)
9193 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9194 if (clang_kind == Decl::TranslationUnit)
9199 context.push_back({compiler_kind, decl_ctx_name});
9202std::vector<lldb_private::CompilerContext>
9204 std::vector<lldb_private::CompilerContext> context;
9207 clang::Decl *decl = (clang::Decl *)opaque_decl;
9209 clang::DeclContext *decl_ctx = decl->getDeclContext();
9212 auto compiler_kind =
9214 context.push_back({compiler_kind, decl_name});
9221 if (clang::FunctionDecl *func_decl =
9222 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9223 if (idx < func_decl->param_size()) {
9224 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9226 return GetType(var_decl->getOriginalType());
9228 }
else if (clang::ObjCMethodDecl *objc_method =
9229 llvm::dyn_cast<clang::ObjCMethodDecl>(
9230 (clang::Decl *)opaque_decl)) {
9231 if (idx < objc_method->param_size())
9232 return GetType(objc_method->parameters()[idx]->getOriginalType());
9238 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9239 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9242 clang::Expr *init_expr = var_decl->getInit();
9245 std::optional<llvm::APSInt> value =
9255 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9256 std::vector<CompilerDecl> found_decls;
9258 if (opaque_decl_ctx && symbol_file) {
9259 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9260 std::set<DeclContext *> searched;
9261 std::multimap<DeclContext *, DeclContext *> search_queue;
9263 for (clang::DeclContext *decl_context = root_decl_ctx;
9264 decl_context !=
nullptr && found_decls.empty();
9265 decl_context = decl_context->getParent()) {
9266 search_queue.insert(std::make_pair(decl_context, decl_context));
9268 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9270 if (!searched.insert(it->second).second)
9275 for (clang::Decl *child : it->second->decls()) {
9276 if (clang::UsingDirectiveDecl *ud =
9277 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9278 if (ignore_using_decls)
9280 clang::DeclContext *from = ud->getCommonAncestor();
9281 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9282 search_queue.insert(
9283 std::make_pair(from, ud->getNominatedNamespace()));
9284 }
else if (clang::UsingDecl *ud =
9285 llvm::dyn_cast<clang::UsingDecl>(child)) {
9286 if (ignore_using_decls)
9288 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9289 clang::Decl *target = usd->getTargetDecl();
9290 if (clang::NamedDecl *nd =
9291 llvm::dyn_cast<clang::NamedDecl>(target)) {
9292 IdentifierInfo *ii = nd->getIdentifier();
9293 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9297 }
else if (clang::NamedDecl *nd =
9298 llvm::dyn_cast<clang::NamedDecl>(child)) {
9299 IdentifierInfo *ii = nd->getIdentifier();
9300 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9351 clang::DeclContext *child_decl_ctx,
9355 if (frame_decl_ctx && symbol_file) {
9356 std::set<DeclContext *> searched;
9357 std::multimap<DeclContext *, DeclContext *> search_queue;
9360 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9364 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9365 decl_ctx = decl_ctx->getParent()) {
9366 if (!decl_ctx->isLookupContext())
9368 if (decl_ctx == parent_decl_ctx)
9371 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9372 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9374 if (searched.find(it->second) != searched.end())
9382 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9385 searched.insert(it->second);
9389 for (clang::Decl *child : it->second->decls()) {
9390 if (clang::UsingDirectiveDecl *ud =
9391 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9392 clang::DeclContext *ns = ud->getNominatedNamespace();
9393 if (ns == parent_decl_ctx)
9396 clang::DeclContext *from = ud->getCommonAncestor();
9397 if (searched.find(ns) == searched.end())
9398 search_queue.insert(std::make_pair(from, ns));
9399 }
else if (child_name) {
9400 if (clang::UsingDecl *ud =
9401 llvm::dyn_cast<clang::UsingDecl>(child)) {
9402 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9403 clang::Decl *target = usd->getTargetDecl();
9404 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9408 IdentifierInfo *ii = nd->getIdentifier();
9409 if (ii ==
nullptr ||
9410 ii->getName() != child_name->
AsCString(
nullptr))
9433 if (opaque_decl_ctx) {
9434 clang::NamedDecl *named_decl =
9435 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9438 llvm::raw_string_ostream stream{name};
9440 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9441 named_decl->getNameForDiagnostic(stream, policy,
false);
9450 if (opaque_decl_ctx) {
9451 clang::NamedDecl *named_decl =
9452 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9460 if (!opaque_decl_ctx)
9463 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9464 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9466 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9468 }
else if (clang::FunctionDecl *fun_decl =
9469 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9470 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9471 return metadata->HasObjectPtr();
9477std::vector<lldb_private::CompilerContext>
9479 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9480 std::vector<lldb_private::CompilerContext> context;
9486 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9487 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9488 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9492 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9493 if (DC->isInlineNamespace())
9496 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9497 return NS->isAnonymousNamespace();
9504 if (decl_ctx == other)
9506 }
while (is_transparent_lookup_allowed(other) &&
9507 (other = other->getParent()));
9514 if (!opaque_decl_ctx)
9517 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9518 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9520 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9522 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9523 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9524 return metadata->GetObjectPtrLanguage();
9544 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9552 return llvm::dyn_cast<clang::CXXMethodDecl>(
9557clang::FunctionDecl *
9560 return llvm::dyn_cast<clang::FunctionDecl>(
9565clang::NamespaceDecl *
9568 return llvm::dyn_cast<clang::NamespaceDecl>(
9573std::optional<ClangASTMetadata>
9575 const Decl *
object) {
9583 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9605 lldbassert(started &&
"Unable to start a class type definition.");
9610 ts->SetDeclIsForcefullyCompleted(td);
9624 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9625 std::unique_ptr<ClangASTSource> ast_source)
9627 m_scratch_ast_source_up(std::move(ast_source)) {
9629 m_scratch_ast_source_up->InstallASTContext(*
this);
9630 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9631 m_scratch_ast_source_up->CreateProxy();
9632 SetExternalSource(proxy_ast_source);
9636 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9644 llvm::Triple triple)
9651 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9663 std::optional<IsolatedASTKind> ast_kind,
9664 bool create_on_demand) {
9667 if (
auto err = type_system_or_err.takeError()) {
9669 "Couldn't get scratch TypeSystemClang: {0}");
9672 auto ts_sp = *type_system_or_err;
9674 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9679 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9681 return std::static_pointer_cast<TypeSystemClang>(
9686static llvm::StringRef
9690 return "C++ modules";
9692 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9696 llvm::StringRef filter,
bool show_color) {
9698 output <<
"State of scratch Clang type system:\n";
9702 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9703 std::vector<KeyAndTS> sorted_typesystems;
9705 sorted_typesystems.emplace_back(a.first, a.second.get());
9706 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9709 for (
const auto &a : sorted_typesystems) {
9712 output <<
"State of scratch Clang type subsystem "
9714 a.second->Dump(output, filter, show_color);
9719 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9727 desired_type, options, ctx_obj);
9732 const ValueList &arg_value_list,
const char *name) {
9737 Process *process = target_sp->GetProcessSP().get();
9742 arg_value_list, name);
9745std::unique_ptr<UtilityFunction>
9752 return std::make_unique<ClangUtilityFunction>(
9753 *target_sp.get(), std::move(text), std::move(name),
9754 target_sp->GetDebugUtilityExpression());
9768 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9772 return std::make_unique<ClangASTSource>(
9777static llvm::StringRef
9781 return "scratch ASTContext for C++ module types";
9783 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9790 return *found_ast->second;
9793 std::shared_ptr<TypeSystemClang> new_ast_sp =
9803 const clang::RecordType *record_type =
9804 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9806 const clang::RecordDecl *record_decl =
9807 record_type->getOriginalDecl()->getDefinitionOrSelf();
9808 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9809 return metadata->IsForcefullyCompleted();
9818 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9822 metadata->SetIsForcefullyCompleted();
9830 LLDB_LOG(log,
"Created new TypeSystem for (ASTContext*){0:x} '{1}'",
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
static bool DumpEnumValue(const clang::QualType &qual_type, Stream &s, const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_offset, uint32_t bitfield_bit_size)
static lldb::opaque_compiler_type_t GetObjCFieldAtIndex(clang::ASTContext *ast, clang::ObjCInterfaceDecl *class_interface_decl, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr)
static void ParseLangArgs(LangOptions &Opts, ArchSpec arch)
static clang::QualType GetFullyUnqualifiedType_Impl(clang::ASTContext *ast, clang::QualType qual_type)
const TemplateArgument * GetNthTemplateArgument(const clang::ClassTemplateSpecializationDecl *decl, size_t idx, bool expand_pack)
static int64_t ReadVBaseOffsetFromVTable(Process &process, VTableContextBase &vtable_ctx, lldb::addr_t vtable_ptr, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl)
static const clang::RecordType * GetCompleteRecordType(clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion)
Returns the clang::RecordType of the specified qual_type.
lldb_private::ThreadSafeDenseMap< clang::ASTContext *, TypeSystemClang * > ClangASTMap
static bool IsClangDeclContext(const CompilerDeclContext &dc)
static bool TemplateParameterAllowsValue(NamedDecl *param, const TemplateArgument &value)
Returns true if the given template parameter can represent the given value.
static CompilerContextKind GetCompilerKind(clang::Decl::Kind clang_kind, clang::DeclContext const *decl_ctx)
static QualType RemoveWrappingTypes(QualType type, ArrayRef< clang::Type::TypeClass > mask={})
Aggressively desugar the provided type, skipping past various kinds of syntactic sugar and other cons...
static TemplateParameterList * CreateTemplateParameterList(ASTContext &ast, const TypeSystemClang::TemplateParameterInfos &template_param_infos, llvm::SmallVector< NamedDecl *, 8 > &template_param_decls)
clang::DeclContext * FindLCABetweenDecls(clang::DeclContext *left, clang::DeclContext *right, clang::DeclContext *root)
static bool check_op_param(bool is_method, clang::OverloadedOperatorKind op_kind, bool unary, bool binary, uint32_t num_params)
static llvm::StringRef GetSpecializedASTName(ScratchTypeSystemClang::IsolatedASTKind feature)
static bool ObjCDeclHasIVars(clang::ObjCInterfaceDecl *class_interface_decl)
static const clang::ObjCObjectType * GetCompleteObjCObjectType(clang::ASTContext *ast, QualType qual_type, bool allow_completion)
Returns the clang::ObjCObjectType of the specified qual_type.
static lldb::addr_t GetVTableAddress(Process &process, VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout)
static clang::ObjCIvarDecl::AccessControl ConvertAccessTypeToObjCIvarAccessControl(AccessType access)
static std::optional< SymbolFile::ArrayInfo > GetDynamicArrayInfo(TypeSystemClang &ast, SymbolFile *sym_file, clang::QualType qual_type, const ExecutionContext *exe_ctx)
static ConstString ExtractMangledNameFromFunctionCallLabel(llvm::StringRef label)
static llvm::StringRef GetNameForIsolatedASTKind(ScratchTypeSystemClang::IsolatedASTKind kind)
Returns a human-readable name that uniquely identifiers the sub-AST kind.
static void InsertCompilerContext(TypeSystemClang *ts, clang::DeclContext *decl_ctx, std::vector< lldb_private::CompilerContext > &context)
static bool GetVBaseBitOffset(VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl, int32_t &bit_offset)
static const clang::EnumType * GetCompleteEnumType(clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion)
Returns the clang::EnumType of the specified qual_type.
static bool QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext &ast, QualType qual_type)
static ClangASTMap & GetASTMap()
static bool GetCompleteQualType(clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion=true)
static void SetMemberOwningModule(clang::Decl *member, const clang::Decl *parent)
static bool ClassTemplateAllowsToInstantiationArgs(ClassTemplateDecl *class_template_decl, const TypeSystemClang::TemplateParameterInfos &instantiation_values)
Returns true if the given class template declaration could produce an instantiation with the specifie...
#define LLDB_INVALID_DECL_LEVEL
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &info) override
DiagnosticConsumer * clone(DiagnosticsEngine &Diags) const
A section + offset based address class.
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool CharIsSignedByDefault() const
Returns true if 'char' is a signed type by default in the architecture false otherwise.
Manages and observes all Clang AST node importing in LLDB.
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)
void ForgetSource(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx)
"lldb/Expression/ClangFunctionCaller.h" Encapsulates a function that can be called.
"lldb/Expression/ClangPersistentVariables.h" Manages persistent values that need to be preserved betw...
"lldb/Expression/ClangUserExpression.h" Encapsulates a single expression for use with Clang
Represents a generic declaration context in a program.
TypeSystem * GetTypeSystem() const
void * GetOpaqueDeclContext() const
Represents a generic declaration such as a function declaration.
lldb::TypeSystemSP GetSharedPointer() const
Generic representation of a type in a programming language.
lldb::LanguageType GetMinimumLanguage()
bool IsEnumerationType(bool &is_signed) const
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
void SetCompilerType(lldb::TypeSystemWP type_system, lldb::opaque_compiler_type_t type)
lldb::Encoding GetEncoding(uint64_t &count) const
size_t GetIndexOfChildMemberWithName(llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) const
Lookup a child member given a name.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
LLVM_DUMP_METHOD void dump() const
Dumping types.
uint32_t GetNumDirectBaseClasses() const
ConstString GetTypeName(bool BaseOnly=false) const
bool IsEnumerationIntegerTypeSigned() const
bool DumpTypeValue(Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope)
bool IsAggregateType() const
lldb::Format GetFormat() const
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const
CompilerType GetDirectBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
bool GetCompleteType() const
Type Completion.
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
llvm::Expected< uint32_t > GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const
Lookup a child given a name.
llvm::Expected< uint32_t > GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const char * GetCString() const
Get the string value as a C string.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
A class that describes the declaration location of a lldb object.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
Process * GetProcessPtr() const
Returns a pointer to the process object.
static FileSystem & Instance()
bool Test(ValueType bit) const
Test a single flag bit.
bool AnySet(ValueType mask) const
Test one or more flags.
Encapsulates a function that can be called.
static bool LanguageIsC(lldb::LanguageType language)
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
static bool LanguageIsPascal(lldb::LanguageType language)
static bool LanguageIsObjC(lldb::LanguageType language)
static bool IsMangledName(llvm::StringRef name)
A class that describes an executable image and its associated object and symbol files.
virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type, const char *ivar_name)
static ObjCLanguageRuntime * Get(Process &process)
unsigned GetValue() const
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Status &error)
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
uint32_t GetAddressByteSize() const
void Finalize() override
Free up any resources associated with this TypeSystem.
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.
llvm::Triple m_triple
The target triple.
std::unique_ptr< ClangASTSource > CreateASTSource()
lldb::TargetWP m_target_wp
TypeSystemClang & GetIsolatedAST(IsolatedASTKind feature)
Returns the requested sub-AST.
UserExpression * GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language, Expression::ResultType desired_type, const EvaluateExpressionOptions &options, ValueObject *ctx_obj) override
std::unique_ptr< ClangASTSource > m_scratch_ast_source_up
The ExternalASTSource that performs lookups and completes minimally imported types.
IsolatedASTKind
The different kinds of isolated ASTs within the scratch TypeSystem.
@ CppModules
The isolated AST for declarations/types from expressions that imported type information from a C++ mo...
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< ClangPersistentVariables > m_persistent_variables
The persistent variables associated with this process for the expression parser.
static char ID
LLVM RTTI support.
PersistentExpressionState * GetPersistentExpressionState() override
FunctionCaller * GetFunctionCaller(const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, const char *name) override
std::unique_ptr< UtilityFunction > CreateUtilityFunction(std::string text, std::string name) override
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.
ScratchTypeSystemClang(Target &target, llvm::Triple triple)
llvm::DenseMap< IsolatedASTKey, std::shared_ptr< TypeSystemClang > > m_isolated_asts
Map from IsolatedASTKind to their actual TypeSystemClang instance.
bool Fail() const
Test for error condition.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
unsigned GetIndentLevel() const
Get the current indentation level.
Provides public interface for all SymbolFiles.
virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx)
virtual bool CompleteType(CompilerType &compiler_type)=0
virtual void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list)=0
virtual std::optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx)=0
If type_uid points to an array type, return its characteristics.
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
const ArchSpec & GetArchitecture() const
void Insert(_KeyType k, _ValueType v)
_ValueType Lookup(_KeyType k)
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
The implementation of lldb::Type's m_payload field for TypeSystemClang.
void SetIsCompleteObjCClass(bool is_complete_objc_class)
bool IsCompleteObjCClass()
Type::Payload m_payload
The payload is used for typedefs and ptrauth types.
TypePayloadClang()=default
void SetOwningModule(OptionalClangModuleID id)
static constexpr unsigned ObjCClassBit
llvm::ArrayRef< clang::TemplateArgument > GetParameterPackArgs() const
clang::TemplateArgument const & Front() const
llvm::StringRef GetPackName() const
bool hasParameterPack() const
TemplateParameterInfos const & GetParameterPack() const
llvm::ArrayRef< const char * > GetNames() const
llvm::ArrayRef< clang::TemplateArgument > GetArgs() const
A TypeSystem implementation based on Clang.
bool IsMemberFunctionPointerType(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeForIdentifier(const clang::ASTContext &Ctx, llvm::StringRef type_name, clang::DeclContext *decl_context=nullptr)
llvm::Expected< uint64_t > GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
CompilerType CreateFunctionType(const CompilerType &result_type, llvm::ArrayRef< CompilerType > args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
size_t GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) override
static clang::TypedefNameDecl * GetAsTypedefDecl(const CompilerType &type)
std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl, bool qualified=true)
Returns the internal type name for the given NamedDecl using the type printing policy.
static clang::ObjCInterfaceDecl * GetAsObjCInterfaceDecl(const CompilerType &type)
uint32_t m_pointer_byte_size
bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream &s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override
std::string m_display_name
A string describing what this TypeSystemClang represents (e.g., AST for debug information,...
ConstString GetTypeName(lldb::opaque_compiler_type_t type, bool base_only) override
static void SetOwningModule(clang::Decl *decl, OptionalClangModuleID owning_module)
Set the owning module for decl.
llvm::Expected< uint64_t > GetObjCBitSize(clang::QualType qual_type, ExecutionContextScope *exe_scope)
std::unique_ptr< clang::TargetInfo > m_target_info_up
std::unique_ptr< clang::LangOptions > m_language_options_up
Scalar DeclGetConstantValue(void *opaque_decl) override
llvm::Expected< CompilerType > GetDereferencedType(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, std::string &deref_name, uint32_t &deref_byte_size, int32_t &deref_byte_offset, ValueObject *valobj, uint64_t &language_flags) override
bool BaseSpecifierIsEmpty(const clang::CXXBaseSpecifier *b)
static uint32_t GetNumPointeeChildren(clang::QualType type)
ConstString DeclGetMangledName(void *opaque_decl) override
CompilerType GetBasicType(lldb::BasicType type)
clang::ClassTemplateDecl * CreateClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef class_name, int kind, const TemplateParameterInfos &infos)
std::unique_ptr< clang::HeaderSearchOptions > m_header_search_opts_up
clang::UsingDecl * CreateUsingDeclaration(clang::DeclContext *current_decl_ctx, OptionalClangModuleID owning_module, clang::NamedDecl *target)
static clang::AccessSpecifier ConvertAccessTypeToAccessSpecifier(lldb::AccessType access)
CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override
bool IsForcefullyCompleted(lldb::opaque_compiler_type_t type) override
bool SupportsLanguage(lldb::LanguageType language) override
uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override
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.
void CompleteTagDecl(clang::TagDecl *)
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size)
std::shared_ptr< clang::TargetOptions > & getTargetOptions()
static TypeSystemClang * GetASTContext(clang::ASTContext *ast_ctx)
bool IsReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool *is_rvalue) override
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
const char * GetTargetTriple()
TypeSystemClang(llvm::StringRef name, llvm::Triple triple)
Constructs a TypeSystemClang with an ASTContext using the given triple.
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, Module *module, Target *target)
clang::TargetInfo * getTargetInfo()
clang::FunctionTemplateDecl * CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::FunctionDecl *func_decl, const TemplateParameterInfos &infos)
CompilerType CreateArrayType(const CompilerType &element_type, std::optional< size_t > element_count, bool is_vector)
static bool AreTypesSame(CompilerType type1, CompilerType type2, bool ignore_qualifiers=false)
CompilerType GetArrayType(lldb::opaque_compiler_type_t type, uint64_t size) override
bool IsFunctionType(lldb::opaque_compiler_type_t type) override
CompilerType GetFunctionReturnType(lldb::opaque_compiler_type_t type) override
std::optional< ClangASTMetadata > GetMetadata(const clang::Decl *object)
CompilerType GetLValueReferenceType(lldb::opaque_compiler_type_t type) override
bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td)
lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override
bool CanPassInRegisters(const CompilerType &type) override
CompilerDecl GetStaticFieldWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex) override
bool IsEnumerationType(lldb::opaque_compiler_type_t type, bool &is_signed) override
bool IsTemplateType(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
static bool IsCXXClassType(const CompilerType &type)
bool IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed) override
void SetCXXRecordDeclAccess(const clang::CXXRecordDecl *object, clang::AccessSpecifier access)
uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override
static bool IsOperator(llvm::StringRef name, clang::OverloadedOperatorKind &op_kind)
bool IsCharType(lldb::opaque_compiler_type_t type) override
CompilerType CreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
static void SetFloatingInitializerForVariable(clang::VarDecl *var, const llvm::APFloat &init_value)
Initializes a variable with a floating point value.
uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) override
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) override
CompilerType GetType(clang::QualType qt)
Creates a CompilerType from the given QualType with the current TypeSystemClang instance as the Compi...
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override
std::string m_target_triple
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > bases)
bool IsBeingDefined(lldb::opaque_compiler_type_t type) override
ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override
std::unique_ptr< clang::IdentifierTable > m_identifier_table_up
static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name)
static void SetIntegerInitializerForVariable(clang::VarDecl *var, const llvm::APInt &init_value)
Initializes a variable with an integer value.
bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override
CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &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 IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::SourceManager > m_source_manager_up
bool IsVoidType(lldb::opaque_compiler_type_t type) override
static void SetIsPacked(const CompilerType &type)
void ForEachEnumerator(lldb::opaque_compiler_type_t type, std::function< bool(const CompilerType &integer_type, ConstString name, const llvm::APSInt &value)> const &callback) override
clang::AccessSpecifier GetCXXRecordDeclAccess(const clang::CXXRecordDecl *object)
CompilerType CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *class_template_specialization_decl)
bool IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
std::unique_ptr< clang::DiagnosticOptions > m_diagnostic_options_up
void CreateFunctionTemplateSpecializationInfo(clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template, const TemplateParameterInfos &infos)
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, uint64_t enum_value, uint32_t enum_value_bit_size)
llvm::StringRef getDisplayName() const
Returns the display name of this TypeSystemClang that indicates what purpose it serves in LLDB.
bool IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length)
CompilerType GetRValueReferenceType(lldb::opaque_compiler_type_t type) override
CompilerDecl GetCompilerDecl(clang::Decl *decl)
Creates a CompilerDecl from the given Decl with the current TypeSystemClang instance as its typesyste...
unsigned GetPtrAuthDiscriminator(lldb::opaque_compiler_type_t type) override
CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override
bool GetCompleteType(lldb::opaque_compiler_type_t type) override
bool IsBlockPointerType(lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) override
bool IsConst(lldb::opaque_compiler_type_t type) override
static clang::AccessSpecifier UnifyAccessSpecifiers(clang::AccessSpecifier lhs, clang::AccessSpecifier rhs)
std::unique_ptr< clang::CXXBaseSpecifier > CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class)
CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override
std::vector< CompilerDecl > DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_using_decls) override
const llvm::fltSemantics & GetFloatTypeSemantics(size_t byte_size, lldb::Format format) override
llvm::Expected< uint32_t > GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes) override
void setSema(clang::Sema *s)
uint32_t GetPointerByteSize() override
bool IsCompleteType(lldb::opaque_compiler_type_t type) override
CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed)
clang::MangleContext * getMangleContext()
void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *)
unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override
static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx)
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
CompilerType GetTypeForFormatters(void *type) override
void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id)
bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override
This is used by swift.
static LanguageSet GetSupportedLanguagesForExpressions()
clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, const CompilerType &function_Type, clang::StorageClass storage, bool is_inline, llvm::StringRef asm_label)
CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override
CompilerDeclContext GetCompilerDeclContextForType(const CompilerType &type) override
Returns the direct parent context of specified type.
std::unique_ptr< clang::SelectorTable > m_selector_table_up
PDBASTParser * GetPDBParser() override
std::optional< CompilerType::IntegralTemplateArgument > GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
bool DeclContextIsClassMethod(void *opaque_decl_ctx) override
void SetTargetTriple(llvm::StringRef target_triple)
CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
static bool CheckOverloadedOperatorKindParameterCount(bool is_method, clang::OverloadedOperatorKind op_kind, uint32_t num_params)
clang::DeclarationName GetDeclarationName(llvm::StringRef name, const CompilerType &function_clang_type)
DeclMetadataMap m_decl_metadata
Maps Decls to their associated ClangASTMetadata.
static clang::CXXMethodDecl * DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc)
CompilerType GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override
uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx, clang::DeclContext *child_decl_ctx, ConstString *child_name=nullptr, CompilerType *child_type=nullptr)
static clang::QualType GetQualType(lldb::opaque_compiler_type_t type)
clang::PrintingPolicy GetTypePrintingPolicy()
Returns the PrintingPolicy used when generating the internal type names.
uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override
static clang::RecordDecl * GetAsRecordDecl(const CompilerType &type)
CompilerType GetPointerSizedIntType(bool is_signed)
uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl, bool omit_empty_base_classes)
lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) override
std::unique_ptr< DWARFASTParserClang > m_dwarf_ast_parser_up
CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size)
bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override
int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override
static void BuildIndirectFields(const CompilerType &type)
std::unique_ptr< clang::FileManager > m_file_manager_up
uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl, const clang::CXXBaseSpecifier *base_spec, bool omit_empty_base_classes)
bool IsAnonymousType(lldb::opaque_compiler_type_t type) override
bool Verify(lldb::opaque_compiler_type_t type) override
Verify the integrity of the type to catch CompilerTypes that mix and match invalid TypeSystem/Opaque ...
size_t GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override
void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type)
CompilerType CreateBlockPointerType(const CompilerType &function_type)
lldb::LanguageType GetMinimumLanguage(lldb::opaque_compiler_type_t type) override
bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size)
clang::ClassTemplateSpecializationDecl * CreateClassTemplateSpecializationDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::ClassTemplateDecl *class_template_decl, int kind, const TemplateParameterInfos &infos)
llvm::SmallVector< clang::ParmVarDecl * > CreateParameterDeclarations(clang::FunctionDecl *context, const clang::FunctionProtoType &prototype, const llvm::SmallVector< llvm::StringRef > ¶m_names)
For each parameter type of prototype, creates a clang::ParmVarDecl whose clang::DeclContext is contex...
std::unique_ptr< clang::HeaderSearch > m_header_search_up
void Finalize() override
Free up any resources associated with this TypeSystem.
static clang::ASTContext * DeclContextGetTypeSystemClang(const CompilerDeclContext &dc)
uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, CompilerType *base_type_ptr) override
LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override
Convenience LLVM-style dump method for use in the debugger only.
CXXRecordDeclAccessMap m_cxx_record_decl_access
Maps CXXRecordDecl to their most recent added method/field's AccessSpecifier.
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
std::unique_ptr< clang::ASTContext > m_ast_up
CompilerType CreateGenericFunctionPrototype() override
static clang::QualType GetCanonicalQualType(lldb::opaque_compiler_type_t type)
CompilerType DeclGetFunctionReturnType(void *opaque_decl) override
static bool IsEnumType(lldb::opaque_compiler_type_t type)
std::unique_ptr< npdb::PdbAstBuilder > m_native_pdb_ast_parser_up
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
CompilerType GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static bool SetObjCSuperClass(const CompilerType &type, const CompilerType &superclass_compiler_type)
clang::UsingDirectiveDecl * CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::NamespaceDecl *ns_decl)
static lldb::opaque_compiler_type_t GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type)
bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override
void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name)
Dump clang AST types from the symbol file.
CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override
static void DumpDeclHiearchy(clang::Decl *decl)
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
static clang::FunctionDecl * DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc)
bool IsScalarType(lldb::opaque_compiler_type_t type) override
bool GetPtrAuthAddressDiversity(lldb::opaque_compiler_type_t type) override
std::shared_ptr< clang::TargetOptions > m_target_options_rp
lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override
static bool IsClassType(lldb::opaque_compiler_type_t type)
bool IsDefined(lldb::opaque_compiler_type_t type) override
static bool IsObjCClassType(const CompilerType &type)
TypeMetadataMap m_type_metadata
Maps Types to their associated ClangASTMetadata.
CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override
bool RecordHasFields(const clang::RecordDecl *record_decl)
CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index) override
static std::optional< ClangASTMetadata > DeclContextGetMetaData(const CompilerDeclContext &dc, const clang::Decl *object)
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override
static clang::ObjCMethodDecl * AddMethodToObjCObjectType(const CompilerType &type, const char *name, const CompilerType &method_compiler_type, bool is_artificial, bool is_variadic, bool is_objc_direct_call)
~TypeSystemClang() override
CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, std::optional< ClangASTMetadata > metadata=std::nullopt, bool exports_symbols=false)
bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, void *other_opaque_decl_ctx) override
CompilerType AddPtrAuthModifier(lldb::opaque_compiler_type_t type, uint32_t payload) override
static bool AddObjCClassProperty(const CompilerType &type, const char *property_name, const CompilerType &property_compiler_type, clang::ObjCIvarDecl *ivar_decl, const char *property_setter_name, const char *property_getter_name, uint32_t property_attributes, ClangASTMetadata metadata)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
void SetMetadata(const clang::Decl *object, ClangASTMetadata meta_data)
clang::ParmVarDecl * CreateParameterDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType ¶m_type, int storage, bool add_decl=false)
void DumpTypeDescription(lldb::opaque_compiler_type_t type, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) override
Dump the type to stdout.
CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
static clang::NamespaceDecl * DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped, std::optional< clang::EnumExtensibilityAttr::Kind > enum_kind=std::nullopt)
npdb::PdbAstBuilder * GetNativePDBParser() override
std::unique_ptr< clang::DiagnosticConsumer > m_diagnostic_consumer_up
CompilerType CreateObjCClass(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool isInternal, std::optional< ClangASTMetadata > metadata=std::nullopt)
CompilerType GetTypeForDecl(clang::NamedDecl *decl)
CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc)
lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, uint64_t &count) override
bool IsTypedefType(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override
std::optional< size_t > GetTypeBitAlign(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< clang::Builtin::Context > m_builtins_up
CompilerType GetBuiltinTypeByName(ConstString name) override
bool GetCompleteDecl(clang::Decl *decl)
static bool StartTagDeclarationDefinition(const CompilerType &type)
uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl, bool omit_empty_base_classes)
bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, CompilerType *target_type, bool check_cplusplus, bool check_objc) override
CompilerType GetOrCreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
void LogCreation() const
Emits information about this TypeSystem into the expression log.
static llvm::StringRef GetPluginNameStatic()
clang::Sema * m_sema
The sema associated that is currently used to build this ASTContext.
size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override
static clang::VarDecl * AddVariableToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &var_type, lldb::AccessType access)
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override
const clang::ClassTemplateSpecializationDecl * GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type)
std::unique_ptr< clang::MangleContext > m_mangle_ctx_up
TypeMemberFunctionImpl GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
bool IsTypeImpl(lldb::opaque_compiler_type_t type, llvm::function_ref< bool(clang::QualType)> predicate) const
size_t DeclGetFunctionNumArguments(void *opaque_decl) override
CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< PDBASTParser > m_pdb_ast_parser_up
std::unique_ptr< clang::DiagnosticsEngine > m_diagnostics_engine_up
static std::optional< std::string > GetCXXClassName(const CompilerType &type)
static void DumpTypeName(const CompilerType &type)
plugin::dwarf::DWARFASTParser * GetDWARFParser() override
CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx) override
bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
static clang::EnumDecl * GetAsEnumDecl(const CompilerType &type)
CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::ModuleMap > m_module_map_up
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, llvm::StringRef asm_label, const CompilerType &method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
static bool IsObjCObjectOrInterfaceType(const CompilerType &type)
static void RequireCompleteType(CompilerType type)
Complete a type from debug info, or mark it as forcefully completed if there is no definition of the ...
CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload) override
Using the current type, create a new typedef to that type using "typedef_name" as the name and "decl_...
llvm::Expected< uint32_t > GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes, const ExecutionContext *exe_ctx) override
CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override
clang::TemplateTemplateParmDecl * CreateTemplateTemplateParmDecl(const char *template_name)
lldb::TemplateArgumentKind GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
clang::ClassTemplateDecl * ParseClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, const char *parent_name, int tag_decl_kind, const TypeSystemClang::TemplateParameterInfos &template_param_infos)
clang::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
std::vector< lldb_private::CompilerContext > DeclGetCompilerContext(void *opaque_decl) override
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
std::vector< lldb_private::CompilerContext > DeclContextGetCompilerContext(void *opaque_decl_ctx) override
void CreateASTContext()
Creates the internal ASTContext.
void SetExternalSource(llvm::IntrusiveRefCntPtr< clang::ExternalASTSource > ast_source_sp)
CompilerType GetCStringType(bool is_const)
bool IsAggregateType(lldb::opaque_compiler_type_t type) override
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override
static LanguageSet GetSupportedLanguagesForTypes()
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
llvm::Expected< uint64_t > GetByteSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope)
ConstString DeclContextGetName(void *opaque_decl_ctx) override
size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack) override
ConstString DeclGetName(void *opaque_decl) override
virtual SymbolFile * GetSymbolFile() const
bool m_has_forcefully_completed_types
Used for reporting statistics.
Encapsulates a one-time expression for use in lldb.
virtual uint64_t GetData(DataExtractor &data, Status &error)
CompilerType GetCompilerType()
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
AddressType GetAddressTypeOfChildren()
ConstString GetName() const
const ExecutionContextRef & GetExecutionContextRef() const
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_IVAR_OFFSET
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.
lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, uint32_t item_bit_size, uint32_t item_bit_offset, ExecutionContextScope *exe_scope=nullptr, bool show_memory_tags=false)
Dumps item_count objects into the stream s.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
void * opaque_compiler_type_t
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eBasicTypeUnsignedShort
@ eBasicTypeUnsignedInt128
@ eBasicTypeUnsignedWChar
@ eBasicTypeLongDoubleComplex
@ eBasicTypeUnsignedLongLong
@ eBasicTypeDoubleComplex
Format
Display format definitions.
@ eFormatCString
NULL terminated C strings.
@ eFormatCharArray
Print characters with no single quotes, used for character arrays that can contain non printable char...
@ eFormatVoid
Do not print this.
@ eFormatComplex
Floating point complex type.
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
@ eFormatComplexInteger
Integer complex type.
@ eFormatFloat128
Disambiguate between 128-bit long double (which uses eFormatFloat) and __float128 (which uses eFormat...
LanguageType
Programming language type.
@ eLanguageTypeC_plus_plus_20
ISO C++:2020.
@ eLanguageTypeC_plus_plus_14
ISO C++:2014.
@ eLanguageTypeC11
ISO C:2011.
@ eLanguageTypeC99
ISO C:1999.
@ eLanguageTypeC_plus_plus_03
ISO C++:2003.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeC_plus_plus_17
ISO C++:2017.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
@ eLanguageTypeC_plus_plus_11
ISO C++:2011.
@ eLanguageTypeC89
ISO C:1989.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
@ eLanguageTypeDylan
Dylan.
std::shared_ptr< lldb_private::Type > TypeSP
@ eTemplateArgumentKindTemplate
@ eTemplateArgumentKindTemplateExpansion
@ eTemplateArgumentKindNull
@ eTemplateArgumentKindNullPtr
@ eTemplateArgumentKindDeclaration
@ eTemplateArgumentKindIntegral
@ eTemplateArgumentKindPack
@ eTemplateArgumentKindType
@ eTemplateArgumentKindStructuralValue
@ eTemplateArgumentKindExpression
Encoding
Register encoding definitions.
@ eEncodingVector
vector registers
@ eEncodingUint
unsigned integer
@ eEncodingSint
signed integer
MemberFunctionKind
Kind of member function.
@ eMemberFunctionKindInstanceMethod
A function that applies to a specific instance.
@ eMemberFunctionKindConstructor
A function used to create instances.
@ eMemberFunctionKindUnknown
Not sure what the type of this is.
@ eMemberFunctionKindDestructor
A function used to tear down existing instances.
@ eMemberFunctionKindStaticMethod
A function that applies to a type rather than any instance.
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Target > TargetSP
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)
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
static llvm::Expected< FunctionCallLabel > fromString(llvm::StringRef label)
Decodes the specified function label into a FunctionCallLabel.
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
void Insert(lldb::LanguageType language)
A type-erased pair of llvm::dwarf::SourceLanguageName and version.