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())
912 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
931 return GetType(ast.UnsignedCharTy);
933 return GetType(ast.UnsignedShortTy);
935 return GetType(ast.UnsignedIntTy);
940 if (type_name.contains(
"complex")) {
949 case DW_ATE_complex_float: {
950 CanQualType FloatComplexTy = ast.getComplexType(ast.FloatTy);
952 return GetType(FloatComplexTy);
954 CanQualType DoubleComplexTy = ast.getComplexType(ast.DoubleTy);
956 return GetType(DoubleComplexTy);
958 CanQualType LongDoubleComplexTy = ast.getComplexType(ast.LongDoubleTy);
960 return GetType(LongDoubleComplexTy);
970 if (type_name ==
"float" &&
973 if (type_name ==
"double" &&
976 if (type_name ==
"long double" &&
978 return GetType(ast.LongDoubleTy);
979 if (type_name ==
"__bf16" &&
981 return GetType(ast.BFloat16Ty);
982 if (type_name ==
"_Float16" &&
988 if ((type_name ==
"__float128" || type_name ==
"_Float128" ||
989 type_name ==
"f128") &&
991 return GetType(ast.Float128Ty);
998 return GetType(ast.LongDoubleTy);
1002 return GetType(ast.Float128Ty);
1006 if (!type_name.empty()) {
1007 if (type_name.starts_with(
"_BitInt"))
1008 return GetType(ast.getBitIntType(
false, bit_size));
1009 if (type_name ==
"wchar_t" &&
1014 if (type_name ==
"void" &&
1017 if (type_name.contains(
"long long") &&
1019 return GetType(ast.LongLongTy);
1020 if (type_name.contains(
"long") &&
1023 if (type_name.contains(
"short") &&
1026 if (type_name.contains(
"char")) {
1030 return GetType(ast.SignedCharTy);
1032 if (type_name.contains(
"int")) {
1049 return GetType(ast.LongLongTy);
1054 case DW_ATE_signed_char:
1055 if (type_name ==
"char") {
1060 return GetType(ast.SignedCharTy);
1063 case DW_ATE_unsigned:
1064 if (!type_name.empty()) {
1065 if (type_name.starts_with(
"unsigned _BitInt"))
1066 return GetType(ast.getBitIntType(
true, bit_size));
1067 if (type_name ==
"wchar_t") {
1074 if (type_name.contains(
"long long")) {
1076 return GetType(ast.UnsignedLongLongTy);
1077 }
else if (type_name.contains(
"long")) {
1079 return GetType(ast.UnsignedLongTy);
1080 }
else if (type_name.contains(
"short")) {
1082 return GetType(ast.UnsignedShortTy);
1083 }
else if (type_name.contains(
"char")) {
1085 return GetType(ast.UnsignedCharTy);
1086 }
else if (type_name.contains(
"int")) {
1088 return GetType(ast.UnsignedIntTy);
1090 return GetType(ast.UnsignedInt128Ty);
1095 return GetType(ast.UnsignedCharTy);
1097 return GetType(ast.UnsignedShortTy);
1099 return GetType(ast.UnsignedIntTy);
1101 return GetType(ast.UnsignedLongTy);
1103 return GetType(ast.UnsignedLongLongTy);
1105 return GetType(ast.UnsignedInt128Ty);
1108 case DW_ATE_unsigned_char:
1109 if (type_name ==
"char") {
1114 return GetType(ast.UnsignedCharTy);
1116 return GetType(ast.UnsignedShortTy);
1119 case DW_ATE_imaginary_float:
1131 if (!type_name.empty()) {
1132 if (type_name ==
"char16_t")
1134 if (type_name ==
"char32_t")
1136 if (type_name ==
"char8_t")
1145 "error: need to add support for DW_TAG_base_type '{0}' "
1146 "encoded with DW_ATE = {1:x}, bit_size = {2}",
1147 type_name, dw_ate, bit_size);
1153 QualType char_type(ast.CharTy);
1156 char_type.addConst();
1158 return GetType(ast.getPointerType(char_type));
1162 bool ignore_qualifiers) {
1173 if (ignore_qualifiers) {
1174 type1_qual = type1_qual.getUnqualifiedType();
1175 type2_qual = type2_qual.getUnqualifiedType();
1178 return ast->getASTContext().hasSameType(type1_qual, type2_qual);
1185 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
1186 if (
auto *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl))
1198 if (clang::ObjCInterfaceDecl *interface_decl =
1199 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
1201 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
1203 if (clang::ValueDecl *value_decl = llvm::dyn_cast<clang::ValueDecl>(decl))
1217 return GetType(value_decl->getType());
1220#pragma mark Structure, Unions, Classes
1224 if (!decl || !owning_module.
HasValue())
1227 decl->setFromASTFile();
1228 decl->setOwningModuleID(owning_module.
GetValue());
1229 decl->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
1235 bool is_framework,
bool is_explicit) {
1237 auto *ast_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1239 assert(ast_source &&
"external ast source was lost");
1257 clang::Module *module;
1258 auto parent_desc = ast_source->getSourceDescriptor(parent.
GetValue());
1260 name, parent_desc ? parent_desc->getModuleOrNull() :
nullptr,
1261 is_framework, is_explicit);
1263 return ast_source->GetIDForModule(module);
1265 return ast_source->RegisterModule(module);
1270 AccessType access_type, llvm::StringRef name,
int kind,
1271 LanguageType language, std::optional<ClangASTMetadata> metadata,
1272 bool exports_symbols) {
1275 if (decl_ctx ==
nullptr)
1276 decl_ctx = ast.getTranslationUnitDecl();
1280 bool isInternal =
false;
1281 return CreateObjCClass(name, decl_ctx, owning_module, isInternal, metadata);
1290 bool has_name = !name.empty();
1291 CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1292 decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1293 decl->setDeclContext(decl_ctx);
1295 decl->setDeclName(&ast.Idents.get(name));
1323 if (isa<CXXRecordDecl>(decl_ctx) && exports_symbols)
1324 decl->setAnonymousStructOrUnion(
true);
1334 decl_ctx->addDecl(decl);
1336 return GetType(ast.getCanonicalTagType(decl));
1343QualType GetValueParamType(
const clang::TemplateArgument &argument) {
1344 switch (argument.getKind()) {
1345 case TemplateArgument::Integral:
1346 return argument.getIntegralType();
1347 case TemplateArgument::StructuralValue:
1348 return argument.getStructuralValueType();
1354void AddAccessSpecifierDecl(clang::CXXRecordDecl *cxx_record_decl,
1356 clang::AccessSpecifier previous_access,
1357 clang::AccessSpecifier access_specifier) {
1358 if (!cxx_record_decl->isClass() && !cxx_record_decl->isStruct())
1360 if (previous_access != access_specifier) {
1363 if ((cxx_record_decl->isStruct() &&
1364 previous_access == clang::AccessSpecifier::AS_none &&
1365 access_specifier == clang::AccessSpecifier::AS_public) ||
1366 (cxx_record_decl->isClass() &&
1367 previous_access == clang::AccessSpecifier::AS_none &&
1368 access_specifier == clang::AccessSpecifier::AS_private)) {
1371 cxx_record_decl->addDecl(
1372 AccessSpecDecl::Create(ct, access_specifier, cxx_record_decl,
1373 SourceLocation(), SourceLocation()));
1381 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1382 const bool parameter_pack =
false;
1383 const bool is_typename =
false;
1384 const unsigned depth = 0;
1385 const size_t num_template_params = template_param_infos.
Size();
1386 DeclContext *
const decl_context =
1387 ast.getTranslationUnitDecl();
1389 auto const &args = template_param_infos.
GetArgs();
1390 auto const &names = template_param_infos.
GetNames();
1391 for (
size_t i = 0; i < num_template_params; ++i) {
1392 const char *name = names[i];
1394 IdentifierInfo *identifier_info =
nullptr;
1395 if (name && name[0])
1396 identifier_info = &ast.Idents.get(name);
1397 TemplateArgument
const &targ = args[i];
1398 QualType template_param_type = GetValueParamType(targ);
1399 if (!template_param_type.isNull()) {
1400 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1401 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1402 identifier_info, template_param_type, parameter_pack,
1403 ast.getTrivialTypeSourceInfo(template_param_type)));
1405 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1406 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1407 identifier_info, is_typename, parameter_pack));
1412 IdentifierInfo *identifier_info =
nullptr;
1414 identifier_info = &ast.Idents.get(template_param_infos.
GetPackName());
1415 const bool parameter_pack_true =
true;
1417 QualType template_param_type =
1421 if (!template_param_type.isNull()) {
1422 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1423 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1424 num_template_params, identifier_info, template_param_type,
1425 parameter_pack_true,
1426 ast.getTrivialTypeSourceInfo(template_param_type)));
1428 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1429 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1430 num_template_params, identifier_info, is_typename,
1431 parameter_pack_true));
1434 clang::Expr *
const requires_clause =
nullptr;
1435 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1436 ast, SourceLocation(), SourceLocation(), template_param_decls,
1437 SourceLocation(), requires_clause);
1438 return template_param_list;
1443 clang::FunctionDecl *func_decl,
1448 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1450 ast, template_param_infos, template_param_decls);
1451 FunctionTemplateDecl *func_tmpl_decl =
1452 FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1453 func_tmpl_decl->setDeclContext(decl_ctx);
1454 func_tmpl_decl->setLocation(func_decl->getLocation());
1455 func_tmpl_decl->setDeclName(func_decl->getDeclName());
1456 func_tmpl_decl->setTemplateParameters(template_param_list);
1457 func_tmpl_decl->init(func_decl);
1460 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1461 i < template_param_decl_count; ++i) {
1463 template_param_decls[i]->setDeclContext(func_decl);
1468 if (decl_ctx->isRecord())
1469 func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
1471 return func_tmpl_decl;
1475 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1477 TemplateArgumentList *template_args_ptr = TemplateArgumentList::CreateCopy(
1478 func_decl->getASTContext(), infos.
GetArgs());
1480 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
1481 template_args_ptr,
nullptr);
1488 const TemplateArgument &value) {
1489 if (llvm::isa<TemplateTypeParmDecl>(param)) {
1491 if (value.getKind() != TemplateArgument::Type)
1493 }
else if (
auto *type_param =
1494 llvm::dyn_cast<NonTypeTemplateParmDecl>(param)) {
1496 QualType value_param_type = GetValueParamType(value);
1497 if (value_param_type.isNull())
1501 if (type_param->getType() != value_param_type)
1509 "Don't know how to compare template parameter to passed"
1510 " value. Decl kind of parameter is: {0}",
1511 param->getDeclKindName());
1512 lldbassert(
false &&
"Can't compare this TemplateParmDecl subclass");
1527 ClassTemplateDecl *class_template_decl,
1530 TemplateParameterList ¶ms = *class_template_decl->getTemplateParameters();
1536 std::optional<NamedDecl *> pack_parameter;
1538 size_t non_pack_params = params.size();
1539 for (
size_t i = 0; i < params.size(); ++i) {
1540 NamedDecl *param = params.getParam(i);
1541 if (param->isParameterPack()) {
1542 pack_parameter = param;
1543 non_pack_params = i;
1551 if (non_pack_params != instantiation_values.
Size())
1569 for (
const auto pair :
1570 llvm::zip_first(instantiation_values.
GetArgs(), params)) {
1571 const TemplateArgument &passed_arg = std::get<0>(pair);
1572 NamedDecl *found_param = std::get<1>(pair);
1577 return class_template_decl;
1586 ClassTemplateDecl *class_template_decl =
nullptr;
1587 if (decl_ctx ==
nullptr)
1588 decl_ctx = ast.getTranslationUnitDecl();
1590 IdentifierInfo &identifier_info = ast.Idents.get(class_name);
1591 DeclarationName decl_name(&identifier_info);
1594 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1595 for (NamedDecl *decl : result) {
1596 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1597 if (!class_template_decl)
1606 template_param_infos))
1608 return class_template_decl;
1611 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1614 ast, template_param_infos, template_param_decls);
1616 CXXRecordDecl *template_cxx_decl =
1617 CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1618 template_cxx_decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1620 template_cxx_decl->setDeclContext(decl_ctx);
1621 template_cxx_decl->setDeclName(decl_name);
1624 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1625 i < template_param_decl_count; ++i) {
1626 template_param_decls[i]->setDeclContext(template_cxx_decl);
1634 class_template_decl =
1635 ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1637 class_template_decl->setDeclContext(decl_ctx);
1638 class_template_decl->setDeclName(decl_name);
1639 class_template_decl->setTemplateParameters(template_param_list);
1640 class_template_decl->init(template_cxx_decl);
1641 template_cxx_decl->setDescribedClassTemplate(class_template_decl);
1645 class_template_decl->setAccess(
1648 decl_ctx->addDecl(class_template_decl);
1650 VerifyDecl(class_template_decl);
1652 return class_template_decl;
1655TemplateTemplateParmDecl *
1659 auto *decl_ctx = ast.getTranslationUnitDecl();
1661 IdentifierInfo &identifier_info = ast.Idents.get(template_name);
1662 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1666 ast, template_param_infos, template_param_decls);
1672 return TemplateTemplateParmDecl::Create(
1673 ast, decl_ctx, SourceLocation(),
1675 false, &identifier_info,
1676 TemplateNameKind::TNK_Type_template,
true,
1677 template_param_list);
1680ClassTemplateSpecializationDecl *
1683 ClassTemplateDecl *class_template_decl,
int kind,
1686 llvm::SmallVector<clang::TemplateArgument, 2> args(
1687 template_param_infos.
Size() +
1690 auto const &orig_args = template_param_infos.
GetArgs();
1691 std::copy(orig_args.begin(), orig_args.end(), args.begin());
1693 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1696 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1697 ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
1698 class_template_specialization_decl->setTagKind(
1699 static_cast<TagDecl::TagKind
>(kind));
1700 class_template_specialization_decl->setDeclContext(decl_ctx);
1701 class_template_specialization_decl->setInstantiationOf(class_template_decl);
1702 class_template_specialization_decl->setTemplateArgs(
1703 TemplateArgumentList::CreateCopy(ast, args));
1704 void *insert_pos =
nullptr;
1705 if (class_template_decl->findSpecialization(args, insert_pos))
1707 class_template_decl->AddSpecialization(class_template_specialization_decl,
1709 class_template_specialization_decl->setDeclName(
1710 class_template_decl->getDeclName());
1715 class_template_specialization_decl->setStrictPackMatch(
false);
1718 decl_ctx->addDecl(class_template_specialization_decl);
1720 class_template_specialization_decl->setSpecializationKind(
1721 TSK_ExplicitSpecialization);
1723 return class_template_specialization_decl;
1727 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1728 if (class_template_specialization_decl) {
1730 return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
1736 clang::OverloadedOperatorKind op_kind,
1737 bool unary,
bool binary,
1738 uint32_t num_params) {
1740 if (op_kind == OO_Call)
1746 if (num_params == 1)
1748 if (num_params == 2)
1755 bool is_method, clang::OverloadedOperatorKind op_kind,
1756 uint32_t num_params) {
1764 case OO_Array_Delete:
1768#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1770 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1772#include "clang/Basic/OperatorKinds.def"
1779clang::AccessSpecifier
1781 clang::AccessSpecifier rhs) {
1784 if (lhs == AS_none || rhs == AS_none)
1786 if (lhs == AS_private || rhs == AS_private)
1788 if (lhs == AS_protected || rhs == AS_protected)
1789 return AS_protected;
1794 uint32_t &bitfield_bit_size) {
1796 if (field ==
nullptr)
1799 if (field->isBitField()) {
1800 Expr *bit_width_expr = field->getBitWidth();
1801 if (bit_width_expr) {
1802 if (std::optional<llvm::APSInt> bit_width_apsint =
1803 bit_width_expr->getIntegerConstantExpr(ast)) {
1804 bitfield_bit_size = bit_width_apsint->getLimitedValue(
UINT32_MAX);
1813 if (record_decl ==
nullptr)
1816 if (!record_decl->field_empty())
1820 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1821 if (cxx_record_decl) {
1822 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1823 for (base_class = cxx_record_decl->bases_begin(),
1824 base_class_end = cxx_record_decl->bases_end();
1825 base_class != base_class_end; ++base_class) {
1826 assert(record_decl != base_class->getType()->getAsCXXRecordDecl() &&
1827 "Base can't inherit from itself.");
1839 if (std::optional<ClangASTMetadata> meta_data =
GetMetadata(record_decl);
1840 meta_data && meta_data->IsForcefullyCompleted())
1846#pragma mark Objective-C Classes
1849 llvm::StringRef name, clang::DeclContext *decl_ctx,
1851 std::optional<ClangASTMetadata> metadata) {
1853 assert(!name.empty());
1855 decl_ctx = ast.getTranslationUnitDecl();
1857 ObjCInterfaceDecl *decl =
1858 ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
1859 decl->setDeclContext(decl_ctx);
1860 decl->setDeclName(&ast.Idents.get(name));
1861 decl->setImplicit(isInternal);
1867 return GetType(ast.getObjCInterfaceType(decl));
1876 bool omit_empty_base_classes) {
1877 uint32_t num_bases = 0;
1878 if (cxx_record_decl) {
1879 if (omit_empty_base_classes) {
1880 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1881 for (base_class = cxx_record_decl->bases_begin(),
1882 base_class_end = cxx_record_decl->bases_end();
1883 base_class != base_class_end; ++base_class) {
1890 num_bases = cxx_record_decl->getNumBases();
1895#pragma mark Namespace Declarations
1898 const char *name, clang::DeclContext *decl_ctx,
1900 NamespaceDecl *namespace_decl =
nullptr;
1902 TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
1904 decl_ctx = translation_unit_decl;
1907 IdentifierInfo &identifier_info = ast.Idents.get(name);
1908 DeclarationName decl_name(&identifier_info);
1909 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1910 for (NamedDecl *decl : result) {
1911 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1913 return namespace_decl;
1916 namespace_decl = NamespaceDecl::Create(ast, decl_ctx, is_inline,
1917 SourceLocation(), SourceLocation(),
1918 &identifier_info,
nullptr,
false);
1920 decl_ctx->addDecl(namespace_decl);
1922 if (decl_ctx == translation_unit_decl) {
1923 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1925 return namespace_decl;
1928 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1929 SourceLocation(),
nullptr,
nullptr,
false);
1930 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1931 translation_unit_decl->addDecl(namespace_decl);
1932 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace());
1934 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1935 if (parent_namespace_decl) {
1936 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1938 return namespace_decl;
1940 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1941 SourceLocation(),
nullptr,
nullptr,
false);
1942 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1943 parent_namespace_decl->addDecl(namespace_decl);
1944 assert(namespace_decl ==
1945 parent_namespace_decl->getAnonymousNamespace());
1947 assert(
false &&
"GetUniqueNamespaceDeclaration called with no name and "
1948 "no namespace as decl_ctx");
1956 VerifyDecl(namespace_decl);
1957 return namespace_decl;
1964 clang::BlockDecl *decl =
1965 clang::BlockDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1966 decl->setDeclContext(ctx);
1975 clang::DeclContext *right,
1976 clang::DeclContext *root) {
1977 if (root ==
nullptr)
1980 std::set<clang::DeclContext *> path_left;
1981 for (clang::DeclContext *d = left; d !=
nullptr; d = d->getParent())
1982 path_left.insert(d);
1984 for (clang::DeclContext *d = right; d !=
nullptr; d = d->getParent())
1985 if (path_left.find(d) != path_left.end())
1993 clang::NamespaceDecl *ns_decl) {
1994 if (decl_ctx && ns_decl) {
1995 auto *translation_unit =
getASTContext().getTranslationUnitDecl();
1996 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
1998 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
1999 clang::SourceLocation(), ns_decl,
2002 decl_ctx->addDecl(using_decl);
2012 clang::NamedDecl *target) {
2013 if (current_decl_ctx && target) {
2014 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
2016 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(),
false);
2018 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
2020 target->getDeclName(), using_decl, target);
2022 using_decl->addShadowDecl(shadow_decl);
2023 current_decl_ctx->addDecl(using_decl);
2031 const char *name, clang::QualType type) {
2033 clang::VarDecl *var_decl =
2034 clang::VarDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
2035 var_decl->setDeclContext(decl_context);
2036 if (name && name[0])
2037 var_decl->setDeclName(&
getASTContext().Idents.getOwn(name));
2038 var_decl->setType(type);
2040 var_decl->setAccess(clang::AS_public);
2041 decl_context->addDecl(var_decl);
2050 switch (basic_type) {
2052 return ast->VoidTy.getAsOpaquePtr();
2054 return ast->CharTy.getAsOpaquePtr();
2056 return ast->SignedCharTy.getAsOpaquePtr();
2058 return ast->UnsignedCharTy.getAsOpaquePtr();
2060 return ast->getWCharType().getAsOpaquePtr();
2062 return ast->getSignedWCharType().getAsOpaquePtr();
2064 return ast->getUnsignedWCharType().getAsOpaquePtr();
2066 return ast->Char8Ty.getAsOpaquePtr();
2068 return ast->Char16Ty.getAsOpaquePtr();
2070 return ast->Char32Ty.getAsOpaquePtr();
2072 return ast->ShortTy.getAsOpaquePtr();
2074 return ast->UnsignedShortTy.getAsOpaquePtr();
2076 return ast->IntTy.getAsOpaquePtr();
2078 return ast->UnsignedIntTy.getAsOpaquePtr();
2080 return ast->LongTy.getAsOpaquePtr();
2082 return ast->UnsignedLongTy.getAsOpaquePtr();
2084 return ast->LongLongTy.getAsOpaquePtr();
2086 return ast->UnsignedLongLongTy.getAsOpaquePtr();
2088 return ast->Int128Ty.getAsOpaquePtr();
2090 return ast->UnsignedInt128Ty.getAsOpaquePtr();
2092 return ast->BoolTy.getAsOpaquePtr();
2094 return ast->HalfTy.getAsOpaquePtr();
2096 return ast->FloatTy.getAsOpaquePtr();
2098 return ast->DoubleTy.getAsOpaquePtr();
2100 return ast->LongDoubleTy.getAsOpaquePtr();
2102 return ast->Float128Ty.getAsOpaquePtr();
2104 return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
2106 return ast->getComplexType(ast->DoubleTy).getAsOpaquePtr();
2108 return ast->getComplexType(ast->LongDoubleTy).getAsOpaquePtr();
2110 return ast->getObjCIdType().getAsOpaquePtr();
2112 return ast->getObjCClassType().getAsOpaquePtr();
2114 return ast->getObjCSelType().getAsOpaquePtr();
2116 return ast->NullPtrTy.getAsOpaquePtr();
2122#pragma mark Function Types
2124clang::DeclarationName
2127 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2128 if (!
IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2137 const clang::FunctionProtoType *function_type =
2138 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2139 if (function_type ==
nullptr)
2140 return clang::DeclarationName();
2142 const bool is_method =
false;
2143 const unsigned int num_params = function_type->getNumParams();
2145 is_method, op_kind, num_params))
2146 return clang::DeclarationName();
2148 return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
2152 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
2153 printing_policy.SuppressTagKeyword =
true;
2156 printing_policy.SuppressInlineNamespace =
2157 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None);
2158 printing_policy.SuppressUnwrittenScope =
false;
2170 printing_policy.SuppressDefaultTemplateArgs =
false;
2171 return printing_policy;
2178 llvm::raw_string_ostream os(result);
2179 named_decl->getNameForDiagnostic(os, printing_policy, qualified);
2185 llvm::StringRef name,
const CompilerType &function_clang_type,
2186 clang::StorageClass storage,
bool is_inline, llvm::StringRef asm_label) {
2187 FunctionDecl *func_decl =
nullptr;
2190 decl_ctx = ast.getTranslationUnitDecl();
2192 const bool hasWrittenPrototype =
true;
2193 const bool isConstexprSpecified =
false;
2195 clang::DeclarationName declarationName =
2197 func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
2198 func_decl->setDeclContext(decl_ctx);
2199 func_decl->setDeclName(declarationName);
2201 func_decl->setStorageClass(storage);
2202 func_decl->setInlineSpecified(is_inline);
2203 func_decl->setHasWrittenPrototype(hasWrittenPrototype);
2204 func_decl->setConstexprKind(isConstexprSpecified
2205 ? ConstexprSpecKind::Constexpr
2206 : ConstexprSpecKind::Unspecified);
2218 if (!asm_label.empty())
2219 func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label));
2222 decl_ctx->addDecl(func_decl);
2224 VerifyDecl(func_decl);
2230 const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
2231 bool is_variadic,
unsigned type_quals, clang::CallingConv cc,
2232 clang::RefQualifierKind ref_qual) {
2236 std::vector<QualType> qual_type_args;
2238 for (
const auto &arg : args) {
2253 FunctionProtoType::ExtProtoInfo proto_info;
2254 proto_info.ExtInfo = cc;
2255 proto_info.Variadic = is_variadic;
2256 proto_info.ExceptionSpec = EST_None;
2257 proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
2258 proto_info.RefQualifier = ref_qual;
2266 const char *name,
const CompilerType ¶m_type,
int storage,
2269 auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
2270 decl->setDeclContext(decl_ctx);
2271 if (name && name[0])
2272 decl->setDeclName(&ast.Idents.get(name));
2274 decl->setStorageClass(
static_cast<clang::StorageClass
>(storage));
2277 decl_ctx->addDecl(decl);
2284 QualType block_type =
m_ast_up->getBlockPointerType(
2290#pragma mark Array Types
2294 std::optional<size_t> element_count,
2307 clang::ArraySizeModifier::Normal, 0));
2313 llvm::APInt ap_element_count(64, *element_count);
2315 ap_element_count,
nullptr,
2316 clang::ArraySizeModifier::Normal, 0));
2320 llvm::StringRef type_name,
2321 const std::initializer_list<std::pair<const char *, CompilerType>>
2328 lldbassert(0 &&
"Trying to create a type for an existing name");
2336 for (
const auto &field : type_fields)
2346 llvm::StringRef type_name,
2347 const std::initializer_list<std::pair<const char *, CompilerType>>
2359#pragma mark Enumeration Types
2362 llvm::StringRef name, clang::DeclContext *decl_ctx,
2364 const CompilerType &integer_clang_type,
bool is_scoped,
2365 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind) {
2372 EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
2373 enum_decl->setDeclContext(decl_ctx);
2375 enum_decl->setDeclName(&ast.Idents.get(name));
2376 enum_decl->setScoped(is_scoped);
2377 enum_decl->setScopedUsingClassTag(is_scoped);
2378 enum_decl->setFixed(
false);
2381 decl_ctx->addDecl(enum_decl);
2385 clang::EnumExtensibilityAttr::CreateImplicit(ast, *enum_kind));
2390 enum_decl->setAccess(AS_public);
2392 return GetType(ast.getCanonicalTagType(enum_decl));
2403 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
2404 return GetType(ast.SignedCharTy);
2406 if (bit_size == ast.getTypeSize(ast.ShortTy))
2409 if (bit_size == ast.getTypeSize(ast.IntTy))
2412 if (bit_size == ast.getTypeSize(ast.LongTy))
2415 if (bit_size == ast.getTypeSize(ast.LongLongTy))
2416 return GetType(ast.LongLongTy);
2418 if (bit_size == ast.getTypeSize(ast.Int128Ty))
2421 if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
2422 return GetType(ast.UnsignedCharTy);
2424 if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
2425 return GetType(ast.UnsignedShortTy);
2427 if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
2428 return GetType(ast.UnsignedIntTy);
2430 if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
2431 return GetType(ast.UnsignedLongTy);
2433 if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
2434 return GetType(ast.UnsignedLongLongTy);
2436 if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
2437 return GetType(ast.UnsignedInt128Ty);
2454 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2456 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2457 named_decl->getDeclName().getAsString().c_str());
2459 printf(
"%20s\n", decl_ctx->getDeclKindName());
2465 if (decl ==
nullptr)
2469 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2471 bool is_injected_class_name =
2472 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2473 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2474 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2475 record_decl->getDeclName().getAsString().c_str(),
2476 is_injected_class_name ?
" (injected class name)" :
"");
2479 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2481 printf(
"%20s: %s\n", decl->getDeclKindName(),
2482 named_decl->getDeclName().getAsString().c_str());
2484 printf(
"%20s\n", decl->getDeclKindName());
2490 clang::Decl *decl) {
2494 ExternalASTSource *ast_source = ast->getExternalSource();
2499 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2500 if (tag_decl->isCompleteDefinition())
2503 if (!tag_decl->hasExternalLexicalStorage())
2506 ast_source->CompleteType(tag_decl);
2508 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2509 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2510 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2511 if (objc_interface_decl->getDefinition())
2514 if (!objc_interface_decl->hasExternalLexicalStorage())
2517 ast_source->CompleteType(objc_interface_decl);
2519 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2549std::optional<ClangASTMetadata>
2555 return std::nullopt;
2558std::optional<ClangASTMetadata>
2564 return std::nullopt;
2568 clang::AccessSpecifier access) {
2569 if (access == clang::AccessSpecifier::AS_none)
2575clang::AccessSpecifier
2580 return clang::AccessSpecifier::AS_none;
2602 if (find(mask, type->getTypeClass()) != mask.end())
2604 switch (type->getTypeClass()) {
2607 case clang::Type::Atomic:
2608 type = cast<clang::AtomicType>(type)->getValueType();
2610 case clang::Type::Auto:
2611 case clang::Type::Decltype:
2612 case clang::Type::Paren:
2613 case clang::Type::SubstTemplateTypeParm:
2614 case clang::Type::TemplateSpecialization:
2615 case clang::Type::Typedef:
2616 case clang::Type::TypeOf:
2617 case clang::Type::TypeOfExpr:
2618 case clang::Type::Using:
2619 case clang::Type::PredefinedSugar:
2620 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2634 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2635 switch (type_class) {
2636 case clang::Type::ObjCInterface:
2637 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2639 case clang::Type::ObjCObjectPointer:
2641 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2642 ->getPointeeType());
2643 case clang::Type::Enum:
2644 case clang::Type::Record:
2645 return llvm::cast<clang::TagType>(qual_type)
2647 ->getDefinitionOrSelf();
2659static const clang::RecordType *
2661 assert(qual_type->isRecordType());
2663 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2665 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2669 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2672 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2673 const bool fields_loaded =
2674 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2677 if (is_complete && fields_loaded)
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 assert(qual_type->isEnumeralType());
2706 const clang::EnumType *enum_type =
2707 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2709 auto *tag_decl = enum_type->getAsTagDecl();
2713 if (tag_decl->getDefinition())
2717 if (!tag_decl->hasExternalLexicalStorage())
2721 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2722 if (!external_ast_source)
2725 external_ast_source->CompleteType(tag_decl);
2733static const clang::ObjCObjectType *
2735 assert(qual_type->isObjCObjectType());
2738 const clang::ObjCObjectType *objc_class_type =
2739 llvm::cast<clang::ObjCObjectType>(qual_type);
2741 clang::ObjCInterfaceDecl *class_interface_decl =
2742 objc_class_type->getInterface();
2745 if (!class_interface_decl)
2746 return objc_class_type;
2749 if (class_interface_decl->getDefinition())
2750 return objc_class_type;
2753 if (!class_interface_decl->hasExternalLexicalStorage())
2757 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2758 if (!external_ast_source)
2761 external_ast_source->CompleteType(class_interface_decl);
2762 return objc_class_type;
2766 clang::QualType qual_type) {
2768 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2769 switch (type_class) {
2770 case clang::Type::ConstantArray:
2771 case clang::Type::IncompleteArray:
2772 case clang::Type::VariableArray: {
2773 const clang::ArrayType *array_type =
2774 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2779 case clang::Type::Record: {
2781 return !RT->isIncompleteType();
2786 case clang::Type::Enum: {
2788 return !ET->isIncompleteType();
2792 case clang::Type::ObjCObject:
2793 case clang::Type::ObjCInterface: {
2795 return !OT->isIncompleteType();
2800 case clang::Type::Attributed:
2802 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType());
2804 case clang::Type::MemberPointer:
2807 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2808 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2809 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2812 return !qual_type.getTypePtr()->isIncompleteType();
2823static clang::ObjCIvarDecl::AccessControl
2827 return clang::ObjCIvarDecl::None;
2829 return clang::ObjCIvarDecl::Public;
2831 return clang::ObjCIvarDecl::Private;
2833 return clang::ObjCIvarDecl::Protected;
2835 return clang::ObjCIvarDecl::Package;
2837 return clang::ObjCIvarDecl::None;
2844 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2851 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2852 switch (type_class) {
2853 case clang::Type::IncompleteArray:
2854 case clang::Type::VariableArray:
2855 case clang::Type::ConstantArray:
2856 case clang::Type::ExtVector:
2857 case clang::Type::Vector:
2858 case clang::Type::Record:
2859 case clang::Type::ObjCObject:
2860 case clang::Type::ObjCInterface:
2872 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2873 switch (type_class) {
2874 case clang::Type::Record: {
2875 if (
const clang::RecordType *record_type =
2876 llvm::dyn_cast_or_null<clang::RecordType>(
2877 qual_type.getTypePtrOrNull())) {
2878 if (
const clang::RecordDecl *record_decl = record_type->getDecl()) {
2879 return record_decl->isAnonymousStructOrUnion();
2893 uint64_t *size,
bool *is_incomplete) {
2896 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2897 switch (type_class) {
2901 case clang::Type::ConstantArray:
2902 if (element_type_ptr)
2904 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2908 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2910 .getLimitedValue(ULLONG_MAX);
2912 *is_incomplete =
false;
2915 case clang::Type::IncompleteArray:
2916 if (element_type_ptr)
2918 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2924 *is_incomplete =
true;
2927 case clang::Type::VariableArray:
2928 if (element_type_ptr)
2930 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2936 *is_incomplete =
false;
2939 case clang::Type::DependentSizedArray:
2940 if (element_type_ptr)
2943 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2949 *is_incomplete =
false;
2952 if (element_type_ptr)
2953 element_type_ptr->
Clear();
2957 *is_incomplete =
false;
2965 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2966 switch (type_class) {
2967 case clang::Type::Vector: {
2968 const clang::VectorType *vector_type =
2969 qual_type->getAs<clang::VectorType>();
2972 *size = vector_type->getNumElements();
2974 *element_type =
GetType(vector_type->getElementType());
2978 case clang::Type::ExtVector: {
2979 const clang::ExtVectorType *ext_vector_type =
2980 qual_type->getAs<clang::ExtVectorType>();
2981 if (ext_vector_type) {
2983 *size = ext_vector_type->getNumElements();
2987 ext_vector_type->getElementType().getAsOpaquePtr());
3003 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
3006 clang::ObjCInterfaceDecl *result_iface_decl =
3007 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
3009 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
3013 return (ast_metadata->GetISAPtr() != 0);
3017 return GetQualType(type).getUnqualifiedType()->isCharType();
3039 if (!pointee_or_element_clang_type.
IsValid())
3042 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
3043 if (pointee_or_element_clang_type.
IsCharType()) {
3044 if (type_flags.
Test(eTypeIsArray)) {
3047 length = llvm::cast<clang::ConstantArrayType>(
3061 if (
auto pointer_auth = qual_type.getPointerAuth())
3062 return pointer_auth.getKey();
3071 if (
auto pointer_auth = qual_type.getPointerAuth())
3072 return pointer_auth.getExtraDiscriminator();
3081 if (
auto pointer_auth = qual_type.getPointerAuth())
3082 return pointer_auth.isAddressDiscriminated();
3088 auto isFunctionType = [&](clang::QualType qual_type) {
3089 return qual_type->isFunctionType();
3103 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3104 switch (type_class) {
3105 case clang::Type::Record:
3107 const clang::CXXRecordDecl *cxx_record_decl =
3108 qual_type->getAsCXXRecordDecl();
3109 if (cxx_record_decl) {
3110 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3113 const clang::RecordType *record_type =
3114 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3116 if (
const clang::RecordDecl *record_decl =
3117 record_type->getDecl()->getDefinition()) {
3120 clang::RecordDecl::field_iterator field_pos,
3121 field_end = record_decl->field_end();
3122 uint32_t num_fields = 0;
3123 bool is_hva =
false;
3124 bool is_hfa =
false;
3125 clang::QualType base_qual_type;
3126 uint64_t base_bitwidth = 0;
3127 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3129 clang::QualType field_qual_type = field_pos->getType();
3130 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3131 if (field_qual_type->isFloatingType()) {
3132 if (field_qual_type->isComplexType())
3135 if (num_fields == 0)
3136 base_qual_type = field_qual_type;
3141 if (field_qual_type.getTypePtr() !=
3142 base_qual_type.getTypePtr())
3146 }
else if (field_qual_type->isVectorType() ||
3147 field_qual_type->isExtVectorType()) {
3148 if (num_fields == 0) {
3149 base_qual_type = field_qual_type;
3150 base_bitwidth = field_bitwidth;
3155 if (base_bitwidth != field_bitwidth)
3157 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3166 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3183 const clang::FunctionProtoType *func =
3184 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3186 return func->getNumParams();
3193 const size_t index) {
3196 const clang::FunctionProtoType *func =
3197 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3199 if (index < func->getNumParams())
3200 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3208 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3212 if (predicate(qual_type))
3215 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3216 switch (type_class) {
3220 case clang::Type::LValueReference:
3221 case clang::Type::RValueReference: {
3222 const clang::ReferenceType *reference_type =
3223 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3225 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3234 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3235 return qual_type->isMemberFunctionPointerType();
3238 return IsTypeImpl(type, isMemberFunctionPointerType);
3242 auto isFunctionPointerType = [](clang::QualType qual_type) {
3243 return qual_type->isFunctionPointerType();
3246 return IsTypeImpl(type, isFunctionPointerType);
3252 auto isBlockPointerType = [&](clang::QualType qual_type) {
3253 if (qual_type->isBlockPointerType()) {
3254 if (function_pointer_type_ptr) {
3255 const clang::BlockPointerType *block_pointer_type =
3256 qual_type->castAs<clang::BlockPointerType>();
3257 QualType pointee_type = block_pointer_type->getPointeeType();
3258 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3260 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3277 if (qual_type.isNull())
3286 is_signed = qual_type->isSignedIntegerType();
3294 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3298 is_signed = enum_type->isSignedIntegerOrEnumerationType();
3309 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3313 return enum_type->isScopedEnumeralType();
3324 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3325 switch (type_class) {
3326 case clang::Type::Builtin:
3327 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3330 case clang::BuiltinType::ObjCId:
3331 case clang::BuiltinType::ObjCClass:
3335 case clang::Type::ObjCObjectPointer:
3339 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3343 case clang::Type::BlockPointer:
3346 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3350 case clang::Type::Pointer:
3353 llvm::cast<clang::PointerType>(qual_type)
3357 case clang::Type::MemberPointer:
3360 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3369 pointee_type->
Clear();
3377 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3378 switch (type_class) {
3379 case clang::Type::Builtin:
3380 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3383 case clang::BuiltinType::ObjCId:
3384 case clang::BuiltinType::ObjCClass:
3388 case clang::Type::ObjCObjectPointer:
3392 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3396 case clang::Type::BlockPointer:
3399 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3403 case clang::Type::Pointer:
3406 llvm::cast<clang::PointerType>(qual_type)
3410 case clang::Type::MemberPointer:
3413 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3417 case clang::Type::LValueReference:
3420 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3424 case clang::Type::RValueReference:
3427 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3436 pointee_type->
Clear();
3445 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3447 switch (type_class) {
3448 case clang::Type::LValueReference:
3451 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3457 case clang::Type::RValueReference:
3460 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3472 pointee_type->
Clear();
3481 if (
const clang::BuiltinType *BT = llvm::dyn_cast<clang::BuiltinType>(
3482 qual_type->getCanonicalTypeInternal())) {
3483 clang::BuiltinType::Kind kind = BT->getKind();
3484 if (kind >= clang::BuiltinType::Float &&
3485 kind <= clang::BuiltinType::LongDouble) {
3489 }
else if (
const clang::ComplexType *CT =
3490 llvm::dyn_cast<clang::ComplexType>(
3491 qual_type->getCanonicalTypeInternal())) {
3497 }
else if (
const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(
3498 qual_type->getCanonicalTypeInternal())) {
3515 const clang::TagType *tag_type =
3516 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3518 if (clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinition())
3519 return tag_decl->isCompleteDefinition();
3522 const clang::ObjCObjectType *objc_class_type =
3523 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3524 if (objc_class_type) {
3525 clang::ObjCInterfaceDecl *class_interface_decl =
3526 objc_class_type->getInterface();
3527 if (class_interface_decl)
3528 return class_interface_decl->getDefinition() !=
nullptr;
3539 const clang::ObjCObjectPointerType *obj_pointer_type =
3540 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3542 if (obj_pointer_type)
3543 return obj_pointer_type->isObjCClassType();
3558 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3559 return (type_class == clang::Type::Record);
3566 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3567 return (type_class == clang::Type::Enum);
3573 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3574 switch (type_class) {
3575 case clang::Type::Record:
3577 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3584 return cxx_record_decl->isDynamicClass();
3598 bool check_cplusplus,
3600 if (dynamic_pointee_type)
3601 dynamic_pointee_type->
Clear();
3605 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3606 if (dynamic_pointee_type)
3608 type.getAsOpaquePtr());
3611 clang::QualType pointee_qual_type;
3613 switch (qual_type->getTypeClass()) {
3614 case clang::Type::Builtin:
3615 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3616 clang::BuiltinType::ObjCId) {
3617 set_dynamic_pointee_type(qual_type);
3622 case clang::Type::ObjCObjectPointer:
3625 if (
const auto *objc_pointee_type =
3626 qual_type->getPointeeType().getTypePtrOrNull()) {
3627 if (
const auto *objc_object_type =
3628 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3629 objc_pointee_type)) {
3630 if (objc_object_type->isObjCClass())
3634 set_dynamic_pointee_type(
3635 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3638 case clang::Type::Pointer:
3640 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3643 case clang::Type::LValueReference:
3644 case clang::Type::RValueReference:
3646 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3656 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3657 case clang::Type::Builtin:
3658 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3659 case clang::BuiltinType::UnknownAny:
3660 case clang::BuiltinType::Void:
3661 set_dynamic_pointee_type(pointee_qual_type);
3667 case clang::Type::Record: {
3668 if (!check_cplusplus)
3670 clang::CXXRecordDecl *cxx_record_decl =
3671 pointee_qual_type->getAsCXXRecordDecl();
3672 if (!cxx_record_decl)
3676 if (cxx_record_decl->isCompleteDefinition())
3677 success = cxx_record_decl->isDynamicClass();
3679 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3680 std::optional<bool> is_dynamic =
3681 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3683 success = *is_dynamic;
3685 success = cxx_record_decl->isDynamicClass();
3691 set_dynamic_pointee_type(pointee_qual_type);
3695 case clang::Type::ObjCObject:
3696 case clang::Type::ObjCInterface:
3698 set_dynamic_pointee_type(pointee_qual_type);
3713 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3720 ->getTypeClass() == clang::Type::Typedef;
3730 if (
auto *record_decl =
3732 return record_decl->canPassInRegisters();
3738 return TypeSystemClangSupportsLanguage(language);
3741std::optional<std::string>
3744 return std::nullopt;
3747 if (qual_type.isNull())
3748 return std::nullopt;
3750 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3751 if (!cxx_record_decl)
3752 return std::nullopt;
3754 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3762 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3769 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3771 return tag_type->getDecl()->isEntityBeingDefined();
3782 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3783 if (class_type_ptr) {
3784 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3785 const clang::ObjCObjectPointerType *obj_pointer_type =
3786 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3787 if (obj_pointer_type ==
nullptr)
3788 class_type_ptr->
Clear();
3792 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3799 class_type_ptr->
Clear();
3826 {clang::Type::Typedef, clang::Type::Atomic});
3829 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3830 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3837 if (
auto *named_decl = qual_type->getAsTagDecl())
3849 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3850 printing_policy.SuppressTagKeyword =
true;
3851 printing_policy.SuppressScope =
false;
3852 printing_policy.SuppressUnwrittenScope =
true;
3853 printing_policy.SuppressInlineNamespace =
3854 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::All);
3855 return ConstString(qual_type.getAsString(printing_policy));
3864 if (pointee_or_element_clang_type)
3865 pointee_or_element_clang_type->
Clear();
3867 clang::QualType qual_type =
3870 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3871 switch (type_class) {
3872 case clang::Type::Attributed:
3873 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3876 pointee_or_element_clang_type);
3877 case clang::Type::BitInt: {
3878 uint32_t type_flags = eTypeIsScalar | eTypeIsInteger | eTypeHasValue;
3879 if (qual_type->isSignedIntegerType())
3880 type_flags |= eTypeIsSigned;
3884 case clang::Type::Builtin: {
3885 const clang::BuiltinType *builtin_type =
3886 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3888 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3889 switch (builtin_type->getKind()) {
3890 case clang::BuiltinType::ObjCId:
3891 case clang::BuiltinType::ObjCClass:
3892 if (pointee_or_element_clang_type)
3896 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3899 case clang::BuiltinType::ObjCSel:
3900 if (pointee_or_element_clang_type)
3903 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3906 case clang::BuiltinType::Bool:
3907 case clang::BuiltinType::Char_U:
3908 case clang::BuiltinType::UChar:
3909 case clang::BuiltinType::WChar_U:
3910 case clang::BuiltinType::Char16:
3911 case clang::BuiltinType::Char32:
3912 case clang::BuiltinType::UShort:
3913 case clang::BuiltinType::UInt:
3914 case clang::BuiltinType::ULong:
3915 case clang::BuiltinType::ULongLong:
3916 case clang::BuiltinType::UInt128:
3917 case clang::BuiltinType::Char_S:
3918 case clang::BuiltinType::SChar:
3919 case clang::BuiltinType::WChar_S:
3920 case clang::BuiltinType::Short:
3921 case clang::BuiltinType::Int:
3922 case clang::BuiltinType::Long:
3923 case clang::BuiltinType::LongLong:
3924 case clang::BuiltinType::Int128:
3925 case clang::BuiltinType::Float:
3926 case clang::BuiltinType::Double:
3927 case clang::BuiltinType::LongDouble:
3928 builtin_type_flags |= eTypeIsScalar;
3929 if (builtin_type->isInteger()) {
3930 builtin_type_flags |= eTypeIsInteger;
3931 if (builtin_type->isSignedInteger())
3932 builtin_type_flags |= eTypeIsSigned;
3933 }
else if (builtin_type->isFloatingPoint())
3934 builtin_type_flags |= eTypeIsFloat;
3939 return builtin_type_flags;
3942 case clang::Type::BlockPointer:
3943 if (pointee_or_element_clang_type)
3945 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3946 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3948 case clang::Type::Complex: {
3949 uint32_t complex_type_flags =
3950 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3951 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3952 qual_type->getCanonicalTypeInternal());
3954 clang::QualType complex_element_type(complex_type->getElementType());
3955 if (complex_element_type->isIntegerType())
3956 complex_type_flags |= eTypeIsInteger;
3957 else if (complex_element_type->isFloatingType())
3958 complex_type_flags |= eTypeIsFloat;
3960 return complex_type_flags;
3963 case clang::Type::ConstantArray:
3964 case clang::Type::DependentSizedArray:
3965 case clang::Type::IncompleteArray:
3966 case clang::Type::VariableArray:
3967 if (pointee_or_element_clang_type)
3969 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
3972 return eTypeHasChildren | eTypeIsArray;
3974 case clang::Type::DependentName:
3976 case clang::Type::DependentSizedExtVector:
3977 return eTypeHasChildren | eTypeIsVector;
3979 case clang::Type::Enum:
3980 if (pointee_or_element_clang_type)
3982 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
3984 ->getDefinitionOrSelf()
3987 return eTypeIsEnumeration | eTypeHasValue;
3989 case clang::Type::FunctionProto:
3990 return eTypeIsFuncPrototype | eTypeHasValue;
3991 case clang::Type::FunctionNoProto:
3992 return eTypeIsFuncPrototype | eTypeHasValue;
3993 case clang::Type::InjectedClassName:
3996 case clang::Type::LValueReference:
3997 case clang::Type::RValueReference:
3998 if (pointee_or_element_clang_type)
4001 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
4004 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
4006 case clang::Type::MemberPointer:
4007 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
4009 case clang::Type::ObjCObjectPointer:
4010 if (pointee_or_element_clang_type)
4012 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4013 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
4016 case clang::Type::ObjCObject:
4017 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4018 case clang::Type::ObjCInterface:
4019 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4021 case clang::Type::Pointer:
4022 if (pointee_or_element_clang_type)
4024 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4025 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
4027 case clang::Type::Record:
4028 if (qual_type->getAsCXXRecordDecl())
4029 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
4031 return eTypeHasChildren | eTypeIsStructUnion;
4033 case clang::Type::SubstTemplateTypeParm:
4034 return eTypeIsTemplate;
4035 case clang::Type::TemplateTypeParm:
4036 return eTypeIsTemplate;
4037 case clang::Type::TemplateSpecialization:
4038 return eTypeIsTemplate;
4040 case clang::Type::Typedef:
4041 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
4043 ->getUnderlyingType())
4045 case clang::Type::UnresolvedUsing:
4048 case clang::Type::ExtVector:
4049 case clang::Type::Vector: {
4050 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
4051 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
4052 qual_type->getCanonicalTypeInternal());
4056 QualType element_type = vector_type->getElementType();
4057 if (element_type.isNull())
4060 if (element_type->isIntegerType())
4061 vector_type_flags |= eTypeIsInteger;
4062 else if (element_type->isFloatingType())
4063 vector_type_flags |= eTypeIsFloat;
4064 return vector_type_flags;
4079 if (qual_type->isAnyPointerType()) {
4080 if (qual_type->isObjCObjectPointerType())
4082 if (qual_type->getPointeeCXXRecordDecl())
4085 clang::QualType pointee_type(qual_type->getPointeeType());
4086 if (pointee_type->getPointeeCXXRecordDecl())
4088 if (pointee_type->isObjCObjectOrInterfaceType())
4090 if (pointee_type->isObjCClassType())
4092 if (pointee_type.getTypePtr() ==
4096 if (qual_type->isObjCObjectOrInterfaceType())
4098 if (qual_type->getAsCXXRecordDecl())
4100 switch (qual_type->getTypeClass()) {
4103 case clang::Type::Builtin:
4104 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4106 case clang::BuiltinType::Void:
4107 case clang::BuiltinType::Bool:
4108 case clang::BuiltinType::Char_U:
4109 case clang::BuiltinType::UChar:
4110 case clang::BuiltinType::WChar_U:
4111 case clang::BuiltinType::Char16:
4112 case clang::BuiltinType::Char32:
4113 case clang::BuiltinType::UShort:
4114 case clang::BuiltinType::UInt:
4115 case clang::BuiltinType::ULong:
4116 case clang::BuiltinType::ULongLong:
4117 case clang::BuiltinType::UInt128:
4118 case clang::BuiltinType::Char_S:
4119 case clang::BuiltinType::SChar:
4120 case clang::BuiltinType::WChar_S:
4121 case clang::BuiltinType::Short:
4122 case clang::BuiltinType::Int:
4123 case clang::BuiltinType::Long:
4124 case clang::BuiltinType::LongLong:
4125 case clang::BuiltinType::Int128:
4126 case clang::BuiltinType::Float:
4127 case clang::BuiltinType::Double:
4128 case clang::BuiltinType::LongDouble:
4131 case clang::BuiltinType::NullPtr:
4134 case clang::BuiltinType::ObjCId:
4135 case clang::BuiltinType::ObjCClass:
4136 case clang::BuiltinType::ObjCSel:
4139 case clang::BuiltinType::Dependent:
4140 case clang::BuiltinType::Overload:
4141 case clang::BuiltinType::BoundMember:
4142 case clang::BuiltinType::UnknownAny:
4146 case clang::Type::Typedef:
4147 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4149 ->getUnderlyingType())
4159 return lldb::eTypeClassInvalid;
4161 clang::QualType qual_type =
4164 switch (qual_type->getTypeClass()) {
4165 case clang::Type::Atomic:
4166 case clang::Type::Auto:
4167 case clang::Type::CountAttributed:
4168 case clang::Type::Decltype:
4169 case clang::Type::Paren:
4170 case clang::Type::TypeOf:
4171 case clang::Type::TypeOfExpr:
4172 case clang::Type::Using:
4173 case clang::Type::PredefinedSugar:
4174 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4175 case clang::Type::UnaryTransform:
4177 case clang::Type::FunctionNoProto:
4178 return lldb::eTypeClassFunction;
4179 case clang::Type::FunctionProto:
4180 return lldb::eTypeClassFunction;
4181 case clang::Type::IncompleteArray:
4182 return lldb::eTypeClassArray;
4183 case clang::Type::VariableArray:
4184 return lldb::eTypeClassArray;
4185 case clang::Type::ConstantArray:
4186 return lldb::eTypeClassArray;
4187 case clang::Type::DependentSizedArray:
4188 return lldb::eTypeClassArray;
4189 case clang::Type::ArrayParameter:
4190 return lldb::eTypeClassArray;
4191 case clang::Type::DependentSizedExtVector:
4192 return lldb::eTypeClassVector;
4193 case clang::Type::DependentVector:
4194 return lldb::eTypeClassVector;
4195 case clang::Type::ExtVector:
4196 return lldb::eTypeClassVector;
4197 case clang::Type::Vector:
4198 return lldb::eTypeClassVector;
4199 case clang::Type::Builtin:
4201 case clang::Type::BitInt:
4202 case clang::Type::DependentBitInt:
4203 return lldb::eTypeClassBuiltin;
4204 case clang::Type::ObjCObjectPointer:
4205 return lldb::eTypeClassObjCObjectPointer;
4206 case clang::Type::BlockPointer:
4207 return lldb::eTypeClassBlockPointer;
4208 case clang::Type::Pointer:
4209 return lldb::eTypeClassPointer;
4210 case clang::Type::LValueReference:
4211 return lldb::eTypeClassReference;
4212 case clang::Type::RValueReference:
4213 return lldb::eTypeClassReference;
4214 case clang::Type::MemberPointer:
4215 return lldb::eTypeClassMemberPointer;
4216 case clang::Type::Complex:
4217 if (qual_type->isComplexType())
4218 return lldb::eTypeClassComplexFloat;
4220 return lldb::eTypeClassComplexInteger;
4221 case clang::Type::ObjCObject:
4222 return lldb::eTypeClassObjCObject;
4223 case clang::Type::ObjCInterface:
4224 return lldb::eTypeClassObjCInterface;
4225 case clang::Type::Record: {
4226 const clang::RecordType *record_type =
4227 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4228 const clang::RecordDecl *record_decl = record_type->getDecl();
4229 if (record_decl->isUnion())
4230 return lldb::eTypeClassUnion;
4231 else if (record_decl->isStruct())
4232 return lldb::eTypeClassStruct;
4234 return lldb::eTypeClassClass;
4236 case clang::Type::Enum:
4237 return lldb::eTypeClassEnumeration;
4238 case clang::Type::Typedef:
4239 return lldb::eTypeClassTypedef;
4240 case clang::Type::UnresolvedUsing:
4243 case clang::Type::Attributed:
4244 case clang::Type::BTFTagAttributed:
4246 case clang::Type::TemplateTypeParm:
4248 case clang::Type::SubstTemplateTypeParm:
4250 case clang::Type::SubstTemplateTypeParmPack:
4252 case clang::Type::InjectedClassName:
4254 case clang::Type::DependentName:
4256 case clang::Type::PackExpansion:
4259 case clang::Type::TemplateSpecialization:
4261 case clang::Type::DeducedTemplateSpecialization:
4263 case clang::Type::Pipe:
4267 case clang::Type::Decayed:
4269 case clang::Type::Adjusted:
4271 case clang::Type::ObjCTypeParam:
4274 case clang::Type::DependentAddressSpace:
4276 case clang::Type::MacroQualified:
4280 case clang::Type::ConstantMatrix:
4281 case clang::Type::DependentSizedMatrix:
4285 case clang::Type::PackIndexing:
4288 case clang::Type::HLSLAttributedResource:
4290 case clang::Type::HLSLInlineSpirv:
4292 case clang::Type::SubstBuiltinTemplatePack:
4296 return lldb::eTypeClassOther;
4301 return GetQualType(type).getQualifiers().getCVRQualifiers();
4313 const clang::Type *array_eletype =
4314 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4319 return GetType(clang::QualType(array_eletype, 0));
4330 return GetType(ast_ctx.getConstantArrayType(
4331 qual_type, llvm::APInt(64, size),
nullptr,
4332 clang::ArraySizeModifier::Normal, 0));
4334 return GetType(ast_ctx.getIncompleteArrayType(
4335 qual_type, clang::ArraySizeModifier::Normal, 0));
4349 clang::QualType qual_type) {
4350 if (qual_type->isPointerType())
4351 qual_type = ast->getPointerType(
4353 else if (
const ConstantArrayType *arr =
4354 ast->getAsConstantArrayType(qual_type)) {
4355 qual_type = ast->getConstantArrayType(
4357 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4358 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4360 qual_type = qual_type.getUnqualifiedType();
4361 qual_type.removeLocalConst();
4362 qual_type.removeLocalRestrict();
4363 qual_type.removeLocalVolatile();
4385 const clang::FunctionProtoType *func =
4388 return func->getNumParams();
4396 const clang::FunctionProtoType *func =
4397 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4399 const uint32_t num_args = func->getNumParams();
4401 return GetType(func->getParamType(idx));
4411 const clang::FunctionProtoType *func =
4412 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4414 return GetType(func->getReturnType());
4421 size_t num_functions = 0;
4424 switch (qual_type->getTypeClass()) {
4425 case clang::Type::Record:
4427 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4428 num_functions = std::distance(cxx_record_decl->method_begin(),
4429 cxx_record_decl->method_end());
4432 case clang::Type::ObjCObjectPointer: {
4433 const clang::ObjCObjectPointerType *objc_class_type =
4434 qual_type->castAs<clang::ObjCObjectPointerType>();
4435 const clang::ObjCInterfaceType *objc_interface_type =
4436 objc_class_type->getInterfaceType();
4437 if (objc_interface_type &&
4439 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4440 clang::ObjCInterfaceDecl *class_interface_decl =
4441 objc_interface_type->getDecl();
4442 if (class_interface_decl) {
4443 num_functions = std::distance(class_interface_decl->meth_begin(),
4444 class_interface_decl->meth_end());
4450 case clang::Type::ObjCObject:
4451 case clang::Type::ObjCInterface:
4453 const clang::ObjCObjectType *objc_class_type =
4454 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4455 if (objc_class_type) {
4456 clang::ObjCInterfaceDecl *class_interface_decl =
4457 objc_class_type->getInterface();
4458 if (class_interface_decl)
4459 num_functions = std::distance(class_interface_decl->meth_begin(),
4460 class_interface_decl->meth_end());
4469 return num_functions;
4481 switch (qual_type->getTypeClass()) {
4482 case clang::Type::Record:
4484 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4485 auto method_iter = cxx_record_decl->method_begin();
4486 auto method_end = cxx_record_decl->method_end();
4488 static_cast<size_t>(std::distance(method_iter, method_end))) {
4489 std::advance(method_iter, idx);
4490 clang::CXXMethodDecl *cxx_method_decl =
4491 method_iter->getCanonicalDecl();
4492 if (cxx_method_decl) {
4493 name = cxx_method_decl->getDeclName().getAsString();
4494 if (cxx_method_decl->isStatic())
4496 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4498 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4502 clang_type =
GetType(cxx_method_decl->getType());
4510 case clang::Type::ObjCObjectPointer: {
4511 const clang::ObjCObjectPointerType *objc_class_type =
4512 qual_type->castAs<clang::ObjCObjectPointerType>();
4513 const clang::ObjCInterfaceType *objc_interface_type =
4514 objc_class_type->getInterfaceType();
4515 if (objc_interface_type &&
4517 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4518 clang::ObjCInterfaceDecl *class_interface_decl =
4519 objc_interface_type->getDecl();
4520 if (class_interface_decl) {
4521 auto method_iter = class_interface_decl->meth_begin();
4522 auto method_end = class_interface_decl->meth_end();
4524 static_cast<size_t>(std::distance(method_iter, method_end))) {
4525 std::advance(method_iter, idx);
4526 clang::ObjCMethodDecl *objc_method_decl =
4527 method_iter->getCanonicalDecl();
4528 if (objc_method_decl) {
4530 name = objc_method_decl->getSelector().getAsString();
4531 if (objc_method_decl->isClassMethod())
4542 case clang::Type::ObjCObject:
4543 case clang::Type::ObjCInterface:
4545 const clang::ObjCObjectType *objc_class_type =
4546 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4547 if (objc_class_type) {
4548 clang::ObjCInterfaceDecl *class_interface_decl =
4549 objc_class_type->getInterface();
4550 if (class_interface_decl) {
4551 auto method_iter = class_interface_decl->meth_begin();
4552 auto method_end = class_interface_decl->meth_end();
4554 static_cast<size_t>(std::distance(method_iter, method_end))) {
4555 std::advance(method_iter, idx);
4556 clang::ObjCMethodDecl *objc_method_decl =
4557 method_iter->getCanonicalDecl();
4558 if (objc_method_decl) {
4560 name = objc_method_decl->getSelector().getAsString();
4561 if (objc_method_decl->isClassMethod())
4594 return GetType(qual_type.getTypePtr()->getPointeeType());
4604 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4605 case clang::Type::ObjCObject:
4606 case clang::Type::ObjCInterface:
4653 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4654 clang::QualType result =
4655 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4665 result.addVolatile();
4675 result.addRestrict();
4684 if (type && typedef_name && typedef_name[0]) {
4688 clang::DeclContext *decl_ctx =
4693 clang::TypedefDecl *decl =
4694 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4695 decl->setDeclContext(decl_ctx);
4696 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4697 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4698 decl_ctx->addDecl(decl);
4701 clang::TagDecl *tdecl =
nullptr;
4702 if (!qual_type.isNull()) {
4703 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4704 tdecl = rt->getDecl();
4705 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4706 tdecl = et->getDecl();
4712 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4713 tdecl->setTypedefNameForAnonDecl(decl);
4715 decl->setAccess(clang::AS_public);
4718 NestedNameSpecifier Qualifier =
4719 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4721 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4729 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4732 return GetType(typedef_type->getDecl()->getUnderlyingType());
4745 const FunctionType::ExtInfo generic_ext_info(
4754 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4759const llvm::fltSemantics &
4762 const size_t bit_size = byte_size * 8;
4763 if (bit_size == ast.getTypeSize(ast.FloatTy))
4764 return ast.getFloatTypeSemantics(ast.FloatTy);
4765 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4766 return ast.getFloatTypeSemantics(ast.DoubleTy);
4768 bit_size == ast.getTypeSize(ast.Float128Ty))
4769 return ast.getFloatTypeSemantics(ast.Float128Ty);
4770 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4771 bit_size == llvm::APFloat::semanticsSizeInBits(
4772 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4773 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4774 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4775 return ast.getFloatTypeSemantics(ast.HalfTy);
4776 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4777 return ast.getFloatTypeSemantics(ast.Float128Ty);
4778 return llvm::APFloatBase::Bogus();
4781llvm::Expected<uint64_t>
4784 assert(qual_type->isObjCObjectOrInterfaceType());
4789 if (std::optional<uint64_t> bit_size =
4790 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4794 static bool g_printed =
false;
4799 llvm::outs() <<
"warning: trying to determine the size of type ";
4801 llvm::outs() <<
"without a valid ExecutionContext. this is not "
4802 "reliable. please file a bug against LLDB.\n";
4803 llvm::outs() <<
"backtrace:\n";
4804 llvm::sys::PrintStackTrace(llvm::outs());
4805 llvm::outs() <<
"\n";
4814llvm::Expected<uint64_t>
4817 const bool base_name_only =
true;
4819 return llvm::createStringError(
4820 "could not complete type %s",
4824 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4825 switch (type_class) {
4826 case clang::Type::ConstantArray:
4827 case clang::Type::FunctionProto:
4828 case clang::Type::Record:
4830 case clang::Type::ObjCInterface:
4831 case clang::Type::ObjCObject:
4833 case clang::Type::IncompleteArray: {
4834 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4837 qual_type->getArrayElementTypeNoTypeQual()
4838 ->getCanonicalTypeUnqualified());
4843 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4847 return llvm::createStringError(
4848 "could not get size of type %s",
4852std::optional<size_t>
4866 switch (qual_type->getTypeClass()) {
4867 case clang::Type::Atomic:
4868 case clang::Type::Auto:
4869 case clang::Type::CountAttributed:
4870 case clang::Type::Decltype:
4871 case clang::Type::Paren:
4872 case clang::Type::Typedef:
4873 case clang::Type::TypeOf:
4874 case clang::Type::TypeOfExpr:
4875 case clang::Type::Using:
4876 case clang::Type::PredefinedSugar:
4877 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4879 case clang::Type::UnaryTransform:
4882 case clang::Type::FunctionNoProto:
4883 case clang::Type::FunctionProto:
4886 case clang::Type::IncompleteArray:
4887 case clang::Type::VariableArray:
4888 case clang::Type::ArrayParameter:
4891 case clang::Type::ConstantArray:
4894 case clang::Type::DependentVector:
4895 case clang::Type::ExtVector:
4896 case clang::Type::Vector:
4899 case clang::Type::BitInt:
4900 case clang::Type::DependentBitInt:
4904 case clang::Type::Builtin:
4905 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4906 case clang::BuiltinType::Void:
4909 case clang::BuiltinType::Char_S:
4910 case clang::BuiltinType::SChar:
4911 case clang::BuiltinType::WChar_S:
4912 case clang::BuiltinType::Short:
4913 case clang::BuiltinType::Int:
4914 case clang::BuiltinType::Long:
4915 case clang::BuiltinType::LongLong:
4916 case clang::BuiltinType::Int128:
4919 case clang::BuiltinType::Bool:
4920 case clang::BuiltinType::Char_U:
4921 case clang::BuiltinType::UChar:
4922 case clang::BuiltinType::WChar_U:
4923 case clang::BuiltinType::Char8:
4924 case clang::BuiltinType::Char16:
4925 case clang::BuiltinType::Char32:
4926 case clang::BuiltinType::UShort:
4927 case clang::BuiltinType::UInt:
4928 case clang::BuiltinType::ULong:
4929 case clang::BuiltinType::ULongLong:
4930 case clang::BuiltinType::UInt128:
4934 case clang::BuiltinType::ShortAccum:
4935 case clang::BuiltinType::Accum:
4936 case clang::BuiltinType::LongAccum:
4937 case clang::BuiltinType::UShortAccum:
4938 case clang::BuiltinType::UAccum:
4939 case clang::BuiltinType::ULongAccum:
4940 case clang::BuiltinType::ShortFract:
4941 case clang::BuiltinType::Fract:
4942 case clang::BuiltinType::LongFract:
4943 case clang::BuiltinType::UShortFract:
4944 case clang::BuiltinType::UFract:
4945 case clang::BuiltinType::ULongFract:
4946 case clang::BuiltinType::SatShortAccum:
4947 case clang::BuiltinType::SatAccum:
4948 case clang::BuiltinType::SatLongAccum:
4949 case clang::BuiltinType::SatUShortAccum:
4950 case clang::BuiltinType::SatUAccum:
4951 case clang::BuiltinType::SatULongAccum:
4952 case clang::BuiltinType::SatShortFract:
4953 case clang::BuiltinType::SatFract:
4954 case clang::BuiltinType::SatLongFract:
4955 case clang::BuiltinType::SatUShortFract:
4956 case clang::BuiltinType::SatUFract:
4957 case clang::BuiltinType::SatULongFract:
4960 case clang::BuiltinType::Half:
4961 case clang::BuiltinType::Float:
4962 case clang::BuiltinType::Float16:
4963 case clang::BuiltinType::Float128:
4964 case clang::BuiltinType::Double:
4965 case clang::BuiltinType::LongDouble:
4966 case clang::BuiltinType::BFloat16:
4967 case clang::BuiltinType::Ibm128:
4970 case clang::BuiltinType::ObjCClass:
4971 case clang::BuiltinType::ObjCId:
4972 case clang::BuiltinType::ObjCSel:
4975 case clang::BuiltinType::NullPtr:
4978 case clang::BuiltinType::Kind::ARCUnbridgedCast:
4979 case clang::BuiltinType::Kind::BoundMember:
4980 case clang::BuiltinType::Kind::BuiltinFn:
4981 case clang::BuiltinType::Kind::Dependent:
4982 case clang::BuiltinType::Kind::OCLClkEvent:
4983 case clang::BuiltinType::Kind::OCLEvent:
4984 case clang::BuiltinType::Kind::OCLImage1dRO:
4985 case clang::BuiltinType::Kind::OCLImage1dWO:
4986 case clang::BuiltinType::Kind::OCLImage1dRW:
4987 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
4988 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
4989 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
4990 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
4991 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
4992 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
4993 case clang::BuiltinType::Kind::OCLImage2dRO:
4994 case clang::BuiltinType::Kind::OCLImage2dWO:
4995 case clang::BuiltinType::Kind::OCLImage2dRW:
4996 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
4997 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
4998 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
4999 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
5000 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
5001 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
5002 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
5003 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
5004 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
5005 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
5006 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
5007 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
5008 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
5009 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
5010 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
5011 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
5012 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
5013 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
5014 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
5015 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
5016 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
5017 case clang::BuiltinType::Kind::OCLImage3dRO:
5018 case clang::BuiltinType::Kind::OCLImage3dWO:
5019 case clang::BuiltinType::Kind::OCLImage3dRW:
5020 case clang::BuiltinType::Kind::OCLQueue:
5021 case clang::BuiltinType::Kind::OCLReserveID:
5022 case clang::BuiltinType::Kind::OCLSampler:
5023 case clang::BuiltinType::Kind::HLSLResource:
5024 case clang::BuiltinType::Kind::ArraySection:
5025 case clang::BuiltinType::Kind::OMPArrayShaping:
5026 case clang::BuiltinType::Kind::OMPIterator:
5027 case clang::BuiltinType::Kind::Overload:
5028 case clang::BuiltinType::Kind::PseudoObject:
5029 case clang::BuiltinType::Kind::UnknownAny:
5032 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
5033 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
5034 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
5035 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
5036 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
5037 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
5038 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
5039 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
5040 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
5041 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
5042 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
5043 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
5047 case clang::BuiltinType::VectorPair:
5048 case clang::BuiltinType::VectorQuad:
5049 case clang::BuiltinType::DMR1024:
5050 case clang::BuiltinType::DMR2048:
5054#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5055#include "clang/Basic/AArch64ACLETypes.def"
5059#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5060#include "clang/Basic/RISCVVTypes.def"
5064 case clang::BuiltinType::WasmExternRef:
5067 case clang::BuiltinType::IncompleteMatrixIdx:
5070 case clang::BuiltinType::UnresolvedTemplate:
5074#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
5075 case clang::BuiltinType::Id:
5076#include "clang/Basic/AMDGPUTypes.def"
5082 case clang::Type::ObjCObjectPointer:
5083 case clang::Type::BlockPointer:
5084 case clang::Type::Pointer:
5085 case clang::Type::LValueReference:
5086 case clang::Type::RValueReference:
5087 case clang::Type::MemberPointer:
5089 case clang::Type::Complex: {
5091 if (qual_type->isComplexType())
5094 const clang::ComplexType *complex_type =
5095 qual_type->getAsComplexIntegerType();
5104 case clang::Type::ObjCInterface:
5106 case clang::Type::Record:
5108 case clang::Type::Enum:
5109 return qual_type->isUnsignedIntegerOrEnumerationType()
5112 case clang::Type::DependentSizedArray:
5113 case clang::Type::DependentSizedExtVector:
5114 case clang::Type::UnresolvedUsing:
5115 case clang::Type::Attributed:
5116 case clang::Type::BTFTagAttributed:
5117 case clang::Type::TemplateTypeParm:
5118 case clang::Type::SubstTemplateTypeParm:
5119 case clang::Type::SubstTemplateTypeParmPack:
5120 case clang::Type::InjectedClassName:
5121 case clang::Type::DependentName:
5122 case clang::Type::PackExpansion:
5123 case clang::Type::ObjCObject:
5125 case clang::Type::TemplateSpecialization:
5126 case clang::Type::DeducedTemplateSpecialization:
5127 case clang::Type::Adjusted:
5128 case clang::Type::Pipe:
5132 case clang::Type::Decayed:
5134 case clang::Type::ObjCTypeParam:
5137 case clang::Type::DependentAddressSpace:
5139 case clang::Type::MacroQualified:
5142 case clang::Type::ConstantMatrix:
5143 case clang::Type::DependentSizedMatrix:
5147 case clang::Type::PackIndexing:
5150 case clang::Type::HLSLAttributedResource:
5152 case clang::Type::HLSLInlineSpirv:
5154 case clang::Type::SubstBuiltinTemplatePack:
5167 switch (qual_type->getTypeClass()) {
5168 case clang::Type::Atomic:
5169 case clang::Type::Auto:
5170 case clang::Type::CountAttributed:
5171 case clang::Type::Decltype:
5172 case clang::Type::Paren:
5173 case clang::Type::Typedef:
5174 case clang::Type::TypeOf:
5175 case clang::Type::TypeOfExpr:
5176 case clang::Type::Using:
5177 case clang::Type::PredefinedSugar:
5178 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5179 case clang::Type::UnaryTransform:
5182 case clang::Type::FunctionNoProto:
5183 case clang::Type::FunctionProto:
5186 case clang::Type::IncompleteArray:
5187 case clang::Type::VariableArray:
5188 case clang::Type::ArrayParameter:
5191 case clang::Type::ConstantArray:
5194 case clang::Type::DependentVector:
5195 case clang::Type::ExtVector:
5196 case clang::Type::Vector:
5199 case clang::Type::BitInt:
5200 case clang::Type::DependentBitInt:
5204 case clang::Type::Builtin:
5205 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5206 case clang::BuiltinType::UnknownAny:
5207 case clang::BuiltinType::Void:
5208 case clang::BuiltinType::BoundMember:
5211 case clang::BuiltinType::Bool:
5213 case clang::BuiltinType::Char_S:
5214 case clang::BuiltinType::SChar:
5215 case clang::BuiltinType::WChar_S:
5216 case clang::BuiltinType::Char_U:
5217 case clang::BuiltinType::UChar:
5218 case clang::BuiltinType::WChar_U:
5220 case clang::BuiltinType::Char8:
5222 case clang::BuiltinType::Char16:
5224 case clang::BuiltinType::Char32:
5226 case clang::BuiltinType::UShort:
5228 case clang::BuiltinType::Short:
5230 case clang::BuiltinType::UInt:
5232 case clang::BuiltinType::Int:
5234 case clang::BuiltinType::ULong:
5236 case clang::BuiltinType::Long:
5238 case clang::BuiltinType::ULongLong:
5240 case clang::BuiltinType::LongLong:
5242 case clang::BuiltinType::UInt128:
5244 case clang::BuiltinType::Int128:
5246 case clang::BuiltinType::Half:
5247 case clang::BuiltinType::Float:
5248 case clang::BuiltinType::Double:
5249 case clang::BuiltinType::LongDouble:
5251 case clang::BuiltinType::Float128:
5257 case clang::Type::ObjCObjectPointer:
5259 case clang::Type::BlockPointer:
5261 case clang::Type::Pointer:
5263 case clang::Type::LValueReference:
5264 case clang::Type::RValueReference:
5266 case clang::Type::MemberPointer:
5268 case clang::Type::Complex: {
5269 if (qual_type->isComplexType())
5274 case clang::Type::ObjCInterface:
5276 case clang::Type::Record:
5278 case clang::Type::Enum:
5280 case clang::Type::DependentSizedArray:
5281 case clang::Type::DependentSizedExtVector:
5282 case clang::Type::UnresolvedUsing:
5283 case clang::Type::Attributed:
5284 case clang::Type::BTFTagAttributed:
5285 case clang::Type::TemplateTypeParm:
5286 case clang::Type::SubstTemplateTypeParm:
5287 case clang::Type::SubstTemplateTypeParmPack:
5288 case clang::Type::InjectedClassName:
5289 case clang::Type::DependentName:
5290 case clang::Type::PackExpansion:
5291 case clang::Type::ObjCObject:
5293 case clang::Type::TemplateSpecialization:
5294 case clang::Type::DeducedTemplateSpecialization:
5295 case clang::Type::Adjusted:
5296 case clang::Type::Pipe:
5300 case clang::Type::Decayed:
5302 case clang::Type::ObjCTypeParam:
5305 case clang::Type::DependentAddressSpace:
5307 case clang::Type::MacroQualified:
5311 case clang::Type::ConstantMatrix:
5312 case clang::Type::DependentSizedMatrix:
5316 case clang::Type::PackIndexing:
5319 case clang::Type::HLSLAttributedResource:
5321 case clang::Type::HLSLInlineSpirv:
5323 case clang::Type::SubstBuiltinTemplatePack:
5331 while (class_interface_decl) {
5332 if (class_interface_decl->ivar_size() > 0)
5335 class_interface_decl = class_interface_decl->getSuperClass();
5340static std::optional<SymbolFile::ArrayInfo>
5342 clang::QualType qual_type,
5344 if (qual_type->isIncompleteArrayType())
5345 if (std::optional<ClangASTMetadata> metadata =
5349 return std::nullopt;
5352llvm::Expected<uint32_t>
5354 bool omit_empty_base_classes,
5357 return llvm::createStringError(
"invalid clang type");
5359 uint32_t num_children = 0;
5361 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5362 switch (type_class) {
5363 case clang::Type::Builtin:
5364 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5365 case clang::BuiltinType::ObjCId:
5366 case clang::BuiltinType::ObjCClass:
5375 case clang::Type::Complex:
5377 case clang::Type::Record:
5379 const clang::RecordType *record_type =
5380 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5381 const clang::RecordDecl *record_decl =
5382 record_type->getDecl()->getDefinitionOrSelf();
5383 const clang::CXXRecordDecl *cxx_record_decl =
5384 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5388 num_children += std::distance(record_decl->field_begin(),
5389 record_decl->field_end());
5391 return llvm::createStringError(
5394 case clang::Type::ObjCObject:
5395 case clang::Type::ObjCInterface:
5397 const clang::ObjCObjectType *objc_class_type =
5398 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5399 assert(objc_class_type);
5400 if (objc_class_type) {
5401 clang::ObjCInterfaceDecl *class_interface_decl =
5402 objc_class_type->getInterface();
5404 if (class_interface_decl) {
5406 clang::ObjCInterfaceDecl *superclass_interface_decl =
5407 class_interface_decl->getSuperClass();
5408 if (superclass_interface_decl) {
5409 if (omit_empty_base_classes) {
5416 num_children += class_interface_decl->ivar_size();
5422 case clang::Type::LValueReference:
5423 case clang::Type::RValueReference:
5424 case clang::Type::ObjCObjectPointer: {
5427 uint32_t num_pointee_children = 0;
5429 auto num_children_or_err =
5430 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5431 if (!num_children_or_err)
5432 return num_children_or_err;
5433 num_pointee_children = *num_children_or_err;
5436 if (num_pointee_children == 0)
5439 num_children = num_pointee_children;
5442 case clang::Type::Vector:
5443 case clang::Type::ExtVector:
5445 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5448 case clang::Type::ConstantArray:
5449 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5453 case clang::Type::IncompleteArray:
5454 if (
auto array_info =
5457 num_children = array_info->element_orders.size()
5458 ? array_info->element_orders.back().value_or(0)
5462 case clang::Type::Pointer: {
5463 const clang::PointerType *pointer_type =
5464 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5465 clang::QualType pointee_type(pointer_type->getPointeeType());
5467 uint32_t num_pointee_children = 0;
5469 auto num_children_or_err =
5470 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5471 if (!num_children_or_err)
5472 return num_children_or_err;
5473 num_pointee_children = *num_children_or_err;
5475 if (num_pointee_children == 0) {
5480 num_children = num_pointee_children;
5486 return num_children;
5493 if (name_ref.consume_front(
"unsigned _BitInt(") ||
5494 name_ref.consume_front(
"_BitInt(")) {
5496 if (name_ref.consumeInteger(10, bit_size))
5499 if (!name_ref.consume_front(
")"))
5503 name.
GetStringRef().starts_with(
"unsigned"), bit_size));
5512 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5513 if (type_class == clang::Type::Builtin) {
5514 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5515 case clang::BuiltinType::Void:
5517 case clang::BuiltinType::Bool:
5519 case clang::BuiltinType::Char_S:
5521 case clang::BuiltinType::Char_U:
5523 case clang::BuiltinType::Char8:
5525 case clang::BuiltinType::Char16:
5527 case clang::BuiltinType::Char32:
5529 case clang::BuiltinType::UChar:
5531 case clang::BuiltinType::SChar:
5533 case clang::BuiltinType::WChar_S:
5535 case clang::BuiltinType::WChar_U:
5537 case clang::BuiltinType::Short:
5539 case clang::BuiltinType::UShort:
5541 case clang::BuiltinType::Int:
5543 case clang::BuiltinType::UInt:
5545 case clang::BuiltinType::Long:
5547 case clang::BuiltinType::ULong:
5549 case clang::BuiltinType::LongLong:
5551 case clang::BuiltinType::ULongLong:
5553 case clang::BuiltinType::Int128:
5555 case clang::BuiltinType::UInt128:
5558 case clang::BuiltinType::Half:
5560 case clang::BuiltinType::Float:
5562 case clang::BuiltinType::Double:
5564 case clang::BuiltinType::LongDouble:
5566 case clang::BuiltinType::Float128:
5569 case clang::BuiltinType::NullPtr:
5571 case clang::BuiltinType::ObjCId:
5573 case clang::BuiltinType::ObjCClass:
5575 case clang::BuiltinType::ObjCSel:
5589 const llvm::APSInt &value)>
const &callback) {
5590 const clang::EnumType *enum_type =
5593 const clang::EnumDecl *enum_decl =
5594 enum_type->getDecl()->getDefinitionOrSelf();
5598 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5599 for (enum_pos = enum_decl->enumerator_begin(),
5600 enum_end_pos = enum_decl->enumerator_end();
5601 enum_pos != enum_end_pos; ++enum_pos) {
5602 ConstString name(enum_pos->getNameAsString().c_str());
5603 if (!callback(integer_type, name, enum_pos->getInitVal()))
5610#pragma mark Aggregate Types
5618 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5619 switch (type_class) {
5620 case clang::Type::Record:
5622 const clang::RecordType *record_type =
5623 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5625 clang::RecordDecl *record_decl =
5626 record_type->getDecl()->getDefinition();
5628 count = std::distance(record_decl->field_begin(),
5629 record_decl->field_end());
5635 case clang::Type::ObjCObjectPointer: {
5636 const clang::ObjCObjectPointerType *objc_class_type =
5637 qual_type->castAs<clang::ObjCObjectPointerType>();
5638 const clang::ObjCInterfaceType *objc_interface_type =
5639 objc_class_type->getInterfaceType();
5640 if (objc_interface_type &&
5642 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5643 clang::ObjCInterfaceDecl *class_interface_decl =
5644 objc_interface_type->getDecl();
5645 if (class_interface_decl) {
5646 count = class_interface_decl->ivar_size();
5652 case clang::Type::ObjCObject:
5653 case clang::Type::ObjCInterface:
5655 const clang::ObjCObjectType *objc_class_type =
5656 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5657 if (objc_class_type) {
5658 clang::ObjCInterfaceDecl *class_interface_decl =
5659 objc_class_type->getInterface();
5661 if (class_interface_decl)
5662 count = class_interface_decl->ivar_size();
5675 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5676 std::string &name, uint64_t *bit_offset_ptr,
5677 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5678 if (class_interface_decl) {
5679 if (idx < (class_interface_decl->ivar_size())) {
5680 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5681 ivar_end = class_interface_decl->ivar_end();
5682 uint32_t ivar_idx = 0;
5684 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5685 ++ivar_pos, ++ivar_idx) {
5686 if (ivar_idx == idx) {
5687 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5689 clang::QualType ivar_qual_type(ivar_decl->getType());
5691 name.assign(ivar_decl->getNameAsString());
5693 if (bit_offset_ptr) {
5694 const clang::ASTRecordLayout &interface_layout =
5695 ast->getASTObjCInterfaceLayout(class_interface_decl);
5696 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5699 const bool is_bitfield = ivar_pos->isBitField();
5701 if (bitfield_bit_size_ptr) {
5702 *bitfield_bit_size_ptr = 0;
5704 if (is_bitfield && ast) {
5705 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5706 clang::Expr::EvalResult result;
5707 if (bitfield_bit_size_expr &&
5708 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5709 llvm::APSInt bitfield_apsint = result.Val.getInt();
5710 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5714 if (is_bitfield_ptr)
5715 *is_bitfield_ptr = is_bitfield;
5717 return ivar_qual_type.getAsOpaquePtr();
5726 size_t idx, std::string &name,
5727 uint64_t *bit_offset_ptr,
5728 uint32_t *bitfield_bit_size_ptr,
5729 bool *is_bitfield_ptr) {
5734 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5735 switch (type_class) {
5736 case clang::Type::Record:
5738 const clang::RecordType *record_type =
5739 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5740 const clang::RecordDecl *record_decl =
5741 record_type->getDecl()->getDefinitionOrSelf();
5742 uint32_t field_idx = 0;
5743 clang::RecordDecl::field_iterator field, field_end;
5744 for (field = record_decl->field_begin(),
5745 field_end = record_decl->field_end();
5746 field != field_end; ++field, ++field_idx) {
5747 if (idx == field_idx) {
5750 name.assign(field->getNameAsString());
5754 if (bit_offset_ptr) {
5755 const clang::ASTRecordLayout &record_layout =
5757 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5760 const bool is_bitfield = field->isBitField();
5762 if (bitfield_bit_size_ptr) {
5763 *bitfield_bit_size_ptr = 0;
5766 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5767 clang::Expr::EvalResult result;
5768 if (bitfield_bit_size_expr &&
5769 bitfield_bit_size_expr->EvaluateAsInt(result,
5771 llvm::APSInt bitfield_apsint = result.Val.getInt();
5772 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5776 if (is_bitfield_ptr)
5777 *is_bitfield_ptr = is_bitfield;
5779 return GetType(field->getType());
5785 case clang::Type::ObjCObjectPointer: {
5786 const clang::ObjCObjectPointerType *objc_class_type =
5787 qual_type->castAs<clang::ObjCObjectPointerType>();
5788 const clang::ObjCInterfaceType *objc_interface_type =
5789 objc_class_type->getInterfaceType();
5790 if (objc_interface_type &&
5792 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5793 clang::ObjCInterfaceDecl *class_interface_decl =
5794 objc_interface_type->getDecl();
5795 if (class_interface_decl) {
5799 name, bit_offset_ptr, bitfield_bit_size_ptr,
5806 case clang::Type::ObjCObject:
5807 case clang::Type::ObjCInterface:
5809 const clang::ObjCObjectType *objc_class_type =
5810 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5811 assert(objc_class_type);
5812 if (objc_class_type) {
5813 clang::ObjCInterfaceDecl *class_interface_decl =
5814 objc_class_type->getInterface();
5818 name, bit_offset_ptr, bitfield_bit_size_ptr,
5834 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5835 switch (type_class) {
5836 case clang::Type::Record:
5838 const clang::CXXRecordDecl *cxx_record_decl =
5839 qual_type->getAsCXXRecordDecl();
5840 if (cxx_record_decl)
5841 count = cxx_record_decl->getNumBases();
5845 case clang::Type::ObjCObjectPointer:
5849 case clang::Type::ObjCObject:
5851 const clang::ObjCObjectType *objc_class_type =
5852 qual_type->getAsObjCQualifiedInterfaceType();
5853 if (objc_class_type) {
5854 clang::ObjCInterfaceDecl *class_interface_decl =
5855 objc_class_type->getInterface();
5857 if (class_interface_decl && class_interface_decl->getSuperClass())
5862 case clang::Type::ObjCInterface:
5864 const clang::ObjCInterfaceType *objc_interface_type =
5865 qual_type->getAs<clang::ObjCInterfaceType>();
5866 if (objc_interface_type) {
5867 clang::ObjCInterfaceDecl *class_interface_decl =
5868 objc_interface_type->getInterface();
5870 if (class_interface_decl && class_interface_decl->getSuperClass())
5886 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5887 switch (type_class) {
5888 case clang::Type::Record:
5890 const clang::CXXRecordDecl *cxx_record_decl =
5891 qual_type->getAsCXXRecordDecl();
5892 if (cxx_record_decl)
5893 count = cxx_record_decl->getNumVBases();
5906 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5907 switch (type_class) {
5908 case clang::Type::Record:
5910 const clang::CXXRecordDecl *cxx_record_decl =
5911 qual_type->getAsCXXRecordDecl();
5912 if (cxx_record_decl) {
5913 uint32_t curr_idx = 0;
5914 clang::CXXRecordDecl::base_class_const_iterator base_class,
5916 for (base_class = cxx_record_decl->bases_begin(),
5917 base_class_end = cxx_record_decl->bases_end();
5918 base_class != base_class_end; ++base_class, ++curr_idx) {
5919 if (curr_idx == idx) {
5920 if (bit_offset_ptr) {
5921 const clang::ASTRecordLayout &record_layout =
5923 const clang::CXXRecordDecl *base_class_decl =
5924 llvm::cast<clang::CXXRecordDecl>(
5925 base_class->getType()
5926 ->castAs<clang::RecordType>()
5928 if (base_class->isVirtual())
5930 record_layout.getVBaseClassOffset(base_class_decl)
5935 record_layout.getBaseClassOffset(base_class_decl)
5939 return GetType(base_class->getType());
5946 case clang::Type::ObjCObjectPointer:
5949 case clang::Type::ObjCObject:
5951 const clang::ObjCObjectType *objc_class_type =
5952 qual_type->getAsObjCQualifiedInterfaceType();
5953 if (objc_class_type) {
5954 clang::ObjCInterfaceDecl *class_interface_decl =
5955 objc_class_type->getInterface();
5957 if (class_interface_decl) {
5958 clang::ObjCInterfaceDecl *superclass_interface_decl =
5959 class_interface_decl->getSuperClass();
5960 if (superclass_interface_decl) {
5962 *bit_offset_ptr = 0;
5964 superclass_interface_decl));
5970 case clang::Type::ObjCInterface:
5972 const clang::ObjCObjectType *objc_interface_type =
5973 qual_type->getAs<clang::ObjCInterfaceType>();
5974 if (objc_interface_type) {
5975 clang::ObjCInterfaceDecl *class_interface_decl =
5976 objc_interface_type->getInterface();
5978 if (class_interface_decl) {
5979 clang::ObjCInterfaceDecl *superclass_interface_decl =
5980 class_interface_decl->getSuperClass();
5981 if (superclass_interface_decl) {
5983 *bit_offset_ptr = 0;
5985 superclass_interface_decl));
6001 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6002 switch (type_class) {
6003 case clang::Type::Record:
6005 const clang::CXXRecordDecl *cxx_record_decl =
6006 qual_type->getAsCXXRecordDecl();
6007 if (cxx_record_decl) {
6008 uint32_t curr_idx = 0;
6009 clang::CXXRecordDecl::base_class_const_iterator base_class,
6011 for (base_class = cxx_record_decl->vbases_begin(),
6012 base_class_end = cxx_record_decl->vbases_end();
6013 base_class != base_class_end; ++base_class, ++curr_idx) {
6014 if (curr_idx == idx) {
6015 if (bit_offset_ptr) {
6016 const clang::ASTRecordLayout &record_layout =
6018 const clang::CXXRecordDecl *base_class_decl =
6019 llvm::cast<clang::CXXRecordDecl>(
6020 base_class->getType()
6021 ->castAs<clang::RecordType>()
6024 record_layout.getVBaseClassOffset(base_class_decl)
6028 return GetType(base_class->getType());
6043 llvm::StringRef name) {
6045 switch (qual_type->getTypeClass()) {
6046 case clang::Type::Record: {
6050 const clang::RecordType *record_type =
6051 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6052 const clang::RecordDecl *record_decl =
6053 record_type->getDecl()->getDefinitionOrSelf();
6055 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
6056 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
6057 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
6058 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
6082 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6083 switch (type_class) {
6084 case clang::Type::Builtin:
6085 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6086 case clang::BuiltinType::UnknownAny:
6087 case clang::BuiltinType::Void:
6088 case clang::BuiltinType::NullPtr:
6089 case clang::BuiltinType::OCLEvent:
6090 case clang::BuiltinType::OCLImage1dRO:
6091 case clang::BuiltinType::OCLImage1dWO:
6092 case clang::BuiltinType::OCLImage1dRW:
6093 case clang::BuiltinType::OCLImage1dArrayRO:
6094 case clang::BuiltinType::OCLImage1dArrayWO:
6095 case clang::BuiltinType::OCLImage1dArrayRW:
6096 case clang::BuiltinType::OCLImage1dBufferRO:
6097 case clang::BuiltinType::OCLImage1dBufferWO:
6098 case clang::BuiltinType::OCLImage1dBufferRW:
6099 case clang::BuiltinType::OCLImage2dRO:
6100 case clang::BuiltinType::OCLImage2dWO:
6101 case clang::BuiltinType::OCLImage2dRW:
6102 case clang::BuiltinType::OCLImage2dArrayRO:
6103 case clang::BuiltinType::OCLImage2dArrayWO:
6104 case clang::BuiltinType::OCLImage2dArrayRW:
6105 case clang::BuiltinType::OCLImage3dRO:
6106 case clang::BuiltinType::OCLImage3dWO:
6107 case clang::BuiltinType::OCLImage3dRW:
6108 case clang::BuiltinType::OCLSampler:
6109 case clang::BuiltinType::HLSLResource:
6111 case clang::BuiltinType::Bool:
6112 case clang::BuiltinType::Char_U:
6113 case clang::BuiltinType::UChar:
6114 case clang::BuiltinType::WChar_U:
6115 case clang::BuiltinType::Char16:
6116 case clang::BuiltinType::Char32:
6117 case clang::BuiltinType::UShort:
6118 case clang::BuiltinType::UInt:
6119 case clang::BuiltinType::ULong:
6120 case clang::BuiltinType::ULongLong:
6121 case clang::BuiltinType::UInt128:
6122 case clang::BuiltinType::Char_S:
6123 case clang::BuiltinType::SChar:
6124 case clang::BuiltinType::WChar_S:
6125 case clang::BuiltinType::Short:
6126 case clang::BuiltinType::Int:
6127 case clang::BuiltinType::Long:
6128 case clang::BuiltinType::LongLong:
6129 case clang::BuiltinType::Int128:
6130 case clang::BuiltinType::Float:
6131 case clang::BuiltinType::Double:
6132 case clang::BuiltinType::LongDouble:
6133 case clang::BuiltinType::Float128:
6134 case clang::BuiltinType::Dependent:
6135 case clang::BuiltinType::Overload:
6136 case clang::BuiltinType::ObjCId:
6137 case clang::BuiltinType::ObjCClass:
6138 case clang::BuiltinType::ObjCSel:
6139 case clang::BuiltinType::BoundMember:
6140 case clang::BuiltinType::Half:
6141 case clang::BuiltinType::ARCUnbridgedCast:
6142 case clang::BuiltinType::PseudoObject:
6143 case clang::BuiltinType::BuiltinFn:
6144 case clang::BuiltinType::ArraySection:
6151 case clang::Type::Complex:
6153 case clang::Type::Pointer:
6155 case clang::Type::BlockPointer:
6158 case clang::Type::LValueReference:
6160 case clang::Type::RValueReference:
6162 case clang::Type::MemberPointer:
6164 case clang::Type::ConstantArray:
6166 case clang::Type::IncompleteArray:
6168 case clang::Type::VariableArray:
6170 case clang::Type::DependentSizedArray:
6172 case clang::Type::DependentSizedExtVector:
6174 case clang::Type::Vector:
6176 case clang::Type::ExtVector:
6178 case clang::Type::FunctionProto:
6180 case clang::Type::FunctionNoProto:
6182 case clang::Type::UnresolvedUsing:
6184 case clang::Type::Record:
6186 case clang::Type::Enum:
6188 case clang::Type::TemplateTypeParm:
6190 case clang::Type::SubstTemplateTypeParm:
6192 case clang::Type::TemplateSpecialization:
6194 case clang::Type::InjectedClassName:
6196 case clang::Type::DependentName:
6198 case clang::Type::ObjCObject:
6200 case clang::Type::ObjCInterface:
6202 case clang::Type::ObjCObjectPointer:
6212 std::string &deref_name, uint32_t &deref_byte_size,
6213 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6217 return llvm::createStringError(
"not a pointer, reference or array type");
6218 uint32_t child_bitfield_bit_size = 0;
6219 uint32_t child_bitfield_bit_offset = 0;
6220 bool child_is_base_class;
6221 bool child_is_deref_of_parent;
6223 type, exe_ctx, 0,
false,
true,
false, deref_name, deref_byte_size,
6224 deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6225 child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
6230 bool transparent_pointers,
bool omit_empty_base_classes,
6231 bool ignore_array_bounds, std::string &child_name,
6232 uint32_t &child_byte_size, int32_t &child_byte_offset,
6233 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6234 bool &child_is_base_class,
bool &child_is_deref_of_parent,
6237 return llvm::createStringError(
"invalid type");
6239 auto get_exe_scope = [&exe_ctx]() {
6243 clang::QualType parent_qual_type(
6245 const clang::Type::TypeClass parent_type_class =
6246 parent_qual_type->getTypeClass();
6247 child_bitfield_bit_size = 0;
6248 child_bitfield_bit_offset = 0;
6249 child_is_base_class =
false;
6252 auto num_children_or_err =
6254 if (!num_children_or_err)
6255 return num_children_or_err.takeError();
6257 const bool idx_is_valid = idx < *num_children_or_err;
6259 switch (parent_type_class) {
6260 case clang::Type::Builtin:
6262 return llvm::createStringError(
"invalid index");
6264 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6265 case clang::BuiltinType::ObjCId:
6266 case clang::BuiltinType::ObjCClass:
6277 case clang::Type::Record: {
6279 return llvm::createStringError(
"invalid index");
6281 return llvm::createStringError(
"cannot complete type");
6283 const clang::RecordType *record_type =
6284 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6285 const clang::RecordDecl *record_decl =
6286 record_type->getDecl()->getDefinitionOrSelf();
6287 const clang::ASTRecordLayout &record_layout =
6289 uint32_t child_idx = 0;
6291 const clang::CXXRecordDecl *cxx_record_decl =
6292 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6293 if (cxx_record_decl) {
6295 clang::CXXRecordDecl::base_class_const_iterator base_class,
6297 for (base_class = cxx_record_decl->bases_begin(),
6298 base_class_end = cxx_record_decl->bases_end();
6299 base_class != base_class_end; ++base_class) {
6300 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6303 if (omit_empty_base_classes) {
6305 llvm::cast<clang::CXXRecordDecl>(
6306 base_class->getType()->getAs<clang::RecordType>()->getDecl())
6307 ->getDefinitionOrSelf();
6312 if (idx == child_idx) {
6313 if (base_class_decl ==
nullptr)
6314 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6315 base_class->getType()
6316 ->getAs<clang::RecordType>()
6318 ->getDefinitionOrSelf();
6320 if (base_class->isVirtual()) {
6321 bool handled =
false;
6323 clang::VTableContextBase *vtable_ctx =
6327 cxx_record_decl, base_class_decl,
6331 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6335 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6340 child_byte_offset = bit_offset / 8;
6343 auto size_or_err = base_class_clang_type.
GetBitSize(get_exe_scope());
6345 return llvm::joinErrors(
6346 llvm::createStringError(
"no size info for base class"),
6347 size_or_err.takeError());
6349 uint64_t base_class_clang_type_bit_size = *size_or_err;
6352 assert(base_class_clang_type_bit_size % 8 == 0);
6353 child_byte_size = base_class_clang_type_bit_size / 8;
6354 child_is_base_class =
true;
6355 return base_class_clang_type;
6363 uint32_t field_idx = 0;
6364 clang::RecordDecl::field_iterator field, field_end;
6365 for (field = record_decl->field_begin(),
6366 field_end = record_decl->field_end();
6367 field != field_end; ++field, ++field_idx, ++child_idx) {
6368 if (idx == child_idx) {
6371 child_name.assign(field->getNameAsString());
6376 assert(field_idx < record_layout.getFieldCount());
6377 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6379 return llvm::joinErrors(
6380 llvm::createStringError(
"no size info for field"),
6381 size_or_err.takeError());
6383 child_byte_size = *size_or_err;
6384 const uint32_t child_bit_size = child_byte_size * 8;
6388 bit_offset = record_layout.getFieldOffset(field_idx);
6390 child_bitfield_bit_offset = bit_offset % child_bit_size;
6391 const uint32_t child_bit_offset =
6392 bit_offset - child_bitfield_bit_offset;
6393 child_byte_offset = child_bit_offset / 8;
6395 child_byte_offset = bit_offset / 8;
6398 return field_clang_type;
6402 case clang::Type::ObjCObject:
6403 case clang::Type::ObjCInterface: {
6405 return llvm::createStringError(
"invalid index");
6407 return llvm::createStringError(
"cannot complete type");
6409 const clang::ObjCObjectType *objc_class_type =
6410 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6411 assert(objc_class_type);
6412 if (!objc_class_type)
6413 return llvm::createStringError(
"unexpected object type");
6415 uint32_t child_idx = 0;
6416 clang::ObjCInterfaceDecl *class_interface_decl =
6417 objc_class_type->getInterface();
6419 if (!class_interface_decl)
6420 return llvm::createStringError(
"cannot get interface decl");
6422 const clang::ASTRecordLayout &interface_layout =
6423 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6424 clang::ObjCInterfaceDecl *superclass_interface_decl =
6425 class_interface_decl->getSuperClass();
6426 if (superclass_interface_decl) {
6427 if (omit_empty_base_classes) {
6429 getASTContext().getObjCInterfaceType(superclass_interface_decl));
6430 if (llvm::expectedToStdOptional(base_class_clang_type.
GetNumChildren(
6431 omit_empty_base_classes, exe_ctx))
6434 clang::QualType ivar_qual_type(
getASTContext().getObjCInterfaceType(
6435 superclass_interface_decl));
6437 child_name.assign(superclass_interface_decl->getNameAsString());
6439 clang::TypeInfo ivar_type_info =
6442 child_byte_size = ivar_type_info.Width / 8;
6443 child_byte_offset = 0;
6444 child_is_base_class =
true;
6446 return GetType(ivar_qual_type);
6455 const uint32_t superclass_idx = child_idx;
6457 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6458 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6459 ivar_end = class_interface_decl->ivar_end();
6461 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
6463 if (child_idx == idx) {
6464 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6466 clang::QualType ivar_qual_type(ivar_decl->getType());
6468 child_name.assign(ivar_decl->getNameAsString());
6470 clang::TypeInfo ivar_type_info =
6473 child_byte_size = ivar_type_info.Width / 8;
6489 if (objc_runtime !=
nullptr) {
6492 parent_ast_type, ivar_decl->getNameAsString().c_str());
6500 if (child_byte_offset ==
6503 interface_layout.getFieldOffset(child_idx - superclass_idx);
6504 child_byte_offset = bit_offset / 8;
6516 interface_layout.getFieldOffset(child_idx - superclass_idx);
6518 child_bitfield_bit_offset = bit_offset % 8;
6520 return GetType(ivar_qual_type);
6527 case clang::Type::ObjCObjectPointer: {
6529 return llvm::createStringError(
"invalid index");
6533 child_is_deref_of_parent =
false;
6534 bool tmp_child_is_deref_of_parent =
false;
6536 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6537 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6538 child_bitfield_bit_size, child_bitfield_bit_offset,
6539 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6542 child_is_deref_of_parent =
true;
6543 const char *parent_name =
6546 child_name.assign(1,
'*');
6547 child_name += parent_name;
6552 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6554 return size_or_err.takeError();
6555 child_byte_size = *size_or_err;
6556 child_byte_offset = 0;
6557 return pointee_clang_type;
6562 case clang::Type::Vector:
6563 case clang::Type::ExtVector: {
6565 return llvm::createStringError(
"invalid index");
6566 const clang::VectorType *array =
6567 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6569 return llvm::createStringError(
"unexpected vector type");
6573 return llvm::createStringError(
"cannot complete type");
6575 char element_name[64];
6576 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6577 static_cast<uint64_t
>(idx));
6578 child_name.assign(element_name);
6579 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6581 return size_or_err.takeError();
6582 child_byte_size = *size_or_err;
6583 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6584 return element_type;
6586 case clang::Type::ConstantArray:
6587 case clang::Type::IncompleteArray: {
6588 if (!ignore_array_bounds && !idx_is_valid)
6589 return llvm::createStringError(
"invalid index");
6590 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6592 return llvm::createStringError(
"unexpected array type");
6595 return llvm::createStringError(
"cannot complete type");
6597 child_name = std::string(llvm::formatv(
"[{0}]", idx));
6598 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6600 return size_or_err.takeError();
6601 child_byte_size = *size_or_err;
6602 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6603 return element_type;
6605 case clang::Type::Pointer: {
6610 return llvm::createStringError(
"cannot dereference void *");
6613 child_is_deref_of_parent =
false;
6614 bool tmp_child_is_deref_of_parent =
false;
6616 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6617 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6618 child_bitfield_bit_size, child_bitfield_bit_offset,
6619 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6622 child_is_deref_of_parent =
true;
6626 child_name.assign(1,
'*');
6627 child_name += parent_name;
6632 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6634 return size_or_err.takeError();
6635 child_byte_size = *size_or_err;
6636 child_byte_offset = 0;
6637 return pointee_clang_type;
6642 case clang::Type::LValueReference:
6643 case clang::Type::RValueReference: {
6645 return llvm::createStringError(
"invalid index");
6646 const clang::ReferenceType *reference_type =
6647 llvm::cast<clang::ReferenceType>(
6651 child_is_deref_of_parent =
false;
6652 bool tmp_child_is_deref_of_parent =
false;
6654 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6655 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6656 child_bitfield_bit_size, child_bitfield_bit_offset,
6657 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6662 child_name.assign(1,
'&');
6663 child_name += parent_name;
6668 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6670 return size_or_err.takeError();
6671 child_byte_size = *size_or_err;
6672 child_byte_offset = 0;
6673 return pointee_clang_type;
6680 return llvm::createStringError(
"cannot enumerate children");
6684 const clang::RecordDecl *record_decl,
6685 const clang::CXXBaseSpecifier *base_spec,
6686 bool omit_empty_base_classes) {
6687 uint32_t child_idx = 0;
6689 const clang::CXXRecordDecl *cxx_record_decl =
6690 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6692 if (cxx_record_decl) {
6693 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6694 for (base_class = cxx_record_decl->bases_begin(),
6695 base_class_end = cxx_record_decl->bases_end();
6696 base_class != base_class_end; ++base_class) {
6697 if (omit_empty_base_classes) {
6702 if (base_class == base_spec)
6712 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6713 bool omit_empty_base_classes) {
6715 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6716 omit_empty_base_classes);
6718 clang::RecordDecl::field_iterator field, field_end;
6719 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6720 field != field_end; ++field, ++child_idx) {
6721 if (field->getCanonicalDecl() == canonical_decl)
6763 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6764 if (type && !name.empty()) {
6766 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6767 switch (type_class) {
6768 case clang::Type::Record:
6770 const clang::RecordType *record_type =
6771 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6772 const clang::RecordDecl *record_decl =
6773 record_type->getDecl()->getDefinitionOrSelf();
6775 assert(record_decl);
6776 uint32_t child_idx = 0;
6778 const clang::CXXRecordDecl *cxx_record_decl =
6779 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6782 clang::RecordDecl::field_iterator field, field_end;
6783 for (field = record_decl->field_begin(),
6784 field_end = record_decl->field_end();
6785 field != field_end; ++field, ++child_idx) {
6786 llvm::StringRef field_name = field->getName();
6787 if (field_name.empty()) {
6789 std::vector<uint32_t> save_indices = child_indexes;
6790 child_indexes.push_back(
6792 cxx_record_decl, omit_empty_base_classes));
6794 name, omit_empty_base_classes, child_indexes))
6795 return child_indexes.size();
6796 child_indexes = std::move(save_indices);
6797 }
else if (field_name == name) {
6799 child_indexes.push_back(
6801 cxx_record_decl, omit_empty_base_classes));
6802 return child_indexes.size();
6806 if (cxx_record_decl) {
6807 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6810 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6811 clang::DeclarationName decl_name(&ident_ref);
6813 clang::CXXBasePaths paths;
6814 if (cxx_record_decl->lookupInBases(
6815 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6816 clang::CXXBasePath &path) {
6817 CXXRecordDecl *record =
6818 specifier->getType()->getAsCXXRecordDecl();
6819 auto r = record->lookup(decl_name);
6820 path.Decls = r.begin();
6824 clang::CXXBasePaths::const_paths_iterator path,
6825 path_end = paths.end();
6826 for (path = paths.begin(); path != path_end; ++path) {
6827 const size_t num_path_elements = path->size();
6828 for (
size_t e = 0; e < num_path_elements; ++e) {
6829 clang::CXXBasePathElement elem = (*path)[e];
6832 omit_empty_base_classes);
6834 child_indexes.clear();
6837 child_indexes.push_back(child_idx);
6838 parent_record_decl = elem.Base->getType()
6839 ->castAs<clang::RecordType>()
6841 ->getDefinitionOrSelf();
6844 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6847 parent_record_decl, *I, omit_empty_base_classes);
6849 child_indexes.clear();
6852 child_indexes.push_back(child_idx);
6856 return child_indexes.size();
6862 case clang::Type::ObjCObject:
6863 case clang::Type::ObjCInterface:
6865 llvm::StringRef name_sref(name);
6866 const clang::ObjCObjectType *objc_class_type =
6867 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6868 assert(objc_class_type);
6869 if (objc_class_type) {
6870 uint32_t child_idx = 0;
6871 clang::ObjCInterfaceDecl *class_interface_decl =
6872 objc_class_type->getInterface();
6874 if (class_interface_decl) {
6875 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6876 ivar_end = class_interface_decl->ivar_end();
6877 clang::ObjCInterfaceDecl *superclass_interface_decl =
6878 class_interface_decl->getSuperClass();
6880 for (ivar_pos = class_interface_decl->ivar_begin();
6881 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6882 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6884 if (ivar_decl->getName() == name_sref) {
6885 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6886 (omit_empty_base_classes &&
6890 child_indexes.push_back(child_idx);
6891 return child_indexes.size();
6895 if (superclass_interface_decl) {
6899 child_indexes.push_back(0);
6903 superclass_interface_decl));
6905 name, omit_empty_base_classes, child_indexes)) {
6908 return child_indexes.size();
6913 child_indexes.pop_back();
6920 case clang::Type::ObjCObjectPointer: {
6922 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6923 ->getPointeeType());
6925 name, omit_empty_base_classes, child_indexes);
6928 case clang::Type::LValueReference:
6929 case clang::Type::RValueReference: {
6930 const clang::ReferenceType *reference_type =
6931 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
6932 clang::QualType pointee_type(reference_type->getPointeeType());
6937 name, omit_empty_base_classes, child_indexes);
6941 case clang::Type::Pointer: {
6946 name, omit_empty_base_classes, child_indexes);
6961llvm::Expected<uint32_t>
6963 llvm::StringRef name,
6964 bool omit_empty_base_classes) {
6965 if (type && !name.empty()) {
6968 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6970 switch (type_class) {
6971 case clang::Type::Record:
6973 const clang::RecordType *record_type =
6974 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6975 const clang::RecordDecl *record_decl =
6976 record_type->getDecl()->getDefinitionOrSelf();
6978 assert(record_decl);
6979 uint32_t child_idx = 0;
6981 const clang::CXXRecordDecl *cxx_record_decl =
6982 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6984 if (cxx_record_decl) {
6985 clang::CXXRecordDecl::base_class_const_iterator base_class,
6987 for (base_class = cxx_record_decl->bases_begin(),
6988 base_class_end = cxx_record_decl->bases_end();
6989 base_class != base_class_end; ++base_class) {
6991 clang::CXXRecordDecl *base_class_decl =
6992 llvm::cast<clang::CXXRecordDecl>(
6993 base_class->getType()
6994 ->castAs<clang::RecordType>()
6996 ->getDefinitionOrSelf();
6997 if (omit_empty_base_classes &&
7002 std::string base_class_type_name(
7004 if (base_class_type_name == name)
7011 clang::RecordDecl::field_iterator field, field_end;
7012 for (field = record_decl->field_begin(),
7013 field_end = record_decl->field_end();
7014 field != field_end; ++field, ++child_idx) {
7015 if (field->getName() == name)
7021 case clang::Type::ObjCObject:
7022 case clang::Type::ObjCInterface:
7024 const clang::ObjCObjectType *objc_class_type =
7025 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
7026 assert(objc_class_type);
7027 if (objc_class_type) {
7028 uint32_t child_idx = 0;
7029 clang::ObjCInterfaceDecl *class_interface_decl =
7030 objc_class_type->getInterface();
7032 if (class_interface_decl) {
7033 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
7034 ivar_end = class_interface_decl->ivar_end();
7035 clang::ObjCInterfaceDecl *superclass_interface_decl =
7036 class_interface_decl->getSuperClass();
7038 for (ivar_pos = class_interface_decl->ivar_begin();
7039 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
7040 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
7042 if (ivar_decl->getName() == name) {
7043 if ((!omit_empty_base_classes && superclass_interface_decl) ||
7044 (omit_empty_base_classes &&
7052 if (superclass_interface_decl) {
7053 if (superclass_interface_decl->getName() == name)
7061 case clang::Type::ObjCObjectPointer: {
7063 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7064 ->getPointeeType());
7066 name, omit_empty_base_classes);
7069 case clang::Type::LValueReference:
7070 case clang::Type::RValueReference: {
7071 const clang::ReferenceType *reference_type =
7072 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7077 omit_empty_base_classes);
7081 case clang::Type::Pointer: {
7082 const clang::PointerType *pointer_type =
7083 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7088 omit_empty_base_classes);
7096 return llvm::createStringError(
"Type has no child named '%s'",
7097 name.str().c_str());
7102 llvm::StringRef name) {
7103 if (!type || name.empty())
7107 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7109 switch (type_class) {
7110 case clang::Type::Record: {
7113 const clang::RecordType *record_type =
7114 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7115 const clang::RecordDecl *record_decl =
7116 record_type->getDecl()->getDefinitionOrSelf();
7118 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7119 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7120 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7122 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7124 ElaboratedTypeKeyword::None, std::nullopt,
7140 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7141 return isa<clang::ClassTemplateSpecializationDecl>(
7142 cxx_record_decl->getDecl());
7153 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7154 switch (type_class) {
7155 case clang::Type::Record:
7157 const clang::CXXRecordDecl *cxx_record_decl =
7158 qual_type->getAsCXXRecordDecl();
7159 if (cxx_record_decl) {
7160 const clang::ClassTemplateSpecializationDecl *template_decl =
7161 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7163 if (template_decl) {
7164 const auto &template_arg_list = template_decl->getTemplateArgs();
7165 size_t num_args = template_arg_list.size();
7166 assert(num_args &&
"template specialization without any args");
7167 if (expand_pack && num_args) {
7168 const auto &pack = template_arg_list[num_args - 1];
7169 if (pack.getKind() == clang::TemplateArgument::Pack)
7170 num_args += pack.pack_size() - 1;
7185const clang::ClassTemplateSpecializationDecl *
7192 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7193 switch (type_class) {
7194 case clang::Type::Record: {
7197 const clang::CXXRecordDecl *cxx_record_decl =
7198 qual_type->getAsCXXRecordDecl();
7199 if (!cxx_record_decl)
7201 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7210const TemplateArgument *
7212 size_t idx,
bool expand_pack) {
7213 const auto &args = decl->getTemplateArgs();
7214 const size_t args_size = args.size();
7216 assert(args_size &&
"template specialization without any args");
7220 const size_t last_idx = args_size - 1;
7229 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7230 return idx >= args.size() ? nullptr : &args[idx];
7235 const auto &pack = args[last_idx];
7236 const size_t pack_idx = idx - last_idx;
7237 if (pack_idx >= pack.pack_size())
7239 return &pack.pack_elements()[pack_idx];
7244 size_t arg_idx,
bool expand_pack) {
7245 const clang::ClassTemplateSpecializationDecl *template_decl =
7254 switch (arg->getKind()) {
7255 case clang::TemplateArgument::Null:
7258 case clang::TemplateArgument::NullPtr:
7261 case clang::TemplateArgument::Type:
7264 case clang::TemplateArgument::Declaration:
7267 case clang::TemplateArgument::Integral:
7270 case clang::TemplateArgument::Template:
7273 case clang::TemplateArgument::TemplateExpansion:
7276 case clang::TemplateArgument::Expression:
7279 case clang::TemplateArgument::Pack:
7282 case clang::TemplateArgument::StructuralValue:
7285 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7290 size_t idx,
bool expand_pack) {
7291 const clang::ClassTemplateSpecializationDecl *template_decl =
7297 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7300 return GetType(arg->getAsType());
7303std::optional<CompilerType::IntegralTemplateArgument>
7305 size_t idx,
bool expand_pack) {
7306 const clang::ClassTemplateSpecializationDecl *template_decl =
7309 return std::nullopt;
7313 return std::nullopt;
7315 switch (arg->getKind()) {
7316 case clang::TemplateArgument::Integral:
7317 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7318 case clang::TemplateArgument::StructuralValue: {
7319 clang::APValue value = arg->getAsStructuralValue();
7322 if (value.isFloat())
7323 return {{value.getFloat(), type}};
7326 return {{value.getInt(), type}};
7328 return std::nullopt;
7331 return std::nullopt;
7345 bool is_signed =
false;
7346 bool isUnscopedEnumerationType =
7348 if (isUnscopedEnumerationType)
7369 llvm_unreachable(
"All cases handled above.");
7372llvm::Expected<CompilerType>
7389 uint64_t from_size = 0;
7397 llvm::Expected<uint64_t> from_size = from.
GetByteSize(exe_scope);
7399 return from_size.takeError();
7409 llvm::Expected<uint64_t> byte_size = type.GetByteSize(exe_scope);
7411 return byte_size.takeError();
7412 if (*from_size < *byte_size ||
7413 (*from_size == *byte_size && is_signed == type.IsSigned())) {
7417 llvm_unreachable(
"char type should fit into long long");
7422 llvm::Expected<uint64_t> int_byte_size = int_type.
GetByteSize(exe_scope);
7424 return int_byte_size.takeError();
7432 return (from_size == *int_byte_size)
7438 const clang::EnumType *enutype =
7441 return enutype->getDecl()->getDefinitionOrSelf();
7446 const clang::RecordType *record_type =
7449 return record_type->getDecl()->getDefinitionOrSelf();
7457clang::TypedefNameDecl *
7459 const clang::TypedefType *typedef_type =
7462 return typedef_type->getDecl();
7466clang::CXXRecordDecl *
7471clang::ObjCInterfaceDecl *
7473 const clang::ObjCObjectType *objc_class_type =
7474 llvm::dyn_cast<clang::ObjCObjectType>(
7476 if (objc_class_type)
7477 return objc_class_type->getInterface();
7484 uint32_t bitfield_bit_size) {
7490 clang::ASTContext &clang_ast = ast->getASTContext();
7491 clang::IdentifierInfo *ident =
nullptr;
7493 ident = &clang_ast.Idents.get(name);
7495 clang::FieldDecl *field =
nullptr;
7497 clang::Expr *bit_width =
nullptr;
7498 if (bitfield_bit_size != 0) {
7499 if (clang_ast.IntTy.isNull()) {
7502 "{0} failed: builtin ASTContext types have not been initialized");
7506 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7508 bit_width =
new (clang_ast)
7509 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7510 clang_ast.IntTy, clang::SourceLocation());
7511 bit_width = clang::ConstantExpr::Create(
7512 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7515 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7517 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7518 field->setDeclContext(record_decl);
7519 field->setDeclName(ident);
7522 field->setBitWidth(bit_width);
7528 if (
const clang::TagType *TagT =
7529 field->getType()->getAs<clang::TagType>()) {
7530 if (clang::RecordDecl *Rec =
7531 llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
7532 if (!Rec->getDeclName()) {
7533 Rec->setAnonymousStructOrUnion(
true);
7534 field->setImplicit();
7540 clang::AccessSpecifier access_specifier =
7542 field->setAccess(access_specifier);
7544 if (clang::CXXRecordDecl *cxx_record_decl =
7545 llvm::dyn_cast<CXXRecordDecl>(record_decl)) {
7546 AddAccessSpecifierDecl(cxx_record_decl, ast->getASTContext(),
7547 ast->GetCXXRecordDeclAccess(cxx_record_decl),
7549 ast->SetCXXRecordDeclAccess(cxx_record_decl, access_specifier);
7551 record_decl->addDecl(field);
7556 clang::ObjCInterfaceDecl *class_interface_decl =
7557 ast->GetAsObjCInterfaceDecl(type);
7559 if (class_interface_decl) {
7560 const bool is_synthesized =
false;
7565 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7566 ivar->setDeclContext(class_interface_decl);
7567 ivar->setDeclName(ident);
7571 ivar->setBitWidth(bit_width);
7572 ivar->setSynthesize(is_synthesized);
7577 class_interface_decl->addDecl(field);
7594 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7599 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7601 IndirectFieldVector indirect_fields;
7602 clang::RecordDecl::field_iterator field_pos;
7603 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7604 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7605 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7606 last_field_pos = field_pos++) {
7607 if (field_pos->isAnonymousStructOrUnion()) {
7608 clang::QualType field_qual_type = field_pos->getType();
7610 const clang::RecordType *field_record_type =
7611 field_qual_type->getAs<clang::RecordType>();
7613 if (!field_record_type)
7616 clang::RecordDecl *field_record_decl =
7617 field_record_type->getDecl()->getDefinition();
7619 if (!field_record_decl)
7622 for (clang::RecordDecl::decl_iterator
7623 di = field_record_decl->decls_begin(),
7624 de = field_record_decl->decls_end();
7626 if (clang::FieldDecl *nested_field_decl =
7627 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7628 clang::NamedDecl **chain =
7629 new (ast->getASTContext()) clang::NamedDecl *[2];
7630 chain[0] = *field_pos;
7631 chain[1] = nested_field_decl;
7632 clang::IndirectFieldDecl *indirect_field =
7633 clang::IndirectFieldDecl::Create(
7634 ast->getASTContext(), record_decl, clang::SourceLocation(),
7635 nested_field_decl->getIdentifier(),
7636 nested_field_decl->getType(), {chain, 2});
7639 indirect_field->setImplicit();
7642 field_pos->getAccess(), nested_field_decl->getAccess()));
7644 indirect_fields.push_back(indirect_field);
7645 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7646 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7647 size_t nested_chain_size =
7648 nested_indirect_field_decl->getChainingSize();
7649 clang::NamedDecl **chain =
new (ast->getASTContext())
7650 clang::NamedDecl *[nested_chain_size + 1];
7651 chain[0] = *field_pos;
7653 int chain_index = 1;
7654 for (clang::IndirectFieldDecl::chain_iterator
7655 nci = nested_indirect_field_decl->chain_begin(),
7656 nce = nested_indirect_field_decl->chain_end();
7658 chain[chain_index] = *nci;
7662 clang::IndirectFieldDecl *indirect_field =
7663 clang::IndirectFieldDecl::Create(
7664 ast->getASTContext(), record_decl, clang::SourceLocation(),
7665 nested_indirect_field_decl->getIdentifier(),
7666 nested_indirect_field_decl->getType(),
7667 {chain, nested_chain_size + 1});
7670 indirect_field->setImplicit();
7673 field_pos->getAccess(), nested_indirect_field_decl->getAccess()));
7675 indirect_fields.push_back(indirect_field);
7683 if (last_field_pos != field_end_pos) {
7684 if (last_field_pos->getType()->isIncompleteArrayType())
7685 record_decl->hasFlexibleArrayMember();
7688 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7689 ife = indirect_fields.end();
7691 record_decl->addDecl(*ifi);
7704 record_decl->addAttr(
7705 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7720 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7724 clang::VarDecl *var_decl =
nullptr;
7725 clang::IdentifierInfo *ident =
nullptr;
7727 ident = &ast->getASTContext().Idents.get(name);
7730 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7731 var_decl->setDeclContext(record_decl);
7732 var_decl->setDeclName(ident);
7734 var_decl->setStorageClass(clang::SC_Static);
7739 var_decl->setAccess(
7741 record_decl->addDecl(var_decl);
7743 VerifyDecl(var_decl);
7749 VarDecl *var,
const llvm::APInt &init_value) {
7750 assert(!var->hasInit() &&
"variable already initialized");
7752 clang::ASTContext &ast = var->getASTContext();
7753 QualType qt = var->getType();
7754 assert(qt->isIntegralOrEnumerationType() &&
7755 "only integer or enum types supported");
7758 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7759 const EnumDecl *enum_decl = enum_type->getDecl()->getDefinitionOrSelf();
7760 qt = enum_decl->getIntegerType();
7764 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7765 var->setInit(CXXBoolLiteralExpr::Create(
7766 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7768 var->setInit(IntegerLiteral::Create(
7769 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7774 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7775 assert(!var->hasInit() &&
"variable already initialized");
7777 clang::ASTContext &ast = var->getASTContext();
7778 QualType qt = var->getType();
7779 assert(qt->isFloatingType() &&
"only floating point types supported");
7780 var->setInit(FloatingLiteral::Create(
7781 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7784llvm::SmallVector<clang::ParmVarDecl *>
7786 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7787 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7789 assert(parameter_names.empty() ||
7790 parameter_names.size() == prototype.getNumParams());
7792 llvm::SmallVector<clang::ParmVarDecl *> params;
7793 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7795 llvm::StringRef name =
7796 !parameter_names.empty() ? parameter_names[param_index] :
"";
7800 GetType(prototype.getParamType(param_index)),
7801 clang::SC_None,
false);
7804 params.push_back(param);
7812 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7814 bool is_explicit,
bool is_attr_used,
bool is_artificial) {
7815 if (!type || !method_clang_type.
IsValid() || name.empty())
7820 clang::CXXRecordDecl *cxx_record_decl =
7821 record_qual_type->getAsCXXRecordDecl();
7823 if (cxx_record_decl ==
nullptr)
7828 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7830 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7832 const clang::FunctionType *function_type =
7833 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7835 if (function_type ==
nullptr)
7838 const clang::FunctionProtoType *method_function_prototype(
7839 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7841 if (!method_function_prototype)
7844 unsigned int num_params = method_function_prototype->getNumParams();
7846 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7847 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7852 const clang::ExplicitSpecifier explicit_spec(
7853 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7854 : clang::ExplicitSpecKind::ResolvedFalse);
7856 if (name.starts_with(
"~")) {
7857 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7859 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7860 cxx_dtor_decl->setDeclName(
7863 cxx_dtor_decl->setType(method_qual_type);
7864 cxx_dtor_decl->setImplicit(is_artificial);
7865 cxx_dtor_decl->setInlineSpecified(is_inline);
7866 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7867 cxx_method_decl = cxx_dtor_decl;
7868 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7869 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7871 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7872 cxx_ctor_decl->setDeclName(
7875 cxx_ctor_decl->setType(method_qual_type);
7876 cxx_ctor_decl->setImplicit(is_artificial);
7877 cxx_ctor_decl->setInlineSpecified(is_inline);
7878 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7879 cxx_ctor_decl->setNumCtorInitializers(0);
7880 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7881 cxx_method_decl = cxx_ctor_decl;
7883 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7884 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7887 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7892 const bool is_method =
true;
7894 is_method, op_kind, num_params))
7896 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7898 cxx_method_decl->setDeclContext(cxx_record_decl);
7899 cxx_method_decl->setDeclName(
7900 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7901 cxx_method_decl->setType(method_qual_type);
7902 cxx_method_decl->setStorageClass(SC);
7903 cxx_method_decl->setInlineSpecified(is_inline);
7904 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7905 }
else if (num_params == 0) {
7907 auto *cxx_conversion_decl =
7908 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7910 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7911 cxx_conversion_decl->setDeclName(
7912 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7914 function_type->getReturnType())));
7915 cxx_conversion_decl->setType(method_qual_type);
7916 cxx_conversion_decl->setInlineSpecified(is_inline);
7917 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7918 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7919 cxx_method_decl = cxx_conversion_decl;
7923 if (cxx_method_decl ==
nullptr) {
7924 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7926 cxx_method_decl->setDeclContext(cxx_record_decl);
7927 cxx_method_decl->setDeclName(decl_name);
7928 cxx_method_decl->setType(method_qual_type);
7929 cxx_method_decl->setInlineSpecified(is_inline);
7930 cxx_method_decl->setStorageClass(SC);
7931 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7936 clang::AccessSpecifier access_specifier =
7939 cxx_method_decl->setAccess(access_specifier);
7940 cxx_method_decl->setVirtualAsWritten(is_virtual);
7943 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7945 if (!asm_label.empty())
7946 cxx_method_decl->addAttr(
7947 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7952 cxx_method_decl, *method_function_prototype, {}));
7959 cxx_record_decl->addDecl(cxx_method_decl);
7968 if (is_artificial) {
7969 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7970 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7971 (cxx_ctor_decl->isCopyConstructor() &&
7972 cxx_record_decl->hasTrivialCopyConstructor()) ||
7973 (cxx_ctor_decl->isMoveConstructor() &&
7974 cxx_record_decl->hasTrivialMoveConstructor()))) {
7975 cxx_ctor_decl->setDefaulted();
7976 cxx_ctor_decl->setTrivial(
true);
7977 }
else if (cxx_dtor_decl) {
7978 if (cxx_record_decl->hasTrivialDestructor()) {
7979 cxx_dtor_decl->setDefaulted();
7980 cxx_dtor_decl->setTrivial(
true);
7982 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7983 cxx_record_decl->hasTrivialCopyAssignment()) ||
7984 (cxx_method_decl->isMoveAssignmentOperator() &&
7985 cxx_record_decl->hasTrivialMoveAssignment())) {
7986 cxx_method_decl->setDefaulted();
7987 cxx_method_decl->setTrivial(
true);
7991 VerifyDecl(cxx_method_decl);
7993 return cxx_method_decl;
7999 for (
auto *method : record->methods())
8000 addOverridesForMethod(method);
8003#pragma mark C++ Base Classes
8005std::unique_ptr<clang::CXXBaseSpecifier>
8008 bool base_of_class) {
8012 return std::make_unique<clang::CXXBaseSpecifier>(
8013 clang::SourceRange(), is_virtual, base_of_class,
8016 clang::SourceLocation());
8021 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
8025 if (!cxx_record_decl)
8027 std::vector<clang::CXXBaseSpecifier *> raw_bases;
8028 raw_bases.reserve(bases.size());
8032 for (
auto &b : bases)
8033 raw_bases.push_back(b.get());
8034 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
8043 clang::ASTContext &clang_ast = ast->getASTContext();
8045 if (type && superclass_clang_type.
IsValid() &&
8047 clang::ObjCInterfaceDecl *class_interface_decl =
8049 clang::ObjCInterfaceDecl *super_interface_decl =
8051 if (class_interface_decl && super_interface_decl) {
8052 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
8053 clang_ast.getObjCInterfaceType(super_interface_decl)));
8062 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
8063 const char *property_setter_name,
const char *property_getter_name,
8065 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
8066 property_name[0] ==
'\0')
8071 clang::ASTContext &clang_ast = ast->getASTContext();
8074 if (!class_interface_decl)
8079 if (property_clang_type.
IsValid())
8080 property_clang_type_to_access = property_clang_type;
8082 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
8084 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
8087 clang::TypeSourceInfo *prop_type_source;
8089 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
8091 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
8094 clang::ObjCPropertyDecl *property_decl =
8095 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8096 property_decl->setDeclContext(class_interface_decl);
8097 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
8098 property_decl->setType(ivar_decl
8099 ? ivar_decl->getType()
8107 ast->SetMetadata(property_decl, metadata);
8109 class_interface_decl->addDecl(property_decl);
8111 clang::Selector setter_sel, getter_sel;
8113 if (property_setter_name) {
8114 std::string property_setter_no_colon(property_setter_name,
8115 strlen(property_setter_name) - 1);
8116 const clang::IdentifierInfo *setter_ident =
8117 &clang_ast.Idents.get(property_setter_no_colon);
8118 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8119 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
8120 std::string setter_sel_string(
"set");
8121 setter_sel_string.push_back(::toupper(property_name[0]));
8122 setter_sel_string.append(&property_name[1]);
8123 const clang::IdentifierInfo *setter_ident =
8124 &clang_ast.Idents.get(setter_sel_string);
8125 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8127 property_decl->setSetterName(setter_sel);
8128 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
8130 if (property_getter_name !=
nullptr) {
8131 const clang::IdentifierInfo *getter_ident =
8132 &clang_ast.Idents.get(property_getter_name);
8133 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8135 const clang::IdentifierInfo *getter_ident =
8136 &clang_ast.Idents.get(property_name);
8137 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8139 property_decl->setGetterName(getter_sel);
8140 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
8143 property_decl->setPropertyIvarDecl(ivar_decl);
8145 if (property_attributes & DW_APPLE_PROPERTY_readonly)
8146 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
8147 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
8148 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
8149 if (property_attributes & DW_APPLE_PROPERTY_assign)
8150 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
8151 if (property_attributes & DW_APPLE_PROPERTY_retain)
8152 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
8153 if (property_attributes & DW_APPLE_PROPERTY_copy)
8154 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
8155 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8156 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
8157 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
8158 property_decl->setPropertyAttributes(
8159 ObjCPropertyAttribute::kind_nullability);
8160 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
8161 property_decl->setPropertyAttributes(
8162 ObjCPropertyAttribute::kind_null_resettable);
8163 if (property_attributes & ObjCPropertyAttribute::kind_class)
8164 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8166 const bool isInstance =
8167 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8169 clang::ObjCMethodDecl *getter =
nullptr;
8170 if (!getter_sel.isNull())
8171 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8172 : class_interface_decl->lookupClassMethod(getter_sel);
8173 if (!getter_sel.isNull() && !getter) {
8174 const bool isVariadic =
false;
8175 const bool isPropertyAccessor =
true;
8176 const bool isSynthesizedAccessorStub =
false;
8177 const bool isImplicitlyDeclared =
true;
8178 const bool isDefined =
false;
8179 const clang::ObjCImplementationControl impControl =
8180 clang::ObjCImplementationControl::None;
8181 const bool HasRelatedResultType =
false;
8184 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8185 getter->setDeclName(getter_sel);
8187 getter->setDeclContext(class_interface_decl);
8188 getter->setInstanceMethod(isInstance);
8189 getter->setVariadic(isVariadic);
8190 getter->setPropertyAccessor(isPropertyAccessor);
8191 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8192 getter->setImplicit(isImplicitlyDeclared);
8193 getter->setDefined(isDefined);
8194 getter->setDeclImplementation(impControl);
8195 getter->setRelatedResultType(HasRelatedResultType);
8199 ast->SetMetadata(getter, metadata);
8201 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8202 llvm::ArrayRef<clang::SourceLocation>());
8203 class_interface_decl->addDecl(getter);
8207 getter->setPropertyAccessor(
true);
8208 property_decl->setGetterMethodDecl(getter);
8211 clang::ObjCMethodDecl *setter =
nullptr;
8212 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8213 : class_interface_decl->lookupClassMethod(setter_sel);
8214 if (!setter_sel.isNull() && !setter) {
8215 clang::QualType result_type = clang_ast.VoidTy;
8216 const bool isVariadic =
false;
8217 const bool isPropertyAccessor =
true;
8218 const bool isSynthesizedAccessorStub =
false;
8219 const bool isImplicitlyDeclared =
true;
8220 const bool isDefined =
false;
8221 const clang::ObjCImplementationControl impControl =
8222 clang::ObjCImplementationControl::None;
8223 const bool HasRelatedResultType =
false;
8226 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8227 setter->setDeclName(setter_sel);
8228 setter->setReturnType(result_type);
8229 setter->setDeclContext(class_interface_decl);
8230 setter->setInstanceMethod(isInstance);
8231 setter->setVariadic(isVariadic);
8232 setter->setPropertyAccessor(isPropertyAccessor);
8233 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8234 setter->setImplicit(isImplicitlyDeclared);
8235 setter->setDefined(isDefined);
8236 setter->setDeclImplementation(impControl);
8237 setter->setRelatedResultType(HasRelatedResultType);
8241 ast->SetMetadata(setter, metadata);
8243 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8244 params.push_back(clang::ParmVarDecl::Create(
8245 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8248 clang::SC_Auto,
nullptr));
8250 setter->setMethodParams(clang_ast,
8251 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8252 llvm::ArrayRef<clang::SourceLocation>());
8254 class_interface_decl->addDecl(setter);
8258 setter->setPropertyAccessor(
true);
8259 property_decl->setSetterMethodDecl(setter);
8270 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8271 bool is_objc_direct_call) {
8272 if (!type || !method_clang_type.
IsValid())
8277 if (class_interface_decl ==
nullptr)
8280 if (lldb_ast ==
nullptr)
8282 clang::ASTContext &ast = lldb_ast->getASTContext();
8284 const char *selector_start = ::strchr(name,
' ');
8285 if (selector_start ==
nullptr)
8289 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8294 unsigned num_selectors_with_args = 0;
8295 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8297 len = ::strcspn(start,
":]");
8298 bool has_arg = (start[len] ==
':');
8300 ++num_selectors_with_args;
8301 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8306 if (selector_idents.size() == 0)
8309 clang::Selector method_selector = ast.Selectors.getSelector(
8310 num_selectors_with_args ? selector_idents.size() : 0,
8311 selector_idents.data());
8316 const clang::Type *method_type(method_qual_type.getTypePtr());
8318 if (method_type ==
nullptr)
8321 const clang::FunctionProtoType *method_function_prototype(
8322 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8324 if (!method_function_prototype)
8327 const bool isInstance = (name[0] ==
'-');
8328 const bool isVariadic = is_variadic;
8329 const bool isPropertyAccessor =
false;
8330 const bool isSynthesizedAccessorStub =
false;
8332 const bool isImplicitlyDeclared =
true;
8333 const bool isDefined =
false;
8334 const clang::ObjCImplementationControl impControl =
8335 clang::ObjCImplementationControl::None;
8336 const bool HasRelatedResultType =
false;
8338 const unsigned num_args = method_function_prototype->getNumParams();
8340 if (num_args != num_selectors_with_args)
8344 auto *objc_method_decl =
8345 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8346 objc_method_decl->setDeclName(method_selector);
8347 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8348 objc_method_decl->setDeclContext(
8350 objc_method_decl->setInstanceMethod(isInstance);
8351 objc_method_decl->setVariadic(isVariadic);
8352 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8353 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8354 objc_method_decl->setImplicit(isImplicitlyDeclared);
8355 objc_method_decl->setDefined(isDefined);
8356 objc_method_decl->setDeclImplementation(impControl);
8357 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8360 if (objc_method_decl ==
nullptr)
8364 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8366 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8367 params.push_back(clang::ParmVarDecl::Create(
8368 ast, objc_method_decl, clang::SourceLocation(),
8369 clang::SourceLocation(),
8371 method_function_prototype->getParamType(param_index),
nullptr,
8372 clang::SC_Auto,
nullptr));
8375 objc_method_decl->setMethodParams(
8376 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8377 llvm::ArrayRef<clang::SourceLocation>());
8380 if (is_objc_direct_call) {
8383 objc_method_decl->addAttr(
8384 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8389 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8392 class_interface_decl->addDecl(objc_method_decl);
8394 VerifyDecl(objc_method_decl);
8396 return objc_method_decl;
8406 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8407 switch (type_class) {
8408 case clang::Type::Record: {
8409 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8410 if (cxx_record_decl) {
8411 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8412 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8417 case clang::Type::Enum: {
8418 clang::EnumDecl *enum_decl =
8419 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8421 enum_decl->setHasExternalLexicalStorage(has_extern);
8422 enum_decl->setHasExternalVisibleStorage(has_extern);
8427 case clang::Type::ObjCObject:
8428 case clang::Type::ObjCInterface: {
8429 const clang::ObjCObjectType *objc_class_type =
8430 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8431 assert(objc_class_type);
8432 if (objc_class_type) {
8433 clang::ObjCInterfaceDecl *class_interface_decl =
8434 objc_class_type->getInterface();
8436 if (class_interface_decl) {
8437 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8438 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8454 if (!qual_type.isNull()) {
8455 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8457 clang::TagDecl *tag_decl = tag_type->getDecl();
8459 tag_decl->startDefinition();
8464 const clang::ObjCObjectType *object_type =
8465 qual_type->getAs<clang::ObjCObjectType>();
8467 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8468 if (interface_decl) {
8469 interface_decl->startDefinition();
8480 if (qual_type.isNull())
8484 if (lldb_ast ==
nullptr)
8490 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8492 clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinitionOrSelf();
8494 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8504 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8505 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8506 if (cxx_record_decl->needsImplicitCopyConstructor())
8507 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8508 if (cxx_record_decl->needsImplicitCopyAssignment())
8509 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8512 if (!cxx_record_decl->isCompleteDefinition())
8513 cxx_record_decl->completeDefinition();
8514 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8515 cxx_record_decl->setHasExternalLexicalStorage(
false);
8516 cxx_record_decl->setHasExternalVisibleStorage(
false);
8517 lldb_ast->SetCXXRecordDeclAccess(cxx_record_decl,
8518 clang::AccessSpecifier::AS_none);
8523 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8527 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8529 if (enum_decl->isCompleteDefinition())
8532 QualType integer_type(enum_decl->getIntegerType());
8533 if (!integer_type.isNull()) {
8534 clang::ASTContext &ast = lldb_ast->getASTContext();
8536 unsigned NumNegativeBits = 0;
8537 unsigned NumPositiveBits = 0;
8538 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8541 clang::QualType BestPromotionType;
8542 clang::QualType BestType;
8543 ast.computeBestEnumTypes(
false, NumNegativeBits,
8544 NumPositiveBits, BestType, BestPromotionType);
8546 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8547 BestPromotionType, NumPositiveBits,
8555 const llvm::APSInt &value) {
8566 if (!enum_opaque_compiler_type)
8569 clang::QualType enum_qual_type(
8572 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8577 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8582 clang::EnumConstantDecl *enumerator_decl =
8583 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8585 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8586 enumerator_decl->setDeclContext(enum_decl);
8587 if (name && name[0])
8588 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8589 enumerator_decl->setType(clang::QualType(enutype, 0));
8591 enumerator_decl->setAccess(AS_public);
8597 enum_decl->addDecl(enumerator_decl);
8599 VerifyDecl(enumerator_decl);
8600 return enumerator_decl;
8605 uint64_t enum_value, uint32_t enum_value_bit_size) {
8607 llvm::APSInt value(enum_value_bit_size,
8616 const clang::Type *clang_type = qt.getTypePtrOrNull();
8617 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8621 return GetType(enum_type->getDecl()->getDefinitionOrSelf()->getIntegerType());
8627 if (type && pointee_type.
IsValid() &&
8632 return ast->GetType(ast->getASTContext().getMemberPointerType(
8641#define DEPTH_INCREMENT 2
8644LLVM_DUMP_METHOD
void
8654struct ScopedASTColor {
8655 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8656 : ast(ast), old_show_colors(ast.getDiagnostics().getShowColors()) {
8657 ast.getDiagnostics().setShowColors(show_colors);
8660 ~ScopedASTColor() { ast.getDiagnostics().setShowColors(old_show_colors); }
8662 clang::ASTContext *
8663 const bool old_show_colors;
8672 clang::CreateASTDumper(output, filter,
8676 false, clang::ADOF_Default);
8679 consumer->HandleTranslationUnit(*
m_ast_up);
8683 llvm::StringRef symbol_name) {
8690 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8691 size_t ntypes = type_list.
GetSize();
8693 for (
size_t i = 0; i < ntypes; ++i) {
8696 if (!symbol_name.empty())
8697 if (symbol_name != type->GetName().GetStringRef())
8700 s << type->GetName().AsCString() <<
"\n";
8703 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8711 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8713 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8725 size_t byte_size, uint32_t bitfield_bit_offset,
8726 uint32_t bitfield_bit_size) {
8727 const clang::EnumType *enutype =
8728 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8729 const clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8731 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8732 const uint64_t enum_svalue =
8735 bitfield_bit_offset)
8737 bitfield_bit_offset);
8738 bool can_be_bitfield =
true;
8739 uint64_t covered_bits = 0;
8740 int num_enumerators = 0;
8748 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8749 if (enumerators.empty())
8750 can_be_bitfield =
false;
8752 for (
auto *enumerator : enumerators) {
8753 llvm::APSInt init_val = enumerator->getInitVal();
8754 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8755 : init_val.getZExtValue();
8756 if (qual_type_is_signed)
8757 val = llvm::SignExtend64(val, 8 * byte_size);
8758 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8759 can_be_bitfield =
false;
8760 covered_bits |= val;
8762 if (val == enum_svalue) {
8771 offset = byte_offset;
8773 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8777 if (!can_be_bitfield) {
8778 if (qual_type_is_signed)
8779 s.
Printf(
"%" PRIi64, enum_svalue);
8781 s.
Printf(
"%" PRIu64, enum_uvalue);
8788 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8792 uint64_t remaining_value = enum_uvalue;
8793 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8794 values.reserve(num_enumerators);
8795 for (
auto *enumerator : enum_decl->enumerators())
8796 if (
auto val = enumerator->getInitVal().getZExtValue())
8797 values.emplace_back(val, enumerator->getName());
8802 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8803 return llvm::popcount(a.first) > llvm::popcount(b.first);
8806 for (
const auto &val : values) {
8807 if ((remaining_value & val.first) != val.first)
8809 remaining_value &= ~val.first;
8811 if (remaining_value)
8817 if (remaining_value)
8818 s.
Printf(
"0x%" PRIx64, remaining_value);
8826 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8835 switch (qual_type->getTypeClass()) {
8836 case clang::Type::Typedef: {
8837 clang::QualType typedef_qual_type =
8838 llvm::cast<clang::TypedefType>(qual_type)
8840 ->getUnderlyingType();
8843 format = typedef_clang_type.
GetFormat();
8844 clang::TypeInfo typedef_type_info =
8846 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8856 bitfield_bit_offset,
8861 case clang::Type::Enum:
8866 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8867 bitfield_bit_offset, bitfield_bit_size);
8875 uint32_t item_count = 1;
8915 item_count = byte_size;
8920 item_count = byte_size / 2;
8925 item_count = byte_size / 4;
8931 bitfield_bit_size, bitfield_bit_offset,
8947 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(clang_type)) {
8956 clang::QualType qual_type =
8959 llvm::SmallVector<char, 1024> buf;
8960 llvm::raw_svector_ostream llvm_ostrm(buf);
8962 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8963 switch (type_class) {
8964 case clang::Type::ObjCObject:
8965 case clang::Type::ObjCInterface: {
8968 auto *objc_class_type =
8969 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8970 assert(objc_class_type);
8971 if (!objc_class_type)
8973 clang::ObjCInterfaceDecl *class_interface_decl =
8974 objc_class_type->getInterface();
8975 if (!class_interface_decl)
8978 class_interface_decl->dump(llvm_ostrm);
8980 class_interface_decl->print(llvm_ostrm,
8985 case clang::Type::Typedef: {
8986 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8989 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
8991 typedef_decl->dump(llvm_ostrm);
8994 if (!clang_typedef_name.empty()) {
9001 case clang::Type::Record: {
9004 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
9005 const clang::RecordDecl *record_decl = record_type->getDecl();
9007 record_decl->dump(llvm_ostrm);
9009 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
9015 if (
auto *tag_type =
9016 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
9017 if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
9019 tag_decl->dump(llvm_ostrm);
9021 tag_decl->print(llvm_ostrm, 0);
9027 std::string clang_type_name(qual_type.getAsString());
9028 if (!clang_type_name.empty())
9035 if (buf.size() > 0) {
9036 s.
Write(buf.data(), buf.size());
9043 clang::QualType qual_type(
9046 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
9047 switch (type_class) {
9048 case clang::Type::Record: {
9049 const clang::CXXRecordDecl *cxx_record_decl =
9050 qual_type->getAsCXXRecordDecl();
9051 if (cxx_record_decl)
9052 printf(
"class %s", cxx_record_decl->getName().str().c_str());
9055 case clang::Type::Enum: {
9056 clang::EnumDecl *enum_decl =
9057 llvm::cast<clang::EnumType>(qual_type)->getDecl();
9059 printf(
"enum %s", enum_decl->getName().str().c_str());
9063 case clang::Type::ObjCObject:
9064 case clang::Type::ObjCInterface: {
9065 const clang::ObjCObjectType *objc_class_type =
9066 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
9067 if (objc_class_type) {
9068 clang::ObjCInterfaceDecl *class_interface_decl =
9069 objc_class_type->getInterface();
9073 if (class_interface_decl)
9074 printf(
"@class %s", class_interface_decl->getName().str().c_str());
9078 case clang::Type::Typedef:
9079 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
9086 case clang::Type::Auto:
9089 llvm::cast<clang::AutoType>(qual_type)
9091 .getAsOpaquePtr()));
9093 case clang::Type::Paren:
9097 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
9100 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
9110 if (template_param_infos.
IsValid()) {
9111 std::string template_basename(parent_name);
9113 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
9114 template_basename.erase(i);
9117 template_basename.c_str(), tag_decl_kind,
9118 template_param_infos);
9133 clang::ObjCInterfaceDecl *decl) {
9157 std::make_unique<npdb::PdbAstBuilderClang>(*
this);
9162 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9163 uint64_t &alignment,
9164 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9165 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9167 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9180 field_offsets, base_offsets, vbase_offsets);
9187 clang::NamedDecl *nd =
9188 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9198 if (!label_or_err) {
9199 llvm::consumeError(label_or_err.takeError());
9203 llvm::StringRef mangled = label_or_err->lookup_name;
9211 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9212 static_cast<clang::Decl *
>(opaque_decl));
9214 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9218 if (!mc || !mc->shouldMangleCXXName(nd))
9223 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9228 llvm::SmallVector<char, 1024> buf;
9229 llvm::raw_svector_ostream llvm_ostrm(buf);
9230 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9232 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9235 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9237 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9241 mc->mangleName(nd, llvm_ostrm);
9257 if (clang::FunctionDecl *func_decl =
9258 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9259 return GetType(func_decl->getReturnType());
9260 if (clang::ObjCMethodDecl *objc_method =
9261 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9262 return GetType(objc_method->getReturnType());
9268 if (clang::FunctionDecl *func_decl =
9269 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9270 return func_decl->param_size();
9271 if (clang::ObjCMethodDecl *objc_method =
9272 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9273 return objc_method->param_size();
9279 clang::DeclContext
const *decl_ctx) {
9280 switch (clang_kind) {
9281 case Decl::TranslationUnit:
9283 case Decl::Namespace:
9294 if (decl_ctx->isFunctionOrMethod())
9296 if (decl_ctx->isRecord())
9306 std::vector<lldb_private::CompilerContext> &context) {
9307 if (decl_ctx ==
nullptr)
9310 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9311 if (clang_kind == Decl::TranslationUnit)
9316 context.push_back({compiler_kind, decl_ctx_name});
9319std::vector<lldb_private::CompilerContext>
9321 std::vector<lldb_private::CompilerContext> context;
9324 clang::Decl *decl = (clang::Decl *)opaque_decl;
9326 clang::DeclContext *decl_ctx = decl->getDeclContext();
9329 auto compiler_kind =
9331 context.push_back({compiler_kind, decl_name});
9338 if (clang::FunctionDecl *func_decl =
9339 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9340 if (idx < func_decl->param_size()) {
9341 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9343 return GetType(var_decl->getOriginalType());
9345 }
else if (clang::ObjCMethodDecl *objc_method =
9346 llvm::dyn_cast<clang::ObjCMethodDecl>(
9347 (clang::Decl *)opaque_decl)) {
9348 if (idx < objc_method->param_size())
9349 return GetType(objc_method->parameters()[idx]->getOriginalType());
9355 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9356 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9359 clang::Expr *init_expr = var_decl->getInit();
9362 std::optional<llvm::APSInt> value =
9372 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9373 std::vector<CompilerDecl> found_decls;
9375 if (opaque_decl_ctx && symbol_file) {
9376 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9377 std::set<DeclContext *> searched;
9378 std::multimap<DeclContext *, DeclContext *> search_queue;
9380 for (clang::DeclContext *decl_context = root_decl_ctx;
9381 decl_context !=
nullptr && found_decls.empty();
9382 decl_context = decl_context->getParent()) {
9383 search_queue.insert(std::make_pair(decl_context, decl_context));
9385 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9387 if (!searched.insert(it->second).second)
9392 for (clang::Decl *child : it->second->decls()) {
9393 if (clang::UsingDirectiveDecl *ud =
9394 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9395 if (ignore_using_decls)
9397 clang::DeclContext *from = ud->getCommonAncestor();
9398 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9399 search_queue.insert(
9400 std::make_pair(from, ud->getNominatedNamespace()));
9401 }
else if (clang::UsingDecl *ud =
9402 llvm::dyn_cast<clang::UsingDecl>(child)) {
9403 if (ignore_using_decls)
9405 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9406 clang::Decl *target = usd->getTargetDecl();
9407 if (clang::NamedDecl *nd =
9408 llvm::dyn_cast<clang::NamedDecl>(target)) {
9409 IdentifierInfo *ii = nd->getIdentifier();
9410 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9414 }
else if (clang::NamedDecl *nd =
9415 llvm::dyn_cast<clang::NamedDecl>(child)) {
9416 IdentifierInfo *ii = nd->getIdentifier();
9417 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9468 clang::DeclContext *child_decl_ctx,
9472 if (frame_decl_ctx && symbol_file) {
9473 std::set<DeclContext *> searched;
9474 std::multimap<DeclContext *, DeclContext *> search_queue;
9477 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9481 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9482 decl_ctx = decl_ctx->getParent()) {
9483 if (!decl_ctx->isLookupContext())
9485 if (decl_ctx == parent_decl_ctx)
9488 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9489 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9491 if (searched.find(it->second) != searched.end())
9499 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9502 searched.insert(it->second);
9506 for (clang::Decl *child : it->second->decls()) {
9507 if (clang::UsingDirectiveDecl *ud =
9508 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9509 clang::DeclContext *ns = ud->getNominatedNamespace();
9510 if (ns == parent_decl_ctx)
9513 clang::DeclContext *from = ud->getCommonAncestor();
9514 if (searched.find(ns) == searched.end())
9515 search_queue.insert(std::make_pair(from, ns));
9516 }
else if (child_name) {
9517 if (clang::UsingDecl *ud =
9518 llvm::dyn_cast<clang::UsingDecl>(child)) {
9519 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9520 clang::Decl *target = usd->getTargetDecl();
9521 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9525 IdentifierInfo *ii = nd->getIdentifier();
9526 if (ii ==
nullptr ||
9527 ii->getName() != child_name->
AsCString(
nullptr))
9550 if (opaque_decl_ctx) {
9551 clang::NamedDecl *named_decl =
9552 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9555 llvm::raw_string_ostream stream{name};
9557 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9558 named_decl->getNameForDiagnostic(stream, policy,
false);
9567 if (opaque_decl_ctx) {
9568 clang::NamedDecl *named_decl =
9569 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9577 if (!opaque_decl_ctx)
9580 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9581 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9583 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9585 }
else if (clang::FunctionDecl *fun_decl =
9586 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9587 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9588 return metadata->HasObjectPtr();
9594std::vector<lldb_private::CompilerContext>
9596 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9597 std::vector<lldb_private::CompilerContext> context;
9603 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9604 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9605 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9609 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9610 if (DC->isInlineNamespace())
9613 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9614 return NS->isAnonymousNamespace();
9621 if (decl_ctx == other)
9623 }
while (is_transparent_lookup_allowed(other) &&
9624 (other = other->getParent()));
9631 if (!opaque_decl_ctx)
9634 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9635 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9637 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9639 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9640 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9641 return metadata->GetObjectPtrLanguage();
9661 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9669 return llvm::dyn_cast<clang::CXXMethodDecl>(
9674clang::FunctionDecl *
9677 return llvm::dyn_cast<clang::FunctionDecl>(
9682clang::NamespaceDecl *
9685 return llvm::dyn_cast<clang::NamespaceDecl>(
9690std::optional<ClangASTMetadata>
9692 const Decl *
object) {
9700 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9723 lldbassert(started &&
"Unable to start a class type definition.");
9728 ts->SetDeclIsForcefullyCompleted(td);
9742 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9743 std::unique_ptr<ClangASTSource> ast_source)
9745 m_scratch_ast_source_up(std::move(ast_source)) {
9747 m_scratch_ast_source_up->InstallASTContext(*
this);
9748 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9749 m_scratch_ast_source_up->CreateProxy();
9750 SetExternalSource(proxy_ast_source);
9754 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9762 llvm::Triple triple)
9769 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9781 std::optional<IsolatedASTKind> ast_kind,
9782 bool create_on_demand) {
9785 if (
auto err = type_system_or_err.takeError()) {
9787 "Couldn't get scratch TypeSystemClang: {0}");
9790 auto ts_sp = *type_system_or_err;
9792 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9797 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9799 return std::static_pointer_cast<TypeSystemClang>(
9804static llvm::StringRef
9808 return "C++ modules";
9810 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9814 llvm::StringRef filter,
bool show_color) {
9816 output <<
"State of scratch Clang type system:\n";
9820 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9821 std::vector<KeyAndTS> sorted_typesystems;
9823 sorted_typesystems.emplace_back(a.first, a.second.get());
9824 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9827 for (
const auto &a : sorted_typesystems) {
9830 output <<
"State of scratch Clang type subsystem "
9832 a.second->Dump(output, filter, show_color);
9837 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9845 desired_type, options, ctx_obj);
9850 const ValueList &arg_value_list,
const char *name) {
9855 Process *process = target_sp->GetProcessSP().get();
9860 arg_value_list, name);
9863std::unique_ptr<UtilityFunction>
9870 return std::make_unique<ClangUtilityFunction>(
9871 *target_sp.get(), std::move(text), std::move(name),
9872 target_sp->GetDebugUtilityExpression());
9886 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9890 return std::make_unique<ClangASTSource>(
9895static llvm::StringRef
9899 return "scratch ASTContext for C++ module types";
9901 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9908 return *found_ast->second;
9911 std::shared_ptr<TypeSystemClang> new_ast_sp =
9921 const clang::RecordType *record_type =
9922 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9924 const clang::RecordDecl *record_decl =
9925 record_type->getDecl()->getDefinitionOrSelf();
9926 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9927 return metadata->IsForcefullyCompleted();
9936 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9940 metadata->SetIsForcefullyCompleted();
9948 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)
lldb_private::ThreadSafeDenseMap< clang::ASTContext *, TypeSystemClang * > ClangASTMap
static const clang::RecordType * GetCompleteRecordType(clang::ASTContext *ast, clang::QualType qual_type)
Returns the clang::RecordType of the specified qual_type.
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 lldb::addr_t GetVTableAddress(Process &process, VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout)
static bool GetCompleteQualType(clang::ASTContext *ast, clang::QualType qual_type)
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 const clang::EnumType * GetCompleteEnumType(clang::ASTContext *ast, clang::QualType qual_type)
Returns the clang::EnumType of the specified qual_type.
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 bool QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext &ast, QualType qual_type)
static const clang::ObjCObjectType * GetCompleteObjCObjectType(clang::ASTContext *ast, QualType qual_type)
Returns the clang::ObjCObjectType of the specified qual_type.
static ClangASTMap & GetASTMap()
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.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
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.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
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)
std::unique_ptr< npdb::PdbAstBuilderClang > m_native_pdb_ast_parser_up
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)
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)
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.