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 = {
880 auto iter = g_type_map.find(name);
881 if (iter == g_type_map.end())
908 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
927 return GetType(ast.UnsignedCharTy);
929 return GetType(ast.UnsignedShortTy);
931 return GetType(ast.UnsignedIntTy);
936 if (type_name.contains(
"complex")) {
945 case DW_ATE_complex_float: {
946 CanQualType FloatComplexTy = ast.getComplexType(ast.FloatTy);
948 return GetType(FloatComplexTy);
950 CanQualType DoubleComplexTy = ast.getComplexType(ast.DoubleTy);
952 return GetType(DoubleComplexTy);
954 CanQualType LongDoubleComplexTy = ast.getComplexType(ast.LongDoubleTy);
956 return GetType(LongDoubleComplexTy);
966 if (type_name ==
"float" &&
969 if (type_name ==
"double" &&
972 if (type_name ==
"long double" &&
974 return GetType(ast.LongDoubleTy);
975 if (type_name ==
"__bf16" &&
977 return GetType(ast.BFloat16Ty);
978 if (type_name ==
"_Float16" &&
984 if ((type_name ==
"__float128" || type_name ==
"_Float128" ||
985 type_name ==
"f128") &&
987 return GetType(ast.Float128Ty);
994 return GetType(ast.LongDoubleTy);
998 return GetType(ast.Float128Ty);
1002 if (!type_name.empty()) {
1003 if (type_name.starts_with(
"_BitInt"))
1004 return GetType(ast.getBitIntType(
false, bit_size));
1005 if (type_name ==
"wchar_t" &&
1010 if (type_name ==
"void" &&
1013 if (type_name.contains(
"long long") &&
1015 return GetType(ast.LongLongTy);
1016 if (type_name.contains(
"long") &&
1019 if (type_name.contains(
"short") &&
1022 if (type_name.contains(
"char")) {
1026 return GetType(ast.SignedCharTy);
1028 if (type_name.contains(
"int")) {
1045 return GetType(ast.LongLongTy);
1050 case DW_ATE_signed_char:
1051 if (type_name ==
"char") {
1056 return GetType(ast.SignedCharTy);
1059 case DW_ATE_unsigned:
1060 if (!type_name.empty()) {
1061 if (type_name.starts_with(
"unsigned _BitInt"))
1062 return GetType(ast.getBitIntType(
true, bit_size));
1063 if (type_name ==
"wchar_t") {
1070 if (type_name.contains(
"long long")) {
1072 return GetType(ast.UnsignedLongLongTy);
1073 }
else if (type_name.contains(
"long")) {
1075 return GetType(ast.UnsignedLongTy);
1076 }
else if (type_name.contains(
"short")) {
1078 return GetType(ast.UnsignedShortTy);
1079 }
else if (type_name.contains(
"char")) {
1081 return GetType(ast.UnsignedCharTy);
1082 }
else if (type_name.contains(
"int")) {
1084 return GetType(ast.UnsignedIntTy);
1086 return GetType(ast.UnsignedInt128Ty);
1091 return GetType(ast.UnsignedCharTy);
1093 return GetType(ast.UnsignedShortTy);
1095 return GetType(ast.UnsignedIntTy);
1097 return GetType(ast.UnsignedLongTy);
1099 return GetType(ast.UnsignedLongLongTy);
1101 return GetType(ast.UnsignedInt128Ty);
1104 case DW_ATE_unsigned_char:
1105 if (type_name ==
"char") {
1110 return GetType(ast.UnsignedCharTy);
1112 return GetType(ast.UnsignedShortTy);
1115 case DW_ATE_imaginary_float:
1127 if (!type_name.empty()) {
1128 if (type_name ==
"char16_t")
1130 if (type_name ==
"char32_t")
1132 if (type_name ==
"char8_t")
1141 "error: need to add support for DW_TAG_base_type '{0}' "
1142 "encoded with DW_ATE = {1:x}, bit_size = {2}",
1143 type_name, dw_ate, bit_size);
1149 QualType char_type(ast.CharTy);
1152 char_type.addConst();
1154 return GetType(ast.getPointerType(char_type));
1158 bool ignore_qualifiers) {
1169 if (ignore_qualifiers) {
1170 type1_qual = type1_qual.getUnqualifiedType();
1171 type2_qual = type2_qual.getUnqualifiedType();
1174 return ast->getASTContext().hasSameType(type1_qual, type2_qual);
1181 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
1182 if (
auto *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl))
1194 if (clang::ObjCInterfaceDecl *interface_decl =
1195 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
1197 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
1199 if (clang::ValueDecl *value_decl = llvm::dyn_cast<clang::ValueDecl>(decl))
1213 return GetType(value_decl->getType());
1216#pragma mark Structure, Unions, Classes
1220 if (!decl || !owning_module.
HasValue())
1223 decl->setFromASTFile();
1224 decl->setOwningModuleID(owning_module.
GetValue());
1225 decl->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
1231 bool is_framework,
bool is_explicit) {
1233 auto *ast_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1235 assert(ast_source &&
"external ast source was lost");
1253 clang::Module *module;
1254 auto parent_desc = ast_source->getSourceDescriptor(parent.
GetValue());
1256 name, parent_desc ? parent_desc->getModuleOrNull() :
nullptr,
1257 is_framework, is_explicit);
1259 return ast_source->GetIDForModule(module);
1261 return ast_source->RegisterModule(module);
1266 AccessType access_type, llvm::StringRef name,
int kind,
1267 LanguageType language, std::optional<ClangASTMetadata> metadata,
1268 bool exports_symbols) {
1271 if (decl_ctx ==
nullptr)
1272 decl_ctx = ast.getTranslationUnitDecl();
1276 bool isInternal =
false;
1277 return CreateObjCClass(name, decl_ctx, owning_module, isInternal, metadata);
1286 bool has_name = !name.empty();
1287 CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1288 decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1289 decl->setDeclContext(decl_ctx);
1291 decl->setDeclName(&ast.Idents.get(name));
1319 if (isa<CXXRecordDecl>(decl_ctx) && exports_symbols)
1320 decl->setAnonymousStructOrUnion(
true);
1330 decl_ctx->addDecl(decl);
1332 return GetType(ast.getCanonicalTagType(decl));
1339QualType GetValueParamType(
const clang::TemplateArgument &argument) {
1340 switch (argument.getKind()) {
1341 case TemplateArgument::Integral:
1342 return argument.getIntegralType();
1343 case TemplateArgument::StructuralValue:
1344 return argument.getStructuralValueType();
1350void AddAccessSpecifierDecl(clang::CXXRecordDecl *cxx_record_decl,
1352 clang::AccessSpecifier previous_access,
1353 clang::AccessSpecifier access_specifier) {
1354 if (!cxx_record_decl->isClass() && !cxx_record_decl->isStruct())
1356 if (previous_access != access_specifier) {
1359 if ((cxx_record_decl->isStruct() &&
1360 previous_access == clang::AccessSpecifier::AS_none &&
1361 access_specifier == clang::AccessSpecifier::AS_public) ||
1362 (cxx_record_decl->isClass() &&
1363 previous_access == clang::AccessSpecifier::AS_none &&
1364 access_specifier == clang::AccessSpecifier::AS_private)) {
1367 cxx_record_decl->addDecl(
1368 AccessSpecDecl::Create(ct, access_specifier, cxx_record_decl,
1369 SourceLocation(), SourceLocation()));
1377 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1378 const bool parameter_pack =
false;
1379 const bool is_typename =
false;
1380 const unsigned depth = 0;
1381 const size_t num_template_params = template_param_infos.
Size();
1382 DeclContext *
const decl_context =
1383 ast.getTranslationUnitDecl();
1385 auto const &args = template_param_infos.
GetArgs();
1386 auto const &names = template_param_infos.
GetNames();
1387 for (
size_t i = 0; i < num_template_params; ++i) {
1388 const char *name = names[i];
1390 IdentifierInfo *identifier_info =
nullptr;
1391 if (name && name[0])
1392 identifier_info = &ast.Idents.get(name);
1393 TemplateArgument
const &targ = args[i];
1394 QualType template_param_type = GetValueParamType(targ);
1395 if (!template_param_type.isNull()) {
1396 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1397 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1398 identifier_info, template_param_type, parameter_pack,
1399 ast.getTrivialTypeSourceInfo(template_param_type)));
1401 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1402 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1403 identifier_info, is_typename, parameter_pack));
1408 IdentifierInfo *identifier_info =
nullptr;
1410 identifier_info = &ast.Idents.get(template_param_infos.
GetPackName());
1411 const bool parameter_pack_true =
true;
1413 QualType template_param_type =
1417 if (!template_param_type.isNull()) {
1418 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1419 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1420 num_template_params, identifier_info, template_param_type,
1421 parameter_pack_true,
1422 ast.getTrivialTypeSourceInfo(template_param_type)));
1424 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1425 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1426 num_template_params, identifier_info, is_typename,
1427 parameter_pack_true));
1430 clang::Expr *
const requires_clause =
nullptr;
1431 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1432 ast, SourceLocation(), SourceLocation(), template_param_decls,
1433 SourceLocation(), requires_clause);
1434 return template_param_list;
1439 clang::FunctionDecl *func_decl,
1444 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1446 ast, template_param_infos, template_param_decls);
1447 FunctionTemplateDecl *func_tmpl_decl =
1448 FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1449 func_tmpl_decl->setDeclContext(decl_ctx);
1450 func_tmpl_decl->setLocation(func_decl->getLocation());
1451 func_tmpl_decl->setDeclName(func_decl->getDeclName());
1452 func_tmpl_decl->setTemplateParameters(template_param_list);
1453 func_tmpl_decl->init(func_decl);
1456 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1457 i < template_param_decl_count; ++i) {
1459 template_param_decls[i]->setDeclContext(func_decl);
1464 if (decl_ctx->isRecord())
1465 func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
1467 return func_tmpl_decl;
1471 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1473 TemplateArgumentList *template_args_ptr = TemplateArgumentList::CreateCopy(
1474 func_decl->getASTContext(), infos.
GetArgs());
1476 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
1477 template_args_ptr,
nullptr);
1484 const TemplateArgument &value) {
1485 if (llvm::isa<TemplateTypeParmDecl>(param)) {
1487 if (value.getKind() != TemplateArgument::Type)
1489 }
else if (
auto *type_param =
1490 llvm::dyn_cast<NonTypeTemplateParmDecl>(param)) {
1492 QualType value_param_type = GetValueParamType(value);
1493 if (value_param_type.isNull())
1497 if (type_param->getType() != value_param_type)
1505 "Don't know how to compare template parameter to passed"
1506 " value. Decl kind of parameter is: {0}",
1507 param->getDeclKindName());
1508 lldbassert(
false &&
"Can't compare this TemplateParmDecl subclass");
1523 ClassTemplateDecl *class_template_decl,
1526 TemplateParameterList ¶ms = *class_template_decl->getTemplateParameters();
1532 std::optional<NamedDecl *> pack_parameter;
1534 size_t non_pack_params = params.size();
1535 for (
size_t i = 0; i < params.size(); ++i) {
1536 NamedDecl *param = params.getParam(i);
1537 if (param->isParameterPack()) {
1538 pack_parameter = param;
1539 non_pack_params = i;
1547 if (non_pack_params != instantiation_values.
Size())
1565 for (
const auto pair :
1566 llvm::zip_first(instantiation_values.
GetArgs(), params)) {
1567 const TemplateArgument &passed_arg = std::get<0>(pair);
1568 NamedDecl *found_param = std::get<1>(pair);
1573 return class_template_decl;
1582 ClassTemplateDecl *class_template_decl =
nullptr;
1583 if (decl_ctx ==
nullptr)
1584 decl_ctx = ast.getTranslationUnitDecl();
1586 IdentifierInfo &identifier_info = ast.Idents.get(class_name);
1587 DeclarationName decl_name(&identifier_info);
1590 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1591 for (NamedDecl *decl : result) {
1592 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1593 if (!class_template_decl)
1602 template_param_infos))
1604 return class_template_decl;
1607 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1610 ast, template_param_infos, template_param_decls);
1612 CXXRecordDecl *template_cxx_decl =
1613 CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1614 template_cxx_decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1616 template_cxx_decl->setDeclContext(decl_ctx);
1617 template_cxx_decl->setDeclName(decl_name);
1620 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1621 i < template_param_decl_count; ++i) {
1622 template_param_decls[i]->setDeclContext(template_cxx_decl);
1630 class_template_decl =
1631 ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1633 class_template_decl->setDeclContext(decl_ctx);
1634 class_template_decl->setDeclName(decl_name);
1635 class_template_decl->setTemplateParameters(template_param_list);
1636 class_template_decl->init(template_cxx_decl);
1637 template_cxx_decl->setDescribedClassTemplate(class_template_decl);
1641 class_template_decl->setAccess(
1644 decl_ctx->addDecl(class_template_decl);
1646 VerifyDecl(class_template_decl);
1648 return class_template_decl;
1651TemplateTemplateParmDecl *
1655 auto *decl_ctx = ast.getTranslationUnitDecl();
1657 IdentifierInfo &identifier_info = ast.Idents.get(template_name);
1658 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1662 ast, template_param_infos, template_param_decls);
1668 return TemplateTemplateParmDecl::Create(
1669 ast, decl_ctx, SourceLocation(),
1671 false, &identifier_info,
1672 TemplateNameKind::TNK_Type_template,
true,
1673 template_param_list);
1676ClassTemplateSpecializationDecl *
1679 ClassTemplateDecl *class_template_decl,
int kind,
1682 llvm::SmallVector<clang::TemplateArgument, 2> args(
1683 template_param_infos.
Size() +
1686 auto const &orig_args = template_param_infos.
GetArgs();
1687 std::copy(orig_args.begin(), orig_args.end(), args.begin());
1689 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1692 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1693 ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
1694 class_template_specialization_decl->setTagKind(
1695 static_cast<TagDecl::TagKind
>(kind));
1696 class_template_specialization_decl->setDeclContext(decl_ctx);
1697 class_template_specialization_decl->setInstantiationOf(class_template_decl);
1698 class_template_specialization_decl->setTemplateArgs(
1699 TemplateArgumentList::CreateCopy(ast, args));
1700 void *insert_pos =
nullptr;
1701 if (class_template_decl->findSpecialization(args, insert_pos))
1703 class_template_decl->AddSpecialization(class_template_specialization_decl,
1705 class_template_specialization_decl->setDeclName(
1706 class_template_decl->getDeclName());
1711 class_template_specialization_decl->setStrictPackMatch(
false);
1714 decl_ctx->addDecl(class_template_specialization_decl);
1716 class_template_specialization_decl->setSpecializationKind(
1717 TSK_ExplicitSpecialization);
1719 return class_template_specialization_decl;
1723 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1724 if (class_template_specialization_decl) {
1726 return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
1732 clang::OverloadedOperatorKind op_kind,
1733 bool unary,
bool binary,
1734 uint32_t num_params) {
1736 if (op_kind == OO_Call)
1742 if (num_params == 1)
1744 if (num_params == 2)
1751 bool is_method, clang::OverloadedOperatorKind op_kind,
1752 uint32_t num_params) {
1760 case OO_Array_Delete:
1764#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1766 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1768#include "clang/Basic/OperatorKinds.def"
1775clang::AccessSpecifier
1777 clang::AccessSpecifier rhs) {
1780 if (lhs == AS_none || rhs == AS_none)
1782 if (lhs == AS_private || rhs == AS_private)
1784 if (lhs == AS_protected || rhs == AS_protected)
1785 return AS_protected;
1790 uint32_t &bitfield_bit_size) {
1792 if (field ==
nullptr)
1795 if (field->isBitField()) {
1796 Expr *bit_width_expr = field->getBitWidth();
1797 if (bit_width_expr) {
1798 if (std::optional<llvm::APSInt> bit_width_apsint =
1799 bit_width_expr->getIntegerConstantExpr(ast)) {
1800 bitfield_bit_size = bit_width_apsint->getLimitedValue(
UINT32_MAX);
1809 if (record_decl ==
nullptr)
1812 if (!record_decl->field_empty())
1816 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1817 if (cxx_record_decl) {
1818 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1819 for (base_class = cxx_record_decl->bases_begin(),
1820 base_class_end = cxx_record_decl->bases_end();
1821 base_class != base_class_end; ++base_class) {
1822 assert(record_decl != base_class->getType()->getAsCXXRecordDecl() &&
1823 "Base can't inherit from itself.");
1835 if (std::optional<ClangASTMetadata> meta_data =
GetMetadata(record_decl);
1836 meta_data && meta_data->IsForcefullyCompleted())
1842#pragma mark Objective-C Classes
1845 llvm::StringRef name, clang::DeclContext *decl_ctx,
1847 std::optional<ClangASTMetadata> metadata) {
1849 assert(!name.empty());
1851 decl_ctx = ast.getTranslationUnitDecl();
1853 ObjCInterfaceDecl *decl =
1854 ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
1855 decl->setDeclContext(decl_ctx);
1856 decl->setDeclName(&ast.Idents.get(name));
1857 decl->setImplicit(isInternal);
1863 return GetType(ast.getObjCInterfaceType(decl));
1872 bool omit_empty_base_classes) {
1873 uint32_t num_bases = 0;
1874 if (cxx_record_decl) {
1875 if (omit_empty_base_classes) {
1876 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1877 for (base_class = cxx_record_decl->bases_begin(),
1878 base_class_end = cxx_record_decl->bases_end();
1879 base_class != base_class_end; ++base_class) {
1886 num_bases = cxx_record_decl->getNumBases();
1891#pragma mark Namespace Declarations
1894 const char *name, clang::DeclContext *decl_ctx,
1896 NamespaceDecl *namespace_decl =
nullptr;
1898 TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
1900 decl_ctx = translation_unit_decl;
1903 IdentifierInfo &identifier_info = ast.Idents.get(name);
1904 DeclarationName decl_name(&identifier_info);
1905 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1906 for (NamedDecl *decl : result) {
1907 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1909 return namespace_decl;
1912 namespace_decl = NamespaceDecl::Create(ast, decl_ctx, is_inline,
1913 SourceLocation(), SourceLocation(),
1914 &identifier_info,
nullptr,
false);
1916 decl_ctx->addDecl(namespace_decl);
1918 if (decl_ctx == translation_unit_decl) {
1919 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1921 return namespace_decl;
1924 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1925 SourceLocation(),
nullptr,
nullptr,
false);
1926 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1927 translation_unit_decl->addDecl(namespace_decl);
1928 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace());
1930 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1931 if (parent_namespace_decl) {
1932 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1934 return namespace_decl;
1936 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1937 SourceLocation(),
nullptr,
nullptr,
false);
1938 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1939 parent_namespace_decl->addDecl(namespace_decl);
1940 assert(namespace_decl ==
1941 parent_namespace_decl->getAnonymousNamespace());
1943 assert(
false &&
"GetUniqueNamespaceDeclaration called with no name and "
1944 "no namespace as decl_ctx");
1952 VerifyDecl(namespace_decl);
1953 return namespace_decl;
1960 clang::BlockDecl *decl =
1961 clang::BlockDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1962 decl->setDeclContext(ctx);
1971 clang::DeclContext *right,
1972 clang::DeclContext *root) {
1973 if (root ==
nullptr)
1976 std::set<clang::DeclContext *> path_left;
1977 for (clang::DeclContext *d = left; d !=
nullptr; d = d->getParent())
1978 path_left.insert(d);
1980 for (clang::DeclContext *d = right; d !=
nullptr; d = d->getParent())
1981 if (path_left.find(d) != path_left.end())
1989 clang::NamespaceDecl *ns_decl) {
1990 if (decl_ctx && ns_decl) {
1991 auto *translation_unit =
getASTContext().getTranslationUnitDecl();
1992 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
1994 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
1995 clang::SourceLocation(), ns_decl,
1998 decl_ctx->addDecl(using_decl);
2008 clang::NamedDecl *target) {
2009 if (current_decl_ctx && target) {
2010 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
2012 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(),
false);
2014 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
2016 target->getDeclName(), using_decl, target);
2018 using_decl->addShadowDecl(shadow_decl);
2019 current_decl_ctx->addDecl(using_decl);
2027 const char *name, clang::QualType type) {
2029 clang::VarDecl *var_decl =
2030 clang::VarDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
2031 var_decl->setDeclContext(decl_context);
2032 if (name && name[0])
2033 var_decl->setDeclName(&
getASTContext().Idents.getOwn(name));
2034 var_decl->setType(type);
2036 var_decl->setAccess(clang::AS_public);
2037 decl_context->addDecl(var_decl);
2046 switch (basic_type) {
2048 return ast->VoidTy.getAsOpaquePtr();
2050 return ast->CharTy.getAsOpaquePtr();
2052 return ast->SignedCharTy.getAsOpaquePtr();
2054 return ast->UnsignedCharTy.getAsOpaquePtr();
2056 return ast->getWCharType().getAsOpaquePtr();
2058 return ast->getSignedWCharType().getAsOpaquePtr();
2060 return ast->getUnsignedWCharType().getAsOpaquePtr();
2062 return ast->Char8Ty.getAsOpaquePtr();
2064 return ast->Char16Ty.getAsOpaquePtr();
2066 return ast->Char32Ty.getAsOpaquePtr();
2068 return ast->ShortTy.getAsOpaquePtr();
2070 return ast->UnsignedShortTy.getAsOpaquePtr();
2072 return ast->IntTy.getAsOpaquePtr();
2074 return ast->UnsignedIntTy.getAsOpaquePtr();
2076 return ast->LongTy.getAsOpaquePtr();
2078 return ast->UnsignedLongTy.getAsOpaquePtr();
2080 return ast->LongLongTy.getAsOpaquePtr();
2082 return ast->UnsignedLongLongTy.getAsOpaquePtr();
2084 return ast->Int128Ty.getAsOpaquePtr();
2086 return ast->UnsignedInt128Ty.getAsOpaquePtr();
2088 return ast->BoolTy.getAsOpaquePtr();
2090 return ast->HalfTy.getAsOpaquePtr();
2092 return ast->FloatTy.getAsOpaquePtr();
2094 return ast->DoubleTy.getAsOpaquePtr();
2096 return ast->LongDoubleTy.getAsOpaquePtr();
2098 return ast->Float128Ty.getAsOpaquePtr();
2100 return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
2102 return ast->getComplexType(ast->DoubleTy).getAsOpaquePtr();
2104 return ast->getComplexType(ast->LongDoubleTy).getAsOpaquePtr();
2106 return ast->getObjCIdType().getAsOpaquePtr();
2108 return ast->getObjCClassType().getAsOpaquePtr();
2110 return ast->getObjCSelType().getAsOpaquePtr();
2112 return ast->NullPtrTy.getAsOpaquePtr();
2118#pragma mark Function Types
2120clang::DeclarationName
2123 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2124 if (!
IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2133 const clang::FunctionProtoType *function_type =
2134 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2135 if (function_type ==
nullptr)
2136 return clang::DeclarationName();
2138 const bool is_method =
false;
2139 const unsigned int num_params = function_type->getNumParams();
2141 is_method, op_kind, num_params))
2142 return clang::DeclarationName();
2144 return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
2148 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
2149 printing_policy.SuppressTagKeyword =
true;
2152 printing_policy.SuppressInlineNamespace =
2153 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None);
2154 printing_policy.SuppressUnwrittenScope =
false;
2166 printing_policy.SuppressDefaultTemplateArgs =
false;
2167 return printing_policy;
2174 llvm::raw_string_ostream os(result);
2175 named_decl->getNameForDiagnostic(os, printing_policy, qualified);
2181 llvm::StringRef name,
const CompilerType &function_clang_type,
2182 clang::StorageClass storage,
bool is_inline, llvm::StringRef asm_label) {
2183 FunctionDecl *func_decl =
nullptr;
2186 decl_ctx = ast.getTranslationUnitDecl();
2188 const bool hasWrittenPrototype =
true;
2189 const bool isConstexprSpecified =
false;
2191 clang::DeclarationName declarationName =
2193 func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
2194 func_decl->setDeclContext(decl_ctx);
2195 func_decl->setDeclName(declarationName);
2197 func_decl->setStorageClass(storage);
2198 func_decl->setInlineSpecified(is_inline);
2199 func_decl->setHasWrittenPrototype(hasWrittenPrototype);
2200 func_decl->setConstexprKind(isConstexprSpecified
2201 ? ConstexprSpecKind::Constexpr
2202 : ConstexprSpecKind::Unspecified);
2214 if (!asm_label.empty())
2215 func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label));
2218 decl_ctx->addDecl(func_decl);
2220 VerifyDecl(func_decl);
2226 const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
2227 bool is_variadic,
unsigned type_quals, clang::CallingConv cc,
2228 clang::RefQualifierKind ref_qual) {
2232 std::vector<QualType> qual_type_args;
2234 for (
const auto &arg : args) {
2249 FunctionProtoType::ExtProtoInfo proto_info;
2250 proto_info.ExtInfo = cc;
2251 proto_info.Variadic = is_variadic;
2252 proto_info.ExceptionSpec = EST_None;
2253 proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
2254 proto_info.RefQualifier = ref_qual;
2262 const char *name,
const CompilerType ¶m_type,
int storage,
2265 auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
2266 decl->setDeclContext(decl_ctx);
2267 if (name && name[0])
2268 decl->setDeclName(&ast.Idents.get(name));
2270 decl->setStorageClass(
static_cast<clang::StorageClass
>(storage));
2273 decl_ctx->addDecl(decl);
2280 QualType block_type =
m_ast_up->getBlockPointerType(
2286#pragma mark Array Types
2290 std::optional<size_t> element_count,
2303 clang::ArraySizeModifier::Normal, 0));
2309 llvm::APInt ap_element_count(64, *element_count);
2311 ap_element_count,
nullptr,
2312 clang::ArraySizeModifier::Normal, 0));
2316 llvm::StringRef type_name,
2317 const std::initializer_list<std::pair<const char *, CompilerType>>
2324 lldbassert(0 &&
"Trying to create a type for an existing name");
2332 for (
const auto &field : type_fields)
2342 llvm::StringRef type_name,
2343 const std::initializer_list<std::pair<const char *, CompilerType>>
2355#pragma mark Enumeration Types
2358 llvm::StringRef name, clang::DeclContext *decl_ctx,
2360 const CompilerType &integer_clang_type,
bool is_scoped,
2361 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind) {
2368 EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
2369 enum_decl->setDeclContext(decl_ctx);
2371 enum_decl->setDeclName(&ast.Idents.get(name));
2372 enum_decl->setScoped(is_scoped);
2373 enum_decl->setScopedUsingClassTag(is_scoped);
2374 enum_decl->setFixed(
false);
2377 decl_ctx->addDecl(enum_decl);
2381 clang::EnumExtensibilityAttr::CreateImplicit(ast, *enum_kind));
2386 enum_decl->setAccess(AS_public);
2388 return GetType(ast.getCanonicalTagType(enum_decl));
2399 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
2400 return GetType(ast.SignedCharTy);
2402 if (bit_size == ast.getTypeSize(ast.ShortTy))
2405 if (bit_size == ast.getTypeSize(ast.IntTy))
2408 if (bit_size == ast.getTypeSize(ast.LongTy))
2411 if (bit_size == ast.getTypeSize(ast.LongLongTy))
2412 return GetType(ast.LongLongTy);
2414 if (bit_size == ast.getTypeSize(ast.Int128Ty))
2417 if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
2418 return GetType(ast.UnsignedCharTy);
2420 if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
2421 return GetType(ast.UnsignedShortTy);
2423 if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
2424 return GetType(ast.UnsignedIntTy);
2426 if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
2427 return GetType(ast.UnsignedLongTy);
2429 if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
2430 return GetType(ast.UnsignedLongLongTy);
2432 if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
2433 return GetType(ast.UnsignedInt128Ty);
2450 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2452 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2453 named_decl->getDeclName().getAsString().c_str());
2455 printf(
"%20s\n", decl_ctx->getDeclKindName());
2461 if (decl ==
nullptr)
2465 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2467 bool is_injected_class_name =
2468 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2469 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2470 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2471 record_decl->getDeclName().getAsString().c_str(),
2472 is_injected_class_name ?
" (injected class name)" :
"");
2475 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2477 printf(
"%20s: %s\n", decl->getDeclKindName(),
2478 named_decl->getDeclName().getAsString().c_str());
2480 printf(
"%20s\n", decl->getDeclKindName());
2486 clang::Decl *decl) {
2490 ExternalASTSource *ast_source = ast->getExternalSource();
2495 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2496 if (tag_decl->isCompleteDefinition())
2499 if (!tag_decl->hasExternalLexicalStorage())
2502 ast_source->CompleteType(tag_decl);
2504 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2505 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2506 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2507 if (objc_interface_decl->getDefinition())
2510 if (!objc_interface_decl->hasExternalLexicalStorage())
2513 ast_source->CompleteType(objc_interface_decl);
2515 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2545std::optional<ClangASTMetadata>
2551 return std::nullopt;
2554std::optional<ClangASTMetadata>
2560 return std::nullopt;
2564 clang::AccessSpecifier access) {
2565 if (access == clang::AccessSpecifier::AS_none)
2571clang::AccessSpecifier
2576 return clang::AccessSpecifier::AS_none;
2598 if (find(mask, type->getTypeClass()) != mask.end())
2600 switch (type->getTypeClass()) {
2603 case clang::Type::Atomic:
2604 type = cast<clang::AtomicType>(type)->getValueType();
2606 case clang::Type::Auto:
2607 case clang::Type::Decltype:
2608 case clang::Type::Paren:
2609 case clang::Type::SubstTemplateTypeParm:
2610 case clang::Type::TemplateSpecialization:
2611 case clang::Type::Typedef:
2612 case clang::Type::TypeOf:
2613 case clang::Type::TypeOfExpr:
2614 case clang::Type::Using:
2615 case clang::Type::PredefinedSugar:
2616 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2630 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2631 switch (type_class) {
2632 case clang::Type::ObjCInterface:
2633 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2635 case clang::Type::ObjCObjectPointer:
2637 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2638 ->getPointeeType());
2639 case clang::Type::Enum:
2640 case clang::Type::Record:
2641 return llvm::cast<clang::TagType>(qual_type)
2643 ->getDefinitionOrSelf();
2656 clang::QualType qual_type,
2657 bool allow_completion) {
2658 assert(qual_type->isRecordType());
2660 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2662 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2666 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2669 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2670 const bool fields_loaded =
2671 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2674 if (is_complete && fields_loaded)
2677 if (!allow_completion)
2685 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2686 if (external_ast_source) {
2687 external_ast_source->CompleteType(cxx_record_decl);
2688 if (cxx_record_decl->isCompleteDefinition()) {
2689 cxx_record_decl->field_begin();
2690 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
2702 clang::QualType qual_type,
2703 bool allow_completion) {
2704 assert(qual_type->isEnumeralType());
2707 const clang::EnumType *enum_type =
2708 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2710 auto *tag_decl = enum_type->getAsTagDecl();
2714 if (tag_decl->getDefinition())
2717 if (!allow_completion)
2721 if (!tag_decl->hasExternalLexicalStorage())
2725 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2726 if (!external_ast_source)
2729 external_ast_source->CompleteType(tag_decl);
2737static const clang::ObjCObjectType *
2739 bool allow_completion) {
2740 assert(qual_type->isObjCObjectType());
2743 const clang::ObjCObjectType *objc_class_type =
2744 llvm::cast<clang::ObjCObjectType>(qual_type);
2746 clang::ObjCInterfaceDecl *class_interface_decl =
2747 objc_class_type->getInterface();
2750 if (!class_interface_decl)
2751 return objc_class_type;
2754 if (class_interface_decl->getDefinition())
2755 return objc_class_type;
2757 if (!allow_completion)
2761 if (!class_interface_decl->hasExternalLexicalStorage())
2765 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2766 if (!external_ast_source)
2769 external_ast_source->CompleteType(class_interface_decl);
2770 return objc_class_type;
2774 clang::QualType qual_type,
2775 bool allow_completion =
true) {
2777 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2778 switch (type_class) {
2779 case clang::Type::ConstantArray:
2780 case clang::Type::IncompleteArray:
2781 case clang::Type::VariableArray: {
2782 const clang::ArrayType *array_type =
2783 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2789 case clang::Type::Record: {
2790 if (
const auto *RT =
2792 return !RT->isIncompleteType();
2797 case clang::Type::Enum: {
2799 return !ET->isIncompleteType();
2803 case clang::Type::ObjCObject:
2804 case clang::Type::ObjCInterface: {
2805 if (
const auto *OT =
2807 return !OT->isIncompleteType();
2812 case clang::Type::Attributed:
2814 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType(),
2817 case clang::Type::MemberPointer:
2820 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2821 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2822 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2826 return !qual_type.getTypePtr()->isIncompleteType();
2837static clang::ObjCIvarDecl::AccessControl
2841 return clang::ObjCIvarDecl::None;
2843 return clang::ObjCIvarDecl::Public;
2845 return clang::ObjCIvarDecl::Private;
2847 return clang::ObjCIvarDecl::Protected;
2849 return clang::ObjCIvarDecl::Package;
2851 return clang::ObjCIvarDecl::None;
2858 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2865 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2866 switch (type_class) {
2867 case clang::Type::IncompleteArray:
2868 case clang::Type::VariableArray:
2869 case clang::Type::ConstantArray:
2870 case clang::Type::ExtVector:
2871 case clang::Type::Vector:
2872 case clang::Type::Record:
2873 case clang::Type::ObjCObject:
2874 case clang::Type::ObjCInterface:
2886 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2887 switch (type_class) {
2888 case clang::Type::Record: {
2889 if (
const clang::RecordType *record_type =
2890 llvm::dyn_cast_or_null<clang::RecordType>(
2891 qual_type.getTypePtrOrNull())) {
2892 if (
const clang::RecordDecl *record_decl = record_type->getDecl()) {
2893 return record_decl->isAnonymousStructOrUnion();
2907 uint64_t *size,
bool *is_incomplete) {
2910 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2911 switch (type_class) {
2915 case clang::Type::ConstantArray:
2916 if (element_type_ptr)
2918 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2922 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2924 .getLimitedValue(ULLONG_MAX);
2926 *is_incomplete =
false;
2929 case clang::Type::IncompleteArray:
2930 if (element_type_ptr)
2932 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2938 *is_incomplete =
true;
2941 case clang::Type::VariableArray:
2942 if (element_type_ptr)
2944 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2950 *is_incomplete =
false;
2953 case clang::Type::DependentSizedArray:
2954 if (element_type_ptr)
2957 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2963 *is_incomplete =
false;
2966 if (element_type_ptr)
2967 element_type_ptr->
Clear();
2971 *is_incomplete =
false;
2979 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2980 switch (type_class) {
2981 case clang::Type::Vector: {
2982 const clang::VectorType *vector_type =
2983 qual_type->getAs<clang::VectorType>();
2986 *size = vector_type->getNumElements();
2988 *element_type =
GetType(vector_type->getElementType());
2992 case clang::Type::ExtVector: {
2993 const clang::ExtVectorType *ext_vector_type =
2994 qual_type->getAs<clang::ExtVectorType>();
2995 if (ext_vector_type) {
2997 *size = ext_vector_type->getNumElements();
3001 ext_vector_type->getElementType().getAsOpaquePtr());
3017 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
3020 clang::ObjCInterfaceDecl *result_iface_decl =
3021 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
3023 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
3027 return (ast_metadata->GetISAPtr() != 0);
3031 return GetQualType(type).getUnqualifiedType()->isCharType();
3040 const bool allow_completion =
true;
3055 if (!pointee_or_element_clang_type.
IsValid())
3058 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
3059 if (pointee_or_element_clang_type.
IsCharType()) {
3060 if (type_flags.
Test(eTypeIsArray)) {
3063 length = llvm::cast<clang::ConstantArrayType>(
3077 if (
auto pointer_auth = qual_type.getPointerAuth())
3078 return pointer_auth.getKey();
3087 if (
auto pointer_auth = qual_type.getPointerAuth())
3088 return pointer_auth.getExtraDiscriminator();
3097 if (
auto pointer_auth = qual_type.getPointerAuth())
3098 return pointer_auth.isAddressDiscriminated();
3104 auto isFunctionType = [&](clang::QualType qual_type) {
3105 return qual_type->isFunctionType();
3119 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3120 switch (type_class) {
3121 case clang::Type::Record:
3123 const clang::CXXRecordDecl *cxx_record_decl =
3124 qual_type->getAsCXXRecordDecl();
3125 if (cxx_record_decl) {
3126 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3129 const clang::RecordType *record_type =
3130 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3132 if (
const clang::RecordDecl *record_decl =
3133 record_type->getDecl()->getDefinition()) {
3136 clang::RecordDecl::field_iterator field_pos,
3137 field_end = record_decl->field_end();
3138 uint32_t num_fields = 0;
3139 bool is_hva =
false;
3140 bool is_hfa =
false;
3141 clang::QualType base_qual_type;
3142 uint64_t base_bitwidth = 0;
3143 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3145 clang::QualType field_qual_type = field_pos->getType();
3146 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3147 if (field_qual_type->isFloatingType()) {
3148 if (field_qual_type->isComplexType())
3151 if (num_fields == 0)
3152 base_qual_type = field_qual_type;
3157 if (field_qual_type.getTypePtr() !=
3158 base_qual_type.getTypePtr())
3162 }
else if (field_qual_type->isVectorType() ||
3163 field_qual_type->isExtVectorType()) {
3164 if (num_fields == 0) {
3165 base_qual_type = field_qual_type;
3166 base_bitwidth = field_bitwidth;
3171 if (base_bitwidth != field_bitwidth)
3173 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3182 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3199 const clang::FunctionProtoType *func =
3200 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3202 return func->getNumParams();
3209 const size_t index) {
3212 const clang::FunctionProtoType *func =
3213 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3215 if (index < func->getNumParams())
3216 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3224 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3228 if (predicate(qual_type))
3231 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3232 switch (type_class) {
3236 case clang::Type::LValueReference:
3237 case clang::Type::RValueReference: {
3238 const clang::ReferenceType *reference_type =
3239 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3241 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3250 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3251 return qual_type->isMemberFunctionPointerType();
3254 return IsTypeImpl(type, isMemberFunctionPointerType);
3258 auto isFunctionPointerType = [](clang::QualType qual_type) {
3259 return qual_type->isFunctionPointerType();
3262 return IsTypeImpl(type, isFunctionPointerType);
3268 auto isBlockPointerType = [&](clang::QualType qual_type) {
3269 if (qual_type->isBlockPointerType()) {
3270 if (function_pointer_type_ptr) {
3271 const clang::BlockPointerType *block_pointer_type =
3272 qual_type->castAs<clang::BlockPointerType>();
3273 QualType pointee_type = block_pointer_type->getPointeeType();
3274 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3276 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3293 const clang::BuiltinType *builtin_type =
3294 llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3297 if (builtin_type->isInteger()) {
3298 is_signed = builtin_type->isSignedInteger();
3309 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3314 ->getDefinitionOrSelf()
3328 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3332 return enum_type->isScopedEnumeralType();
3343 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3344 switch (type_class) {
3345 case clang::Type::Builtin:
3346 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3349 case clang::BuiltinType::ObjCId:
3350 case clang::BuiltinType::ObjCClass:
3354 case clang::Type::ObjCObjectPointer:
3358 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3362 case clang::Type::BlockPointer:
3365 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3369 case clang::Type::Pointer:
3372 llvm::cast<clang::PointerType>(qual_type)
3376 case clang::Type::MemberPointer:
3379 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3388 pointee_type->
Clear();
3396 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3397 switch (type_class) {
3398 case clang::Type::Builtin:
3399 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3402 case clang::BuiltinType::ObjCId:
3403 case clang::BuiltinType::ObjCClass:
3407 case clang::Type::ObjCObjectPointer:
3411 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3415 case clang::Type::BlockPointer:
3418 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3422 case clang::Type::Pointer:
3425 llvm::cast<clang::PointerType>(qual_type)
3429 case clang::Type::MemberPointer:
3432 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3436 case clang::Type::LValueReference:
3439 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3443 case clang::Type::RValueReference:
3446 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3455 pointee_type->
Clear();
3464 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3466 switch (type_class) {
3467 case clang::Type::LValueReference:
3470 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3476 case clang::Type::RValueReference:
3479 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3491 pointee_type->
Clear();
3500 if (
const clang::BuiltinType *BT = llvm::dyn_cast<clang::BuiltinType>(
3501 qual_type->getCanonicalTypeInternal())) {
3502 clang::BuiltinType::Kind kind = BT->getKind();
3503 if (kind >= clang::BuiltinType::Float &&
3504 kind <= clang::BuiltinType::LongDouble) {
3508 }
else if (
const clang::ComplexType *CT =
3509 llvm::dyn_cast<clang::ComplexType>(
3510 qual_type->getCanonicalTypeInternal())) {
3516 }
else if (
const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(
3517 qual_type->getCanonicalTypeInternal())) {
3534 const clang::TagType *tag_type =
3535 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3537 if (clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinition())
3538 return tag_decl->isCompleteDefinition();
3541 const clang::ObjCObjectType *objc_class_type =
3542 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3543 if (objc_class_type) {
3544 clang::ObjCInterfaceDecl *class_interface_decl =
3545 objc_class_type->getInterface();
3546 if (class_interface_decl)
3547 return class_interface_decl->getDefinition() !=
nullptr;
3558 const clang::ObjCObjectPointerType *obj_pointer_type =
3559 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3561 if (obj_pointer_type)
3562 return obj_pointer_type->isObjCClassType();
3577 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3578 return (type_class == clang::Type::Record);
3585 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3586 return (type_class == clang::Type::Enum);
3592 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3593 switch (type_class) {
3594 case clang::Type::Record:
3596 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3603 return cxx_record_decl->isDynamicClass();
3617 bool check_cplusplus,
3619 if (dynamic_pointee_type)
3620 dynamic_pointee_type->
Clear();
3624 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3625 if (dynamic_pointee_type)
3627 type.getAsOpaquePtr());
3630 clang::QualType pointee_qual_type;
3632 switch (qual_type->getTypeClass()) {
3633 case clang::Type::Builtin:
3634 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3635 clang::BuiltinType::ObjCId) {
3636 set_dynamic_pointee_type(qual_type);
3641 case clang::Type::ObjCObjectPointer:
3644 if (
const auto *objc_pointee_type =
3645 qual_type->getPointeeType().getTypePtrOrNull()) {
3646 if (
const auto *objc_object_type =
3647 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3648 objc_pointee_type)) {
3649 if (objc_object_type->isObjCClass())
3653 set_dynamic_pointee_type(
3654 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3657 case clang::Type::Pointer:
3659 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3662 case clang::Type::LValueReference:
3663 case clang::Type::RValueReference:
3665 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3675 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3676 case clang::Type::Builtin:
3677 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3678 case clang::BuiltinType::UnknownAny:
3679 case clang::BuiltinType::Void:
3680 set_dynamic_pointee_type(pointee_qual_type);
3686 case clang::Type::Record: {
3687 if (!check_cplusplus)
3689 clang::CXXRecordDecl *cxx_record_decl =
3690 pointee_qual_type->getAsCXXRecordDecl();
3691 if (!cxx_record_decl)
3695 if (cxx_record_decl->isCompleteDefinition())
3696 success = cxx_record_decl->isDynamicClass();
3698 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3699 std::optional<bool> is_dynamic =
3700 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3702 success = *is_dynamic;
3704 success = cxx_record_decl->isDynamicClass();
3710 set_dynamic_pointee_type(pointee_qual_type);
3714 case clang::Type::ObjCObject:
3715 case clang::Type::ObjCInterface:
3717 set_dynamic_pointee_type(pointee_qual_type);
3732 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3739 ->getTypeClass() == clang::Type::Typedef;
3749 if (
auto *record_decl =
3751 return record_decl->canPassInRegisters();
3757 return TypeSystemClangSupportsLanguage(language);
3760std::optional<std::string>
3763 return std::nullopt;
3766 if (qual_type.isNull())
3767 return std::nullopt;
3769 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3770 if (!cxx_record_decl)
3771 return std::nullopt;
3773 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3781 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3788 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3790 return tag_type->getDecl()->isEntityBeingDefined();
3801 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3802 if (class_type_ptr) {
3803 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3804 const clang::ObjCObjectPointerType *obj_pointer_type =
3805 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3806 if (obj_pointer_type ==
nullptr)
3807 class_type_ptr->
Clear();
3811 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3818 class_type_ptr->
Clear();
3827 const bool allow_completion =
true;
3847 {clang::Type::Typedef, clang::Type::Atomic});
3850 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3851 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3858 if (
auto *named_decl = qual_type->getAsTagDecl())
3870 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3871 printing_policy.SuppressTagKeyword =
true;
3872 printing_policy.SuppressScope =
false;
3873 printing_policy.SuppressUnwrittenScope =
true;
3874 printing_policy.SuppressInlineNamespace =
3875 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::All);
3876 return ConstString(qual_type.getAsString(printing_policy));
3885 if (pointee_or_element_clang_type)
3886 pointee_or_element_clang_type->
Clear();
3888 clang::QualType qual_type =
3891 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3892 switch (type_class) {
3893 case clang::Type::Attributed:
3894 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3897 pointee_or_element_clang_type);
3898 case clang::Type::BitInt: {
3899 uint32_t type_flags = eTypeIsScalar | eTypeIsInteger | eTypeHasValue;
3900 if (qual_type->isSignedIntegerType())
3901 type_flags |= eTypeIsSigned;
3905 case clang::Type::Builtin: {
3906 const clang::BuiltinType *builtin_type =
3907 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3909 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3910 switch (builtin_type->getKind()) {
3911 case clang::BuiltinType::ObjCId:
3912 case clang::BuiltinType::ObjCClass:
3913 if (pointee_or_element_clang_type)
3917 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3920 case clang::BuiltinType::ObjCSel:
3921 if (pointee_or_element_clang_type)
3924 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3927 case clang::BuiltinType::Bool:
3928 case clang::BuiltinType::Char_U:
3929 case clang::BuiltinType::UChar:
3930 case clang::BuiltinType::WChar_U:
3931 case clang::BuiltinType::Char16:
3932 case clang::BuiltinType::Char32:
3933 case clang::BuiltinType::UShort:
3934 case clang::BuiltinType::UInt:
3935 case clang::BuiltinType::ULong:
3936 case clang::BuiltinType::ULongLong:
3937 case clang::BuiltinType::UInt128:
3938 case clang::BuiltinType::Char_S:
3939 case clang::BuiltinType::SChar:
3940 case clang::BuiltinType::WChar_S:
3941 case clang::BuiltinType::Short:
3942 case clang::BuiltinType::Int:
3943 case clang::BuiltinType::Long:
3944 case clang::BuiltinType::LongLong:
3945 case clang::BuiltinType::Int128:
3946 case clang::BuiltinType::Float:
3947 case clang::BuiltinType::Double:
3948 case clang::BuiltinType::LongDouble:
3949 builtin_type_flags |= eTypeIsScalar;
3950 if (builtin_type->isInteger()) {
3951 builtin_type_flags |= eTypeIsInteger;
3952 if (builtin_type->isSignedInteger())
3953 builtin_type_flags |= eTypeIsSigned;
3954 }
else if (builtin_type->isFloatingPoint())
3955 builtin_type_flags |= eTypeIsFloat;
3960 return builtin_type_flags;
3963 case clang::Type::BlockPointer:
3964 if (pointee_or_element_clang_type)
3966 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3967 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3969 case clang::Type::Complex: {
3970 uint32_t complex_type_flags =
3971 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3972 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3973 qual_type->getCanonicalTypeInternal());
3975 clang::QualType complex_element_type(complex_type->getElementType());
3976 if (complex_element_type->isIntegerType())
3977 complex_type_flags |= eTypeIsInteger;
3978 else if (complex_element_type->isFloatingType())
3979 complex_type_flags |= eTypeIsFloat;
3981 return complex_type_flags;
3984 case clang::Type::ConstantArray:
3985 case clang::Type::DependentSizedArray:
3986 case clang::Type::IncompleteArray:
3987 case clang::Type::VariableArray:
3988 if (pointee_or_element_clang_type)
3990 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
3993 return eTypeHasChildren | eTypeIsArray;
3995 case clang::Type::DependentName:
3997 case clang::Type::DependentSizedExtVector:
3998 return eTypeHasChildren | eTypeIsVector;
4000 case clang::Type::Enum:
4001 if (pointee_or_element_clang_type)
4003 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
4005 ->getDefinitionOrSelf()
4008 return eTypeIsEnumeration | eTypeHasValue;
4010 case clang::Type::FunctionProto:
4011 return eTypeIsFuncPrototype | eTypeHasValue;
4012 case clang::Type::FunctionNoProto:
4013 return eTypeIsFuncPrototype | eTypeHasValue;
4014 case clang::Type::InjectedClassName:
4017 case clang::Type::LValueReference:
4018 case clang::Type::RValueReference:
4019 if (pointee_or_element_clang_type)
4022 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
4025 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
4027 case clang::Type::MemberPointer:
4028 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
4030 case clang::Type::ObjCObjectPointer:
4031 if (pointee_or_element_clang_type)
4033 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4034 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
4037 case clang::Type::ObjCObject:
4038 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4039 case clang::Type::ObjCInterface:
4040 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4042 case clang::Type::Pointer:
4043 if (pointee_or_element_clang_type)
4045 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4046 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
4048 case clang::Type::Record:
4049 if (qual_type->getAsCXXRecordDecl())
4050 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
4052 return eTypeHasChildren | eTypeIsStructUnion;
4054 case clang::Type::SubstTemplateTypeParm:
4055 return eTypeIsTemplate;
4056 case clang::Type::TemplateTypeParm:
4057 return eTypeIsTemplate;
4058 case clang::Type::TemplateSpecialization:
4059 return eTypeIsTemplate;
4061 case clang::Type::Typedef:
4062 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
4064 ->getUnderlyingType())
4066 case clang::Type::UnresolvedUsing:
4069 case clang::Type::ExtVector:
4070 case clang::Type::Vector: {
4071 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
4072 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
4073 qual_type->getCanonicalTypeInternal());
4077 QualType element_type = vector_type->getElementType();
4078 if (element_type.isNull())
4081 if (element_type->isIntegerType())
4082 vector_type_flags |= eTypeIsInteger;
4083 else if (element_type->isFloatingType())
4084 vector_type_flags |= eTypeIsFloat;
4085 return vector_type_flags;
4100 if (qual_type->isAnyPointerType()) {
4101 if (qual_type->isObjCObjectPointerType())
4103 if (qual_type->getPointeeCXXRecordDecl())
4106 clang::QualType pointee_type(qual_type->getPointeeType());
4107 if (pointee_type->getPointeeCXXRecordDecl())
4109 if (pointee_type->isObjCObjectOrInterfaceType())
4111 if (pointee_type->isObjCClassType())
4113 if (pointee_type.getTypePtr() ==
4117 if (qual_type->isObjCObjectOrInterfaceType())
4119 if (qual_type->getAsCXXRecordDecl())
4121 switch (qual_type->getTypeClass()) {
4124 case clang::Type::Builtin:
4125 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4127 case clang::BuiltinType::Void:
4128 case clang::BuiltinType::Bool:
4129 case clang::BuiltinType::Char_U:
4130 case clang::BuiltinType::UChar:
4131 case clang::BuiltinType::WChar_U:
4132 case clang::BuiltinType::Char16:
4133 case clang::BuiltinType::Char32:
4134 case clang::BuiltinType::UShort:
4135 case clang::BuiltinType::UInt:
4136 case clang::BuiltinType::ULong:
4137 case clang::BuiltinType::ULongLong:
4138 case clang::BuiltinType::UInt128:
4139 case clang::BuiltinType::Char_S:
4140 case clang::BuiltinType::SChar:
4141 case clang::BuiltinType::WChar_S:
4142 case clang::BuiltinType::Short:
4143 case clang::BuiltinType::Int:
4144 case clang::BuiltinType::Long:
4145 case clang::BuiltinType::LongLong:
4146 case clang::BuiltinType::Int128:
4147 case clang::BuiltinType::Float:
4148 case clang::BuiltinType::Double:
4149 case clang::BuiltinType::LongDouble:
4152 case clang::BuiltinType::NullPtr:
4155 case clang::BuiltinType::ObjCId:
4156 case clang::BuiltinType::ObjCClass:
4157 case clang::BuiltinType::ObjCSel:
4160 case clang::BuiltinType::Dependent:
4161 case clang::BuiltinType::Overload:
4162 case clang::BuiltinType::BoundMember:
4163 case clang::BuiltinType::UnknownAny:
4167 case clang::Type::Typedef:
4168 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4170 ->getUnderlyingType())
4180 return lldb::eTypeClassInvalid;
4182 clang::QualType qual_type =
4185 switch (qual_type->getTypeClass()) {
4186 case clang::Type::Atomic:
4187 case clang::Type::Auto:
4188 case clang::Type::CountAttributed:
4189 case clang::Type::Decltype:
4190 case clang::Type::Paren:
4191 case clang::Type::TypeOf:
4192 case clang::Type::TypeOfExpr:
4193 case clang::Type::Using:
4194 case clang::Type::PredefinedSugar:
4195 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4196 case clang::Type::UnaryTransform:
4198 case clang::Type::FunctionNoProto:
4199 return lldb::eTypeClassFunction;
4200 case clang::Type::FunctionProto:
4201 return lldb::eTypeClassFunction;
4202 case clang::Type::IncompleteArray:
4203 return lldb::eTypeClassArray;
4204 case clang::Type::VariableArray:
4205 return lldb::eTypeClassArray;
4206 case clang::Type::ConstantArray:
4207 return lldb::eTypeClassArray;
4208 case clang::Type::DependentSizedArray:
4209 return lldb::eTypeClassArray;
4210 case clang::Type::ArrayParameter:
4211 return lldb::eTypeClassArray;
4212 case clang::Type::DependentSizedExtVector:
4213 return lldb::eTypeClassVector;
4214 case clang::Type::DependentVector:
4215 return lldb::eTypeClassVector;
4216 case clang::Type::ExtVector:
4217 return lldb::eTypeClassVector;
4218 case clang::Type::Vector:
4219 return lldb::eTypeClassVector;
4220 case clang::Type::Builtin:
4222 case clang::Type::BitInt:
4223 case clang::Type::DependentBitInt:
4224 return lldb::eTypeClassBuiltin;
4225 case clang::Type::ObjCObjectPointer:
4226 return lldb::eTypeClassObjCObjectPointer;
4227 case clang::Type::BlockPointer:
4228 return lldb::eTypeClassBlockPointer;
4229 case clang::Type::Pointer:
4230 return lldb::eTypeClassPointer;
4231 case clang::Type::LValueReference:
4232 return lldb::eTypeClassReference;
4233 case clang::Type::RValueReference:
4234 return lldb::eTypeClassReference;
4235 case clang::Type::MemberPointer:
4236 return lldb::eTypeClassMemberPointer;
4237 case clang::Type::Complex:
4238 if (qual_type->isComplexType())
4239 return lldb::eTypeClassComplexFloat;
4241 return lldb::eTypeClassComplexInteger;
4242 case clang::Type::ObjCObject:
4243 return lldb::eTypeClassObjCObject;
4244 case clang::Type::ObjCInterface:
4245 return lldb::eTypeClassObjCInterface;
4246 case clang::Type::Record: {
4247 const clang::RecordType *record_type =
4248 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4249 const clang::RecordDecl *record_decl = record_type->getDecl();
4250 if (record_decl->isUnion())
4251 return lldb::eTypeClassUnion;
4252 else if (record_decl->isStruct())
4253 return lldb::eTypeClassStruct;
4255 return lldb::eTypeClassClass;
4257 case clang::Type::Enum:
4258 return lldb::eTypeClassEnumeration;
4259 case clang::Type::Typedef:
4260 return lldb::eTypeClassTypedef;
4261 case clang::Type::UnresolvedUsing:
4264 case clang::Type::Attributed:
4265 case clang::Type::BTFTagAttributed:
4267 case clang::Type::TemplateTypeParm:
4269 case clang::Type::SubstTemplateTypeParm:
4271 case clang::Type::SubstTemplateTypeParmPack:
4273 case clang::Type::InjectedClassName:
4275 case clang::Type::DependentName:
4277 case clang::Type::PackExpansion:
4280 case clang::Type::TemplateSpecialization:
4282 case clang::Type::DeducedTemplateSpecialization:
4284 case clang::Type::Pipe:
4288 case clang::Type::Decayed:
4290 case clang::Type::Adjusted:
4292 case clang::Type::ObjCTypeParam:
4295 case clang::Type::DependentAddressSpace:
4297 case clang::Type::MacroQualified:
4301 case clang::Type::ConstantMatrix:
4302 case clang::Type::DependentSizedMatrix:
4306 case clang::Type::PackIndexing:
4309 case clang::Type::HLSLAttributedResource:
4311 case clang::Type::HLSLInlineSpirv:
4313 case clang::Type::SubstBuiltinTemplatePack:
4317 return lldb::eTypeClassOther;
4322 return GetQualType(type).getQualifiers().getCVRQualifiers();
4334 const clang::Type *array_eletype =
4335 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4340 return GetType(clang::QualType(array_eletype, 0));
4351 return GetType(ast_ctx.getConstantArrayType(
4352 qual_type, llvm::APInt(64, size),
nullptr,
4353 clang::ArraySizeModifier::Normal, 0));
4355 return GetType(ast_ctx.getIncompleteArrayType(
4356 qual_type, clang::ArraySizeModifier::Normal, 0));
4370 clang::QualType qual_type) {
4371 if (qual_type->isPointerType())
4372 qual_type = ast->getPointerType(
4374 else if (
const ConstantArrayType *arr =
4375 ast->getAsConstantArrayType(qual_type)) {
4376 qual_type = ast->getConstantArrayType(
4378 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4379 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4381 qual_type = qual_type.getUnqualifiedType();
4382 qual_type.removeLocalConst();
4383 qual_type.removeLocalRestrict();
4384 qual_type.removeLocalVolatile();
4406 const clang::FunctionProtoType *func =
4409 return func->getNumParams();
4417 const clang::FunctionProtoType *func =
4418 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4420 const uint32_t num_args = func->getNumParams();
4422 return GetType(func->getParamType(idx));
4432 const clang::FunctionProtoType *func =
4433 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4435 return GetType(func->getReturnType());
4442 size_t num_functions = 0;
4445 switch (qual_type->getTypeClass()) {
4446 case clang::Type::Record:
4448 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4449 num_functions = std::distance(cxx_record_decl->method_begin(),
4450 cxx_record_decl->method_end());
4453 case clang::Type::ObjCObjectPointer: {
4454 const clang::ObjCObjectPointerType *objc_class_type =
4455 qual_type->castAs<clang::ObjCObjectPointerType>();
4456 const clang::ObjCInterfaceType *objc_interface_type =
4457 objc_class_type->getInterfaceType();
4458 if (objc_interface_type &&
4460 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4461 clang::ObjCInterfaceDecl *class_interface_decl =
4462 objc_interface_type->getDecl();
4463 if (class_interface_decl) {
4464 num_functions = std::distance(class_interface_decl->meth_begin(),
4465 class_interface_decl->meth_end());
4471 case clang::Type::ObjCObject:
4472 case clang::Type::ObjCInterface:
4474 const clang::ObjCObjectType *objc_class_type =
4475 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4476 if (objc_class_type) {
4477 clang::ObjCInterfaceDecl *class_interface_decl =
4478 objc_class_type->getInterface();
4479 if (class_interface_decl)
4480 num_functions = std::distance(class_interface_decl->meth_begin(),
4481 class_interface_decl->meth_end());
4490 return num_functions;
4502 switch (qual_type->getTypeClass()) {
4503 case clang::Type::Record:
4505 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4506 auto method_iter = cxx_record_decl->method_begin();
4507 auto method_end = cxx_record_decl->method_end();
4509 static_cast<size_t>(std::distance(method_iter, method_end))) {
4510 std::advance(method_iter, idx);
4511 clang::CXXMethodDecl *cxx_method_decl =
4512 method_iter->getCanonicalDecl();
4513 if (cxx_method_decl) {
4514 name = cxx_method_decl->getDeclName().getAsString();
4515 if (cxx_method_decl->isStatic())
4517 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4519 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4523 clang_type =
GetType(cxx_method_decl->getType());
4531 case clang::Type::ObjCObjectPointer: {
4532 const clang::ObjCObjectPointerType *objc_class_type =
4533 qual_type->castAs<clang::ObjCObjectPointerType>();
4534 const clang::ObjCInterfaceType *objc_interface_type =
4535 objc_class_type->getInterfaceType();
4536 if (objc_interface_type &&
4538 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4539 clang::ObjCInterfaceDecl *class_interface_decl =
4540 objc_interface_type->getDecl();
4541 if (class_interface_decl) {
4542 auto method_iter = class_interface_decl->meth_begin();
4543 auto method_end = class_interface_decl->meth_end();
4545 static_cast<size_t>(std::distance(method_iter, method_end))) {
4546 std::advance(method_iter, idx);
4547 clang::ObjCMethodDecl *objc_method_decl =
4548 method_iter->getCanonicalDecl();
4549 if (objc_method_decl) {
4551 name = objc_method_decl->getSelector().getAsString();
4552 if (objc_method_decl->isClassMethod())
4563 case clang::Type::ObjCObject:
4564 case clang::Type::ObjCInterface:
4566 const clang::ObjCObjectType *objc_class_type =
4567 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4568 if (objc_class_type) {
4569 clang::ObjCInterfaceDecl *class_interface_decl =
4570 objc_class_type->getInterface();
4571 if (class_interface_decl) {
4572 auto method_iter = class_interface_decl->meth_begin();
4573 auto method_end = class_interface_decl->meth_end();
4575 static_cast<size_t>(std::distance(method_iter, method_end))) {
4576 std::advance(method_iter, idx);
4577 clang::ObjCMethodDecl *objc_method_decl =
4578 method_iter->getCanonicalDecl();
4579 if (objc_method_decl) {
4581 name = objc_method_decl->getSelector().getAsString();
4582 if (objc_method_decl->isClassMethod())
4615 return GetType(qual_type.getTypePtr()->getPointeeType());
4625 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4626 case clang::Type::ObjCObject:
4627 case clang::Type::ObjCInterface:
4674 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4675 clang::QualType result =
4676 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4686 result.addVolatile();
4696 result.addRestrict();
4705 if (type && typedef_name && typedef_name[0]) {
4709 clang::DeclContext *decl_ctx =
4714 clang::TypedefDecl *decl =
4715 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4716 decl->setDeclContext(decl_ctx);
4717 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4718 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4719 decl_ctx->addDecl(decl);
4722 clang::TagDecl *tdecl =
nullptr;
4723 if (!qual_type.isNull()) {
4724 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4725 tdecl = rt->getDecl();
4726 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4727 tdecl = et->getDecl();
4733 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4734 tdecl->setTypedefNameForAnonDecl(decl);
4736 decl->setAccess(clang::AS_public);
4739 NestedNameSpecifier Qualifier =
4740 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4742 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4750 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4753 return GetType(typedef_type->getDecl()->getUnderlyingType());
4766 const FunctionType::ExtInfo generic_ext_info(
4775 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4780const llvm::fltSemantics &
4783 const size_t bit_size = byte_size * 8;
4784 if (bit_size == ast.getTypeSize(ast.FloatTy))
4785 return ast.getFloatTypeSemantics(ast.FloatTy);
4786 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4787 return ast.getFloatTypeSemantics(ast.DoubleTy);
4789 bit_size == ast.getTypeSize(ast.Float128Ty))
4790 return ast.getFloatTypeSemantics(ast.Float128Ty);
4791 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4792 bit_size == llvm::APFloat::semanticsSizeInBits(
4793 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4794 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4795 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4796 return ast.getFloatTypeSemantics(ast.HalfTy);
4797 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4798 return ast.getFloatTypeSemantics(ast.Float128Ty);
4799 return llvm::APFloatBase::Bogus();
4802llvm::Expected<uint64_t>
4805 assert(qual_type->isObjCObjectOrInterfaceType());
4810 if (std::optional<uint64_t> bit_size =
4811 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4815 static bool g_printed =
false;
4820 llvm::outs() <<
"warning: trying to determine the size of type ";
4822 llvm::outs() <<
"without a valid ExecutionContext. this is not "
4823 "reliable. please file a bug against LLDB.\n";
4824 llvm::outs() <<
"backtrace:\n";
4825 llvm::sys::PrintStackTrace(llvm::outs());
4826 llvm::outs() <<
"\n";
4835llvm::Expected<uint64_t>
4838 const bool base_name_only =
true;
4840 return llvm::createStringError(
4841 "could not complete type %s",
4845 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4846 switch (type_class) {
4847 case clang::Type::ConstantArray:
4848 case clang::Type::FunctionProto:
4849 case clang::Type::Record:
4851 case clang::Type::ObjCInterface:
4852 case clang::Type::ObjCObject:
4854 case clang::Type::IncompleteArray: {
4855 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4858 qual_type->getArrayElementTypeNoTypeQual()
4859 ->getCanonicalTypeUnqualified());
4864 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4868 return llvm::createStringError(
4869 "could not get size of type %s",
4873std::optional<size_t>
4887 switch (qual_type->getTypeClass()) {
4888 case clang::Type::Atomic:
4889 case clang::Type::Auto:
4890 case clang::Type::CountAttributed:
4891 case clang::Type::Decltype:
4892 case clang::Type::Paren:
4893 case clang::Type::Typedef:
4894 case clang::Type::TypeOf:
4895 case clang::Type::TypeOfExpr:
4896 case clang::Type::Using:
4897 case clang::Type::PredefinedSugar:
4898 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4900 case clang::Type::UnaryTransform:
4903 case clang::Type::FunctionNoProto:
4904 case clang::Type::FunctionProto:
4907 case clang::Type::IncompleteArray:
4908 case clang::Type::VariableArray:
4909 case clang::Type::ArrayParameter:
4912 case clang::Type::ConstantArray:
4915 case clang::Type::DependentVector:
4916 case clang::Type::ExtVector:
4917 case clang::Type::Vector:
4920 case clang::Type::BitInt:
4921 case clang::Type::DependentBitInt:
4925 case clang::Type::Builtin:
4926 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4927 case clang::BuiltinType::Void:
4930 case clang::BuiltinType::Char_S:
4931 case clang::BuiltinType::SChar:
4932 case clang::BuiltinType::WChar_S:
4933 case clang::BuiltinType::Short:
4934 case clang::BuiltinType::Int:
4935 case clang::BuiltinType::Long:
4936 case clang::BuiltinType::LongLong:
4937 case clang::BuiltinType::Int128:
4940 case clang::BuiltinType::Bool:
4941 case clang::BuiltinType::Char_U:
4942 case clang::BuiltinType::UChar:
4943 case clang::BuiltinType::WChar_U:
4944 case clang::BuiltinType::Char8:
4945 case clang::BuiltinType::Char16:
4946 case clang::BuiltinType::Char32:
4947 case clang::BuiltinType::UShort:
4948 case clang::BuiltinType::UInt:
4949 case clang::BuiltinType::ULong:
4950 case clang::BuiltinType::ULongLong:
4951 case clang::BuiltinType::UInt128:
4955 case clang::BuiltinType::ShortAccum:
4956 case clang::BuiltinType::Accum:
4957 case clang::BuiltinType::LongAccum:
4958 case clang::BuiltinType::UShortAccum:
4959 case clang::BuiltinType::UAccum:
4960 case clang::BuiltinType::ULongAccum:
4961 case clang::BuiltinType::ShortFract:
4962 case clang::BuiltinType::Fract:
4963 case clang::BuiltinType::LongFract:
4964 case clang::BuiltinType::UShortFract:
4965 case clang::BuiltinType::UFract:
4966 case clang::BuiltinType::ULongFract:
4967 case clang::BuiltinType::SatShortAccum:
4968 case clang::BuiltinType::SatAccum:
4969 case clang::BuiltinType::SatLongAccum:
4970 case clang::BuiltinType::SatUShortAccum:
4971 case clang::BuiltinType::SatUAccum:
4972 case clang::BuiltinType::SatULongAccum:
4973 case clang::BuiltinType::SatShortFract:
4974 case clang::BuiltinType::SatFract:
4975 case clang::BuiltinType::SatLongFract:
4976 case clang::BuiltinType::SatUShortFract:
4977 case clang::BuiltinType::SatUFract:
4978 case clang::BuiltinType::SatULongFract:
4981 case clang::BuiltinType::Half:
4982 case clang::BuiltinType::Float:
4983 case clang::BuiltinType::Float16:
4984 case clang::BuiltinType::Float128:
4985 case clang::BuiltinType::Double:
4986 case clang::BuiltinType::LongDouble:
4987 case clang::BuiltinType::BFloat16:
4988 case clang::BuiltinType::Ibm128:
4991 case clang::BuiltinType::ObjCClass:
4992 case clang::BuiltinType::ObjCId:
4993 case clang::BuiltinType::ObjCSel:
4996 case clang::BuiltinType::NullPtr:
4999 case clang::BuiltinType::Kind::ARCUnbridgedCast:
5000 case clang::BuiltinType::Kind::BoundMember:
5001 case clang::BuiltinType::Kind::BuiltinFn:
5002 case clang::BuiltinType::Kind::Dependent:
5003 case clang::BuiltinType::Kind::OCLClkEvent:
5004 case clang::BuiltinType::Kind::OCLEvent:
5005 case clang::BuiltinType::Kind::OCLImage1dRO:
5006 case clang::BuiltinType::Kind::OCLImage1dWO:
5007 case clang::BuiltinType::Kind::OCLImage1dRW:
5008 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
5009 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
5010 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
5011 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
5012 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
5013 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
5014 case clang::BuiltinType::Kind::OCLImage2dRO:
5015 case clang::BuiltinType::Kind::OCLImage2dWO:
5016 case clang::BuiltinType::Kind::OCLImage2dRW:
5017 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
5018 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
5019 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
5020 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
5021 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
5022 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
5023 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
5024 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
5025 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
5026 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
5027 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
5028 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
5029 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
5030 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
5031 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
5032 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
5033 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
5034 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
5035 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
5036 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
5037 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
5038 case clang::BuiltinType::Kind::OCLImage3dRO:
5039 case clang::BuiltinType::Kind::OCLImage3dWO:
5040 case clang::BuiltinType::Kind::OCLImage3dRW:
5041 case clang::BuiltinType::Kind::OCLQueue:
5042 case clang::BuiltinType::Kind::OCLReserveID:
5043 case clang::BuiltinType::Kind::OCLSampler:
5044 case clang::BuiltinType::Kind::HLSLResource:
5045 case clang::BuiltinType::Kind::ArraySection:
5046 case clang::BuiltinType::Kind::OMPArrayShaping:
5047 case clang::BuiltinType::Kind::OMPIterator:
5048 case clang::BuiltinType::Kind::Overload:
5049 case clang::BuiltinType::Kind::PseudoObject:
5050 case clang::BuiltinType::Kind::UnknownAny:
5053 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
5054 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
5055 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
5056 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
5057 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
5058 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
5059 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
5060 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
5061 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
5062 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
5063 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
5064 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
5068 case clang::BuiltinType::VectorPair:
5069 case clang::BuiltinType::VectorQuad:
5070 case clang::BuiltinType::DMR1024:
5071 case clang::BuiltinType::DMR2048:
5075#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5076#include "clang/Basic/AArch64ACLETypes.def"
5080#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5081#include "clang/Basic/RISCVVTypes.def"
5085 case clang::BuiltinType::WasmExternRef:
5088 case clang::BuiltinType::IncompleteMatrixIdx:
5091 case clang::BuiltinType::UnresolvedTemplate:
5095#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
5096 case clang::BuiltinType::Id:
5097#include "clang/Basic/AMDGPUTypes.def"
5103 case clang::Type::ObjCObjectPointer:
5104 case clang::Type::BlockPointer:
5105 case clang::Type::Pointer:
5106 case clang::Type::LValueReference:
5107 case clang::Type::RValueReference:
5108 case clang::Type::MemberPointer:
5110 case clang::Type::Complex: {
5112 if (qual_type->isComplexType())
5115 const clang::ComplexType *complex_type =
5116 qual_type->getAsComplexIntegerType();
5125 case clang::Type::ObjCInterface:
5127 case clang::Type::Record:
5129 case clang::Type::Enum:
5130 return qual_type->isUnsignedIntegerOrEnumerationType()
5133 case clang::Type::DependentSizedArray:
5134 case clang::Type::DependentSizedExtVector:
5135 case clang::Type::UnresolvedUsing:
5136 case clang::Type::Attributed:
5137 case clang::Type::BTFTagAttributed:
5138 case clang::Type::TemplateTypeParm:
5139 case clang::Type::SubstTemplateTypeParm:
5140 case clang::Type::SubstTemplateTypeParmPack:
5141 case clang::Type::InjectedClassName:
5142 case clang::Type::DependentName:
5143 case clang::Type::PackExpansion:
5144 case clang::Type::ObjCObject:
5146 case clang::Type::TemplateSpecialization:
5147 case clang::Type::DeducedTemplateSpecialization:
5148 case clang::Type::Adjusted:
5149 case clang::Type::Pipe:
5153 case clang::Type::Decayed:
5155 case clang::Type::ObjCTypeParam:
5158 case clang::Type::DependentAddressSpace:
5160 case clang::Type::MacroQualified:
5163 case clang::Type::ConstantMatrix:
5164 case clang::Type::DependentSizedMatrix:
5168 case clang::Type::PackIndexing:
5171 case clang::Type::HLSLAttributedResource:
5173 case clang::Type::HLSLInlineSpirv:
5175 case clang::Type::SubstBuiltinTemplatePack:
5188 switch (qual_type->getTypeClass()) {
5189 case clang::Type::Atomic:
5190 case clang::Type::Auto:
5191 case clang::Type::CountAttributed:
5192 case clang::Type::Decltype:
5193 case clang::Type::Paren:
5194 case clang::Type::Typedef:
5195 case clang::Type::TypeOf:
5196 case clang::Type::TypeOfExpr:
5197 case clang::Type::Using:
5198 case clang::Type::PredefinedSugar:
5199 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5200 case clang::Type::UnaryTransform:
5203 case clang::Type::FunctionNoProto:
5204 case clang::Type::FunctionProto:
5207 case clang::Type::IncompleteArray:
5208 case clang::Type::VariableArray:
5209 case clang::Type::ArrayParameter:
5212 case clang::Type::ConstantArray:
5215 case clang::Type::DependentVector:
5216 case clang::Type::ExtVector:
5217 case clang::Type::Vector:
5220 case clang::Type::BitInt:
5221 case clang::Type::DependentBitInt:
5225 case clang::Type::Builtin:
5226 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5227 case clang::BuiltinType::UnknownAny:
5228 case clang::BuiltinType::Void:
5229 case clang::BuiltinType::BoundMember:
5232 case clang::BuiltinType::Bool:
5234 case clang::BuiltinType::Char_S:
5235 case clang::BuiltinType::SChar:
5236 case clang::BuiltinType::WChar_S:
5237 case clang::BuiltinType::Char_U:
5238 case clang::BuiltinType::UChar:
5239 case clang::BuiltinType::WChar_U:
5241 case clang::BuiltinType::Char8:
5243 case clang::BuiltinType::Char16:
5245 case clang::BuiltinType::Char32:
5247 case clang::BuiltinType::UShort:
5249 case clang::BuiltinType::Short:
5251 case clang::BuiltinType::UInt:
5253 case clang::BuiltinType::Int:
5255 case clang::BuiltinType::ULong:
5257 case clang::BuiltinType::Long:
5259 case clang::BuiltinType::ULongLong:
5261 case clang::BuiltinType::LongLong:
5263 case clang::BuiltinType::UInt128:
5265 case clang::BuiltinType::Int128:
5267 case clang::BuiltinType::Half:
5268 case clang::BuiltinType::Float:
5269 case clang::BuiltinType::Double:
5270 case clang::BuiltinType::LongDouble:
5272 case clang::BuiltinType::Float128:
5278 case clang::Type::ObjCObjectPointer:
5280 case clang::Type::BlockPointer:
5282 case clang::Type::Pointer:
5284 case clang::Type::LValueReference:
5285 case clang::Type::RValueReference:
5287 case clang::Type::MemberPointer:
5289 case clang::Type::Complex: {
5290 if (qual_type->isComplexType())
5295 case clang::Type::ObjCInterface:
5297 case clang::Type::Record:
5299 case clang::Type::Enum:
5301 case clang::Type::DependentSizedArray:
5302 case clang::Type::DependentSizedExtVector:
5303 case clang::Type::UnresolvedUsing:
5304 case clang::Type::Attributed:
5305 case clang::Type::BTFTagAttributed:
5306 case clang::Type::TemplateTypeParm:
5307 case clang::Type::SubstTemplateTypeParm:
5308 case clang::Type::SubstTemplateTypeParmPack:
5309 case clang::Type::InjectedClassName:
5310 case clang::Type::DependentName:
5311 case clang::Type::PackExpansion:
5312 case clang::Type::ObjCObject:
5314 case clang::Type::TemplateSpecialization:
5315 case clang::Type::DeducedTemplateSpecialization:
5316 case clang::Type::Adjusted:
5317 case clang::Type::Pipe:
5321 case clang::Type::Decayed:
5323 case clang::Type::ObjCTypeParam:
5326 case clang::Type::DependentAddressSpace:
5328 case clang::Type::MacroQualified:
5332 case clang::Type::ConstantMatrix:
5333 case clang::Type::DependentSizedMatrix:
5337 case clang::Type::PackIndexing:
5340 case clang::Type::HLSLAttributedResource:
5342 case clang::Type::HLSLInlineSpirv:
5344 case clang::Type::SubstBuiltinTemplatePack:
5352 while (class_interface_decl) {
5353 if (class_interface_decl->ivar_size() > 0)
5356 class_interface_decl = class_interface_decl->getSuperClass();
5361static std::optional<SymbolFile::ArrayInfo>
5363 clang::QualType qual_type,
5365 if (qual_type->isIncompleteArrayType())
5366 if (std::optional<ClangASTMetadata> metadata =
5370 return std::nullopt;
5373llvm::Expected<uint32_t>
5375 bool omit_empty_base_classes,
5378 return llvm::createStringError(
"invalid clang type");
5380 uint32_t num_children = 0;
5382 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5383 switch (type_class) {
5384 case clang::Type::Builtin:
5385 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5386 case clang::BuiltinType::ObjCId:
5387 case clang::BuiltinType::ObjCClass:
5396 case clang::Type::Complex:
5398 case clang::Type::Record:
5400 const clang::RecordType *record_type =
5401 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5402 const clang::RecordDecl *record_decl =
5403 record_type->getDecl()->getDefinitionOrSelf();
5404 const clang::CXXRecordDecl *cxx_record_decl =
5405 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5409 num_children += std::distance(record_decl->field_begin(),
5410 record_decl->field_end());
5412 return llvm::createStringError(
5415 case clang::Type::ObjCObject:
5416 case clang::Type::ObjCInterface:
5418 const clang::ObjCObjectType *objc_class_type =
5419 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5420 assert(objc_class_type);
5421 if (objc_class_type) {
5422 clang::ObjCInterfaceDecl *class_interface_decl =
5423 objc_class_type->getInterface();
5425 if (class_interface_decl) {
5427 clang::ObjCInterfaceDecl *superclass_interface_decl =
5428 class_interface_decl->getSuperClass();
5429 if (superclass_interface_decl) {
5430 if (omit_empty_base_classes) {
5437 num_children += class_interface_decl->ivar_size();
5443 case clang::Type::LValueReference:
5444 case clang::Type::RValueReference:
5445 case clang::Type::ObjCObjectPointer: {
5448 uint32_t num_pointee_children = 0;
5450 auto num_children_or_err =
5451 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5452 if (!num_children_or_err)
5453 return num_children_or_err;
5454 num_pointee_children = *num_children_or_err;
5457 if (num_pointee_children == 0)
5460 num_children = num_pointee_children;
5463 case clang::Type::Vector:
5464 case clang::Type::ExtVector:
5466 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5469 case clang::Type::ConstantArray:
5470 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5474 case clang::Type::IncompleteArray:
5475 if (
auto array_info =
5478 num_children = array_info->element_orders.size()
5479 ? array_info->element_orders.back().value_or(0)
5483 case clang::Type::Pointer: {
5484 const clang::PointerType *pointer_type =
5485 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5486 clang::QualType pointee_type(pointer_type->getPointeeType());
5488 uint32_t num_pointee_children = 0;
5490 auto num_children_or_err =
5491 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5492 if (!num_children_or_err)
5493 return num_children_or_err;
5494 num_pointee_children = *num_children_or_err;
5496 if (num_pointee_children == 0) {
5501 num_children = num_pointee_children;
5507 return num_children;
5518 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5519 if (type_class == clang::Type::Builtin) {
5520 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5521 case clang::BuiltinType::Void:
5523 case clang::BuiltinType::Bool:
5525 case clang::BuiltinType::Char_S:
5527 case clang::BuiltinType::Char_U:
5529 case clang::BuiltinType::Char8:
5531 case clang::BuiltinType::Char16:
5533 case clang::BuiltinType::Char32:
5535 case clang::BuiltinType::UChar:
5537 case clang::BuiltinType::SChar:
5539 case clang::BuiltinType::WChar_S:
5541 case clang::BuiltinType::WChar_U:
5543 case clang::BuiltinType::Short:
5545 case clang::BuiltinType::UShort:
5547 case clang::BuiltinType::Int:
5549 case clang::BuiltinType::UInt:
5551 case clang::BuiltinType::Long:
5553 case clang::BuiltinType::ULong:
5555 case clang::BuiltinType::LongLong:
5557 case clang::BuiltinType::ULongLong:
5559 case clang::BuiltinType::Int128:
5561 case clang::BuiltinType::UInt128:
5564 case clang::BuiltinType::Half:
5566 case clang::BuiltinType::Float:
5568 case clang::BuiltinType::Double:
5570 case clang::BuiltinType::LongDouble:
5572 case clang::BuiltinType::Float128:
5575 case clang::BuiltinType::NullPtr:
5577 case clang::BuiltinType::ObjCId:
5579 case clang::BuiltinType::ObjCClass:
5581 case clang::BuiltinType::ObjCSel:
5595 const llvm::APSInt &value)>
const &callback) {
5596 const clang::EnumType *enum_type =
5599 const clang::EnumDecl *enum_decl =
5600 enum_type->getDecl()->getDefinitionOrSelf();
5604 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5605 for (enum_pos = enum_decl->enumerator_begin(),
5606 enum_end_pos = enum_decl->enumerator_end();
5607 enum_pos != enum_end_pos; ++enum_pos) {
5608 ConstString name(enum_pos->getNameAsString().c_str());
5609 if (!callback(integer_type, name, enum_pos->getInitVal()))
5616#pragma mark Aggregate Types
5624 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5625 switch (type_class) {
5626 case clang::Type::Record:
5628 const clang::RecordType *record_type =
5629 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5631 clang::RecordDecl *record_decl =
5632 record_type->getDecl()->getDefinition();
5634 count = std::distance(record_decl->field_begin(),
5635 record_decl->field_end());
5641 case clang::Type::ObjCObjectPointer: {
5642 const clang::ObjCObjectPointerType *objc_class_type =
5643 qual_type->castAs<clang::ObjCObjectPointerType>();
5644 const clang::ObjCInterfaceType *objc_interface_type =
5645 objc_class_type->getInterfaceType();
5646 if (objc_interface_type &&
5648 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5649 clang::ObjCInterfaceDecl *class_interface_decl =
5650 objc_interface_type->getDecl();
5651 if (class_interface_decl) {
5652 count = class_interface_decl->ivar_size();
5658 case clang::Type::ObjCObject:
5659 case clang::Type::ObjCInterface:
5661 const clang::ObjCObjectType *objc_class_type =
5662 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5663 if (objc_class_type) {
5664 clang::ObjCInterfaceDecl *class_interface_decl =
5665 objc_class_type->getInterface();
5667 if (class_interface_decl)
5668 count = class_interface_decl->ivar_size();
5681 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5682 std::string &name, uint64_t *bit_offset_ptr,
5683 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5684 if (class_interface_decl) {
5685 if (idx < (class_interface_decl->ivar_size())) {
5686 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5687 ivar_end = class_interface_decl->ivar_end();
5688 uint32_t ivar_idx = 0;
5690 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5691 ++ivar_pos, ++ivar_idx) {
5692 if (ivar_idx == idx) {
5693 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5695 clang::QualType ivar_qual_type(ivar_decl->getType());
5697 name.assign(ivar_decl->getNameAsString());
5699 if (bit_offset_ptr) {
5700 const clang::ASTRecordLayout &interface_layout =
5701 ast->getASTObjCInterfaceLayout(class_interface_decl);
5702 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5705 const bool is_bitfield = ivar_pos->isBitField();
5707 if (bitfield_bit_size_ptr) {
5708 *bitfield_bit_size_ptr = 0;
5710 if (is_bitfield && ast) {
5711 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5712 clang::Expr::EvalResult result;
5713 if (bitfield_bit_size_expr &&
5714 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5715 llvm::APSInt bitfield_apsint = result.Val.getInt();
5716 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5720 if (is_bitfield_ptr)
5721 *is_bitfield_ptr = is_bitfield;
5723 return ivar_qual_type.getAsOpaquePtr();
5732 size_t idx, std::string &name,
5733 uint64_t *bit_offset_ptr,
5734 uint32_t *bitfield_bit_size_ptr,
5735 bool *is_bitfield_ptr) {
5740 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5741 switch (type_class) {
5742 case clang::Type::Record:
5744 const clang::RecordType *record_type =
5745 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5746 const clang::RecordDecl *record_decl =
5747 record_type->getDecl()->getDefinitionOrSelf();
5748 uint32_t field_idx = 0;
5749 clang::RecordDecl::field_iterator field, field_end;
5750 for (field = record_decl->field_begin(),
5751 field_end = record_decl->field_end();
5752 field != field_end; ++field, ++field_idx) {
5753 if (idx == field_idx) {
5756 name.assign(field->getNameAsString());
5760 if (bit_offset_ptr) {
5761 const clang::ASTRecordLayout &record_layout =
5763 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5766 const bool is_bitfield = field->isBitField();
5768 if (bitfield_bit_size_ptr) {
5769 *bitfield_bit_size_ptr = 0;
5772 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5773 clang::Expr::EvalResult result;
5774 if (bitfield_bit_size_expr &&
5775 bitfield_bit_size_expr->EvaluateAsInt(result,
5777 llvm::APSInt bitfield_apsint = result.Val.getInt();
5778 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5782 if (is_bitfield_ptr)
5783 *is_bitfield_ptr = is_bitfield;
5785 return GetType(field->getType());
5791 case clang::Type::ObjCObjectPointer: {
5792 const clang::ObjCObjectPointerType *objc_class_type =
5793 qual_type->castAs<clang::ObjCObjectPointerType>();
5794 const clang::ObjCInterfaceType *objc_interface_type =
5795 objc_class_type->getInterfaceType();
5796 if (objc_interface_type &&
5798 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5799 clang::ObjCInterfaceDecl *class_interface_decl =
5800 objc_interface_type->getDecl();
5801 if (class_interface_decl) {
5805 name, bit_offset_ptr, bitfield_bit_size_ptr,
5812 case clang::Type::ObjCObject:
5813 case clang::Type::ObjCInterface:
5815 const clang::ObjCObjectType *objc_class_type =
5816 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5817 assert(objc_class_type);
5818 if (objc_class_type) {
5819 clang::ObjCInterfaceDecl *class_interface_decl =
5820 objc_class_type->getInterface();
5824 name, bit_offset_ptr, bitfield_bit_size_ptr,
5840 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5841 switch (type_class) {
5842 case clang::Type::Record:
5844 const clang::CXXRecordDecl *cxx_record_decl =
5845 qual_type->getAsCXXRecordDecl();
5846 if (cxx_record_decl)
5847 count = cxx_record_decl->getNumBases();
5851 case clang::Type::ObjCObjectPointer:
5855 case clang::Type::ObjCObject:
5857 const clang::ObjCObjectType *objc_class_type =
5858 qual_type->getAsObjCQualifiedInterfaceType();
5859 if (objc_class_type) {
5860 clang::ObjCInterfaceDecl *class_interface_decl =
5861 objc_class_type->getInterface();
5863 if (class_interface_decl && class_interface_decl->getSuperClass())
5868 case clang::Type::ObjCInterface:
5870 const clang::ObjCInterfaceType *objc_interface_type =
5871 qual_type->getAs<clang::ObjCInterfaceType>();
5872 if (objc_interface_type) {
5873 clang::ObjCInterfaceDecl *class_interface_decl =
5874 objc_interface_type->getInterface();
5876 if (class_interface_decl && class_interface_decl->getSuperClass())
5892 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5893 switch (type_class) {
5894 case clang::Type::Record:
5896 const clang::CXXRecordDecl *cxx_record_decl =
5897 qual_type->getAsCXXRecordDecl();
5898 if (cxx_record_decl)
5899 count = cxx_record_decl->getNumVBases();
5912 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5913 switch (type_class) {
5914 case clang::Type::Record:
5916 const clang::CXXRecordDecl *cxx_record_decl =
5917 qual_type->getAsCXXRecordDecl();
5918 if (cxx_record_decl) {
5919 uint32_t curr_idx = 0;
5920 clang::CXXRecordDecl::base_class_const_iterator base_class,
5922 for (base_class = cxx_record_decl->bases_begin(),
5923 base_class_end = cxx_record_decl->bases_end();
5924 base_class != base_class_end; ++base_class, ++curr_idx) {
5925 if (curr_idx == idx) {
5926 if (bit_offset_ptr) {
5927 const clang::ASTRecordLayout &record_layout =
5929 const clang::CXXRecordDecl *base_class_decl =
5930 llvm::cast<clang::CXXRecordDecl>(
5931 base_class->getType()
5932 ->castAs<clang::RecordType>()
5934 if (base_class->isVirtual())
5936 record_layout.getVBaseClassOffset(base_class_decl)
5941 record_layout.getBaseClassOffset(base_class_decl)
5945 return GetType(base_class->getType());
5952 case clang::Type::ObjCObjectPointer:
5955 case clang::Type::ObjCObject:
5957 const clang::ObjCObjectType *objc_class_type =
5958 qual_type->getAsObjCQualifiedInterfaceType();
5959 if (objc_class_type) {
5960 clang::ObjCInterfaceDecl *class_interface_decl =
5961 objc_class_type->getInterface();
5963 if (class_interface_decl) {
5964 clang::ObjCInterfaceDecl *superclass_interface_decl =
5965 class_interface_decl->getSuperClass();
5966 if (superclass_interface_decl) {
5968 *bit_offset_ptr = 0;
5970 superclass_interface_decl));
5976 case clang::Type::ObjCInterface:
5978 const clang::ObjCObjectType *objc_interface_type =
5979 qual_type->getAs<clang::ObjCInterfaceType>();
5980 if (objc_interface_type) {
5981 clang::ObjCInterfaceDecl *class_interface_decl =
5982 objc_interface_type->getInterface();
5984 if (class_interface_decl) {
5985 clang::ObjCInterfaceDecl *superclass_interface_decl =
5986 class_interface_decl->getSuperClass();
5987 if (superclass_interface_decl) {
5989 *bit_offset_ptr = 0;
5991 superclass_interface_decl));
6007 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6008 switch (type_class) {
6009 case clang::Type::Record:
6011 const clang::CXXRecordDecl *cxx_record_decl =
6012 qual_type->getAsCXXRecordDecl();
6013 if (cxx_record_decl) {
6014 uint32_t curr_idx = 0;
6015 clang::CXXRecordDecl::base_class_const_iterator base_class,
6017 for (base_class = cxx_record_decl->vbases_begin(),
6018 base_class_end = cxx_record_decl->vbases_end();
6019 base_class != base_class_end; ++base_class, ++curr_idx) {
6020 if (curr_idx == idx) {
6021 if (bit_offset_ptr) {
6022 const clang::ASTRecordLayout &record_layout =
6024 const clang::CXXRecordDecl *base_class_decl =
6025 llvm::cast<clang::CXXRecordDecl>(
6026 base_class->getType()
6027 ->castAs<clang::RecordType>()
6030 record_layout.getVBaseClassOffset(base_class_decl)
6034 return GetType(base_class->getType());
6049 llvm::StringRef name) {
6051 switch (qual_type->getTypeClass()) {
6052 case clang::Type::Record: {
6056 const clang::RecordType *record_type =
6057 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6058 const clang::RecordDecl *record_decl =
6059 record_type->getDecl()->getDefinitionOrSelf();
6061 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
6062 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
6063 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
6064 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
6088 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6089 switch (type_class) {
6090 case clang::Type::Builtin:
6091 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6092 case clang::BuiltinType::UnknownAny:
6093 case clang::BuiltinType::Void:
6094 case clang::BuiltinType::NullPtr:
6095 case clang::BuiltinType::OCLEvent:
6096 case clang::BuiltinType::OCLImage1dRO:
6097 case clang::BuiltinType::OCLImage1dWO:
6098 case clang::BuiltinType::OCLImage1dRW:
6099 case clang::BuiltinType::OCLImage1dArrayRO:
6100 case clang::BuiltinType::OCLImage1dArrayWO:
6101 case clang::BuiltinType::OCLImage1dArrayRW:
6102 case clang::BuiltinType::OCLImage1dBufferRO:
6103 case clang::BuiltinType::OCLImage1dBufferWO:
6104 case clang::BuiltinType::OCLImage1dBufferRW:
6105 case clang::BuiltinType::OCLImage2dRO:
6106 case clang::BuiltinType::OCLImage2dWO:
6107 case clang::BuiltinType::OCLImage2dRW:
6108 case clang::BuiltinType::OCLImage2dArrayRO:
6109 case clang::BuiltinType::OCLImage2dArrayWO:
6110 case clang::BuiltinType::OCLImage2dArrayRW:
6111 case clang::BuiltinType::OCLImage3dRO:
6112 case clang::BuiltinType::OCLImage3dWO:
6113 case clang::BuiltinType::OCLImage3dRW:
6114 case clang::BuiltinType::OCLSampler:
6115 case clang::BuiltinType::HLSLResource:
6117 case clang::BuiltinType::Bool:
6118 case clang::BuiltinType::Char_U:
6119 case clang::BuiltinType::UChar:
6120 case clang::BuiltinType::WChar_U:
6121 case clang::BuiltinType::Char16:
6122 case clang::BuiltinType::Char32:
6123 case clang::BuiltinType::UShort:
6124 case clang::BuiltinType::UInt:
6125 case clang::BuiltinType::ULong:
6126 case clang::BuiltinType::ULongLong:
6127 case clang::BuiltinType::UInt128:
6128 case clang::BuiltinType::Char_S:
6129 case clang::BuiltinType::SChar:
6130 case clang::BuiltinType::WChar_S:
6131 case clang::BuiltinType::Short:
6132 case clang::BuiltinType::Int:
6133 case clang::BuiltinType::Long:
6134 case clang::BuiltinType::LongLong:
6135 case clang::BuiltinType::Int128:
6136 case clang::BuiltinType::Float:
6137 case clang::BuiltinType::Double:
6138 case clang::BuiltinType::LongDouble:
6139 case clang::BuiltinType::Float128:
6140 case clang::BuiltinType::Dependent:
6141 case clang::BuiltinType::Overload:
6142 case clang::BuiltinType::ObjCId:
6143 case clang::BuiltinType::ObjCClass:
6144 case clang::BuiltinType::ObjCSel:
6145 case clang::BuiltinType::BoundMember:
6146 case clang::BuiltinType::Half:
6147 case clang::BuiltinType::ARCUnbridgedCast:
6148 case clang::BuiltinType::PseudoObject:
6149 case clang::BuiltinType::BuiltinFn:
6150 case clang::BuiltinType::ArraySection:
6157 case clang::Type::Complex:
6159 case clang::Type::Pointer:
6161 case clang::Type::BlockPointer:
6164 case clang::Type::LValueReference:
6166 case clang::Type::RValueReference:
6168 case clang::Type::MemberPointer:
6170 case clang::Type::ConstantArray:
6172 case clang::Type::IncompleteArray:
6174 case clang::Type::VariableArray:
6176 case clang::Type::DependentSizedArray:
6178 case clang::Type::DependentSizedExtVector:
6180 case clang::Type::Vector:
6182 case clang::Type::ExtVector:
6184 case clang::Type::FunctionProto:
6186 case clang::Type::FunctionNoProto:
6188 case clang::Type::UnresolvedUsing:
6190 case clang::Type::Record:
6192 case clang::Type::Enum:
6194 case clang::Type::TemplateTypeParm:
6196 case clang::Type::SubstTemplateTypeParm:
6198 case clang::Type::TemplateSpecialization:
6200 case clang::Type::InjectedClassName:
6202 case clang::Type::DependentName:
6204 case clang::Type::ObjCObject:
6206 case clang::Type::ObjCInterface:
6208 case clang::Type::ObjCObjectPointer:
6218 std::string &deref_name, uint32_t &deref_byte_size,
6219 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6223 return llvm::createStringError(
"not a pointer, reference or array type");
6224 uint32_t child_bitfield_bit_size = 0;
6225 uint32_t child_bitfield_bit_offset = 0;
6226 bool child_is_base_class;
6227 bool child_is_deref_of_parent;
6229 type, exe_ctx, 0,
false,
true,
false, deref_name, deref_byte_size,
6230 deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6231 child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
6236 bool transparent_pointers,
bool omit_empty_base_classes,
6237 bool ignore_array_bounds, std::string &child_name,
6238 uint32_t &child_byte_size, int32_t &child_byte_offset,
6239 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6240 bool &child_is_base_class,
bool &child_is_deref_of_parent,
6243 return llvm::createStringError(
"invalid type");
6245 auto get_exe_scope = [&exe_ctx]() {
6249 clang::QualType parent_qual_type(
6251 const clang::Type::TypeClass parent_type_class =
6252 parent_qual_type->getTypeClass();
6253 child_bitfield_bit_size = 0;
6254 child_bitfield_bit_offset = 0;
6255 child_is_base_class =
false;
6258 auto num_children_or_err =
6260 if (!num_children_or_err)
6261 return num_children_or_err.takeError();
6263 const bool idx_is_valid = idx < *num_children_or_err;
6265 switch (parent_type_class) {
6266 case clang::Type::Builtin:
6268 return llvm::createStringError(
"invalid index");
6270 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6271 case clang::BuiltinType::ObjCId:
6272 case clang::BuiltinType::ObjCClass:
6283 case clang::Type::Record: {
6285 return llvm::createStringError(
"invalid index");
6287 return llvm::createStringError(
"cannot complete type");
6289 const clang::RecordType *record_type =
6290 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6291 const clang::RecordDecl *record_decl =
6292 record_type->getDecl()->getDefinitionOrSelf();
6293 const clang::ASTRecordLayout &record_layout =
6295 uint32_t child_idx = 0;
6297 const clang::CXXRecordDecl *cxx_record_decl =
6298 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6299 if (cxx_record_decl) {
6301 clang::CXXRecordDecl::base_class_const_iterator base_class,
6303 for (base_class = cxx_record_decl->bases_begin(),
6304 base_class_end = cxx_record_decl->bases_end();
6305 base_class != base_class_end; ++base_class) {
6306 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6309 if (omit_empty_base_classes) {
6311 llvm::cast<clang::CXXRecordDecl>(
6312 base_class->getType()->getAs<clang::RecordType>()->getDecl())
6313 ->getDefinitionOrSelf();
6318 if (idx == child_idx) {
6319 if (base_class_decl ==
nullptr)
6320 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6321 base_class->getType()
6322 ->getAs<clang::RecordType>()
6324 ->getDefinitionOrSelf();
6326 if (base_class->isVirtual()) {
6327 bool handled =
false;
6329 clang::VTableContextBase *vtable_ctx =
6333 cxx_record_decl, base_class_decl,
6337 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6341 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6346 child_byte_offset = bit_offset / 8;
6349 auto size_or_err = base_class_clang_type.
GetBitSize(get_exe_scope());
6351 return llvm::joinErrors(
6352 llvm::createStringError(
"no size info for base class"),
6353 size_or_err.takeError());
6355 uint64_t base_class_clang_type_bit_size = *size_or_err;
6358 assert(base_class_clang_type_bit_size % 8 == 0);
6359 child_byte_size = base_class_clang_type_bit_size / 8;
6360 child_is_base_class =
true;
6361 return base_class_clang_type;
6369 uint32_t field_idx = 0;
6370 clang::RecordDecl::field_iterator field, field_end;
6371 for (field = record_decl->field_begin(),
6372 field_end = record_decl->field_end();
6373 field != field_end; ++field, ++field_idx, ++child_idx) {
6374 if (idx == child_idx) {
6377 child_name.assign(field->getNameAsString());
6382 assert(field_idx < record_layout.getFieldCount());
6383 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6385 return llvm::joinErrors(
6386 llvm::createStringError(
"no size info for field"),
6387 size_or_err.takeError());
6389 child_byte_size = *size_or_err;
6390 const uint32_t child_bit_size = child_byte_size * 8;
6394 bit_offset = record_layout.getFieldOffset(field_idx);
6396 child_bitfield_bit_offset = bit_offset % child_bit_size;
6397 const uint32_t child_bit_offset =
6398 bit_offset - child_bitfield_bit_offset;
6399 child_byte_offset = child_bit_offset / 8;
6401 child_byte_offset = bit_offset / 8;
6404 return field_clang_type;
6408 case clang::Type::ObjCObject:
6409 case clang::Type::ObjCInterface: {
6411 return llvm::createStringError(
"invalid index");
6413 return llvm::createStringError(
"cannot complete type");
6415 const clang::ObjCObjectType *objc_class_type =
6416 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6417 assert(objc_class_type);
6418 if (!objc_class_type)
6419 return llvm::createStringError(
"unexpected object type");
6421 uint32_t child_idx = 0;
6422 clang::ObjCInterfaceDecl *class_interface_decl =
6423 objc_class_type->getInterface();
6425 if (!class_interface_decl)
6426 return llvm::createStringError(
"cannot get interface decl");
6428 const clang::ASTRecordLayout &interface_layout =
6429 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6430 clang::ObjCInterfaceDecl *superclass_interface_decl =
6431 class_interface_decl->getSuperClass();
6432 if (superclass_interface_decl) {
6433 if (omit_empty_base_classes) {
6435 getASTContext().getObjCInterfaceType(superclass_interface_decl));
6436 if (llvm::expectedToStdOptional(base_class_clang_type.
GetNumChildren(
6437 omit_empty_base_classes, exe_ctx))
6440 clang::QualType ivar_qual_type(
getASTContext().getObjCInterfaceType(
6441 superclass_interface_decl));
6443 child_name.assign(superclass_interface_decl->getNameAsString());
6445 clang::TypeInfo ivar_type_info =
6448 child_byte_size = ivar_type_info.Width / 8;
6449 child_byte_offset = 0;
6450 child_is_base_class =
true;
6452 return GetType(ivar_qual_type);
6461 const uint32_t superclass_idx = child_idx;
6463 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6464 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6465 ivar_end = class_interface_decl->ivar_end();
6467 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
6469 if (child_idx == idx) {
6470 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6472 clang::QualType ivar_qual_type(ivar_decl->getType());
6474 child_name.assign(ivar_decl->getNameAsString());
6476 clang::TypeInfo ivar_type_info =
6479 child_byte_size = ivar_type_info.Width / 8;
6495 if (objc_runtime !=
nullptr) {
6498 parent_ast_type, ivar_decl->getNameAsString().c_str());
6506 if (child_byte_offset ==
6509 interface_layout.getFieldOffset(child_idx - superclass_idx);
6510 child_byte_offset = bit_offset / 8;
6522 interface_layout.getFieldOffset(child_idx - superclass_idx);
6524 child_bitfield_bit_offset = bit_offset % 8;
6526 return GetType(ivar_qual_type);
6533 case clang::Type::ObjCObjectPointer: {
6535 return llvm::createStringError(
"invalid index");
6539 child_is_deref_of_parent =
false;
6540 bool tmp_child_is_deref_of_parent =
false;
6542 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6543 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6544 child_bitfield_bit_size, child_bitfield_bit_offset,
6545 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6548 child_is_deref_of_parent =
true;
6549 const char *parent_name =
6552 child_name.assign(1,
'*');
6553 child_name += parent_name;
6558 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6560 return size_or_err.takeError();
6561 child_byte_size = *size_or_err;
6562 child_byte_offset = 0;
6563 return pointee_clang_type;
6568 case clang::Type::Vector:
6569 case clang::Type::ExtVector: {
6571 return llvm::createStringError(
"invalid index");
6572 const clang::VectorType *array =
6573 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6575 return llvm::createStringError(
"unexpected vector type");
6579 return llvm::createStringError(
"cannot complete type");
6581 char element_name[64];
6582 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6583 static_cast<uint64_t
>(idx));
6584 child_name.assign(element_name);
6585 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6587 return size_or_err.takeError();
6588 child_byte_size = *size_or_err;
6589 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6590 return element_type;
6592 case clang::Type::ConstantArray:
6593 case clang::Type::IncompleteArray: {
6594 if (!ignore_array_bounds && !idx_is_valid)
6595 return llvm::createStringError(
"invalid index");
6596 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6598 return llvm::createStringError(
"unexpected array type");
6601 return llvm::createStringError(
"cannot complete type");
6603 child_name = std::string(llvm::formatv(
"[{0}]", idx));
6604 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6606 return size_or_err.takeError();
6607 child_byte_size = *size_or_err;
6608 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6609 return element_type;
6611 case clang::Type::Pointer: {
6616 return llvm::createStringError(
"cannot dereference void *");
6619 child_is_deref_of_parent =
false;
6620 bool tmp_child_is_deref_of_parent =
false;
6622 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6623 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6624 child_bitfield_bit_size, child_bitfield_bit_offset,
6625 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6628 child_is_deref_of_parent =
true;
6632 child_name.assign(1,
'*');
6633 child_name += parent_name;
6638 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6640 return size_or_err.takeError();
6641 child_byte_size = *size_or_err;
6642 child_byte_offset = 0;
6643 return pointee_clang_type;
6648 case clang::Type::LValueReference:
6649 case clang::Type::RValueReference: {
6651 return llvm::createStringError(
"invalid index");
6652 const clang::ReferenceType *reference_type =
6653 llvm::cast<clang::ReferenceType>(
6657 child_is_deref_of_parent =
false;
6658 bool tmp_child_is_deref_of_parent =
false;
6660 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6661 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6662 child_bitfield_bit_size, child_bitfield_bit_offset,
6663 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6668 child_name.assign(1,
'&');
6669 child_name += parent_name;
6674 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6676 return size_or_err.takeError();
6677 child_byte_size = *size_or_err;
6678 child_byte_offset = 0;
6679 return pointee_clang_type;
6686 return llvm::createStringError(
"cannot enumerate children");
6690 const clang::RecordDecl *record_decl,
6691 const clang::CXXBaseSpecifier *base_spec,
6692 bool omit_empty_base_classes) {
6693 uint32_t child_idx = 0;
6695 const clang::CXXRecordDecl *cxx_record_decl =
6696 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6698 if (cxx_record_decl) {
6699 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6700 for (base_class = cxx_record_decl->bases_begin(),
6701 base_class_end = cxx_record_decl->bases_end();
6702 base_class != base_class_end; ++base_class) {
6703 if (omit_empty_base_classes) {
6708 if (base_class == base_spec)
6718 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6719 bool omit_empty_base_classes) {
6721 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6722 omit_empty_base_classes);
6724 clang::RecordDecl::field_iterator field, field_end;
6725 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6726 field != field_end; ++field, ++child_idx) {
6727 if (field->getCanonicalDecl() == canonical_decl)
6769 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6770 if (type && !name.empty()) {
6772 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6773 switch (type_class) {
6774 case clang::Type::Record:
6776 const clang::RecordType *record_type =
6777 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6778 const clang::RecordDecl *record_decl =
6779 record_type->getDecl()->getDefinitionOrSelf();
6781 assert(record_decl);
6782 uint32_t child_idx = 0;
6784 const clang::CXXRecordDecl *cxx_record_decl =
6785 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6788 clang::RecordDecl::field_iterator field, field_end;
6789 for (field = record_decl->field_begin(),
6790 field_end = record_decl->field_end();
6791 field != field_end; ++field, ++child_idx) {
6792 llvm::StringRef field_name = field->getName();
6793 if (field_name.empty()) {
6795 std::vector<uint32_t> save_indices = child_indexes;
6796 child_indexes.push_back(
6798 cxx_record_decl, omit_empty_base_classes));
6800 name, omit_empty_base_classes, child_indexes))
6801 return child_indexes.size();
6802 child_indexes = std::move(save_indices);
6803 }
else if (field_name == name) {
6805 child_indexes.push_back(
6807 cxx_record_decl, omit_empty_base_classes));
6808 return child_indexes.size();
6812 if (cxx_record_decl) {
6813 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6816 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6817 clang::DeclarationName decl_name(&ident_ref);
6819 clang::CXXBasePaths paths;
6820 if (cxx_record_decl->lookupInBases(
6821 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6822 clang::CXXBasePath &path) {
6823 CXXRecordDecl *record =
6824 specifier->getType()->getAsCXXRecordDecl();
6825 auto r = record->lookup(decl_name);
6826 path.Decls = r.begin();
6830 clang::CXXBasePaths::const_paths_iterator path,
6831 path_end = paths.end();
6832 for (path = paths.begin(); path != path_end; ++path) {
6833 const size_t num_path_elements = path->size();
6834 for (
size_t e = 0; e < num_path_elements; ++e) {
6835 clang::CXXBasePathElement elem = (*path)[e];
6838 omit_empty_base_classes);
6840 child_indexes.clear();
6843 child_indexes.push_back(child_idx);
6844 parent_record_decl = elem.Base->getType()
6845 ->castAs<clang::RecordType>()
6847 ->getDefinitionOrSelf();
6850 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6853 parent_record_decl, *I, omit_empty_base_classes);
6855 child_indexes.clear();
6858 child_indexes.push_back(child_idx);
6862 return child_indexes.size();
6868 case clang::Type::ObjCObject:
6869 case clang::Type::ObjCInterface:
6871 llvm::StringRef name_sref(name);
6872 const clang::ObjCObjectType *objc_class_type =
6873 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6874 assert(objc_class_type);
6875 if (objc_class_type) {
6876 uint32_t child_idx = 0;
6877 clang::ObjCInterfaceDecl *class_interface_decl =
6878 objc_class_type->getInterface();
6880 if (class_interface_decl) {
6881 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6882 ivar_end = class_interface_decl->ivar_end();
6883 clang::ObjCInterfaceDecl *superclass_interface_decl =
6884 class_interface_decl->getSuperClass();
6886 for (ivar_pos = class_interface_decl->ivar_begin();
6887 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6888 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6890 if (ivar_decl->getName() == name_sref) {
6891 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6892 (omit_empty_base_classes &&
6896 child_indexes.push_back(child_idx);
6897 return child_indexes.size();
6901 if (superclass_interface_decl) {
6905 child_indexes.push_back(0);
6909 superclass_interface_decl));
6911 name, omit_empty_base_classes, child_indexes)) {
6914 return child_indexes.size();
6919 child_indexes.pop_back();
6926 case clang::Type::ObjCObjectPointer: {
6928 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6929 ->getPointeeType());
6931 name, omit_empty_base_classes, child_indexes);
6934 case clang::Type::LValueReference:
6935 case clang::Type::RValueReference: {
6936 const clang::ReferenceType *reference_type =
6937 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
6938 clang::QualType pointee_type(reference_type->getPointeeType());
6943 name, omit_empty_base_classes, child_indexes);
6947 case clang::Type::Pointer: {
6952 name, omit_empty_base_classes, child_indexes);
6967llvm::Expected<uint32_t>
6969 llvm::StringRef name,
6970 bool omit_empty_base_classes) {
6971 if (type && !name.empty()) {
6974 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6976 switch (type_class) {
6977 case clang::Type::Record:
6979 const clang::RecordType *record_type =
6980 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6981 const clang::RecordDecl *record_decl =
6982 record_type->getDecl()->getDefinitionOrSelf();
6984 assert(record_decl);
6985 uint32_t child_idx = 0;
6987 const clang::CXXRecordDecl *cxx_record_decl =
6988 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6990 if (cxx_record_decl) {
6991 clang::CXXRecordDecl::base_class_const_iterator base_class,
6993 for (base_class = cxx_record_decl->bases_begin(),
6994 base_class_end = cxx_record_decl->bases_end();
6995 base_class != base_class_end; ++base_class) {
6997 clang::CXXRecordDecl *base_class_decl =
6998 llvm::cast<clang::CXXRecordDecl>(
6999 base_class->getType()
7000 ->castAs<clang::RecordType>()
7002 ->getDefinitionOrSelf();
7003 if (omit_empty_base_classes &&
7008 std::string base_class_type_name(
7010 if (base_class_type_name == name)
7017 clang::RecordDecl::field_iterator field, field_end;
7018 for (field = record_decl->field_begin(),
7019 field_end = record_decl->field_end();
7020 field != field_end; ++field, ++child_idx) {
7021 if (field->getName() == name)
7027 case clang::Type::ObjCObject:
7028 case clang::Type::ObjCInterface:
7030 const clang::ObjCObjectType *objc_class_type =
7031 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
7032 assert(objc_class_type);
7033 if (objc_class_type) {
7034 uint32_t child_idx = 0;
7035 clang::ObjCInterfaceDecl *class_interface_decl =
7036 objc_class_type->getInterface();
7038 if (class_interface_decl) {
7039 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
7040 ivar_end = class_interface_decl->ivar_end();
7041 clang::ObjCInterfaceDecl *superclass_interface_decl =
7042 class_interface_decl->getSuperClass();
7044 for (ivar_pos = class_interface_decl->ivar_begin();
7045 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
7046 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
7048 if (ivar_decl->getName() == name) {
7049 if ((!omit_empty_base_classes && superclass_interface_decl) ||
7050 (omit_empty_base_classes &&
7058 if (superclass_interface_decl) {
7059 if (superclass_interface_decl->getName() == name)
7067 case clang::Type::ObjCObjectPointer: {
7069 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7070 ->getPointeeType());
7072 name, omit_empty_base_classes);
7075 case clang::Type::LValueReference:
7076 case clang::Type::RValueReference: {
7077 const clang::ReferenceType *reference_type =
7078 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7083 omit_empty_base_classes);
7087 case clang::Type::Pointer: {
7088 const clang::PointerType *pointer_type =
7089 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7094 omit_empty_base_classes);
7102 return llvm::createStringError(
"Type has no child named '%s'",
7103 name.str().c_str());
7108 llvm::StringRef name) {
7109 if (!type || name.empty())
7113 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7115 switch (type_class) {
7116 case clang::Type::Record: {
7119 const clang::RecordType *record_type =
7120 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7121 const clang::RecordDecl *record_decl =
7122 record_type->getDecl()->getDefinitionOrSelf();
7124 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7125 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7126 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7128 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7130 ElaboratedTypeKeyword::None, std::nullopt,
7146 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7147 return isa<clang::ClassTemplateSpecializationDecl>(
7148 cxx_record_decl->getDecl());
7159 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7160 switch (type_class) {
7161 case clang::Type::Record:
7163 const clang::CXXRecordDecl *cxx_record_decl =
7164 qual_type->getAsCXXRecordDecl();
7165 if (cxx_record_decl) {
7166 const clang::ClassTemplateSpecializationDecl *template_decl =
7167 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7169 if (template_decl) {
7170 const auto &template_arg_list = template_decl->getTemplateArgs();
7171 size_t num_args = template_arg_list.size();
7172 assert(num_args &&
"template specialization without any args");
7173 if (expand_pack && num_args) {
7174 const auto &pack = template_arg_list[num_args - 1];
7175 if (pack.getKind() == clang::TemplateArgument::Pack)
7176 num_args += pack.pack_size() - 1;
7191const clang::ClassTemplateSpecializationDecl *
7198 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7199 switch (type_class) {
7200 case clang::Type::Record: {
7203 const clang::CXXRecordDecl *cxx_record_decl =
7204 qual_type->getAsCXXRecordDecl();
7205 if (!cxx_record_decl)
7207 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7216const TemplateArgument *
7218 size_t idx,
bool expand_pack) {
7219 const auto &args = decl->getTemplateArgs();
7220 const size_t args_size = args.size();
7222 assert(args_size &&
"template specialization without any args");
7226 const size_t last_idx = args_size - 1;
7235 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7236 return idx >= args.size() ? nullptr : &args[idx];
7241 const auto &pack = args[last_idx];
7242 const size_t pack_idx = idx - last_idx;
7243 if (pack_idx >= pack.pack_size())
7245 return &pack.pack_elements()[pack_idx];
7250 size_t arg_idx,
bool expand_pack) {
7251 const clang::ClassTemplateSpecializationDecl *template_decl =
7260 switch (arg->getKind()) {
7261 case clang::TemplateArgument::Null:
7264 case clang::TemplateArgument::NullPtr:
7267 case clang::TemplateArgument::Type:
7270 case clang::TemplateArgument::Declaration:
7273 case clang::TemplateArgument::Integral:
7276 case clang::TemplateArgument::Template:
7279 case clang::TemplateArgument::TemplateExpansion:
7282 case clang::TemplateArgument::Expression:
7285 case clang::TemplateArgument::Pack:
7288 case clang::TemplateArgument::StructuralValue:
7291 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7296 size_t idx,
bool expand_pack) {
7297 const clang::ClassTemplateSpecializationDecl *template_decl =
7303 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7306 return GetType(arg->getAsType());
7309std::optional<CompilerType::IntegralTemplateArgument>
7311 size_t idx,
bool expand_pack) {
7312 const clang::ClassTemplateSpecializationDecl *template_decl =
7315 return std::nullopt;
7319 return std::nullopt;
7321 switch (arg->getKind()) {
7322 case clang::TemplateArgument::Integral:
7323 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7324 case clang::TemplateArgument::StructuralValue: {
7325 clang::APValue value = arg->getAsStructuralValue();
7328 if (value.isFloat())
7329 return {{value.getFloat(), type}};
7332 return {{value.getInt(), type}};
7334 return std::nullopt;
7337 return std::nullopt;
7351 bool is_signed =
false;
7352 bool isUnscopedEnumerationType =
7354 if (isUnscopedEnumerationType)
7375 llvm_unreachable(
"All cases handled above.");
7378llvm::Expected<CompilerType>
7395 uint64_t from_size = 0;
7403 llvm::Expected<uint64_t> from_size = from.
GetByteSize(exe_scope);
7405 return from_size.takeError();
7415 llvm::Expected<uint64_t> byte_size = type.GetByteSize(exe_scope);
7417 return byte_size.takeError();
7418 if (*from_size < *byte_size ||
7419 (*from_size == *byte_size && is_signed == type.IsSigned())) {
7423 llvm_unreachable(
"char type should fit into long long");
7428 llvm::Expected<uint64_t> int_byte_size = int_type.
GetByteSize(exe_scope);
7430 return int_byte_size.takeError();
7438 return (from_size == *int_byte_size)
7444 const clang::EnumType *enutype =
7447 return enutype->getDecl()->getDefinitionOrSelf();
7452 const clang::RecordType *record_type =
7455 return record_type->getDecl()->getDefinitionOrSelf();
7463clang::TypedefNameDecl *
7465 const clang::TypedefType *typedef_type =
7468 return typedef_type->getDecl();
7472clang::CXXRecordDecl *
7477clang::ObjCInterfaceDecl *
7479 const clang::ObjCObjectType *objc_class_type =
7480 llvm::dyn_cast<clang::ObjCObjectType>(
7482 if (objc_class_type)
7483 return objc_class_type->getInterface();
7490 uint32_t bitfield_bit_size) {
7496 clang::ASTContext &clang_ast = ast->getASTContext();
7497 clang::IdentifierInfo *ident =
nullptr;
7499 ident = &clang_ast.Idents.get(name);
7501 clang::FieldDecl *field =
nullptr;
7503 clang::Expr *bit_width =
nullptr;
7504 if (bitfield_bit_size != 0) {
7505 if (clang_ast.IntTy.isNull()) {
7508 "{0} failed: builtin ASTContext types have not been initialized");
7512 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7514 bit_width =
new (clang_ast)
7515 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7516 clang_ast.IntTy, clang::SourceLocation());
7517 bit_width = clang::ConstantExpr::Create(
7518 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7521 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7523 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7524 field->setDeclContext(record_decl);
7525 field->setDeclName(ident);
7528 field->setBitWidth(bit_width);
7534 if (
const clang::TagType *TagT =
7535 field->getType()->getAs<clang::TagType>()) {
7536 if (clang::RecordDecl *Rec =
7537 llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
7538 if (!Rec->getDeclName()) {
7539 Rec->setAnonymousStructOrUnion(
true);
7540 field->setImplicit();
7546 clang::AccessSpecifier access_specifier =
7548 field->setAccess(access_specifier);
7550 if (clang::CXXRecordDecl *cxx_record_decl =
7551 llvm::dyn_cast<CXXRecordDecl>(record_decl)) {
7552 AddAccessSpecifierDecl(cxx_record_decl, ast->getASTContext(),
7553 ast->GetCXXRecordDeclAccess(cxx_record_decl),
7555 ast->SetCXXRecordDeclAccess(cxx_record_decl, access_specifier);
7557 record_decl->addDecl(field);
7562 clang::ObjCInterfaceDecl *class_interface_decl =
7563 ast->GetAsObjCInterfaceDecl(type);
7565 if (class_interface_decl) {
7566 const bool is_synthesized =
false;
7571 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7572 ivar->setDeclContext(class_interface_decl);
7573 ivar->setDeclName(ident);
7577 ivar->setBitWidth(bit_width);
7578 ivar->setSynthesize(is_synthesized);
7583 class_interface_decl->addDecl(field);
7600 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7605 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7607 IndirectFieldVector indirect_fields;
7608 clang::RecordDecl::field_iterator field_pos;
7609 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7610 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7611 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7612 last_field_pos = field_pos++) {
7613 if (field_pos->isAnonymousStructOrUnion()) {
7614 clang::QualType field_qual_type = field_pos->getType();
7616 const clang::RecordType *field_record_type =
7617 field_qual_type->getAs<clang::RecordType>();
7619 if (!field_record_type)
7622 clang::RecordDecl *field_record_decl =
7623 field_record_type->getDecl()->getDefinition();
7625 if (!field_record_decl)
7628 for (clang::RecordDecl::decl_iterator
7629 di = field_record_decl->decls_begin(),
7630 de = field_record_decl->decls_end();
7632 if (clang::FieldDecl *nested_field_decl =
7633 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7634 clang::NamedDecl **chain =
7635 new (ast->getASTContext()) clang::NamedDecl *[2];
7636 chain[0] = *field_pos;
7637 chain[1] = nested_field_decl;
7638 clang::IndirectFieldDecl *indirect_field =
7639 clang::IndirectFieldDecl::Create(
7640 ast->getASTContext(), record_decl, clang::SourceLocation(),
7641 nested_field_decl->getIdentifier(),
7642 nested_field_decl->getType(), {chain, 2});
7645 indirect_field->setImplicit();
7648 field_pos->getAccess(), nested_field_decl->getAccess()));
7650 indirect_fields.push_back(indirect_field);
7651 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7652 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7653 size_t nested_chain_size =
7654 nested_indirect_field_decl->getChainingSize();
7655 clang::NamedDecl **chain =
new (ast->getASTContext())
7656 clang::NamedDecl *[nested_chain_size + 1];
7657 chain[0] = *field_pos;
7659 int chain_index = 1;
7660 for (clang::IndirectFieldDecl::chain_iterator
7661 nci = nested_indirect_field_decl->chain_begin(),
7662 nce = nested_indirect_field_decl->chain_end();
7664 chain[chain_index] = *nci;
7668 clang::IndirectFieldDecl *indirect_field =
7669 clang::IndirectFieldDecl::Create(
7670 ast->getASTContext(), record_decl, clang::SourceLocation(),
7671 nested_indirect_field_decl->getIdentifier(),
7672 nested_indirect_field_decl->getType(),
7673 {chain, nested_chain_size + 1});
7676 indirect_field->setImplicit();
7679 field_pos->getAccess(), nested_indirect_field_decl->getAccess()));
7681 indirect_fields.push_back(indirect_field);
7689 if (last_field_pos != field_end_pos) {
7690 if (last_field_pos->getType()->isIncompleteArrayType())
7691 record_decl->hasFlexibleArrayMember();
7694 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7695 ife = indirect_fields.end();
7697 record_decl->addDecl(*ifi);
7710 record_decl->addAttr(
7711 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7726 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7730 clang::VarDecl *var_decl =
nullptr;
7731 clang::IdentifierInfo *ident =
nullptr;
7733 ident = &ast->getASTContext().Idents.get(name);
7736 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7737 var_decl->setDeclContext(record_decl);
7738 var_decl->setDeclName(ident);
7740 var_decl->setStorageClass(clang::SC_Static);
7745 var_decl->setAccess(
7747 record_decl->addDecl(var_decl);
7749 VerifyDecl(var_decl);
7755 VarDecl *var,
const llvm::APInt &init_value) {
7756 assert(!var->hasInit() &&
"variable already initialized");
7758 clang::ASTContext &ast = var->getASTContext();
7759 QualType qt = var->getType();
7760 assert(qt->isIntegralOrEnumerationType() &&
7761 "only integer or enum types supported");
7764 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7765 const EnumDecl *enum_decl = enum_type->getDecl()->getDefinitionOrSelf();
7766 qt = enum_decl->getIntegerType();
7770 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7771 var->setInit(CXXBoolLiteralExpr::Create(
7772 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7774 var->setInit(IntegerLiteral::Create(
7775 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7780 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7781 assert(!var->hasInit() &&
"variable already initialized");
7783 clang::ASTContext &ast = var->getASTContext();
7784 QualType qt = var->getType();
7785 assert(qt->isFloatingType() &&
"only floating point types supported");
7786 var->setInit(FloatingLiteral::Create(
7787 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7790llvm::SmallVector<clang::ParmVarDecl *>
7792 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7793 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7795 assert(parameter_names.empty() ||
7796 parameter_names.size() == prototype.getNumParams());
7798 llvm::SmallVector<clang::ParmVarDecl *> params;
7799 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7801 llvm::StringRef name =
7802 !parameter_names.empty() ? parameter_names[param_index] :
"";
7806 GetType(prototype.getParamType(param_index)),
7807 clang::SC_None,
false);
7810 params.push_back(param);
7818 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7820 bool is_explicit,
bool is_attr_used,
bool is_artificial) {
7821 if (!type || !method_clang_type.
IsValid() || name.empty())
7826 clang::CXXRecordDecl *cxx_record_decl =
7827 record_qual_type->getAsCXXRecordDecl();
7829 if (cxx_record_decl ==
nullptr)
7834 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7836 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7838 const clang::FunctionType *function_type =
7839 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7841 if (function_type ==
nullptr)
7844 const clang::FunctionProtoType *method_function_prototype(
7845 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7847 if (!method_function_prototype)
7850 unsigned int num_params = method_function_prototype->getNumParams();
7852 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7853 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7858 const clang::ExplicitSpecifier explicit_spec(
7859 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7860 : clang::ExplicitSpecKind::ResolvedFalse);
7862 if (name.starts_with(
"~")) {
7863 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7865 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7866 cxx_dtor_decl->setDeclName(
7869 cxx_dtor_decl->setType(method_qual_type);
7870 cxx_dtor_decl->setImplicit(is_artificial);
7871 cxx_dtor_decl->setInlineSpecified(is_inline);
7872 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7873 cxx_method_decl = cxx_dtor_decl;
7874 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7875 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7877 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7878 cxx_ctor_decl->setDeclName(
7881 cxx_ctor_decl->setType(method_qual_type);
7882 cxx_ctor_decl->setImplicit(is_artificial);
7883 cxx_ctor_decl->setInlineSpecified(is_inline);
7884 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7885 cxx_ctor_decl->setNumCtorInitializers(0);
7886 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7887 cxx_method_decl = cxx_ctor_decl;
7889 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7890 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7893 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7898 const bool is_method =
true;
7900 is_method, op_kind, num_params))
7902 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7904 cxx_method_decl->setDeclContext(cxx_record_decl);
7905 cxx_method_decl->setDeclName(
7906 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7907 cxx_method_decl->setType(method_qual_type);
7908 cxx_method_decl->setStorageClass(SC);
7909 cxx_method_decl->setInlineSpecified(is_inline);
7910 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7911 }
else if (num_params == 0) {
7913 auto *cxx_conversion_decl =
7914 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7916 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7917 cxx_conversion_decl->setDeclName(
7918 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7920 function_type->getReturnType())));
7921 cxx_conversion_decl->setType(method_qual_type);
7922 cxx_conversion_decl->setInlineSpecified(is_inline);
7923 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7924 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7925 cxx_method_decl = cxx_conversion_decl;
7929 if (cxx_method_decl ==
nullptr) {
7930 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7932 cxx_method_decl->setDeclContext(cxx_record_decl);
7933 cxx_method_decl->setDeclName(decl_name);
7934 cxx_method_decl->setType(method_qual_type);
7935 cxx_method_decl->setInlineSpecified(is_inline);
7936 cxx_method_decl->setStorageClass(SC);
7937 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7942 clang::AccessSpecifier access_specifier =
7945 cxx_method_decl->setAccess(access_specifier);
7946 cxx_method_decl->setVirtualAsWritten(is_virtual);
7949 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7951 if (!asm_label.empty())
7952 cxx_method_decl->addAttr(
7953 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7958 cxx_method_decl, *method_function_prototype, {}));
7965 cxx_record_decl->addDecl(cxx_method_decl);
7974 if (is_artificial) {
7975 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7976 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7977 (cxx_ctor_decl->isCopyConstructor() &&
7978 cxx_record_decl->hasTrivialCopyConstructor()) ||
7979 (cxx_ctor_decl->isMoveConstructor() &&
7980 cxx_record_decl->hasTrivialMoveConstructor()))) {
7981 cxx_ctor_decl->setDefaulted();
7982 cxx_ctor_decl->setTrivial(
true);
7983 }
else if (cxx_dtor_decl) {
7984 if (cxx_record_decl->hasTrivialDestructor()) {
7985 cxx_dtor_decl->setDefaulted();
7986 cxx_dtor_decl->setTrivial(
true);
7988 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7989 cxx_record_decl->hasTrivialCopyAssignment()) ||
7990 (cxx_method_decl->isMoveAssignmentOperator() &&
7991 cxx_record_decl->hasTrivialMoveAssignment())) {
7992 cxx_method_decl->setDefaulted();
7993 cxx_method_decl->setTrivial(
true);
7997 VerifyDecl(cxx_method_decl);
7999 return cxx_method_decl;
8005 for (
auto *method : record->methods())
8006 addOverridesForMethod(method);
8009#pragma mark C++ Base Classes
8011std::unique_ptr<clang::CXXBaseSpecifier>
8014 bool base_of_class) {
8018 return std::make_unique<clang::CXXBaseSpecifier>(
8019 clang::SourceRange(), is_virtual, base_of_class,
8022 clang::SourceLocation());
8027 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
8031 if (!cxx_record_decl)
8033 std::vector<clang::CXXBaseSpecifier *> raw_bases;
8034 raw_bases.reserve(bases.size());
8038 for (
auto &b : bases)
8039 raw_bases.push_back(b.get());
8040 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
8049 clang::ASTContext &clang_ast = ast->getASTContext();
8051 if (type && superclass_clang_type.
IsValid() &&
8053 clang::ObjCInterfaceDecl *class_interface_decl =
8055 clang::ObjCInterfaceDecl *super_interface_decl =
8057 if (class_interface_decl && super_interface_decl) {
8058 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
8059 clang_ast.getObjCInterfaceType(super_interface_decl)));
8068 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
8069 const char *property_setter_name,
const char *property_getter_name,
8071 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
8072 property_name[0] ==
'\0')
8077 clang::ASTContext &clang_ast = ast->getASTContext();
8080 if (!class_interface_decl)
8085 if (property_clang_type.
IsValid())
8086 property_clang_type_to_access = property_clang_type;
8088 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
8090 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
8093 clang::TypeSourceInfo *prop_type_source;
8095 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
8097 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
8100 clang::ObjCPropertyDecl *property_decl =
8101 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8102 property_decl->setDeclContext(class_interface_decl);
8103 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
8104 property_decl->setType(ivar_decl
8105 ? ivar_decl->getType()
8113 ast->SetMetadata(property_decl, metadata);
8115 class_interface_decl->addDecl(property_decl);
8117 clang::Selector setter_sel, getter_sel;
8119 if (property_setter_name) {
8120 std::string property_setter_no_colon(property_setter_name,
8121 strlen(property_setter_name) - 1);
8122 const clang::IdentifierInfo *setter_ident =
8123 &clang_ast.Idents.get(property_setter_no_colon);
8124 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8125 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
8126 std::string setter_sel_string(
"set");
8127 setter_sel_string.push_back(::toupper(property_name[0]));
8128 setter_sel_string.append(&property_name[1]);
8129 const clang::IdentifierInfo *setter_ident =
8130 &clang_ast.Idents.get(setter_sel_string);
8131 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8133 property_decl->setSetterName(setter_sel);
8134 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
8136 if (property_getter_name !=
nullptr) {
8137 const clang::IdentifierInfo *getter_ident =
8138 &clang_ast.Idents.get(property_getter_name);
8139 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8141 const clang::IdentifierInfo *getter_ident =
8142 &clang_ast.Idents.get(property_name);
8143 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8145 property_decl->setGetterName(getter_sel);
8146 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
8149 property_decl->setPropertyIvarDecl(ivar_decl);
8151 if (property_attributes & DW_APPLE_PROPERTY_readonly)
8152 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
8153 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
8154 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
8155 if (property_attributes & DW_APPLE_PROPERTY_assign)
8156 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
8157 if (property_attributes & DW_APPLE_PROPERTY_retain)
8158 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
8159 if (property_attributes & DW_APPLE_PROPERTY_copy)
8160 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
8161 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8162 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
8163 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
8164 property_decl->setPropertyAttributes(
8165 ObjCPropertyAttribute::kind_nullability);
8166 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
8167 property_decl->setPropertyAttributes(
8168 ObjCPropertyAttribute::kind_null_resettable);
8169 if (property_attributes & ObjCPropertyAttribute::kind_class)
8170 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8172 const bool isInstance =
8173 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8175 clang::ObjCMethodDecl *getter =
nullptr;
8176 if (!getter_sel.isNull())
8177 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8178 : class_interface_decl->lookupClassMethod(getter_sel);
8179 if (!getter_sel.isNull() && !getter) {
8180 const bool isVariadic =
false;
8181 const bool isPropertyAccessor =
true;
8182 const bool isSynthesizedAccessorStub =
false;
8183 const bool isImplicitlyDeclared =
true;
8184 const bool isDefined =
false;
8185 const clang::ObjCImplementationControl impControl =
8186 clang::ObjCImplementationControl::None;
8187 const bool HasRelatedResultType =
false;
8190 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8191 getter->setDeclName(getter_sel);
8193 getter->setDeclContext(class_interface_decl);
8194 getter->setInstanceMethod(isInstance);
8195 getter->setVariadic(isVariadic);
8196 getter->setPropertyAccessor(isPropertyAccessor);
8197 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8198 getter->setImplicit(isImplicitlyDeclared);
8199 getter->setDefined(isDefined);
8200 getter->setDeclImplementation(impControl);
8201 getter->setRelatedResultType(HasRelatedResultType);
8205 ast->SetMetadata(getter, metadata);
8207 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8208 llvm::ArrayRef<clang::SourceLocation>());
8209 class_interface_decl->addDecl(getter);
8213 getter->setPropertyAccessor(
true);
8214 property_decl->setGetterMethodDecl(getter);
8217 clang::ObjCMethodDecl *setter =
nullptr;
8218 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8219 : class_interface_decl->lookupClassMethod(setter_sel);
8220 if (!setter_sel.isNull() && !setter) {
8221 clang::QualType result_type = clang_ast.VoidTy;
8222 const bool isVariadic =
false;
8223 const bool isPropertyAccessor =
true;
8224 const bool isSynthesizedAccessorStub =
false;
8225 const bool isImplicitlyDeclared =
true;
8226 const bool isDefined =
false;
8227 const clang::ObjCImplementationControl impControl =
8228 clang::ObjCImplementationControl::None;
8229 const bool HasRelatedResultType =
false;
8232 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8233 setter->setDeclName(setter_sel);
8234 setter->setReturnType(result_type);
8235 setter->setDeclContext(class_interface_decl);
8236 setter->setInstanceMethod(isInstance);
8237 setter->setVariadic(isVariadic);
8238 setter->setPropertyAccessor(isPropertyAccessor);
8239 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8240 setter->setImplicit(isImplicitlyDeclared);
8241 setter->setDefined(isDefined);
8242 setter->setDeclImplementation(impControl);
8243 setter->setRelatedResultType(HasRelatedResultType);
8247 ast->SetMetadata(setter, metadata);
8249 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8250 params.push_back(clang::ParmVarDecl::Create(
8251 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8254 clang::SC_Auto,
nullptr));
8256 setter->setMethodParams(clang_ast,
8257 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8258 llvm::ArrayRef<clang::SourceLocation>());
8260 class_interface_decl->addDecl(setter);
8264 setter->setPropertyAccessor(
true);
8265 property_decl->setSetterMethodDecl(setter);
8276 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8277 bool is_objc_direct_call) {
8278 if (!type || !method_clang_type.
IsValid())
8283 if (class_interface_decl ==
nullptr)
8286 if (lldb_ast ==
nullptr)
8288 clang::ASTContext &ast = lldb_ast->getASTContext();
8290 const char *selector_start = ::strchr(name,
' ');
8291 if (selector_start ==
nullptr)
8295 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8300 unsigned num_selectors_with_args = 0;
8301 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8303 len = ::strcspn(start,
":]");
8304 bool has_arg = (start[len] ==
':');
8306 ++num_selectors_with_args;
8307 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8312 if (selector_idents.size() == 0)
8315 clang::Selector method_selector = ast.Selectors.getSelector(
8316 num_selectors_with_args ? selector_idents.size() : 0,
8317 selector_idents.data());
8322 const clang::Type *method_type(method_qual_type.getTypePtr());
8324 if (method_type ==
nullptr)
8327 const clang::FunctionProtoType *method_function_prototype(
8328 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8330 if (!method_function_prototype)
8333 const bool isInstance = (name[0] ==
'-');
8334 const bool isVariadic = is_variadic;
8335 const bool isPropertyAccessor =
false;
8336 const bool isSynthesizedAccessorStub =
false;
8338 const bool isImplicitlyDeclared =
true;
8339 const bool isDefined =
false;
8340 const clang::ObjCImplementationControl impControl =
8341 clang::ObjCImplementationControl::None;
8342 const bool HasRelatedResultType =
false;
8344 const unsigned num_args = method_function_prototype->getNumParams();
8346 if (num_args != num_selectors_with_args)
8350 auto *objc_method_decl =
8351 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8352 objc_method_decl->setDeclName(method_selector);
8353 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8354 objc_method_decl->setDeclContext(
8356 objc_method_decl->setInstanceMethod(isInstance);
8357 objc_method_decl->setVariadic(isVariadic);
8358 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8359 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8360 objc_method_decl->setImplicit(isImplicitlyDeclared);
8361 objc_method_decl->setDefined(isDefined);
8362 objc_method_decl->setDeclImplementation(impControl);
8363 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8366 if (objc_method_decl ==
nullptr)
8370 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8372 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8373 params.push_back(clang::ParmVarDecl::Create(
8374 ast, objc_method_decl, clang::SourceLocation(),
8375 clang::SourceLocation(),
8377 method_function_prototype->getParamType(param_index),
nullptr,
8378 clang::SC_Auto,
nullptr));
8381 objc_method_decl->setMethodParams(
8382 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8383 llvm::ArrayRef<clang::SourceLocation>());
8386 if (is_objc_direct_call) {
8389 objc_method_decl->addAttr(
8390 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8395 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8398 class_interface_decl->addDecl(objc_method_decl);
8400 VerifyDecl(objc_method_decl);
8402 return objc_method_decl;
8412 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8413 switch (type_class) {
8414 case clang::Type::Record: {
8415 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8416 if (cxx_record_decl) {
8417 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8418 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8423 case clang::Type::Enum: {
8424 clang::EnumDecl *enum_decl =
8425 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8427 enum_decl->setHasExternalLexicalStorage(has_extern);
8428 enum_decl->setHasExternalVisibleStorage(has_extern);
8433 case clang::Type::ObjCObject:
8434 case clang::Type::ObjCInterface: {
8435 const clang::ObjCObjectType *objc_class_type =
8436 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8437 assert(objc_class_type);
8438 if (objc_class_type) {
8439 clang::ObjCInterfaceDecl *class_interface_decl =
8440 objc_class_type->getInterface();
8442 if (class_interface_decl) {
8443 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8444 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8460 if (!qual_type.isNull()) {
8461 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8463 clang::TagDecl *tag_decl = tag_type->getDecl();
8465 tag_decl->startDefinition();
8470 const clang::ObjCObjectType *object_type =
8471 qual_type->getAs<clang::ObjCObjectType>();
8473 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8474 if (interface_decl) {
8475 interface_decl->startDefinition();
8486 if (qual_type.isNull())
8490 if (lldb_ast ==
nullptr)
8496 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8498 clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinitionOrSelf();
8500 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8510 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8511 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8512 if (cxx_record_decl->needsImplicitCopyConstructor())
8513 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8514 if (cxx_record_decl->needsImplicitCopyAssignment())
8515 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8518 if (!cxx_record_decl->isCompleteDefinition())
8519 cxx_record_decl->completeDefinition();
8520 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8521 cxx_record_decl->setHasExternalLexicalStorage(
false);
8522 cxx_record_decl->setHasExternalVisibleStorage(
false);
8523 lldb_ast->SetCXXRecordDeclAccess(cxx_record_decl,
8524 clang::AccessSpecifier::AS_none);
8529 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8533 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8535 if (enum_decl->isCompleteDefinition())
8538 QualType integer_type(enum_decl->getIntegerType());
8539 if (!integer_type.isNull()) {
8540 clang::ASTContext &ast = lldb_ast->getASTContext();
8542 unsigned NumNegativeBits = 0;
8543 unsigned NumPositiveBits = 0;
8544 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8547 clang::QualType BestPromotionType;
8548 clang::QualType BestType;
8549 ast.computeBestEnumTypes(
false, NumNegativeBits,
8550 NumPositiveBits, BestType, BestPromotionType);
8552 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8553 BestPromotionType, NumPositiveBits,
8561 const llvm::APSInt &value) {
8572 if (!enum_opaque_compiler_type)
8575 clang::QualType enum_qual_type(
8578 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8583 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8588 clang::EnumConstantDecl *enumerator_decl =
8589 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8591 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8592 enumerator_decl->setDeclContext(enum_decl);
8593 if (name && name[0])
8594 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8595 enumerator_decl->setType(clang::QualType(enutype, 0));
8597 enumerator_decl->setAccess(AS_public);
8603 enum_decl->addDecl(enumerator_decl);
8605 VerifyDecl(enumerator_decl);
8606 return enumerator_decl;
8611 uint64_t enum_value, uint32_t enum_value_bit_size) {
8613 llvm::APSInt value(enum_value_bit_size,
8622 const clang::Type *clang_type = qt.getTypePtrOrNull();
8623 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8627 return GetType(enum_type->getDecl()->getDefinitionOrSelf()->getIntegerType());
8633 if (type && pointee_type.
IsValid() &&
8638 return ast->GetType(ast->getASTContext().getMemberPointerType(
8647#define DEPTH_INCREMENT 2
8650LLVM_DUMP_METHOD
void
8660struct ScopedASTColor {
8661 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8662 : ast(ast), old_show_colors(ast.getDiagnostics().getShowColors()) {
8663 ast.getDiagnostics().setShowColors(show_colors);
8666 ~ScopedASTColor() { ast.getDiagnostics().setShowColors(old_show_colors); }
8668 clang::ASTContext *
8669 const bool old_show_colors;
8678 clang::CreateASTDumper(output, filter,
8682 false, clang::ADOF_Default);
8685 consumer->HandleTranslationUnit(*
m_ast_up);
8689 llvm::StringRef symbol_name) {
8696 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8697 size_t ntypes = type_list.
GetSize();
8699 for (
size_t i = 0; i < ntypes; ++i) {
8702 if (!symbol_name.empty())
8703 if (symbol_name != type->GetName().GetStringRef())
8706 s << type->GetName().AsCString() <<
"\n";
8709 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8717 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8719 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8731 size_t byte_size, uint32_t bitfield_bit_offset,
8732 uint32_t bitfield_bit_size) {
8733 const clang::EnumType *enutype =
8734 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8735 const clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8737 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8738 const uint64_t enum_svalue =
8741 bitfield_bit_offset)
8743 bitfield_bit_offset);
8744 bool can_be_bitfield =
true;
8745 uint64_t covered_bits = 0;
8746 int num_enumerators = 0;
8754 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8755 if (enumerators.empty())
8756 can_be_bitfield =
false;
8758 for (
auto *enumerator : enumerators) {
8759 llvm::APSInt init_val = enumerator->getInitVal();
8760 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8761 : init_val.getZExtValue();
8762 if (qual_type_is_signed)
8763 val = llvm::SignExtend64(val, 8 * byte_size);
8764 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8765 can_be_bitfield =
false;
8766 covered_bits |= val;
8768 if (val == enum_svalue) {
8777 offset = byte_offset;
8779 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8783 if (!can_be_bitfield) {
8784 if (qual_type_is_signed)
8785 s.
Printf(
"%" PRIi64, enum_svalue);
8787 s.
Printf(
"%" PRIu64, enum_uvalue);
8794 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8798 uint64_t remaining_value = enum_uvalue;
8799 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8800 values.reserve(num_enumerators);
8801 for (
auto *enumerator : enum_decl->enumerators())
8802 if (
auto val = enumerator->getInitVal().getZExtValue())
8803 values.emplace_back(val, enumerator->getName());
8808 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8809 return llvm::popcount(a.first) > llvm::popcount(b.first);
8812 for (
const auto &val : values) {
8813 if ((remaining_value & val.first) != val.first)
8815 remaining_value &= ~val.first;
8817 if (remaining_value)
8823 if (remaining_value)
8824 s.
Printf(
"0x%" PRIx64, remaining_value);
8832 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8841 switch (qual_type->getTypeClass()) {
8842 case clang::Type::Typedef: {
8843 clang::QualType typedef_qual_type =
8844 llvm::cast<clang::TypedefType>(qual_type)
8846 ->getUnderlyingType();
8849 format = typedef_clang_type.
GetFormat();
8850 clang::TypeInfo typedef_type_info =
8852 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8862 bitfield_bit_offset,
8867 case clang::Type::Enum:
8872 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8873 bitfield_bit_offset, bitfield_bit_size);
8881 uint32_t item_count = 1;
8921 item_count = byte_size;
8926 item_count = byte_size / 2;
8931 item_count = byte_size / 4;
8937 bitfield_bit_size, bitfield_bit_offset,
8953 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(clang_type)) {
8962 clang::QualType qual_type =
8965 llvm::SmallVector<char, 1024> buf;
8966 llvm::raw_svector_ostream llvm_ostrm(buf);
8968 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8969 switch (type_class) {
8970 case clang::Type::ObjCObject:
8971 case clang::Type::ObjCInterface: {
8974 auto *objc_class_type =
8975 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8976 assert(objc_class_type);
8977 if (!objc_class_type)
8979 clang::ObjCInterfaceDecl *class_interface_decl =
8980 objc_class_type->getInterface();
8981 if (!class_interface_decl)
8984 class_interface_decl->dump(llvm_ostrm);
8986 class_interface_decl->print(llvm_ostrm,
8991 case clang::Type::Typedef: {
8992 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8995 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
8997 typedef_decl->dump(llvm_ostrm);
9000 if (!clang_typedef_name.empty()) {
9007 case clang::Type::Record: {
9010 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
9011 const clang::RecordDecl *record_decl = record_type->getDecl();
9013 record_decl->dump(llvm_ostrm);
9015 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
9021 if (
auto *tag_type =
9022 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
9023 if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
9025 tag_decl->dump(llvm_ostrm);
9027 tag_decl->print(llvm_ostrm, 0);
9033 std::string clang_type_name(qual_type.getAsString());
9034 if (!clang_type_name.empty())
9041 if (buf.size() > 0) {
9042 s.
Write(buf.data(), buf.size());
9049 clang::QualType qual_type(
9052 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
9053 switch (type_class) {
9054 case clang::Type::Record: {
9055 const clang::CXXRecordDecl *cxx_record_decl =
9056 qual_type->getAsCXXRecordDecl();
9057 if (cxx_record_decl)
9058 printf(
"class %s", cxx_record_decl->getName().str().c_str());
9061 case clang::Type::Enum: {
9062 clang::EnumDecl *enum_decl =
9063 llvm::cast<clang::EnumType>(qual_type)->getDecl();
9065 printf(
"enum %s", enum_decl->getName().str().c_str());
9069 case clang::Type::ObjCObject:
9070 case clang::Type::ObjCInterface: {
9071 const clang::ObjCObjectType *objc_class_type =
9072 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
9073 if (objc_class_type) {
9074 clang::ObjCInterfaceDecl *class_interface_decl =
9075 objc_class_type->getInterface();
9079 if (class_interface_decl)
9080 printf(
"@class %s", class_interface_decl->getName().str().c_str());
9084 case clang::Type::Typedef:
9085 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
9092 case clang::Type::Auto:
9095 llvm::cast<clang::AutoType>(qual_type)
9097 .getAsOpaquePtr()));
9099 case clang::Type::Paren:
9103 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
9106 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
9116 if (template_param_infos.
IsValid()) {
9117 std::string template_basename(parent_name);
9119 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
9120 template_basename.erase(i);
9123 template_basename.c_str(), tag_decl_kind,
9124 template_param_infos);
9139 clang::ObjCInterfaceDecl *decl) {
9167 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9168 uint64_t &alignment,
9169 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9170 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9172 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9185 field_offsets, base_offsets, vbase_offsets);
9192 clang::NamedDecl *nd =
9193 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9203 if (!label_or_err) {
9204 llvm::consumeError(label_or_err.takeError());
9208 llvm::StringRef mangled = label_or_err->lookup_name;
9216 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9217 static_cast<clang::Decl *
>(opaque_decl));
9219 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9223 if (!mc || !mc->shouldMangleCXXName(nd))
9228 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9233 llvm::SmallVector<char, 1024> buf;
9234 llvm::raw_svector_ostream llvm_ostrm(buf);
9235 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9237 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9240 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9242 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9246 mc->mangleName(nd, llvm_ostrm);
9262 if (clang::FunctionDecl *func_decl =
9263 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9264 return GetType(func_decl->getReturnType());
9265 if (clang::ObjCMethodDecl *objc_method =
9266 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9267 return GetType(objc_method->getReturnType());
9273 if (clang::FunctionDecl *func_decl =
9274 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9275 return func_decl->param_size();
9276 if (clang::ObjCMethodDecl *objc_method =
9277 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9278 return objc_method->param_size();
9284 clang::DeclContext
const *decl_ctx) {
9285 switch (clang_kind) {
9286 case Decl::TranslationUnit:
9288 case Decl::Namespace:
9299 if (decl_ctx->isFunctionOrMethod())
9301 if (decl_ctx->isRecord())
9311 std::vector<lldb_private::CompilerContext> &context) {
9312 if (decl_ctx ==
nullptr)
9315 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9316 if (clang_kind == Decl::TranslationUnit)
9321 context.push_back({compiler_kind, decl_ctx_name});
9324std::vector<lldb_private::CompilerContext>
9326 std::vector<lldb_private::CompilerContext> context;
9329 clang::Decl *decl = (clang::Decl *)opaque_decl;
9331 clang::DeclContext *decl_ctx = decl->getDeclContext();
9334 auto compiler_kind =
9336 context.push_back({compiler_kind, decl_name});
9343 if (clang::FunctionDecl *func_decl =
9344 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9345 if (idx < func_decl->param_size()) {
9346 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9348 return GetType(var_decl->getOriginalType());
9350 }
else if (clang::ObjCMethodDecl *objc_method =
9351 llvm::dyn_cast<clang::ObjCMethodDecl>(
9352 (clang::Decl *)opaque_decl)) {
9353 if (idx < objc_method->param_size())
9354 return GetType(objc_method->parameters()[idx]->getOriginalType());
9360 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9361 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9364 clang::Expr *init_expr = var_decl->getInit();
9367 std::optional<llvm::APSInt> value =
9377 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9378 std::vector<CompilerDecl> found_decls;
9380 if (opaque_decl_ctx && symbol_file) {
9381 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9382 std::set<DeclContext *> searched;
9383 std::multimap<DeclContext *, DeclContext *> search_queue;
9385 for (clang::DeclContext *decl_context = root_decl_ctx;
9386 decl_context !=
nullptr && found_decls.empty();
9387 decl_context = decl_context->getParent()) {
9388 search_queue.insert(std::make_pair(decl_context, decl_context));
9390 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9392 if (!searched.insert(it->second).second)
9397 for (clang::Decl *child : it->second->decls()) {
9398 if (clang::UsingDirectiveDecl *ud =
9399 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9400 if (ignore_using_decls)
9402 clang::DeclContext *from = ud->getCommonAncestor();
9403 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9404 search_queue.insert(
9405 std::make_pair(from, ud->getNominatedNamespace()));
9406 }
else if (clang::UsingDecl *ud =
9407 llvm::dyn_cast<clang::UsingDecl>(child)) {
9408 if (ignore_using_decls)
9410 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9411 clang::Decl *target = usd->getTargetDecl();
9412 if (clang::NamedDecl *nd =
9413 llvm::dyn_cast<clang::NamedDecl>(target)) {
9414 IdentifierInfo *ii = nd->getIdentifier();
9415 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9419 }
else if (clang::NamedDecl *nd =
9420 llvm::dyn_cast<clang::NamedDecl>(child)) {
9421 IdentifierInfo *ii = nd->getIdentifier();
9422 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9473 clang::DeclContext *child_decl_ctx,
9477 if (frame_decl_ctx && symbol_file) {
9478 std::set<DeclContext *> searched;
9479 std::multimap<DeclContext *, DeclContext *> search_queue;
9482 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9486 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9487 decl_ctx = decl_ctx->getParent()) {
9488 if (!decl_ctx->isLookupContext())
9490 if (decl_ctx == parent_decl_ctx)
9493 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9494 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9496 if (searched.find(it->second) != searched.end())
9504 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9507 searched.insert(it->second);
9511 for (clang::Decl *child : it->second->decls()) {
9512 if (clang::UsingDirectiveDecl *ud =
9513 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9514 clang::DeclContext *ns = ud->getNominatedNamespace();
9515 if (ns == parent_decl_ctx)
9518 clang::DeclContext *from = ud->getCommonAncestor();
9519 if (searched.find(ns) == searched.end())
9520 search_queue.insert(std::make_pair(from, ns));
9521 }
else if (child_name) {
9522 if (clang::UsingDecl *ud =
9523 llvm::dyn_cast<clang::UsingDecl>(child)) {
9524 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9525 clang::Decl *target = usd->getTargetDecl();
9526 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9530 IdentifierInfo *ii = nd->getIdentifier();
9531 if (ii ==
nullptr ||
9532 ii->getName() != child_name->
AsCString(
nullptr))
9555 if (opaque_decl_ctx) {
9556 clang::NamedDecl *named_decl =
9557 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9560 llvm::raw_string_ostream stream{name};
9562 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9563 named_decl->getNameForDiagnostic(stream, policy,
false);
9572 if (opaque_decl_ctx) {
9573 clang::NamedDecl *named_decl =
9574 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9582 if (!opaque_decl_ctx)
9585 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9586 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9588 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9590 }
else if (clang::FunctionDecl *fun_decl =
9591 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9592 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9593 return metadata->HasObjectPtr();
9599std::vector<lldb_private::CompilerContext>
9601 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9602 std::vector<lldb_private::CompilerContext> context;
9608 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9609 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9610 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9614 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9615 if (DC->isInlineNamespace())
9618 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9619 return NS->isAnonymousNamespace();
9626 if (decl_ctx == other)
9628 }
while (is_transparent_lookup_allowed(other) &&
9629 (other = other->getParent()));
9636 if (!opaque_decl_ctx)
9639 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9640 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9642 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9644 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9645 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9646 return metadata->GetObjectPtrLanguage();
9666 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9674 return llvm::dyn_cast<clang::CXXMethodDecl>(
9679clang::FunctionDecl *
9682 return llvm::dyn_cast<clang::FunctionDecl>(
9687clang::NamespaceDecl *
9690 return llvm::dyn_cast<clang::NamespaceDecl>(
9695std::optional<ClangASTMetadata>
9697 const Decl *
object) {
9705 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9727 lldbassert(started &&
"Unable to start a class type definition.");
9732 ts->SetDeclIsForcefullyCompleted(td);
9746 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9747 std::unique_ptr<ClangASTSource> ast_source)
9749 m_scratch_ast_source_up(std::move(ast_source)) {
9751 m_scratch_ast_source_up->InstallASTContext(*
this);
9752 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9753 m_scratch_ast_source_up->CreateProxy();
9754 SetExternalSource(proxy_ast_source);
9758 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9766 llvm::Triple triple)
9773 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9785 std::optional<IsolatedASTKind> ast_kind,
9786 bool create_on_demand) {
9789 if (
auto err = type_system_or_err.takeError()) {
9791 "Couldn't get scratch TypeSystemClang: {0}");
9794 auto ts_sp = *type_system_or_err;
9796 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9801 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9803 return std::static_pointer_cast<TypeSystemClang>(
9808static llvm::StringRef
9812 return "C++ modules";
9814 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9818 llvm::StringRef filter,
bool show_color) {
9820 output <<
"State of scratch Clang type system:\n";
9824 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9825 std::vector<KeyAndTS> sorted_typesystems;
9827 sorted_typesystems.emplace_back(a.first, a.second.get());
9828 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9831 for (
const auto &a : sorted_typesystems) {
9834 output <<
"State of scratch Clang type subsystem "
9836 a.second->Dump(output, filter, show_color);
9841 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9849 desired_type, options, ctx_obj);
9854 const ValueList &arg_value_list,
const char *name) {
9859 Process *process = target_sp->GetProcessSP().get();
9864 arg_value_list, name);
9867std::unique_ptr<UtilityFunction>
9874 return std::make_unique<ClangUtilityFunction>(
9875 *target_sp.get(), std::move(text), std::move(name),
9876 target_sp->GetDebugUtilityExpression());
9890 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9894 return std::make_unique<ClangASTSource>(
9899static llvm::StringRef
9903 return "scratch ASTContext for C++ module types";
9905 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9912 return *found_ast->second;
9915 std::shared_ptr<TypeSystemClang> new_ast_sp =
9925 const clang::RecordType *record_type =
9926 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9928 const clang::RecordDecl *record_decl =
9929 record_type->getDecl()->getDefinitionOrSelf();
9930 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9931 return metadata->IsForcefullyCompleted();
9940 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9944 metadata->SetIsForcefullyCompleted();
9952 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
lldb::BasicType GetBasicTypeEnumeration() const
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
void SetCompilerType(lldb::TypeSystemWP type_system, lldb::opaque_compiler_type_t type)
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
lldb::Encoding GetEncoding() const
bool IsPromotableIntegerType() const
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
bool IsInteger() const
This is used when you don't care about the signedness of the integer.
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.
bool IsUnscopedEnumerationType() const
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.
CompilerType GetCanonicalType() const
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 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)
lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type) override
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
llvm::Expected< CompilerType > DoIntegralPromotion(CompilerType from, ExecutionContextScope *exe_scope) override
Perform integral promotion on a given type.
static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc)
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)
bool IsFloatingPointType(lldb::opaque_compiler_type_t type, bool &is_complex) override
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
bool IsPromotableIntegerType(lldb::opaque_compiler_type_t type) override
Checks if the type is eligible for integral promotion.
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.