11#include "clang/AST/DeclBase.h"
12#include "clang/AST/ExprCXX.h"
13#include "clang/Frontend/ASTConsumers.h"
14#include "llvm/ADT/ScopeExit.h"
15#include "llvm/Support/Casting.h"
16#include "llvm/Support/FormatAdapters.h"
17#include "llvm/Support/FormatVariadic.h"
24#include "clang/AST/ASTContext.h"
25#include "clang/AST/ASTImporter.h"
26#include "clang/AST/Attr.h"
27#include "clang/AST/CXXInheritance.h"
28#include "clang/AST/DeclObjC.h"
29#include "clang/AST/DeclTemplate.h"
30#include "clang/AST/Mangle.h"
31#include "clang/AST/QualTypeNames.h"
32#include "clang/AST/RecordLayout.h"
33#include "clang/AST/Type.h"
34#include "clang/AST/VTableBuilder.h"
35#include "clang/Basic/Builtins.h"
36#include "clang/Basic/Diagnostic.h"
37#include "clang/Basic/FileManager.h"
38#include "clang/Basic/FileSystemOptions.h"
39#include "clang/Basic/LangStandard.h"
40#include "clang/Basic/SourceManager.h"
41#include "clang/Basic/TargetInfo.h"
42#include "clang/Basic/TargetOptions.h"
43#include "clang/Frontend/FrontendOptions.h"
44#include "clang/Lex/HeaderSearch.h"
45#include "clang/Lex/HeaderSearchOptions.h"
46#include "clang/Lex/ModuleMap.h"
47#include "clang/Sema/Sema.h"
49#include "llvm/Support/Signals.h"
50#include "llvm/Support/Threading.h"
94using namespace llvm::dwarf;
96using llvm::StringSwitch;
101static void VerifyDecl(clang::Decl *decl) {
102 assert(decl &&
"VerifyDecl called with nullptr?");
128bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) {
130 lldbassert(&m1->getASTContext() == &m2->getASTContext() &&
131 "Methods should have the same AST context");
132 clang::ASTContext &context = m1->getASTContext();
134 const auto *m1Type = llvm::cast<clang::FunctionProtoType>(
135 context.getCanonicalType(m1->getType()));
137 const auto *m2Type = llvm::cast<clang::FunctionProtoType>(
138 context.getCanonicalType(m2->getType()));
140 auto compareArgTypes = [&context](
const clang::QualType &m1p,
141 const clang::QualType &m2p) {
142 return context.hasSameType(m1p.getUnqualifiedType(),
143 m2p.getUnqualifiedType());
148 return (m1->getNumParams() != m2->getNumParams()) ||
149 !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(),
150 m2Type->param_type_begin(), compareArgTypes);
156void addOverridesForMethod(clang::CXXMethodDecl *decl) {
157 if (!decl->isVirtual())
160 clang::CXXBasePaths paths;
161 llvm::SmallVector<clang::NamedDecl *, 4> decls;
163 auto find_overridden_methods =
164 [&decls, decl](
const clang::CXXBaseSpecifier *specifier,
165 clang::CXXBasePath &path) {
166 if (
auto *base_record = specifier->getType()->getAsCXXRecordDecl()) {
168 clang::DeclarationName name = decl->getDeclName();
172 if (name.getNameKind() == clang::DeclarationName::CXXDestructorName)
173 if (
auto *baseDtorDecl = base_record->getDestructor()) {
174 if (baseDtorDecl->isVirtual()) {
175 decls.push_back(baseDtorDecl);
182 for (path.Decls = base_record->lookup(name).begin();
183 path.Decls != path.Decls.end(); ++path.Decls) {
184 if (
auto *method_decl =
185 llvm::dyn_cast<clang::CXXMethodDecl>(*path.Decls))
186 if (method_decl->isVirtual() && !isOverload(decl, method_decl)) {
187 decls.push_back(method_decl);
196 if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) {
197 for (
auto *overridden_decl : decls)
198 decl->addOverriddenMethod(
199 llvm::cast<clang::CXXMethodDecl>(overridden_decl));
205 VTableContextBase &vtable_ctx,
207 const ASTRecordLayout &record_layout) {
211 uint32_t type_info = this_type.
GetTypeInfo(&pointee_type);
216 bool ptr_or_ref =
false;
217 if (type_info & (eTypeIsPointer | eTypeIsReference)) {
223 const uint32_t cpp_class = eTypeIsClass | eTypeIsCPlusPlus;
224 if ((type_info & cpp_class) != cpp_class)
229 vtable_ctx.isMicrosoft() ? record_layout.getVBPtrOffset().getQuantity()
243 vbtable_ptr_addr += vbtable_ptr_offset;
254 auto size = valobj.
GetData(data, err);
262 VTableContextBase &vtable_ctx,
264 const CXXRecordDecl *cxx_record_decl,
265 const CXXRecordDecl *base_class_decl) {
266 if (vtable_ctx.isMicrosoft()) {
267 clang::MicrosoftVTableContext &msoft_vtable_ctx =
268 static_cast<clang::MicrosoftVTableContext &
>(vtable_ctx);
272 const unsigned vbtable_index =
273 msoft_vtable_ctx.getVBTableIndex(cxx_record_decl, base_class_decl);
274 const lldb::addr_t base_offset_addr = vtable_ptr + vbtable_index * 4;
280 clang::ItaniumVTableContext &itanium_vtable_ctx =
281 static_cast<clang::ItaniumVTableContext &
>(vtable_ctx);
283 clang::CharUnits base_offset_offset =
284 itanium_vtable_ctx.getVirtualBaseOffsetOffset(cxx_record_decl,
287 vtable_ptr + base_offset_offset.getQuantity();
296 const ASTRecordLayout &record_layout,
297 const CXXRecordDecl *cxx_record_decl,
298 const CXXRecordDecl *base_class_decl,
299 int32_t &bit_offset) {
311 *process, vtable_ctx, vtable_ptr, cxx_record_decl, base_class_decl);
312 if (base_offset == INT64_MAX)
315 bit_offset = base_offset * 8;
325 static llvm::once_flag g_once_flag;
326 llvm::call_once(g_once_flag, []() {
333 bool is_complete_objc_class)
346 const clang::Decl *parent) {
347 if (!member || !parent)
354 member->setFromASTFile();
355 member->setOwningModuleID(
id.GetValue());
356 member->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
357 if (llvm::isa<clang::NamedDecl>(member))
358 if (
auto *dc = llvm::dyn_cast<clang::DeclContext>(parent)) {
359 dc->setHasExternalVisibleStorage(
true);
362 dc->setHasExternalLexicalStorage(
true);
369 clang::OverloadedOperatorKind &op_kind) {
371 if (!name.consume_front(
"operator"))
376 bool space_after_operator = name.consume_front(
" ");
378 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
379 .Case(
"+", clang::OO_Plus)
380 .Case(
"+=", clang::OO_PlusEqual)
381 .Case(
"++", clang::OO_PlusPlus)
382 .Case(
"-", clang::OO_Minus)
383 .Case(
"-=", clang::OO_MinusEqual)
384 .Case(
"--", clang::OO_MinusMinus)
385 .Case(
"->", clang::OO_Arrow)
386 .Case(
"->*", clang::OO_ArrowStar)
387 .Case(
"*", clang::OO_Star)
388 .Case(
"*=", clang::OO_StarEqual)
389 .Case(
"/", clang::OO_Slash)
390 .Case(
"/=", clang::OO_SlashEqual)
391 .Case(
"%", clang::OO_Percent)
392 .Case(
"%=", clang::OO_PercentEqual)
393 .Case(
"^", clang::OO_Caret)
394 .Case(
"^=", clang::OO_CaretEqual)
395 .Case(
"&", clang::OO_Amp)
396 .Case(
"&=", clang::OO_AmpEqual)
397 .Case(
"&&", clang::OO_AmpAmp)
398 .Case(
"|", clang::OO_Pipe)
399 .Case(
"|=", clang::OO_PipeEqual)
400 .Case(
"||", clang::OO_PipePipe)
401 .Case(
"~", clang::OO_Tilde)
402 .Case(
"!", clang::OO_Exclaim)
403 .Case(
"!=", clang::OO_ExclaimEqual)
404 .Case(
"=", clang::OO_Equal)
405 .Case(
"==", clang::OO_EqualEqual)
406 .Case(
"<", clang::OO_Less)
407 .Case(
"<=>", clang::OO_Spaceship)
408 .Case(
"<<", clang::OO_LessLess)
409 .Case(
"<<=", clang::OO_LessLessEqual)
410 .Case(
"<=", clang::OO_LessEqual)
411 .Case(
">", clang::OO_Greater)
412 .Case(
">>", clang::OO_GreaterGreater)
413 .Case(
">>=", clang::OO_GreaterGreaterEqual)
414 .Case(
">=", clang::OO_GreaterEqual)
415 .Case(
"()", clang::OO_Call)
416 .Case(
"[]", clang::OO_Subscript)
417 .Case(
",", clang::OO_Comma)
418 .Default(clang::NUM_OVERLOADED_OPERATORS);
421 if (op_kind != clang::NUM_OVERLOADED_OPERATORS)
433 if (!space_after_operator)
438 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
439 .Case(
"new", clang::OO_New)
440 .Case(
"new[]", clang::OO_Array_New)
441 .Case(
"delete", clang::OO_Delete)
442 .Case(
"delete[]", clang::OO_Array_Delete)
444 .Default(clang::NUM_OVERLOADED_OPERATORS);
449clang::AccessSpecifier
469 std::vector<std::string> Includes;
470 LangOptions::setLangDefaults(Opts, clang::Language::ObjCXX, arch.
GetTriple(),
471 Includes, clang::LangStandard::lang_gnucxx98);
473 Opts.setValueVisibilityMode(DefaultVisibility);
477 Opts.Trigraphs = !Opts.GNUMode;
482 Opts.ModulesLocalVisibility = 1;
486 llvm::Triple target_triple) {
488 if (!target_triple.str().empty())
498 ASTContext &existing_ctxt) {
514 if (!TypeSystemClangSupportsLanguage(language))
518 arch =
module->GetArchitecture();
528 if (triple.getVendor() == llvm::Triple::Apple &&
529 triple.getOS() == llvm::Triple::UnknownOS) {
530 if (triple.getArch() == llvm::Triple::arm ||
531 triple.getArch() == llvm::Triple::aarch64 ||
532 triple.getArch() == llvm::Triple::aarch64_32 ||
533 triple.getArch() == llvm::Triple::thumb) {
534 triple.setOS(llvm::Triple::IOS);
536 triple.setOS(llvm::Triple::MacOSX);
541 std::string ast_name =
542 "ASTContext for '" +
module->GetFileSpec().GetPath() + "'";
543 return std::make_shared<TypeSystemClang>(ast_name, triple);
544 }
else if (target && target->
IsValid())
545 return std::make_shared<ScratchTypeSystemClang>(*target, triple);
607 assert(s ==
nullptr || &s->getASTContext() ==
m_ast_up.get());
620 llvm::IntrusiveRefCntPtr<ExternalASTSource> ast_source_sp) {
622 ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(
true);
623 ast.setExternalSource(std::move(ast_source_sp));
636 const clang::Diagnostic &info)
override {
638 llvm::SmallVector<char, 32> diag_str(10);
639 info.FormatDiagnostic(diag_str);
640 diag_str.push_back(
'\0');
645 DiagnosticConsumer *
clone(DiagnosticsEngine &Diags)
const {
666 clang::FileSystemOptions file_system_options;
676 m_ast_up = std::make_unique<ASTContext>(
688 m_ast_up->InitBuiltinTypes(*target_info);
692 "Failed to initialize builtin ASTContext types for target '{0}'. "
693 "Printing variables may behave unexpectedly.",
699 static std::once_flag s_uninitialized_target_warning;
701 &s_uninitialized_target_warning);
707 llvm::makeIntrusiveRefCnt<ClangExternalASTSourceCallbacks>(*
this);
739#pragma mark Basic Types
742 ASTContext &ast, QualType qual_type) {
743 uint64_t qual_type_bit_size = ast.getTypeSize(qual_type);
744 return qual_type_bit_size == bit_size;
763 return GetType(ast.UnsignedCharTy);
765 return GetType(ast.UnsignedShortTy);
767 return GetType(ast.UnsignedIntTy);
769 return GetType(ast.UnsignedLongTy);
771 return GetType(ast.UnsignedLongLongTy);
773 return GetType(ast.UnsignedInt128Ty);
778 return GetType(ast.SignedCharTy);
786 return GetType(ast.LongLongTy);
797 return GetType(ast.LongDoubleTy);
801 return GetType(ast.Float128Ty);
806 if (bit_size && !(bit_size & 0x7u))
807 return GetType(ast.getExtVectorType(ast.UnsignedCharTy, bit_size / 8));
815 static const llvm::StringMap<lldb::BasicType> g_type_map = {
868 auto iter = g_type_map.find(name);
869 if (iter == g_type_map.end())
896 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
915 return GetType(ast.UnsignedCharTy);
917 return GetType(ast.UnsignedShortTy);
919 return GetType(ast.UnsignedIntTy);
924 if (type_name.contains(
"complex")) {
933 case DW_ATE_complex_float: {
934 CanQualType FloatComplexTy = ast.getComplexType(ast.FloatTy);
936 return GetType(FloatComplexTy);
938 CanQualType DoubleComplexTy = ast.getComplexType(ast.DoubleTy);
940 return GetType(DoubleComplexTy);
942 CanQualType LongDoubleComplexTy = ast.getComplexType(ast.LongDoubleTy);
944 return GetType(LongDoubleComplexTy);
954 if (type_name ==
"float" &&
957 if (type_name ==
"double" &&
960 if (type_name ==
"long double" &&
962 return GetType(ast.LongDoubleTy);
963 if (type_name ==
"__bf16" &&
965 return GetType(ast.BFloat16Ty);
966 if (type_name ==
"_Float16" &&
972 if ((type_name ==
"__float128" || type_name ==
"_Float128" ||
973 type_name ==
"f128") &&
975 return GetType(ast.Float128Ty);
982 return GetType(ast.LongDoubleTy);
986 return GetType(ast.Float128Ty);
990 if (!type_name.empty()) {
991 if (type_name ==
"wchar_t" &&
996 if (type_name ==
"void" &&
999 if (type_name.contains(
"long long") &&
1001 return GetType(ast.LongLongTy);
1002 if (type_name.contains(
"long") &&
1005 if (type_name.contains(
"short") &&
1008 if (type_name.contains(
"char")) {
1012 return GetType(ast.SignedCharTy);
1014 if (type_name.contains(
"int")) {
1031 return GetType(ast.LongLongTy);
1036 case DW_ATE_signed_char:
1037 if (type_name ==
"char") {
1042 return GetType(ast.SignedCharTy);
1045 case DW_ATE_unsigned:
1046 if (!type_name.empty()) {
1047 if (type_name ==
"wchar_t") {
1054 if (type_name.contains(
"long long")) {
1056 return GetType(ast.UnsignedLongLongTy);
1057 }
else if (type_name.contains(
"long")) {
1059 return GetType(ast.UnsignedLongTy);
1060 }
else if (type_name.contains(
"short")) {
1062 return GetType(ast.UnsignedShortTy);
1063 }
else if (type_name.contains(
"char")) {
1065 return GetType(ast.UnsignedCharTy);
1066 }
else if (type_name.contains(
"int")) {
1068 return GetType(ast.UnsignedIntTy);
1070 return GetType(ast.UnsignedInt128Ty);
1075 return GetType(ast.UnsignedCharTy);
1077 return GetType(ast.UnsignedShortTy);
1079 return GetType(ast.UnsignedIntTy);
1081 return GetType(ast.UnsignedLongTy);
1083 return GetType(ast.UnsignedLongLongTy);
1085 return GetType(ast.UnsignedInt128Ty);
1088 case DW_ATE_unsigned_char:
1089 if (type_name ==
"char") {
1094 return GetType(ast.UnsignedCharTy);
1096 return GetType(ast.UnsignedShortTy);
1099 case DW_ATE_imaginary_float:
1111 if (!type_name.empty()) {
1112 if (type_name ==
"char16_t")
1114 if (type_name ==
"char32_t")
1116 if (type_name ==
"char8_t")
1125 "error: need to add support for DW_TAG_base_type '{0}' "
1126 "encoded with DW_ATE = {1:x}, bit_size = {2}",
1127 type_name, dw_ate, bit_size);
1133 QualType char_type(ast.CharTy);
1136 char_type.addConst();
1138 return GetType(ast.getPointerType(char_type));
1142 bool ignore_qualifiers) {
1153 if (ignore_qualifiers) {
1154 type1_qual = type1_qual.getUnqualifiedType();
1155 type2_qual = type2_qual.getUnqualifiedType();
1158 return ast->getASTContext().hasSameType(type1_qual, type2_qual);
1165 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
1166 if (
auto *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl))
1178 if (clang::ObjCInterfaceDecl *interface_decl =
1179 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
1181 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
1183 if (clang::ValueDecl *value_decl = llvm::dyn_cast<clang::ValueDecl>(decl))
1197 return GetType(value_decl->getType());
1200#pragma mark Structure, Unions, Classes
1204 if (!decl || !owning_module.
HasValue())
1207 decl->setFromASTFile();
1208 decl->setOwningModuleID(owning_module.
GetValue());
1209 decl->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
1215 bool is_framework,
bool is_explicit) {
1217 auto *ast_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1219 assert(ast_source &&
"external ast source was lost");
1237 clang::Module *module;
1238 auto parent_desc = ast_source->getSourceDescriptor(parent.
GetValue());
1240 name, parent_desc ? parent_desc->getModuleOrNull() :
nullptr,
1241 is_framework, is_explicit);
1243 return ast_source->GetIDForModule(module);
1245 return ast_source->RegisterModule(module);
1250 AccessType access_type, llvm::StringRef name,
int kind,
1251 LanguageType language, std::optional<ClangASTMetadata> metadata,
1252 bool exports_symbols) {
1255 if (decl_ctx ==
nullptr)
1256 decl_ctx = ast.getTranslationUnitDecl();
1260 bool isInternal =
false;
1261 return CreateObjCClass(name, decl_ctx, owning_module, isInternal, metadata);
1270 bool has_name = !name.empty();
1271 CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1272 decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1273 decl->setDeclContext(decl_ctx);
1275 decl->setDeclName(&ast.Idents.get(name));
1303 if (isa<CXXRecordDecl>(decl_ctx) && exports_symbols)
1304 decl->setAnonymousStructOrUnion(
true);
1314 decl_ctx->addDecl(decl);
1316 return GetType(ast.getCanonicalTagType(decl));
1323QualType GetValueParamType(
const clang::TemplateArgument &argument) {
1324 switch (argument.getKind()) {
1325 case TemplateArgument::Integral:
1326 return argument.getIntegralType();
1327 case TemplateArgument::StructuralValue:
1328 return argument.getStructuralValueType();
1334void AddAccessSpecifierDecl(clang::CXXRecordDecl *cxx_record_decl,
1336 clang::AccessSpecifier previous_access,
1337 clang::AccessSpecifier access_specifier) {
1338 if (!cxx_record_decl->isClass() && !cxx_record_decl->isStruct())
1340 if (previous_access != access_specifier) {
1343 if ((cxx_record_decl->isStruct() &&
1344 previous_access == clang::AccessSpecifier::AS_none &&
1345 access_specifier == clang::AccessSpecifier::AS_public) ||
1346 (cxx_record_decl->isClass() &&
1347 previous_access == clang::AccessSpecifier::AS_none &&
1348 access_specifier == clang::AccessSpecifier::AS_private)) {
1351 cxx_record_decl->addDecl(
1352 AccessSpecDecl::Create(ct, access_specifier, cxx_record_decl,
1353 SourceLocation(), SourceLocation()));
1361 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1362 const bool parameter_pack =
false;
1363 const bool is_typename =
false;
1364 const unsigned depth = 0;
1365 const size_t num_template_params = template_param_infos.
Size();
1366 DeclContext *
const decl_context =
1367 ast.getTranslationUnitDecl();
1369 auto const &args = template_param_infos.
GetArgs();
1370 auto const &names = template_param_infos.
GetNames();
1371 for (
size_t i = 0; i < num_template_params; ++i) {
1372 const char *name = names[i];
1374 IdentifierInfo *identifier_info =
nullptr;
1375 if (name && name[0])
1376 identifier_info = &ast.Idents.get(name);
1377 TemplateArgument
const &targ = args[i];
1378 QualType template_param_type = GetValueParamType(targ);
1379 if (!template_param_type.isNull()) {
1380 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1381 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1382 identifier_info, template_param_type, parameter_pack,
1383 ast.getTrivialTypeSourceInfo(template_param_type)));
1385 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1386 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1387 identifier_info, is_typename, parameter_pack));
1392 IdentifierInfo *identifier_info =
nullptr;
1394 identifier_info = &ast.Idents.get(template_param_infos.
GetPackName());
1395 const bool parameter_pack_true =
true;
1397 QualType template_param_type =
1401 if (!template_param_type.isNull()) {
1402 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1403 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1404 num_template_params, identifier_info, template_param_type,
1405 parameter_pack_true,
1406 ast.getTrivialTypeSourceInfo(template_param_type)));
1408 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1409 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1410 num_template_params, identifier_info, is_typename,
1411 parameter_pack_true));
1414 clang::Expr *
const requires_clause =
nullptr;
1415 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1416 ast, SourceLocation(), SourceLocation(), template_param_decls,
1417 SourceLocation(), requires_clause);
1418 return template_param_list;
1423 clang::FunctionDecl *func_decl,
1428 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1430 ast, template_param_infos, template_param_decls);
1431 FunctionTemplateDecl *func_tmpl_decl =
1432 FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1433 func_tmpl_decl->setDeclContext(decl_ctx);
1434 func_tmpl_decl->setLocation(func_decl->getLocation());
1435 func_tmpl_decl->setDeclName(func_decl->getDeclName());
1436 func_tmpl_decl->setTemplateParameters(template_param_list);
1437 func_tmpl_decl->init(func_decl);
1440 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1441 i < template_param_decl_count; ++i) {
1443 template_param_decls[i]->setDeclContext(func_decl);
1448 if (decl_ctx->isRecord())
1449 func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
1451 return func_tmpl_decl;
1455 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1457 TemplateArgumentList *template_args_ptr = TemplateArgumentList::CreateCopy(
1458 func_decl->getASTContext(), infos.
GetArgs());
1460 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
1461 template_args_ptr,
nullptr);
1468 const TemplateArgument &value) {
1469 if (llvm::isa<TemplateTypeParmDecl>(param)) {
1471 if (value.getKind() != TemplateArgument::Type)
1473 }
else if (
auto *type_param =
1474 llvm::dyn_cast<NonTypeTemplateParmDecl>(param)) {
1476 QualType value_param_type = GetValueParamType(value);
1477 if (value_param_type.isNull())
1481 if (type_param->getType() != value_param_type)
1489 "Don't know how to compare template parameter to passed"
1490 " value. Decl kind of parameter is: {0}",
1491 param->getDeclKindName());
1492 lldbassert(
false &&
"Can't compare this TemplateParmDecl subclass");
1507 ClassTemplateDecl *class_template_decl,
1510 TemplateParameterList ¶ms = *class_template_decl->getTemplateParameters();
1516 std::optional<NamedDecl *> pack_parameter;
1518 size_t non_pack_params = params.size();
1519 for (
size_t i = 0; i < params.size(); ++i) {
1520 NamedDecl *param = params.getParam(i);
1521 if (param->isParameterPack()) {
1522 pack_parameter = param;
1523 non_pack_params = i;
1531 if (non_pack_params != instantiation_values.
Size())
1549 for (
const auto pair :
1550 llvm::zip_first(instantiation_values.
GetArgs(), params)) {
1551 const TemplateArgument &passed_arg = std::get<0>(pair);
1552 NamedDecl *found_param = std::get<1>(pair);
1557 return class_template_decl;
1566 ClassTemplateDecl *class_template_decl =
nullptr;
1567 if (decl_ctx ==
nullptr)
1568 decl_ctx = ast.getTranslationUnitDecl();
1570 IdentifierInfo &identifier_info = ast.Idents.get(class_name);
1571 DeclarationName decl_name(&identifier_info);
1574 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1575 for (NamedDecl *decl : result) {
1576 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1577 if (!class_template_decl)
1586 template_param_infos))
1588 return class_template_decl;
1591 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1594 ast, template_param_infos, template_param_decls);
1596 CXXRecordDecl *template_cxx_decl =
1597 CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1598 template_cxx_decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1600 template_cxx_decl->setDeclContext(decl_ctx);
1601 template_cxx_decl->setDeclName(decl_name);
1604 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1605 i < template_param_decl_count; ++i) {
1606 template_param_decls[i]->setDeclContext(template_cxx_decl);
1614 class_template_decl =
1615 ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1617 class_template_decl->setDeclContext(decl_ctx);
1618 class_template_decl->setDeclName(decl_name);
1619 class_template_decl->setTemplateParameters(template_param_list);
1620 class_template_decl->init(template_cxx_decl);
1621 template_cxx_decl->setDescribedClassTemplate(class_template_decl);
1625 class_template_decl->setAccess(
1628 decl_ctx->addDecl(class_template_decl);
1630 VerifyDecl(class_template_decl);
1632 return class_template_decl;
1635TemplateTemplateParmDecl *
1639 auto *decl_ctx = ast.getTranslationUnitDecl();
1641 IdentifierInfo &identifier_info = ast.Idents.get(template_name);
1642 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1646 ast, template_param_infos, template_param_decls);
1652 return TemplateTemplateParmDecl::Create(
1653 ast, decl_ctx, SourceLocation(),
1655 false, &identifier_info,
1656 TemplateNameKind::TNK_Type_template,
true,
1657 template_param_list);
1660ClassTemplateSpecializationDecl *
1663 ClassTemplateDecl *class_template_decl,
int kind,
1666 llvm::SmallVector<clang::TemplateArgument, 2> args(
1667 template_param_infos.
Size() +
1670 auto const &orig_args = template_param_infos.
GetArgs();
1671 std::copy(orig_args.begin(), orig_args.end(), args.begin());
1673 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1676 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1677 ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
1678 class_template_specialization_decl->setTagKind(
1679 static_cast<TagDecl::TagKind
>(kind));
1680 class_template_specialization_decl->setDeclContext(decl_ctx);
1681 class_template_specialization_decl->setInstantiationOf(class_template_decl);
1682 class_template_specialization_decl->setTemplateArgs(
1683 TemplateArgumentList::CreateCopy(ast, args));
1684 class_template_specialization_decl->setDeclName(
1685 class_template_decl->getDeclName());
1690 class_template_specialization_decl->setStrictPackMatch(
false);
1693 decl_ctx->addDecl(class_template_specialization_decl);
1695 class_template_specialization_decl->setSpecializationKind(
1696 TSK_ExplicitSpecialization);
1698 return class_template_specialization_decl;
1702 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1703 if (class_template_specialization_decl) {
1705 return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
1711 clang::OverloadedOperatorKind op_kind,
1712 bool unary,
bool binary,
1713 uint32_t num_params) {
1715 if (op_kind == OO_Call)
1721 if (num_params == 1)
1723 if (num_params == 2)
1730 bool is_method, clang::OverloadedOperatorKind op_kind,
1731 uint32_t num_params) {
1739 case OO_Array_Delete:
1743#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1745 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1747#include "clang/Basic/OperatorKinds.def"
1754clang::AccessSpecifier
1756 clang::AccessSpecifier rhs) {
1759 if (lhs == AS_none || rhs == AS_none)
1761 if (lhs == AS_private || rhs == AS_private)
1763 if (lhs == AS_protected || rhs == AS_protected)
1764 return AS_protected;
1769 uint32_t &bitfield_bit_size) {
1771 if (field ==
nullptr)
1774 if (field->isBitField()) {
1775 Expr *bit_width_expr = field->getBitWidth();
1776 if (bit_width_expr) {
1777 if (std::optional<llvm::APSInt> bit_width_apsint =
1778 bit_width_expr->getIntegerConstantExpr(ast)) {
1779 bitfield_bit_size = bit_width_apsint->getLimitedValue(
UINT32_MAX);
1788 if (record_decl ==
nullptr)
1791 if (!record_decl->field_empty())
1795 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1796 if (cxx_record_decl) {
1797 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1798 for (base_class = cxx_record_decl->bases_begin(),
1799 base_class_end = cxx_record_decl->bases_end();
1800 base_class != base_class_end; ++base_class) {
1801 assert(record_decl != base_class->getType()->getAsCXXRecordDecl() &&
1802 "Base can't inherit from itself.");
1814 if (std::optional<ClangASTMetadata> meta_data =
GetMetadata(record_decl);
1815 meta_data && meta_data->IsForcefullyCompleted())
1821#pragma mark Objective-C Classes
1824 llvm::StringRef name, clang::DeclContext *decl_ctx,
1826 std::optional<ClangASTMetadata> metadata) {
1828 assert(!name.empty());
1830 decl_ctx = ast.getTranslationUnitDecl();
1832 ObjCInterfaceDecl *decl =
1833 ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
1834 decl->setDeclContext(decl_ctx);
1835 decl->setDeclName(&ast.Idents.get(name));
1836 decl->setImplicit(isInternal);
1842 return GetType(ast.getObjCInterfaceType(decl));
1851 bool omit_empty_base_classes) {
1852 uint32_t num_bases = 0;
1853 if (cxx_record_decl) {
1854 if (omit_empty_base_classes) {
1855 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1856 for (base_class = cxx_record_decl->bases_begin(),
1857 base_class_end = cxx_record_decl->bases_end();
1858 base_class != base_class_end; ++base_class) {
1865 num_bases = cxx_record_decl->getNumBases();
1870#pragma mark Namespace Declarations
1873 const char *name, clang::DeclContext *decl_ctx,
1875 NamespaceDecl *namespace_decl =
nullptr;
1877 TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
1879 decl_ctx = translation_unit_decl;
1882 IdentifierInfo &identifier_info = ast.Idents.get(name);
1883 DeclarationName decl_name(&identifier_info);
1884 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1885 for (NamedDecl *decl : result) {
1886 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1888 return namespace_decl;
1891 namespace_decl = NamespaceDecl::Create(ast, decl_ctx, is_inline,
1892 SourceLocation(), SourceLocation(),
1893 &identifier_info,
nullptr,
false);
1895 decl_ctx->addDecl(namespace_decl);
1897 if (decl_ctx == translation_unit_decl) {
1898 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1900 return namespace_decl;
1903 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1904 SourceLocation(),
nullptr,
nullptr,
false);
1905 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1906 translation_unit_decl->addDecl(namespace_decl);
1907 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace());
1909 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1910 if (parent_namespace_decl) {
1911 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1913 return namespace_decl;
1915 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1916 SourceLocation(),
nullptr,
nullptr,
false);
1917 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1918 parent_namespace_decl->addDecl(namespace_decl);
1919 assert(namespace_decl ==
1920 parent_namespace_decl->getAnonymousNamespace());
1922 assert(
false &&
"GetUniqueNamespaceDeclaration called with no name and "
1923 "no namespace as decl_ctx");
1931 VerifyDecl(namespace_decl);
1932 return namespace_decl;
1939 clang::BlockDecl *decl =
1940 clang::BlockDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1941 decl->setDeclContext(ctx);
1950 clang::DeclContext *right,
1951 clang::DeclContext *root) {
1952 if (root ==
nullptr)
1955 std::set<clang::DeclContext *> path_left;
1956 for (clang::DeclContext *d = left; d !=
nullptr; d = d->getParent())
1957 path_left.insert(d);
1959 for (clang::DeclContext *d = right; d !=
nullptr; d = d->getParent())
1960 if (path_left.find(d) != path_left.end())
1968 clang::NamespaceDecl *ns_decl) {
1969 if (decl_ctx && ns_decl) {
1970 auto *translation_unit =
getASTContext().getTranslationUnitDecl();
1971 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
1973 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
1974 clang::SourceLocation(), ns_decl,
1977 decl_ctx->addDecl(using_decl);
1987 clang::NamedDecl *target) {
1988 if (current_decl_ctx && target) {
1989 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
1991 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(),
false);
1993 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
1995 target->getDeclName(), using_decl, target);
1997 using_decl->addShadowDecl(shadow_decl);
1998 current_decl_ctx->addDecl(using_decl);
2006 const char *name, clang::QualType type) {
2008 clang::VarDecl *var_decl =
2009 clang::VarDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
2010 var_decl->setDeclContext(decl_context);
2011 if (name && name[0])
2012 var_decl->setDeclName(&
getASTContext().Idents.getOwn(name));
2013 var_decl->setType(type);
2015 var_decl->setAccess(clang::AS_public);
2016 decl_context->addDecl(var_decl);
2025 switch (basic_type) {
2027 return ast->VoidTy.getAsOpaquePtr();
2029 return ast->CharTy.getAsOpaquePtr();
2031 return ast->SignedCharTy.getAsOpaquePtr();
2033 return ast->UnsignedCharTy.getAsOpaquePtr();
2035 return ast->getWCharType().getAsOpaquePtr();
2037 return ast->getSignedWCharType().getAsOpaquePtr();
2039 return ast->getUnsignedWCharType().getAsOpaquePtr();
2041 return ast->Char8Ty.getAsOpaquePtr();
2043 return ast->Char16Ty.getAsOpaquePtr();
2045 return ast->Char32Ty.getAsOpaquePtr();
2047 return ast->ShortTy.getAsOpaquePtr();
2049 return ast->UnsignedShortTy.getAsOpaquePtr();
2051 return ast->IntTy.getAsOpaquePtr();
2053 return ast->UnsignedIntTy.getAsOpaquePtr();
2055 return ast->LongTy.getAsOpaquePtr();
2057 return ast->UnsignedLongTy.getAsOpaquePtr();
2059 return ast->LongLongTy.getAsOpaquePtr();
2061 return ast->UnsignedLongLongTy.getAsOpaquePtr();
2063 return ast->Int128Ty.getAsOpaquePtr();
2065 return ast->UnsignedInt128Ty.getAsOpaquePtr();
2067 return ast->BoolTy.getAsOpaquePtr();
2069 return ast->HalfTy.getAsOpaquePtr();
2071 return ast->FloatTy.getAsOpaquePtr();
2073 return ast->DoubleTy.getAsOpaquePtr();
2075 return ast->LongDoubleTy.getAsOpaquePtr();
2077 return ast->Float128Ty.getAsOpaquePtr();
2079 return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
2081 return ast->getComplexType(ast->DoubleTy).getAsOpaquePtr();
2083 return ast->getComplexType(ast->LongDoubleTy).getAsOpaquePtr();
2085 return ast->getObjCIdType().getAsOpaquePtr();
2087 return ast->getObjCClassType().getAsOpaquePtr();
2089 return ast->getObjCSelType().getAsOpaquePtr();
2091 return ast->NullPtrTy.getAsOpaquePtr();
2097#pragma mark Function Types
2099clang::DeclarationName
2102 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2103 if (!
IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2112 const clang::FunctionProtoType *function_type =
2113 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2114 if (function_type ==
nullptr)
2115 return clang::DeclarationName();
2117 const bool is_method =
false;
2118 const unsigned int num_params = function_type->getNumParams();
2120 is_method, op_kind, num_params))
2121 return clang::DeclarationName();
2123 return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
2127 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
2128 printing_policy.SuppressTagKeyword =
true;
2131 printing_policy.SuppressInlineNamespace =
false;
2132 printing_policy.SuppressUnwrittenScope =
false;
2144 printing_policy.SuppressDefaultTemplateArgs =
false;
2145 return printing_policy;
2152 llvm::raw_string_ostream os(result);
2153 named_decl->getNameForDiagnostic(os, printing_policy, qualified);
2159 llvm::StringRef name,
const CompilerType &function_clang_type,
2160 clang::StorageClass storage,
bool is_inline, llvm::StringRef asm_label) {
2161 FunctionDecl *func_decl =
nullptr;
2164 decl_ctx = ast.getTranslationUnitDecl();
2166 const bool hasWrittenPrototype =
true;
2167 const bool isConstexprSpecified =
false;
2169 clang::DeclarationName declarationName =
2171 func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
2172 func_decl->setDeclContext(decl_ctx);
2173 func_decl->setDeclName(declarationName);
2175 func_decl->setStorageClass(storage);
2176 func_decl->setInlineSpecified(is_inline);
2177 func_decl->setHasWrittenPrototype(hasWrittenPrototype);
2178 func_decl->setConstexprKind(isConstexprSpecified
2179 ? ConstexprSpecKind::Constexpr
2180 : ConstexprSpecKind::Unspecified);
2192 if (!asm_label.empty())
2193 func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label));
2196 decl_ctx->addDecl(func_decl);
2198 VerifyDecl(func_decl);
2204 const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
2205 bool is_variadic,
unsigned type_quals, clang::CallingConv cc,
2206 clang::RefQualifierKind ref_qual) {
2210 std::vector<QualType> qual_type_args;
2212 for (
const auto &arg : args) {
2227 FunctionProtoType::ExtProtoInfo proto_info;
2228 proto_info.ExtInfo = cc;
2229 proto_info.Variadic = is_variadic;
2230 proto_info.ExceptionSpec = EST_None;
2231 proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
2232 proto_info.RefQualifier = ref_qual;
2240 const char *name,
const CompilerType ¶m_type,
int storage,
2243 auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
2244 decl->setDeclContext(decl_ctx);
2245 if (name && name[0])
2246 decl->setDeclName(&ast.Idents.get(name));
2248 decl->setStorageClass(
static_cast<clang::StorageClass
>(storage));
2251 decl_ctx->addDecl(decl);
2258 QualType block_type =
m_ast_up->getBlockPointerType(
2264#pragma mark Array Types
2268 std::optional<size_t> element_count,
2281 clang::ArraySizeModifier::Normal, 0));
2287 llvm::APInt ap_element_count(64, *element_count);
2289 ap_element_count,
nullptr,
2290 clang::ArraySizeModifier::Normal, 0));
2294 llvm::StringRef type_name,
2295 const std::initializer_list<std::pair<const char *, CompilerType>>
2302 lldbassert(0 &&
"Trying to create a type for an existing name");
2310 for (
const auto &field : type_fields)
2320 llvm::StringRef type_name,
2321 const std::initializer_list<std::pair<const char *, CompilerType>>
2333#pragma mark Enumeration Types
2336 llvm::StringRef name, clang::DeclContext *decl_ctx,
2338 const CompilerType &integer_clang_type,
bool is_scoped,
2339 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind) {
2346 EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
2347 enum_decl->setDeclContext(decl_ctx);
2349 enum_decl->setDeclName(&ast.Idents.get(name));
2350 enum_decl->setScoped(is_scoped);
2351 enum_decl->setScopedUsingClassTag(is_scoped);
2352 enum_decl->setFixed(
false);
2355 decl_ctx->addDecl(enum_decl);
2359 clang::EnumExtensibilityAttr::CreateImplicit(ast, *enum_kind));
2364 enum_decl->setAccess(AS_public);
2366 return GetType(ast.getCanonicalTagType(enum_decl));
2377 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
2378 return GetType(ast.SignedCharTy);
2380 if (bit_size == ast.getTypeSize(ast.ShortTy))
2383 if (bit_size == ast.getTypeSize(ast.IntTy))
2386 if (bit_size == ast.getTypeSize(ast.LongTy))
2389 if (bit_size == ast.getTypeSize(ast.LongLongTy))
2390 return GetType(ast.LongLongTy);
2392 if (bit_size == ast.getTypeSize(ast.Int128Ty))
2395 if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
2396 return GetType(ast.UnsignedCharTy);
2398 if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
2399 return GetType(ast.UnsignedShortTy);
2401 if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
2402 return GetType(ast.UnsignedIntTy);
2404 if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
2405 return GetType(ast.UnsignedLongTy);
2407 if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
2408 return GetType(ast.UnsignedLongLongTy);
2410 if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
2411 return GetType(ast.UnsignedInt128Ty);
2428 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2430 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2431 named_decl->getDeclName().getAsString().c_str());
2433 printf(
"%20s\n", decl_ctx->getDeclKindName());
2439 if (decl ==
nullptr)
2443 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2445 bool is_injected_class_name =
2446 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2447 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2448 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2449 record_decl->getDeclName().getAsString().c_str(),
2450 is_injected_class_name ?
" (injected class name)" :
"");
2453 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2455 printf(
"%20s: %s\n", decl->getDeclKindName(),
2456 named_decl->getDeclName().getAsString().c_str());
2458 printf(
"%20s\n", decl->getDeclKindName());
2464 clang::Decl *decl) {
2468 ExternalASTSource *ast_source = ast->getExternalSource();
2473 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2474 if (tag_decl->isCompleteDefinition())
2477 if (!tag_decl->hasExternalLexicalStorage())
2480 ast_source->CompleteType(tag_decl);
2482 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2483 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2484 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2485 if (objc_interface_decl->getDefinition())
2488 if (!objc_interface_decl->hasExternalLexicalStorage())
2491 ast_source->CompleteType(objc_interface_decl);
2493 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2523std::optional<ClangASTMetadata>
2529 return std::nullopt;
2532std::optional<ClangASTMetadata>
2538 return std::nullopt;
2542 clang::AccessSpecifier access) {
2543 if (access == clang::AccessSpecifier::AS_none)
2549clang::AccessSpecifier
2554 return clang::AccessSpecifier::AS_none;
2576 if (find(mask, type->getTypeClass()) != mask.end())
2578 switch (type->getTypeClass()) {
2581 case clang::Type::Atomic:
2582 type = cast<clang::AtomicType>(type)->getValueType();
2584 case clang::Type::Auto:
2585 case clang::Type::Decltype:
2586 case clang::Type::Paren:
2587 case clang::Type::SubstTemplateTypeParm:
2588 case clang::Type::TemplateSpecialization:
2589 case clang::Type::Typedef:
2590 case clang::Type::TypeOf:
2591 case clang::Type::TypeOfExpr:
2592 case clang::Type::Using:
2593 case clang::Type::PredefinedSugar:
2594 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2608 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2609 switch (type_class) {
2610 case clang::Type::ObjCInterface:
2611 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2613 case clang::Type::ObjCObjectPointer:
2615 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2616 ->getPointeeType());
2617 case clang::Type::Enum:
2618 case clang::Type::Record:
2619 return llvm::cast<clang::TagType>(qual_type)
2621 ->getDefinitionOrSelf();
2634 clang::QualType qual_type,
2635 bool allow_completion) {
2636 assert(qual_type->isRecordType());
2638 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2640 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2644 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2647 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2648 const bool fields_loaded =
2649 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2652 if (is_complete && fields_loaded)
2655 if (!allow_completion)
2663 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2664 if (external_ast_source) {
2665 external_ast_source->CompleteType(cxx_record_decl);
2666 if (cxx_record_decl->isCompleteDefinition()) {
2667 cxx_record_decl->field_begin();
2668 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
2680 clang::QualType qual_type,
2681 bool allow_completion) {
2682 assert(qual_type->isEnumeralType());
2685 const clang::EnumType *enum_type =
2686 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2688 auto *tag_decl = enum_type->getAsTagDecl();
2692 if (tag_decl->getDefinition())
2695 if (!allow_completion)
2699 if (!tag_decl->hasExternalLexicalStorage())
2703 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2704 if (!external_ast_source)
2707 external_ast_source->CompleteType(tag_decl);
2715static const clang::ObjCObjectType *
2717 bool allow_completion) {
2718 assert(qual_type->isObjCObjectType());
2721 const clang::ObjCObjectType *objc_class_type =
2722 llvm::cast<clang::ObjCObjectType>(qual_type);
2724 clang::ObjCInterfaceDecl *class_interface_decl =
2725 objc_class_type->getInterface();
2728 if (!class_interface_decl)
2729 return objc_class_type;
2732 if (class_interface_decl->getDefinition())
2733 return objc_class_type;
2735 if (!allow_completion)
2739 if (!class_interface_decl->hasExternalLexicalStorage())
2743 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2744 if (!external_ast_source)
2747 external_ast_source->CompleteType(class_interface_decl);
2748 return objc_class_type;
2752 clang::QualType qual_type,
2753 bool allow_completion =
true) {
2755 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2756 switch (type_class) {
2757 case clang::Type::ConstantArray:
2758 case clang::Type::IncompleteArray:
2759 case clang::Type::VariableArray: {
2760 const clang::ArrayType *array_type =
2761 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2767 case clang::Type::Record: {
2768 if (
const auto *RT =
2770 return !RT->isIncompleteType();
2775 case clang::Type::Enum: {
2777 return !ET->isIncompleteType();
2781 case clang::Type::ObjCObject:
2782 case clang::Type::ObjCInterface: {
2783 if (
const auto *OT =
2785 return !OT->isIncompleteType();
2790 case clang::Type::Attributed:
2792 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType(),
2795 case clang::Type::MemberPointer:
2798 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2799 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2800 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2804 return !qual_type.getTypePtr()->isIncompleteType();
2815static clang::ObjCIvarDecl::AccessControl
2819 return clang::ObjCIvarDecl::None;
2821 return clang::ObjCIvarDecl::Public;
2823 return clang::ObjCIvarDecl::Private;
2825 return clang::ObjCIvarDecl::Protected;
2827 return clang::ObjCIvarDecl::Package;
2829 return clang::ObjCIvarDecl::None;
2836 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2843 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2844 switch (type_class) {
2845 case clang::Type::IncompleteArray:
2846 case clang::Type::VariableArray:
2847 case clang::Type::ConstantArray:
2848 case clang::Type::ExtVector:
2849 case clang::Type::Vector:
2850 case clang::Type::Record:
2851 case clang::Type::ObjCObject:
2852 case clang::Type::ObjCInterface:
2864 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2865 switch (type_class) {
2866 case clang::Type::Record: {
2867 if (
const clang::RecordType *record_type =
2868 llvm::dyn_cast_or_null<clang::RecordType>(
2869 qual_type.getTypePtrOrNull())) {
2870 if (
const clang::RecordDecl *record_decl =
2871 record_type->getOriginalDecl()) {
2872 return record_decl->isAnonymousStructOrUnion();
2886 uint64_t *size,
bool *is_incomplete) {
2889 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2890 switch (type_class) {
2894 case clang::Type::ConstantArray:
2895 if (element_type_ptr)
2897 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2901 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2903 .getLimitedValue(ULLONG_MAX);
2905 *is_incomplete =
false;
2908 case clang::Type::IncompleteArray:
2909 if (element_type_ptr)
2911 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2917 *is_incomplete =
true;
2920 case clang::Type::VariableArray:
2921 if (element_type_ptr)
2923 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2929 *is_incomplete =
false;
2932 case clang::Type::DependentSizedArray:
2933 if (element_type_ptr)
2936 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2942 *is_incomplete =
false;
2945 if (element_type_ptr)
2946 element_type_ptr->
Clear();
2950 *is_incomplete =
false;
2958 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2959 switch (type_class) {
2960 case clang::Type::Vector: {
2961 const clang::VectorType *vector_type =
2962 qual_type->getAs<clang::VectorType>();
2965 *size = vector_type->getNumElements();
2967 *element_type =
GetType(vector_type->getElementType());
2971 case clang::Type::ExtVector: {
2972 const clang::ExtVectorType *ext_vector_type =
2973 qual_type->getAs<clang::ExtVectorType>();
2974 if (ext_vector_type) {
2976 *size = ext_vector_type->getNumElements();
2980 ext_vector_type->getElementType().getAsOpaquePtr());
2996 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
2999 clang::ObjCInterfaceDecl *result_iface_decl =
3000 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
3002 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
3006 return (ast_metadata->GetISAPtr() != 0);
3010 return GetQualType(type).getUnqualifiedType()->isCharType();
3019 const bool allow_completion =
true;
3034 if (!pointee_or_element_clang_type.
IsValid())
3037 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
3038 if (pointee_or_element_clang_type.
IsCharType()) {
3039 if (type_flags.
Test(eTypeIsArray)) {
3042 length = llvm::cast<clang::ConstantArrayType>(
3056 if (
auto pointer_auth = qual_type.getPointerAuth())
3057 return pointer_auth.getKey();
3066 if (
auto pointer_auth = qual_type.getPointerAuth())
3067 return pointer_auth.getExtraDiscriminator();
3076 if (
auto pointer_auth = qual_type.getPointerAuth())
3077 return pointer_auth.isAddressDiscriminated();
3083 auto isFunctionType = [&](clang::QualType qual_type) {
3084 return qual_type->isFunctionType();
3098 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3099 switch (type_class) {
3100 case clang::Type::Record:
3102 const clang::CXXRecordDecl *cxx_record_decl =
3103 qual_type->getAsCXXRecordDecl();
3104 if (cxx_record_decl) {
3105 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3108 const clang::RecordType *record_type =
3109 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3111 if (
const clang::RecordDecl *record_decl =
3112 record_type->getOriginalDecl()->getDefinition()) {
3115 clang::RecordDecl::field_iterator field_pos,
3116 field_end = record_decl->field_end();
3117 uint32_t num_fields = 0;
3118 bool is_hva =
false;
3119 bool is_hfa =
false;
3120 clang::QualType base_qual_type;
3121 uint64_t base_bitwidth = 0;
3122 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3124 clang::QualType field_qual_type = field_pos->getType();
3125 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3126 if (field_qual_type->isFloatingType()) {
3127 if (field_qual_type->isComplexType())
3130 if (num_fields == 0)
3131 base_qual_type = field_qual_type;
3136 if (field_qual_type.getTypePtr() !=
3137 base_qual_type.getTypePtr())
3141 }
else if (field_qual_type->isVectorType() ||
3142 field_qual_type->isExtVectorType()) {
3143 if (num_fields == 0) {
3144 base_qual_type = field_qual_type;
3145 base_bitwidth = field_bitwidth;
3150 if (base_bitwidth != field_bitwidth)
3152 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3161 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3178 const clang::FunctionProtoType *func =
3179 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3181 return func->getNumParams();
3188 const size_t index) {
3191 const clang::FunctionProtoType *func =
3192 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3194 if (index < func->getNumParams())
3195 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3203 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3207 if (predicate(qual_type))
3210 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3211 switch (type_class) {
3215 case clang::Type::LValueReference:
3216 case clang::Type::RValueReference: {
3217 const clang::ReferenceType *reference_type =
3218 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3220 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3229 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3230 return qual_type->isMemberFunctionPointerType();
3233 return IsTypeImpl(type, isMemberFunctionPointerType);
3237 auto isFunctionPointerType = [](clang::QualType qual_type) {
3238 return qual_type->isFunctionPointerType();
3241 return IsTypeImpl(type, isFunctionPointerType);
3247 auto isBlockPointerType = [&](clang::QualType qual_type) {
3248 if (qual_type->isBlockPointerType()) {
3249 if (function_pointer_type_ptr) {
3250 const clang::BlockPointerType *block_pointer_type =
3251 qual_type->castAs<clang::BlockPointerType>();
3252 QualType pointee_type = block_pointer_type->getPointeeType();
3253 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3255 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3272 const clang::BuiltinType *builtin_type =
3273 llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3276 if (builtin_type->isInteger()) {
3277 is_signed = builtin_type->isSignedInteger();
3288 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3293 ->getDefinitionOrSelf()
3307 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3311 return enum_type->isScopedEnumeralType();
3322 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3323 switch (type_class) {
3324 case clang::Type::Builtin:
3325 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3328 case clang::BuiltinType::ObjCId:
3329 case clang::BuiltinType::ObjCClass:
3333 case clang::Type::ObjCObjectPointer:
3337 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3341 case clang::Type::BlockPointer:
3344 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3348 case clang::Type::Pointer:
3351 llvm::cast<clang::PointerType>(qual_type)
3355 case clang::Type::MemberPointer:
3358 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3367 pointee_type->
Clear();
3375 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3376 switch (type_class) {
3377 case clang::Type::Builtin:
3378 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3381 case clang::BuiltinType::ObjCId:
3382 case clang::BuiltinType::ObjCClass:
3386 case clang::Type::ObjCObjectPointer:
3390 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3394 case clang::Type::BlockPointer:
3397 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3401 case clang::Type::Pointer:
3404 llvm::cast<clang::PointerType>(qual_type)
3408 case clang::Type::MemberPointer:
3411 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3415 case clang::Type::LValueReference:
3418 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3422 case clang::Type::RValueReference:
3425 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3434 pointee_type->
Clear();
3443 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3445 switch (type_class) {
3446 case clang::Type::LValueReference:
3449 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3455 case clang::Type::RValueReference:
3458 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3470 pointee_type->
Clear();
3475 uint32_t &count,
bool &is_complex) {
3479 if (
const clang::BuiltinType *BT = llvm::dyn_cast<clang::BuiltinType>(
3480 qual_type->getCanonicalTypeInternal())) {
3481 clang::BuiltinType::Kind kind = BT->getKind();
3482 if (kind >= clang::BuiltinType::Float &&
3483 kind <= clang::BuiltinType::LongDouble) {
3488 }
else if (
const clang::ComplexType *CT =
3489 llvm::dyn_cast<clang::ComplexType>(
3490 qual_type->getCanonicalTypeInternal())) {
3497 }
else if (
const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(
3498 qual_type->getCanonicalTypeInternal())) {
3501 count = VT->getNumElements();
3517 const clang::TagType *tag_type =
3518 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3520 if (clang::TagDecl *tag_decl = tag_type->getOriginalDecl()->getDefinition())
3521 return tag_decl->isCompleteDefinition();
3524 const clang::ObjCObjectType *objc_class_type =
3525 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3526 if (objc_class_type) {
3527 clang::ObjCInterfaceDecl *class_interface_decl =
3528 objc_class_type->getInterface();
3529 if (class_interface_decl)
3530 return class_interface_decl->getDefinition() !=
nullptr;
3541 const clang::ObjCObjectPointerType *obj_pointer_type =
3542 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3544 if (obj_pointer_type)
3545 return obj_pointer_type->isObjCClassType();
3560 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3561 return (type_class == clang::Type::Record);
3568 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3569 return (type_class == clang::Type::Enum);
3575 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3576 switch (type_class) {
3577 case clang::Type::Record:
3579 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3586 return cxx_record_decl->isDynamicClass();
3600 bool check_cplusplus,
3602 if (dynamic_pointee_type)
3603 dynamic_pointee_type->
Clear();
3607 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3608 if (dynamic_pointee_type)
3610 type.getAsOpaquePtr());
3613 clang::QualType pointee_qual_type;
3615 switch (qual_type->getTypeClass()) {
3616 case clang::Type::Builtin:
3617 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3618 clang::BuiltinType::ObjCId) {
3619 set_dynamic_pointee_type(qual_type);
3624 case clang::Type::ObjCObjectPointer:
3627 if (
const auto *objc_pointee_type =
3628 qual_type->getPointeeType().getTypePtrOrNull()) {
3629 if (
const auto *objc_object_type =
3630 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3631 objc_pointee_type)) {
3632 if (objc_object_type->isObjCClass())
3636 set_dynamic_pointee_type(
3637 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3640 case clang::Type::Pointer:
3642 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3645 case clang::Type::LValueReference:
3646 case clang::Type::RValueReference:
3648 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3658 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3659 case clang::Type::Builtin:
3660 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3661 case clang::BuiltinType::UnknownAny:
3662 case clang::BuiltinType::Void:
3663 set_dynamic_pointee_type(pointee_qual_type);
3669 case clang::Type::Record: {
3670 if (!check_cplusplus)
3672 clang::CXXRecordDecl *cxx_record_decl =
3673 pointee_qual_type->getAsCXXRecordDecl();
3674 if (!cxx_record_decl)
3678 if (cxx_record_decl->isCompleteDefinition())
3679 success = cxx_record_decl->isDynamicClass();
3681 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3682 std::optional<bool> is_dynamic =
3683 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3685 success = *is_dynamic;
3687 success = cxx_record_decl->isDynamicClass();
3693 set_dynamic_pointee_type(pointee_qual_type);
3697 case clang::Type::ObjCObject:
3698 case clang::Type::ObjCInterface:
3700 set_dynamic_pointee_type(pointee_qual_type);
3715 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3722 ->getTypeClass() == clang::Type::Typedef;
3732 if (
auto *record_decl =
3734 return record_decl->canPassInRegisters();
3740 return TypeSystemClangSupportsLanguage(language);
3743std::optional<std::string>
3746 return std::nullopt;
3749 if (qual_type.isNull())
3750 return std::nullopt;
3752 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3753 if (!cxx_record_decl)
3754 return std::nullopt;
3756 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3764 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3771 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3773 return tag_type->getOriginalDecl()->isEntityBeingDefined();
3784 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3785 if (class_type_ptr) {
3786 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3787 const clang::ObjCObjectPointerType *obj_pointer_type =
3788 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3789 if (obj_pointer_type ==
nullptr)
3790 class_type_ptr->
Clear();
3794 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3801 class_type_ptr->
Clear();
3810 const bool allow_completion =
true;
3830 {clang::Type::Typedef, clang::Type::Atomic});
3833 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3834 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3841 if (
auto *named_decl = qual_type->getAsTagDecl())
3853 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3854 printing_policy.SuppressTagKeyword =
true;
3855 printing_policy.SuppressScope =
false;
3856 printing_policy.SuppressUnwrittenScope =
true;
3857 printing_policy.SuppressInlineNamespace =
true;
3858 return ConstString(qual_type.getAsString(printing_policy));
3867 if (pointee_or_element_clang_type)
3868 pointee_or_element_clang_type->
Clear();
3870 clang::QualType qual_type =
3873 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3874 switch (type_class) {
3875 case clang::Type::Attributed:
3876 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3879 pointee_or_element_clang_type);
3880 case clang::Type::Builtin: {
3881 const clang::BuiltinType *builtin_type =
3882 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3884 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3885 switch (builtin_type->getKind()) {
3886 case clang::BuiltinType::ObjCId:
3887 case clang::BuiltinType::ObjCClass:
3888 if (pointee_or_element_clang_type)
3892 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3895 case clang::BuiltinType::ObjCSel:
3896 if (pointee_or_element_clang_type)
3899 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3902 case clang::BuiltinType::Bool:
3903 case clang::BuiltinType::Char_U:
3904 case clang::BuiltinType::UChar:
3905 case clang::BuiltinType::WChar_U:
3906 case clang::BuiltinType::Char16:
3907 case clang::BuiltinType::Char32:
3908 case clang::BuiltinType::UShort:
3909 case clang::BuiltinType::UInt:
3910 case clang::BuiltinType::ULong:
3911 case clang::BuiltinType::ULongLong:
3912 case clang::BuiltinType::UInt128:
3913 case clang::BuiltinType::Char_S:
3914 case clang::BuiltinType::SChar:
3915 case clang::BuiltinType::WChar_S:
3916 case clang::BuiltinType::Short:
3917 case clang::BuiltinType::Int:
3918 case clang::BuiltinType::Long:
3919 case clang::BuiltinType::LongLong:
3920 case clang::BuiltinType::Int128:
3921 case clang::BuiltinType::Float:
3922 case clang::BuiltinType::Double:
3923 case clang::BuiltinType::LongDouble:
3924 builtin_type_flags |= eTypeIsScalar;
3925 if (builtin_type->isInteger()) {
3926 builtin_type_flags |= eTypeIsInteger;
3927 if (builtin_type->isSignedInteger())
3928 builtin_type_flags |= eTypeIsSigned;
3929 }
else if (builtin_type->isFloatingPoint())
3930 builtin_type_flags |= eTypeIsFloat;
3935 return builtin_type_flags;
3938 case clang::Type::BlockPointer:
3939 if (pointee_or_element_clang_type)
3941 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3942 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3944 case clang::Type::Complex: {
3945 uint32_t complex_type_flags =
3946 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3947 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3948 qual_type->getCanonicalTypeInternal());
3950 clang::QualType complex_element_type(complex_type->getElementType());
3951 if (complex_element_type->isIntegerType())
3952 complex_type_flags |= eTypeIsFloat;
3953 else if (complex_element_type->isFloatingType())
3954 complex_type_flags |= eTypeIsInteger;
3956 return complex_type_flags;
3959 case clang::Type::ConstantArray:
3960 case clang::Type::DependentSizedArray:
3961 case clang::Type::IncompleteArray:
3962 case clang::Type::VariableArray:
3963 if (pointee_or_element_clang_type)
3965 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
3968 return eTypeHasChildren | eTypeIsArray;
3970 case clang::Type::DependentName:
3972 case clang::Type::DependentSizedExtVector:
3973 return eTypeHasChildren | eTypeIsVector;
3975 case clang::Type::Enum:
3976 if (pointee_or_element_clang_type)
3978 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
3980 ->getDefinitionOrSelf()
3983 return eTypeIsEnumeration | eTypeHasValue;
3985 case clang::Type::FunctionProto:
3986 return eTypeIsFuncPrototype | eTypeHasValue;
3987 case clang::Type::FunctionNoProto:
3988 return eTypeIsFuncPrototype | eTypeHasValue;
3989 case clang::Type::InjectedClassName:
3992 case clang::Type::LValueReference:
3993 case clang::Type::RValueReference:
3994 if (pointee_or_element_clang_type)
3997 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
4000 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
4002 case clang::Type::MemberPointer:
4003 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
4005 case clang::Type::ObjCObjectPointer:
4006 if (pointee_or_element_clang_type)
4008 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4009 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
4012 case clang::Type::ObjCObject:
4013 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4014 case clang::Type::ObjCInterface:
4015 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4017 case clang::Type::Pointer:
4018 if (pointee_or_element_clang_type)
4020 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4021 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
4023 case clang::Type::Record:
4024 if (qual_type->getAsCXXRecordDecl())
4025 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
4027 return eTypeHasChildren | eTypeIsStructUnion;
4029 case clang::Type::SubstTemplateTypeParm:
4030 return eTypeIsTemplate;
4031 case clang::Type::TemplateTypeParm:
4032 return eTypeIsTemplate;
4033 case clang::Type::TemplateSpecialization:
4034 return eTypeIsTemplate;
4036 case clang::Type::Typedef:
4037 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
4039 ->getUnderlyingType())
4041 case clang::Type::UnresolvedUsing:
4044 case clang::Type::ExtVector:
4045 case clang::Type::Vector: {
4046 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
4047 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
4048 qual_type->getCanonicalTypeInternal());
4050 if (vector_type->isIntegerType())
4051 vector_type_flags |= eTypeIsFloat;
4052 else if (vector_type->isFloatingType())
4053 vector_type_flags |= eTypeIsInteger;
4055 return vector_type_flags;
4070 if (qual_type->isAnyPointerType()) {
4071 if (qual_type->isObjCObjectPointerType())
4073 if (qual_type->getPointeeCXXRecordDecl())
4076 clang::QualType pointee_type(qual_type->getPointeeType());
4077 if (pointee_type->getPointeeCXXRecordDecl())
4079 if (pointee_type->isObjCObjectOrInterfaceType())
4081 if (pointee_type->isObjCClassType())
4083 if (pointee_type.getTypePtr() ==
4087 if (qual_type->isObjCObjectOrInterfaceType())
4089 if (qual_type->getAsCXXRecordDecl())
4091 switch (qual_type->getTypeClass()) {
4094 case clang::Type::Builtin:
4095 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4097 case clang::BuiltinType::Void:
4098 case clang::BuiltinType::Bool:
4099 case clang::BuiltinType::Char_U:
4100 case clang::BuiltinType::UChar:
4101 case clang::BuiltinType::WChar_U:
4102 case clang::BuiltinType::Char16:
4103 case clang::BuiltinType::Char32:
4104 case clang::BuiltinType::UShort:
4105 case clang::BuiltinType::UInt:
4106 case clang::BuiltinType::ULong:
4107 case clang::BuiltinType::ULongLong:
4108 case clang::BuiltinType::UInt128:
4109 case clang::BuiltinType::Char_S:
4110 case clang::BuiltinType::SChar:
4111 case clang::BuiltinType::WChar_S:
4112 case clang::BuiltinType::Short:
4113 case clang::BuiltinType::Int:
4114 case clang::BuiltinType::Long:
4115 case clang::BuiltinType::LongLong:
4116 case clang::BuiltinType::Int128:
4117 case clang::BuiltinType::Float:
4118 case clang::BuiltinType::Double:
4119 case clang::BuiltinType::LongDouble:
4122 case clang::BuiltinType::NullPtr:
4125 case clang::BuiltinType::ObjCId:
4126 case clang::BuiltinType::ObjCClass:
4127 case clang::BuiltinType::ObjCSel:
4130 case clang::BuiltinType::Dependent:
4131 case clang::BuiltinType::Overload:
4132 case clang::BuiltinType::BoundMember:
4133 case clang::BuiltinType::UnknownAny:
4137 case clang::Type::Typedef:
4138 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4140 ->getUnderlyingType())
4150 return lldb::eTypeClassInvalid;
4152 clang::QualType qual_type =
4155 switch (qual_type->getTypeClass()) {
4156 case clang::Type::Atomic:
4157 case clang::Type::Auto:
4158 case clang::Type::CountAttributed:
4159 case clang::Type::Decltype:
4160 case clang::Type::Paren:
4161 case clang::Type::TypeOf:
4162 case clang::Type::TypeOfExpr:
4163 case clang::Type::Using:
4164 case clang::Type::PredefinedSugar:
4165 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4166 case clang::Type::UnaryTransform:
4168 case clang::Type::FunctionNoProto:
4169 return lldb::eTypeClassFunction;
4170 case clang::Type::FunctionProto:
4171 return lldb::eTypeClassFunction;
4172 case clang::Type::IncompleteArray:
4173 return lldb::eTypeClassArray;
4174 case clang::Type::VariableArray:
4175 return lldb::eTypeClassArray;
4176 case clang::Type::ConstantArray:
4177 return lldb::eTypeClassArray;
4178 case clang::Type::DependentSizedArray:
4179 return lldb::eTypeClassArray;
4180 case clang::Type::ArrayParameter:
4181 return lldb::eTypeClassArray;
4182 case clang::Type::DependentSizedExtVector:
4183 return lldb::eTypeClassVector;
4184 case clang::Type::DependentVector:
4185 return lldb::eTypeClassVector;
4186 case clang::Type::ExtVector:
4187 return lldb::eTypeClassVector;
4188 case clang::Type::Vector:
4189 return lldb::eTypeClassVector;
4190 case clang::Type::Builtin:
4192 case clang::Type::BitInt:
4193 case clang::Type::DependentBitInt:
4194 return lldb::eTypeClassBuiltin;
4195 case clang::Type::ObjCObjectPointer:
4196 return lldb::eTypeClassObjCObjectPointer;
4197 case clang::Type::BlockPointer:
4198 return lldb::eTypeClassBlockPointer;
4199 case clang::Type::Pointer:
4200 return lldb::eTypeClassPointer;
4201 case clang::Type::LValueReference:
4202 return lldb::eTypeClassReference;
4203 case clang::Type::RValueReference:
4204 return lldb::eTypeClassReference;
4205 case clang::Type::MemberPointer:
4206 return lldb::eTypeClassMemberPointer;
4207 case clang::Type::Complex:
4208 if (qual_type->isComplexType())
4209 return lldb::eTypeClassComplexFloat;
4211 return lldb::eTypeClassComplexInteger;
4212 case clang::Type::ObjCObject:
4213 return lldb::eTypeClassObjCObject;
4214 case clang::Type::ObjCInterface:
4215 return lldb::eTypeClassObjCInterface;
4216 case clang::Type::Record: {
4217 const clang::RecordType *record_type =
4218 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4219 const clang::RecordDecl *record_decl = record_type->getOriginalDecl();
4220 if (record_decl->isUnion())
4221 return lldb::eTypeClassUnion;
4222 else if (record_decl->isStruct())
4223 return lldb::eTypeClassStruct;
4225 return lldb::eTypeClassClass;
4227 case clang::Type::Enum:
4228 return lldb::eTypeClassEnumeration;
4229 case clang::Type::Typedef:
4230 return lldb::eTypeClassTypedef;
4231 case clang::Type::UnresolvedUsing:
4234 case clang::Type::Attributed:
4235 case clang::Type::BTFTagAttributed:
4237 case clang::Type::TemplateTypeParm:
4239 case clang::Type::SubstTemplateTypeParm:
4241 case clang::Type::SubstTemplateTypeParmPack:
4243 case clang::Type::InjectedClassName:
4245 case clang::Type::DependentName:
4247 case clang::Type::PackExpansion:
4250 case clang::Type::TemplateSpecialization:
4252 case clang::Type::DeducedTemplateSpecialization:
4254 case clang::Type::Pipe:
4258 case clang::Type::Decayed:
4260 case clang::Type::Adjusted:
4262 case clang::Type::ObjCTypeParam:
4265 case clang::Type::DependentAddressSpace:
4267 case clang::Type::MacroQualified:
4271 case clang::Type::ConstantMatrix:
4272 case clang::Type::DependentSizedMatrix:
4276 case clang::Type::PackIndexing:
4279 case clang::Type::HLSLAttributedResource:
4281 case clang::Type::HLSLInlineSpirv:
4283 case clang::Type::SubstBuiltinTemplatePack:
4287 return lldb::eTypeClassOther;
4292 return GetQualType(type).getQualifiers().getCVRQualifiers();
4304 const clang::Type *array_eletype =
4305 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4310 return GetType(clang::QualType(array_eletype, 0));
4321 return GetType(ast_ctx.getConstantArrayType(
4322 qual_type, llvm::APInt(64, size),
nullptr,
4323 clang::ArraySizeModifier::Normal, 0));
4325 return GetType(ast_ctx.getIncompleteArrayType(
4326 qual_type, clang::ArraySizeModifier::Normal, 0));
4340 clang::QualType qual_type) {
4341 if (qual_type->isPointerType())
4342 qual_type = ast->getPointerType(
4344 else if (
const ConstantArrayType *arr =
4345 ast->getAsConstantArrayType(qual_type)) {
4346 qual_type = ast->getConstantArrayType(
4348 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4349 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4351 qual_type = qual_type.getUnqualifiedType();
4352 qual_type.removeLocalConst();
4353 qual_type.removeLocalRestrict();
4354 qual_type.removeLocalVolatile();
4376 const clang::FunctionProtoType *func =
4379 return func->getNumParams();
4387 const clang::FunctionProtoType *func =
4388 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4390 const uint32_t num_args = func->getNumParams();
4392 return GetType(func->getParamType(idx));
4402 const clang::FunctionProtoType *func =
4403 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4405 return GetType(func->getReturnType());
4412 size_t num_functions = 0;
4415 switch (qual_type->getTypeClass()) {
4416 case clang::Type::Record:
4418 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4419 num_functions = std::distance(cxx_record_decl->method_begin(),
4420 cxx_record_decl->method_end());
4423 case clang::Type::ObjCObjectPointer: {
4424 const clang::ObjCObjectPointerType *objc_class_type =
4425 qual_type->castAs<clang::ObjCObjectPointerType>();
4426 const clang::ObjCInterfaceType *objc_interface_type =
4427 objc_class_type->getInterfaceType();
4428 if (objc_interface_type &&
4430 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4431 clang::ObjCInterfaceDecl *class_interface_decl =
4432 objc_interface_type->getDecl();
4433 if (class_interface_decl) {
4434 num_functions = std::distance(class_interface_decl->meth_begin(),
4435 class_interface_decl->meth_end());
4441 case clang::Type::ObjCObject:
4442 case clang::Type::ObjCInterface:
4444 const clang::ObjCObjectType *objc_class_type =
4445 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4446 if (objc_class_type) {
4447 clang::ObjCInterfaceDecl *class_interface_decl =
4448 objc_class_type->getInterface();
4449 if (class_interface_decl)
4450 num_functions = std::distance(class_interface_decl->meth_begin(),
4451 class_interface_decl->meth_end());
4460 return num_functions;
4472 switch (qual_type->getTypeClass()) {
4473 case clang::Type::Record:
4475 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4476 auto method_iter = cxx_record_decl->method_begin();
4477 auto method_end = cxx_record_decl->method_end();
4479 static_cast<size_t>(std::distance(method_iter, method_end))) {
4480 std::advance(method_iter, idx);
4481 clang::CXXMethodDecl *cxx_method_decl =
4482 method_iter->getCanonicalDecl();
4483 if (cxx_method_decl) {
4484 name = cxx_method_decl->getDeclName().getAsString();
4485 if (cxx_method_decl->isStatic())
4487 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4489 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4493 clang_type =
GetType(cxx_method_decl->getType());
4501 case clang::Type::ObjCObjectPointer: {
4502 const clang::ObjCObjectPointerType *objc_class_type =
4503 qual_type->castAs<clang::ObjCObjectPointerType>();
4504 const clang::ObjCInterfaceType *objc_interface_type =
4505 objc_class_type->getInterfaceType();
4506 if (objc_interface_type &&
4508 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4509 clang::ObjCInterfaceDecl *class_interface_decl =
4510 objc_interface_type->getDecl();
4511 if (class_interface_decl) {
4512 auto method_iter = class_interface_decl->meth_begin();
4513 auto method_end = class_interface_decl->meth_end();
4515 static_cast<size_t>(std::distance(method_iter, method_end))) {
4516 std::advance(method_iter, idx);
4517 clang::ObjCMethodDecl *objc_method_decl =
4518 method_iter->getCanonicalDecl();
4519 if (objc_method_decl) {
4521 name = objc_method_decl->getSelector().getAsString();
4522 if (objc_method_decl->isClassMethod())
4533 case clang::Type::ObjCObject:
4534 case clang::Type::ObjCInterface:
4536 const clang::ObjCObjectType *objc_class_type =
4537 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4538 if (objc_class_type) {
4539 clang::ObjCInterfaceDecl *class_interface_decl =
4540 objc_class_type->getInterface();
4541 if (class_interface_decl) {
4542 auto method_iter = class_interface_decl->meth_begin();
4543 auto method_end = class_interface_decl->meth_end();
4545 static_cast<size_t>(std::distance(method_iter, method_end))) {
4546 std::advance(method_iter, idx);
4547 clang::ObjCMethodDecl *objc_method_decl =
4548 method_iter->getCanonicalDecl();
4549 if (objc_method_decl) {
4551 name = objc_method_decl->getSelector().getAsString();
4552 if (objc_method_decl->isClassMethod())
4585 return GetType(qual_type.getTypePtr()->getPointeeType());
4595 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4596 case clang::Type::ObjCObject:
4597 case clang::Type::ObjCInterface:
4644 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4645 clang::QualType result =
4646 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4656 result.addVolatile();
4666 result.addRestrict();
4675 if (type && typedef_name && typedef_name[0]) {
4679 clang::DeclContext *decl_ctx =
4684 clang::TypedefDecl *decl =
4685 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4686 decl->setDeclContext(decl_ctx);
4687 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4688 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4689 decl_ctx->addDecl(decl);
4692 clang::TagDecl *tdecl =
nullptr;
4693 if (!qual_type.isNull()) {
4694 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4695 tdecl = rt->getOriginalDecl();
4696 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4697 tdecl = et->getOriginalDecl();
4703 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4704 tdecl->setTypedefNameForAnonDecl(decl);
4706 decl->setAccess(clang::AS_public);
4709 NestedNameSpecifier Qualifier =
4710 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4712 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4720 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4723 return GetType(typedef_type->getDecl()->getUnderlyingType());
4736 const FunctionType::ExtInfo generic_ext_info(
4745 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4750const llvm::fltSemantics &
4753 const size_t bit_size = byte_size * 8;
4754 if (bit_size == ast.getTypeSize(ast.FloatTy))
4755 return ast.getFloatTypeSemantics(ast.FloatTy);
4756 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4757 return ast.getFloatTypeSemantics(ast.DoubleTy);
4759 bit_size == ast.getTypeSize(ast.Float128Ty))
4760 return ast.getFloatTypeSemantics(ast.Float128Ty);
4761 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4762 bit_size == llvm::APFloat::semanticsSizeInBits(
4763 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4764 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4765 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4766 return ast.getFloatTypeSemantics(ast.HalfTy);
4767 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4768 return ast.getFloatTypeSemantics(ast.Float128Ty);
4769 return llvm::APFloatBase::Bogus();
4772llvm::Expected<uint64_t>
4775 assert(qual_type->isObjCObjectOrInterfaceType());
4780 if (std::optional<uint64_t> bit_size =
4781 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4785 static bool g_printed =
false;
4790 llvm::outs() <<
"warning: trying to determine the size of type ";
4792 llvm::outs() <<
"without a valid ExecutionContext. this is not "
4793 "reliable. please file a bug against LLDB.\n";
4794 llvm::outs() <<
"backtrace:\n";
4795 llvm::sys::PrintStackTrace(llvm::outs());
4796 llvm::outs() <<
"\n";
4805llvm::Expected<uint64_t>
4808 const bool base_name_only =
true;
4810 return llvm::createStringError(
4811 "could not complete type %s",
4815 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4816 switch (type_class) {
4817 case clang::Type::ConstantArray:
4818 case clang::Type::FunctionProto:
4819 case clang::Type::Record:
4821 case clang::Type::ObjCInterface:
4822 case clang::Type::ObjCObject:
4824 case clang::Type::IncompleteArray: {
4825 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4828 qual_type->getArrayElementTypeNoTypeQual()
4829 ->getCanonicalTypeUnqualified());
4834 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4838 return llvm::createStringError(
4839 "could not get size of type %s",
4843std::optional<size_t>
4859 switch (qual_type->getTypeClass()) {
4860 case clang::Type::Atomic:
4861 case clang::Type::Auto:
4862 case clang::Type::CountAttributed:
4863 case clang::Type::Decltype:
4864 case clang::Type::Paren:
4865 case clang::Type::Typedef:
4866 case clang::Type::TypeOf:
4867 case clang::Type::TypeOfExpr:
4868 case clang::Type::Using:
4869 case clang::Type::PredefinedSugar:
4870 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4872 case clang::Type::UnaryTransform:
4875 case clang::Type::FunctionNoProto:
4876 case clang::Type::FunctionProto:
4879 case clang::Type::IncompleteArray:
4880 case clang::Type::VariableArray:
4881 case clang::Type::ArrayParameter:
4884 case clang::Type::ConstantArray:
4887 case clang::Type::DependentVector:
4888 case clang::Type::ExtVector:
4889 case clang::Type::Vector:
4893 case clang::Type::BitInt:
4894 case clang::Type::DependentBitInt:
4898 case clang::Type::Builtin:
4899 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4900 case clang::BuiltinType::Void:
4903 case clang::BuiltinType::Char_S:
4904 case clang::BuiltinType::SChar:
4905 case clang::BuiltinType::WChar_S:
4906 case clang::BuiltinType::Short:
4907 case clang::BuiltinType::Int:
4908 case clang::BuiltinType::Long:
4909 case clang::BuiltinType::LongLong:
4910 case clang::BuiltinType::Int128:
4913 case clang::BuiltinType::Bool:
4914 case clang::BuiltinType::Char_U:
4915 case clang::BuiltinType::UChar:
4916 case clang::BuiltinType::WChar_U:
4917 case clang::BuiltinType::Char8:
4918 case clang::BuiltinType::Char16:
4919 case clang::BuiltinType::Char32:
4920 case clang::BuiltinType::UShort:
4921 case clang::BuiltinType::UInt:
4922 case clang::BuiltinType::ULong:
4923 case clang::BuiltinType::ULongLong:
4924 case clang::BuiltinType::UInt128:
4928 case clang::BuiltinType::ShortAccum:
4929 case clang::BuiltinType::Accum:
4930 case clang::BuiltinType::LongAccum:
4931 case clang::BuiltinType::UShortAccum:
4932 case clang::BuiltinType::UAccum:
4933 case clang::BuiltinType::ULongAccum:
4934 case clang::BuiltinType::ShortFract:
4935 case clang::BuiltinType::Fract:
4936 case clang::BuiltinType::LongFract:
4937 case clang::BuiltinType::UShortFract:
4938 case clang::BuiltinType::UFract:
4939 case clang::BuiltinType::ULongFract:
4940 case clang::BuiltinType::SatShortAccum:
4941 case clang::BuiltinType::SatAccum:
4942 case clang::BuiltinType::SatLongAccum:
4943 case clang::BuiltinType::SatUShortAccum:
4944 case clang::BuiltinType::SatUAccum:
4945 case clang::BuiltinType::SatULongAccum:
4946 case clang::BuiltinType::SatShortFract:
4947 case clang::BuiltinType::SatFract:
4948 case clang::BuiltinType::SatLongFract:
4949 case clang::BuiltinType::SatUShortFract:
4950 case clang::BuiltinType::SatUFract:
4951 case clang::BuiltinType::SatULongFract:
4954 case clang::BuiltinType::Half:
4955 case clang::BuiltinType::Float:
4956 case clang::BuiltinType::Float16:
4957 case clang::BuiltinType::Float128:
4958 case clang::BuiltinType::Double:
4959 case clang::BuiltinType::LongDouble:
4960 case clang::BuiltinType::BFloat16:
4961 case clang::BuiltinType::Ibm128:
4964 case clang::BuiltinType::ObjCClass:
4965 case clang::BuiltinType::ObjCId:
4966 case clang::BuiltinType::ObjCSel:
4969 case clang::BuiltinType::NullPtr:
4972 case clang::BuiltinType::Kind::ARCUnbridgedCast:
4973 case clang::BuiltinType::Kind::BoundMember:
4974 case clang::BuiltinType::Kind::BuiltinFn:
4975 case clang::BuiltinType::Kind::Dependent:
4976 case clang::BuiltinType::Kind::OCLClkEvent:
4977 case clang::BuiltinType::Kind::OCLEvent:
4978 case clang::BuiltinType::Kind::OCLImage1dRO:
4979 case clang::BuiltinType::Kind::OCLImage1dWO:
4980 case clang::BuiltinType::Kind::OCLImage1dRW:
4981 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
4982 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
4983 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
4984 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
4985 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
4986 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
4987 case clang::BuiltinType::Kind::OCLImage2dRO:
4988 case clang::BuiltinType::Kind::OCLImage2dWO:
4989 case clang::BuiltinType::Kind::OCLImage2dRW:
4990 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
4991 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
4992 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
4993 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
4994 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
4995 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
4996 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
4997 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
4998 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
4999 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
5000 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
5001 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
5002 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
5003 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
5004 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
5005 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
5006 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
5007 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
5008 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
5009 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
5010 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
5011 case clang::BuiltinType::Kind::OCLImage3dRO:
5012 case clang::BuiltinType::Kind::OCLImage3dWO:
5013 case clang::BuiltinType::Kind::OCLImage3dRW:
5014 case clang::BuiltinType::Kind::OCLQueue:
5015 case clang::BuiltinType::Kind::OCLReserveID:
5016 case clang::BuiltinType::Kind::OCLSampler:
5017 case clang::BuiltinType::Kind::HLSLResource:
5018 case clang::BuiltinType::Kind::ArraySection:
5019 case clang::BuiltinType::Kind::OMPArrayShaping:
5020 case clang::BuiltinType::Kind::OMPIterator:
5021 case clang::BuiltinType::Kind::Overload:
5022 case clang::BuiltinType::Kind::PseudoObject:
5023 case clang::BuiltinType::Kind::UnknownAny:
5026 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
5027 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
5028 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
5029 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
5030 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
5031 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
5032 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
5033 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
5034 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
5035 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
5036 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
5037 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
5041 case clang::BuiltinType::VectorPair:
5042 case clang::BuiltinType::VectorQuad:
5043 case clang::BuiltinType::DMR1024:
5044 case clang::BuiltinType::DMR2048:
5048#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5049#include "clang/Basic/AArch64ACLETypes.def"
5053#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5054#include "clang/Basic/RISCVVTypes.def"
5058 case clang::BuiltinType::WasmExternRef:
5061 case clang::BuiltinType::IncompleteMatrixIdx:
5064 case clang::BuiltinType::UnresolvedTemplate:
5068#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
5069 case clang::BuiltinType::Id:
5070#include "clang/Basic/AMDGPUTypes.def"
5076 case clang::Type::ObjCObjectPointer:
5077 case clang::Type::BlockPointer:
5078 case clang::Type::Pointer:
5079 case clang::Type::LValueReference:
5080 case clang::Type::RValueReference:
5081 case clang::Type::MemberPointer:
5083 case clang::Type::Complex: {
5085 if (qual_type->isComplexType())
5088 const clang::ComplexType *complex_type =
5089 qual_type->getAsComplexIntegerType();
5099 case clang::Type::ObjCInterface:
5101 case clang::Type::Record:
5103 case clang::Type::Enum:
5104 return qual_type->isUnsignedIntegerOrEnumerationType()
5107 case clang::Type::DependentSizedArray:
5108 case clang::Type::DependentSizedExtVector:
5109 case clang::Type::UnresolvedUsing:
5110 case clang::Type::Attributed:
5111 case clang::Type::BTFTagAttributed:
5112 case clang::Type::TemplateTypeParm:
5113 case clang::Type::SubstTemplateTypeParm:
5114 case clang::Type::SubstTemplateTypeParmPack:
5115 case clang::Type::InjectedClassName:
5116 case clang::Type::DependentName:
5117 case clang::Type::PackExpansion:
5118 case clang::Type::ObjCObject:
5120 case clang::Type::TemplateSpecialization:
5121 case clang::Type::DeducedTemplateSpecialization:
5122 case clang::Type::Adjusted:
5123 case clang::Type::Pipe:
5127 case clang::Type::Decayed:
5129 case clang::Type::ObjCTypeParam:
5132 case clang::Type::DependentAddressSpace:
5134 case clang::Type::MacroQualified:
5137 case clang::Type::ConstantMatrix:
5138 case clang::Type::DependentSizedMatrix:
5142 case clang::Type::PackIndexing:
5145 case clang::Type::HLSLAttributedResource:
5147 case clang::Type::HLSLInlineSpirv:
5149 case clang::Type::SubstBuiltinTemplatePack:
5162 switch (qual_type->getTypeClass()) {
5163 case clang::Type::Atomic:
5164 case clang::Type::Auto:
5165 case clang::Type::CountAttributed:
5166 case clang::Type::Decltype:
5167 case clang::Type::Paren:
5168 case clang::Type::Typedef:
5169 case clang::Type::TypeOf:
5170 case clang::Type::TypeOfExpr:
5171 case clang::Type::Using:
5172 case clang::Type::PredefinedSugar:
5173 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5174 case clang::Type::UnaryTransform:
5177 case clang::Type::FunctionNoProto:
5178 case clang::Type::FunctionProto:
5181 case clang::Type::IncompleteArray:
5182 case clang::Type::VariableArray:
5183 case clang::Type::ArrayParameter:
5186 case clang::Type::ConstantArray:
5189 case clang::Type::DependentVector:
5190 case clang::Type::ExtVector:
5191 case clang::Type::Vector:
5194 case clang::Type::BitInt:
5195 case clang::Type::DependentBitInt:
5199 case clang::Type::Builtin:
5200 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5201 case clang::BuiltinType::UnknownAny:
5202 case clang::BuiltinType::Void:
5203 case clang::BuiltinType::BoundMember:
5206 case clang::BuiltinType::Bool:
5208 case clang::BuiltinType::Char_S:
5209 case clang::BuiltinType::SChar:
5210 case clang::BuiltinType::WChar_S:
5211 case clang::BuiltinType::Char_U:
5212 case clang::BuiltinType::UChar:
5213 case clang::BuiltinType::WChar_U:
5215 case clang::BuiltinType::Char8:
5217 case clang::BuiltinType::Char16:
5219 case clang::BuiltinType::Char32:
5221 case clang::BuiltinType::UShort:
5223 case clang::BuiltinType::Short:
5225 case clang::BuiltinType::UInt:
5227 case clang::BuiltinType::Int:
5229 case clang::BuiltinType::ULong:
5231 case clang::BuiltinType::Long:
5233 case clang::BuiltinType::ULongLong:
5235 case clang::BuiltinType::LongLong:
5237 case clang::BuiltinType::UInt128:
5239 case clang::BuiltinType::Int128:
5241 case clang::BuiltinType::Half:
5242 case clang::BuiltinType::Float:
5243 case clang::BuiltinType::Double:
5244 case clang::BuiltinType::LongDouble:
5246 case clang::BuiltinType::Float128:
5252 case clang::Type::ObjCObjectPointer:
5254 case clang::Type::BlockPointer:
5256 case clang::Type::Pointer:
5258 case clang::Type::LValueReference:
5259 case clang::Type::RValueReference:
5261 case clang::Type::MemberPointer:
5263 case clang::Type::Complex: {
5264 if (qual_type->isComplexType())
5269 case clang::Type::ObjCInterface:
5271 case clang::Type::Record:
5273 case clang::Type::Enum:
5275 case clang::Type::DependentSizedArray:
5276 case clang::Type::DependentSizedExtVector:
5277 case clang::Type::UnresolvedUsing:
5278 case clang::Type::Attributed:
5279 case clang::Type::BTFTagAttributed:
5280 case clang::Type::TemplateTypeParm:
5281 case clang::Type::SubstTemplateTypeParm:
5282 case clang::Type::SubstTemplateTypeParmPack:
5283 case clang::Type::InjectedClassName:
5284 case clang::Type::DependentName:
5285 case clang::Type::PackExpansion:
5286 case clang::Type::ObjCObject:
5288 case clang::Type::TemplateSpecialization:
5289 case clang::Type::DeducedTemplateSpecialization:
5290 case clang::Type::Adjusted:
5291 case clang::Type::Pipe:
5295 case clang::Type::Decayed:
5297 case clang::Type::ObjCTypeParam:
5300 case clang::Type::DependentAddressSpace:
5302 case clang::Type::MacroQualified:
5306 case clang::Type::ConstantMatrix:
5307 case clang::Type::DependentSizedMatrix:
5311 case clang::Type::PackIndexing:
5314 case clang::Type::HLSLAttributedResource:
5316 case clang::Type::HLSLInlineSpirv:
5318 case clang::Type::SubstBuiltinTemplatePack:
5326 while (class_interface_decl) {
5327 if (class_interface_decl->ivar_size() > 0)
5330 class_interface_decl = class_interface_decl->getSuperClass();
5335static std::optional<SymbolFile::ArrayInfo>
5337 clang::QualType qual_type,
5339 if (qual_type->isIncompleteArrayType())
5340 if (std::optional<ClangASTMetadata> metadata =
5344 return std::nullopt;
5347llvm::Expected<uint32_t>
5349 bool omit_empty_base_classes,
5352 return llvm::createStringError(
"invalid clang type");
5354 uint32_t num_children = 0;
5356 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5357 switch (type_class) {
5358 case clang::Type::Builtin:
5359 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5360 case clang::BuiltinType::ObjCId:
5361 case clang::BuiltinType::ObjCClass:
5370 case clang::Type::Complex:
5372 case clang::Type::Record:
5374 const clang::RecordType *record_type =
5375 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5376 const clang::RecordDecl *record_decl =
5377 record_type->getOriginalDecl()->getDefinitionOrSelf();
5378 const clang::CXXRecordDecl *cxx_record_decl =
5379 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5383 num_children += std::distance(record_decl->field_begin(),
5384 record_decl->field_end());
5386 return llvm::createStringError(
5389 case clang::Type::ObjCObject:
5390 case clang::Type::ObjCInterface:
5392 const clang::ObjCObjectType *objc_class_type =
5393 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5394 assert(objc_class_type);
5395 if (objc_class_type) {
5396 clang::ObjCInterfaceDecl *class_interface_decl =
5397 objc_class_type->getInterface();
5399 if (class_interface_decl) {
5401 clang::ObjCInterfaceDecl *superclass_interface_decl =
5402 class_interface_decl->getSuperClass();
5403 if (superclass_interface_decl) {
5404 if (omit_empty_base_classes) {
5411 num_children += class_interface_decl->ivar_size();
5417 case clang::Type::LValueReference:
5418 case clang::Type::RValueReference:
5419 case clang::Type::ObjCObjectPointer: {
5422 uint32_t num_pointee_children = 0;
5424 auto num_children_or_err =
5425 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5426 if (!num_children_or_err)
5427 return num_children_or_err;
5428 num_pointee_children = *num_children_or_err;
5431 if (num_pointee_children == 0)
5434 num_children = num_pointee_children;
5437 case clang::Type::Vector:
5438 case clang::Type::ExtVector:
5440 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5443 case clang::Type::ConstantArray:
5444 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5448 case clang::Type::IncompleteArray:
5449 if (
auto array_info =
5452 num_children = array_info->element_orders.size()
5453 ? array_info->element_orders.back().value_or(0)
5457 case clang::Type::Pointer: {
5458 const clang::PointerType *pointer_type =
5459 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5460 clang::QualType pointee_type(pointer_type->getPointeeType());
5462 uint32_t num_pointee_children = 0;
5464 auto num_children_or_err =
5465 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5466 if (!num_children_or_err)
5467 return num_children_or_err;
5468 num_pointee_children = *num_children_or_err;
5470 if (num_pointee_children == 0) {
5475 num_children = num_pointee_children;
5481 return num_children;
5492 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5493 if (type_class == clang::Type::Builtin) {
5494 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5495 case clang::BuiltinType::Void:
5497 case clang::BuiltinType::Bool:
5499 case clang::BuiltinType::Char_S:
5501 case clang::BuiltinType::Char_U:
5503 case clang::BuiltinType::Char8:
5505 case clang::BuiltinType::Char16:
5507 case clang::BuiltinType::Char32:
5509 case clang::BuiltinType::UChar:
5511 case clang::BuiltinType::SChar:
5513 case clang::BuiltinType::WChar_S:
5515 case clang::BuiltinType::WChar_U:
5517 case clang::BuiltinType::Short:
5519 case clang::BuiltinType::UShort:
5521 case clang::BuiltinType::Int:
5523 case clang::BuiltinType::UInt:
5525 case clang::BuiltinType::Long:
5527 case clang::BuiltinType::ULong:
5529 case clang::BuiltinType::LongLong:
5531 case clang::BuiltinType::ULongLong:
5533 case clang::BuiltinType::Int128:
5535 case clang::BuiltinType::UInt128:
5538 case clang::BuiltinType::Half:
5540 case clang::BuiltinType::Float:
5542 case clang::BuiltinType::Double:
5544 case clang::BuiltinType::LongDouble:
5546 case clang::BuiltinType::Float128:
5549 case clang::BuiltinType::NullPtr:
5551 case clang::BuiltinType::ObjCId:
5553 case clang::BuiltinType::ObjCClass:
5555 case clang::BuiltinType::ObjCSel:
5569 const llvm::APSInt &value)>
const &callback) {
5570 const clang::EnumType *enum_type =
5573 const clang::EnumDecl *enum_decl =
5574 enum_type->getOriginalDecl()->getDefinitionOrSelf();
5578 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5579 for (enum_pos = enum_decl->enumerator_begin(),
5580 enum_end_pos = enum_decl->enumerator_end();
5581 enum_pos != enum_end_pos; ++enum_pos) {
5582 ConstString name(enum_pos->getNameAsString().c_str());
5583 if (!callback(integer_type, name, enum_pos->getInitVal()))
5590#pragma mark Aggregate Types
5598 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5599 switch (type_class) {
5600 case clang::Type::Record:
5602 const clang::RecordType *record_type =
5603 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5605 clang::RecordDecl *record_decl =
5606 record_type->getOriginalDecl()->getDefinition();
5608 count = std::distance(record_decl->field_begin(),
5609 record_decl->field_end());
5615 case clang::Type::ObjCObjectPointer: {
5616 const clang::ObjCObjectPointerType *objc_class_type =
5617 qual_type->castAs<clang::ObjCObjectPointerType>();
5618 const clang::ObjCInterfaceType *objc_interface_type =
5619 objc_class_type->getInterfaceType();
5620 if (objc_interface_type &&
5622 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5623 clang::ObjCInterfaceDecl *class_interface_decl =
5624 objc_interface_type->getDecl();
5625 if (class_interface_decl) {
5626 count = class_interface_decl->ivar_size();
5632 case clang::Type::ObjCObject:
5633 case clang::Type::ObjCInterface:
5635 const clang::ObjCObjectType *objc_class_type =
5636 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5637 if (objc_class_type) {
5638 clang::ObjCInterfaceDecl *class_interface_decl =
5639 objc_class_type->getInterface();
5641 if (class_interface_decl)
5642 count = class_interface_decl->ivar_size();
5655 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5656 std::string &name, uint64_t *bit_offset_ptr,
5657 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5658 if (class_interface_decl) {
5659 if (idx < (class_interface_decl->ivar_size())) {
5660 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5661 ivar_end = class_interface_decl->ivar_end();
5662 uint32_t ivar_idx = 0;
5664 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5665 ++ivar_pos, ++ivar_idx) {
5666 if (ivar_idx == idx) {
5667 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5669 clang::QualType ivar_qual_type(ivar_decl->getType());
5671 name.assign(ivar_decl->getNameAsString());
5673 if (bit_offset_ptr) {
5674 const clang::ASTRecordLayout &interface_layout =
5675 ast->getASTObjCInterfaceLayout(class_interface_decl);
5676 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5679 const bool is_bitfield = ivar_pos->isBitField();
5681 if (bitfield_bit_size_ptr) {
5682 *bitfield_bit_size_ptr = 0;
5684 if (is_bitfield && ast) {
5685 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5686 clang::Expr::EvalResult result;
5687 if (bitfield_bit_size_expr &&
5688 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5689 llvm::APSInt bitfield_apsint = result.Val.getInt();
5690 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5694 if (is_bitfield_ptr)
5695 *is_bitfield_ptr = is_bitfield;
5697 return ivar_qual_type.getAsOpaquePtr();
5706 size_t idx, std::string &name,
5707 uint64_t *bit_offset_ptr,
5708 uint32_t *bitfield_bit_size_ptr,
5709 bool *is_bitfield_ptr) {
5714 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5715 switch (type_class) {
5716 case clang::Type::Record:
5718 const clang::RecordType *record_type =
5719 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5720 const clang::RecordDecl *record_decl =
5721 record_type->getOriginalDecl()->getDefinitionOrSelf();
5722 uint32_t field_idx = 0;
5723 clang::RecordDecl::field_iterator field, field_end;
5724 for (field = record_decl->field_begin(),
5725 field_end = record_decl->field_end();
5726 field != field_end; ++field, ++field_idx) {
5727 if (idx == field_idx) {
5730 name.assign(field->getNameAsString());
5734 if (bit_offset_ptr) {
5735 const clang::ASTRecordLayout &record_layout =
5737 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5740 const bool is_bitfield = field->isBitField();
5742 if (bitfield_bit_size_ptr) {
5743 *bitfield_bit_size_ptr = 0;
5746 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5747 clang::Expr::EvalResult result;
5748 if (bitfield_bit_size_expr &&
5749 bitfield_bit_size_expr->EvaluateAsInt(result,
5751 llvm::APSInt bitfield_apsint = result.Val.getInt();
5752 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5756 if (is_bitfield_ptr)
5757 *is_bitfield_ptr = is_bitfield;
5759 return GetType(field->getType());
5765 case clang::Type::ObjCObjectPointer: {
5766 const clang::ObjCObjectPointerType *objc_class_type =
5767 qual_type->castAs<clang::ObjCObjectPointerType>();
5768 const clang::ObjCInterfaceType *objc_interface_type =
5769 objc_class_type->getInterfaceType();
5770 if (objc_interface_type &&
5772 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5773 clang::ObjCInterfaceDecl *class_interface_decl =
5774 objc_interface_type->getDecl();
5775 if (class_interface_decl) {
5779 name, bit_offset_ptr, bitfield_bit_size_ptr,
5786 case clang::Type::ObjCObject:
5787 case clang::Type::ObjCInterface:
5789 const clang::ObjCObjectType *objc_class_type =
5790 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5791 assert(objc_class_type);
5792 if (objc_class_type) {
5793 clang::ObjCInterfaceDecl *class_interface_decl =
5794 objc_class_type->getInterface();
5798 name, bit_offset_ptr, bitfield_bit_size_ptr,
5814 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5815 switch (type_class) {
5816 case clang::Type::Record:
5818 const clang::CXXRecordDecl *cxx_record_decl =
5819 qual_type->getAsCXXRecordDecl();
5820 if (cxx_record_decl)
5821 count = cxx_record_decl->getNumBases();
5825 case clang::Type::ObjCObjectPointer:
5829 case clang::Type::ObjCObject:
5831 const clang::ObjCObjectType *objc_class_type =
5832 qual_type->getAsObjCQualifiedInterfaceType();
5833 if (objc_class_type) {
5834 clang::ObjCInterfaceDecl *class_interface_decl =
5835 objc_class_type->getInterface();
5837 if (class_interface_decl && class_interface_decl->getSuperClass())
5842 case clang::Type::ObjCInterface:
5844 const clang::ObjCInterfaceType *objc_interface_type =
5845 qual_type->getAs<clang::ObjCInterfaceType>();
5846 if (objc_interface_type) {
5847 clang::ObjCInterfaceDecl *class_interface_decl =
5848 objc_interface_type->getInterface();
5850 if (class_interface_decl && class_interface_decl->getSuperClass())
5866 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5867 switch (type_class) {
5868 case clang::Type::Record:
5870 const clang::CXXRecordDecl *cxx_record_decl =
5871 qual_type->getAsCXXRecordDecl();
5872 if (cxx_record_decl)
5873 count = cxx_record_decl->getNumVBases();
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 uint32_t curr_idx = 0;
5894 clang::CXXRecordDecl::base_class_const_iterator base_class,
5896 for (base_class = cxx_record_decl->bases_begin(),
5897 base_class_end = cxx_record_decl->bases_end();
5898 base_class != base_class_end; ++base_class, ++curr_idx) {
5899 if (curr_idx == idx) {
5900 if (bit_offset_ptr) {
5901 const clang::ASTRecordLayout &record_layout =
5903 const clang::CXXRecordDecl *base_class_decl =
5904 llvm::cast<clang::CXXRecordDecl>(
5905 base_class->getType()
5906 ->castAs<clang::RecordType>()
5907 ->getOriginalDecl());
5908 if (base_class->isVirtual())
5910 record_layout.getVBaseClassOffset(base_class_decl)
5915 record_layout.getBaseClassOffset(base_class_decl)
5919 return GetType(base_class->getType());
5926 case clang::Type::ObjCObjectPointer:
5929 case clang::Type::ObjCObject:
5931 const clang::ObjCObjectType *objc_class_type =
5932 qual_type->getAsObjCQualifiedInterfaceType();
5933 if (objc_class_type) {
5934 clang::ObjCInterfaceDecl *class_interface_decl =
5935 objc_class_type->getInterface();
5937 if (class_interface_decl) {
5938 clang::ObjCInterfaceDecl *superclass_interface_decl =
5939 class_interface_decl->getSuperClass();
5940 if (superclass_interface_decl) {
5942 *bit_offset_ptr = 0;
5944 superclass_interface_decl));
5950 case clang::Type::ObjCInterface:
5952 const clang::ObjCObjectType *objc_interface_type =
5953 qual_type->getAs<clang::ObjCInterfaceType>();
5954 if (objc_interface_type) {
5955 clang::ObjCInterfaceDecl *class_interface_decl =
5956 objc_interface_type->getInterface();
5958 if (class_interface_decl) {
5959 clang::ObjCInterfaceDecl *superclass_interface_decl =
5960 class_interface_decl->getSuperClass();
5961 if (superclass_interface_decl) {
5963 *bit_offset_ptr = 0;
5965 superclass_interface_decl));
5981 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5982 switch (type_class) {
5983 case clang::Type::Record:
5985 const clang::CXXRecordDecl *cxx_record_decl =
5986 qual_type->getAsCXXRecordDecl();
5987 if (cxx_record_decl) {
5988 uint32_t curr_idx = 0;
5989 clang::CXXRecordDecl::base_class_const_iterator base_class,
5991 for (base_class = cxx_record_decl->vbases_begin(),
5992 base_class_end = cxx_record_decl->vbases_end();
5993 base_class != base_class_end; ++base_class, ++curr_idx) {
5994 if (curr_idx == idx) {
5995 if (bit_offset_ptr) {
5996 const clang::ASTRecordLayout &record_layout =
5998 const clang::CXXRecordDecl *base_class_decl =
5999 llvm::cast<clang::CXXRecordDecl>(
6000 base_class->getType()
6001 ->castAs<clang::RecordType>()
6002 ->getOriginalDecl());
6004 record_layout.getVBaseClassOffset(base_class_decl)
6008 return GetType(base_class->getType());
6023 llvm::StringRef name) {
6025 switch (qual_type->getTypeClass()) {
6026 case clang::Type::Record: {
6030 const clang::RecordType *record_type =
6031 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6032 const clang::RecordDecl *record_decl =
6033 record_type->getOriginalDecl()->getDefinitionOrSelf();
6035 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
6036 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
6037 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
6038 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
6062 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6063 switch (type_class) {
6064 case clang::Type::Builtin:
6065 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6066 case clang::BuiltinType::UnknownAny:
6067 case clang::BuiltinType::Void:
6068 case clang::BuiltinType::NullPtr:
6069 case clang::BuiltinType::OCLEvent:
6070 case clang::BuiltinType::OCLImage1dRO:
6071 case clang::BuiltinType::OCLImage1dWO:
6072 case clang::BuiltinType::OCLImage1dRW:
6073 case clang::BuiltinType::OCLImage1dArrayRO:
6074 case clang::BuiltinType::OCLImage1dArrayWO:
6075 case clang::BuiltinType::OCLImage1dArrayRW:
6076 case clang::BuiltinType::OCLImage1dBufferRO:
6077 case clang::BuiltinType::OCLImage1dBufferWO:
6078 case clang::BuiltinType::OCLImage1dBufferRW:
6079 case clang::BuiltinType::OCLImage2dRO:
6080 case clang::BuiltinType::OCLImage2dWO:
6081 case clang::BuiltinType::OCLImage2dRW:
6082 case clang::BuiltinType::OCLImage2dArrayRO:
6083 case clang::BuiltinType::OCLImage2dArrayWO:
6084 case clang::BuiltinType::OCLImage2dArrayRW:
6085 case clang::BuiltinType::OCLImage3dRO:
6086 case clang::BuiltinType::OCLImage3dWO:
6087 case clang::BuiltinType::OCLImage3dRW:
6088 case clang::BuiltinType::OCLSampler:
6089 case clang::BuiltinType::HLSLResource:
6091 case clang::BuiltinType::Bool:
6092 case clang::BuiltinType::Char_U:
6093 case clang::BuiltinType::UChar:
6094 case clang::BuiltinType::WChar_U:
6095 case clang::BuiltinType::Char16:
6096 case clang::BuiltinType::Char32:
6097 case clang::BuiltinType::UShort:
6098 case clang::BuiltinType::UInt:
6099 case clang::BuiltinType::ULong:
6100 case clang::BuiltinType::ULongLong:
6101 case clang::BuiltinType::UInt128:
6102 case clang::BuiltinType::Char_S:
6103 case clang::BuiltinType::SChar:
6104 case clang::BuiltinType::WChar_S:
6105 case clang::BuiltinType::Short:
6106 case clang::BuiltinType::Int:
6107 case clang::BuiltinType::Long:
6108 case clang::BuiltinType::LongLong:
6109 case clang::BuiltinType::Int128:
6110 case clang::BuiltinType::Float:
6111 case clang::BuiltinType::Double:
6112 case clang::BuiltinType::LongDouble:
6113 case clang::BuiltinType::Float128:
6114 case clang::BuiltinType::Dependent:
6115 case clang::BuiltinType::Overload:
6116 case clang::BuiltinType::ObjCId:
6117 case clang::BuiltinType::ObjCClass:
6118 case clang::BuiltinType::ObjCSel:
6119 case clang::BuiltinType::BoundMember:
6120 case clang::BuiltinType::Half:
6121 case clang::BuiltinType::ARCUnbridgedCast:
6122 case clang::BuiltinType::PseudoObject:
6123 case clang::BuiltinType::BuiltinFn:
6124 case clang::BuiltinType::ArraySection:
6131 case clang::Type::Complex:
6133 case clang::Type::Pointer:
6135 case clang::Type::BlockPointer:
6138 case clang::Type::LValueReference:
6140 case clang::Type::RValueReference:
6142 case clang::Type::MemberPointer:
6144 case clang::Type::ConstantArray:
6146 case clang::Type::IncompleteArray:
6148 case clang::Type::VariableArray:
6150 case clang::Type::DependentSizedArray:
6152 case clang::Type::DependentSizedExtVector:
6154 case clang::Type::Vector:
6156 case clang::Type::ExtVector:
6158 case clang::Type::FunctionProto:
6160 case clang::Type::FunctionNoProto:
6162 case clang::Type::UnresolvedUsing:
6164 case clang::Type::Record:
6166 case clang::Type::Enum:
6168 case clang::Type::TemplateTypeParm:
6170 case clang::Type::SubstTemplateTypeParm:
6172 case clang::Type::TemplateSpecialization:
6174 case clang::Type::InjectedClassName:
6176 case clang::Type::DependentName:
6178 case clang::Type::ObjCObject:
6180 case clang::Type::ObjCInterface:
6182 case clang::Type::ObjCObjectPointer:
6192 std::string &deref_name, uint32_t &deref_byte_size,
6193 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6197 return llvm::createStringError(
"not a pointer, reference or array type");
6198 uint32_t child_bitfield_bit_size = 0;
6199 uint32_t child_bitfield_bit_offset = 0;
6200 bool child_is_base_class;
6201 bool child_is_deref_of_parent;
6203 type, exe_ctx, 0,
false,
true,
false, deref_name, deref_byte_size,
6204 deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6205 child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
6210 bool transparent_pointers,
bool omit_empty_base_classes,
6211 bool ignore_array_bounds, std::string &child_name,
6212 uint32_t &child_byte_size, int32_t &child_byte_offset,
6213 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6214 bool &child_is_base_class,
bool &child_is_deref_of_parent,
6219 auto get_exe_scope = [&exe_ctx]() {
6223 clang::QualType parent_qual_type(
6225 const clang::Type::TypeClass parent_type_class =
6226 parent_qual_type->getTypeClass();
6227 child_bitfield_bit_size = 0;
6228 child_bitfield_bit_offset = 0;
6229 child_is_base_class =
false;
6232 auto num_children_or_err =
6234 if (!num_children_or_err)
6235 return num_children_or_err.takeError();
6237 const bool idx_is_valid = idx < *num_children_or_err;
6239 switch (parent_type_class) {
6240 case clang::Type::Builtin:
6242 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6243 case clang::BuiltinType::ObjCId:
6244 case clang::BuiltinType::ObjCClass:
6257 case clang::Type::Record:
6259 const clang::RecordType *record_type =
6260 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6261 const clang::RecordDecl *record_decl =
6262 record_type->getOriginalDecl()->getDefinitionOrSelf();
6263 const clang::ASTRecordLayout &record_layout =
6265 uint32_t child_idx = 0;
6267 const clang::CXXRecordDecl *cxx_record_decl =
6268 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6269 if (cxx_record_decl) {
6271 clang::CXXRecordDecl::base_class_const_iterator base_class,
6273 for (base_class = cxx_record_decl->bases_begin(),
6274 base_class_end = cxx_record_decl->bases_end();
6275 base_class != base_class_end; ++base_class) {
6276 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6279 if (omit_empty_base_classes) {
6280 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6281 base_class->getType()
6282 ->getAs<clang::RecordType>()
6283 ->getOriginalDecl())
6284 ->getDefinitionOrSelf();
6289 if (idx == child_idx) {
6290 if (base_class_decl ==
nullptr)
6291 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6292 base_class->getType()
6293 ->getAs<clang::RecordType>()
6294 ->getOriginalDecl())
6295 ->getDefinitionOrSelf();
6297 if (base_class->isVirtual()) {
6298 bool handled =
false;
6300 clang::VTableContextBase *vtable_ctx =
6304 record_layout, cxx_record_decl,
6305 base_class_decl, bit_offset);
6308 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6312 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6317 child_byte_offset = bit_offset / 8;
6321 base_class_clang_type.
GetBitSize(get_exe_scope());
6323 return llvm::joinErrors(
6324 llvm::createStringError(
"no size info for base class"),
6325 size_or_err.takeError());
6327 uint64_t base_class_clang_type_bit_size = *size_or_err;
6330 assert(base_class_clang_type_bit_size % 8 == 0);
6331 child_byte_size = base_class_clang_type_bit_size / 8;
6332 child_is_base_class =
true;
6333 return base_class_clang_type;
6341 uint32_t field_idx = 0;
6342 clang::RecordDecl::field_iterator field, field_end;
6343 for (field = record_decl->field_begin(),
6344 field_end = record_decl->field_end();
6345 field != field_end; ++field, ++field_idx, ++child_idx) {
6346 if (idx == child_idx) {
6349 child_name.assign(field->getNameAsString());
6354 assert(field_idx < record_layout.getFieldCount());
6355 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6357 return llvm::joinErrors(
6358 llvm::createStringError(
"no size info for field"),
6359 size_or_err.takeError());
6361 child_byte_size = *size_or_err;
6362 const uint32_t child_bit_size = child_byte_size * 8;
6366 bit_offset = record_layout.getFieldOffset(field_idx);
6368 child_bitfield_bit_offset = bit_offset % child_bit_size;
6369 const uint32_t child_bit_offset =
6370 bit_offset - child_bitfield_bit_offset;
6371 child_byte_offset = child_bit_offset / 8;
6373 child_byte_offset = bit_offset / 8;
6376 return field_clang_type;
6382 case clang::Type::ObjCObject:
6383 case clang::Type::ObjCInterface:
6385 const clang::ObjCObjectType *objc_class_type =
6386 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6387 assert(objc_class_type);
6388 if (objc_class_type) {
6389 uint32_t child_idx = 0;
6390 clang::ObjCInterfaceDecl *class_interface_decl =
6391 objc_class_type->getInterface();
6393 if (class_interface_decl) {
6395 const clang::ASTRecordLayout &interface_layout =
6396 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6397 clang::ObjCInterfaceDecl *superclass_interface_decl =
6398 class_interface_decl->getSuperClass();
6399 if (superclass_interface_decl) {
6400 if (omit_empty_base_classes) {
6403 superclass_interface_decl));
6404 if (llvm::expectedToStdOptional(
6406 omit_empty_base_classes, exe_ctx))
6409 clang::QualType ivar_qual_type(
6411 superclass_interface_decl));
6414 superclass_interface_decl->getNameAsString());
6416 clang::TypeInfo ivar_type_info =
6419 child_byte_size = ivar_type_info.Width / 8;
6420 child_byte_offset = 0;
6421 child_is_base_class =
true;
6423 return GetType(ivar_qual_type);
6432 const uint32_t superclass_idx = child_idx;
6434 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6435 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6436 ivar_end = class_interface_decl->ivar_end();
6438 for (ivar_pos = class_interface_decl->ivar_begin();
6439 ivar_pos != ivar_end; ++ivar_pos) {
6440 if (child_idx == idx) {
6441 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6443 clang::QualType ivar_qual_type(ivar_decl->getType());
6445 child_name.assign(ivar_decl->getNameAsString());
6447 clang::TypeInfo ivar_type_info =
6450 child_byte_size = ivar_type_info.Width / 8;
6466 if (objc_runtime !=
nullptr) {
6469 parent_ast_type, ivar_decl->getNameAsString().c_str());
6477 if (child_byte_offset ==
6479 bit_offset = interface_layout.getFieldOffset(child_idx -
6481 child_byte_offset = bit_offset / 8;
6492 bit_offset = interface_layout.getFieldOffset(
6493 child_idx - superclass_idx);
6495 child_bitfield_bit_offset = bit_offset % 8;
6497 return GetType(ivar_qual_type);
6507 case clang::Type::ObjCObjectPointer:
6512 child_is_deref_of_parent =
false;
6513 bool tmp_child_is_deref_of_parent =
false;
6515 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6516 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6517 child_bitfield_bit_size, child_bitfield_bit_offset,
6518 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6521 child_is_deref_of_parent =
true;
6522 const char *parent_name =
6525 child_name.assign(1,
'*');
6526 child_name += parent_name;
6531 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6533 return size_or_err.takeError();
6534 child_byte_size = *size_or_err;
6535 child_byte_offset = 0;
6536 return pointee_clang_type;
6542 case clang::Type::Vector:
6543 case clang::Type::ExtVector:
6545 const clang::VectorType *array =
6546 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6550 char element_name[64];
6551 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6552 static_cast<uint64_t
>(idx));
6553 child_name.assign(element_name);
6554 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6556 return size_or_err.takeError();
6557 child_byte_size = *size_or_err;
6558 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6559 return element_type;
6565 case clang::Type::ConstantArray:
6566 case clang::Type::IncompleteArray:
6567 if (ignore_array_bounds || idx_is_valid) {
6568 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6572 child_name = std::string(llvm::formatv(
"[{0}]", idx));
6573 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6575 return size_or_err.takeError();
6576 child_byte_size = *size_or_err;
6577 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6578 return element_type;
6584 case clang::Type::Pointer: {
6592 child_is_deref_of_parent =
false;
6593 bool tmp_child_is_deref_of_parent =
false;
6595 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6596 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6597 child_bitfield_bit_size, child_bitfield_bit_offset,
6598 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6601 child_is_deref_of_parent =
true;
6603 const char *parent_name =
6606 child_name.assign(1,
'*');
6607 child_name += parent_name;
6612 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6614 return size_or_err.takeError();
6615 child_byte_size = *size_or_err;
6616 child_byte_offset = 0;
6617 return pointee_clang_type;
6623 case clang::Type::LValueReference:
6624 case clang::Type::RValueReference:
6626 const clang::ReferenceType *reference_type =
6627 llvm::cast<clang::ReferenceType>(
6630 GetType(reference_type->getPointeeType());
6632 child_is_deref_of_parent =
false;
6633 bool tmp_child_is_deref_of_parent =
false;
6635 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6636 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6637 child_bitfield_bit_size, child_bitfield_bit_offset,
6638 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6641 const char *parent_name =
6644 child_name.assign(1,
'&');
6645 child_name += parent_name;
6650 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6652 return size_or_err.takeError();
6653 child_byte_size = *size_or_err;
6654 child_byte_offset = 0;
6655 return pointee_clang_type;
6668 const clang::RecordDecl *record_decl,
6669 const clang::CXXBaseSpecifier *base_spec,
6670 bool omit_empty_base_classes) {
6671 uint32_t child_idx = 0;
6673 const clang::CXXRecordDecl *cxx_record_decl =
6674 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6676 if (cxx_record_decl) {
6677 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6678 for (base_class = cxx_record_decl->bases_begin(),
6679 base_class_end = cxx_record_decl->bases_end();
6680 base_class != base_class_end; ++base_class) {
6681 if (omit_empty_base_classes) {
6686 if (base_class == base_spec)
6696 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6697 bool omit_empty_base_classes) {
6699 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6700 omit_empty_base_classes);
6702 clang::RecordDecl::field_iterator field, field_end;
6703 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6704 field != field_end; ++field, ++child_idx) {
6705 if (field->getCanonicalDecl() == canonical_decl)
6747 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6748 if (type && !name.empty()) {
6750 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6751 switch (type_class) {
6752 case clang::Type::Record:
6754 const clang::RecordType *record_type =
6755 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6756 const clang::RecordDecl *record_decl =
6757 record_type->getOriginalDecl()->getDefinitionOrSelf();
6759 assert(record_decl);
6760 uint32_t child_idx = 0;
6762 const clang::CXXRecordDecl *cxx_record_decl =
6763 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6766 clang::RecordDecl::field_iterator field, field_end;
6767 for (field = record_decl->field_begin(),
6768 field_end = record_decl->field_end();
6769 field != field_end; ++field, ++child_idx) {
6770 llvm::StringRef field_name = field->getName();
6771 if (field_name.empty()) {
6773 std::vector<uint32_t> save_indices = child_indexes;
6774 child_indexes.push_back(
6776 cxx_record_decl, omit_empty_base_classes));
6778 name, omit_empty_base_classes, child_indexes))
6779 return child_indexes.size();
6780 child_indexes = std::move(save_indices);
6781 }
else if (field_name == name) {
6783 child_indexes.push_back(
6785 cxx_record_decl, omit_empty_base_classes));
6786 return child_indexes.size();
6790 if (cxx_record_decl) {
6791 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6794 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6795 clang::DeclarationName decl_name(&ident_ref);
6797 clang::CXXBasePaths paths;
6798 if (cxx_record_decl->lookupInBases(
6799 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6800 clang::CXXBasePath &path) {
6801 CXXRecordDecl *record =
6802 specifier->getType()->getAsCXXRecordDecl();
6803 auto r = record->lookup(decl_name);
6804 path.Decls = r.begin();
6808 clang::CXXBasePaths::const_paths_iterator path,
6809 path_end = paths.end();
6810 for (path = paths.begin(); path != path_end; ++path) {
6811 const size_t num_path_elements = path->size();
6812 for (
size_t e = 0; e < num_path_elements; ++e) {
6813 clang::CXXBasePathElement elem = (*path)[e];
6816 omit_empty_base_classes);
6818 child_indexes.clear();
6821 child_indexes.push_back(child_idx);
6822 parent_record_decl = elem.Base->getType()
6823 ->castAs<clang::RecordType>()
6825 ->getDefinitionOrSelf();
6828 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6831 parent_record_decl, *I, omit_empty_base_classes);
6833 child_indexes.clear();
6836 child_indexes.push_back(child_idx);
6840 return child_indexes.size();
6846 case clang::Type::ObjCObject:
6847 case clang::Type::ObjCInterface:
6849 llvm::StringRef name_sref(name);
6850 const clang::ObjCObjectType *objc_class_type =
6851 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6852 assert(objc_class_type);
6853 if (objc_class_type) {
6854 uint32_t child_idx = 0;
6855 clang::ObjCInterfaceDecl *class_interface_decl =
6856 objc_class_type->getInterface();
6858 if (class_interface_decl) {
6859 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6860 ivar_end = class_interface_decl->ivar_end();
6861 clang::ObjCInterfaceDecl *superclass_interface_decl =
6862 class_interface_decl->getSuperClass();
6864 for (ivar_pos = class_interface_decl->ivar_begin();
6865 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6866 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6868 if (ivar_decl->getName() == name_sref) {
6869 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6870 (omit_empty_base_classes &&
6874 child_indexes.push_back(child_idx);
6875 return child_indexes.size();
6879 if (superclass_interface_decl) {
6883 child_indexes.push_back(0);
6887 superclass_interface_decl));
6889 name, omit_empty_base_classes, child_indexes)) {
6892 return child_indexes.size();
6897 child_indexes.pop_back();
6904 case clang::Type::ObjCObjectPointer: {
6906 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6907 ->getPointeeType());
6909 name, omit_empty_base_classes, child_indexes);
6912 case clang::Type::LValueReference:
6913 case clang::Type::RValueReference: {
6914 const clang::ReferenceType *reference_type =
6915 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
6916 clang::QualType pointee_type(reference_type->getPointeeType());
6921 name, omit_empty_base_classes, child_indexes);
6925 case clang::Type::Pointer: {
6930 name, omit_empty_base_classes, child_indexes);
6945llvm::Expected<uint32_t>
6947 llvm::StringRef name,
6948 bool omit_empty_base_classes) {
6949 if (type && !name.empty()) {
6952 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6954 switch (type_class) {
6955 case clang::Type::Record:
6957 const clang::RecordType *record_type =
6958 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6959 const clang::RecordDecl *record_decl =
6960 record_type->getOriginalDecl()->getDefinitionOrSelf();
6962 assert(record_decl);
6963 uint32_t child_idx = 0;
6965 const clang::CXXRecordDecl *cxx_record_decl =
6966 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6968 if (cxx_record_decl) {
6969 clang::CXXRecordDecl::base_class_const_iterator base_class,
6971 for (base_class = cxx_record_decl->bases_begin(),
6972 base_class_end = cxx_record_decl->bases_end();
6973 base_class != base_class_end; ++base_class) {
6975 clang::CXXRecordDecl *base_class_decl =
6976 llvm::cast<clang::CXXRecordDecl>(
6977 base_class->getType()
6978 ->castAs<clang::RecordType>()
6979 ->getOriginalDecl())
6980 ->getDefinitionOrSelf();
6981 if (omit_empty_base_classes &&
6986 std::string base_class_type_name(
6988 if (base_class_type_name == name)
6995 clang::RecordDecl::field_iterator field, field_end;
6996 for (field = record_decl->field_begin(),
6997 field_end = record_decl->field_end();
6998 field != field_end; ++field, ++child_idx) {
6999 if (field->getName() == name)
7005 case clang::Type::ObjCObject:
7006 case clang::Type::ObjCInterface:
7008 const clang::ObjCObjectType *objc_class_type =
7009 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
7010 assert(objc_class_type);
7011 if (objc_class_type) {
7012 uint32_t child_idx = 0;
7013 clang::ObjCInterfaceDecl *class_interface_decl =
7014 objc_class_type->getInterface();
7016 if (class_interface_decl) {
7017 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
7018 ivar_end = class_interface_decl->ivar_end();
7019 clang::ObjCInterfaceDecl *superclass_interface_decl =
7020 class_interface_decl->getSuperClass();
7022 for (ivar_pos = class_interface_decl->ivar_begin();
7023 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
7024 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
7026 if (ivar_decl->getName() == name) {
7027 if ((!omit_empty_base_classes && superclass_interface_decl) ||
7028 (omit_empty_base_classes &&
7036 if (superclass_interface_decl) {
7037 if (superclass_interface_decl->getName() == name)
7045 case clang::Type::ObjCObjectPointer: {
7047 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7048 ->getPointeeType());
7050 name, omit_empty_base_classes);
7053 case clang::Type::LValueReference:
7054 case clang::Type::RValueReference: {
7055 const clang::ReferenceType *reference_type =
7056 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7061 omit_empty_base_classes);
7065 case clang::Type::Pointer: {
7066 const clang::PointerType *pointer_type =
7067 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7072 omit_empty_base_classes);
7080 return llvm::createStringError(
"Type has no child named '%s'",
7081 name.str().c_str());
7086 llvm::StringRef name) {
7087 if (!type || name.empty())
7091 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7093 switch (type_class) {
7094 case clang::Type::Record: {
7097 const clang::RecordType *record_type =
7098 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7099 const clang::RecordDecl *record_decl =
7100 record_type->getOriginalDecl()->getDefinitionOrSelf();
7102 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7103 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7104 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7106 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7108 ElaboratedTypeKeyword::None, std::nullopt,
7124 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7125 return isa<clang::ClassTemplateSpecializationDecl>(
7126 cxx_record_decl->getOriginalDecl());
7137 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7138 switch (type_class) {
7139 case clang::Type::Record:
7141 const clang::CXXRecordDecl *cxx_record_decl =
7142 qual_type->getAsCXXRecordDecl();
7143 if (cxx_record_decl) {
7144 const clang::ClassTemplateSpecializationDecl *template_decl =
7145 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7147 if (template_decl) {
7148 const auto &template_arg_list = template_decl->getTemplateArgs();
7149 size_t num_args = template_arg_list.size();
7150 assert(num_args &&
"template specialization without any args");
7151 if (expand_pack && num_args) {
7152 const auto &pack = template_arg_list[num_args - 1];
7153 if (pack.getKind() == clang::TemplateArgument::Pack)
7154 num_args += pack.pack_size() - 1;
7169const clang::ClassTemplateSpecializationDecl *
7176 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7177 switch (type_class) {
7178 case clang::Type::Record: {
7181 const clang::CXXRecordDecl *cxx_record_decl =
7182 qual_type->getAsCXXRecordDecl();
7183 if (!cxx_record_decl)
7185 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7194const TemplateArgument *
7196 size_t idx,
bool expand_pack) {
7197 const auto &args = decl->getTemplateArgs();
7198 const size_t args_size = args.size();
7200 assert(args_size &&
"template specialization without any args");
7204 const size_t last_idx = args_size - 1;
7213 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7214 return idx >= args.size() ? nullptr : &args[idx];
7219 const auto &pack = args[last_idx];
7220 const size_t pack_idx = idx - last_idx;
7221 if (pack_idx >= pack.pack_size())
7223 return &pack.pack_elements()[pack_idx];
7228 size_t arg_idx,
bool expand_pack) {
7229 const clang::ClassTemplateSpecializationDecl *template_decl =
7238 switch (arg->getKind()) {
7239 case clang::TemplateArgument::Null:
7242 case clang::TemplateArgument::NullPtr:
7245 case clang::TemplateArgument::Type:
7248 case clang::TemplateArgument::Declaration:
7251 case clang::TemplateArgument::Integral:
7254 case clang::TemplateArgument::Template:
7257 case clang::TemplateArgument::TemplateExpansion:
7260 case clang::TemplateArgument::Expression:
7263 case clang::TemplateArgument::Pack:
7266 case clang::TemplateArgument::StructuralValue:
7269 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7274 size_t idx,
bool expand_pack) {
7275 const clang::ClassTemplateSpecializationDecl *template_decl =
7281 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7284 return GetType(arg->getAsType());
7287std::optional<CompilerType::IntegralTemplateArgument>
7289 size_t idx,
bool expand_pack) {
7290 const clang::ClassTemplateSpecializationDecl *template_decl =
7293 return std::nullopt;
7297 return std::nullopt;
7299 switch (arg->getKind()) {
7300 case clang::TemplateArgument::Integral:
7301 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7302 case clang::TemplateArgument::StructuralValue: {
7303 clang::APValue value = arg->getAsStructuralValue();
7306 if (value.isFloat())
7307 return {{value.getFloat(), type}};
7310 return {{value.getInt(), type}};
7312 return std::nullopt;
7315 return std::nullopt;
7326 const clang::EnumType *enutype =
7329 return enutype->getOriginalDecl()->getDefinitionOrSelf();
7334 const clang::RecordType *record_type =
7337 return record_type->getOriginalDecl()->getDefinitionOrSelf();
7345clang::TypedefNameDecl *
7347 const clang::TypedefType *typedef_type =
7350 return typedef_type->getDecl();
7354clang::CXXRecordDecl *
7359clang::ObjCInterfaceDecl *
7361 const clang::ObjCObjectType *objc_class_type =
7362 llvm::dyn_cast<clang::ObjCObjectType>(
7364 if (objc_class_type)
7365 return objc_class_type->getInterface();
7372 uint32_t bitfield_bit_size) {
7378 clang::ASTContext &clang_ast = ast->getASTContext();
7379 clang::IdentifierInfo *ident =
nullptr;
7381 ident = &clang_ast.Idents.get(name);
7383 clang::FieldDecl *field =
nullptr;
7385 clang::Expr *bit_width =
nullptr;
7386 if (bitfield_bit_size != 0) {
7387 if (clang_ast.IntTy.isNull()) {
7390 "{0} failed: builtin ASTContext types have not been initialized");
7394 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7396 bit_width =
new (clang_ast)
7397 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7398 clang_ast.IntTy, clang::SourceLocation());
7399 bit_width = clang::ConstantExpr::Create(
7400 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7403 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7405 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7406 field->setDeclContext(record_decl);
7407 field->setDeclName(ident);
7410 field->setBitWidth(bit_width);
7416 if (
const clang::TagType *TagT =
7417 field->getType()->getAs<clang::TagType>()) {
7418 if (clang::RecordDecl *Rec =
7419 llvm::dyn_cast<clang::RecordDecl>(TagT->getOriginalDecl()))
7420 if (!Rec->getDeclName()) {
7421 Rec->setAnonymousStructOrUnion(
true);
7422 field->setImplicit();
7428 clang::AccessSpecifier access_specifier =
7430 field->setAccess(access_specifier);
7432 if (clang::CXXRecordDecl *cxx_record_decl =
7433 llvm::dyn_cast<CXXRecordDecl>(record_decl)) {
7434 AddAccessSpecifierDecl(cxx_record_decl, ast->getASTContext(),
7435 ast->GetCXXRecordDeclAccess(cxx_record_decl),
7437 ast->SetCXXRecordDeclAccess(cxx_record_decl, access_specifier);
7439 record_decl->addDecl(field);
7444 clang::ObjCInterfaceDecl *class_interface_decl =
7445 ast->GetAsObjCInterfaceDecl(type);
7447 if (class_interface_decl) {
7448 const bool is_synthesized =
false;
7453 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7454 ivar->setDeclContext(class_interface_decl);
7455 ivar->setDeclName(ident);
7459 ivar->setBitWidth(bit_width);
7460 ivar->setSynthesize(is_synthesized);
7465 class_interface_decl->addDecl(field);
7482 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7487 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7489 IndirectFieldVector indirect_fields;
7490 clang::RecordDecl::field_iterator field_pos;
7491 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7492 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7493 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7494 last_field_pos = field_pos++) {
7495 if (field_pos->isAnonymousStructOrUnion()) {
7496 clang::QualType field_qual_type = field_pos->getType();
7498 const clang::RecordType *field_record_type =
7499 field_qual_type->getAs<clang::RecordType>();
7501 if (!field_record_type)
7504 clang::RecordDecl *field_record_decl =
7505 field_record_type->getOriginalDecl()->getDefinition();
7507 if (!field_record_decl)
7510 for (clang::RecordDecl::decl_iterator
7511 di = field_record_decl->decls_begin(),
7512 de = field_record_decl->decls_end();
7514 if (clang::FieldDecl *nested_field_decl =
7515 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7516 clang::NamedDecl **chain =
7517 new (ast->getASTContext()) clang::NamedDecl *[2];
7518 chain[0] = *field_pos;
7519 chain[1] = nested_field_decl;
7520 clang::IndirectFieldDecl *indirect_field =
7521 clang::IndirectFieldDecl::Create(
7522 ast->getASTContext(), record_decl, clang::SourceLocation(),
7523 nested_field_decl->getIdentifier(),
7524 nested_field_decl->getType(), {chain, 2});
7527 indirect_field->setImplicit();
7530 field_pos->getAccess(), nested_field_decl->getAccess()));
7532 indirect_fields.push_back(indirect_field);
7533 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7534 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7535 size_t nested_chain_size =
7536 nested_indirect_field_decl->getChainingSize();
7537 clang::NamedDecl **chain =
new (ast->getASTContext())
7538 clang::NamedDecl *[nested_chain_size + 1];
7539 chain[0] = *field_pos;
7541 int chain_index = 1;
7542 for (clang::IndirectFieldDecl::chain_iterator
7543 nci = nested_indirect_field_decl->chain_begin(),
7544 nce = nested_indirect_field_decl->chain_end();
7546 chain[chain_index] = *nci;
7550 clang::IndirectFieldDecl *indirect_field =
7551 clang::IndirectFieldDecl::Create(
7552 ast->getASTContext(), record_decl, clang::SourceLocation(),
7553 nested_indirect_field_decl->getIdentifier(),
7554 nested_indirect_field_decl->getType(),
7555 {chain, nested_chain_size + 1});
7558 indirect_field->setImplicit();
7561 field_pos->getAccess(), nested_indirect_field_decl->getAccess()));
7563 indirect_fields.push_back(indirect_field);
7571 if (last_field_pos != field_end_pos) {
7572 if (last_field_pos->getType()->isIncompleteArrayType())
7573 record_decl->hasFlexibleArrayMember();
7576 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7577 ife = indirect_fields.end();
7579 record_decl->addDecl(*ifi);
7592 record_decl->addAttr(
7593 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7608 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7612 clang::VarDecl *var_decl =
nullptr;
7613 clang::IdentifierInfo *ident =
nullptr;
7615 ident = &ast->getASTContext().Idents.get(name);
7618 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7619 var_decl->setDeclContext(record_decl);
7620 var_decl->setDeclName(ident);
7622 var_decl->setStorageClass(clang::SC_Static);
7627 var_decl->setAccess(
7629 record_decl->addDecl(var_decl);
7631 VerifyDecl(var_decl);
7637 VarDecl *var,
const llvm::APInt &init_value) {
7638 assert(!var->hasInit() &&
"variable already initialized");
7640 clang::ASTContext &ast = var->getASTContext();
7641 QualType qt = var->getType();
7642 assert(qt->isIntegralOrEnumerationType() &&
7643 "only integer or enum types supported");
7646 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7647 const EnumDecl *enum_decl =
7648 enum_type->getOriginalDecl()->getDefinitionOrSelf();
7649 qt = enum_decl->getIntegerType();
7653 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7654 var->setInit(CXXBoolLiteralExpr::Create(
7655 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7657 var->setInit(IntegerLiteral::Create(
7658 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7663 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7664 assert(!var->hasInit() &&
"variable already initialized");
7666 clang::ASTContext &ast = var->getASTContext();
7667 QualType qt = var->getType();
7668 assert(qt->isFloatingType() &&
"only floating point types supported");
7669 var->setInit(FloatingLiteral::Create(
7670 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7673llvm::SmallVector<clang::ParmVarDecl *>
7675 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7676 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7678 assert(parameter_names.empty() ||
7679 parameter_names.size() == prototype.getNumParams());
7681 llvm::SmallVector<clang::ParmVarDecl *> params;
7682 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7684 llvm::StringRef name =
7685 !parameter_names.empty() ? parameter_names[param_index] :
"";
7689 GetType(prototype.getParamType(param_index)),
7690 clang::SC_None,
false);
7693 params.push_back(param);
7701 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7703 bool is_explicit,
bool is_attr_used,
bool is_artificial) {
7704 if (!type || !method_clang_type.
IsValid() || name.empty())
7709 clang::CXXRecordDecl *cxx_record_decl =
7710 record_qual_type->getAsCXXRecordDecl();
7712 if (cxx_record_decl ==
nullptr)
7717 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7719 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7721 const clang::FunctionType *function_type =
7722 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7724 if (function_type ==
nullptr)
7727 const clang::FunctionProtoType *method_function_prototype(
7728 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7730 if (!method_function_prototype)
7733 unsigned int num_params = method_function_prototype->getNumParams();
7735 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7736 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7741 const clang::ExplicitSpecifier explicit_spec(
7742 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7743 : clang::ExplicitSpecKind::ResolvedFalse);
7745 if (name.starts_with(
"~")) {
7746 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7748 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7749 cxx_dtor_decl->setDeclName(
7752 cxx_dtor_decl->setType(method_qual_type);
7753 cxx_dtor_decl->setImplicit(is_artificial);
7754 cxx_dtor_decl->setInlineSpecified(is_inline);
7755 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7756 cxx_method_decl = cxx_dtor_decl;
7757 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7758 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7760 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7761 cxx_ctor_decl->setDeclName(
7764 cxx_ctor_decl->setType(method_qual_type);
7765 cxx_ctor_decl->setImplicit(is_artificial);
7766 cxx_ctor_decl->setInlineSpecified(is_inline);
7767 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7768 cxx_ctor_decl->setNumCtorInitializers(0);
7769 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7770 cxx_method_decl = cxx_ctor_decl;
7772 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7773 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7776 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7781 const bool is_method =
true;
7783 is_method, op_kind, num_params))
7785 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7787 cxx_method_decl->setDeclContext(cxx_record_decl);
7788 cxx_method_decl->setDeclName(
7789 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7790 cxx_method_decl->setType(method_qual_type);
7791 cxx_method_decl->setStorageClass(SC);
7792 cxx_method_decl->setInlineSpecified(is_inline);
7793 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7794 }
else if (num_params == 0) {
7796 auto *cxx_conversion_decl =
7797 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7799 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7800 cxx_conversion_decl->setDeclName(
7801 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7803 function_type->getReturnType())));
7804 cxx_conversion_decl->setType(method_qual_type);
7805 cxx_conversion_decl->setInlineSpecified(is_inline);
7806 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7807 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7808 cxx_method_decl = cxx_conversion_decl;
7812 if (cxx_method_decl ==
nullptr) {
7813 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7815 cxx_method_decl->setDeclContext(cxx_record_decl);
7816 cxx_method_decl->setDeclName(decl_name);
7817 cxx_method_decl->setType(method_qual_type);
7818 cxx_method_decl->setInlineSpecified(is_inline);
7819 cxx_method_decl->setStorageClass(SC);
7820 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7825 clang::AccessSpecifier access_specifier =
7828 cxx_method_decl->setAccess(access_specifier);
7829 cxx_method_decl->setVirtualAsWritten(is_virtual);
7832 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7834 if (!asm_label.empty())
7835 cxx_method_decl->addAttr(
7836 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7841 cxx_method_decl, *method_function_prototype, {}));
7848 cxx_record_decl->addDecl(cxx_method_decl);
7857 if (is_artificial) {
7858 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7859 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7860 (cxx_ctor_decl->isCopyConstructor() &&
7861 cxx_record_decl->hasTrivialCopyConstructor()) ||
7862 (cxx_ctor_decl->isMoveConstructor() &&
7863 cxx_record_decl->hasTrivialMoveConstructor()))) {
7864 cxx_ctor_decl->setDefaulted();
7865 cxx_ctor_decl->setTrivial(
true);
7866 }
else if (cxx_dtor_decl) {
7867 if (cxx_record_decl->hasTrivialDestructor()) {
7868 cxx_dtor_decl->setDefaulted();
7869 cxx_dtor_decl->setTrivial(
true);
7871 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7872 cxx_record_decl->hasTrivialCopyAssignment()) ||
7873 (cxx_method_decl->isMoveAssignmentOperator() &&
7874 cxx_record_decl->hasTrivialMoveAssignment())) {
7875 cxx_method_decl->setDefaulted();
7876 cxx_method_decl->setTrivial(
true);
7880 VerifyDecl(cxx_method_decl);
7882 return cxx_method_decl;
7888 for (
auto *method : record->methods())
7889 addOverridesForMethod(method);
7892#pragma mark C++ Base Classes
7894std::unique_ptr<clang::CXXBaseSpecifier>
7897 bool base_of_class) {
7901 return std::make_unique<clang::CXXBaseSpecifier>(
7902 clang::SourceRange(), is_virtual, base_of_class,
7905 clang::SourceLocation());
7910 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
7914 if (!cxx_record_decl)
7916 std::vector<clang::CXXBaseSpecifier *> raw_bases;
7917 raw_bases.reserve(bases.size());
7921 for (
auto &b : bases)
7922 raw_bases.push_back(b.get());
7923 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
7932 clang::ASTContext &clang_ast = ast->getASTContext();
7934 if (type && superclass_clang_type.
IsValid() &&
7936 clang::ObjCInterfaceDecl *class_interface_decl =
7938 clang::ObjCInterfaceDecl *super_interface_decl =
7940 if (class_interface_decl && super_interface_decl) {
7941 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
7942 clang_ast.getObjCInterfaceType(super_interface_decl)));
7951 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
7952 const char *property_setter_name,
const char *property_getter_name,
7954 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
7955 property_name[0] ==
'\0')
7960 clang::ASTContext &clang_ast = ast->getASTContext();
7963 if (!class_interface_decl)
7968 if (property_clang_type.
IsValid())
7969 property_clang_type_to_access = property_clang_type;
7971 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
7973 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
7976 clang::TypeSourceInfo *prop_type_source;
7978 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
7980 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
7983 clang::ObjCPropertyDecl *property_decl =
7984 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7985 property_decl->setDeclContext(class_interface_decl);
7986 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
7987 property_decl->setType(ivar_decl
7988 ? ivar_decl->getType()
7996 ast->SetMetadata(property_decl, metadata);
7998 class_interface_decl->addDecl(property_decl);
8000 clang::Selector setter_sel, getter_sel;
8002 if (property_setter_name) {
8003 std::string property_setter_no_colon(property_setter_name,
8004 strlen(property_setter_name) - 1);
8005 const clang::IdentifierInfo *setter_ident =
8006 &clang_ast.Idents.get(property_setter_no_colon);
8007 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8008 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
8009 std::string setter_sel_string(
"set");
8010 setter_sel_string.push_back(::toupper(property_name[0]));
8011 setter_sel_string.append(&property_name[1]);
8012 const clang::IdentifierInfo *setter_ident =
8013 &clang_ast.Idents.get(setter_sel_string);
8014 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8016 property_decl->setSetterName(setter_sel);
8017 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
8019 if (property_getter_name !=
nullptr) {
8020 const clang::IdentifierInfo *getter_ident =
8021 &clang_ast.Idents.get(property_getter_name);
8022 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8024 const clang::IdentifierInfo *getter_ident =
8025 &clang_ast.Idents.get(property_name);
8026 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8028 property_decl->setGetterName(getter_sel);
8029 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
8032 property_decl->setPropertyIvarDecl(ivar_decl);
8034 if (property_attributes & DW_APPLE_PROPERTY_readonly)
8035 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
8036 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
8037 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
8038 if (property_attributes & DW_APPLE_PROPERTY_assign)
8039 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
8040 if (property_attributes & DW_APPLE_PROPERTY_retain)
8041 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
8042 if (property_attributes & DW_APPLE_PROPERTY_copy)
8043 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
8044 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8045 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
8046 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
8047 property_decl->setPropertyAttributes(
8048 ObjCPropertyAttribute::kind_nullability);
8049 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
8050 property_decl->setPropertyAttributes(
8051 ObjCPropertyAttribute::kind_null_resettable);
8052 if (property_attributes & ObjCPropertyAttribute::kind_class)
8053 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8055 const bool isInstance =
8056 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8058 clang::ObjCMethodDecl *getter =
nullptr;
8059 if (!getter_sel.isNull())
8060 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8061 : class_interface_decl->lookupClassMethod(getter_sel);
8062 if (!getter_sel.isNull() && !getter) {
8063 const bool isVariadic =
false;
8064 const bool isPropertyAccessor =
true;
8065 const bool isSynthesizedAccessorStub =
false;
8066 const bool isImplicitlyDeclared =
true;
8067 const bool isDefined =
false;
8068 const clang::ObjCImplementationControl impControl =
8069 clang::ObjCImplementationControl::None;
8070 const bool HasRelatedResultType =
false;
8073 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8074 getter->setDeclName(getter_sel);
8076 getter->setDeclContext(class_interface_decl);
8077 getter->setInstanceMethod(isInstance);
8078 getter->setVariadic(isVariadic);
8079 getter->setPropertyAccessor(isPropertyAccessor);
8080 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8081 getter->setImplicit(isImplicitlyDeclared);
8082 getter->setDefined(isDefined);
8083 getter->setDeclImplementation(impControl);
8084 getter->setRelatedResultType(HasRelatedResultType);
8088 ast->SetMetadata(getter, metadata);
8090 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8091 llvm::ArrayRef<clang::SourceLocation>());
8092 class_interface_decl->addDecl(getter);
8096 getter->setPropertyAccessor(
true);
8097 property_decl->setGetterMethodDecl(getter);
8100 clang::ObjCMethodDecl *setter =
nullptr;
8101 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8102 : class_interface_decl->lookupClassMethod(setter_sel);
8103 if (!setter_sel.isNull() && !setter) {
8104 clang::QualType result_type = clang_ast.VoidTy;
8105 const bool isVariadic =
false;
8106 const bool isPropertyAccessor =
true;
8107 const bool isSynthesizedAccessorStub =
false;
8108 const bool isImplicitlyDeclared =
true;
8109 const bool isDefined =
false;
8110 const clang::ObjCImplementationControl impControl =
8111 clang::ObjCImplementationControl::None;
8112 const bool HasRelatedResultType =
false;
8115 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8116 setter->setDeclName(setter_sel);
8117 setter->setReturnType(result_type);
8118 setter->setDeclContext(class_interface_decl);
8119 setter->setInstanceMethod(isInstance);
8120 setter->setVariadic(isVariadic);
8121 setter->setPropertyAccessor(isPropertyAccessor);
8122 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8123 setter->setImplicit(isImplicitlyDeclared);
8124 setter->setDefined(isDefined);
8125 setter->setDeclImplementation(impControl);
8126 setter->setRelatedResultType(HasRelatedResultType);
8130 ast->SetMetadata(setter, metadata);
8132 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8133 params.push_back(clang::ParmVarDecl::Create(
8134 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8137 clang::SC_Auto,
nullptr));
8139 setter->setMethodParams(clang_ast,
8140 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8141 llvm::ArrayRef<clang::SourceLocation>());
8143 class_interface_decl->addDecl(setter);
8147 setter->setPropertyAccessor(
true);
8148 property_decl->setSetterMethodDecl(setter);
8159 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8160 bool is_objc_direct_call) {
8161 if (!type || !method_clang_type.
IsValid())
8166 if (class_interface_decl ==
nullptr)
8169 if (lldb_ast ==
nullptr)
8171 clang::ASTContext &ast = lldb_ast->getASTContext();
8173 const char *selector_start = ::strchr(name,
' ');
8174 if (selector_start ==
nullptr)
8178 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8183 unsigned num_selectors_with_args = 0;
8184 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8186 len = ::strcspn(start,
":]");
8187 bool has_arg = (start[len] ==
':');
8189 ++num_selectors_with_args;
8190 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8195 if (selector_idents.size() == 0)
8198 clang::Selector method_selector = ast.Selectors.getSelector(
8199 num_selectors_with_args ? selector_idents.size() : 0,
8200 selector_idents.data());
8205 const clang::Type *method_type(method_qual_type.getTypePtr());
8207 if (method_type ==
nullptr)
8210 const clang::FunctionProtoType *method_function_prototype(
8211 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8213 if (!method_function_prototype)
8216 const bool isInstance = (name[0] ==
'-');
8217 const bool isVariadic = is_variadic;
8218 const bool isPropertyAccessor =
false;
8219 const bool isSynthesizedAccessorStub =
false;
8221 const bool isImplicitlyDeclared =
true;
8222 const bool isDefined =
false;
8223 const clang::ObjCImplementationControl impControl =
8224 clang::ObjCImplementationControl::None;
8225 const bool HasRelatedResultType =
false;
8227 const unsigned num_args = method_function_prototype->getNumParams();
8229 if (num_args != num_selectors_with_args)
8233 auto *objc_method_decl =
8234 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8235 objc_method_decl->setDeclName(method_selector);
8236 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8237 objc_method_decl->setDeclContext(
8239 objc_method_decl->setInstanceMethod(isInstance);
8240 objc_method_decl->setVariadic(isVariadic);
8241 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8242 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8243 objc_method_decl->setImplicit(isImplicitlyDeclared);
8244 objc_method_decl->setDefined(isDefined);
8245 objc_method_decl->setDeclImplementation(impControl);
8246 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8249 if (objc_method_decl ==
nullptr)
8253 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8255 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8256 params.push_back(clang::ParmVarDecl::Create(
8257 ast, objc_method_decl, clang::SourceLocation(),
8258 clang::SourceLocation(),
8260 method_function_prototype->getParamType(param_index),
nullptr,
8261 clang::SC_Auto,
nullptr));
8264 objc_method_decl->setMethodParams(
8265 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8266 llvm::ArrayRef<clang::SourceLocation>());
8269 if (is_objc_direct_call) {
8272 objc_method_decl->addAttr(
8273 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8278 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8281 class_interface_decl->addDecl(objc_method_decl);
8283 VerifyDecl(objc_method_decl);
8285 return objc_method_decl;
8295 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8296 switch (type_class) {
8297 case clang::Type::Record: {
8298 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8299 if (cxx_record_decl) {
8300 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8301 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8306 case clang::Type::Enum: {
8307 clang::EnumDecl *enum_decl =
8308 llvm::cast<clang::EnumType>(qual_type)->getOriginalDecl();
8310 enum_decl->setHasExternalLexicalStorage(has_extern);
8311 enum_decl->setHasExternalVisibleStorage(has_extern);
8316 case clang::Type::ObjCObject:
8317 case clang::Type::ObjCInterface: {
8318 const clang::ObjCObjectType *objc_class_type =
8319 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8320 assert(objc_class_type);
8321 if (objc_class_type) {
8322 clang::ObjCInterfaceDecl *class_interface_decl =
8323 objc_class_type->getInterface();
8325 if (class_interface_decl) {
8326 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8327 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8343 if (!qual_type.isNull()) {
8344 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8346 clang::TagDecl *tag_decl = tag_type->getOriginalDecl();
8348 tag_decl->startDefinition();
8353 const clang::ObjCObjectType *object_type =
8354 qual_type->getAs<clang::ObjCObjectType>();
8356 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8357 if (interface_decl) {
8358 interface_decl->startDefinition();
8369 if (qual_type.isNull())
8373 if (lldb_ast ==
nullptr)
8379 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8381 clang::TagDecl *tag_decl =
8382 tag_type->getOriginalDecl()->getDefinitionOrSelf();
8384 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8394 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8395 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8396 if (cxx_record_decl->needsImplicitCopyConstructor())
8397 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8398 if (cxx_record_decl->needsImplicitCopyAssignment())
8399 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8402 if (!cxx_record_decl->isCompleteDefinition())
8403 cxx_record_decl->completeDefinition();
8404 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8405 cxx_record_decl->setHasExternalLexicalStorage(
false);
8406 cxx_record_decl->setHasExternalVisibleStorage(
false);
8407 lldb_ast->SetCXXRecordDeclAccess(cxx_record_decl,
8408 clang::AccessSpecifier::AS_none);
8413 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8417 clang::EnumDecl *enum_decl =
8418 enutype->getOriginalDecl()->getDefinitionOrSelf();
8420 if (enum_decl->isCompleteDefinition())
8423 QualType integer_type(enum_decl->getIntegerType());
8424 if (!integer_type.isNull()) {
8425 clang::ASTContext &ast = lldb_ast->getASTContext();
8427 unsigned NumNegativeBits = 0;
8428 unsigned NumPositiveBits = 0;
8429 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8432 clang::QualType BestPromotionType;
8433 clang::QualType BestType;
8434 ast.computeBestEnumTypes(
false, NumNegativeBits,
8435 NumPositiveBits, BestType, BestPromotionType);
8437 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8438 BestPromotionType, NumPositiveBits,
8446 const llvm::APSInt &value) {
8457 if (!enum_opaque_compiler_type)
8460 clang::QualType enum_qual_type(
8463 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8468 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8473 clang::EnumConstantDecl *enumerator_decl =
8474 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8476 clang::EnumDecl *enum_decl =
8477 enutype->getOriginalDecl()->getDefinitionOrSelf();
8478 enumerator_decl->setDeclContext(enum_decl);
8479 if (name && name[0])
8480 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8481 enumerator_decl->setType(clang::QualType(enutype, 0));
8485 if (!enumerator_decl)
8488 enum_decl->addDecl(enumerator_decl);
8490 VerifyDecl(enumerator_decl);
8491 return enumerator_decl;
8496 uint64_t enum_value, uint32_t enum_value_bit_size) {
8498 llvm::APSInt value(enum_value_bit_size,
8507 const clang::Type *clang_type = qt.getTypePtrOrNull();
8508 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8513 enum_type->getOriginalDecl()->getDefinitionOrSelf()->getIntegerType());
8519 if (type && pointee_type.
IsValid() &&
8524 return ast->GetType(ast->getASTContext().getMemberPointerType(
8533#define DEPTH_INCREMENT 2
8536LLVM_DUMP_METHOD
void
8546struct ScopedASTColor {
8547 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8548 : ast(ast), old_show_colors(ast.getDiagnostics().getShowColors()) {
8549 ast.getDiagnostics().setShowColors(show_colors);
8552 ~ScopedASTColor() { ast.getDiagnostics().setShowColors(old_show_colors); }
8554 clang::ASTContext *
8555 const bool old_show_colors;
8564 clang::CreateASTDumper(output, filter,
8568 false, clang::ADOF_Default);
8571 consumer->HandleTranslationUnit(*
m_ast_up);
8575 llvm::StringRef symbol_name) {
8582 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8583 size_t ntypes = type_list.
GetSize();
8585 for (
size_t i = 0; i < ntypes; ++i) {
8588 if (!symbol_name.empty())
8589 if (symbol_name != type->GetName().GetStringRef())
8592 s << type->GetName().AsCString() <<
"\n";
8595 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8603 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8605 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8617 size_t byte_size, uint32_t bitfield_bit_offset,
8618 uint32_t bitfield_bit_size) {
8619 const clang::EnumType *enutype =
8620 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8621 const clang::EnumDecl *enum_decl =
8622 enutype->getOriginalDecl()->getDefinitionOrSelf();
8624 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8625 const uint64_t enum_svalue =
8628 bitfield_bit_offset)
8630 bitfield_bit_offset);
8631 bool can_be_bitfield =
true;
8632 uint64_t covered_bits = 0;
8633 int num_enumerators = 0;
8641 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8642 if (enumerators.empty())
8643 can_be_bitfield =
false;
8645 for (
auto *enumerator : enumerators) {
8646 llvm::APSInt init_val = enumerator->getInitVal();
8647 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8648 : init_val.getZExtValue();
8649 if (qual_type_is_signed)
8650 val = llvm::SignExtend64(val, 8 * byte_size);
8651 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8652 can_be_bitfield =
false;
8653 covered_bits |= val;
8655 if (val == enum_svalue) {
8664 offset = byte_offset;
8666 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8670 if (!can_be_bitfield) {
8671 if (qual_type_is_signed)
8672 s.
Printf(
"%" PRIi64, enum_svalue);
8674 s.
Printf(
"%" PRIu64, enum_uvalue);
8681 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8685 uint64_t remaining_value = enum_uvalue;
8686 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8687 values.reserve(num_enumerators);
8688 for (
auto *enumerator : enum_decl->enumerators())
8689 if (
auto val = enumerator->getInitVal().getZExtValue())
8690 values.emplace_back(val, enumerator->getName());
8695 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8696 return llvm::popcount(a.first) > llvm::popcount(b.first);
8699 for (
const auto &val : values) {
8700 if ((remaining_value & val.first) != val.first)
8702 remaining_value &= ~val.first;
8704 if (remaining_value)
8710 if (remaining_value)
8711 s.
Printf(
"0x%" PRIx64, remaining_value);
8719 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8728 switch (qual_type->getTypeClass()) {
8729 case clang::Type::Typedef: {
8730 clang::QualType typedef_qual_type =
8731 llvm::cast<clang::TypedefType>(qual_type)
8733 ->getUnderlyingType();
8736 format = typedef_clang_type.
GetFormat();
8737 clang::TypeInfo typedef_type_info =
8739 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8749 bitfield_bit_offset,
8754 case clang::Type::Enum:
8759 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8760 bitfield_bit_offset, bitfield_bit_size);
8768 uint32_t item_count = 1;
8808 item_count = byte_size;
8813 item_count = byte_size / 2;
8818 item_count = byte_size / 4;
8824 bitfield_bit_size, bitfield_bit_offset,
8840 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(clang_type)) {
8849 clang::QualType qual_type =
8852 llvm::SmallVector<char, 1024> buf;
8853 llvm::raw_svector_ostream llvm_ostrm(buf);
8855 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8856 switch (type_class) {
8857 case clang::Type::ObjCObject:
8858 case clang::Type::ObjCInterface: {
8861 auto *objc_class_type =
8862 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8863 assert(objc_class_type);
8864 if (!objc_class_type)
8866 clang::ObjCInterfaceDecl *class_interface_decl =
8867 objc_class_type->getInterface();
8868 if (!class_interface_decl)
8871 class_interface_decl->dump(llvm_ostrm);
8873 class_interface_decl->print(llvm_ostrm,
8878 case clang::Type::Typedef: {
8879 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8882 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
8884 typedef_decl->dump(llvm_ostrm);
8887 if (!clang_typedef_name.empty()) {
8894 case clang::Type::Record: {
8897 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
8898 const clang::RecordDecl *record_decl = record_type->getOriginalDecl();
8900 record_decl->dump(llvm_ostrm);
8902 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
8908 if (
auto *tag_type =
8909 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
8910 if (clang::TagDecl *tag_decl = tag_type->getOriginalDecl()) {
8912 tag_decl->dump(llvm_ostrm);
8914 tag_decl->print(llvm_ostrm, 0);
8920 std::string clang_type_name(qual_type.getAsString());
8921 if (!clang_type_name.empty())
8928 if (buf.size() > 0) {
8929 s.
Write(buf.data(), buf.size());
8936 clang::QualType qual_type(
8939 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8940 switch (type_class) {
8941 case clang::Type::Record: {
8942 const clang::CXXRecordDecl *cxx_record_decl =
8943 qual_type->getAsCXXRecordDecl();
8944 if (cxx_record_decl)
8945 printf(
"class %s", cxx_record_decl->getName().str().c_str());
8948 case clang::Type::Enum: {
8949 clang::EnumDecl *enum_decl =
8950 llvm::cast<clang::EnumType>(qual_type)->getOriginalDecl();
8952 printf(
"enum %s", enum_decl->getName().str().c_str());
8956 case clang::Type::ObjCObject:
8957 case clang::Type::ObjCInterface: {
8958 const clang::ObjCObjectType *objc_class_type =
8959 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
8960 if (objc_class_type) {
8961 clang::ObjCInterfaceDecl *class_interface_decl =
8962 objc_class_type->getInterface();
8966 if (class_interface_decl)
8967 printf(
"@class %s", class_interface_decl->getName().str().c_str());
8971 case clang::Type::Typedef:
8972 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
8979 case clang::Type::Auto:
8982 llvm::cast<clang::AutoType>(qual_type)
8984 .getAsOpaquePtr()));
8986 case clang::Type::Paren:
8990 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
8993 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
9003 if (template_param_infos.
IsValid()) {
9004 std::string template_basename(parent_name);
9006 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
9007 template_basename.erase(i);
9010 template_basename.c_str(), tag_decl_kind,
9011 template_param_infos);
9026 clang::ObjCInterfaceDecl *decl) {
9054 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9055 uint64_t &alignment,
9056 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9057 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9059 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9072 field_offsets, base_offsets, vbase_offsets);
9079 clang::NamedDecl *nd =
9080 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9090 if (!label_or_err) {
9091 llvm::consumeError(label_or_err.takeError());
9095 llvm::StringRef mangled = label_or_err->lookup_name;
9103 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9104 static_cast<clang::Decl *
>(opaque_decl));
9106 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9110 if (!mc || !mc->shouldMangleCXXName(nd))
9115 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9120 llvm::SmallVector<char, 1024> buf;
9121 llvm::raw_svector_ostream llvm_ostrm(buf);
9122 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9124 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9127 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9129 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9133 mc->mangleName(nd, llvm_ostrm);
9149 if (clang::FunctionDecl *func_decl =
9150 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9151 return GetType(func_decl->getReturnType());
9152 if (clang::ObjCMethodDecl *objc_method =
9153 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9154 return GetType(objc_method->getReturnType());
9160 if (clang::FunctionDecl *func_decl =
9161 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9162 return func_decl->param_size();
9163 if (clang::ObjCMethodDecl *objc_method =
9164 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9165 return objc_method->param_size();
9171 clang::DeclContext
const *decl_ctx) {
9172 switch (clang_kind) {
9173 case Decl::TranslationUnit:
9175 case Decl::Namespace:
9186 if (decl_ctx->isFunctionOrMethod())
9188 if (decl_ctx->isRecord())
9198 std::vector<lldb_private::CompilerContext> &context) {
9199 if (decl_ctx ==
nullptr)
9202 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9203 if (clang_kind == Decl::TranslationUnit)
9208 context.push_back({compiler_kind, decl_ctx_name});
9211std::vector<lldb_private::CompilerContext>
9213 std::vector<lldb_private::CompilerContext> context;
9216 clang::Decl *decl = (clang::Decl *)opaque_decl;
9218 clang::DeclContext *decl_ctx = decl->getDeclContext();
9221 auto compiler_kind =
9223 context.push_back({compiler_kind, decl_name});
9230 if (clang::FunctionDecl *func_decl =
9231 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9232 if (idx < func_decl->param_size()) {
9233 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9235 return GetType(var_decl->getOriginalType());
9237 }
else if (clang::ObjCMethodDecl *objc_method =
9238 llvm::dyn_cast<clang::ObjCMethodDecl>(
9239 (clang::Decl *)opaque_decl)) {
9240 if (idx < objc_method->param_size())
9241 return GetType(objc_method->parameters()[idx]->getOriginalType());
9247 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9248 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9251 clang::Expr *init_expr = var_decl->getInit();
9254 std::optional<llvm::APSInt> value =
9264 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9265 std::vector<CompilerDecl> found_decls;
9267 if (opaque_decl_ctx && symbol_file) {
9268 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9269 std::set<DeclContext *> searched;
9270 std::multimap<DeclContext *, DeclContext *> search_queue;
9272 for (clang::DeclContext *decl_context = root_decl_ctx;
9273 decl_context !=
nullptr && found_decls.empty();
9274 decl_context = decl_context->getParent()) {
9275 search_queue.insert(std::make_pair(decl_context, decl_context));
9277 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9279 if (!searched.insert(it->second).second)
9284 for (clang::Decl *child : it->second->decls()) {
9285 if (clang::UsingDirectiveDecl *ud =
9286 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9287 if (ignore_using_decls)
9289 clang::DeclContext *from = ud->getCommonAncestor();
9290 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9291 search_queue.insert(
9292 std::make_pair(from, ud->getNominatedNamespace()));
9293 }
else if (clang::UsingDecl *ud =
9294 llvm::dyn_cast<clang::UsingDecl>(child)) {
9295 if (ignore_using_decls)
9297 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9298 clang::Decl *target = usd->getTargetDecl();
9299 if (clang::NamedDecl *nd =
9300 llvm::dyn_cast<clang::NamedDecl>(target)) {
9301 IdentifierInfo *ii = nd->getIdentifier();
9302 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9306 }
else if (clang::NamedDecl *nd =
9307 llvm::dyn_cast<clang::NamedDecl>(child)) {
9308 IdentifierInfo *ii = nd->getIdentifier();
9309 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9360 clang::DeclContext *child_decl_ctx,
9364 if (frame_decl_ctx && symbol_file) {
9365 std::set<DeclContext *> searched;
9366 std::multimap<DeclContext *, DeclContext *> search_queue;
9369 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9373 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9374 decl_ctx = decl_ctx->getParent()) {
9375 if (!decl_ctx->isLookupContext())
9377 if (decl_ctx == parent_decl_ctx)
9380 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9381 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9383 if (searched.find(it->second) != searched.end())
9391 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9394 searched.insert(it->second);
9398 for (clang::Decl *child : it->second->decls()) {
9399 if (clang::UsingDirectiveDecl *ud =
9400 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9401 clang::DeclContext *ns = ud->getNominatedNamespace();
9402 if (ns == parent_decl_ctx)
9405 clang::DeclContext *from = ud->getCommonAncestor();
9406 if (searched.find(ns) == searched.end())
9407 search_queue.insert(std::make_pair(from, ns));
9408 }
else if (child_name) {
9409 if (clang::UsingDecl *ud =
9410 llvm::dyn_cast<clang::UsingDecl>(child)) {
9411 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9412 clang::Decl *target = usd->getTargetDecl();
9413 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9417 IdentifierInfo *ii = nd->getIdentifier();
9418 if (ii ==
nullptr ||
9419 ii->getName() != child_name->
AsCString(
nullptr))
9442 if (opaque_decl_ctx) {
9443 clang::NamedDecl *named_decl =
9444 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9447 llvm::raw_string_ostream stream{name};
9449 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9450 named_decl->getNameForDiagnostic(stream, policy,
false);
9459 if (opaque_decl_ctx) {
9460 clang::NamedDecl *named_decl =
9461 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9469 if (!opaque_decl_ctx)
9472 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9473 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9475 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9477 }
else if (clang::FunctionDecl *fun_decl =
9478 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9479 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9480 return metadata->HasObjectPtr();
9486std::vector<lldb_private::CompilerContext>
9488 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9489 std::vector<lldb_private::CompilerContext> context;
9495 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9496 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9497 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9501 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9502 if (DC->isInlineNamespace())
9505 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9506 return NS->isAnonymousNamespace();
9513 if (decl_ctx == other)
9515 }
while (is_transparent_lookup_allowed(other) &&
9516 (other = other->getParent()));
9523 if (!opaque_decl_ctx)
9526 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9527 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9529 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9531 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9532 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9533 return metadata->GetObjectPtrLanguage();
9553 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9561 return llvm::dyn_cast<clang::CXXMethodDecl>(
9566clang::FunctionDecl *
9569 return llvm::dyn_cast<clang::FunctionDecl>(
9574clang::NamespaceDecl *
9577 return llvm::dyn_cast<clang::NamespaceDecl>(
9582std::optional<ClangASTMetadata>
9584 const Decl *
object) {
9592 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9614 lldbassert(started &&
"Unable to start a class type definition.");
9619 ts->SetDeclIsForcefullyCompleted(td);
9633 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9634 std::unique_ptr<ClangASTSource> ast_source)
9636 m_scratch_ast_source_up(std::move(ast_source)) {
9638 m_scratch_ast_source_up->InstallASTContext(*
this);
9639 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9640 m_scratch_ast_source_up->CreateProxy();
9641 SetExternalSource(proxy_ast_source);
9645 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9653 llvm::Triple triple)
9660 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9672 std::optional<IsolatedASTKind> ast_kind,
9673 bool create_on_demand) {
9676 if (
auto err = type_system_or_err.takeError()) {
9678 "Couldn't get scratch TypeSystemClang: {0}");
9681 auto ts_sp = *type_system_or_err;
9683 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9688 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9690 return std::static_pointer_cast<TypeSystemClang>(
9695static llvm::StringRef
9699 return "C++ modules";
9701 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9705 llvm::StringRef filter,
bool show_color) {
9707 output <<
"State of scratch Clang type system:\n";
9711 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9712 std::vector<KeyAndTS> sorted_typesystems;
9714 sorted_typesystems.emplace_back(a.first, a.second.get());
9715 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9718 for (
const auto &a : sorted_typesystems) {
9721 output <<
"State of scratch Clang type subsystem "
9723 a.second->Dump(output, filter, show_color);
9728 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9736 desired_type, options, ctx_obj);
9741 const ValueList &arg_value_list,
const char *name) {
9746 Process *process = target_sp->GetProcessSP().get();
9751 arg_value_list, name);
9754std::unique_ptr<UtilityFunction>
9761 return std::make_unique<ClangUtilityFunction>(
9762 *target_sp.get(), std::move(text), std::move(name),
9763 target_sp->GetDebugUtilityExpression());
9777 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9781 return std::make_unique<ClangASTSource>(
9786static llvm::StringRef
9790 return "scratch ASTContext for C++ module types";
9792 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9799 return *found_ast->second;
9802 std::shared_ptr<TypeSystemClang> new_ast_sp =
9812 const clang::RecordType *record_type =
9813 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9815 const clang::RecordDecl *record_decl =
9816 record_type->getOriginalDecl()->getDefinitionOrSelf();
9817 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9818 return metadata->IsForcefullyCompleted();
9827 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9831 metadata->SetIsForcefullyCompleted();
9839 LLDB_LOG(log,
"Created new TypeSystem for (ASTContext*){0:x} '{1}'",
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
static bool DumpEnumValue(const clang::QualType &qual_type, Stream &s, const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_offset, uint32_t bitfield_bit_size)
static lldb::opaque_compiler_type_t GetObjCFieldAtIndex(clang::ASTContext *ast, clang::ObjCInterfaceDecl *class_interface_decl, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr)
static void ParseLangArgs(LangOptions &Opts, ArchSpec arch)
static clang::QualType GetFullyUnqualifiedType_Impl(clang::ASTContext *ast, clang::QualType qual_type)
const TemplateArgument * GetNthTemplateArgument(const clang::ClassTemplateSpecializationDecl *decl, size_t idx, bool expand_pack)
static int64_t ReadVBaseOffsetFromVTable(Process &process, VTableContextBase &vtable_ctx, lldb::addr_t vtable_ptr, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl)
static const clang::RecordType * GetCompleteRecordType(clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion)
Returns the clang::RecordType of the specified qual_type.
lldb_private::ThreadSafeDenseMap< clang::ASTContext *, TypeSystemClang * > ClangASTMap
static bool IsClangDeclContext(const CompilerDeclContext &dc)
static bool TemplateParameterAllowsValue(NamedDecl *param, const TemplateArgument &value)
Returns true if the given template parameter can represent the given value.
static CompilerContextKind GetCompilerKind(clang::Decl::Kind clang_kind, clang::DeclContext const *decl_ctx)
static QualType RemoveWrappingTypes(QualType type, ArrayRef< clang::Type::TypeClass > mask={})
Aggressively desugar the provided type, skipping past various kinds of syntactic sugar and other cons...
static TemplateParameterList * CreateTemplateParameterList(ASTContext &ast, const TypeSystemClang::TemplateParameterInfos &template_param_infos, llvm::SmallVector< NamedDecl *, 8 > &template_param_decls)
clang::DeclContext * FindLCABetweenDecls(clang::DeclContext *left, clang::DeclContext *right, clang::DeclContext *root)
static bool check_op_param(bool is_method, clang::OverloadedOperatorKind op_kind, bool unary, bool binary, uint32_t num_params)
static llvm::StringRef GetSpecializedASTName(ScratchTypeSystemClang::IsolatedASTKind feature)
static bool ObjCDeclHasIVars(clang::ObjCInterfaceDecl *class_interface_decl)
static const clang::ObjCObjectType * GetCompleteObjCObjectType(clang::ASTContext *ast, QualType qual_type, bool allow_completion)
Returns the clang::ObjCObjectType of the specified qual_type.
static lldb::addr_t GetVTableAddress(Process &process, VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout)
static clang::ObjCIvarDecl::AccessControl ConvertAccessTypeToObjCIvarAccessControl(AccessType access)
static std::optional< SymbolFile::ArrayInfo > GetDynamicArrayInfo(TypeSystemClang &ast, SymbolFile *sym_file, clang::QualType qual_type, const ExecutionContext *exe_ctx)
static ConstString ExtractMangledNameFromFunctionCallLabel(llvm::StringRef label)
static llvm::StringRef GetNameForIsolatedASTKind(ScratchTypeSystemClang::IsolatedASTKind kind)
Returns a human-readable name that uniquely identifiers the sub-AST kind.
static void InsertCompilerContext(TypeSystemClang *ts, clang::DeclContext *decl_ctx, std::vector< lldb_private::CompilerContext > &context)
static bool GetVBaseBitOffset(VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl, int32_t &bit_offset)
static const clang::EnumType * GetCompleteEnumType(clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion)
Returns the clang::EnumType of the specified qual_type.
static bool QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext &ast, QualType qual_type)
static ClangASTMap & GetASTMap()
static bool GetCompleteQualType(clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion=true)
static void SetMemberOwningModule(clang::Decl *member, const clang::Decl *parent)
static bool ClassTemplateAllowsToInstantiationArgs(ClassTemplateDecl *class_template_decl, const TypeSystemClang::TemplateParameterInfos &instantiation_values)
Returns true if the given class template declaration could produce an instantiation with the specifie...
#define LLDB_INVALID_DECL_LEVEL
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &info) override
DiagnosticConsumer * clone(DiagnosticsEngine &Diags) const
A section + offset based address class.
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool CharIsSignedByDefault() const
Returns true if 'char' is a signed type by default in the architecture false otherwise.
Manages and observes all Clang AST node importing in LLDB.
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &bit_size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets)
void ForgetSource(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx)
"lldb/Expression/ClangFunctionCaller.h" Encapsulates a function that can be called.
"lldb/Expression/ClangPersistentVariables.h" Manages persistent values that need to be preserved betw...
"lldb/Expression/ClangUserExpression.h" Encapsulates a single expression for use with Clang
Represents a generic declaration context in a program.
TypeSystem * GetTypeSystem() const
void * GetOpaqueDeclContext() const
Represents a generic declaration such as a function declaration.
lldb::TypeSystemSP GetSharedPointer() const
Generic representation of a type in a programming language.
lldb::LanguageType GetMinimumLanguage()
bool IsEnumerationType(bool &is_signed) const
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
void SetCompilerType(lldb::TypeSystemWP type_system, lldb::opaque_compiler_type_t type)
lldb::Encoding GetEncoding(uint64_t &count) const
size_t GetIndexOfChildMemberWithName(llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) const
Lookup a child member given a name.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
LLVM_DUMP_METHOD void dump() const
Dumping types.
uint32_t GetNumDirectBaseClasses() const
ConstString GetTypeName(bool BaseOnly=false) const
bool IsEnumerationIntegerTypeSigned() const
bool DumpTypeValue(Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope)
bool IsAggregateType() const
lldb::Format GetFormat() const
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const
CompilerType GetDirectBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
bool GetCompleteType() const
Type Completion.
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
llvm::Expected< uint32_t > GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const
Lookup a child given a name.
llvm::Expected< uint32_t > GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const char * GetCString() const
Get the string value as a C string.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
A class that describes the declaration location of a lldb object.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
Process * GetProcessPtr() const
Returns a pointer to the process object.
static FileSystem & Instance()
bool Test(ValueType bit) const
Test a single flag bit.
bool AnySet(ValueType mask) const
Test one or more flags.
Encapsulates a function that can be called.
static bool LanguageIsC(lldb::LanguageType language)
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
static bool LanguageIsPascal(lldb::LanguageType language)
static bool LanguageIsObjC(lldb::LanguageType language)
static bool IsMangledName(llvm::StringRef name)
A class that describes an executable image and its associated object and symbol files.
virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type, const char *ivar_name)
static ObjCLanguageRuntime * Get(Process &process)
unsigned GetValue() const
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Status &error)
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
uint32_t GetAddressByteSize() const
void Finalize() override
Free up any resources associated with this TypeSystem.
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
llvm::Triple m_triple
The target triple.
std::unique_ptr< ClangASTSource > CreateASTSource()
lldb::TargetWP m_target_wp
TypeSystemClang & GetIsolatedAST(IsolatedASTKind feature)
Returns the requested sub-AST.
UserExpression * GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language, Expression::ResultType desired_type, const EvaluateExpressionOptions &options, ValueObject *ctx_obj) override
std::unique_ptr< ClangASTSource > m_scratch_ast_source_up
The ExternalASTSource that performs lookups and completes minimally imported types.
IsolatedASTKind
The different kinds of isolated ASTs within the scratch TypeSystem.
@ CppModules
The isolated AST for declarations/types from expressions that imported type information from a C++ mo...
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< ClangPersistentVariables > m_persistent_variables
The persistent variables associated with this process for the expression parser.
static char ID
LLVM RTTI support.
PersistentExpressionState * GetPersistentExpressionState() override
FunctionCaller * GetFunctionCaller(const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, const char *name) override
std::unique_ptr< UtilityFunction > CreateUtilityFunction(std::string text, std::string name) override
void ForgetSource(clang::ASTContext *src_ctx, ClangASTImporter &importer)
Unregisters the given ASTContext as a source from the scratch AST (and all sub-ASTs).
static const std::nullopt_t DefaultAST
Alias for requesting the default scratch TypeSystemClang in GetForTarget.
ScratchTypeSystemClang(Target &target, llvm::Triple triple)
llvm::DenseMap< IsolatedASTKey, std::shared_ptr< TypeSystemClang > > m_isolated_asts
Map from IsolatedASTKind to their actual TypeSystemClang instance.
bool Fail() const
Test for error condition.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
unsigned GetIndentLevel() const
Get the current indentation level.
Provides public interface for all SymbolFiles.
virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx)
virtual bool CompleteType(CompilerType &compiler_type)=0
virtual void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list)=0
virtual std::optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx)=0
If type_uid points to an array type, return its characteristics.
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
const ArchSpec & GetArchitecture() const
void Insert(_KeyType k, _ValueType v)
_ValueType Lookup(_KeyType k)
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
The implementation of lldb::Type's m_payload field for TypeSystemClang.
void SetIsCompleteObjCClass(bool is_complete_objc_class)
bool IsCompleteObjCClass()
Type::Payload m_payload
The payload is used for typedefs and ptrauth types.
TypePayloadClang()=default
void SetOwningModule(OptionalClangModuleID id)
static constexpr unsigned ObjCClassBit
llvm::ArrayRef< clang::TemplateArgument > GetParameterPackArgs() const
clang::TemplateArgument const & Front() const
llvm::StringRef GetPackName() const
bool hasParameterPack() const
TemplateParameterInfos const & GetParameterPack() const
llvm::ArrayRef< const char * > GetNames() const
llvm::ArrayRef< clang::TemplateArgument > GetArgs() const
A TypeSystem implementation based on Clang.
bool IsMemberFunctionPointerType(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeForIdentifier(const clang::ASTContext &Ctx, llvm::StringRef type_name, clang::DeclContext *decl_context=nullptr)
llvm::Expected< uint64_t > GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
CompilerType CreateFunctionType(const CompilerType &result_type, llvm::ArrayRef< CompilerType > args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
size_t GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) override
static clang::TypedefNameDecl * GetAsTypedefDecl(const CompilerType &type)
std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl, bool qualified=true)
Returns the internal type name for the given NamedDecl using the type printing policy.
static clang::ObjCInterfaceDecl * GetAsObjCInterfaceDecl(const CompilerType &type)
uint32_t m_pointer_byte_size
bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream &s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override
std::string m_display_name
A string describing what this TypeSystemClang represents (e.g., AST for debug information,...
ConstString GetTypeName(lldb::opaque_compiler_type_t type, bool base_only) override
static void SetOwningModule(clang::Decl *decl, OptionalClangModuleID owning_module)
Set the owning module for decl.
llvm::Expected< uint64_t > GetObjCBitSize(clang::QualType qual_type, ExecutionContextScope *exe_scope)
std::unique_ptr< clang::TargetInfo > m_target_info_up
std::unique_ptr< clang::LangOptions > m_language_options_up
Scalar DeclGetConstantValue(void *opaque_decl) override
llvm::Expected< CompilerType > GetDereferencedType(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, std::string &deref_name, uint32_t &deref_byte_size, int32_t &deref_byte_offset, ValueObject *valobj, uint64_t &language_flags) override
bool BaseSpecifierIsEmpty(const clang::CXXBaseSpecifier *b)
static uint32_t GetNumPointeeChildren(clang::QualType type)
ConstString DeclGetMangledName(void *opaque_decl) override
CompilerType GetBasicType(lldb::BasicType type)
clang::ClassTemplateDecl * CreateClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef class_name, int kind, const TemplateParameterInfos &infos)
std::unique_ptr< clang::HeaderSearchOptions > m_header_search_opts_up
clang::UsingDecl * CreateUsingDeclaration(clang::DeclContext *current_decl_ctx, OptionalClangModuleID owning_module, clang::NamedDecl *target)
static clang::AccessSpecifier ConvertAccessTypeToAccessSpecifier(lldb::AccessType access)
CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override
bool IsForcefullyCompleted(lldb::opaque_compiler_type_t type) override
bool SupportsLanguage(lldb::LanguageType language) override
uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override
OptionalClangModuleID GetOrCreateClangModule(llvm::StringRef name, OptionalClangModuleID parent, bool is_framework=false, bool is_explicit=false)
Synthesize a clang::Module and return its ID or a default-constructed ID.
void CompleteTagDecl(clang::TagDecl *)
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size)
std::shared_ptr< clang::TargetOptions > & getTargetOptions()
static TypeSystemClang * GetASTContext(clang::ASTContext *ast_ctx)
bool IsReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool *is_rvalue) override
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
const char * GetTargetTriple()
TypeSystemClang(llvm::StringRef name, llvm::Triple triple)
Constructs a TypeSystemClang with an ASTContext using the given triple.
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, Module *module, Target *target)
clang::TargetInfo * getTargetInfo()
clang::FunctionTemplateDecl * CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::FunctionDecl *func_decl, const TemplateParameterInfos &infos)
CompilerType CreateArrayType(const CompilerType &element_type, std::optional< size_t > element_count, bool is_vector)
static bool AreTypesSame(CompilerType type1, CompilerType type2, bool ignore_qualifiers=false)
CompilerType GetArrayType(lldb::opaque_compiler_type_t type, uint64_t size) override
bool IsFunctionType(lldb::opaque_compiler_type_t type) override
CompilerType GetFunctionReturnType(lldb::opaque_compiler_type_t type) override
std::optional< ClangASTMetadata > GetMetadata(const clang::Decl *object)
CompilerType GetLValueReferenceType(lldb::opaque_compiler_type_t type) override
bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td)
lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override
bool CanPassInRegisters(const CompilerType &type) override
CompilerDecl GetStaticFieldWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, bool &is_complex) override
bool IsEnumerationType(lldb::opaque_compiler_type_t type, bool &is_signed) override
bool IsTemplateType(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
static bool IsCXXClassType(const CompilerType &type)
bool IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed) override
void SetCXXRecordDeclAccess(const clang::CXXRecordDecl *object, clang::AccessSpecifier access)
uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override
static bool IsOperator(llvm::StringRef name, clang::OverloadedOperatorKind &op_kind)
bool IsCharType(lldb::opaque_compiler_type_t type) override
CompilerType CreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
static void SetFloatingInitializerForVariable(clang::VarDecl *var, const llvm::APFloat &init_value)
Initializes a variable with a floating point value.
uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) override
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) override
CompilerType GetType(clang::QualType qt)
Creates a CompilerType from the given QualType with the current TypeSystemClang instance as the Compi...
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override
std::string m_target_triple
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > bases)
bool IsBeingDefined(lldb::opaque_compiler_type_t type) override
ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override
std::unique_ptr< clang::IdentifierTable > m_identifier_table_up
static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name)
static void SetIntegerInitializerForVariable(clang::VarDecl *var, const llvm::APInt &init_value)
Initializes a variable with an integer value.
bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override
CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets)
bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::SourceManager > m_source_manager_up
bool IsVoidType(lldb::opaque_compiler_type_t type) override
static void SetIsPacked(const CompilerType &type)
void ForEachEnumerator(lldb::opaque_compiler_type_t type, std::function< bool(const CompilerType &integer_type, ConstString name, const llvm::APSInt &value)> const &callback) override
clang::AccessSpecifier GetCXXRecordDeclAccess(const clang::CXXRecordDecl *object)
CompilerType CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *class_template_specialization_decl)
bool IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
std::unique_ptr< clang::DiagnosticOptions > m_diagnostic_options_up
void CreateFunctionTemplateSpecializationInfo(clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template, const TemplateParameterInfos &infos)
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, uint64_t enum_value, uint32_t enum_value_bit_size)
llvm::StringRef getDisplayName() const
Returns the display name of this TypeSystemClang that indicates what purpose it serves in LLDB.
bool IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length)
CompilerType GetRValueReferenceType(lldb::opaque_compiler_type_t type) override
CompilerDecl GetCompilerDecl(clang::Decl *decl)
Creates a CompilerDecl from the given Decl with the current TypeSystemClang instance as its typesyste...
unsigned GetPtrAuthDiscriminator(lldb::opaque_compiler_type_t type) override
CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override
bool GetCompleteType(lldb::opaque_compiler_type_t type) override
bool IsBlockPointerType(lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) override
bool IsConst(lldb::opaque_compiler_type_t type) override
static clang::AccessSpecifier UnifyAccessSpecifiers(clang::AccessSpecifier lhs, clang::AccessSpecifier rhs)
std::unique_ptr< clang::CXXBaseSpecifier > CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class)
CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override
std::vector< CompilerDecl > DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_using_decls) override
const llvm::fltSemantics & GetFloatTypeSemantics(size_t byte_size, lldb::Format format) override
llvm::Expected< uint32_t > GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes) override
void setSema(clang::Sema *s)
uint32_t GetPointerByteSize() override
bool IsCompleteType(lldb::opaque_compiler_type_t type) override
CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed)
clang::MangleContext * getMangleContext()
void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *)
unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override
static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx)
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
CompilerType GetTypeForFormatters(void *type) override
void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id)
bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override
This is used by swift.
static LanguageSet GetSupportedLanguagesForExpressions()
clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, const CompilerType &function_Type, clang::StorageClass storage, bool is_inline, llvm::StringRef asm_label)
CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override
CompilerDeclContext GetCompilerDeclContextForType(const CompilerType &type) override
Returns the direct parent context of specified type.
std::unique_ptr< clang::SelectorTable > m_selector_table_up
PDBASTParser * GetPDBParser() override
std::optional< CompilerType::IntegralTemplateArgument > GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
bool DeclContextIsClassMethod(void *opaque_decl_ctx) override
void SetTargetTriple(llvm::StringRef target_triple)
CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
static bool CheckOverloadedOperatorKindParameterCount(bool is_method, clang::OverloadedOperatorKind op_kind, uint32_t num_params)
clang::DeclarationName GetDeclarationName(llvm::StringRef name, const CompilerType &function_clang_type)
DeclMetadataMap m_decl_metadata
Maps Decls to their associated ClangASTMetadata.
static clang::CXXMethodDecl * DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc)
CompilerType GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override
uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx, clang::DeclContext *child_decl_ctx, ConstString *child_name=nullptr, CompilerType *child_type=nullptr)
static clang::QualType GetQualType(lldb::opaque_compiler_type_t type)
clang::PrintingPolicy GetTypePrintingPolicy()
Returns the PrintingPolicy used when generating the internal type names.
uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override
static clang::RecordDecl * GetAsRecordDecl(const CompilerType &type)
CompilerType GetPointerSizedIntType(bool is_signed)
uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl, bool omit_empty_base_classes)
lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) override
std::unique_ptr< DWARFASTParserClang > m_dwarf_ast_parser_up
CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size)
bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override
int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override
static void BuildIndirectFields(const CompilerType &type)
std::unique_ptr< clang::FileManager > m_file_manager_up
uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl, const clang::CXXBaseSpecifier *base_spec, bool omit_empty_base_classes)
bool IsAnonymousType(lldb::opaque_compiler_type_t type) override
bool Verify(lldb::opaque_compiler_type_t type) override
Verify the integrity of the type to catch CompilerTypes that mix and match invalid TypeSystem/Opaque ...
size_t GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override
void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type)
CompilerType CreateBlockPointerType(const CompilerType &function_type)
lldb::LanguageType GetMinimumLanguage(lldb::opaque_compiler_type_t type) override
bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size)
clang::ClassTemplateSpecializationDecl * CreateClassTemplateSpecializationDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::ClassTemplateDecl *class_template_decl, int kind, const TemplateParameterInfos &infos)
llvm::SmallVector< clang::ParmVarDecl * > CreateParameterDeclarations(clang::FunctionDecl *context, const clang::FunctionProtoType &prototype, const llvm::SmallVector< llvm::StringRef > ¶m_names)
For each parameter type of prototype, creates a clang::ParmVarDecl whose clang::DeclContext is contex...
std::unique_ptr< clang::HeaderSearch > m_header_search_up
void Finalize() override
Free up any resources associated with this TypeSystem.
static clang::ASTContext * DeclContextGetTypeSystemClang(const CompilerDeclContext &dc)
uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, CompilerType *base_type_ptr) override
LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override
Convenience LLVM-style dump method for use in the debugger only.
CXXRecordDeclAccessMap m_cxx_record_decl_access
Maps CXXRecordDecl to their most recent added method/field's AccessSpecifier.
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
std::unique_ptr< clang::ASTContext > m_ast_up
CompilerType CreateGenericFunctionPrototype() override
static clang::QualType GetCanonicalQualType(lldb::opaque_compiler_type_t type)
CompilerType DeclGetFunctionReturnType(void *opaque_decl) override
static bool IsEnumType(lldb::opaque_compiler_type_t type)
std::unique_ptr< npdb::PdbAstBuilder > m_native_pdb_ast_parser_up
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
CompilerType GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static bool SetObjCSuperClass(const CompilerType &type, const CompilerType &superclass_compiler_type)
clang::UsingDirectiveDecl * CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::NamespaceDecl *ns_decl)
static lldb::opaque_compiler_type_t GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type)
bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override
void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name)
Dump clang AST types from the symbol file.
CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override
static void DumpDeclHiearchy(clang::Decl *decl)
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
static clang::FunctionDecl * DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc)
bool IsScalarType(lldb::opaque_compiler_type_t type) override
bool GetPtrAuthAddressDiversity(lldb::opaque_compiler_type_t type) override
std::shared_ptr< clang::TargetOptions > m_target_options_rp
lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override
static bool IsClassType(lldb::opaque_compiler_type_t type)
bool IsDefined(lldb::opaque_compiler_type_t type) override
static bool IsObjCClassType(const CompilerType &type)
TypeMetadataMap m_type_metadata
Maps Types to their associated ClangASTMetadata.
CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override
bool RecordHasFields(const clang::RecordDecl *record_decl)
CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index) override
static std::optional< ClangASTMetadata > DeclContextGetMetaData(const CompilerDeclContext &dc, const clang::Decl *object)
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override
static clang::ObjCMethodDecl * AddMethodToObjCObjectType(const CompilerType &type, const char *name, const CompilerType &method_compiler_type, bool is_artificial, bool is_variadic, bool is_objc_direct_call)
~TypeSystemClang() override
CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, std::optional< ClangASTMetadata > metadata=std::nullopt, bool exports_symbols=false)
bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, void *other_opaque_decl_ctx) override
CompilerType AddPtrAuthModifier(lldb::opaque_compiler_type_t type, uint32_t payload) override
static bool AddObjCClassProperty(const CompilerType &type, const char *property_name, const CompilerType &property_compiler_type, clang::ObjCIvarDecl *ivar_decl, const char *property_setter_name, const char *property_getter_name, uint32_t property_attributes, ClangASTMetadata metadata)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
void SetMetadata(const clang::Decl *object, ClangASTMetadata meta_data)
clang::ParmVarDecl * CreateParameterDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType ¶m_type, int storage, bool add_decl=false)
void DumpTypeDescription(lldb::opaque_compiler_type_t type, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) override
Dump the type to stdout.
CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
static clang::NamespaceDecl * DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped, std::optional< clang::EnumExtensibilityAttr::Kind > enum_kind=std::nullopt)
npdb::PdbAstBuilder * GetNativePDBParser() override
std::unique_ptr< clang::DiagnosticConsumer > m_diagnostic_consumer_up
CompilerType CreateObjCClass(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool isInternal, std::optional< ClangASTMetadata > metadata=std::nullopt)
CompilerType GetTypeForDecl(clang::NamedDecl *decl)
CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc)
lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, uint64_t &count) override
bool IsTypedefType(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override
std::optional< size_t > GetTypeBitAlign(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< clang::Builtin::Context > m_builtins_up
CompilerType GetBuiltinTypeByName(ConstString name) override
bool GetCompleteDecl(clang::Decl *decl)
static bool StartTagDeclarationDefinition(const CompilerType &type)
uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl, bool omit_empty_base_classes)
bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, CompilerType *target_type, bool check_cplusplus, bool check_objc) override
CompilerType GetOrCreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
void LogCreation() const
Emits information about this TypeSystem into the expression log.
static llvm::StringRef GetPluginNameStatic()
clang::Sema * m_sema
The sema associated that is currently used to build this ASTContext.
size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override
static clang::VarDecl * AddVariableToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &var_type, lldb::AccessType access)
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override
const clang::ClassTemplateSpecializationDecl * GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type)
std::unique_ptr< clang::MangleContext > m_mangle_ctx_up
TypeMemberFunctionImpl GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
bool IsTypeImpl(lldb::opaque_compiler_type_t type, llvm::function_ref< bool(clang::QualType)> predicate) const
size_t DeclGetFunctionNumArguments(void *opaque_decl) override
CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< PDBASTParser > m_pdb_ast_parser_up
std::unique_ptr< clang::DiagnosticsEngine > m_diagnostics_engine_up
static std::optional< std::string > GetCXXClassName(const CompilerType &type)
static void DumpTypeName(const CompilerType &type)
plugin::dwarf::DWARFASTParser * GetDWARFParser() override
CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx) override
bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
static clang::EnumDecl * GetAsEnumDecl(const CompilerType &type)
CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::ModuleMap > m_module_map_up
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, llvm::StringRef asm_label, const CompilerType &method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
static bool IsObjCObjectOrInterfaceType(const CompilerType &type)
static void RequireCompleteType(CompilerType type)
Complete a type from debug info, or mark it as forcefully completed if there is no definition of the ...
CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload) override
Using the current type, create a new typedef to that type using "typedef_name" as the name and "decl_...
llvm::Expected< uint32_t > GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes, const ExecutionContext *exe_ctx) override
CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override
clang::TemplateTemplateParmDecl * CreateTemplateTemplateParmDecl(const char *template_name)
lldb::TemplateArgumentKind GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
clang::ClassTemplateDecl * ParseClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, const char *parent_name, int tag_decl_kind, const TypeSystemClang::TemplateParameterInfos &template_param_infos)
clang::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
std::vector< lldb_private::CompilerContext > DeclGetCompilerContext(void *opaque_decl) override
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
std::vector< lldb_private::CompilerContext > DeclContextGetCompilerContext(void *opaque_decl_ctx) override
void CreateASTContext()
Creates the internal ASTContext.
void SetExternalSource(llvm::IntrusiveRefCntPtr< clang::ExternalASTSource > ast_source_sp)
CompilerType GetCStringType(bool is_const)
bool IsAggregateType(lldb::opaque_compiler_type_t type) override
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override
static LanguageSet GetSupportedLanguagesForTypes()
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
llvm::Expected< uint64_t > GetByteSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope)
ConstString DeclContextGetName(void *opaque_decl_ctx) override
size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack) override
ConstString DeclGetName(void *opaque_decl) override
virtual SymbolFile * GetSymbolFile() const
bool m_has_forcefully_completed_types
Used for reporting statistics.
Encapsulates a one-time expression for use in lldb.
virtual uint64_t GetData(DataExtractor &data, Status &error)
CompilerType GetCompilerType()
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
AddressType GetAddressTypeOfChildren()
ConstString GetName() const
const ExecutionContextRef & GetExecutionContextRef() const
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_IVAR_OFFSET
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, uint32_t item_bit_size, uint32_t item_bit_offset, ExecutionContextScope *exe_scope=nullptr, bool show_memory_tags=false)
Dumps item_count objects into the stream s.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
void * opaque_compiler_type_t
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eBasicTypeUnsignedShort
@ eBasicTypeUnsignedInt128
@ eBasicTypeUnsignedWChar
@ eBasicTypeLongDoubleComplex
@ eBasicTypeUnsignedLongLong
@ eBasicTypeDoubleComplex
Format
Display format definitions.
@ eFormatCString
NULL terminated C strings.
@ eFormatCharArray
Print characters with no single quotes, used for character arrays that can contain non printable char...
@ eFormatVoid
Do not print this.
@ eFormatComplex
Floating point complex type.
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
@ eFormatComplexInteger
Integer complex type.
@ eFormatFloat128
Disambiguate between 128-bit long double (which uses eFormatFloat) and __float128 (which uses eFormat...
LanguageType
Programming language type.
@ eLanguageTypeC_plus_plus_20
ISO C++:2020.
@ eLanguageTypeC_plus_plus_14
ISO C++:2014.
@ eLanguageTypeC11
ISO C:2011.
@ eLanguageTypeC99
ISO C:1999.
@ eLanguageTypeC_plus_plus_03
ISO C++:2003.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeC_plus_plus_17
ISO C++:2017.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
@ eLanguageTypeC_plus_plus_11
ISO C++:2011.
@ eLanguageTypeC89
ISO C:1989.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
@ eLanguageTypeDylan
Dylan.
std::shared_ptr< lldb_private::Type > TypeSP
@ eTemplateArgumentKindTemplate
@ eTemplateArgumentKindTemplateExpansion
@ eTemplateArgumentKindNull
@ eTemplateArgumentKindNullPtr
@ eTemplateArgumentKindDeclaration
@ eTemplateArgumentKindIntegral
@ eTemplateArgumentKindPack
@ eTemplateArgumentKindType
@ eTemplateArgumentKindStructuralValue
@ eTemplateArgumentKindExpression
Encoding
Register encoding definitions.
@ eEncodingVector
vector registers
@ eEncodingUint
unsigned integer
@ eEncodingSint
signed integer
MemberFunctionKind
Kind of member function.
@ eMemberFunctionKindInstanceMethod
A function that applies to a specific instance.
@ eMemberFunctionKindConstructor
A function used to create instances.
@ eMemberFunctionKindUnknown
Not sure what the type of this is.
@ eMemberFunctionKindDestructor
A function used to tear down existing instances.
@ eMemberFunctionKindStaticMethod
A function that applies to a type rather than any instance.
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Target > TargetSP
static clang::QualType GetQualType(const CompilerType &ct)
static clang::QualType GetCanonicalQualType(const CompilerType &ct)
static bool IsClangType(const CompilerType &ct)
static CompilerType RemoveFastQualifiers(const CompilerType &ct)
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
static llvm::Expected< FunctionCallLabel > fromString(llvm::StringRef label)
Decodes the specified function label into a FunctionCallLabel.
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
void Insert(lldb::LanguageType language)
A type-erased pair of llvm::dwarf::SourceLanguageName and version.