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/ErrorExtras.h"
17#include "llvm/Support/FormatAdapters.h"
18#include "llvm/Support/FormatVariadic.h"
25#include "clang/AST/ASTContext.h"
26#include "clang/AST/ASTImporter.h"
27#include "clang/AST/Attr.h"
28#include "clang/AST/CXXInheritance.h"
29#include "clang/AST/DeclObjC.h"
30#include "clang/AST/DeclTemplate.h"
31#include "clang/AST/Mangle.h"
32#include "clang/AST/QualTypeNames.h"
33#include "clang/AST/RecordLayout.h"
34#include "clang/AST/Type.h"
35#include "clang/AST/VTableBuilder.h"
36#include "clang/Basic/Builtins.h"
37#include "clang/Basic/Diagnostic.h"
38#include "clang/Basic/FileManager.h"
39#include "clang/Basic/FileSystemOptions.h"
40#include "clang/Basic/LangStandard.h"
41#include "clang/Basic/SourceManager.h"
42#include "clang/Basic/TargetInfo.h"
43#include "clang/Basic/TargetOptions.h"
44#include "clang/Frontend/FrontendOptions.h"
45#include "clang/Lex/HeaderSearch.h"
46#include "clang/Lex/HeaderSearchOptions.h"
47#include "clang/Lex/ModuleMap.h"
48#include "clang/Sema/Sema.h"
50#include "llvm/Support/Signals.h"
51#include "llvm/Support/Threading.h"
95using namespace llvm::dwarf;
97using llvm::StringSwitch;
102static void VerifyDecl(clang::Decl *decl) {
103 assert(decl &&
"VerifyDecl called with nullptr?");
129bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) {
131 lldbassert(&m1->getASTContext() == &m2->getASTContext() &&
132 "Methods should have the same AST context");
133 clang::ASTContext &context = m1->getASTContext();
135 const auto *m1Type = llvm::cast<clang::FunctionProtoType>(
136 context.getCanonicalType(m1->getType()));
138 const auto *m2Type = llvm::cast<clang::FunctionProtoType>(
139 context.getCanonicalType(m2->getType()));
141 auto compareArgTypes = [&context](
const clang::QualType &m1p,
142 const clang::QualType &m2p) {
143 return context.hasSameType(m1p.getUnqualifiedType(),
144 m2p.getUnqualifiedType());
149 return (m1->getNumParams() != m2->getNumParams()) ||
150 !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(),
151 m2Type->param_type_begin(), compareArgTypes);
157void addOverridesForMethod(clang::CXXMethodDecl *decl) {
158 if (!decl->isVirtual())
161 clang::CXXBasePaths paths;
162 llvm::SmallVector<clang::NamedDecl *, 4> decls;
164 auto find_overridden_methods =
165 [&decls, decl](
const clang::CXXBaseSpecifier *specifier,
166 clang::CXXBasePath &path) {
167 if (
auto *base_record = specifier->getType()->getAsCXXRecordDecl()) {
169 clang::DeclarationName name = decl->getDeclName();
173 if (name.getNameKind() == clang::DeclarationName::CXXDestructorName)
174 if (
auto *baseDtorDecl = base_record->getDestructor()) {
175 if (baseDtorDecl->isVirtual()) {
176 decls.push_back(baseDtorDecl);
183 for (path.Decls = base_record->lookup(name).begin();
184 path.Decls != path.Decls.end(); ++path.Decls) {
185 if (
auto *method_decl =
186 llvm::dyn_cast<clang::CXXMethodDecl>(*path.Decls))
187 if (method_decl->isVirtual() && !isOverload(decl, method_decl)) {
188 decls.push_back(method_decl);
197 if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) {
198 for (
auto *overridden_decl : decls)
199 decl->addOverriddenMethod(
200 llvm::cast<clang::CXXMethodDecl>(overridden_decl));
206 VTableContextBase &vtable_ctx,
208 const ASTRecordLayout &record_layout) {
212 uint32_t type_info = this_type.
GetTypeInfo(&pointee_type);
217 bool ptr_or_ref =
false;
218 if (type_info & (eTypeIsPointer | eTypeIsReference)) {
224 const uint32_t cpp_class = eTypeIsClass | eTypeIsCPlusPlus;
225 if ((type_info & cpp_class) != cpp_class)
230 vtable_ctx.isMicrosoft() ? record_layout.getVBPtrOffset().getQuantity()
244 vbtable_ptr_addr += vbtable_ptr_offset;
246 llvm::Expected<lldb::addr_t> vbtable_ptr_addr_or_err =
248 if (!vbtable_ptr_addr_or_err) {
249 llvm::consumeError(vbtable_ptr_addr_or_err.takeError());
252 return *vbtable_ptr_addr_or_err;
260 auto size = valobj.
GetData(data, err);
268 VTableContextBase &vtable_ctx,
270 const CXXRecordDecl *cxx_record_decl,
271 const CXXRecordDecl *base_class_decl) {
272 if (vtable_ctx.isMicrosoft()) {
273 clang::MicrosoftVTableContext &msoft_vtable_ctx =
274 static_cast<clang::MicrosoftVTableContext &
>(vtable_ctx);
278 const unsigned vbtable_index =
279 msoft_vtable_ctx.getVBTableIndex(cxx_record_decl, base_class_decl);
280 const lldb::addr_t base_offset_addr = vtable_ptr + vbtable_index * 4;
286 clang::ItaniumVTableContext &itanium_vtable_ctx =
287 static_cast<clang::ItaniumVTableContext &
>(vtable_ctx);
289 clang::CharUnits base_offset_offset =
290 itanium_vtable_ctx.getVirtualBaseOffsetOffset(cxx_record_decl,
293 vtable_ptr + base_offset_offset.getQuantity();
302 const ASTRecordLayout &record_layout,
303 const CXXRecordDecl *cxx_record_decl,
304 const CXXRecordDecl *base_class_decl,
305 int32_t &bit_offset) {
317 *process, vtable_ctx, vtable_ptr, cxx_record_decl, base_class_decl);
318 if (base_offset == INT64_MAX)
321 if (vtable_ctx.isMicrosoft())
322 base_offset += record_layout.getVBPtrOffset().getQuantity();
323 bit_offset = base_offset * 8;
333 static llvm::once_flag g_once_flag;
334 llvm::call_once(g_once_flag, []() {
341 bool is_complete_objc_class)
354 const clang::Decl *parent) {
355 if (!member || !parent)
362 member->setFromASTFile();
363 member->setOwningModuleID(
id.GetValue());
364 member->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
365 if (llvm::isa<clang::NamedDecl>(member))
366 if (
auto *dc = llvm::dyn_cast<clang::DeclContext>(parent)) {
367 dc->setHasExternalVisibleStorage(
true);
370 dc->setHasExternalLexicalStorage(
true);
377 clang::OverloadedOperatorKind &op_kind) {
379 if (!name.consume_front(
"operator"))
384 bool space_after_operator = name.consume_front(
" ");
386 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
387 .Case(
"+", clang::OO_Plus)
388 .Case(
"+=", clang::OO_PlusEqual)
389 .Case(
"++", clang::OO_PlusPlus)
390 .Case(
"-", clang::OO_Minus)
391 .Case(
"-=", clang::OO_MinusEqual)
392 .Case(
"--", clang::OO_MinusMinus)
393 .Case(
"->", clang::OO_Arrow)
394 .Case(
"->*", clang::OO_ArrowStar)
395 .Case(
"*", clang::OO_Star)
396 .Case(
"*=", clang::OO_StarEqual)
397 .Case(
"/", clang::OO_Slash)
398 .Case(
"/=", clang::OO_SlashEqual)
399 .Case(
"%", clang::OO_Percent)
400 .Case(
"%=", clang::OO_PercentEqual)
401 .Case(
"^", clang::OO_Caret)
402 .Case(
"^=", clang::OO_CaretEqual)
403 .Case(
"&", clang::OO_Amp)
404 .Case(
"&=", clang::OO_AmpEqual)
405 .Case(
"&&", clang::OO_AmpAmp)
406 .Case(
"|", clang::OO_Pipe)
407 .Case(
"|=", clang::OO_PipeEqual)
408 .Case(
"||", clang::OO_PipePipe)
409 .Case(
"~", clang::OO_Tilde)
410 .Case(
"!", clang::OO_Exclaim)
411 .Case(
"!=", clang::OO_ExclaimEqual)
412 .Case(
"=", clang::OO_Equal)
413 .Case(
"==", clang::OO_EqualEqual)
414 .Case(
"<", clang::OO_Less)
415 .Case(
"<=>", clang::OO_Spaceship)
416 .Case(
"<<", clang::OO_LessLess)
417 .Case(
"<<=", clang::OO_LessLessEqual)
418 .Case(
"<=", clang::OO_LessEqual)
419 .Case(
">", clang::OO_Greater)
420 .Case(
">>", clang::OO_GreaterGreater)
421 .Case(
">>=", clang::OO_GreaterGreaterEqual)
422 .Case(
">=", clang::OO_GreaterEqual)
423 .Case(
"()", clang::OO_Call)
424 .Case(
"[]", clang::OO_Subscript)
425 .Case(
",", clang::OO_Comma)
426 .Default(clang::NUM_OVERLOADED_OPERATORS);
429 if (op_kind != clang::NUM_OVERLOADED_OPERATORS)
441 if (!space_after_operator)
446 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
447 .Case(
"new", clang::OO_New)
448 .Case(
"new[]", clang::OO_Array_New)
449 .Case(
"delete", clang::OO_Delete)
450 .Case(
"delete[]", clang::OO_Array_Delete)
452 .Default(clang::NUM_OVERLOADED_OPERATORS);
457clang::AccessSpecifier
477 std::vector<std::string> Includes;
478 LangOptions::setLangDefaults(Opts, clang::Language::ObjCXX, arch.
GetTriple(),
479 Includes, clang::LangStandard::lang_gnucxx98);
481 Opts.setValueVisibilityMode(DefaultVisibility);
485 Opts.Trigraphs = !Opts.GNUMode;
490 Opts.ModulesLocalVisibility = 1;
494 llvm::Triple target_triple) {
496 if (!target_triple.str().empty())
506 ASTContext &existing_ctxt) {
522 if (!TypeSystemClangSupportsLanguage(language))
526 arch =
module->GetArchitecture();
536 if (triple.getVendor() == llvm::Triple::Apple &&
537 triple.getOS() == llvm::Triple::UnknownOS) {
538 if (triple.getArch() == llvm::Triple::arm ||
539 triple.getArch() == llvm::Triple::aarch64 ||
540 triple.getArch() == llvm::Triple::aarch64_32 ||
541 triple.getArch() == llvm::Triple::thumb) {
542 triple.setOS(llvm::Triple::IOS);
544 triple.setOS(llvm::Triple::MacOSX);
549 std::string ast_name =
550 "ASTContext for '" +
module->GetFileSpec().GetPath() + "'";
551 return std::make_shared<TypeSystemClang>(ast_name, triple);
552 }
else if (target && target->
IsValid())
553 return std::make_shared<ScratchTypeSystemClang>(*target, triple);
615 assert(s ==
nullptr || &s->getASTContext() ==
m_ast_up.get());
628 llvm::IntrusiveRefCntPtr<ExternalASTSource> ast_source_sp) {
630 ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(
true);
631 ast.setExternalSource(std::move(ast_source_sp));
644 const clang::Diagnostic &info)
override {
646 llvm::SmallVector<char, 32> diag_str(10);
647 info.FormatDiagnostic(diag_str);
648 diag_str.push_back(
'\0');
653 DiagnosticConsumer *
clone(DiagnosticsEngine &Diags)
const {
674 clang::FileSystemOptions file_system_options;
684 m_ast_up = std::make_unique<ASTContext>(
696 m_ast_up->InitBuiltinTypes(*target_info);
700 "Failed to initialize builtin ASTContext types for target '{0}'. "
701 "Printing variables may behave unexpectedly.",
707 static std::once_flag s_uninitialized_target_warning;
709 &s_uninitialized_target_warning);
715 llvm::makeIntrusiveRefCnt<ClangExternalASTSourceCallbacks>(*
this);
747#pragma mark Basic Types
750 ASTContext &ast, QualType qual_type) {
751 uint64_t qual_type_bit_size = ast.getTypeSize(qual_type);
752 return qual_type_bit_size == bit_size;
771 return GetType(ast.UnsignedCharTy);
773 return GetType(ast.UnsignedShortTy);
775 return GetType(ast.UnsignedIntTy);
777 return GetType(ast.UnsignedLongTy);
779 return GetType(ast.UnsignedLongLongTy);
781 return GetType(ast.UnsignedInt128Ty);
786 return GetType(ast.SignedCharTy);
794 return GetType(ast.LongLongTy);
805 return GetType(ast.LongDoubleTy);
809 return GetType(ast.Float128Ty);
814 if (bit_size && !(bit_size & 0x7u))
815 return GetType(ast.getExtVectorType(ast.UnsignedCharTy, bit_size / 8));
823 static const llvm::StringMap<lldb::BasicType> g_type_map = {
888 auto iter = g_type_map.find(name);
889 if (iter == g_type_map.end())
920 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
939 return GetType(ast.UnsignedCharTy);
941 return GetType(ast.UnsignedShortTy);
943 return GetType(ast.UnsignedIntTy);
948 if (type_name.contains(
"complex")) {
957 case DW_ATE_complex_float: {
958 CanQualType FloatComplexTy = ast.getComplexType(ast.FloatTy);
960 return GetType(FloatComplexTy);
962 CanQualType DoubleComplexTy = ast.getComplexType(ast.DoubleTy);
964 return GetType(DoubleComplexTy);
966 CanQualType LongDoubleComplexTy = ast.getComplexType(ast.LongDoubleTy);
968 return GetType(LongDoubleComplexTy);
978 if (type_name ==
"float" &&
981 if (type_name ==
"double" &&
984 if (type_name ==
"long double" &&
986 return GetType(ast.LongDoubleTy);
987 if (type_name ==
"__bf16" &&
989 return GetType(ast.BFloat16Ty);
990 if (type_name ==
"_Float16" &&
996 if ((type_name ==
"__float128" || type_name ==
"_Float128" ||
997 type_name ==
"f128") &&
999 return GetType(ast.Float128Ty);
1006 return GetType(ast.LongDoubleTy);
1010 return GetType(ast.Float128Ty);
1014 if (!type_name.empty()) {
1015 if (type_name.starts_with(
"_BitInt"))
1016 return GetType(ast.getBitIntType(
false, bit_size));
1017 if (type_name ==
"wchar_t" &&
1022 if (type_name ==
"void" &&
1025 if (type_name.contains(
"long long") &&
1027 return GetType(ast.LongLongTy);
1028 if (type_name.contains(
"long") &&
1031 if (type_name.contains(
"short") &&
1034 if (type_name.contains(
"char")) {
1038 return GetType(ast.SignedCharTy);
1040 if (type_name.contains(
"int")) {
1057 return GetType(ast.LongLongTy);
1062 case DW_ATE_signed_char:
1063 if (type_name ==
"char") {
1068 return GetType(ast.SignedCharTy);
1071 case DW_ATE_unsigned:
1072 if (!type_name.empty()) {
1073 if (type_name.starts_with(
"unsigned _BitInt"))
1074 return GetType(ast.getBitIntType(
true, bit_size));
1075 if (type_name ==
"wchar_t") {
1082 if (type_name.contains(
"long long")) {
1084 return GetType(ast.UnsignedLongLongTy);
1085 }
else if (type_name.contains(
"long")) {
1087 return GetType(ast.UnsignedLongTy);
1088 }
else if (type_name.contains(
"short")) {
1090 return GetType(ast.UnsignedShortTy);
1091 }
else if (type_name.contains(
"char")) {
1093 return GetType(ast.UnsignedCharTy);
1094 }
else if (type_name.contains(
"int")) {
1096 return GetType(ast.UnsignedIntTy);
1098 return GetType(ast.UnsignedInt128Ty);
1103 return GetType(ast.UnsignedCharTy);
1105 return GetType(ast.UnsignedShortTy);
1107 return GetType(ast.UnsignedIntTy);
1109 return GetType(ast.UnsignedLongTy);
1111 return GetType(ast.UnsignedLongLongTy);
1113 return GetType(ast.UnsignedInt128Ty);
1116 case DW_ATE_unsigned_char:
1117 if (type_name ==
"char") {
1122 return GetType(ast.UnsignedCharTy);
1124 return GetType(ast.UnsignedShortTy);
1127 case DW_ATE_imaginary_float:
1139 if (!type_name.empty()) {
1140 if (type_name ==
"char16_t")
1142 if (type_name ==
"char32_t")
1144 if (type_name ==
"char8_t")
1153 "error: need to add support for DW_TAG_base_type '{0}' "
1154 "encoded with DW_ATE = {1:x}, bit_size = {2}",
1155 type_name, dw_ate, bit_size);
1161 QualType char_type(ast.CharTy);
1164 char_type.addConst();
1166 return GetType(ast.getPointerType(char_type));
1170 bool ignore_qualifiers) {
1181 if (ignore_qualifiers) {
1182 type1_qual = type1_qual.getUnqualifiedType();
1183 type2_qual = type2_qual.getUnqualifiedType();
1186 return ast->getASTContext().hasSameType(type1_qual, type2_qual);
1193 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
1194 if (
auto *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl))
1206 if (clang::ObjCInterfaceDecl *interface_decl =
1207 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
1209 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
1211 if (clang::ValueDecl *value_decl = llvm::dyn_cast<clang::ValueDecl>(decl))
1225 return GetType(value_decl->getType());
1228#pragma mark Structure, Unions, Classes
1232 if (!decl || !owning_module.
HasValue())
1235 decl->setFromASTFile();
1236 decl->setOwningModuleID(owning_module.
GetValue());
1237 decl->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
1243 bool is_framework,
bool is_explicit) {
1245 auto *ast_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1247 assert(ast_source &&
"external ast source was lost");
1265 clang::Module *module;
1266 auto parent_desc = ast_source->getSourceDescriptor(parent.
GetValue());
1268 name, parent_desc ? parent_desc->getModuleOrNull() :
nullptr,
1269 is_framework, is_explicit);
1271 return ast_source->GetIDForModule(module);
1273 return ast_source->RegisterModule(module);
1279 std::optional<ClangASTMetadata> metadata,
bool exports_symbols) {
1282 if (decl_ctx ==
nullptr)
1283 decl_ctx = ast.getTranslationUnitDecl();
1287 bool isInternal =
false;
1288 return CreateObjCClass(name, decl_ctx, owning_module, isInternal, metadata);
1297 bool has_name = !name.empty();
1298 CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1299 decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1300 decl->setDeclContext(decl_ctx);
1302 decl->setDeclName(&ast.Idents.get(name));
1330 if (isa<CXXRecordDecl>(decl_ctx) && exports_symbols)
1331 decl->setAnonymousStructOrUnion(
true);
1337 decl->setAccess(AS_public);
1340 decl_ctx->addDecl(decl);
1342 return GetType(ast.getCanonicalTagType(decl));
1349QualType GetValueParamType(
const clang::TemplateArgument &argument) {
1350 switch (argument.getKind()) {
1351 case TemplateArgument::Integral:
1352 return argument.getIntegralType();
1353 case TemplateArgument::StructuralValue:
1354 return argument.getStructuralValueType();
1364 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1365 const bool parameter_pack =
false;
1366 const bool is_typename =
false;
1367 const unsigned depth = 0;
1368 const size_t num_template_params = template_param_infos.
Size();
1369 DeclContext *
const decl_context =
1370 ast.getTranslationUnitDecl();
1372 auto const &args = template_param_infos.
GetArgs();
1373 auto const &names = template_param_infos.
GetNames();
1374 for (
size_t i = 0; i < num_template_params; ++i) {
1375 const char *name = names[i];
1377 IdentifierInfo *identifier_info =
nullptr;
1378 if (name && name[0])
1379 identifier_info = &ast.Idents.get(name);
1380 TemplateArgument
const &targ = args[i];
1381 QualType template_param_type = GetValueParamType(targ);
1382 if (!template_param_type.isNull()) {
1383 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1384 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1385 identifier_info, template_param_type, parameter_pack,
1386 ast.getTrivialTypeSourceInfo(template_param_type)));
1388 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1389 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1390 identifier_info, is_typename, parameter_pack));
1395 IdentifierInfo *identifier_info =
nullptr;
1397 identifier_info = &ast.Idents.get(template_param_infos.
GetPackName());
1398 const bool parameter_pack_true =
true;
1400 QualType template_param_type =
1404 if (!template_param_type.isNull()) {
1405 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1406 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1407 num_template_params, identifier_info, template_param_type,
1408 parameter_pack_true,
1409 ast.getTrivialTypeSourceInfo(template_param_type)));
1411 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1412 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1413 num_template_params, identifier_info, is_typename,
1414 parameter_pack_true));
1417 clang::Expr *
const requires_clause =
nullptr;
1418 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1419 ast, SourceLocation(), SourceLocation(), template_param_decls,
1420 SourceLocation(), requires_clause);
1421 return template_param_list;
1426 clang::FunctionDecl *func_decl,
1431 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1433 ast, template_param_infos, template_param_decls);
1434 FunctionTemplateDecl *func_tmpl_decl =
1435 FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1436 func_tmpl_decl->setDeclContext(decl_ctx);
1437 func_tmpl_decl->setLocation(func_decl->getLocation());
1438 func_tmpl_decl->setDeclName(func_decl->getDeclName());
1439 func_tmpl_decl->setTemplateParameters(template_param_list);
1440 func_tmpl_decl->init(func_decl);
1443 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1444 i < template_param_decl_count; ++i) {
1446 template_param_decls[i]->setDeclContext(func_decl);
1448 func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
1450 return func_tmpl_decl;
1454 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1456 TemplateArgumentList *template_args_ptr = TemplateArgumentList::CreateCopy(
1457 func_decl->getASTContext(), infos.
GetArgs());
1459 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
1460 template_args_ptr, {});
1467 const TemplateArgument &value) {
1468 if (llvm::isa<TemplateTypeParmDecl>(param)) {
1470 if (value.getKind() != TemplateArgument::Type)
1472 }
else if (
auto *type_param =
1473 llvm::dyn_cast<NonTypeTemplateParmDecl>(param)) {
1475 QualType value_param_type = GetValueParamType(value);
1476 if (value_param_type.isNull())
1480 if (type_param->getType() != value_param_type)
1488 "Don't know how to compare template parameter to passed"
1489 " value. Decl kind of parameter is: {0}",
1490 param->getDeclKindName());
1491 lldbassert(
false &&
"Can't compare this TemplateParmDecl subclass");
1506 ClassTemplateDecl *class_template_decl,
1509 TemplateParameterList ¶ms = *class_template_decl->getTemplateParameters();
1515 std::optional<NamedDecl *> pack_parameter;
1517 size_t non_pack_params = params.size();
1518 for (
size_t i = 0; i < params.size(); ++i) {
1519 NamedDecl *param = params.getParam(i);
1520 if (param->isParameterPack()) {
1521 pack_parameter = param;
1522 non_pack_params = i;
1530 if (non_pack_params != instantiation_values.
Size())
1548 for (
const auto pair :
1549 llvm::zip_first(instantiation_values.
GetArgs(), params)) {
1550 const TemplateArgument &passed_arg = std::get<0>(pair);
1551 NamedDecl *found_param = std::get<1>(pair);
1556 return class_template_decl;
1561 llvm::StringRef class_name,
int kind,
1565 ClassTemplateDecl *class_template_decl =
nullptr;
1566 if (decl_ctx ==
nullptr)
1567 decl_ctx = ast.getTranslationUnitDecl();
1569 IdentifierInfo &identifier_info = ast.Idents.get(class_name);
1570 DeclarationName decl_name(&identifier_info);
1573 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1574 for (NamedDecl *decl : result) {
1575 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1576 if (!class_template_decl)
1585 template_param_infos))
1587 return class_template_decl;
1590 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1593 ast, template_param_infos, template_param_decls);
1595 CXXRecordDecl *template_cxx_decl =
1596 CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1597 template_cxx_decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1599 template_cxx_decl->setDeclContext(decl_ctx);
1600 template_cxx_decl->setDeclName(decl_name);
1603 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1604 i < template_param_decl_count; ++i) {
1605 template_param_decls[i]->setDeclContext(template_cxx_decl);
1613 class_template_decl =
1614 ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1616 class_template_decl->setDeclContext(decl_ctx);
1617 class_template_decl->setDeclName(decl_name);
1618 class_template_decl->setTemplateParameters(template_param_list);
1619 class_template_decl->init(template_cxx_decl);
1620 template_cxx_decl->setDescribedClassTemplate(class_template_decl);
1623 class_template_decl->setAccess(AS_public);
1625 decl_ctx->addDecl(class_template_decl);
1627 VerifyDecl(class_template_decl);
1629 return class_template_decl;
1632TemplateTemplateParmDecl *
1636 auto *decl_ctx = ast.getTranslationUnitDecl();
1638 IdentifierInfo &identifier_info = ast.Idents.get(template_name);
1639 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1643 std::make_unique<TemplateParameterInfos>());
1645 ast, template_param_infos, template_param_decls);
1651 return TemplateTemplateParmDecl::Create(
1652 ast, decl_ctx, SourceLocation(),
1654 false, &identifier_info,
1655 TemplateNameKind::TNK_Type_template,
true,
1656 template_param_list);
1659ClassTemplateSpecializationDecl *
1662 ClassTemplateDecl *class_template_decl,
int kind,
1665 llvm::SmallVector<clang::TemplateArgument, 2> args(
1666 template_param_infos.
Size() +
1669 auto const &orig_args = template_param_infos.
GetArgs();
1670 std::copy(orig_args.begin(), orig_args.end(), args.begin());
1672 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1675 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1676 ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
1677 class_template_specialization_decl->setTagKind(
1678 static_cast<TagDecl::TagKind
>(kind));
1679 class_template_specialization_decl->setDeclContext(decl_ctx);
1680 class_template_specialization_decl->setInstantiationOf(class_template_decl);
1681 class_template_specialization_decl->setTemplateArgs(
1682 TemplateArgumentList::CreateCopy(ast, args));
1683 llvm::FoldingSetInsertToken insert_token;
1684 if (class_template_decl->findSpecialization(args, insert_token))
1686 class_template_decl->AddSpecialization(class_template_specialization_decl,
1688 class_template_specialization_decl->setDeclName(
1689 class_template_decl->getDeclName());
1694 class_template_specialization_decl->setStrictPackMatch(
false);
1697 decl_ctx->addDecl(class_template_specialization_decl);
1699 class_template_specialization_decl->setSpecializationKind(
1700 TSK_ExplicitSpecialization);
1702 return class_template_specialization_decl;
1706 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1707 if (class_template_specialization_decl) {
1709 return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
1715 clang::OverloadedOperatorKind op_kind,
1716 bool unary,
bool binary,
1717 uint32_t num_params) {
1719 if (op_kind == OO_Call)
1725 if (num_params == 1)
1727 if (num_params == 2)
1734 bool is_method, clang::OverloadedOperatorKind op_kind,
1735 uint32_t num_params) {
1743 case OO_Array_Delete:
1747#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1749 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1751#include "clang/Basic/OperatorKinds.def"
1759 uint32_t &bitfield_bit_size) {
1761 if (field ==
nullptr)
1764 if (field->isBitField()) {
1765 Expr *bit_width_expr = field->getBitWidth();
1766 if (bit_width_expr) {
1767 if (std::optional<llvm::APSInt> bit_width_apsint =
1768 bit_width_expr->getIntegerConstantExpr(ast)) {
1769 bitfield_bit_size = bit_width_apsint->getLimitedValue(
UINT32_MAX);
1778 if (record_decl ==
nullptr)
1781 if (!record_decl->field_empty())
1785 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1786 if (cxx_record_decl) {
1787 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1788 for (base_class = cxx_record_decl->bases_begin(),
1789 base_class_end = cxx_record_decl->bases_end();
1790 base_class != base_class_end; ++base_class) {
1791 assert(record_decl != base_class->getType()->getAsCXXRecordDecl() &&
1792 "Base can't inherit from itself.");
1804 if (std::optional<ClangASTMetadata> meta_data =
GetMetadata(record_decl);
1805 meta_data && meta_data->IsForcefullyCompleted())
1811#pragma mark Objective-C Classes
1814 llvm::StringRef name, clang::DeclContext *decl_ctx,
1816 std::optional<ClangASTMetadata> metadata) {
1818 assert(!name.empty());
1820 decl_ctx = ast.getTranslationUnitDecl();
1822 ObjCInterfaceDecl *decl =
1823 ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
1824 decl->setDeclContext(decl_ctx);
1825 decl->setDeclName(&ast.Idents.get(name));
1826 decl->setImplicit(isInternal);
1832 return GetType(ast.getObjCInterfaceType(decl));
1841 bool omit_empty_base_classes) {
1842 uint32_t num_bases = 0;
1843 if (cxx_record_decl) {
1844 if (omit_empty_base_classes) {
1845 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1846 for (base_class = cxx_record_decl->bases_begin(),
1847 base_class_end = cxx_record_decl->bases_end();
1848 base_class != base_class_end; ++base_class) {
1855 num_bases = cxx_record_decl->getNumBases();
1860#pragma mark Namespace Declarations
1863 const char *name, clang::DeclContext *decl_ctx,
1865 NamespaceDecl *namespace_decl =
nullptr;
1867 TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
1869 decl_ctx = translation_unit_decl;
1872 IdentifierInfo &identifier_info = ast.Idents.get(name);
1873 DeclarationName decl_name(&identifier_info);
1874 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1875 for (NamedDecl *decl : result) {
1876 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1878 return namespace_decl;
1881 namespace_decl = NamespaceDecl::Create(ast, decl_ctx, is_inline,
1882 SourceLocation(), SourceLocation(),
1883 &identifier_info,
nullptr,
false);
1885 decl_ctx->addDecl(namespace_decl);
1887 if (decl_ctx == translation_unit_decl) {
1888 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1890 return namespace_decl;
1893 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1894 SourceLocation(),
nullptr,
nullptr,
false);
1895 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1896 translation_unit_decl->addDecl(namespace_decl);
1897 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace());
1899 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1900 if (parent_namespace_decl) {
1901 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1903 return namespace_decl;
1905 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1906 SourceLocation(),
nullptr,
nullptr,
false);
1907 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1908 parent_namespace_decl->addDecl(namespace_decl);
1909 assert(namespace_decl ==
1910 parent_namespace_decl->getAnonymousNamespace());
1912 assert(
false &&
"GetUniqueNamespaceDeclaration called with no name and "
1913 "no namespace as decl_ctx");
1921 VerifyDecl(namespace_decl);
1922 return namespace_decl;
1929 clang::BlockDecl *decl =
1930 clang::BlockDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1931 decl->setDeclContext(ctx);
1940 clang::DeclContext *right,
1941 clang::DeclContext *root) {
1942 if (root ==
nullptr)
1945 std::set<clang::DeclContext *> path_left;
1946 for (clang::DeclContext *d = left; d !=
nullptr; d = d->getParent())
1947 path_left.insert(d);
1949 for (clang::DeclContext *d = right; d !=
nullptr; d = d->getParent())
1950 if (path_left.find(d) != path_left.end())
1958 clang::NamespaceDecl *ns_decl) {
1959 if (decl_ctx && ns_decl) {
1960 auto *translation_unit =
getASTContext().getTranslationUnitDecl();
1961 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
1963 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
1964 clang::SourceLocation(), ns_decl,
1967 decl_ctx->addDecl(using_decl);
1977 clang::NamedDecl *target) {
1978 if (current_decl_ctx && target) {
1979 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
1981 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(),
false);
1983 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
1985 target->getDeclName(), using_decl, target);
1987 using_decl->addShadowDecl(shadow_decl);
1988 current_decl_ctx->addDecl(using_decl);
1996 const char *name, clang::QualType type) {
1998 clang::VarDecl *var_decl =
1999 clang::VarDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
2000 var_decl->setDeclContext(decl_context);
2001 if (name && name[0])
2002 var_decl->setDeclName(&
getASTContext().Idents.getOwn(name));
2003 var_decl->setType(type);
2005 var_decl->setAccess(clang::AS_public);
2006 decl_context->addDecl(var_decl);
2015 switch (basic_type) {
2017 return ast->VoidTy.getAsOpaquePtr();
2019 return ast->CharTy.getAsOpaquePtr();
2021 return ast->SignedCharTy.getAsOpaquePtr();
2023 return ast->UnsignedCharTy.getAsOpaquePtr();
2025 return ast->getWCharType().getAsOpaquePtr();
2027 return ast->getSignedWCharType().getAsOpaquePtr();
2029 return ast->getUnsignedWCharType().getAsOpaquePtr();
2031 return ast->Char8Ty.getAsOpaquePtr();
2033 return ast->Char16Ty.getAsOpaquePtr();
2035 return ast->Char32Ty.getAsOpaquePtr();
2037 return ast->ShortTy.getAsOpaquePtr();
2039 return ast->UnsignedShortTy.getAsOpaquePtr();
2041 return ast->IntTy.getAsOpaquePtr();
2043 return ast->UnsignedIntTy.getAsOpaquePtr();
2045 return ast->LongTy.getAsOpaquePtr();
2047 return ast->UnsignedLongTy.getAsOpaquePtr();
2049 return ast->LongLongTy.getAsOpaquePtr();
2051 return ast->UnsignedLongLongTy.getAsOpaquePtr();
2053 return ast->Int128Ty.getAsOpaquePtr();
2055 return ast->UnsignedInt128Ty.getAsOpaquePtr();
2057 return ast->BoolTy.getAsOpaquePtr();
2059 return ast->HalfTy.getAsOpaquePtr();
2061 return ast->FloatTy.getAsOpaquePtr();
2063 return ast->DoubleTy.getAsOpaquePtr();
2065 return ast->LongDoubleTy.getAsOpaquePtr();
2067 return ast->Float128Ty.getAsOpaquePtr();
2069 return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
2071 return ast->getComplexType(ast->DoubleTy).getAsOpaquePtr();
2073 return ast->getComplexType(ast->LongDoubleTy).getAsOpaquePtr();
2075 return ast->getObjCIdType().getAsOpaquePtr();
2077 return ast->getObjCClassType().getAsOpaquePtr();
2079 return ast->getObjCSelType().getAsOpaquePtr();
2081 return ast->NullPtrTy.getAsOpaquePtr();
2087#pragma mark Function Types
2089clang::DeclarationName
2092 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2093 if (!
IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2102 const clang::FunctionProtoType *function_type =
2103 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2104 if (function_type ==
nullptr)
2105 return clang::DeclarationName();
2107 const bool is_method =
false;
2108 const unsigned int num_params = function_type->getNumParams();
2110 is_method, op_kind, num_params))
2111 return clang::DeclarationName();
2113 return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
2117 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
2118 printing_policy.SuppressTagKeyword =
true;
2121 printing_policy.SuppressInlineNamespace =
2122 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None);
2123 printing_policy.SuppressUnwrittenScope =
false;
2135 printing_policy.SuppressDefaultTemplateArgs =
false;
2136 return printing_policy;
2143 llvm::raw_string_ostream os(result);
2144 named_decl->getNameForDiagnostic(os, printing_policy, qualified);
2150 llvm::StringRef name,
const CompilerType &function_clang_type,
2151 clang::StorageClass storage,
bool is_inline, llvm::StringRef asm_label) {
2152 FunctionDecl *func_decl =
nullptr;
2155 decl_ctx = ast.getTranslationUnitDecl();
2157 const bool hasWrittenPrototype =
true;
2158 const bool isConstexprSpecified =
false;
2160 clang::DeclarationName declarationName =
2162 func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
2163 func_decl->setDeclContext(decl_ctx);
2164 func_decl->setDeclName(declarationName);
2166 func_decl->setStorageClass(storage);
2167 func_decl->setInlineSpecified(is_inline);
2168 func_decl->setHasWrittenPrototype(hasWrittenPrototype);
2169 func_decl->setConstexprKind(isConstexprSpecified
2170 ? ConstexprSpecKind::Constexpr
2171 : ConstexprSpecKind::Unspecified);
2183 if (!asm_label.empty())
2184 func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label));
2187 decl_ctx->addDecl(func_decl);
2189 VerifyDecl(func_decl);
2195 const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
2196 bool is_variadic,
unsigned type_quals, clang::CallingConv cc,
2197 clang::RefQualifierKind ref_qual) {
2201 std::vector<QualType> qual_type_args;
2203 for (
const auto &arg : args) {
2218 FunctionProtoType::ExtProtoInfo proto_info;
2219 proto_info.ExtInfo = cc;
2220 proto_info.Variadic = is_variadic;
2221 proto_info.ExceptionSpec = EST_None;
2222 proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
2223 proto_info.RefQualifier = ref_qual;
2231 const char *name,
const CompilerType ¶m_type,
int storage,
2234 auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
2235 decl->setDeclContext(decl_ctx);
2236 if (name && name[0])
2237 decl->setDeclName(&ast.Idents.get(name));
2239 decl->setStorageClass(
static_cast<clang::StorageClass
>(storage));
2242 decl_ctx->addDecl(decl);
2249 QualType block_type =
m_ast_up->getBlockPointerType(
2255#pragma mark Array Types
2259 std::optional<size_t> element_count,
2272 clang::ArraySizeModifier::Normal, 0));
2278 llvm::APInt ap_element_count(64, *element_count);
2280 ap_element_count,
nullptr,
2281 clang::ArraySizeModifier::Normal, 0));
2285 llvm::StringRef type_name,
2286 const std::initializer_list<std::pair<const char *, CompilerType>>
2293 lldbassert(0 &&
"Trying to create a type for an existing name");
2298 llvm::to_underlying(clang::TagTypeKind::Struct),
2301 for (
const auto &field : type_fields)
2310 llvm::StringRef type_name,
2311 const std::initializer_list<std::pair<const char *, CompilerType>>
2323#pragma mark Enumeration Types
2326 llvm::StringRef name, clang::DeclContext *decl_ctx,
2328 const CompilerType &integer_clang_type,
bool is_scoped,
2329 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind) {
2336 EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
2337 enum_decl->setDeclContext(decl_ctx);
2339 enum_decl->setDeclName(&ast.Idents.get(name));
2340 enum_decl->setScoped(is_scoped);
2341 enum_decl->setScopedUsingClassTag(is_scoped);
2342 enum_decl->setFixed(
false);
2345 decl_ctx->addDecl(enum_decl);
2349 clang::EnumExtensibilityAttr::CreateImplicit(ast, *enum_kind));
2354 enum_decl->setAccess(AS_public);
2356 return GetType(ast.getCanonicalTagType(enum_decl));
2367 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
2368 return GetType(ast.SignedCharTy);
2370 if (bit_size == ast.getTypeSize(ast.ShortTy))
2373 if (bit_size == ast.getTypeSize(ast.IntTy))
2376 if (bit_size == ast.getTypeSize(ast.LongTy))
2379 if (bit_size == ast.getTypeSize(ast.LongLongTy))
2380 return GetType(ast.LongLongTy);
2382 if (bit_size == ast.getTypeSize(ast.Int128Ty))
2385 if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
2386 return GetType(ast.UnsignedCharTy);
2388 if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
2389 return GetType(ast.UnsignedShortTy);
2391 if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
2392 return GetType(ast.UnsignedIntTy);
2394 if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
2395 return GetType(ast.UnsignedLongTy);
2397 if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
2398 return GetType(ast.UnsignedLongLongTy);
2400 if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
2401 return GetType(ast.UnsignedInt128Ty);
2436 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2438 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2439 named_decl->getDeclName().getAsString().c_str());
2441 printf(
"%20s\n", decl_ctx->getDeclKindName());
2447 if (decl ==
nullptr)
2451 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2453 bool is_injected_class_name =
2454 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2455 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2456 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2457 record_decl->getDeclName().getAsString().c_str(),
2458 is_injected_class_name ?
" (injected class name)" :
"");
2461 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2463 printf(
"%20s: %s\n", decl->getDeclKindName(),
2464 named_decl->getDeclName().getAsString().c_str());
2466 printf(
"%20s\n", decl->getDeclKindName());
2472 clang::Decl *decl) {
2476 ExternalASTSource *ast_source = ast->getExternalSource();
2481 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2482 if (tag_decl->isCompleteDefinition())
2485 if (!tag_decl->hasExternalLexicalStorage())
2488 ast_source->CompleteType(tag_decl);
2490 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2491 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2492 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2493 if (objc_interface_decl->getDefinition())
2496 if (!objc_interface_decl->hasExternalLexicalStorage())
2499 ast_source->CompleteType(objc_interface_decl);
2501 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2531std::optional<ClangASTMetadata>
2537 return std::nullopt;
2540std::optional<ClangASTMetadata>
2546 return std::nullopt;
2568 if (find(mask, type->getTypeClass()) != mask.end())
2570 switch (type->getTypeClass()) {
2573 case clang::Type::Atomic:
2574 type = cast<clang::AtomicType>(type)->getValueType();
2576 case clang::Type::Auto:
2577 case clang::Type::Decltype:
2578 case clang::Type::Paren:
2579 case clang::Type::SubstTemplateTypeParm:
2580 case clang::Type::TemplateSpecialization:
2581 case clang::Type::Typedef:
2582 case clang::Type::TypeOf:
2583 case clang::Type::TypeOfExpr:
2584 case clang::Type::Using:
2585 case clang::Type::PredefinedSugar:
2586 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2600 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2601 switch (type_class) {
2602 case clang::Type::ObjCInterface:
2603 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2605 case clang::Type::ObjCObjectPointer:
2607 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2608 ->getPointeeType());
2609 case clang::Type::Enum:
2610 case clang::Type::Record:
2611 return llvm::cast<clang::TagType>(qual_type)
2613 ->getDefinitionOrSelf();
2625static const clang::RecordType *
2627 assert(qual_type->isRecordType());
2629 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2631 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2635 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2638 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2639 const bool fields_loaded =
2640 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2643 if (is_complete && fields_loaded)
2651 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2652 if (external_ast_source) {
2653 external_ast_source->CompleteType(cxx_record_decl);
2654 if (cxx_record_decl->isCompleteDefinition()) {
2655 cxx_record_decl->field_begin();
2656 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
2668 clang::QualType qual_type) {
2669 assert(qual_type->isEnumeralType());
2672 const clang::EnumType *enum_type =
2673 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2675 auto *tag_decl = enum_type->getAsTagDecl();
2679 if (tag_decl->getDefinition())
2683 if (!tag_decl->hasExternalLexicalStorage())
2687 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2688 if (!external_ast_source)
2691 external_ast_source->CompleteType(tag_decl);
2699static const clang::ObjCObjectType *
2701 assert(qual_type->isObjCObjectType());
2704 const clang::ObjCObjectType *objc_class_type =
2705 llvm::cast<clang::ObjCObjectType>(qual_type);
2707 clang::ObjCInterfaceDecl *class_interface_decl =
2708 objc_class_type->getInterface();
2711 if (!class_interface_decl)
2712 return objc_class_type;
2715 if (class_interface_decl->getDefinition())
2716 return objc_class_type;
2719 if (!class_interface_decl->hasExternalLexicalStorage())
2723 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2724 if (!external_ast_source)
2727 external_ast_source->CompleteType(class_interface_decl);
2728 return objc_class_type;
2732 clang::QualType qual_type) {
2734 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2735 switch (type_class) {
2736 case clang::Type::ConstantArray:
2737 case clang::Type::IncompleteArray:
2738 case clang::Type::VariableArray: {
2739 const clang::ArrayType *array_type =
2740 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2745 case clang::Type::Record: {
2747 return !RT->isIncompleteType();
2752 case clang::Type::Enum: {
2754 return !ET->isIncompleteType();
2758 case clang::Type::ObjCObject:
2759 case clang::Type::ObjCInterface: {
2761 return !OT->isIncompleteType();
2766 case clang::Type::Attributed:
2768 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType());
2770 case clang::Type::MemberPointer:
2773 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2774 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2775 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2778 return !qual_type.getTypePtr()->isIncompleteType();
2793 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2800 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2801 switch (type_class) {
2802 case clang::Type::IncompleteArray:
2803 case clang::Type::VariableArray:
2804 case clang::Type::ConstantArray:
2805 case clang::Type::ExtVector:
2806 case clang::Type::Vector:
2807 case clang::Type::Record:
2808 case clang::Type::ObjCObject:
2809 case clang::Type::ObjCInterface:
2821 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2822 switch (type_class) {
2823 case clang::Type::Record: {
2824 if (
const clang::RecordType *record_type =
2825 llvm::dyn_cast_or_null<clang::RecordType>(
2826 qual_type.getTypePtrOrNull())) {
2827 if (
const clang::RecordDecl *record_decl = record_type->getDecl()) {
2828 return record_decl->isAnonymousStructOrUnion();
2842 uint64_t *size,
bool *is_incomplete) {
2845 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2846 switch (type_class) {
2850 case clang::Type::ConstantArray:
2851 if (element_type_ptr)
2853 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2857 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2859 .getLimitedValue(ULLONG_MAX);
2861 *is_incomplete =
false;
2864 case clang::Type::IncompleteArray:
2865 if (element_type_ptr)
2867 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2873 *is_incomplete =
true;
2876 case clang::Type::VariableArray:
2877 if (element_type_ptr)
2879 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2885 *is_incomplete =
false;
2888 case clang::Type::DependentSizedArray:
2889 if (element_type_ptr)
2892 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2898 *is_incomplete =
false;
2901 if (element_type_ptr)
2902 element_type_ptr->
Clear();
2906 *is_incomplete =
false;
2914 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2915 switch (type_class) {
2916 case clang::Type::Vector: {
2917 const clang::VectorType *vector_type =
2918 qual_type->getAs<clang::VectorType>();
2921 *size = vector_type->getNumElements();
2923 *element_type =
GetType(vector_type->getElementType());
2927 case clang::Type::ExtVector: {
2928 const clang::ExtVectorType *ext_vector_type =
2929 qual_type->getAs<clang::ExtVectorType>();
2930 if (ext_vector_type) {
2932 *size = ext_vector_type->getNumElements();
2936 ext_vector_type->getElementType().getAsOpaquePtr());
2952 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
2955 clang::ObjCInterfaceDecl *result_iface_decl =
2956 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
2958 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
2962 return (ast_metadata->GetISAPtr() != 0);
2966 return GetQualType(type).getUnqualifiedType()->isCharType();
2988 if (!pointee_or_element_clang_type.
IsValid())
2991 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
2992 if (pointee_or_element_clang_type.
IsCharType()) {
2993 if (type_flags.
Test(eTypeIsArray)) {
2996 length = llvm::cast<clang::ConstantArrayType>(
3010 if (
auto pointer_auth = qual_type.getPointerAuth())
3011 return pointer_auth.getKey();
3020 if (
auto pointer_auth = qual_type.getPointerAuth())
3021 return pointer_auth.getExtraDiscriminator();
3030 if (
auto pointer_auth = qual_type.getPointerAuth())
3031 return pointer_auth.isAddressDiscriminated();
3037 auto isFunctionType = [&](clang::QualType qual_type) {
3038 return qual_type->isFunctionType();
3052 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3053 switch (type_class) {
3054 case clang::Type::Record:
3056 const clang::CXXRecordDecl *cxx_record_decl =
3057 qual_type->getAsCXXRecordDecl();
3058 if (cxx_record_decl) {
3059 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3062 const clang::RecordType *record_type =
3063 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3065 if (
const clang::RecordDecl *record_decl =
3066 record_type->getDecl()->getDefinition()) {
3069 clang::RecordDecl::field_iterator field_pos,
3070 field_end = record_decl->field_end();
3071 uint32_t num_fields = 0;
3072 bool is_hva =
false;
3073 bool is_hfa =
false;
3074 clang::QualType base_qual_type;
3075 uint64_t base_bitwidth = 0;
3076 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3078 clang::QualType field_qual_type = field_pos->getType();
3079 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3080 if (field_qual_type->isFloatingType()) {
3081 if (field_qual_type->isComplexType())
3084 if (num_fields == 0)
3085 base_qual_type = field_qual_type;
3090 if (field_qual_type.getTypePtr() !=
3091 base_qual_type.getTypePtr())
3095 }
else if (field_qual_type->isVectorType() ||
3096 field_qual_type->isExtVectorType()) {
3097 if (num_fields == 0) {
3098 base_qual_type = field_qual_type;
3099 base_bitwidth = field_bitwidth;
3104 if (base_bitwidth != field_bitwidth)
3106 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3115 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3132 const clang::FunctionProtoType *func =
3133 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3135 return func->getNumParams();
3142 const size_t index) {
3145 const clang::FunctionProtoType *func =
3146 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3148 if (index < func->getNumParams())
3149 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3157 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3161 if (predicate(qual_type))
3164 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3165 switch (type_class) {
3169 case clang::Type::LValueReference:
3170 case clang::Type::RValueReference: {
3171 const clang::ReferenceType *reference_type =
3172 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3174 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3183 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3184 return qual_type->isMemberFunctionPointerType();
3187 return IsTypeImpl(type, isMemberFunctionPointerType);
3192 auto isMemberDataPointerType = [](clang::QualType qual_type) {
3193 return qual_type->isMemberDataPointerType();
3196 return IsTypeImpl(type, isMemberDataPointerType);
3200 auto isFunctionPointerType = [](clang::QualType qual_type) {
3201 return qual_type->isFunctionPointerType();
3204 return IsTypeImpl(type, isFunctionPointerType);
3210 auto isBlockPointerType = [&](clang::QualType qual_type) {
3211 if (qual_type->isBlockPointerType()) {
3212 if (function_pointer_type_ptr) {
3213 const clang::BlockPointerType *block_pointer_type =
3214 qual_type->castAs<clang::BlockPointerType>();
3215 QualType pointee_type = block_pointer_type->getPointeeType();
3216 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3218 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3235 if (qual_type.isNull())
3244 is_signed = qual_type->isSignedIntegerType();
3252 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3256 is_signed = enum_type->isSignedIntegerOrEnumerationType();
3267 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3271 return enum_type->isScopedEnumeralType();
3282 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3283 switch (type_class) {
3284 case clang::Type::Builtin:
3285 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3288 case clang::BuiltinType::ObjCId:
3289 case clang::BuiltinType::ObjCClass:
3293 case clang::Type::ObjCObjectPointer:
3297 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3301 case clang::Type::BlockPointer:
3304 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3308 case clang::Type::Pointer:
3311 llvm::cast<clang::PointerType>(qual_type)
3315 case clang::Type::MemberPointer:
3318 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3327 pointee_type->
Clear();
3335 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3336 switch (type_class) {
3337 case clang::Type::Builtin:
3338 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3341 case clang::BuiltinType::ObjCId:
3342 case clang::BuiltinType::ObjCClass:
3346 case clang::Type::ObjCObjectPointer:
3350 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3354 case clang::Type::BlockPointer:
3357 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3361 case clang::Type::Pointer:
3364 llvm::cast<clang::PointerType>(qual_type)
3368 case clang::Type::MemberPointer:
3371 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3375 case clang::Type::LValueReference:
3378 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3382 case clang::Type::RValueReference:
3385 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3394 pointee_type->
Clear();
3403 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3405 switch (type_class) {
3406 case clang::Type::LValueReference:
3409 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3415 case clang::Type::RValueReference:
3418 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3430 pointee_type->
Clear();
3439 if (qual_type.isNull())
3442 return qual_type->isFloatingType();
3450 const clang::TagType *tag_type =
3451 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3453 if (clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinition())
3454 return tag_decl->isCompleteDefinition();
3457 const clang::ObjCObjectType *objc_class_type =
3458 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3459 if (objc_class_type) {
3460 clang::ObjCInterfaceDecl *class_interface_decl =
3461 objc_class_type->getInterface();
3462 if (class_interface_decl)
3463 return class_interface_decl->getDefinition() !=
nullptr;
3474 const clang::ObjCObjectPointerType *obj_pointer_type =
3475 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3477 if (obj_pointer_type)
3478 return obj_pointer_type->isObjCClassType();
3493 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3494 return (type_class == clang::Type::Record);
3501 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3502 return (type_class == clang::Type::Enum);
3508 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3509 switch (type_class) {
3510 case clang::Type::Record:
3512 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3519 return cxx_record_decl->isDynamicClass();
3533 bool check_cplusplus,
3535 if (dynamic_pointee_type)
3536 dynamic_pointee_type->
Clear();
3540 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3541 if (dynamic_pointee_type)
3543 type.getAsOpaquePtr());
3546 clang::QualType pointee_qual_type;
3548 switch (qual_type->getTypeClass()) {
3549 case clang::Type::Builtin:
3550 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3551 clang::BuiltinType::ObjCId) {
3552 set_dynamic_pointee_type(qual_type);
3557 case clang::Type::ObjCObjectPointer:
3560 if (
const auto *objc_pointee_type =
3561 qual_type->getPointeeType().getTypePtrOrNull()) {
3562 if (
const auto *objc_object_type =
3563 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3564 objc_pointee_type)) {
3565 if (objc_object_type->isObjCClass())
3569 set_dynamic_pointee_type(
3570 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3573 case clang::Type::Pointer:
3575 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3578 case clang::Type::LValueReference:
3579 case clang::Type::RValueReference:
3581 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3591 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3592 case clang::Type::Builtin:
3593 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3594 case clang::BuiltinType::UnknownAny:
3595 case clang::BuiltinType::Void:
3596 set_dynamic_pointee_type(pointee_qual_type);
3602 case clang::Type::Record: {
3603 if (!check_cplusplus)
3605 clang::CXXRecordDecl *cxx_record_decl =
3606 pointee_qual_type->getAsCXXRecordDecl();
3607 if (!cxx_record_decl)
3611 if (cxx_record_decl->isCompleteDefinition())
3612 success = cxx_record_decl->isDynamicClass();
3614 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3615 std::optional<bool> is_dynamic =
3616 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3618 success = *is_dynamic;
3620 success = cxx_record_decl->isDynamicClass();
3626 set_dynamic_pointee_type(pointee_qual_type);
3630 case clang::Type::ObjCObject:
3631 case clang::Type::ObjCInterface:
3633 set_dynamic_pointee_type(pointee_qual_type);
3648 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3655 ->getTypeClass() == clang::Type::Typedef;
3672 if (
auto *record_decl =
3674 return record_decl->canPassInRegisters();
3680 return TypeSystemClangSupportsLanguage(language);
3683std::optional<std::string>
3686 return std::nullopt;
3689 if (qual_type.isNull())
3690 return std::nullopt;
3692 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3693 if (!cxx_record_decl)
3694 return std::nullopt;
3696 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3704 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3711 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3713 return tag_type->getDecl()->isEntityBeingDefined();
3724 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3725 if (class_type_ptr) {
3726 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3727 const clang::ObjCObjectPointerType *obj_pointer_type =
3728 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3729 if (obj_pointer_type ==
nullptr)
3730 class_type_ptr->
Clear();
3734 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3741 class_type_ptr->
Clear();
3768 {clang::Type::Typedef, clang::Type::Atomic});
3771 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3772 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3779 if (
auto *named_decl = qual_type->getAsTagDecl())
3791 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3792 printing_policy.SuppressTagKeyword =
true;
3793 printing_policy.SuppressScope =
false;
3794 printing_policy.SuppressUnwrittenScope =
true;
3795 printing_policy.SuppressInlineNamespace =
3796 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::All);
3797 return ConstString(qual_type.getAsString(printing_policy));
3806 if (pointee_or_element_clang_type)
3807 pointee_or_element_clang_type->
Clear();
3809 clang::QualType qual_type =
3812 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3813 switch (type_class) {
3814 case clang::Type::Attributed:
3815 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3818 pointee_or_element_clang_type);
3819 case clang::Type::BitInt: {
3820 uint32_t type_flags = eTypeIsScalar | eTypeIsInteger | eTypeHasValue;
3821 if (qual_type->isSignedIntegerType())
3822 type_flags |= eTypeIsSigned;
3826 case clang::Type::Builtin: {
3827 const clang::BuiltinType *builtin_type =
3828 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3830 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3831 switch (builtin_type->getKind()) {
3832 case clang::BuiltinType::ObjCId:
3833 case clang::BuiltinType::ObjCClass:
3834 if (pointee_or_element_clang_type)
3838 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3841 case clang::BuiltinType::ObjCSel:
3842 if (pointee_or_element_clang_type)
3845 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3848 case clang::BuiltinType::Bool:
3849 case clang::BuiltinType::Char_U:
3850 case clang::BuiltinType::UChar:
3851 case clang::BuiltinType::WChar_U:
3852 case clang::BuiltinType::Char16:
3853 case clang::BuiltinType::Char32:
3854 case clang::BuiltinType::UShort:
3855 case clang::BuiltinType::UInt:
3856 case clang::BuiltinType::ULong:
3857 case clang::BuiltinType::ULongLong:
3858 case clang::BuiltinType::UInt128:
3859 case clang::BuiltinType::Char_S:
3860 case clang::BuiltinType::SChar:
3861 case clang::BuiltinType::WChar_S:
3862 case clang::BuiltinType::Short:
3863 case clang::BuiltinType::Int:
3864 case clang::BuiltinType::Long:
3865 case clang::BuiltinType::LongLong:
3866 case clang::BuiltinType::Int128:
3867 case clang::BuiltinType::Float:
3868 case clang::BuiltinType::Double:
3869 case clang::BuiltinType::LongDouble:
3870 builtin_type_flags |= eTypeIsScalar;
3871 if (builtin_type->isInteger()) {
3872 builtin_type_flags |= eTypeIsInteger;
3873 if (builtin_type->isSignedInteger())
3874 builtin_type_flags |= eTypeIsSigned;
3875 }
else if (builtin_type->isFloatingPoint())
3876 builtin_type_flags |= eTypeIsFloat;
3881 return builtin_type_flags;
3884 case clang::Type::BlockPointer:
3885 if (pointee_or_element_clang_type)
3887 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3888 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3890 case clang::Type::Complex: {
3891 uint32_t complex_type_flags =
3892 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3893 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3894 qual_type->getCanonicalTypeInternal());
3896 clang::QualType complex_element_type(complex_type->getElementType());
3897 if (complex_element_type->isIntegerType())
3898 complex_type_flags |= eTypeIsInteger;
3899 else if (complex_element_type->isFloatingType())
3900 complex_type_flags |= eTypeIsFloat;
3902 return complex_type_flags;
3905 case clang::Type::ConstantArray:
3906 case clang::Type::DependentSizedArray:
3907 case clang::Type::IncompleteArray:
3908 case clang::Type::VariableArray:
3909 if (pointee_or_element_clang_type)
3911 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
3914 return eTypeHasChildren | eTypeIsArray;
3916 case clang::Type::DependentName:
3918 case clang::Type::DependentSizedExtVector:
3919 return eTypeHasChildren | eTypeIsVector;
3921 case clang::Type::Enum:
3922 if (pointee_or_element_clang_type)
3924 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
3926 ->getDefinitionOrSelf()
3929 return eTypeIsEnumeration | eTypeHasValue;
3931 case clang::Type::FunctionProto:
3932 return eTypeIsFuncPrototype | eTypeHasValue;
3933 case clang::Type::FunctionNoProto:
3934 return eTypeIsFuncPrototype | eTypeHasValue;
3935 case clang::Type::InjectedClassName:
3938 case clang::Type::LValueReference:
3939 case clang::Type::RValueReference:
3940 if (pointee_or_element_clang_type)
3943 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
3946 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
3948 case clang::Type::MemberPointer:
3949 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
3951 case clang::Type::ObjCObjectPointer:
3952 if (pointee_or_element_clang_type)
3954 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3955 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
3958 case clang::Type::ObjCObject:
3959 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
3960 case clang::Type::ObjCInterface:
3961 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
3963 case clang::Type::Pointer:
3964 if (pointee_or_element_clang_type)
3966 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3967 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
3969 case clang::Type::Record:
3970 if (qual_type->getAsCXXRecordDecl())
3971 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
3973 return eTypeHasChildren | eTypeIsStructUnion;
3975 case clang::Type::SubstTemplateTypeParm:
3976 return eTypeIsTemplate;
3977 case clang::Type::TemplateTypeParm:
3978 return eTypeIsTemplate;
3979 case clang::Type::TemplateSpecialization:
3980 return eTypeIsTemplate;
3982 case clang::Type::Typedef:
3983 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
3985 ->getUnderlyingType())
3987 case clang::Type::UnresolvedUsing:
3990 case clang::Type::ExtVector:
3991 case clang::Type::Vector: {
3992 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
3993 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
3994 qual_type->getCanonicalTypeInternal());
3998 QualType element_type = vector_type->getElementType();
3999 if (element_type.isNull())
4002 if (element_type->isIntegerType())
4003 vector_type_flags |= eTypeIsInteger;
4004 else if (element_type->isFloatingType())
4005 vector_type_flags |= eTypeIsFloat;
4006 return vector_type_flags;
4021 if (qual_type->isAnyPointerType()) {
4022 if (qual_type->isObjCObjectPointerType())
4024 if (qual_type->getPointeeCXXRecordDecl())
4027 clang::QualType pointee_type(qual_type->getPointeeType());
4028 if (pointee_type->getPointeeCXXRecordDecl())
4030 if (pointee_type->isObjCObjectOrInterfaceType())
4032 if (pointee_type->isObjCClassType())
4034 if (pointee_type.getTypePtr() ==
4038 if (qual_type->isObjCObjectOrInterfaceType())
4040 if (qual_type->getAsCXXRecordDecl())
4042 switch (qual_type->getTypeClass()) {
4045 case clang::Type::Builtin:
4046 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4048 case clang::BuiltinType::Void:
4049 case clang::BuiltinType::Bool:
4050 case clang::BuiltinType::Char_U:
4051 case clang::BuiltinType::UChar:
4052 case clang::BuiltinType::WChar_U:
4053 case clang::BuiltinType::Char16:
4054 case clang::BuiltinType::Char32:
4055 case clang::BuiltinType::UShort:
4056 case clang::BuiltinType::UInt:
4057 case clang::BuiltinType::ULong:
4058 case clang::BuiltinType::ULongLong:
4059 case clang::BuiltinType::UInt128:
4060 case clang::BuiltinType::Char_S:
4061 case clang::BuiltinType::SChar:
4062 case clang::BuiltinType::WChar_S:
4063 case clang::BuiltinType::Short:
4064 case clang::BuiltinType::Int:
4065 case clang::BuiltinType::Long:
4066 case clang::BuiltinType::LongLong:
4067 case clang::BuiltinType::Int128:
4068 case clang::BuiltinType::Float:
4069 case clang::BuiltinType::Double:
4070 case clang::BuiltinType::LongDouble:
4073 case clang::BuiltinType::NullPtr:
4076 case clang::BuiltinType::ObjCId:
4077 case clang::BuiltinType::ObjCClass:
4078 case clang::BuiltinType::ObjCSel:
4081 case clang::BuiltinType::Dependent:
4082 case clang::BuiltinType::Overload:
4083 case clang::BuiltinType::BoundMember:
4084 case clang::BuiltinType::UnknownAny:
4088 case clang::Type::Typedef:
4089 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4091 ->getUnderlyingType())
4101 return lldb::eTypeClassInvalid;
4103 clang::QualType qual_type =
4106 switch (qual_type->getTypeClass()) {
4107 case clang::Type::Atomic:
4108 case clang::Type::Auto:
4109 case clang::Type::CountAttributed:
4110 case clang::Type::Decltype:
4111 case clang::Type::Paren:
4112 case clang::Type::TypeOf:
4113 case clang::Type::TypeOfExpr:
4114 case clang::Type::Using:
4115 case clang::Type::PredefinedSugar:
4116 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4117 case clang::Type::LateParsedAttr:
4118 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
4119 "that is resolved before the AST is finalized.");
4120 case clang::Type::UnaryTransform:
4122 case clang::Type::FunctionNoProto:
4123 return lldb::eTypeClassFunction;
4124 case clang::Type::FunctionProto:
4125 return lldb::eTypeClassFunction;
4126 case clang::Type::IncompleteArray:
4127 return lldb::eTypeClassArray;
4128 case clang::Type::VariableArray:
4129 return lldb::eTypeClassArray;
4130 case clang::Type::ConstantArray:
4131 return lldb::eTypeClassArray;
4132 case clang::Type::DependentSizedArray:
4133 return lldb::eTypeClassArray;
4134 case clang::Type::ArrayParameter:
4135 return lldb::eTypeClassArray;
4136 case clang::Type::DependentSizedExtVector:
4137 return lldb::eTypeClassVector;
4138 case clang::Type::DependentVector:
4139 return lldb::eTypeClassVector;
4140 case clang::Type::ExtVector:
4141 return lldb::eTypeClassVector;
4142 case clang::Type::Vector:
4143 return lldb::eTypeClassVector;
4144 case clang::Type::Builtin:
4146 case clang::Type::BitInt:
4147 case clang::Type::DependentBitInt:
4148 case clang::Type::OverflowBehavior:
4149 return lldb::eTypeClassBuiltin;
4150 case clang::Type::ObjCObjectPointer:
4151 return lldb::eTypeClassObjCObjectPointer;
4152 case clang::Type::BlockPointer:
4153 return lldb::eTypeClassBlockPointer;
4154 case clang::Type::Pointer:
4155 return lldb::eTypeClassPointer;
4156 case clang::Type::LValueReference:
4157 return lldb::eTypeClassReference;
4158 case clang::Type::RValueReference:
4159 return lldb::eTypeClassReference;
4160 case clang::Type::MemberPointer:
4161 return lldb::eTypeClassMemberPointer;
4162 case clang::Type::Complex:
4163 if (qual_type->isComplexType())
4164 return lldb::eTypeClassComplexFloat;
4166 return lldb::eTypeClassComplexInteger;
4167 case clang::Type::ObjCObject:
4168 return lldb::eTypeClassObjCObject;
4169 case clang::Type::ObjCInterface:
4170 return lldb::eTypeClassObjCInterface;
4171 case clang::Type::Record: {
4172 const clang::RecordType *record_type =
4173 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4174 const clang::RecordDecl *record_decl = record_type->getDecl();
4175 if (record_decl->isUnion())
4176 return lldb::eTypeClassUnion;
4177 else if (record_decl->isStruct())
4178 return lldb::eTypeClassStruct;
4180 return lldb::eTypeClassClass;
4182 case clang::Type::Enum:
4183 return lldb::eTypeClassEnumeration;
4184 case clang::Type::Typedef:
4185 return lldb::eTypeClassTypedef;
4186 case clang::Type::UnresolvedUsing:
4189 case clang::Type::Attributed:
4190 case clang::Type::BTFTagAttributed:
4192 case clang::Type::TemplateTypeParm:
4194 case clang::Type::SubstTemplateTypeParm:
4196 case clang::Type::SubstTemplateTypeParmPack:
4198 case clang::Type::InjectedClassName:
4200 case clang::Type::DependentName:
4202 case clang::Type::PackExpansion:
4205 case clang::Type::TemplateSpecialization:
4207 case clang::Type::DeducedTemplateSpecialization:
4209 case clang::Type::Pipe:
4213 case clang::Type::Decayed:
4215 case clang::Type::Adjusted:
4217 case clang::Type::ObjCTypeParam:
4220 case clang::Type::DependentAddressSpace:
4222 case clang::Type::MacroQualified:
4226 case clang::Type::ConstantMatrix:
4227 case clang::Type::DependentSizedMatrix:
4231 case clang::Type::PackIndexing:
4234 case clang::Type::HLSLAttributedResource:
4236 case clang::Type::HLSLInlineSpirv:
4238 case clang::Type::SubstBuiltinTemplatePack:
4242 return lldb::eTypeClassOther;
4247 return GetQualType(type).getQualifiers().getCVRQualifiers();
4259 const clang::Type *array_eletype =
4260 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4265 return GetType(clang::QualType(array_eletype, 0));
4276 return GetType(ast_ctx.getConstantArrayType(
4277 qual_type, llvm::APInt(64, size),
nullptr,
4278 clang::ArraySizeModifier::Normal, 0));
4280 return GetType(ast_ctx.getIncompleteArrayType(
4281 qual_type, clang::ArraySizeModifier::Normal, 0));
4295 clang::QualType qual_type) {
4296 if (qual_type->isPointerType())
4297 qual_type = ast->getPointerType(
4299 else if (
const ConstantArrayType *arr =
4300 ast->getAsConstantArrayType(qual_type)) {
4301 qual_type = ast->getConstantArrayType(
4303 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4304 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4306 qual_type = qual_type.getUnqualifiedType();
4307 qual_type.removeLocalConst();
4308 qual_type.removeLocalRestrict();
4309 qual_type.removeLocalVolatile();
4331 const clang::FunctionProtoType *func =
4334 return func->getNumParams();
4342 const clang::FunctionProtoType *func =
4343 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4345 const uint32_t num_args = func->getNumParams();
4347 return GetType(func->getParamType(idx));
4357 const clang::FunctionProtoType *func =
4358 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4360 return GetType(func->getReturnType());
4367 size_t num_functions = 0;
4370 switch (qual_type->getTypeClass()) {
4371 case clang::Type::Record:
4373 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4374 num_functions = std::distance(cxx_record_decl->method_begin(),
4375 cxx_record_decl->method_end());
4378 case clang::Type::ObjCObjectPointer: {
4379 const clang::ObjCObjectPointerType *objc_class_type =
4380 qual_type->castAs<clang::ObjCObjectPointerType>();
4381 const clang::ObjCInterfaceType *objc_interface_type =
4382 objc_class_type->getInterfaceType();
4383 if (objc_interface_type &&
4385 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4386 clang::ObjCInterfaceDecl *class_interface_decl =
4387 objc_interface_type->getDecl();
4388 if (class_interface_decl) {
4389 num_functions = std::distance(class_interface_decl->meth_begin(),
4390 class_interface_decl->meth_end());
4396 case clang::Type::ObjCObject:
4397 case clang::Type::ObjCInterface:
4399 const clang::ObjCObjectType *objc_class_type =
4400 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4401 if (objc_class_type) {
4402 clang::ObjCInterfaceDecl *class_interface_decl =
4403 objc_class_type->getInterface();
4404 if (class_interface_decl)
4405 num_functions = std::distance(class_interface_decl->meth_begin(),
4406 class_interface_decl->meth_end());
4415 return num_functions;
4427 switch (qual_type->getTypeClass()) {
4428 case clang::Type::Record:
4430 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4431 auto method_iter = cxx_record_decl->method_begin();
4432 auto method_end = cxx_record_decl->method_end();
4434 static_cast<size_t>(std::distance(method_iter, method_end))) {
4435 std::advance(method_iter, idx);
4436 clang::CXXMethodDecl *cxx_method_decl =
4437 method_iter->getCanonicalDecl();
4438 if (cxx_method_decl) {
4439 name = cxx_method_decl->getDeclName().getAsString();
4440 if (cxx_method_decl->isStatic())
4442 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4444 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4448 clang_type =
GetType(cxx_method_decl->getType());
4456 case clang::Type::ObjCObjectPointer: {
4457 const clang::ObjCObjectPointerType *objc_class_type =
4458 qual_type->castAs<clang::ObjCObjectPointerType>();
4459 const clang::ObjCInterfaceType *objc_interface_type =
4460 objc_class_type->getInterfaceType();
4461 if (objc_interface_type &&
4463 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4464 clang::ObjCInterfaceDecl *class_interface_decl =
4465 objc_interface_type->getDecl();
4466 if (class_interface_decl) {
4467 auto method_iter = class_interface_decl->meth_begin();
4468 auto method_end = class_interface_decl->meth_end();
4470 static_cast<size_t>(std::distance(method_iter, method_end))) {
4471 std::advance(method_iter, idx);
4472 clang::ObjCMethodDecl *objc_method_decl =
4473 method_iter->getCanonicalDecl();
4474 if (objc_method_decl) {
4476 name = objc_method_decl->getSelector().getAsString();
4477 if (objc_method_decl->isClassMethod())
4488 case clang::Type::ObjCObject:
4489 case clang::Type::ObjCInterface:
4491 const clang::ObjCObjectType *objc_class_type =
4492 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4493 if (objc_class_type) {
4494 clang::ObjCInterfaceDecl *class_interface_decl =
4495 objc_class_type->getInterface();
4496 if (class_interface_decl) {
4497 auto method_iter = class_interface_decl->meth_begin();
4498 auto method_end = class_interface_decl->meth_end();
4500 static_cast<size_t>(std::distance(method_iter, method_end))) {
4501 std::advance(method_iter, idx);
4502 clang::ObjCMethodDecl *objc_method_decl =
4503 method_iter->getCanonicalDecl();
4504 if (objc_method_decl) {
4506 name = objc_method_decl->getSelector().getAsString();
4507 if (objc_method_decl->isClassMethod())
4540 return GetType(qual_type.getTypePtr()->getPointeeType());
4550 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4551 case clang::Type::ObjCObject:
4552 case clang::Type::ObjCInterface:
4599 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4600 clang::QualType result =
4601 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4611 result.addVolatile();
4621 result.addRestrict();
4630 if (type && typedef_name && typedef_name[0]) {
4634 clang::DeclContext *decl_ctx =
4639 clang::TypedefDecl *decl =
4640 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4641 decl->setDeclContext(decl_ctx);
4642 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4643 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4644 decl_ctx->addDecl(decl);
4647 clang::TagDecl *tdecl =
nullptr;
4648 if (!qual_type.isNull()) {
4649 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4650 tdecl = rt->getDecl();
4651 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4652 tdecl = et->getDecl();
4658 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4659 tdecl->setTypedefNameForAnonDecl(decl);
4661 decl->setAccess(clang::AS_public);
4664 NestedNameSpecifier Qualifier =
4665 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4667 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4675 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4678 return GetType(typedef_type->getDecl()->getUnderlyingType());
4691 const FunctionType::ExtInfo generic_ext_info(
4700 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4705const llvm::fltSemantics &
4708 const size_t bit_size = byte_size * 8;
4709 if (bit_size == ast.getTypeSize(ast.FloatTy))
4710 return ast.getFloatTypeSemantics(ast.FloatTy);
4711 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4712 return ast.getFloatTypeSemantics(ast.DoubleTy);
4714 bit_size == ast.getTypeSize(ast.Float128Ty))
4715 return ast.getFloatTypeSemantics(ast.Float128Ty);
4716 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4717 bit_size == llvm::APFloat::semanticsSizeInBits(
4718 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4719 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4720 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4721 return ast.getFloatTypeSemantics(ast.HalfTy);
4722 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4723 return ast.getFloatTypeSemantics(ast.Float128Ty);
4724 return llvm::APFloatBase::Bogus();
4727llvm::Expected<uint64_t>
4730 assert(qual_type->isObjCObjectOrInterfaceType());
4735 if (std::optional<uint64_t> bit_size =
4736 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4740 static bool g_printed =
false;
4745 llvm::outs() <<
"warning: trying to determine the size of type ";
4747 llvm::outs() <<
"without a valid ExecutionContext. this is not "
4748 "reliable. please file a bug against LLDB.\n";
4749 llvm::outs() <<
"backtrace:\n";
4750 llvm::sys::PrintStackTrace(llvm::outs());
4751 llvm::outs() <<
"\n";
4760llvm::Expected<uint64_t>
4763 const bool base_name_only =
true;
4765 return llvm::createStringError(
4766 "could not complete type %s",
4770 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4771 switch (type_class) {
4772 case clang::Type::ConstantArray:
4773 case clang::Type::FunctionProto:
4774 case clang::Type::Record:
4776 case clang::Type::ObjCInterface:
4777 case clang::Type::ObjCObject:
4779 case clang::Type::IncompleteArray: {
4780 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4783 qual_type->getArrayElementTypeNoTypeQual()
4784 ->getCanonicalTypeUnqualified());
4789 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4793 return llvm::createStringError(
4794 "could not get size of type %s",
4798std::optional<size_t>
4812 switch (qual_type->getTypeClass()) {
4813 case clang::Type::Atomic:
4814 case clang::Type::Auto:
4815 case clang::Type::CountAttributed:
4816 case clang::Type::Decltype:
4817 case clang::Type::Paren:
4818 case clang::Type::Typedef:
4819 case clang::Type::TypeOf:
4820 case clang::Type::TypeOfExpr:
4821 case clang::Type::Using:
4822 case clang::Type::PredefinedSugar:
4823 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4824 case clang::Type::LateParsedAttr:
4825 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
4826 "that is resolved before the AST is finalized.");
4828 case clang::Type::UnaryTransform:
4831 case clang::Type::FunctionNoProto:
4832 case clang::Type::FunctionProto:
4835 case clang::Type::IncompleteArray:
4836 case clang::Type::VariableArray:
4837 case clang::Type::ArrayParameter:
4840 case clang::Type::ConstantArray:
4843 case clang::Type::DependentVector:
4844 case clang::Type::ExtVector:
4845 case clang::Type::Vector:
4848 case clang::Type::BitInt:
4849 case clang::Type::DependentBitInt:
4850 case clang::Type::OverflowBehavior:
4854 case clang::Type::Builtin:
4855 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4856 case clang::BuiltinType::Void:
4859 case clang::BuiltinType::Char_S:
4860 case clang::BuiltinType::SChar:
4861 case clang::BuiltinType::WChar_S:
4862 case clang::BuiltinType::Short:
4863 case clang::BuiltinType::Int:
4864 case clang::BuiltinType::Long:
4865 case clang::BuiltinType::LongLong:
4866 case clang::BuiltinType::Int128:
4869 case clang::BuiltinType::Bool:
4870 case clang::BuiltinType::Char_U:
4871 case clang::BuiltinType::UChar:
4872 case clang::BuiltinType::WChar_U:
4873 case clang::BuiltinType::Char8:
4874 case clang::BuiltinType::Char16:
4875 case clang::BuiltinType::Char32:
4876 case clang::BuiltinType::UShort:
4877 case clang::BuiltinType::UInt:
4878 case clang::BuiltinType::ULong:
4879 case clang::BuiltinType::ULongLong:
4880 case clang::BuiltinType::UInt128:
4884 case clang::BuiltinType::ShortAccum:
4885 case clang::BuiltinType::Accum:
4886 case clang::BuiltinType::LongAccum:
4887 case clang::BuiltinType::UShortAccum:
4888 case clang::BuiltinType::UAccum:
4889 case clang::BuiltinType::ULongAccum:
4890 case clang::BuiltinType::ShortFract:
4891 case clang::BuiltinType::Fract:
4892 case clang::BuiltinType::LongFract:
4893 case clang::BuiltinType::UShortFract:
4894 case clang::BuiltinType::UFract:
4895 case clang::BuiltinType::ULongFract:
4896 case clang::BuiltinType::SatShortAccum:
4897 case clang::BuiltinType::SatAccum:
4898 case clang::BuiltinType::SatLongAccum:
4899 case clang::BuiltinType::SatUShortAccum:
4900 case clang::BuiltinType::SatUAccum:
4901 case clang::BuiltinType::SatULongAccum:
4902 case clang::BuiltinType::SatShortFract:
4903 case clang::BuiltinType::SatFract:
4904 case clang::BuiltinType::SatLongFract:
4905 case clang::BuiltinType::SatUShortFract:
4906 case clang::BuiltinType::SatUFract:
4907 case clang::BuiltinType::SatULongFract:
4910 case clang::BuiltinType::Half:
4911 case clang::BuiltinType::Float:
4912 case clang::BuiltinType::Float16:
4913 case clang::BuiltinType::Float128:
4914 case clang::BuiltinType::Double:
4915 case clang::BuiltinType::LongDouble:
4916 case clang::BuiltinType::BFloat16:
4917 case clang::BuiltinType::Ibm128:
4920 case clang::BuiltinType::ObjCClass:
4921 case clang::BuiltinType::ObjCId:
4922 case clang::BuiltinType::ObjCSel:
4925 case clang::BuiltinType::NullPtr:
4928 case clang::BuiltinType::Kind::ARCUnbridgedCast:
4929 case clang::BuiltinType::Kind::BoundMember:
4930 case clang::BuiltinType::Kind::BuiltinFn:
4931 case clang::BuiltinType::Kind::Dependent:
4932 case clang::BuiltinType::Kind::OCLClkEvent:
4933 case clang::BuiltinType::Kind::OCLEvent:
4934 case clang::BuiltinType::Kind::OCLImage1dRO:
4935 case clang::BuiltinType::Kind::OCLImage1dWO:
4936 case clang::BuiltinType::Kind::OCLImage1dRW:
4937 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
4938 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
4939 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
4940 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
4941 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
4942 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
4943 case clang::BuiltinType::Kind::OCLImage2dRO:
4944 case clang::BuiltinType::Kind::OCLImage2dWO:
4945 case clang::BuiltinType::Kind::OCLImage2dRW:
4946 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
4947 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
4948 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
4949 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
4950 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
4951 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
4952 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
4953 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
4954 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
4955 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
4956 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
4957 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
4958 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
4959 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
4960 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
4961 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
4962 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
4963 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
4964 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
4965 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
4966 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
4967 case clang::BuiltinType::Kind::OCLImage3dRO:
4968 case clang::BuiltinType::Kind::OCLImage3dWO:
4969 case clang::BuiltinType::Kind::OCLImage3dRW:
4970 case clang::BuiltinType::Kind::OCLQueue:
4971 case clang::BuiltinType::Kind::OCLReserveID:
4972 case clang::BuiltinType::Kind::OCLSampler:
4973 case clang::BuiltinType::Kind::HLSLResource:
4974 case clang::BuiltinType::Kind::ArraySection:
4975 case clang::BuiltinType::Kind::OMPArrayShaping:
4976 case clang::BuiltinType::Kind::OMPIterator:
4977 case clang::BuiltinType::Kind::Overload:
4978 case clang::BuiltinType::Kind::PseudoObject:
4979 case clang::BuiltinType::Kind::UnknownAny:
4982 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
4983 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
4984 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
4985 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
4986 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
4987 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
4988 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
4989 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
4990 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
4991 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
4992 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
4993 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
4997 case clang::BuiltinType::VectorPair:
4998 case clang::BuiltinType::VectorQuad:
4999 case clang::BuiltinType::DMR1024:
5000 case clang::BuiltinType::DMR2048:
5004#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5005#include "clang/Basic/AArch64ACLETypes.def"
5009#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5010#include "clang/Basic/RISCVVTypes.def"
5014 case clang::BuiltinType::WasmExternRef:
5017 case clang::BuiltinType::IncompleteMatrixIdx:
5020 case clang::BuiltinType::UnresolvedTemplate:
5024#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
5025 case clang::BuiltinType::Id:
5026#include "clang/Basic/AMDGPUTypes.def"
5030#define SPIRV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5031#include "clang/Basic/SPIRVTypes.def"
5037 case clang::Type::ObjCObjectPointer:
5038 case clang::Type::BlockPointer:
5039 case clang::Type::Pointer:
5040 case clang::Type::LValueReference:
5041 case clang::Type::RValueReference:
5042 case clang::Type::MemberPointer:
5044 case clang::Type::Complex: {
5046 if (qual_type->isComplexType())
5049 const clang::ComplexType *complex_type =
5050 qual_type->getAsComplexIntegerType();
5059 case clang::Type::ObjCInterface:
5061 case clang::Type::Record:
5063 case clang::Type::Enum:
5064 return qual_type->isUnsignedIntegerOrEnumerationType()
5067 case clang::Type::DependentSizedArray:
5068 case clang::Type::DependentSizedExtVector:
5069 case clang::Type::UnresolvedUsing:
5070 case clang::Type::Attributed:
5071 case clang::Type::BTFTagAttributed:
5072 case clang::Type::TemplateTypeParm:
5073 case clang::Type::SubstTemplateTypeParm:
5074 case clang::Type::SubstTemplateTypeParmPack:
5075 case clang::Type::InjectedClassName:
5076 case clang::Type::DependentName:
5077 case clang::Type::PackExpansion:
5078 case clang::Type::ObjCObject:
5080 case clang::Type::TemplateSpecialization:
5081 case clang::Type::DeducedTemplateSpecialization:
5082 case clang::Type::Adjusted:
5083 case clang::Type::Pipe:
5087 case clang::Type::Decayed:
5089 case clang::Type::ObjCTypeParam:
5092 case clang::Type::DependentAddressSpace:
5094 case clang::Type::MacroQualified:
5097 case clang::Type::ConstantMatrix:
5098 case clang::Type::DependentSizedMatrix:
5102 case clang::Type::PackIndexing:
5105 case clang::Type::HLSLAttributedResource:
5107 case clang::Type::HLSLInlineSpirv:
5109 case clang::Type::SubstBuiltinTemplatePack:
5122 switch (qual_type->getTypeClass()) {
5123 case clang::Type::Atomic:
5124 case clang::Type::Auto:
5125 case clang::Type::CountAttributed:
5126 case clang::Type::Decltype:
5127 case clang::Type::Paren:
5128 case clang::Type::Typedef:
5129 case clang::Type::TypeOf:
5130 case clang::Type::TypeOfExpr:
5131 case clang::Type::Using:
5132 case clang::Type::PredefinedSugar:
5133 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5134 case clang::Type::LateParsedAttr:
5135 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
5136 "that is resolved before the AST is finalized.");
5137 case clang::Type::UnaryTransform:
5140 case clang::Type::FunctionNoProto:
5141 case clang::Type::FunctionProto:
5144 case clang::Type::IncompleteArray:
5145 case clang::Type::VariableArray:
5146 case clang::Type::ArrayParameter:
5149 case clang::Type::ConstantArray:
5152 case clang::Type::DependentVector:
5153 case clang::Type::ExtVector:
5154 case clang::Type::Vector:
5157 case clang::Type::BitInt:
5158 case clang::Type::DependentBitInt:
5159 case clang::Type::OverflowBehavior:
5163 case clang::Type::Builtin:
5164 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5165 case clang::BuiltinType::UnknownAny:
5166 case clang::BuiltinType::Void:
5167 case clang::BuiltinType::BoundMember:
5170 case clang::BuiltinType::Bool:
5172 case clang::BuiltinType::Char_S:
5173 case clang::BuiltinType::SChar:
5174 case clang::BuiltinType::WChar_S:
5175 case clang::BuiltinType::Char_U:
5176 case clang::BuiltinType::UChar:
5177 case clang::BuiltinType::WChar_U:
5179 case clang::BuiltinType::Char8:
5181 case clang::BuiltinType::Char16:
5183 case clang::BuiltinType::Char32:
5185 case clang::BuiltinType::UShort:
5187 case clang::BuiltinType::Short:
5189 case clang::BuiltinType::UInt:
5191 case clang::BuiltinType::Int:
5193 case clang::BuiltinType::ULong:
5195 case clang::BuiltinType::Long:
5197 case clang::BuiltinType::ULongLong:
5199 case clang::BuiltinType::LongLong:
5201 case clang::BuiltinType::UInt128:
5203 case clang::BuiltinType::Int128:
5205 case clang::BuiltinType::Half:
5206 case clang::BuiltinType::Float:
5207 case clang::BuiltinType::Double:
5208 case clang::BuiltinType::LongDouble:
5210 case clang::BuiltinType::Float128:
5216 case clang::Type::ObjCObjectPointer:
5218 case clang::Type::BlockPointer:
5220 case clang::Type::Pointer:
5222 case clang::Type::LValueReference:
5223 case clang::Type::RValueReference:
5225 case clang::Type::MemberPointer:
5227 case clang::Type::Complex: {
5228 if (qual_type->isComplexType())
5233 case clang::Type::ObjCInterface:
5235 case clang::Type::Record:
5237 case clang::Type::Enum:
5239 case clang::Type::DependentSizedArray:
5240 case clang::Type::DependentSizedExtVector:
5241 case clang::Type::UnresolvedUsing:
5242 case clang::Type::Attributed:
5243 case clang::Type::BTFTagAttributed:
5244 case clang::Type::TemplateTypeParm:
5245 case clang::Type::SubstTemplateTypeParm:
5246 case clang::Type::SubstTemplateTypeParmPack:
5247 case clang::Type::InjectedClassName:
5248 case clang::Type::DependentName:
5249 case clang::Type::PackExpansion:
5250 case clang::Type::ObjCObject:
5252 case clang::Type::TemplateSpecialization:
5253 case clang::Type::DeducedTemplateSpecialization:
5254 case clang::Type::Adjusted:
5255 case clang::Type::Pipe:
5259 case clang::Type::Decayed:
5261 case clang::Type::ObjCTypeParam:
5264 case clang::Type::DependentAddressSpace:
5266 case clang::Type::MacroQualified:
5270 case clang::Type::ConstantMatrix:
5271 case clang::Type::DependentSizedMatrix:
5275 case clang::Type::PackIndexing:
5278 case clang::Type::HLSLAttributedResource:
5280 case clang::Type::HLSLInlineSpirv:
5282 case clang::Type::SubstBuiltinTemplatePack:
5290 while (class_interface_decl) {
5291 if (class_interface_decl->ivar_size() > 0)
5294 class_interface_decl = class_interface_decl->getSuperClass();
5299static std::optional<SymbolFile::ArrayInfo>
5301 clang::QualType qual_type,
5303 if (qual_type->isIncompleteArrayType())
5304 if (std::optional<ClangASTMetadata> metadata =
5308 return std::nullopt;
5311llvm::Expected<uint32_t>
5313 bool omit_empty_base_classes,
5316 return llvm::createStringError(
"invalid clang type");
5318 uint32_t num_children = 0;
5320 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5321 switch (type_class) {
5322 case clang::Type::Builtin:
5323 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5324 case clang::BuiltinType::ObjCId:
5325 case clang::BuiltinType::ObjCClass:
5334 case clang::Type::Complex:
5336 case clang::Type::Record:
5338 const clang::RecordType *record_type =
5339 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5340 const clang::RecordDecl *record_decl =
5341 record_type->getDecl()->getDefinitionOrSelf();
5342 const clang::CXXRecordDecl *cxx_record_decl =
5343 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5347 num_children += std::distance(record_decl->field_begin(),
5348 record_decl->field_end());
5350 return llvm::createStringError(
5353 case clang::Type::ObjCObject:
5354 case clang::Type::ObjCInterface:
5356 const clang::ObjCObjectType *objc_class_type =
5357 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5358 assert(objc_class_type);
5359 if (objc_class_type) {
5360 clang::ObjCInterfaceDecl *class_interface_decl =
5361 objc_class_type->getInterface();
5363 if (class_interface_decl) {
5365 clang::ObjCInterfaceDecl *superclass_interface_decl =
5366 class_interface_decl->getSuperClass();
5367 if (superclass_interface_decl) {
5368 if (omit_empty_base_classes) {
5375 num_children += class_interface_decl->ivar_size();
5381 case clang::Type::LValueReference:
5382 case clang::Type::RValueReference:
5383 case clang::Type::ObjCObjectPointer: {
5386 uint32_t num_pointee_children = 0;
5388 auto num_children_or_err =
5389 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5390 if (!num_children_or_err)
5391 return num_children_or_err;
5392 num_pointee_children = *num_children_or_err;
5395 if (num_pointee_children == 0)
5398 num_children = num_pointee_children;
5401 case clang::Type::Vector:
5402 case clang::Type::ExtVector:
5404 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5407 case clang::Type::ConstantArray:
5408 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5412 case clang::Type::IncompleteArray:
5413 if (
auto array_info =
5416 num_children = array_info->element_orders.size()
5417 ? array_info->element_orders.back().value_or(0)
5421 case clang::Type::Pointer: {
5422 const clang::PointerType *pointer_type =
5423 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5424 clang::QualType pointee_type(pointer_type->getPointeeType());
5426 uint32_t num_pointee_children = 0;
5428 auto num_children_or_err =
5429 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5430 if (!num_children_or_err)
5431 return num_children_or_err;
5432 num_pointee_children = *num_children_or_err;
5434 if (num_pointee_children == 0) {
5439 num_children = num_pointee_children;
5445 return num_children;
5452 if (name_ref.consume_front(
"unsigned _BitInt(") ||
5453 name_ref.consume_front(
"_BitInt(")) {
5455 if (name_ref.consumeInteger(10, bit_size))
5458 if (!name_ref.consume_front(
")"))
5462 name.
GetStringRef().starts_with(
"unsigned"), bit_size));
5471 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5472 if (type_class == clang::Type::Builtin) {
5473 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5474 case clang::BuiltinType::Void:
5476 case clang::BuiltinType::Bool:
5478 case clang::BuiltinType::Char_S:
5480 case clang::BuiltinType::Char_U:
5482 case clang::BuiltinType::Char8:
5484 case clang::BuiltinType::Char16:
5486 case clang::BuiltinType::Char32:
5488 case clang::BuiltinType::UChar:
5490 case clang::BuiltinType::SChar:
5492 case clang::BuiltinType::WChar_S:
5494 case clang::BuiltinType::WChar_U:
5496 case clang::BuiltinType::Short:
5498 case clang::BuiltinType::UShort:
5500 case clang::BuiltinType::Int:
5502 case clang::BuiltinType::UInt:
5504 case clang::BuiltinType::Long:
5506 case clang::BuiltinType::ULong:
5508 case clang::BuiltinType::LongLong:
5510 case clang::BuiltinType::ULongLong:
5512 case clang::BuiltinType::Int128:
5514 case clang::BuiltinType::UInt128:
5517 case clang::BuiltinType::Half:
5519 case clang::BuiltinType::Float:
5521 case clang::BuiltinType::Double:
5523 case clang::BuiltinType::LongDouble:
5525 case clang::BuiltinType::Float128:
5528 case clang::BuiltinType::NullPtr:
5530 case clang::BuiltinType::ObjCId:
5532 case clang::BuiltinType::ObjCClass:
5534 case clang::BuiltinType::ObjCSel:
5548 const llvm::APSInt &value)>
const &callback) {
5549 const clang::EnumType *enum_type =
5552 const clang::EnumDecl *enum_decl =
5553 enum_type->getDecl()->getDefinitionOrSelf();
5557 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5558 for (enum_pos = enum_decl->enumerator_begin(),
5559 enum_end_pos = enum_decl->enumerator_end();
5560 enum_pos != enum_end_pos; ++enum_pos) {
5562 if (!callback(integer_type, name, enum_pos->getInitVal()))
5569#pragma mark Aggregate Types
5577 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5578 switch (type_class) {
5579 case clang::Type::Record:
5581 const clang::RecordType *record_type =
5582 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5584 clang::RecordDecl *record_decl =
5585 record_type->getDecl()->getDefinition();
5587 count = std::distance(record_decl->field_begin(),
5588 record_decl->field_end());
5594 case clang::Type::ObjCObjectPointer: {
5595 const clang::ObjCObjectPointerType *objc_class_type =
5596 qual_type->castAs<clang::ObjCObjectPointerType>();
5597 const clang::ObjCInterfaceType *objc_interface_type =
5598 objc_class_type->getInterfaceType();
5599 if (objc_interface_type &&
5601 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5602 clang::ObjCInterfaceDecl *class_interface_decl =
5603 objc_interface_type->getDecl();
5604 if (class_interface_decl) {
5605 count = class_interface_decl->ivar_size();
5611 case clang::Type::ObjCObject:
5612 case clang::Type::ObjCInterface:
5614 const clang::ObjCObjectType *objc_class_type =
5615 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5616 if (objc_class_type) {
5617 clang::ObjCInterfaceDecl *class_interface_decl =
5618 objc_class_type->getInterface();
5620 if (class_interface_decl)
5621 count = class_interface_decl->ivar_size();
5634 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5635 std::string &name, uint64_t *bit_offset_ptr,
5636 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5637 if (class_interface_decl) {
5638 if (idx < (class_interface_decl->ivar_size())) {
5639 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5640 ivar_end = class_interface_decl->ivar_end();
5641 uint32_t ivar_idx = 0;
5643 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5644 ++ivar_pos, ++ivar_idx) {
5645 if (ivar_idx == idx) {
5646 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5648 clang::QualType ivar_qual_type(ivar_decl->getType());
5650 name.assign(ivar_decl->getNameAsString());
5652 if (bit_offset_ptr) {
5653 const clang::ASTRecordLayout &interface_layout =
5654 ast->getASTObjCInterfaceLayout(class_interface_decl);
5655 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5658 const bool is_bitfield = ivar_pos->isBitField();
5660 if (bitfield_bit_size_ptr) {
5661 *bitfield_bit_size_ptr = 0;
5663 if (is_bitfield && ast) {
5664 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5665 clang::Expr::EvalResult result;
5666 if (bitfield_bit_size_expr &&
5667 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5668 llvm::APSInt bitfield_apsint = result.Val.getInt();
5669 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5673 if (is_bitfield_ptr)
5674 *is_bitfield_ptr = is_bitfield;
5676 return ivar_qual_type.getAsOpaquePtr();
5685 size_t idx, std::string &name,
5686 uint64_t *bit_offset_ptr,
5687 uint32_t *bitfield_bit_size_ptr,
5688 bool *is_bitfield_ptr) {
5693 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5694 switch (type_class) {
5695 case clang::Type::Record:
5697 const clang::RecordType *record_type =
5698 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5699 const clang::RecordDecl *record_decl =
5700 record_type->getDecl()->getDefinitionOrSelf();
5701 uint32_t field_idx = 0;
5702 clang::RecordDecl::field_iterator field, field_end;
5703 for (field = record_decl->field_begin(),
5704 field_end = record_decl->field_end();
5705 field != field_end; ++field, ++field_idx) {
5706 if (idx == field_idx) {
5709 name.assign(field->getNameAsString());
5713 if (bit_offset_ptr) {
5714 const clang::ASTRecordLayout &record_layout =
5716 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5719 const bool is_bitfield = field->isBitField();
5721 if (bitfield_bit_size_ptr) {
5722 *bitfield_bit_size_ptr = 0;
5725 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5726 clang::Expr::EvalResult result;
5727 if (bitfield_bit_size_expr &&
5728 bitfield_bit_size_expr->EvaluateAsInt(result,
5730 llvm::APSInt bitfield_apsint = result.Val.getInt();
5731 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5735 if (is_bitfield_ptr)
5736 *is_bitfield_ptr = is_bitfield;
5738 return GetType(field->getType());
5744 case clang::Type::ObjCObjectPointer: {
5745 const clang::ObjCObjectPointerType *objc_class_type =
5746 qual_type->castAs<clang::ObjCObjectPointerType>();
5747 const clang::ObjCInterfaceType *objc_interface_type =
5748 objc_class_type->getInterfaceType();
5749 if (objc_interface_type &&
5751 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5752 clang::ObjCInterfaceDecl *class_interface_decl =
5753 objc_interface_type->getDecl();
5754 if (class_interface_decl) {
5758 name, bit_offset_ptr, bitfield_bit_size_ptr,
5765 case clang::Type::ObjCObject:
5766 case clang::Type::ObjCInterface:
5768 const clang::ObjCObjectType *objc_class_type =
5769 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5770 assert(objc_class_type);
5771 if (objc_class_type) {
5772 clang::ObjCInterfaceDecl *class_interface_decl =
5773 objc_class_type->getInterface();
5777 name, bit_offset_ptr, bitfield_bit_size_ptr,
5793 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5794 switch (type_class) {
5795 case clang::Type::Record:
5797 const clang::CXXRecordDecl *cxx_record_decl =
5798 qual_type->getAsCXXRecordDecl();
5799 if (cxx_record_decl)
5800 count = cxx_record_decl->getNumBases();
5804 case clang::Type::ObjCObjectPointer:
5808 case clang::Type::ObjCObject:
5810 const clang::ObjCObjectType *objc_class_type =
5811 qual_type->getAsObjCQualifiedInterfaceType();
5812 if (objc_class_type) {
5813 clang::ObjCInterfaceDecl *class_interface_decl =
5814 objc_class_type->getInterface();
5816 if (class_interface_decl && class_interface_decl->getSuperClass())
5821 case clang::Type::ObjCInterface:
5823 const clang::ObjCInterfaceType *objc_interface_type =
5824 qual_type->getAs<clang::ObjCInterfaceType>();
5825 if (objc_interface_type) {
5826 clang::ObjCInterfaceDecl *class_interface_decl =
5827 objc_interface_type->getInterface();
5829 if (class_interface_decl && class_interface_decl->getSuperClass())
5845 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5846 switch (type_class) {
5847 case clang::Type::Record:
5849 const clang::CXXRecordDecl *cxx_record_decl =
5850 qual_type->getAsCXXRecordDecl();
5851 if (cxx_record_decl)
5852 count = cxx_record_decl->getNumVBases();
5865 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5866 switch (type_class) {
5867 case clang::Type::Record:
5869 const clang::CXXRecordDecl *cxx_record_decl =
5870 qual_type->getAsCXXRecordDecl();
5871 if (cxx_record_decl) {
5872 uint32_t curr_idx = 0;
5873 clang::CXXRecordDecl::base_class_const_iterator base_class,
5875 for (base_class = cxx_record_decl->bases_begin(),
5876 base_class_end = cxx_record_decl->bases_end();
5877 base_class != base_class_end; ++base_class, ++curr_idx) {
5878 if (curr_idx == idx) {
5879 if (bit_offset_ptr) {
5880 const clang::ASTRecordLayout &record_layout =
5882 const clang::CXXRecordDecl *base_class_decl =
5883 llvm::cast<clang::CXXRecordDecl>(
5884 base_class->getType()
5885 ->castAs<clang::RecordType>()
5887 if (base_class->isVirtual())
5889 record_layout.getVBaseClassOffset(base_class_decl)
5894 record_layout.getBaseClassOffset(base_class_decl)
5898 return GetType(base_class->getType());
5905 case clang::Type::ObjCObjectPointer:
5908 case clang::Type::ObjCObject:
5910 const clang::ObjCObjectType *objc_class_type =
5911 qual_type->getAsObjCQualifiedInterfaceType();
5912 if (objc_class_type) {
5913 clang::ObjCInterfaceDecl *class_interface_decl =
5914 objc_class_type->getInterface();
5916 if (class_interface_decl) {
5917 clang::ObjCInterfaceDecl *superclass_interface_decl =
5918 class_interface_decl->getSuperClass();
5919 if (superclass_interface_decl) {
5921 *bit_offset_ptr = 0;
5923 superclass_interface_decl));
5929 case clang::Type::ObjCInterface:
5931 const clang::ObjCObjectType *objc_interface_type =
5932 qual_type->getAs<clang::ObjCInterfaceType>();
5933 if (objc_interface_type) {
5934 clang::ObjCInterfaceDecl *class_interface_decl =
5935 objc_interface_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));
5960 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5961 switch (type_class) {
5962 case clang::Type::Record:
5964 const clang::CXXRecordDecl *cxx_record_decl =
5965 qual_type->getAsCXXRecordDecl();
5966 if (cxx_record_decl) {
5967 uint32_t curr_idx = 0;
5968 clang::CXXRecordDecl::base_class_const_iterator base_class,
5970 for (base_class = cxx_record_decl->vbases_begin(),
5971 base_class_end = cxx_record_decl->vbases_end();
5972 base_class != base_class_end; ++base_class, ++curr_idx) {
5973 if (curr_idx == idx) {
5974 if (bit_offset_ptr) {
5975 const clang::ASTRecordLayout &record_layout =
5977 const clang::CXXRecordDecl *base_class_decl =
5978 llvm::cast<clang::CXXRecordDecl>(
5979 base_class->getType()
5980 ->castAs<clang::RecordType>()
5983 record_layout.getVBaseClassOffset(base_class_decl)
5987 return GetType(base_class->getType());
6002 llvm::StringRef name) {
6004 switch (qual_type->getTypeClass()) {
6005 case clang::Type::Record: {
6009 const clang::RecordType *record_type =
6010 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6011 const clang::RecordDecl *record_decl =
6012 record_type->getDecl()->getDefinitionOrSelf();
6014 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
6015 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
6016 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
6017 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
6041 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6042 switch (type_class) {
6043 case clang::Type::Builtin:
6044 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6045 case clang::BuiltinType::UnknownAny:
6046 case clang::BuiltinType::Void:
6047 case clang::BuiltinType::NullPtr:
6048 case clang::BuiltinType::OCLEvent:
6049 case clang::BuiltinType::OCLImage1dRO:
6050 case clang::BuiltinType::OCLImage1dWO:
6051 case clang::BuiltinType::OCLImage1dRW:
6052 case clang::BuiltinType::OCLImage1dArrayRO:
6053 case clang::BuiltinType::OCLImage1dArrayWO:
6054 case clang::BuiltinType::OCLImage1dArrayRW:
6055 case clang::BuiltinType::OCLImage1dBufferRO:
6056 case clang::BuiltinType::OCLImage1dBufferWO:
6057 case clang::BuiltinType::OCLImage1dBufferRW:
6058 case clang::BuiltinType::OCLImage2dRO:
6059 case clang::BuiltinType::OCLImage2dWO:
6060 case clang::BuiltinType::OCLImage2dRW:
6061 case clang::BuiltinType::OCLImage2dArrayRO:
6062 case clang::BuiltinType::OCLImage2dArrayWO:
6063 case clang::BuiltinType::OCLImage2dArrayRW:
6064 case clang::BuiltinType::OCLImage3dRO:
6065 case clang::BuiltinType::OCLImage3dWO:
6066 case clang::BuiltinType::OCLImage3dRW:
6067 case clang::BuiltinType::OCLSampler:
6068 case clang::BuiltinType::HLSLResource:
6070 case clang::BuiltinType::Bool:
6071 case clang::BuiltinType::Char_U:
6072 case clang::BuiltinType::UChar:
6073 case clang::BuiltinType::WChar_U:
6074 case clang::BuiltinType::Char16:
6075 case clang::BuiltinType::Char32:
6076 case clang::BuiltinType::UShort:
6077 case clang::BuiltinType::UInt:
6078 case clang::BuiltinType::ULong:
6079 case clang::BuiltinType::ULongLong:
6080 case clang::BuiltinType::UInt128:
6081 case clang::BuiltinType::Char_S:
6082 case clang::BuiltinType::SChar:
6083 case clang::BuiltinType::WChar_S:
6084 case clang::BuiltinType::Short:
6085 case clang::BuiltinType::Int:
6086 case clang::BuiltinType::Long:
6087 case clang::BuiltinType::LongLong:
6088 case clang::BuiltinType::Int128:
6089 case clang::BuiltinType::Float:
6090 case clang::BuiltinType::Double:
6091 case clang::BuiltinType::LongDouble:
6092 case clang::BuiltinType::Float128:
6093 case clang::BuiltinType::Dependent:
6094 case clang::BuiltinType::Overload:
6095 case clang::BuiltinType::ObjCId:
6096 case clang::BuiltinType::ObjCClass:
6097 case clang::BuiltinType::ObjCSel:
6098 case clang::BuiltinType::BoundMember:
6099 case clang::BuiltinType::Half:
6100 case clang::BuiltinType::ARCUnbridgedCast:
6101 case clang::BuiltinType::PseudoObject:
6102 case clang::BuiltinType::BuiltinFn:
6103 case clang::BuiltinType::ArraySection:
6110 case clang::Type::Complex:
6112 case clang::Type::Pointer:
6114 case clang::Type::BlockPointer:
6117 case clang::Type::LValueReference:
6119 case clang::Type::RValueReference:
6121 case clang::Type::MemberPointer:
6123 case clang::Type::ConstantArray:
6125 case clang::Type::IncompleteArray:
6127 case clang::Type::VariableArray:
6129 case clang::Type::DependentSizedArray:
6131 case clang::Type::DependentSizedExtVector:
6133 case clang::Type::Vector:
6135 case clang::Type::ExtVector:
6137 case clang::Type::FunctionProto:
6139 case clang::Type::FunctionNoProto:
6141 case clang::Type::UnresolvedUsing:
6143 case clang::Type::Record:
6145 case clang::Type::Enum:
6147 case clang::Type::TemplateTypeParm:
6149 case clang::Type::SubstTemplateTypeParm:
6151 case clang::Type::TemplateSpecialization:
6153 case clang::Type::InjectedClassName:
6155 case clang::Type::DependentName:
6157 case clang::Type::ObjCObject:
6159 case clang::Type::ObjCInterface:
6161 case clang::Type::ObjCObjectPointer:
6171 std::string &deref_name, uint32_t &deref_byte_size,
6172 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6176 return llvm::createStringError(
"not a pointer, reference or array type");
6177 uint32_t child_bitfield_bit_size = 0;
6178 uint32_t child_bitfield_bit_offset = 0;
6179 bool child_is_base_class;
6180 bool child_is_deref_of_parent;
6182 type, exe_ctx, 0,
false,
true,
false, deref_name, deref_byte_size,
6183 deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6184 child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
6189 bool transparent_pointers,
bool omit_empty_base_classes,
6190 bool ignore_array_bounds, std::string &child_name,
6191 uint32_t &child_byte_size, int32_t &child_byte_offset,
6192 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6193 bool &child_is_base_class,
bool &child_is_deref_of_parent,
6196 return llvm::createStringError(
"invalid type");
6198 auto get_exe_scope = [&exe_ctx]() {
6202 clang::QualType parent_qual_type(
6204 const clang::Type::TypeClass parent_type_class =
6205 parent_qual_type->getTypeClass();
6206 child_bitfield_bit_size = 0;
6207 child_bitfield_bit_offset = 0;
6208 child_is_base_class =
false;
6211 auto num_children_or_err =
6213 if (!num_children_or_err)
6214 return num_children_or_err.takeError();
6216 const bool idx_is_valid = idx < *num_children_or_err;
6218 switch (parent_type_class) {
6219 case clang::Type::Builtin:
6221 return llvm::createStringError(
"invalid index");
6223 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6224 case clang::BuiltinType::ObjCId:
6225 case clang::BuiltinType::ObjCClass:
6236 case clang::Type::Record: {
6238 return llvm::createStringError(
"invalid index");
6240 return llvm::createStringError(
"cannot complete type");
6242 const clang::RecordType *record_type =
6243 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6244 const clang::RecordDecl *record_decl =
6245 record_type->getDecl()->getDefinitionOrSelf();
6246 const clang::ASTRecordLayout &record_layout =
6248 uint32_t child_idx = 0;
6250 const clang::CXXRecordDecl *cxx_record_decl =
6251 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6252 if (cxx_record_decl) {
6254 clang::CXXRecordDecl::base_class_const_iterator base_class,
6256 for (base_class = cxx_record_decl->bases_begin(),
6257 base_class_end = cxx_record_decl->bases_end();
6258 base_class != base_class_end; ++base_class) {
6259 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6262 if (omit_empty_base_classes) {
6264 llvm::cast<clang::CXXRecordDecl>(
6265 base_class->getType()->getAs<clang::RecordType>()->getDecl())
6266 ->getDefinitionOrSelf();
6271 if (idx == child_idx) {
6272 if (base_class_decl ==
nullptr)
6273 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6274 base_class->getType()
6275 ->getAs<clang::RecordType>()
6277 ->getDefinitionOrSelf();
6279 if (base_class->isVirtual()) {
6280 bool handled =
false;
6282 clang::VTableContextBase *vtable_ctx =
6286 cxx_record_decl, base_class_decl,
6290 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6294 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6299 child_byte_offset = bit_offset / 8;
6302 auto size_or_err = base_class_clang_type.
GetBitSize(get_exe_scope());
6304 return llvm::joinErrors(
6305 llvm::createStringError(
"no size info for base class"),
6306 size_or_err.takeError());
6308 uint64_t base_class_clang_type_bit_size = *size_or_err;
6311 assert(base_class_clang_type_bit_size % 8 == 0);
6312 child_byte_size = base_class_clang_type_bit_size / 8;
6313 child_is_base_class =
true;
6314 return base_class_clang_type;
6322 uint32_t field_idx = 0;
6323 clang::RecordDecl::field_iterator field, field_end;
6324 for (field = record_decl->field_begin(),
6325 field_end = record_decl->field_end();
6326 field != field_end; ++field, ++field_idx, ++child_idx) {
6327 if (idx == child_idx) {
6330 child_name.assign(field->getNameAsString());
6335 assert(field_idx < record_layout.getFieldCount());
6336 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6338 return llvm::joinErrors(
6339 llvm::createStringError(
"no size info for field"),
6340 size_or_err.takeError());
6342 child_byte_size = *size_or_err;
6343 const uint32_t child_bit_size = child_byte_size * 8;
6347 bit_offset = record_layout.getFieldOffset(field_idx);
6349 child_bitfield_bit_offset = bit_offset % child_bit_size;
6350 const uint32_t child_bit_offset =
6351 bit_offset - child_bitfield_bit_offset;
6352 child_byte_offset = child_bit_offset / 8;
6354 child_byte_offset = bit_offset / 8;
6357 return field_clang_type;
6361 case clang::Type::ObjCObject:
6362 case clang::Type::ObjCInterface: {
6364 return llvm::createStringError(
"invalid index");
6366 return llvm::createStringError(
"cannot complete type");
6368 const clang::ObjCObjectType *objc_class_type =
6369 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6370 assert(objc_class_type);
6371 if (!objc_class_type)
6372 return llvm::createStringError(
"unexpected object type");
6374 uint32_t child_idx = 0;
6375 clang::ObjCInterfaceDecl *class_interface_decl =
6376 objc_class_type->getInterface();
6378 if (!class_interface_decl)
6379 return llvm::createStringError(
"cannot get interface decl");
6381 const clang::ASTRecordLayout &interface_layout =
6382 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6383 clang::ObjCInterfaceDecl *superclass_interface_decl =
6384 class_interface_decl->getSuperClass();
6385 if (superclass_interface_decl) {
6386 if (omit_empty_base_classes) {
6388 getASTContext().getObjCInterfaceType(superclass_interface_decl));
6389 if (llvm::expectedToOptional(base_class_clang_type.
GetNumChildren(
6390 omit_empty_base_classes, exe_ctx))
6393 clang::QualType ivar_qual_type(
getASTContext().getObjCInterfaceType(
6394 superclass_interface_decl));
6396 child_name.assign(superclass_interface_decl->getNameAsString());
6398 clang::TypeInfo ivar_type_info =
6401 child_byte_size = ivar_type_info.Width / 8;
6402 child_byte_offset = 0;
6403 child_is_base_class =
true;
6405 return GetType(ivar_qual_type);
6414 const uint32_t superclass_idx = child_idx;
6416 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6417 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6418 ivar_end = class_interface_decl->ivar_end();
6420 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
6422 if (child_idx == idx) {
6423 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6425 clang::QualType ivar_qual_type(ivar_decl->getType());
6427 child_name.assign(ivar_decl->getNameAsString());
6429 clang::TypeInfo ivar_type_info =
6432 child_byte_size = ivar_type_info.Width / 8;
6448 if (objc_runtime !=
nullptr) {
6451 parent_ast_type, ivar_decl->getNameAsString().c_str());
6459 if (child_byte_offset ==
6462 interface_layout.getFieldOffset(child_idx - superclass_idx);
6463 child_byte_offset = bit_offset / 8;
6475 interface_layout.getFieldOffset(child_idx - superclass_idx);
6477 child_bitfield_bit_offset = bit_offset % 8;
6479 return GetType(ivar_qual_type);
6486 case clang::Type::ObjCObjectPointer: {
6488 return llvm::createStringError(
"invalid index");
6492 child_is_deref_of_parent =
false;
6493 bool tmp_child_is_deref_of_parent =
false;
6495 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6496 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6497 child_bitfield_bit_size, child_bitfield_bit_offset,
6498 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6501 child_is_deref_of_parent =
true;
6502 const char *parent_name =
6505 child_name.assign(1,
'*');
6506 child_name += parent_name;
6511 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6513 return size_or_err.takeError();
6514 child_byte_size = *size_or_err;
6515 child_byte_offset = 0;
6516 return pointee_clang_type;
6521 case clang::Type::Vector:
6522 case clang::Type::ExtVector: {
6524 return llvm::createStringError(
"invalid index");
6525 const clang::VectorType *array =
6526 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6528 return llvm::createStringError(
"unexpected vector type");
6532 return llvm::createStringError(
"cannot complete type");
6534 char element_name[64];
6535 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6536 static_cast<uint64_t
>(idx));
6537 child_name.assign(element_name);
6538 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6540 return size_or_err.takeError();
6541 child_byte_size = *size_or_err;
6542 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6543 return element_type;
6545 case clang::Type::ConstantArray:
6546 case clang::Type::IncompleteArray: {
6547 if (!ignore_array_bounds && !idx_is_valid)
6548 return llvm::createStringError(
"invalid index");
6549 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6551 return llvm::createStringError(
"unexpected array type");
6554 return llvm::createStringError(
"cannot complete type");
6556 child_name = std::string(llvm::formatv(
"[{0}]", idx));
6557 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6559 return size_or_err.takeError();
6560 child_byte_size = *size_or_err;
6561 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6562 return element_type;
6564 case clang::Type::Pointer: {
6569 return llvm::createStringError(
"cannot dereference void *");
6572 child_is_deref_of_parent =
false;
6573 bool tmp_child_is_deref_of_parent =
false;
6575 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6576 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6577 child_bitfield_bit_size, child_bitfield_bit_offset,
6578 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6581 child_is_deref_of_parent =
true;
6585 child_name.assign(1,
'*');
6586 child_name += parent_name;
6591 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6593 return size_or_err.takeError();
6594 child_byte_size = *size_or_err;
6595 child_byte_offset = 0;
6596 return pointee_clang_type;
6601 case clang::Type::LValueReference:
6602 case clang::Type::RValueReference: {
6604 return llvm::createStringError(
"invalid index");
6605 const clang::ReferenceType *reference_type =
6606 llvm::cast<clang::ReferenceType>(
6610 child_is_deref_of_parent =
false;
6611 bool tmp_child_is_deref_of_parent =
false;
6613 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6614 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6615 child_bitfield_bit_size, child_bitfield_bit_offset,
6616 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6621 child_name.assign(1,
'&');
6622 child_name += parent_name;
6627 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6629 return size_or_err.takeError();
6630 child_byte_size = *size_or_err;
6631 child_byte_offset = 0;
6632 return pointee_clang_type;
6639 return llvm::createStringError(
"cannot enumerate children");
6643 const clang::RecordDecl *record_decl,
6644 const clang::CXXBaseSpecifier *base_spec,
6645 bool omit_empty_base_classes) {
6646 uint32_t child_idx = 0;
6648 const clang::CXXRecordDecl *cxx_record_decl =
6649 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6651 if (cxx_record_decl) {
6652 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6653 for (base_class = cxx_record_decl->bases_begin(),
6654 base_class_end = cxx_record_decl->bases_end();
6655 base_class != base_class_end; ++base_class) {
6656 if (omit_empty_base_classes) {
6661 if (base_class == base_spec)
6671 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6672 bool omit_empty_base_classes) {
6674 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6675 omit_empty_base_classes);
6677 clang::RecordDecl::field_iterator field, field_end;
6678 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6679 field != field_end; ++field, ++child_idx) {
6680 if (field->getCanonicalDecl() == canonical_decl)
6722 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6723 if (type && !name.empty()) {
6725 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6726 switch (type_class) {
6727 case clang::Type::Record:
6729 const clang::RecordType *record_type =
6730 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6731 const clang::RecordDecl *record_decl =
6732 record_type->getDecl()->getDefinitionOrSelf();
6734 assert(record_decl);
6735 uint32_t child_idx = 0;
6737 const clang::CXXRecordDecl *cxx_record_decl =
6738 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6741 clang::RecordDecl::field_iterator field, field_end;
6742 for (field = record_decl->field_begin(),
6743 field_end = record_decl->field_end();
6744 field != field_end; ++field, ++child_idx) {
6745 llvm::StringRef field_name = field->getName();
6746 if (field_name.empty()) {
6748 std::vector<uint32_t> save_indices = child_indexes;
6749 child_indexes.push_back(
6751 cxx_record_decl, omit_empty_base_classes));
6753 name, omit_empty_base_classes, child_indexes))
6754 return child_indexes.size();
6755 child_indexes = std::move(save_indices);
6756 }
else if (field_name == name) {
6758 child_indexes.push_back(
6760 cxx_record_decl, omit_empty_base_classes));
6761 return child_indexes.size();
6765 if (cxx_record_decl) {
6766 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6769 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6770 clang::DeclarationName decl_name(&ident_ref);
6772 clang::CXXBasePaths paths;
6773 if (cxx_record_decl->lookupInBases(
6774 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6775 clang::CXXBasePath &path) {
6776 CXXRecordDecl *record =
6777 specifier->getType()->getAsCXXRecordDecl();
6778 auto r = record->lookup(decl_name);
6779 path.Decls = r.begin();
6783 clang::CXXBasePaths::const_paths_iterator path,
6784 path_end = paths.end();
6785 for (path = paths.begin(); path != path_end; ++path) {
6786 const size_t num_path_elements = path->size();
6787 for (
size_t e = 0; e < num_path_elements; ++e) {
6788 clang::CXXBasePathElement elem = (*path)[e];
6791 omit_empty_base_classes);
6793 child_indexes.clear();
6796 child_indexes.push_back(child_idx);
6797 parent_record_decl = elem.Base->getType()
6798 ->castAs<clang::RecordType>()
6800 ->getDefinitionOrSelf();
6803 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6806 parent_record_decl, *I, omit_empty_base_classes);
6808 child_indexes.clear();
6811 child_indexes.push_back(child_idx);
6815 return child_indexes.size();
6821 case clang::Type::ObjCObject:
6822 case clang::Type::ObjCInterface:
6824 llvm::StringRef name_sref(name);
6825 const clang::ObjCObjectType *objc_class_type =
6826 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6827 assert(objc_class_type);
6828 if (objc_class_type) {
6829 uint32_t child_idx = 0;
6830 clang::ObjCInterfaceDecl *class_interface_decl =
6831 objc_class_type->getInterface();
6833 if (class_interface_decl) {
6834 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6835 ivar_end = class_interface_decl->ivar_end();
6836 clang::ObjCInterfaceDecl *superclass_interface_decl =
6837 class_interface_decl->getSuperClass();
6839 for (ivar_pos = class_interface_decl->ivar_begin();
6840 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6841 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6843 if (ivar_decl->getName() == name_sref) {
6844 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6845 (omit_empty_base_classes &&
6849 child_indexes.push_back(child_idx);
6850 return child_indexes.size();
6854 if (superclass_interface_decl) {
6858 child_indexes.push_back(0);
6862 superclass_interface_decl));
6864 name, omit_empty_base_classes, child_indexes)) {
6867 return child_indexes.size();
6872 child_indexes.pop_back();
6879 case clang::Type::ObjCObjectPointer: {
6881 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6882 ->getPointeeType());
6884 name, omit_empty_base_classes, child_indexes);
6887 case clang::Type::LValueReference:
6888 case clang::Type::RValueReference: {
6889 const clang::ReferenceType *reference_type =
6890 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
6891 clang::QualType pointee_type(reference_type->getPointeeType());
6896 name, omit_empty_base_classes, child_indexes);
6900 case clang::Type::Pointer: {
6905 name, omit_empty_base_classes, child_indexes);
6920llvm::Expected<uint32_t>
6922 llvm::StringRef name,
6923 bool omit_empty_base_classes) {
6924 if (type && !name.empty()) {
6927 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6929 switch (type_class) {
6930 case clang::Type::Record:
6932 const clang::RecordType *record_type =
6933 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6934 const clang::RecordDecl *record_decl =
6935 record_type->getDecl()->getDefinitionOrSelf();
6937 assert(record_decl);
6938 uint32_t child_idx = 0;
6940 const clang::CXXRecordDecl *cxx_record_decl =
6941 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6943 if (cxx_record_decl) {
6944 clang::CXXRecordDecl::base_class_const_iterator base_class,
6946 for (base_class = cxx_record_decl->bases_begin(),
6947 base_class_end = cxx_record_decl->bases_end();
6948 base_class != base_class_end; ++base_class) {
6950 clang::CXXRecordDecl *base_class_decl =
6951 llvm::cast<clang::CXXRecordDecl>(
6952 base_class->getType()
6953 ->castAs<clang::RecordType>()
6955 ->getDefinitionOrSelf();
6956 if (omit_empty_base_classes &&
6961 std::string base_class_type_name(
6963 if (base_class_type_name == name)
6970 clang::RecordDecl::field_iterator field, field_end;
6971 for (field = record_decl->field_begin(),
6972 field_end = record_decl->field_end();
6973 field != field_end; ++field, ++child_idx) {
6974 if (field->getName() == name)
6980 case clang::Type::ObjCObject:
6981 case clang::Type::ObjCInterface:
6983 const clang::ObjCObjectType *objc_class_type =
6984 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6985 assert(objc_class_type);
6986 if (objc_class_type) {
6987 uint32_t child_idx = 0;
6988 clang::ObjCInterfaceDecl *class_interface_decl =
6989 objc_class_type->getInterface();
6991 if (class_interface_decl) {
6992 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6993 ivar_end = class_interface_decl->ivar_end();
6994 clang::ObjCInterfaceDecl *superclass_interface_decl =
6995 class_interface_decl->getSuperClass();
6997 for (ivar_pos = class_interface_decl->ivar_begin();
6998 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6999 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
7001 if (ivar_decl->getName() == name) {
7002 if ((!omit_empty_base_classes && superclass_interface_decl) ||
7003 (omit_empty_base_classes &&
7011 if (superclass_interface_decl) {
7012 if (superclass_interface_decl->getName() == name)
7020 case clang::Type::ObjCObjectPointer: {
7022 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7023 ->getPointeeType());
7025 name, omit_empty_base_classes);
7028 case clang::Type::LValueReference:
7029 case clang::Type::RValueReference: {
7030 const clang::ReferenceType *reference_type =
7031 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7036 omit_empty_base_classes);
7040 case clang::Type::Pointer: {
7041 const clang::PointerType *pointer_type =
7042 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7047 omit_empty_base_classes);
7055 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
7060 llvm::StringRef name) {
7061 if (!type || name.empty())
7065 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7067 switch (type_class) {
7068 case clang::Type::Record: {
7071 const clang::RecordType *record_type =
7072 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7073 const clang::RecordDecl *record_decl =
7074 record_type->getDecl()->getDefinitionOrSelf();
7076 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7077 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7078 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7080 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7082 ElaboratedTypeKeyword::None, std::nullopt,
7098 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7099 return isa<clang::ClassTemplateSpecializationDecl>(
7100 cxx_record_decl->getDecl());
7111 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7112 switch (type_class) {
7113 case clang::Type::Record:
7115 const clang::CXXRecordDecl *cxx_record_decl =
7116 qual_type->getAsCXXRecordDecl();
7117 if (cxx_record_decl) {
7118 const clang::ClassTemplateSpecializationDecl *template_decl =
7119 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7121 if (template_decl) {
7122 const auto &template_arg_list = template_decl->getTemplateArgs();
7123 size_t num_args = template_arg_list.size();
7124 assert(num_args &&
"template specialization without any args");
7125 if (expand_pack && num_args) {
7126 const auto &pack = template_arg_list[num_args - 1];
7127 if (pack.getKind() == clang::TemplateArgument::Pack)
7128 num_args += pack.pack_size() - 1;
7143const clang::ClassTemplateSpecializationDecl *
7150 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7151 switch (type_class) {
7152 case clang::Type::Record: {
7155 const clang::CXXRecordDecl *cxx_record_decl =
7156 qual_type->getAsCXXRecordDecl();
7157 if (!cxx_record_decl)
7159 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7168const TemplateArgument *
7170 size_t idx,
bool expand_pack) {
7171 const auto &args = decl->getTemplateArgs();
7172 const size_t args_size = args.size();
7174 assert(args_size &&
"template specialization without any args");
7178 const size_t last_idx = args_size - 1;
7187 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7188 return idx >= args.size() ? nullptr : &args[idx];
7193 const auto &pack = args[last_idx];
7194 const size_t pack_idx = idx - last_idx;
7195 if (pack_idx >= pack.pack_size())
7197 return &pack.pack_elements()[pack_idx];
7202 size_t arg_idx,
bool expand_pack) {
7203 const clang::ClassTemplateSpecializationDecl *template_decl =
7212 switch (arg->getKind()) {
7213 case clang::TemplateArgument::Null:
7216 case clang::TemplateArgument::NullPtr:
7219 case clang::TemplateArgument::Type:
7222 case clang::TemplateArgument::Declaration:
7225 case clang::TemplateArgument::Integral:
7228 case clang::TemplateArgument::Template:
7231 case clang::TemplateArgument::TemplateExpansion:
7234 case clang::TemplateArgument::Expression:
7237 case clang::TemplateArgument::Pack:
7240 case clang::TemplateArgument::StructuralValue:
7243 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7248 size_t idx,
bool expand_pack) {
7249 const clang::ClassTemplateSpecializationDecl *template_decl =
7255 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7258 return GetType(arg->getAsType());
7261std::optional<CompilerType::IntegralTemplateArgument>
7263 size_t idx,
bool expand_pack) {
7264 const clang::ClassTemplateSpecializationDecl *template_decl =
7267 return std::nullopt;
7271 return std::nullopt;
7273 switch (arg->getKind()) {
7274 case clang::TemplateArgument::Integral:
7275 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7276 case clang::TemplateArgument::StructuralValue: {
7277 clang::APValue value = arg->getAsStructuralValue();
7280 if (value.isFloat())
7281 return {{value.getFloat(), type}};
7284 return {{value.getInt(), type}};
7286 return std::nullopt;
7289 return std::nullopt;
7314 const clang::EnumType *enutype =
7317 return enutype->getDecl()->getDefinitionOrSelf();
7322 const clang::RecordType *record_type =
7325 return record_type->getDecl()->getDefinitionOrSelf();
7333clang::TypedefNameDecl *
7335 const clang::TypedefType *typedef_type =
7338 return typedef_type->getDecl();
7342clang::CXXRecordDecl *
7347clang::ObjCInterfaceDecl *
7349 const clang::ObjCObjectType *objc_class_type =
7350 llvm::dyn_cast<clang::ObjCObjectType>(
7352 if (objc_class_type)
7353 return objc_class_type->getInterface();
7359 const CompilerType &field_clang_type, uint32_t bitfield_bit_size) {
7365 clang::ASTContext &clang_ast = ast->getASTContext();
7366 clang::IdentifierInfo *ident =
nullptr;
7368 ident = &clang_ast.Idents.get(name);
7370 clang::FieldDecl *field =
nullptr;
7372 clang::Expr *bit_width =
nullptr;
7373 if (bitfield_bit_size != 0) {
7374 if (clang_ast.IntTy.isNull()) {
7376 "builtin ASTContext types have not been initialized");
7380 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7382 bit_width =
new (clang_ast)
7383 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7384 clang_ast.IntTy, clang::SourceLocation());
7385 bit_width = clang::ConstantExpr::Create(
7386 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7389 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7391 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7392 field->setDeclContext(record_decl);
7393 field->setDeclName(ident);
7396 field->setBitWidth(bit_width);
7402 if (
const clang::TagType *TagT =
7403 field->getType()->getAs<clang::TagType>()) {
7404 if (clang::RecordDecl *Rec =
7405 llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
7406 if (!Rec->getDeclName()) {
7407 Rec->setAnonymousStructOrUnion(
true);
7408 field->setImplicit();
7414 field->setAccess(AS_public);
7416 record_decl->addDecl(field);
7421 clang::ObjCInterfaceDecl *class_interface_decl =
7422 ast->GetAsObjCInterfaceDecl(type);
7424 if (class_interface_decl) {
7425 const bool is_synthesized =
false;
7430 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7431 ivar->setDeclContext(class_interface_decl);
7432 ivar->setDeclName(ident);
7434 ivar->setAccessControl(ObjCIvarDecl::AccessControl::Public);
7436 ivar->setBitWidth(bit_width);
7437 ivar->setSynthesize(is_synthesized);
7442 class_interface_decl->addDecl(field);
7459 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7464 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7466 IndirectFieldVector indirect_fields;
7467 clang::RecordDecl::field_iterator field_pos;
7468 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7469 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7470 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7471 last_field_pos = field_pos++) {
7472 if (field_pos->isAnonymousStructOrUnion()) {
7473 clang::QualType field_qual_type = field_pos->getType();
7475 const clang::RecordType *field_record_type =
7476 field_qual_type->getAs<clang::RecordType>();
7478 if (!field_record_type)
7481 clang::RecordDecl *field_record_decl =
7482 field_record_type->getDecl()->getDefinition();
7484 if (!field_record_decl)
7487 for (clang::RecordDecl::decl_iterator
7488 di = field_record_decl->decls_begin(),
7489 de = field_record_decl->decls_end();
7491 if (clang::FieldDecl *nested_field_decl =
7492 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7493 clang::NamedDecl **chain =
7494 new (ast->getASTContext()) clang::NamedDecl *[2];
7495 chain[0] = *field_pos;
7496 chain[1] = nested_field_decl;
7497 clang::IndirectFieldDecl *indirect_field =
7498 clang::IndirectFieldDecl::Create(
7499 ast->getASTContext(), record_decl, clang::SourceLocation(),
7500 nested_field_decl->getIdentifier(),
7501 nested_field_decl->getType(), {chain, 2});
7504 indirect_field->setImplicit();
7506 indirect_field->setAccess(AS_public);
7508 indirect_fields.push_back(indirect_field);
7509 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7510 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7511 size_t nested_chain_size =
7512 nested_indirect_field_decl->getChainingSize();
7513 clang::NamedDecl **chain =
new (ast->getASTContext())
7514 clang::NamedDecl *[nested_chain_size + 1];
7515 chain[0] = *field_pos;
7517 int chain_index = 1;
7518 for (clang::IndirectFieldDecl::chain_iterator
7519 nci = nested_indirect_field_decl->chain_begin(),
7520 nce = nested_indirect_field_decl->chain_end();
7522 chain[chain_index] = *nci;
7526 clang::IndirectFieldDecl *indirect_field =
7527 clang::IndirectFieldDecl::Create(
7528 ast->getASTContext(), record_decl, clang::SourceLocation(),
7529 nested_indirect_field_decl->getIdentifier(),
7530 nested_indirect_field_decl->getType(),
7531 {chain, nested_chain_size + 1});
7534 indirect_field->setImplicit();
7536 indirect_field->setAccess(AS_public);
7538 indirect_fields.push_back(indirect_field);
7546 if (last_field_pos != field_end_pos) {
7547 if (last_field_pos->getType()->isIncompleteArrayType())
7548 record_decl->hasFlexibleArrayMember();
7551 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7552 ife = indirect_fields.end();
7554 record_decl->addDecl(*ifi);
7567 record_decl->addAttr(
7568 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7575 llvm::StringRef name,
7584 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7588 clang::VarDecl *var_decl =
nullptr;
7589 clang::IdentifierInfo *ident =
nullptr;
7591 ident = &ast->getASTContext().Idents.get(name);
7594 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7595 var_decl->setDeclContext(record_decl);
7596 var_decl->setDeclName(ident);
7598 var_decl->setStorageClass(clang::SC_Static);
7603 var_decl->setAccess(AS_public);
7604 record_decl->addDecl(var_decl);
7606 VerifyDecl(var_decl);
7612 VarDecl *var,
const llvm::APInt &init_value) {
7613 assert(!var->hasInit() &&
"variable already initialized");
7615 clang::ASTContext &ast = var->getASTContext();
7616 QualType qt = var->getType();
7617 assert(qt->isIntegralOrEnumerationType() &&
7618 "only integer or enum types supported");
7621 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7622 const EnumDecl *enum_decl = enum_type->getDecl()->getDefinitionOrSelf();
7623 qt = enum_decl->getIntegerType();
7627 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7628 var->setInit(CXXBoolLiteralExpr::Create(
7629 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7631 var->setInit(IntegerLiteral::Create(
7632 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7637 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7638 assert(!var->hasInit() &&
"variable already initialized");
7640 clang::ASTContext &ast = var->getASTContext();
7641 QualType qt = var->getType();
7642 assert(qt->isFloatingType() &&
"only floating point types supported");
7643 var->setInit(FloatingLiteral::Create(
7644 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7647llvm::SmallVector<clang::ParmVarDecl *>
7649 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7650 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7652 assert(parameter_names.empty() ||
7653 parameter_names.size() == prototype.getNumParams());
7655 llvm::SmallVector<clang::ParmVarDecl *> params;
7656 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7658 llvm::StringRef name =
7659 !parameter_names.empty() ? parameter_names[param_index] :
"";
7663 GetType(prototype.getParamType(param_index)),
7664 clang::SC_None,
false);
7667 params.push_back(param);
7675 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7676 bool is_virtual,
bool is_static,
bool is_inline,
bool is_explicit,
7677 bool is_attr_used,
bool is_artificial) {
7678 if (!type || !method_clang_type.
IsValid() || name.empty())
7683 clang::CXXRecordDecl *cxx_record_decl =
7684 record_qual_type->getAsCXXRecordDecl();
7686 if (cxx_record_decl ==
nullptr)
7691 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7693 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7695 const clang::FunctionType *function_type =
7696 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7698 if (function_type ==
nullptr)
7701 const clang::FunctionProtoType *method_function_prototype(
7702 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7704 if (!method_function_prototype)
7707 unsigned int num_params = method_function_prototype->getNumParams();
7709 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7710 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7715 const clang::ExplicitSpecifier explicit_spec(
7716 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7717 : clang::ExplicitSpecKind::ResolvedFalse);
7719 if (name.starts_with(
"~")) {
7720 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7722 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7723 cxx_dtor_decl->setDeclName(
7726 cxx_dtor_decl->setType(method_qual_type);
7727 cxx_dtor_decl->setImplicit(is_artificial);
7728 cxx_dtor_decl->setInlineSpecified(is_inline);
7729 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7730 cxx_method_decl = cxx_dtor_decl;
7731 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7732 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7734 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7735 cxx_ctor_decl->setDeclName(
7738 cxx_ctor_decl->setType(method_qual_type);
7739 cxx_ctor_decl->setImplicit(is_artificial);
7740 cxx_ctor_decl->setInlineSpecified(is_inline);
7741 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7742 cxx_ctor_decl->setNumCtorInitializers(0);
7743 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7744 cxx_method_decl = cxx_ctor_decl;
7746 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7747 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7750 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7755 const bool is_method =
true;
7757 is_method, op_kind, num_params))
7759 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7761 cxx_method_decl->setDeclContext(cxx_record_decl);
7762 cxx_method_decl->setDeclName(
7763 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7764 cxx_method_decl->setType(method_qual_type);
7765 cxx_method_decl->setStorageClass(SC);
7766 cxx_method_decl->setInlineSpecified(is_inline);
7767 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7768 }
else if (num_params == 0) {
7770 auto *cxx_conversion_decl =
7771 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7773 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7774 cxx_conversion_decl->setDeclName(
7775 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7777 function_type->getReturnType())));
7778 cxx_conversion_decl->setType(method_qual_type);
7779 cxx_conversion_decl->setInlineSpecified(is_inline);
7780 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7781 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7782 cxx_method_decl = cxx_conversion_decl;
7786 if (cxx_method_decl ==
nullptr) {
7787 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7789 cxx_method_decl->setDeclContext(cxx_record_decl);
7790 cxx_method_decl->setDeclName(decl_name);
7791 cxx_method_decl->setType(method_qual_type);
7792 cxx_method_decl->setInlineSpecified(is_inline);
7793 cxx_method_decl->setStorageClass(SC);
7794 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7799 cxx_method_decl->setAccess(AS_public);
7800 cxx_method_decl->setVirtualAsWritten(is_virtual);
7803 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7805 if (!asm_label.empty())
7806 cxx_method_decl->addAttr(
7807 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7812 cxx_method_decl, *method_function_prototype, {}));
7814 cxx_record_decl->addDecl(cxx_method_decl);
7823 if (is_artificial) {
7824 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7825 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7826 (cxx_ctor_decl->isCopyConstructor() &&
7827 cxx_record_decl->hasTrivialCopyConstructor()) ||
7828 (cxx_ctor_decl->isMoveConstructor() &&
7829 cxx_record_decl->hasTrivialMoveConstructor()))) {
7830 cxx_ctor_decl->setDefaulted();
7831 cxx_ctor_decl->setTrivial(
true);
7832 }
else if (cxx_dtor_decl) {
7833 if (cxx_record_decl->hasTrivialDestructor()) {
7834 cxx_dtor_decl->setDefaulted();
7835 cxx_dtor_decl->setTrivial(
true);
7837 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7838 cxx_record_decl->hasTrivialCopyAssignment()) ||
7839 (cxx_method_decl->isMoveAssignmentOperator() &&
7840 cxx_record_decl->hasTrivialMoveAssignment())) {
7841 cxx_method_decl->setDefaulted();
7842 cxx_method_decl->setTrivial(
true);
7846 VerifyDecl(cxx_method_decl);
7848 return cxx_method_decl;
7854 for (
auto *method : record->methods())
7855 addOverridesForMethod(method);
7858#pragma mark C++ Base Classes
7860std::unique_ptr<clang::CXXBaseSpecifier>
7863 bool base_of_class) {
7867 return std::make_unique<clang::CXXBaseSpecifier>(
7868 clang::SourceRange(), is_virtual, base_of_class,
7871 clang::SourceLocation());
7876 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
7880 if (!cxx_record_decl)
7882 std::vector<clang::CXXBaseSpecifier *> raw_bases;
7883 raw_bases.reserve(bases.size());
7887 for (
auto &b : bases)
7888 raw_bases.push_back(b.get());
7889 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
7898 clang::ASTContext &clang_ast = ast->getASTContext();
7900 if (type && superclass_clang_type.
IsValid() &&
7902 clang::ObjCInterfaceDecl *class_interface_decl =
7904 clang::ObjCInterfaceDecl *super_interface_decl =
7906 if (class_interface_decl && super_interface_decl) {
7907 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
7908 clang_ast.getObjCInterfaceType(super_interface_decl)));
7917 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
7918 const char *property_setter_name,
const char *property_getter_name,
7920 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
7921 property_name[0] ==
'\0')
7926 clang::ASTContext &clang_ast = ast->getASTContext();
7929 if (!class_interface_decl)
7934 if (property_clang_type.
IsValid())
7935 property_clang_type_to_access = property_clang_type;
7937 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
7939 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
7942 clang::TypeSourceInfo *prop_type_source;
7944 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
7946 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
7949 clang::ObjCPropertyDecl *property_decl =
7950 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7951 property_decl->setDeclContext(class_interface_decl);
7952 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
7953 property_decl->setType(ivar_decl
7954 ? ivar_decl->getType()
7962 ast->SetMetadata(property_decl, metadata);
7964 class_interface_decl->addDecl(property_decl);
7966 clang::Selector setter_sel, getter_sel;
7968 if (property_setter_name) {
7969 std::string property_setter_no_colon(property_setter_name,
7970 strlen(property_setter_name) - 1);
7971 const clang::IdentifierInfo *setter_ident =
7972 &clang_ast.Idents.get(property_setter_no_colon);
7973 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
7974 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
7975 std::string setter_sel_string(
"set");
7976 setter_sel_string.push_back(::toupper(property_name[0]));
7977 setter_sel_string.append(&property_name[1]);
7978 const clang::IdentifierInfo *setter_ident =
7979 &clang_ast.Idents.get(setter_sel_string);
7980 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
7982 property_decl->setSetterName(setter_sel);
7983 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
7985 if (property_getter_name !=
nullptr) {
7986 const clang::IdentifierInfo *getter_ident =
7987 &clang_ast.Idents.get(property_getter_name);
7988 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
7990 const clang::IdentifierInfo *getter_ident =
7991 &clang_ast.Idents.get(property_name);
7992 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
7994 property_decl->setGetterName(getter_sel);
7995 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
7998 property_decl->setPropertyIvarDecl(ivar_decl);
8000 if (property_attributes & DW_APPLE_PROPERTY_readonly)
8001 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
8002 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
8003 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
8004 if (property_attributes & DW_APPLE_PROPERTY_assign)
8005 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
8006 if (property_attributes & DW_APPLE_PROPERTY_retain)
8007 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
8008 if (property_attributes & DW_APPLE_PROPERTY_copy)
8009 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
8010 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8011 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
8012 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
8013 property_decl->setPropertyAttributes(
8014 ObjCPropertyAttribute::kind_nullability);
8015 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
8016 property_decl->setPropertyAttributes(
8017 ObjCPropertyAttribute::kind_null_resettable);
8018 if (property_attributes & ObjCPropertyAttribute::kind_class)
8019 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8021 const bool isInstance =
8022 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8024 clang::ObjCMethodDecl *getter =
nullptr;
8025 if (!getter_sel.isNull())
8026 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8027 : class_interface_decl->lookupClassMethod(getter_sel);
8028 if (!getter_sel.isNull() && !getter) {
8029 const bool isVariadic =
false;
8030 const bool isPropertyAccessor =
true;
8031 const bool isSynthesizedAccessorStub =
false;
8032 const bool isImplicitlyDeclared =
true;
8033 const bool isDefined =
false;
8034 const clang::ObjCImplementationControl impControl =
8035 clang::ObjCImplementationControl::None;
8036 const bool HasRelatedResultType =
false;
8039 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8040 getter->setDeclName(getter_sel);
8042 getter->setDeclContext(class_interface_decl);
8043 getter->setInstanceMethod(isInstance);
8044 getter->setVariadic(isVariadic);
8045 getter->setPropertyAccessor(isPropertyAccessor);
8046 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8047 getter->setImplicit(isImplicitlyDeclared);
8048 getter->setDefined(isDefined);
8049 getter->setDeclImplementation(impControl);
8050 getter->setRelatedResultType(HasRelatedResultType);
8054 ast->SetMetadata(getter, metadata);
8056 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8057 llvm::ArrayRef<clang::SourceLocation>());
8058 class_interface_decl->addDecl(getter);
8062 getter->setPropertyAccessor(
true);
8063 property_decl->setGetterMethodDecl(getter);
8066 clang::ObjCMethodDecl *setter =
nullptr;
8067 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8068 : class_interface_decl->lookupClassMethod(setter_sel);
8069 if (!setter_sel.isNull() && !setter) {
8070 clang::QualType result_type = clang_ast.VoidTy;
8071 const bool isVariadic =
false;
8072 const bool isPropertyAccessor =
true;
8073 const bool isSynthesizedAccessorStub =
false;
8074 const bool isImplicitlyDeclared =
true;
8075 const bool isDefined =
false;
8076 const clang::ObjCImplementationControl impControl =
8077 clang::ObjCImplementationControl::None;
8078 const bool HasRelatedResultType =
false;
8081 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8082 setter->setDeclName(setter_sel);
8083 setter->setReturnType(result_type);
8084 setter->setDeclContext(class_interface_decl);
8085 setter->setInstanceMethod(isInstance);
8086 setter->setVariadic(isVariadic);
8087 setter->setPropertyAccessor(isPropertyAccessor);
8088 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8089 setter->setImplicit(isImplicitlyDeclared);
8090 setter->setDefined(isDefined);
8091 setter->setDeclImplementation(impControl);
8092 setter->setRelatedResultType(HasRelatedResultType);
8096 ast->SetMetadata(setter, metadata);
8098 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8099 params.push_back(clang::ParmVarDecl::Create(
8100 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8103 clang::SC_Auto,
nullptr));
8105 setter->setMethodParams(clang_ast,
8106 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8107 llvm::ArrayRef<clang::SourceLocation>());
8109 class_interface_decl->addDecl(setter);
8113 setter->setPropertyAccessor(
true);
8114 property_decl->setSetterMethodDecl(setter);
8125 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8126 bool is_objc_direct_call) {
8127 if (!type || !method_clang_type.
IsValid())
8132 if (class_interface_decl ==
nullptr)
8135 if (lldb_ast ==
nullptr)
8137 clang::ASTContext &ast = lldb_ast->getASTContext();
8139 const char *selector_start = ::strchr(name,
' ');
8140 if (selector_start ==
nullptr)
8144 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8149 unsigned num_selectors_with_args = 0;
8150 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8152 len = ::strcspn(start,
":]");
8153 bool has_arg = (start[len] ==
':');
8155 ++num_selectors_with_args;
8156 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8161 if (selector_idents.size() == 0)
8164 clang::Selector method_selector = ast.Selectors.getSelector(
8165 num_selectors_with_args ? selector_idents.size() : 0,
8166 selector_idents.data());
8171 const clang::Type *method_type(method_qual_type.getTypePtr());
8173 if (method_type ==
nullptr)
8176 const clang::FunctionProtoType *method_function_prototype(
8177 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8179 if (!method_function_prototype)
8182 const bool isInstance = (name[0] ==
'-');
8183 const bool isVariadic = is_variadic;
8184 const bool isPropertyAccessor =
false;
8185 const bool isSynthesizedAccessorStub =
false;
8187 const bool isImplicitlyDeclared =
true;
8188 const bool isDefined =
false;
8189 const clang::ObjCImplementationControl impControl =
8190 clang::ObjCImplementationControl::None;
8191 const bool HasRelatedResultType =
false;
8193 const unsigned num_args = method_function_prototype->getNumParams();
8195 if (num_args != num_selectors_with_args)
8199 auto *objc_method_decl =
8200 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8201 objc_method_decl->setDeclName(method_selector);
8202 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8203 objc_method_decl->setDeclContext(
8205 objc_method_decl->setInstanceMethod(isInstance);
8206 objc_method_decl->setVariadic(isVariadic);
8207 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8208 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8209 objc_method_decl->setImplicit(isImplicitlyDeclared);
8210 objc_method_decl->setDefined(isDefined);
8211 objc_method_decl->setDeclImplementation(impControl);
8212 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8215 if (objc_method_decl ==
nullptr)
8219 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8221 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8222 params.push_back(clang::ParmVarDecl::Create(
8223 ast, objc_method_decl, clang::SourceLocation(),
8224 clang::SourceLocation(),
8226 method_function_prototype->getParamType(param_index),
nullptr,
8227 clang::SC_Auto,
nullptr));
8230 objc_method_decl->setMethodParams(
8231 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8232 llvm::ArrayRef<clang::SourceLocation>());
8235 if (is_objc_direct_call) {
8238 objc_method_decl->addAttr(
8239 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8244 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8247 class_interface_decl->addDecl(objc_method_decl);
8249 VerifyDecl(objc_method_decl);
8251 return objc_method_decl;
8261 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8262 switch (type_class) {
8263 case clang::Type::Record: {
8264 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8265 if (cxx_record_decl) {
8266 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8267 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8272 case clang::Type::Enum: {
8273 clang::EnumDecl *enum_decl =
8274 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8276 enum_decl->setHasExternalLexicalStorage(has_extern);
8277 enum_decl->setHasExternalVisibleStorage(has_extern);
8282 case clang::Type::ObjCObject:
8283 case clang::Type::ObjCInterface: {
8284 const clang::ObjCObjectType *objc_class_type =
8285 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8286 assert(objc_class_type);
8287 if (objc_class_type) {
8288 clang::ObjCInterfaceDecl *class_interface_decl =
8289 objc_class_type->getInterface();
8291 if (class_interface_decl) {
8292 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8293 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8309 if (!qual_type.isNull()) {
8310 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8312 clang::TagDecl *tag_decl = tag_type->getDecl();
8314 tag_decl->startDefinition();
8319 const clang::ObjCObjectType *object_type =
8320 qual_type->getAs<clang::ObjCObjectType>();
8322 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8323 if (interface_decl) {
8324 interface_decl->startDefinition();
8335 if (qual_type.isNull())
8339 if (lldb_ast ==
nullptr)
8345 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8347 clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinitionOrSelf();
8349 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8359 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8360 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8361 if (cxx_record_decl->needsImplicitCopyConstructor())
8362 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8363 if (cxx_record_decl->needsImplicitCopyAssignment())
8364 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8367 if (!cxx_record_decl->isCompleteDefinition())
8368 cxx_record_decl->completeDefinition();
8369 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8370 cxx_record_decl->setHasExternalLexicalStorage(
false);
8371 cxx_record_decl->setHasExternalVisibleStorage(
false);
8376 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8380 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8382 if (enum_decl->isCompleteDefinition())
8385 QualType integer_type(enum_decl->getIntegerType());
8386 if (!integer_type.isNull()) {
8387 clang::ASTContext &ast = lldb_ast->getASTContext();
8389 unsigned NumNegativeBits = 0;
8390 unsigned NumPositiveBits = 0;
8391 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8394 clang::QualType BestPromotionType;
8395 clang::QualType BestType;
8396 ast.computeBestEnumTypes(
false, NumNegativeBits,
8397 NumPositiveBits, BestType, BestPromotionType);
8399 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8400 BestPromotionType, NumPositiveBits,
8408 const llvm::APSInt &value) {
8419 if (!enum_opaque_compiler_type)
8422 clang::QualType enum_qual_type(
8425 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8430 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8435 clang::EnumConstantDecl *enumerator_decl =
8436 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8438 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8439 enumerator_decl->setDeclContext(enum_decl);
8440 if (name && name[0])
8441 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8442 enumerator_decl->setType(clang::QualType(enutype, 0));
8444 enumerator_decl->setAccess(AS_public);
8450 enum_decl->addDecl(enumerator_decl);
8452 VerifyDecl(enumerator_decl);
8453 return enumerator_decl;
8458 uint64_t enum_value, uint32_t enum_value_bit_size) {
8460 llvm::APSInt value(enum_value_bit_size,
8469 const clang::Type *clang_type = qt.getTypePtrOrNull();
8470 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8474 return GetType(enum_type->getDecl()->getDefinitionOrSelf()->getIntegerType());
8480 if (type && pointee_type.
IsValid() &&
8485 return ast->GetType(ast->getASTContext().getMemberPointerType(
8494#define DEPTH_INCREMENT 2
8497LLVM_DUMP_METHOD
void
8507struct ScopedASTColor {
8508 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8511 ast.getDiagnostics().getDiagnosticOptions().getShowColors()) {
8512 ast.getDiagnostics().getDiagnosticOptions().setShowColors(
8513 show_colors ? clang::ShowColorsKind::On : clang::ShowColorsKind::Off);
8517 ast.getDiagnostics().getDiagnosticOptions().setShowColors(old_show_colors);
8520 clang::ASTContext *
8521 const clang::ShowColorsKind old_show_colors;
8530 clang::CreateASTDumper(output, filter,
8534 false, clang::ADOF_Default);
8537 consumer->HandleTranslationUnit(*
m_ast_up);
8541 llvm::StringRef symbol_name) {
8548 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8549 size_t ntypes = type_list.
GetSize();
8551 for (
size_t i = 0; i < ntypes; ++i) {
8554 if (!symbol_name.empty())
8555 if (symbol_name != type->GetName().GetStringRef())
8558 s << type->GetName() <<
"\n";
8561 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8569 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8571 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8583 size_t byte_size, uint32_t bitfield_bit_offset,
8584 uint32_t bitfield_bit_size) {
8585 const clang::EnumType *enutype =
8586 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8587 const clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8589 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8590 const uint64_t enum_svalue =
8593 bitfield_bit_offset)
8595 bitfield_bit_offset);
8596 bool can_be_bitfield =
true;
8597 uint64_t covered_bits = 0;
8598 int num_enumerators = 0;
8606 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8607 if (enumerators.empty())
8608 can_be_bitfield =
false;
8610 for (
auto *enumerator : enumerators) {
8611 llvm::APSInt init_val = enumerator->getInitVal();
8612 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8613 : init_val.getZExtValue();
8614 if (qual_type_is_signed)
8615 val = llvm::SignExtend64(val, 8 * byte_size);
8616 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8617 can_be_bitfield =
false;
8618 covered_bits |= val;
8620 if (val == enum_svalue) {
8629 offset = byte_offset;
8631 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8635 if (!can_be_bitfield) {
8636 if (qual_type_is_signed)
8637 s.
Printf(
"%" PRIi64, enum_svalue);
8639 s.
Printf(
"%" PRIu64, enum_uvalue);
8646 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8650 uint64_t remaining_value = enum_uvalue;
8651 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8652 values.reserve(num_enumerators);
8653 for (
auto *enumerator : enum_decl->enumerators())
8654 if (
auto val = enumerator->getInitVal().getZExtValue())
8655 values.emplace_back(val, enumerator->getName());
8660 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8661 return llvm::popcount(a.first) > llvm::popcount(b.first);
8664 for (
const auto &val : values) {
8665 if ((remaining_value & val.first) != val.first)
8667 remaining_value &= ~val.first;
8669 if (remaining_value)
8675 if (remaining_value)
8676 s.
Printf(
"0x%" PRIx64, remaining_value);
8684 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8693 switch (qual_type->getTypeClass()) {
8694 case clang::Type::Typedef: {
8695 clang::QualType typedef_qual_type =
8696 llvm::cast<clang::TypedefType>(qual_type)
8698 ->getUnderlyingType();
8701 format = typedef_clang_type.
GetFormat();
8702 clang::TypeInfo typedef_type_info =
8704 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8714 bitfield_bit_offset,
8719 case clang::Type::Enum:
8724 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8725 bitfield_bit_offset, bitfield_bit_size);
8733 uint32_t item_count = 1;
8773 item_count = byte_size;
8778 item_count = byte_size / 2;
8783 item_count = byte_size / 4;
8789 bitfield_bit_size, bitfield_bit_offset,
8805 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(clang_type)) {
8814 clang::QualType qual_type =
8817 llvm::SmallVector<char, 1024> buf;
8818 llvm::raw_svector_ostream llvm_ostrm(buf);
8820 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8821 switch (type_class) {
8822 case clang::Type::ObjCObject:
8823 case clang::Type::ObjCInterface: {
8826 auto *objc_class_type =
8827 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8828 assert(objc_class_type);
8829 if (!objc_class_type)
8831 clang::ObjCInterfaceDecl *class_interface_decl =
8832 objc_class_type->getInterface();
8833 if (!class_interface_decl)
8836 class_interface_decl->dump(llvm_ostrm);
8838 class_interface_decl->print(llvm_ostrm,
8843 case clang::Type::Typedef: {
8844 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8847 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
8849 typedef_decl->dump(llvm_ostrm);
8852 if (!clang_typedef_name.empty()) {
8859 case clang::Type::Record: {
8862 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
8863 const clang::RecordDecl *record_decl = record_type->getDecl();
8865 record_decl->dump(llvm_ostrm);
8867 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
8873 if (
auto *tag_type =
8874 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
8875 if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
8877 tag_decl->dump(llvm_ostrm);
8879 tag_decl->print(llvm_ostrm, 0);
8885 std::string clang_type_name(qual_type.getAsString());
8886 if (!clang_type_name.empty())
8893 if (buf.size() > 0) {
8894 s.
Write(buf.data(), buf.size());
8901 clang::QualType qual_type(
8904 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8905 switch (type_class) {
8906 case clang::Type::Record: {
8907 const clang::CXXRecordDecl *cxx_record_decl =
8908 qual_type->getAsCXXRecordDecl();
8909 if (cxx_record_decl)
8910 printf(
"class %s", cxx_record_decl->getName().str().c_str());
8913 case clang::Type::Enum: {
8914 clang::EnumDecl *enum_decl =
8915 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8917 printf(
"enum %s", enum_decl->getName().str().c_str());
8921 case clang::Type::ObjCObject:
8922 case clang::Type::ObjCInterface: {
8923 const clang::ObjCObjectType *objc_class_type =
8924 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
8925 if (objc_class_type) {
8926 clang::ObjCInterfaceDecl *class_interface_decl =
8927 objc_class_type->getInterface();
8931 if (class_interface_decl)
8932 printf(
"@class %s", class_interface_decl->getName().str().c_str());
8936 case clang::Type::Typedef:
8937 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
8944 case clang::Type::Auto:
8947 llvm::cast<clang::AutoType>(qual_type)
8949 .getAsOpaquePtr()));
8951 case clang::Type::Paren:
8955 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
8958 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
8966 const char *parent_name,
int tag_decl_kind,
8968 if (template_param_infos.
IsValid()) {
8969 std::string template_basename(parent_name);
8971 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
8972 template_basename.erase(i);
8975 template_basename.c_str(), tag_decl_kind,
8976 template_param_infos);
8991 clang::ObjCInterfaceDecl *decl) {
9015 std::make_unique<npdb::PdbAstBuilderClang>(*
this);
9020 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9021 uint64_t &alignment,
9022 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9023 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9025 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9038 field_offsets, base_offsets, vbase_offsets);
9045 clang::NamedDecl *nd =
9046 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9056 if (!label_or_err) {
9057 llvm::consumeError(label_or_err.takeError());
9061 llvm::StringRef mangled = label_or_err->lookup_name;
9069 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9070 static_cast<clang::Decl *
>(opaque_decl));
9072 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9076 if (!mc || !mc->shouldMangleCXXName(nd))
9081 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9086 llvm::SmallVector<char, 1024> buf;
9087 llvm::raw_svector_ostream llvm_ostrm(buf);
9088 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9090 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9093 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9095 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9099 mc->mangleName(nd, llvm_ostrm);
9115 if (clang::FunctionDecl *func_decl =
9116 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9117 return GetType(func_decl->getReturnType());
9118 if (clang::ObjCMethodDecl *objc_method =
9119 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9120 return GetType(objc_method->getReturnType());
9126 if (clang::FunctionDecl *func_decl =
9127 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9128 return func_decl->param_size();
9129 if (clang::ObjCMethodDecl *objc_method =
9130 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9131 return objc_method->param_size();
9137 clang::DeclContext
const *decl_ctx) {
9138 switch (clang_kind) {
9139 case Decl::TranslationUnit:
9141 case Decl::Namespace:
9152 if (decl_ctx->isFunctionOrMethod())
9154 if (decl_ctx->isRecord())
9164 std::vector<lldb_private::CompilerContext> &context) {
9165 if (decl_ctx ==
nullptr)
9168 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9169 if (clang_kind == Decl::TranslationUnit)
9174 context.push_back({compiler_kind, decl_ctx_name});
9177std::vector<lldb_private::CompilerContext>
9179 std::vector<lldb_private::CompilerContext> context;
9182 clang::Decl *decl = (clang::Decl *)opaque_decl;
9184 clang::DeclContext *decl_ctx = decl->getDeclContext();
9187 auto compiler_kind =
9189 context.push_back({compiler_kind, decl_name});
9196 if (clang::FunctionDecl *func_decl =
9197 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9198 if (idx < func_decl->param_size()) {
9199 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9201 return GetType(var_decl->getOriginalType());
9203 }
else if (clang::ObjCMethodDecl *objc_method =
9204 llvm::dyn_cast<clang::ObjCMethodDecl>(
9205 (clang::Decl *)opaque_decl)) {
9206 if (idx < objc_method->param_size())
9207 return GetType(objc_method->parameters()[idx]->getOriginalType());
9213 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9214 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9217 clang::Expr *init_expr = var_decl->getInit();
9220 std::optional<llvm::APSInt> value =
9230 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9231 std::vector<CompilerDecl> found_decls;
9233 if (opaque_decl_ctx && symbol_file) {
9234 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9235 std::set<DeclContext *> searched;
9236 std::multimap<DeclContext *, DeclContext *> search_queue;
9238 for (clang::DeclContext *decl_context = root_decl_ctx;
9239 decl_context !=
nullptr && found_decls.empty();
9240 decl_context = decl_context->getParent()) {
9241 search_queue.insert(std::make_pair(decl_context, decl_context));
9243 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9245 if (!searched.insert(it->second).second)
9250 for (clang::Decl *child : it->second->decls()) {
9251 if (clang::UsingDirectiveDecl *ud =
9252 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9253 if (ignore_using_decls)
9255 clang::DeclContext *from = ud->getCommonAncestor();
9256 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9257 search_queue.insert(
9258 std::make_pair(from, ud->getNominatedNamespace()));
9259 }
else if (clang::UsingDecl *ud =
9260 llvm::dyn_cast<clang::UsingDecl>(child)) {
9261 if (ignore_using_decls)
9263 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9264 clang::Decl *target = usd->getTargetDecl();
9265 if (clang::NamedDecl *nd =
9266 llvm::dyn_cast<clang::NamedDecl>(target)) {
9267 IdentifierInfo *ii = nd->getIdentifier();
9268 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9272 }
else if (clang::NamedDecl *nd =
9273 llvm::dyn_cast<clang::NamedDecl>(child)) {
9274 IdentifierInfo *ii = nd->getIdentifier();
9275 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9326 clang::DeclContext *child_decl_ctx,
9330 if (frame_decl_ctx && symbol_file) {
9331 std::set<DeclContext *> searched;
9332 std::multimap<DeclContext *, DeclContext *> search_queue;
9335 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9339 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9340 decl_ctx = decl_ctx->getParent()) {
9341 if (!decl_ctx->isLookupContext())
9343 if (decl_ctx == parent_decl_ctx)
9346 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9347 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9349 if (searched.find(it->second) != searched.end())
9357 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9360 searched.insert(it->second);
9364 for (clang::Decl *child : it->second->decls()) {
9365 if (clang::UsingDirectiveDecl *ud =
9366 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9367 clang::DeclContext *ns = ud->getNominatedNamespace();
9368 if (ns == parent_decl_ctx)
9371 clang::DeclContext *from = ud->getCommonAncestor();
9372 if (searched.find(ns) == searched.end())
9373 search_queue.insert(std::make_pair(from, ns));
9374 }
else if (child_name) {
9375 if (clang::UsingDecl *ud =
9376 llvm::dyn_cast<clang::UsingDecl>(child)) {
9377 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9378 clang::Decl *target = usd->getTargetDecl();
9379 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9383 IdentifierInfo *ii = nd->getIdentifier();
9384 if (ii ==
nullptr ||
9385 ii->getName() != child_name->
AsCString(
nullptr))
9408 if (opaque_decl_ctx) {
9409 clang::NamedDecl *named_decl =
9410 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9413 llvm::raw_string_ostream stream{name};
9415 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9416 named_decl->getNameForDiagnostic(stream, policy,
false);
9425 if (opaque_decl_ctx) {
9426 clang::NamedDecl *named_decl =
9427 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9435 if (!opaque_decl_ctx)
9438 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9439 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9441 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9443 }
else if (clang::FunctionDecl *fun_decl =
9444 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9445 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9446 return metadata->HasObjectPtr();
9452std::vector<lldb_private::CompilerContext>
9454 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9455 std::vector<lldb_private::CompilerContext> context;
9461 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9462 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9463 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9467 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9468 if (DC->isInlineNamespace())
9471 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9472 return NS->isAnonymousNamespace();
9479 if (decl_ctx == other)
9481 }
while (is_transparent_lookup_allowed(other) &&
9482 (other = other->getParent()));
9489 if (!opaque_decl_ctx)
9492 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9493 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9495 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9497 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9498 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9499 return metadata->GetObjectPtrLanguage();
9519 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9527 return llvm::dyn_cast<clang::CXXMethodDecl>(
9532clang::FunctionDecl *
9535 return llvm::dyn_cast<clang::FunctionDecl>(
9540clang::NamespaceDecl *
9543 return llvm::dyn_cast<clang::NamespaceDecl>(
9548std::optional<ClangASTMetadata>
9550 const Decl *
object) {
9558 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9581 lldbassert(started &&
"Unable to start a class type definition.");
9586 ts->SetDeclIsForcefullyCompleted(td);
9600 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9601 std::unique_ptr<ClangASTSource> ast_source)
9603 m_scratch_ast_source_up(std::move(ast_source)) {
9605 m_scratch_ast_source_up->InstallASTContext(*
this);
9606 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9607 m_scratch_ast_source_up->CreateProxy();
9608 SetExternalSource(proxy_ast_source);
9612 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9620 llvm::Triple triple)
9627 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9639 std::optional<IsolatedASTKind> ast_kind,
9640 bool create_on_demand) {
9643 if (
auto err = type_system_or_err.takeError()) {
9645 "Couldn't get scratch TypeSystemClang: {0}");
9648 auto ts_sp = *type_system_or_err;
9650 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9655 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9657 return std::static_pointer_cast<TypeSystemClang>(
9662static llvm::StringRef
9666 return "C++ modules";
9668 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9672 llvm::StringRef filter,
bool show_color) {
9674 output <<
"State of scratch Clang type system:\n";
9678 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9679 std::vector<KeyAndTS> sorted_typesystems;
9681 sorted_typesystems.emplace_back(a.first, a.second.get());
9682 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9685 for (
const auto &a : sorted_typesystems) {
9688 output <<
"State of scratch Clang type subsystem "
9690 a.second->Dump(output, filter, show_color);
9695 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9703 desired_type, options, ctx_obj);
9708 const ValueList &arg_value_list,
const char *name) {
9713 Process *process = target_sp->GetProcessSP().get();
9718 arg_value_list, name);
9721std::unique_ptr<UtilityFunction>
9728 return std::make_unique<ClangUtilityFunction>(
9729 *target_sp.get(), std::move(text), std::move(name),
9730 target_sp->GetDebugUtilityExpression());
9744 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9748 return std::make_unique<ClangASTSource>(
9753static llvm::StringRef
9757 return "scratch ASTContext for C++ module types";
9759 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9766 return *found_ast->second;
9769 std::shared_ptr<TypeSystemClang> new_ast_sp =
9779 const clang::RecordType *record_type =
9780 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9782 const clang::RecordDecl *record_decl =
9783 record_type->getDecl()->getDefinitionOrSelf();
9784 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9785 return metadata->IsForcefullyCompleted();
9794 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9798 metadata->SetIsForcefullyCompleted();
9806 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 const clang::EnumType * GetCompleteEnumType(const clang::ASTContext *ast, clang::QualType qual_type)
Returns the clang::EnumType of the specified qual_type.
static clang::QualType GetFullyUnqualifiedType_Impl(clang::ASTContext *ast, clang::QualType qual_type)
const TemplateArgument * GetNthTemplateArgument(const clang::ClassTemplateSpecializationDecl *decl, size_t idx, bool expand_pack)
static int64_t ReadVBaseOffsetFromVTable(Process &process, VTableContextBase &vtable_ctx, lldb::addr_t vtable_ptr, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl)
lldb_private::ThreadSafeDenseMap< clang::ASTContext *, TypeSystemClang * > ClangASTMap
static 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 const clang::RecordType * GetCompleteRecordType(const clang::ASTContext *ast, clang::QualType qual_type)
Returns the clang::RecordType of the specified qual_type.
static bool check_op_param(bool is_method, clang::OverloadedOperatorKind op_kind, bool unary, bool binary, uint32_t num_params)
static llvm::StringRef GetSpecializedASTName(ScratchTypeSystemClang::IsolatedASTKind feature)
static bool ObjCDeclHasIVars(clang::ObjCInterfaceDecl *class_interface_decl)
static lldb::addr_t GetVTableAddress(Process &process, VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout)
static 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 bool GetCompleteQualType(const clang::ASTContext *ast, clang::QualType qual_type)
static llvm::StringRef GetNameForIsolatedASTKind(ScratchTypeSystemClang::IsolatedASTKind kind)
Returns a human-readable name that uniquely identifiers the sub-AST kind.
static void InsertCompilerContext(TypeSystemClang *ts, clang::DeclContext *decl_ctx, std::vector< lldb_private::CompilerContext > &context)
static bool GetVBaseBitOffset(VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl, int32_t &bit_offset)
static bool QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext &ast, QualType qual_type)
static ClangASTMap & GetASTMap()
static void SetMemberOwningModule(clang::Decl *member, const clang::Decl *parent)
static bool ClassTemplateAllowsToInstantiationArgs(ClassTemplateDecl *class_template_decl, const TypeSystemClang::TemplateParameterInfos &instantiation_values)
Returns true if the given class template declaration could produce an instantiation with the specifie...
static const clang::ObjCObjectType * GetCompleteObjCObjectType(const clang::ASTContext *ast, QualType qual_type)
Returns the clang::ObjCObjectType of the specified qual_type.
#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)
size_t GetIndexOfChildMemberWithName(llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) const
Lookup a child member given a name.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
lldb::Encoding GetEncoding() const
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.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
const char * AsCString(const char *value_if_empty) 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)
llvm::Expected< lldb::addr_t > ReadPointerFromMemory(lldb::addr_t vm_addr)
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) const
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
void SetParameterPack(std::unique_ptr< TemplateParameterInfos > args)
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
clang::ClassTemplateDecl * CreateClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef class_name, int kind, const TemplateParameterInfos &infos)
clang::ClassTemplateDecl * ParseClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *parent_name, int tag_decl_kind, const TypeSystemClang::TemplateParameterInfos &template_param_infos)
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)
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 *)
std::shared_ptr< clang::TargetOptions > & getTargetOptions()
static TypeSystemClang * GetASTContext(clang::ASTContext *ast_ctx)
bool IsReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool *is_rvalue) override
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
const char * GetTargetTriple()
TypeSystemClang(llvm::StringRef name, llvm::Triple triple)
Constructs a TypeSystemClang with an ASTContext using the given triple.
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, Module *module, Target *target)
clang::TargetInfo * getTargetInfo()
clang::FunctionTemplateDecl * CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::FunctionDecl *func_decl, const TemplateParameterInfos &infos)
CompilerType CreateArrayType(const CompilerType &element_type, std::optional< size_t > element_count, bool is_vector)
static bool AreTypesSame(CompilerType type1, CompilerType type2, bool ignore_qualifiers=false)
CompilerType GetArrayType(lldb::opaque_compiler_type_t type, uint64_t size) override
bool IsFunctionType(lldb::opaque_compiler_type_t type) override
CompilerType GetFunctionReturnType(lldb::opaque_compiler_type_t type) override
std::optional< ClangASTMetadata > GetMetadata(const clang::Decl *object)
CompilerType GetLValueReferenceType(lldb::opaque_compiler_type_t type) override
bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td)
lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override
bool CanPassInRegisters(const CompilerType &type) override
CompilerDecl GetStaticFieldWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
bool IsEnumerationType(lldb::opaque_compiler_type_t type, bool &is_signed) override
bool IsTemplateType(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
static bool IsCXXClassType(const CompilerType &type)
bool IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed) override
std::unique_ptr< npdb::PdbAstBuilderClang > m_native_pdb_ast_parser_up
uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override
static bool IsOperator(llvm::StringRef name, clang::OverloadedOperatorKind &op_kind)
bool IsCharType(lldb::opaque_compiler_type_t type) override
CompilerType CreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
static void SetFloatingInitializerForVariable(clang::VarDecl *var, const llvm::APFloat &init_value)
Initializes a variable with a floating point value.
uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) override
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) override
CompilerType GetType(clang::QualType qt)
Creates a CompilerType from the given QualType with the current TypeSystemClang instance as the Compi...
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override
std::string m_target_triple
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > bases)
bool IsBeingDefined(lldb::opaque_compiler_type_t type) override
CompilerType GetPromotedIntegerType(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
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.
static clang::VarDecl * AddVariableToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &var_type)
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
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
bool IsFloatingPointType(lldb::opaque_compiler_type_t type) 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
bool IsMemberDataPointerType(lldb::opaque_compiler_type_t type) 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)
bool HasPointerAuthQualifier(lldb::opaque_compiler_type_t type) override
static clang::QualType GetQualType(lldb::opaque_compiler_type_t type)
clang::PrintingPolicy GetTypePrintingPolicy()
Returns the PrintingPolicy used when generating the internal type names.
uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override
static clang::RecordDecl * GetAsRecordDecl(const CompilerType &type)
CompilerType GetPointerSizedIntType(bool is_signed)
uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl, bool omit_empty_base_classes)
lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) override
std::unique_ptr< DWARFASTParserClang > m_dwarf_ast_parser_up
CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size)
lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type) override
bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override
int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override
static void BuildIndirectFields(const CompilerType &type)
std::unique_ptr< clang::FileManager > m_file_manager_up
uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl, const clang::CXXBaseSpecifier *base_spec, bool omit_empty_base_classes)
bool IsAnonymousType(lldb::opaque_compiler_type_t type) override
bool Verify(lldb::opaque_compiler_type_t type) override
Verify the integrity of the type to catch CompilerTypes that mix and match invalid TypeSystem/Opaque ...
size_t GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override
void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type)
CompilerType CreateBlockPointerType(const CompilerType &function_type)
lldb::LanguageType GetMinimumLanguage(lldb::opaque_compiler_type_t type) override
bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size)
clang::ClassTemplateSpecializationDecl * CreateClassTemplateSpecializationDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::ClassTemplateDecl *class_template_decl, int kind, const TemplateParameterInfos &infos)
llvm::SmallVector< clang::ParmVarDecl * > CreateParameterDeclarations(clang::FunctionDecl *context, const clang::FunctionProtoType &prototype, const llvm::SmallVector< llvm::StringRef > ¶m_names)
For each parameter type of prototype, creates a clang::ParmVarDecl whose clang::DeclContext is contex...
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, int kind, lldb::LanguageType language, std::optional< ClangASTMetadata > metadata=std::nullopt, bool exports_symbols=false)
std::unique_ptr< clang::HeaderSearch > m_header_search_up
void Finalize() override
Free up any resources associated with this TypeSystem.
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, llvm::StringRef asm_label, const CompilerType &method_type, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
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.
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
CompilerType GetSizeType() override
static bool IsEnumType(lldb::opaque_compiler_type_t type)
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
CompilerType GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static bool SetObjCSuperClass(const CompilerType &type, const CompilerType &superclass_compiler_type)
clang::UsingDirectiveDecl * CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::NamespaceDecl *ns_decl)
static lldb::opaque_compiler_type_t GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type)
bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override
void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name)
Dump clang AST types from the symbol file.
CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override
static void DumpDeclHiearchy(clang::Decl *decl)
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
static clang::FunctionDecl * DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc)
bool IsScalarType(lldb::opaque_compiler_type_t type) override
bool GetPtrAuthAddressDiversity(lldb::opaque_compiler_type_t type) override
std::shared_ptr< clang::TargetOptions > m_target_options_rp
lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override
static bool IsClassType(lldb::opaque_compiler_type_t type)
bool IsDefined(lldb::opaque_compiler_type_t type) override
static bool IsObjCClassType(const CompilerType &type)
TypeMetadataMap m_type_metadata
Maps Types to their associated ClangASTMetadata.
CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override
bool RecordHasFields(const clang::RecordDecl *record_decl)
CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index) override
static std::optional< ClangASTMetadata > DeclContextGetMetaData(const CompilerDeclContext &dc, const clang::Decl *object)
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerDiffType(bool is_signed) 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
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)
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
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, uint32_t bitfield_bit_size)
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
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
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::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
std::vector< lldb_private::CompilerContext > DeclGetCompilerContext(void *opaque_decl) override
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
std::vector< lldb_private::CompilerContext > DeclContextGetCompilerContext(void *opaque_decl_ctx) override
void CreateASTContext()
Creates the internal ASTContext.
void SetExternalSource(llvm::IntrusiveRefCntPtr< clang::ExternalASTSource > ast_source_sp)
CompilerType GetCStringType(bool is_const)
bool IsAggregateType(lldb::opaque_compiler_type_t type) override
bool IsPromotableIntegerType(lldb::opaque_compiler_type_t type) override
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override
static LanguageSet GetSupportedLanguagesForTypes()
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
ConstString DeclContextGetName(void *opaque_decl_ctx) override
size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack) override
ConstString DeclGetName(void *opaque_decl) override
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)
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
AddressType GetAddressTypeOfChildren()
CompilerType GetCompilerType()
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.