11#include "clang/AST/DeclBase.h"
12#include "clang/AST/ExprCXX.h"
13#include "clang/Frontend/ASTConsumers.h"
14#include "llvm/ADT/ScopeExit.h"
15#include "llvm/Support/Casting.h"
16#include "llvm/Support/FormatAdapters.h"
17#include "llvm/Support/FormatVariadic.h"
24#include "clang/AST/ASTContext.h"
25#include "clang/AST/ASTImporter.h"
26#include "clang/AST/Attr.h"
27#include "clang/AST/CXXInheritance.h"
28#include "clang/AST/DeclObjC.h"
29#include "clang/AST/DeclTemplate.h"
30#include "clang/AST/Mangle.h"
31#include "clang/AST/QualTypeNames.h"
32#include "clang/AST/RecordLayout.h"
33#include "clang/AST/Type.h"
34#include "clang/AST/VTableBuilder.h"
35#include "clang/Basic/Builtins.h"
36#include "clang/Basic/Diagnostic.h"
37#include "clang/Basic/FileManager.h"
38#include "clang/Basic/FileSystemOptions.h"
39#include "clang/Basic/LangStandard.h"
40#include "clang/Basic/SourceManager.h"
41#include "clang/Basic/TargetInfo.h"
42#include "clang/Basic/TargetOptions.h"
43#include "clang/Frontend/FrontendOptions.h"
44#include "clang/Lex/HeaderSearch.h"
45#include "clang/Lex/HeaderSearchOptions.h"
46#include "clang/Lex/ModuleMap.h"
47#include "clang/Sema/Sema.h"
49#include "llvm/Support/Signals.h"
50#include "llvm/Support/Threading.h"
94using namespace llvm::dwarf;
96using llvm::StringSwitch;
101static void VerifyDecl(clang::Decl *decl) {
102 assert(decl &&
"VerifyDecl called with nullptr?");
128bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) {
130 lldbassert(&m1->getASTContext() == &m2->getASTContext() &&
131 "Methods should have the same AST context");
132 clang::ASTContext &context = m1->getASTContext();
134 const auto *m1Type = llvm::cast<clang::FunctionProtoType>(
135 context.getCanonicalType(m1->getType()));
137 const auto *m2Type = llvm::cast<clang::FunctionProtoType>(
138 context.getCanonicalType(m2->getType()));
140 auto compareArgTypes = [&context](
const clang::QualType &m1p,
141 const clang::QualType &m2p) {
142 return context.hasSameType(m1p.getUnqualifiedType(),
143 m2p.getUnqualifiedType());
148 return (m1->getNumParams() != m2->getNumParams()) ||
149 !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(),
150 m2Type->param_type_begin(), compareArgTypes);
156void addOverridesForMethod(clang::CXXMethodDecl *decl) {
157 if (!decl->isVirtual())
160 clang::CXXBasePaths paths;
161 llvm::SmallVector<clang::NamedDecl *, 4> decls;
163 auto find_overridden_methods =
164 [&decls, decl](
const clang::CXXBaseSpecifier *specifier,
165 clang::CXXBasePath &path) {
166 if (
auto *base_record = specifier->getType()->getAsCXXRecordDecl()) {
168 clang::DeclarationName name = decl->getDeclName();
172 if (name.getNameKind() == clang::DeclarationName::CXXDestructorName)
173 if (
auto *baseDtorDecl = base_record->getDestructor()) {
174 if (baseDtorDecl->isVirtual()) {
175 decls.push_back(baseDtorDecl);
182 for (path.Decls = base_record->lookup(name).begin();
183 path.Decls != path.Decls.end(); ++path.Decls) {
184 if (
auto *method_decl =
185 llvm::dyn_cast<clang::CXXMethodDecl>(*path.Decls))
186 if (method_decl->isVirtual() && !isOverload(decl, method_decl)) {
187 decls.push_back(method_decl);
196 if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) {
197 for (
auto *overridden_decl : decls)
198 decl->addOverriddenMethod(
199 llvm::cast<clang::CXXMethodDecl>(overridden_decl));
205 VTableContextBase &vtable_ctx,
207 const ASTRecordLayout &record_layout) {
211 uint32_t type_info = this_type.
GetTypeInfo(&pointee_type);
216 bool ptr_or_ref =
false;
217 if (type_info & (eTypeIsPointer | eTypeIsReference)) {
223 const uint32_t cpp_class = eTypeIsClass | eTypeIsCPlusPlus;
224 if ((type_info & cpp_class) != cpp_class)
229 vtable_ctx.isMicrosoft() ? record_layout.getVBPtrOffset().getQuantity()
243 vbtable_ptr_addr += vbtable_ptr_offset;
254 auto size = valobj.
GetData(data, err);
262 VTableContextBase &vtable_ctx,
264 const CXXRecordDecl *cxx_record_decl,
265 const CXXRecordDecl *base_class_decl) {
266 if (vtable_ctx.isMicrosoft()) {
267 clang::MicrosoftVTableContext &msoft_vtable_ctx =
268 static_cast<clang::MicrosoftVTableContext &
>(vtable_ctx);
272 const unsigned vbtable_index =
273 msoft_vtable_ctx.getVBTableIndex(cxx_record_decl, base_class_decl);
274 const lldb::addr_t base_offset_addr = vtable_ptr + vbtable_index * 4;
280 clang::ItaniumVTableContext &itanium_vtable_ctx =
281 static_cast<clang::ItaniumVTableContext &
>(vtable_ctx);
283 clang::CharUnits base_offset_offset =
284 itanium_vtable_ctx.getVirtualBaseOffsetOffset(cxx_record_decl,
287 vtable_ptr + base_offset_offset.getQuantity();
296 const ASTRecordLayout &record_layout,
297 const CXXRecordDecl *cxx_record_decl,
298 const CXXRecordDecl *base_class_decl,
299 int32_t &bit_offset) {
311 *process, vtable_ctx, vtable_ptr, cxx_record_decl, base_class_decl);
312 if (base_offset == INT64_MAX)
315 bit_offset = base_offset * 8;
325 static llvm::once_flag g_once_flag;
326 llvm::call_once(g_once_flag, []() {
333 bool is_complete_objc_class)
346 const clang::Decl *parent) {
347 if (!member || !parent)
354 member->setFromASTFile();
355 member->setOwningModuleID(
id.GetValue());
356 member->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
357 if (llvm::isa<clang::NamedDecl>(member))
358 if (
auto *dc = llvm::dyn_cast<clang::DeclContext>(parent)) {
359 dc->setHasExternalVisibleStorage(
true);
362 dc->setHasExternalLexicalStorage(
true);
369 clang::OverloadedOperatorKind &op_kind) {
371 if (!name.consume_front(
"operator"))
376 bool space_after_operator = name.consume_front(
" ");
378 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
379 .Case(
"+", clang::OO_Plus)
380 .Case(
"+=", clang::OO_PlusEqual)
381 .Case(
"++", clang::OO_PlusPlus)
382 .Case(
"-", clang::OO_Minus)
383 .Case(
"-=", clang::OO_MinusEqual)
384 .Case(
"--", clang::OO_MinusMinus)
385 .Case(
"->", clang::OO_Arrow)
386 .Case(
"->*", clang::OO_ArrowStar)
387 .Case(
"*", clang::OO_Star)
388 .Case(
"*=", clang::OO_StarEqual)
389 .Case(
"/", clang::OO_Slash)
390 .Case(
"/=", clang::OO_SlashEqual)
391 .Case(
"%", clang::OO_Percent)
392 .Case(
"%=", clang::OO_PercentEqual)
393 .Case(
"^", clang::OO_Caret)
394 .Case(
"^=", clang::OO_CaretEqual)
395 .Case(
"&", clang::OO_Amp)
396 .Case(
"&=", clang::OO_AmpEqual)
397 .Case(
"&&", clang::OO_AmpAmp)
398 .Case(
"|", clang::OO_Pipe)
399 .Case(
"|=", clang::OO_PipeEqual)
400 .Case(
"||", clang::OO_PipePipe)
401 .Case(
"~", clang::OO_Tilde)
402 .Case(
"!", clang::OO_Exclaim)
403 .Case(
"!=", clang::OO_ExclaimEqual)
404 .Case(
"=", clang::OO_Equal)
405 .Case(
"==", clang::OO_EqualEqual)
406 .Case(
"<", clang::OO_Less)
407 .Case(
"<=>", clang::OO_Spaceship)
408 .Case(
"<<", clang::OO_LessLess)
409 .Case(
"<<=", clang::OO_LessLessEqual)
410 .Case(
"<=", clang::OO_LessEqual)
411 .Case(
">", clang::OO_Greater)
412 .Case(
">>", clang::OO_GreaterGreater)
413 .Case(
">>=", clang::OO_GreaterGreaterEqual)
414 .Case(
">=", clang::OO_GreaterEqual)
415 .Case(
"()", clang::OO_Call)
416 .Case(
"[]", clang::OO_Subscript)
417 .Case(
",", clang::OO_Comma)
418 .Default(clang::NUM_OVERLOADED_OPERATORS);
421 if (op_kind != clang::NUM_OVERLOADED_OPERATORS)
433 if (!space_after_operator)
438 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
439 .Case(
"new", clang::OO_New)
440 .Case(
"new[]", clang::OO_Array_New)
441 .Case(
"delete", clang::OO_Delete)
442 .Case(
"delete[]", clang::OO_Array_Delete)
444 .Default(clang::NUM_OVERLOADED_OPERATORS);
449clang::AccessSpecifier
469 std::vector<std::string> Includes;
470 LangOptions::setLangDefaults(Opts, clang::Language::ObjCXX, arch.
GetTriple(),
471 Includes, clang::LangStandard::lang_gnucxx98);
473 Opts.setValueVisibilityMode(DefaultVisibility);
477 Opts.Trigraphs = !Opts.GNUMode;
482 Opts.ModulesLocalVisibility = 1;
486 llvm::Triple target_triple) {
488 if (!target_triple.str().empty())
498 ASTContext &existing_ctxt) {
514 if (!TypeSystemClangSupportsLanguage(language))
518 arch =
module->GetArchitecture();
528 if (triple.getVendor() == llvm::Triple::Apple &&
529 triple.getOS() == llvm::Triple::UnknownOS) {
530 if (triple.getArch() == llvm::Triple::arm ||
531 triple.getArch() == llvm::Triple::aarch64 ||
532 triple.getArch() == llvm::Triple::aarch64_32 ||
533 triple.getArch() == llvm::Triple::thumb) {
534 triple.setOS(llvm::Triple::IOS);
536 triple.setOS(llvm::Triple::MacOSX);
541 std::string ast_name =
542 "ASTContext for '" +
module->GetFileSpec().GetPath() + "'";
543 return std::make_shared<TypeSystemClang>(ast_name, triple);
544 }
else if (target && target->
IsValid())
545 return std::make_shared<ScratchTypeSystemClang>(*target, triple);
607 assert(s ==
nullptr || &s->getASTContext() ==
m_ast_up.get());
620 llvm::IntrusiveRefCntPtr<ExternalASTSource> ast_source_sp) {
622 ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(
true);
623 ast.setExternalSource(std::move(ast_source_sp));
636 const clang::Diagnostic &info)
override {
638 llvm::SmallVector<char, 32> diag_str(10);
639 info.FormatDiagnostic(diag_str);
640 diag_str.push_back(
'\0');
645 DiagnosticConsumer *
clone(DiagnosticsEngine &Diags)
const {
666 clang::FileSystemOptions file_system_options;
676 m_ast_up = std::make_unique<ASTContext>(
688 m_ast_up->InitBuiltinTypes(*target_info);
692 "Failed to initialize builtin ASTContext types for target '{0}'. "
693 "Printing variables may behave unexpectedly.",
699 static std::once_flag s_uninitialized_target_warning;
701 &s_uninitialized_target_warning);
707 llvm::makeIntrusiveRefCnt<ClangExternalASTSourceCallbacks>(*
this);
739#pragma mark Basic Types
742 ASTContext &ast, QualType qual_type) {
743 uint64_t qual_type_bit_size = ast.getTypeSize(qual_type);
744 return qual_type_bit_size == bit_size;
763 return GetType(ast.UnsignedCharTy);
765 return GetType(ast.UnsignedShortTy);
767 return GetType(ast.UnsignedIntTy);
769 return GetType(ast.UnsignedLongTy);
771 return GetType(ast.UnsignedLongLongTy);
773 return GetType(ast.UnsignedInt128Ty);
778 return GetType(ast.SignedCharTy);
786 return GetType(ast.LongLongTy);
797 return GetType(ast.LongDoubleTy);
801 return GetType(ast.Float128Ty);
806 if (bit_size && !(bit_size & 0x7u))
807 return GetType(ast.getExtVectorType(ast.UnsignedCharTy, bit_size / 8));
815 static const llvm::StringMap<lldb::BasicType> g_type_map = {
880 auto iter = g_type_map.find(name);
881 if (iter == g_type_map.end())
912 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
931 return GetType(ast.UnsignedCharTy);
933 return GetType(ast.UnsignedShortTy);
935 return GetType(ast.UnsignedIntTy);
940 if (type_name.contains(
"complex")) {
949 case DW_ATE_complex_float: {
950 CanQualType FloatComplexTy = ast.getComplexType(ast.FloatTy);
952 return GetType(FloatComplexTy);
954 CanQualType DoubleComplexTy = ast.getComplexType(ast.DoubleTy);
956 return GetType(DoubleComplexTy);
958 CanQualType LongDoubleComplexTy = ast.getComplexType(ast.LongDoubleTy);
960 return GetType(LongDoubleComplexTy);
970 if (type_name ==
"float" &&
973 if (type_name ==
"double" &&
976 if (type_name ==
"long double" &&
978 return GetType(ast.LongDoubleTy);
979 if (type_name ==
"__bf16" &&
981 return GetType(ast.BFloat16Ty);
982 if (type_name ==
"_Float16" &&
988 if ((type_name ==
"__float128" || type_name ==
"_Float128" ||
989 type_name ==
"f128") &&
991 return GetType(ast.Float128Ty);
998 return GetType(ast.LongDoubleTy);
1002 return GetType(ast.Float128Ty);
1006 if (!type_name.empty()) {
1007 if (type_name.starts_with(
"_BitInt"))
1008 return GetType(ast.getBitIntType(
false, bit_size));
1009 if (type_name ==
"wchar_t" &&
1014 if (type_name ==
"void" &&
1017 if (type_name.contains(
"long long") &&
1019 return GetType(ast.LongLongTy);
1020 if (type_name.contains(
"long") &&
1023 if (type_name.contains(
"short") &&
1026 if (type_name.contains(
"char")) {
1030 return GetType(ast.SignedCharTy);
1032 if (type_name.contains(
"int")) {
1049 return GetType(ast.LongLongTy);
1054 case DW_ATE_signed_char:
1055 if (type_name ==
"char") {
1060 return GetType(ast.SignedCharTy);
1063 case DW_ATE_unsigned:
1064 if (!type_name.empty()) {
1065 if (type_name.starts_with(
"unsigned _BitInt"))
1066 return GetType(ast.getBitIntType(
true, bit_size));
1067 if (type_name ==
"wchar_t") {
1074 if (type_name.contains(
"long long")) {
1076 return GetType(ast.UnsignedLongLongTy);
1077 }
else if (type_name.contains(
"long")) {
1079 return GetType(ast.UnsignedLongTy);
1080 }
else if (type_name.contains(
"short")) {
1082 return GetType(ast.UnsignedShortTy);
1083 }
else if (type_name.contains(
"char")) {
1085 return GetType(ast.UnsignedCharTy);
1086 }
else if (type_name.contains(
"int")) {
1088 return GetType(ast.UnsignedIntTy);
1090 return GetType(ast.UnsignedInt128Ty);
1095 return GetType(ast.UnsignedCharTy);
1097 return GetType(ast.UnsignedShortTy);
1099 return GetType(ast.UnsignedIntTy);
1101 return GetType(ast.UnsignedLongTy);
1103 return GetType(ast.UnsignedLongLongTy);
1105 return GetType(ast.UnsignedInt128Ty);
1108 case DW_ATE_unsigned_char:
1109 if (type_name ==
"char") {
1114 return GetType(ast.UnsignedCharTy);
1116 return GetType(ast.UnsignedShortTy);
1119 case DW_ATE_imaginary_float:
1131 if (!type_name.empty()) {
1132 if (type_name ==
"char16_t")
1134 if (type_name ==
"char32_t")
1136 if (type_name ==
"char8_t")
1145 "error: need to add support for DW_TAG_base_type '{0}' "
1146 "encoded with DW_ATE = {1:x}, bit_size = {2}",
1147 type_name, dw_ate, bit_size);
1153 QualType char_type(ast.CharTy);
1156 char_type.addConst();
1158 return GetType(ast.getPointerType(char_type));
1162 bool ignore_qualifiers) {
1173 if (ignore_qualifiers) {
1174 type1_qual = type1_qual.getUnqualifiedType();
1175 type2_qual = type2_qual.getUnqualifiedType();
1178 return ast->getASTContext().hasSameType(type1_qual, type2_qual);
1185 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
1186 if (
auto *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl))
1198 if (clang::ObjCInterfaceDecl *interface_decl =
1199 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
1201 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
1203 if (clang::ValueDecl *value_decl = llvm::dyn_cast<clang::ValueDecl>(decl))
1217 return GetType(value_decl->getType());
1220#pragma mark Structure, Unions, Classes
1224 if (!decl || !owning_module.
HasValue())
1227 decl->setFromASTFile();
1228 decl->setOwningModuleID(owning_module.
GetValue());
1229 decl->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
1235 bool is_framework,
bool is_explicit) {
1237 auto *ast_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1239 assert(ast_source &&
"external ast source was lost");
1257 clang::Module *module;
1258 auto parent_desc = ast_source->getSourceDescriptor(parent.
GetValue());
1260 name, parent_desc ? parent_desc->getModuleOrNull() :
nullptr,
1261 is_framework, is_explicit);
1263 return ast_source->GetIDForModule(module);
1265 return ast_source->RegisterModule(module);
1271 std::optional<ClangASTMetadata> metadata,
bool exports_symbols) {
1274 if (decl_ctx ==
nullptr)
1275 decl_ctx = ast.getTranslationUnitDecl();
1279 bool isInternal =
false;
1280 return CreateObjCClass(name, decl_ctx, owning_module, isInternal, metadata);
1289 bool has_name = !name.empty();
1290 CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1291 decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1292 decl->setDeclContext(decl_ctx);
1294 decl->setDeclName(&ast.Idents.get(name));
1322 if (isa<CXXRecordDecl>(decl_ctx) && exports_symbols)
1323 decl->setAnonymousStructOrUnion(
true);
1329 decl->setAccess(AS_public);
1332 decl_ctx->addDecl(decl);
1334 return GetType(ast.getCanonicalTagType(decl));
1341QualType GetValueParamType(
const clang::TemplateArgument &argument) {
1342 switch (argument.getKind()) {
1343 case TemplateArgument::Integral:
1344 return argument.getIntegralType();
1345 case TemplateArgument::StructuralValue:
1346 return argument.getStructuralValueType();
1356 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1357 const bool parameter_pack =
false;
1358 const bool is_typename =
false;
1359 const unsigned depth = 0;
1360 const size_t num_template_params = template_param_infos.
Size();
1361 DeclContext *
const decl_context =
1362 ast.getTranslationUnitDecl();
1364 auto const &args = template_param_infos.
GetArgs();
1365 auto const &names = template_param_infos.
GetNames();
1366 for (
size_t i = 0; i < num_template_params; ++i) {
1367 const char *name = names[i];
1369 IdentifierInfo *identifier_info =
nullptr;
1370 if (name && name[0])
1371 identifier_info = &ast.Idents.get(name);
1372 TemplateArgument
const &targ = args[i];
1373 QualType template_param_type = GetValueParamType(targ);
1374 if (!template_param_type.isNull()) {
1375 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1376 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1377 identifier_info, template_param_type, parameter_pack,
1378 ast.getTrivialTypeSourceInfo(template_param_type)));
1380 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1381 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1382 identifier_info, is_typename, parameter_pack));
1387 IdentifierInfo *identifier_info =
nullptr;
1389 identifier_info = &ast.Idents.get(template_param_infos.
GetPackName());
1390 const bool parameter_pack_true =
true;
1392 QualType template_param_type =
1396 if (!template_param_type.isNull()) {
1397 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1398 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1399 num_template_params, identifier_info, template_param_type,
1400 parameter_pack_true,
1401 ast.getTrivialTypeSourceInfo(template_param_type)));
1403 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1404 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1405 num_template_params, identifier_info, is_typename,
1406 parameter_pack_true));
1409 clang::Expr *
const requires_clause =
nullptr;
1410 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1411 ast, SourceLocation(), SourceLocation(), template_param_decls,
1412 SourceLocation(), requires_clause);
1413 return template_param_list;
1418 clang::FunctionDecl *func_decl,
1423 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1425 ast, template_param_infos, template_param_decls);
1426 FunctionTemplateDecl *func_tmpl_decl =
1427 FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1428 func_tmpl_decl->setDeclContext(decl_ctx);
1429 func_tmpl_decl->setLocation(func_decl->getLocation());
1430 func_tmpl_decl->setDeclName(func_decl->getDeclName());
1431 func_tmpl_decl->setTemplateParameters(template_param_list);
1432 func_tmpl_decl->init(func_decl);
1435 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1436 i < template_param_decl_count; ++i) {
1438 template_param_decls[i]->setDeclContext(func_decl);
1440 func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
1442 return func_tmpl_decl;
1446 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1448 TemplateArgumentList *template_args_ptr = TemplateArgumentList::CreateCopy(
1449 func_decl->getASTContext(), infos.
GetArgs());
1451 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
1452 template_args_ptr,
nullptr);
1459 const TemplateArgument &value) {
1460 if (llvm::isa<TemplateTypeParmDecl>(param)) {
1462 if (value.getKind() != TemplateArgument::Type)
1464 }
else if (
auto *type_param =
1465 llvm::dyn_cast<NonTypeTemplateParmDecl>(param)) {
1467 QualType value_param_type = GetValueParamType(value);
1468 if (value_param_type.isNull())
1472 if (type_param->getType() != value_param_type)
1480 "Don't know how to compare template parameter to passed"
1481 " value. Decl kind of parameter is: {0}",
1482 param->getDeclKindName());
1483 lldbassert(
false &&
"Can't compare this TemplateParmDecl subclass");
1498 ClassTemplateDecl *class_template_decl,
1501 TemplateParameterList ¶ms = *class_template_decl->getTemplateParameters();
1507 std::optional<NamedDecl *> pack_parameter;
1509 size_t non_pack_params = params.size();
1510 for (
size_t i = 0; i < params.size(); ++i) {
1511 NamedDecl *param = params.getParam(i);
1512 if (param->isParameterPack()) {
1513 pack_parameter = param;
1514 non_pack_params = i;
1522 if (non_pack_params != instantiation_values.
Size())
1540 for (
const auto pair :
1541 llvm::zip_first(instantiation_values.
GetArgs(), params)) {
1542 const TemplateArgument &passed_arg = std::get<0>(pair);
1543 NamedDecl *found_param = std::get<1>(pair);
1548 return class_template_decl;
1553 llvm::StringRef class_name,
int kind,
1557 ClassTemplateDecl *class_template_decl =
nullptr;
1558 if (decl_ctx ==
nullptr)
1559 decl_ctx = ast.getTranslationUnitDecl();
1561 IdentifierInfo &identifier_info = ast.Idents.get(class_name);
1562 DeclarationName decl_name(&identifier_info);
1565 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1566 for (NamedDecl *decl : result) {
1567 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1568 if (!class_template_decl)
1577 template_param_infos))
1579 return class_template_decl;
1582 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1585 ast, template_param_infos, template_param_decls);
1587 CXXRecordDecl *template_cxx_decl =
1588 CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1589 template_cxx_decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1591 template_cxx_decl->setDeclContext(decl_ctx);
1592 template_cxx_decl->setDeclName(decl_name);
1595 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1596 i < template_param_decl_count; ++i) {
1597 template_param_decls[i]->setDeclContext(template_cxx_decl);
1605 class_template_decl =
1606 ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1608 class_template_decl->setDeclContext(decl_ctx);
1609 class_template_decl->setDeclName(decl_name);
1610 class_template_decl->setTemplateParameters(template_param_list);
1611 class_template_decl->init(template_cxx_decl);
1612 template_cxx_decl->setDescribedClassTemplate(class_template_decl);
1615 class_template_decl->setAccess(AS_public);
1617 decl_ctx->addDecl(class_template_decl);
1619 VerifyDecl(class_template_decl);
1621 return class_template_decl;
1624TemplateTemplateParmDecl *
1628 auto *decl_ctx = ast.getTranslationUnitDecl();
1630 IdentifierInfo &identifier_info = ast.Idents.get(template_name);
1631 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1635 ast, template_param_infos, template_param_decls);
1641 return TemplateTemplateParmDecl::Create(
1642 ast, decl_ctx, SourceLocation(),
1644 false, &identifier_info,
1645 TemplateNameKind::TNK_Type_template,
true,
1646 template_param_list);
1649ClassTemplateSpecializationDecl *
1652 ClassTemplateDecl *class_template_decl,
int kind,
1655 llvm::SmallVector<clang::TemplateArgument, 2> args(
1656 template_param_infos.
Size() +
1659 auto const &orig_args = template_param_infos.
GetArgs();
1660 std::copy(orig_args.begin(), orig_args.end(), args.begin());
1662 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1665 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1666 ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
1667 class_template_specialization_decl->setTagKind(
1668 static_cast<TagDecl::TagKind
>(kind));
1669 class_template_specialization_decl->setDeclContext(decl_ctx);
1670 class_template_specialization_decl->setInstantiationOf(class_template_decl);
1671 class_template_specialization_decl->setTemplateArgs(
1672 TemplateArgumentList::CreateCopy(ast, args));
1673 void *insert_pos =
nullptr;
1674 if (class_template_decl->findSpecialization(args, insert_pos))
1676 class_template_decl->AddSpecialization(class_template_specialization_decl,
1678 class_template_specialization_decl->setDeclName(
1679 class_template_decl->getDeclName());
1684 class_template_specialization_decl->setStrictPackMatch(
false);
1687 decl_ctx->addDecl(class_template_specialization_decl);
1689 class_template_specialization_decl->setSpecializationKind(
1690 TSK_ExplicitSpecialization);
1692 return class_template_specialization_decl;
1696 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1697 if (class_template_specialization_decl) {
1699 return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
1705 clang::OverloadedOperatorKind op_kind,
1706 bool unary,
bool binary,
1707 uint32_t num_params) {
1709 if (op_kind == OO_Call)
1715 if (num_params == 1)
1717 if (num_params == 2)
1724 bool is_method, clang::OverloadedOperatorKind op_kind,
1725 uint32_t num_params) {
1733 case OO_Array_Delete:
1737#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1739 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1741#include "clang/Basic/OperatorKinds.def"
1749 uint32_t &bitfield_bit_size) {
1751 if (field ==
nullptr)
1754 if (field->isBitField()) {
1755 Expr *bit_width_expr = field->getBitWidth();
1756 if (bit_width_expr) {
1757 if (std::optional<llvm::APSInt> bit_width_apsint =
1758 bit_width_expr->getIntegerConstantExpr(ast)) {
1759 bitfield_bit_size = bit_width_apsint->getLimitedValue(
UINT32_MAX);
1768 if (record_decl ==
nullptr)
1771 if (!record_decl->field_empty())
1775 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1776 if (cxx_record_decl) {
1777 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1778 for (base_class = cxx_record_decl->bases_begin(),
1779 base_class_end = cxx_record_decl->bases_end();
1780 base_class != base_class_end; ++base_class) {
1781 assert(record_decl != base_class->getType()->getAsCXXRecordDecl() &&
1782 "Base can't inherit from itself.");
1794 if (std::optional<ClangASTMetadata> meta_data =
GetMetadata(record_decl);
1795 meta_data && meta_data->IsForcefullyCompleted())
1801#pragma mark Objective-C Classes
1804 llvm::StringRef name, clang::DeclContext *decl_ctx,
1806 std::optional<ClangASTMetadata> metadata) {
1808 assert(!name.empty());
1810 decl_ctx = ast.getTranslationUnitDecl();
1812 ObjCInterfaceDecl *decl =
1813 ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
1814 decl->setDeclContext(decl_ctx);
1815 decl->setDeclName(&ast.Idents.get(name));
1816 decl->setImplicit(isInternal);
1822 return GetType(ast.getObjCInterfaceType(decl));
1831 bool omit_empty_base_classes) {
1832 uint32_t num_bases = 0;
1833 if (cxx_record_decl) {
1834 if (omit_empty_base_classes) {
1835 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1836 for (base_class = cxx_record_decl->bases_begin(),
1837 base_class_end = cxx_record_decl->bases_end();
1838 base_class != base_class_end; ++base_class) {
1845 num_bases = cxx_record_decl->getNumBases();
1850#pragma mark Namespace Declarations
1853 const char *name, clang::DeclContext *decl_ctx,
1855 NamespaceDecl *namespace_decl =
nullptr;
1857 TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
1859 decl_ctx = translation_unit_decl;
1862 IdentifierInfo &identifier_info = ast.Idents.get(name);
1863 DeclarationName decl_name(&identifier_info);
1864 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1865 for (NamedDecl *decl : result) {
1866 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1868 return namespace_decl;
1871 namespace_decl = NamespaceDecl::Create(ast, decl_ctx, is_inline,
1872 SourceLocation(), SourceLocation(),
1873 &identifier_info,
nullptr,
false);
1875 decl_ctx->addDecl(namespace_decl);
1877 if (decl_ctx == translation_unit_decl) {
1878 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1880 return namespace_decl;
1883 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1884 SourceLocation(),
nullptr,
nullptr,
false);
1885 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1886 translation_unit_decl->addDecl(namespace_decl);
1887 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace());
1889 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1890 if (parent_namespace_decl) {
1891 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1893 return namespace_decl;
1895 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1896 SourceLocation(),
nullptr,
nullptr,
false);
1897 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1898 parent_namespace_decl->addDecl(namespace_decl);
1899 assert(namespace_decl ==
1900 parent_namespace_decl->getAnonymousNamespace());
1902 assert(
false &&
"GetUniqueNamespaceDeclaration called with no name and "
1903 "no namespace as decl_ctx");
1911 VerifyDecl(namespace_decl);
1912 return namespace_decl;
1919 clang::BlockDecl *decl =
1920 clang::BlockDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1921 decl->setDeclContext(ctx);
1930 clang::DeclContext *right,
1931 clang::DeclContext *root) {
1932 if (root ==
nullptr)
1935 std::set<clang::DeclContext *> path_left;
1936 for (clang::DeclContext *d = left; d !=
nullptr; d = d->getParent())
1937 path_left.insert(d);
1939 for (clang::DeclContext *d = right; d !=
nullptr; d = d->getParent())
1940 if (path_left.find(d) != path_left.end())
1948 clang::NamespaceDecl *ns_decl) {
1949 if (decl_ctx && ns_decl) {
1950 auto *translation_unit =
getASTContext().getTranslationUnitDecl();
1951 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
1953 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
1954 clang::SourceLocation(), ns_decl,
1957 decl_ctx->addDecl(using_decl);
1967 clang::NamedDecl *target) {
1968 if (current_decl_ctx && target) {
1969 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
1971 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(),
false);
1973 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
1975 target->getDeclName(), using_decl, target);
1977 using_decl->addShadowDecl(shadow_decl);
1978 current_decl_ctx->addDecl(using_decl);
1986 const char *name, clang::QualType type) {
1988 clang::VarDecl *var_decl =
1989 clang::VarDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1990 var_decl->setDeclContext(decl_context);
1991 if (name && name[0])
1992 var_decl->setDeclName(&
getASTContext().Idents.getOwn(name));
1993 var_decl->setType(type);
1995 var_decl->setAccess(clang::AS_public);
1996 decl_context->addDecl(var_decl);
2005 switch (basic_type) {
2007 return ast->VoidTy.getAsOpaquePtr();
2009 return ast->CharTy.getAsOpaquePtr();
2011 return ast->SignedCharTy.getAsOpaquePtr();
2013 return ast->UnsignedCharTy.getAsOpaquePtr();
2015 return ast->getWCharType().getAsOpaquePtr();
2017 return ast->getSignedWCharType().getAsOpaquePtr();
2019 return ast->getUnsignedWCharType().getAsOpaquePtr();
2021 return ast->Char8Ty.getAsOpaquePtr();
2023 return ast->Char16Ty.getAsOpaquePtr();
2025 return ast->Char32Ty.getAsOpaquePtr();
2027 return ast->ShortTy.getAsOpaquePtr();
2029 return ast->UnsignedShortTy.getAsOpaquePtr();
2031 return ast->IntTy.getAsOpaquePtr();
2033 return ast->UnsignedIntTy.getAsOpaquePtr();
2035 return ast->LongTy.getAsOpaquePtr();
2037 return ast->UnsignedLongTy.getAsOpaquePtr();
2039 return ast->LongLongTy.getAsOpaquePtr();
2041 return ast->UnsignedLongLongTy.getAsOpaquePtr();
2043 return ast->Int128Ty.getAsOpaquePtr();
2045 return ast->UnsignedInt128Ty.getAsOpaquePtr();
2047 return ast->BoolTy.getAsOpaquePtr();
2049 return ast->HalfTy.getAsOpaquePtr();
2051 return ast->FloatTy.getAsOpaquePtr();
2053 return ast->DoubleTy.getAsOpaquePtr();
2055 return ast->LongDoubleTy.getAsOpaquePtr();
2057 return ast->Float128Ty.getAsOpaquePtr();
2059 return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
2061 return ast->getComplexType(ast->DoubleTy).getAsOpaquePtr();
2063 return ast->getComplexType(ast->LongDoubleTy).getAsOpaquePtr();
2065 return ast->getObjCIdType().getAsOpaquePtr();
2067 return ast->getObjCClassType().getAsOpaquePtr();
2069 return ast->getObjCSelType().getAsOpaquePtr();
2071 return ast->NullPtrTy.getAsOpaquePtr();
2077#pragma mark Function Types
2079clang::DeclarationName
2082 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2083 if (!
IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2092 const clang::FunctionProtoType *function_type =
2093 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2094 if (function_type ==
nullptr)
2095 return clang::DeclarationName();
2097 const bool is_method =
false;
2098 const unsigned int num_params = function_type->getNumParams();
2100 is_method, op_kind, num_params))
2101 return clang::DeclarationName();
2103 return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
2107 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
2108 printing_policy.SuppressTagKeyword =
true;
2111 printing_policy.SuppressInlineNamespace =
2112 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None);
2113 printing_policy.SuppressUnwrittenScope =
false;
2125 printing_policy.SuppressDefaultTemplateArgs =
false;
2126 return printing_policy;
2133 llvm::raw_string_ostream os(result);
2134 named_decl->getNameForDiagnostic(os, printing_policy, qualified);
2140 llvm::StringRef name,
const CompilerType &function_clang_type,
2141 clang::StorageClass storage,
bool is_inline, llvm::StringRef asm_label) {
2142 FunctionDecl *func_decl =
nullptr;
2145 decl_ctx = ast.getTranslationUnitDecl();
2147 const bool hasWrittenPrototype =
true;
2148 const bool isConstexprSpecified =
false;
2150 clang::DeclarationName declarationName =
2152 func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
2153 func_decl->setDeclContext(decl_ctx);
2154 func_decl->setDeclName(declarationName);
2156 func_decl->setStorageClass(storage);
2157 func_decl->setInlineSpecified(is_inline);
2158 func_decl->setHasWrittenPrototype(hasWrittenPrototype);
2159 func_decl->setConstexprKind(isConstexprSpecified
2160 ? ConstexprSpecKind::Constexpr
2161 : ConstexprSpecKind::Unspecified);
2173 if (!asm_label.empty())
2174 func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label));
2177 decl_ctx->addDecl(func_decl);
2179 VerifyDecl(func_decl);
2185 const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
2186 bool is_variadic,
unsigned type_quals, clang::CallingConv cc,
2187 clang::RefQualifierKind ref_qual) {
2191 std::vector<QualType> qual_type_args;
2193 for (
const auto &arg : args) {
2208 FunctionProtoType::ExtProtoInfo proto_info;
2209 proto_info.ExtInfo = cc;
2210 proto_info.Variadic = is_variadic;
2211 proto_info.ExceptionSpec = EST_None;
2212 proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
2213 proto_info.RefQualifier = ref_qual;
2221 const char *name,
const CompilerType ¶m_type,
int storage,
2224 auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
2225 decl->setDeclContext(decl_ctx);
2226 if (name && name[0])
2227 decl->setDeclName(&ast.Idents.get(name));
2229 decl->setStorageClass(
static_cast<clang::StorageClass
>(storage));
2232 decl_ctx->addDecl(decl);
2239 QualType block_type =
m_ast_up->getBlockPointerType(
2245#pragma mark Array Types
2249 std::optional<size_t> element_count,
2262 clang::ArraySizeModifier::Normal, 0));
2268 llvm::APInt ap_element_count(64, *element_count);
2270 ap_element_count,
nullptr,
2271 clang::ArraySizeModifier::Normal, 0));
2275 llvm::StringRef type_name,
2276 const std::initializer_list<std::pair<const char *, CompilerType>>
2283 lldbassert(0 &&
"Trying to create a type for an existing name");
2288 llvm::to_underlying(clang::TagTypeKind::Struct),
2291 for (
const auto &field : type_fields)
2300 llvm::StringRef type_name,
2301 const std::initializer_list<std::pair<const char *, CompilerType>>
2313#pragma mark Enumeration Types
2316 llvm::StringRef name, clang::DeclContext *decl_ctx,
2318 const CompilerType &integer_clang_type,
bool is_scoped,
2319 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind) {
2326 EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
2327 enum_decl->setDeclContext(decl_ctx);
2329 enum_decl->setDeclName(&ast.Idents.get(name));
2330 enum_decl->setScoped(is_scoped);
2331 enum_decl->setScopedUsingClassTag(is_scoped);
2332 enum_decl->setFixed(
false);
2335 decl_ctx->addDecl(enum_decl);
2339 clang::EnumExtensibilityAttr::CreateImplicit(ast, *enum_kind));
2344 enum_decl->setAccess(AS_public);
2346 return GetType(ast.getCanonicalTagType(enum_decl));
2357 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
2358 return GetType(ast.SignedCharTy);
2360 if (bit_size == ast.getTypeSize(ast.ShortTy))
2363 if (bit_size == ast.getTypeSize(ast.IntTy))
2366 if (bit_size == ast.getTypeSize(ast.LongTy))
2369 if (bit_size == ast.getTypeSize(ast.LongLongTy))
2370 return GetType(ast.LongLongTy);
2372 if (bit_size == ast.getTypeSize(ast.Int128Ty))
2375 if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
2376 return GetType(ast.UnsignedCharTy);
2378 if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
2379 return GetType(ast.UnsignedShortTy);
2381 if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
2382 return GetType(ast.UnsignedIntTy);
2384 if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
2385 return GetType(ast.UnsignedLongTy);
2387 if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
2388 return GetType(ast.UnsignedLongLongTy);
2390 if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
2391 return GetType(ast.UnsignedInt128Ty);
2418 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2420 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2421 named_decl->getDeclName().getAsString().c_str());
2423 printf(
"%20s\n", decl_ctx->getDeclKindName());
2429 if (decl ==
nullptr)
2433 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2435 bool is_injected_class_name =
2436 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2437 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2438 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2439 record_decl->getDeclName().getAsString().c_str(),
2440 is_injected_class_name ?
" (injected class name)" :
"");
2443 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2445 printf(
"%20s: %s\n", decl->getDeclKindName(),
2446 named_decl->getDeclName().getAsString().c_str());
2448 printf(
"%20s\n", decl->getDeclKindName());
2454 clang::Decl *decl) {
2458 ExternalASTSource *ast_source = ast->getExternalSource();
2463 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2464 if (tag_decl->isCompleteDefinition())
2467 if (!tag_decl->hasExternalLexicalStorage())
2470 ast_source->CompleteType(tag_decl);
2472 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2473 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2474 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2475 if (objc_interface_decl->getDefinition())
2478 if (!objc_interface_decl->hasExternalLexicalStorage())
2481 ast_source->CompleteType(objc_interface_decl);
2483 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2513std::optional<ClangASTMetadata>
2519 return std::nullopt;
2522std::optional<ClangASTMetadata>
2528 return std::nullopt;
2550 if (find(mask, type->getTypeClass()) != mask.end())
2552 switch (type->getTypeClass()) {
2555 case clang::Type::Atomic:
2556 type = cast<clang::AtomicType>(type)->getValueType();
2558 case clang::Type::Auto:
2559 case clang::Type::Decltype:
2560 case clang::Type::Paren:
2561 case clang::Type::SubstTemplateTypeParm:
2562 case clang::Type::TemplateSpecialization:
2563 case clang::Type::Typedef:
2564 case clang::Type::TypeOf:
2565 case clang::Type::TypeOfExpr:
2566 case clang::Type::Using:
2567 case clang::Type::PredefinedSugar:
2568 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2582 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2583 switch (type_class) {
2584 case clang::Type::ObjCInterface:
2585 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2587 case clang::Type::ObjCObjectPointer:
2589 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2590 ->getPointeeType());
2591 case clang::Type::Enum:
2592 case clang::Type::Record:
2593 return llvm::cast<clang::TagType>(qual_type)
2595 ->getDefinitionOrSelf();
2607static const clang::RecordType *
2609 assert(qual_type->isRecordType());
2611 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2613 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2617 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2620 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2621 const bool fields_loaded =
2622 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2625 if (is_complete && fields_loaded)
2633 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2634 if (external_ast_source) {
2635 external_ast_source->CompleteType(cxx_record_decl);
2636 if (cxx_record_decl->isCompleteDefinition()) {
2637 cxx_record_decl->field_begin();
2638 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
2650 clang::QualType qual_type) {
2651 assert(qual_type->isEnumeralType());
2654 const clang::EnumType *enum_type =
2655 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2657 auto *tag_decl = enum_type->getAsTagDecl();
2661 if (tag_decl->getDefinition())
2665 if (!tag_decl->hasExternalLexicalStorage())
2669 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2670 if (!external_ast_source)
2673 external_ast_source->CompleteType(tag_decl);
2681static const clang::ObjCObjectType *
2683 assert(qual_type->isObjCObjectType());
2686 const clang::ObjCObjectType *objc_class_type =
2687 llvm::cast<clang::ObjCObjectType>(qual_type);
2689 clang::ObjCInterfaceDecl *class_interface_decl =
2690 objc_class_type->getInterface();
2693 if (!class_interface_decl)
2694 return objc_class_type;
2697 if (class_interface_decl->getDefinition())
2698 return objc_class_type;
2701 if (!class_interface_decl->hasExternalLexicalStorage())
2705 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2706 if (!external_ast_source)
2709 external_ast_source->CompleteType(class_interface_decl);
2710 return objc_class_type;
2714 clang::QualType qual_type) {
2716 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2717 switch (type_class) {
2718 case clang::Type::ConstantArray:
2719 case clang::Type::IncompleteArray:
2720 case clang::Type::VariableArray: {
2721 const clang::ArrayType *array_type =
2722 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2727 case clang::Type::Record: {
2729 return !RT->isIncompleteType();
2734 case clang::Type::Enum: {
2736 return !ET->isIncompleteType();
2740 case clang::Type::ObjCObject:
2741 case clang::Type::ObjCInterface: {
2743 return !OT->isIncompleteType();
2748 case clang::Type::Attributed:
2750 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType());
2752 case clang::Type::MemberPointer:
2755 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2756 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2757 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2760 return !qual_type.getTypePtr()->isIncompleteType();
2775 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2782 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2783 switch (type_class) {
2784 case clang::Type::IncompleteArray:
2785 case clang::Type::VariableArray:
2786 case clang::Type::ConstantArray:
2787 case clang::Type::ExtVector:
2788 case clang::Type::Vector:
2789 case clang::Type::Record:
2790 case clang::Type::ObjCObject:
2791 case clang::Type::ObjCInterface:
2803 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2804 switch (type_class) {
2805 case clang::Type::Record: {
2806 if (
const clang::RecordType *record_type =
2807 llvm::dyn_cast_or_null<clang::RecordType>(
2808 qual_type.getTypePtrOrNull())) {
2809 if (
const clang::RecordDecl *record_decl = record_type->getDecl()) {
2810 return record_decl->isAnonymousStructOrUnion();
2824 uint64_t *size,
bool *is_incomplete) {
2827 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2828 switch (type_class) {
2832 case clang::Type::ConstantArray:
2833 if (element_type_ptr)
2835 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2839 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2841 .getLimitedValue(ULLONG_MAX);
2843 *is_incomplete =
false;
2846 case clang::Type::IncompleteArray:
2847 if (element_type_ptr)
2849 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2855 *is_incomplete =
true;
2858 case clang::Type::VariableArray:
2859 if (element_type_ptr)
2861 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2867 *is_incomplete =
false;
2870 case clang::Type::DependentSizedArray:
2871 if (element_type_ptr)
2874 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2880 *is_incomplete =
false;
2883 if (element_type_ptr)
2884 element_type_ptr->
Clear();
2888 *is_incomplete =
false;
2896 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2897 switch (type_class) {
2898 case clang::Type::Vector: {
2899 const clang::VectorType *vector_type =
2900 qual_type->getAs<clang::VectorType>();
2903 *size = vector_type->getNumElements();
2905 *element_type =
GetType(vector_type->getElementType());
2909 case clang::Type::ExtVector: {
2910 const clang::ExtVectorType *ext_vector_type =
2911 qual_type->getAs<clang::ExtVectorType>();
2912 if (ext_vector_type) {
2914 *size = ext_vector_type->getNumElements();
2918 ext_vector_type->getElementType().getAsOpaquePtr());
2934 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
2937 clang::ObjCInterfaceDecl *result_iface_decl =
2938 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
2940 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
2944 return (ast_metadata->GetISAPtr() != 0);
2948 return GetQualType(type).getUnqualifiedType()->isCharType();
2970 if (!pointee_or_element_clang_type.
IsValid())
2973 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
2974 if (pointee_or_element_clang_type.
IsCharType()) {
2975 if (type_flags.
Test(eTypeIsArray)) {
2978 length = llvm::cast<clang::ConstantArrayType>(
2992 if (
auto pointer_auth = qual_type.getPointerAuth())
2993 return pointer_auth.getKey();
3002 if (
auto pointer_auth = qual_type.getPointerAuth())
3003 return pointer_auth.getExtraDiscriminator();
3012 if (
auto pointer_auth = qual_type.getPointerAuth())
3013 return pointer_auth.isAddressDiscriminated();
3019 auto isFunctionType = [&](clang::QualType qual_type) {
3020 return qual_type->isFunctionType();
3034 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3035 switch (type_class) {
3036 case clang::Type::Record:
3038 const clang::CXXRecordDecl *cxx_record_decl =
3039 qual_type->getAsCXXRecordDecl();
3040 if (cxx_record_decl) {
3041 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3044 const clang::RecordType *record_type =
3045 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3047 if (
const clang::RecordDecl *record_decl =
3048 record_type->getDecl()->getDefinition()) {
3051 clang::RecordDecl::field_iterator field_pos,
3052 field_end = record_decl->field_end();
3053 uint32_t num_fields = 0;
3054 bool is_hva =
false;
3055 bool is_hfa =
false;
3056 clang::QualType base_qual_type;
3057 uint64_t base_bitwidth = 0;
3058 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3060 clang::QualType field_qual_type = field_pos->getType();
3061 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3062 if (field_qual_type->isFloatingType()) {
3063 if (field_qual_type->isComplexType())
3066 if (num_fields == 0)
3067 base_qual_type = field_qual_type;
3072 if (field_qual_type.getTypePtr() !=
3073 base_qual_type.getTypePtr())
3077 }
else if (field_qual_type->isVectorType() ||
3078 field_qual_type->isExtVectorType()) {
3079 if (num_fields == 0) {
3080 base_qual_type = field_qual_type;
3081 base_bitwidth = field_bitwidth;
3086 if (base_bitwidth != field_bitwidth)
3088 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3097 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3114 const clang::FunctionProtoType *func =
3115 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3117 return func->getNumParams();
3124 const size_t index) {
3127 const clang::FunctionProtoType *func =
3128 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3130 if (index < func->getNumParams())
3131 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3139 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3143 if (predicate(qual_type))
3146 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3147 switch (type_class) {
3151 case clang::Type::LValueReference:
3152 case clang::Type::RValueReference: {
3153 const clang::ReferenceType *reference_type =
3154 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3156 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3165 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3166 return qual_type->isMemberFunctionPointerType();
3169 return IsTypeImpl(type, isMemberFunctionPointerType);
3174 auto isMemberDataPointerType = [](clang::QualType qual_type) {
3175 return qual_type->isMemberDataPointerType();
3178 return IsTypeImpl(type, isMemberDataPointerType);
3182 auto isFunctionPointerType = [](clang::QualType qual_type) {
3183 return qual_type->isFunctionPointerType();
3186 return IsTypeImpl(type, isFunctionPointerType);
3192 auto isBlockPointerType = [&](clang::QualType qual_type) {
3193 if (qual_type->isBlockPointerType()) {
3194 if (function_pointer_type_ptr) {
3195 const clang::BlockPointerType *block_pointer_type =
3196 qual_type->castAs<clang::BlockPointerType>();
3197 QualType pointee_type = block_pointer_type->getPointeeType();
3198 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3200 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3217 if (qual_type.isNull())
3226 is_signed = qual_type->isSignedIntegerType();
3234 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3238 is_signed = enum_type->isSignedIntegerOrEnumerationType();
3249 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3253 return enum_type->isScopedEnumeralType();
3264 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3265 switch (type_class) {
3266 case clang::Type::Builtin:
3267 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3270 case clang::BuiltinType::ObjCId:
3271 case clang::BuiltinType::ObjCClass:
3275 case clang::Type::ObjCObjectPointer:
3279 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3283 case clang::Type::BlockPointer:
3286 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3290 case clang::Type::Pointer:
3293 llvm::cast<clang::PointerType>(qual_type)
3297 case clang::Type::MemberPointer:
3300 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3309 pointee_type->
Clear();
3317 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3318 switch (type_class) {
3319 case clang::Type::Builtin:
3320 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3323 case clang::BuiltinType::ObjCId:
3324 case clang::BuiltinType::ObjCClass:
3328 case clang::Type::ObjCObjectPointer:
3332 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3336 case clang::Type::BlockPointer:
3339 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3343 case clang::Type::Pointer:
3346 llvm::cast<clang::PointerType>(qual_type)
3350 case clang::Type::MemberPointer:
3353 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3357 case clang::Type::LValueReference:
3360 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3364 case clang::Type::RValueReference:
3367 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3376 pointee_type->
Clear();
3385 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3387 switch (type_class) {
3388 case clang::Type::LValueReference:
3391 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3397 case clang::Type::RValueReference:
3400 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3412 pointee_type->
Clear();
3421 if (qual_type.isNull())
3424 return qual_type->isFloatingType();
3432 const clang::TagType *tag_type =
3433 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3435 if (clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinition())
3436 return tag_decl->isCompleteDefinition();
3439 const clang::ObjCObjectType *objc_class_type =
3440 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3441 if (objc_class_type) {
3442 clang::ObjCInterfaceDecl *class_interface_decl =
3443 objc_class_type->getInterface();
3444 if (class_interface_decl)
3445 return class_interface_decl->getDefinition() !=
nullptr;
3456 const clang::ObjCObjectPointerType *obj_pointer_type =
3457 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3459 if (obj_pointer_type)
3460 return obj_pointer_type->isObjCClassType();
3475 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3476 return (type_class == clang::Type::Record);
3483 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3484 return (type_class == clang::Type::Enum);
3490 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3491 switch (type_class) {
3492 case clang::Type::Record:
3494 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3501 return cxx_record_decl->isDynamicClass();
3515 bool check_cplusplus,
3517 if (dynamic_pointee_type)
3518 dynamic_pointee_type->
Clear();
3522 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3523 if (dynamic_pointee_type)
3525 type.getAsOpaquePtr());
3528 clang::QualType pointee_qual_type;
3530 switch (qual_type->getTypeClass()) {
3531 case clang::Type::Builtin:
3532 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3533 clang::BuiltinType::ObjCId) {
3534 set_dynamic_pointee_type(qual_type);
3539 case clang::Type::ObjCObjectPointer:
3542 if (
const auto *objc_pointee_type =
3543 qual_type->getPointeeType().getTypePtrOrNull()) {
3544 if (
const auto *objc_object_type =
3545 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3546 objc_pointee_type)) {
3547 if (objc_object_type->isObjCClass())
3551 set_dynamic_pointee_type(
3552 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3555 case clang::Type::Pointer:
3557 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3560 case clang::Type::LValueReference:
3561 case clang::Type::RValueReference:
3563 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3573 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3574 case clang::Type::Builtin:
3575 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3576 case clang::BuiltinType::UnknownAny:
3577 case clang::BuiltinType::Void:
3578 set_dynamic_pointee_type(pointee_qual_type);
3584 case clang::Type::Record: {
3585 if (!check_cplusplus)
3587 clang::CXXRecordDecl *cxx_record_decl =
3588 pointee_qual_type->getAsCXXRecordDecl();
3589 if (!cxx_record_decl)
3593 if (cxx_record_decl->isCompleteDefinition())
3594 success = cxx_record_decl->isDynamicClass();
3596 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3597 std::optional<bool> is_dynamic =
3598 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3600 success = *is_dynamic;
3602 success = cxx_record_decl->isDynamicClass();
3608 set_dynamic_pointee_type(pointee_qual_type);
3612 case clang::Type::ObjCObject:
3613 case clang::Type::ObjCInterface:
3615 set_dynamic_pointee_type(pointee_qual_type);
3630 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3637 ->getTypeClass() == clang::Type::Typedef;
3654 if (
auto *record_decl =
3656 return record_decl->canPassInRegisters();
3662 return TypeSystemClangSupportsLanguage(language);
3665std::optional<std::string>
3668 return std::nullopt;
3671 if (qual_type.isNull())
3672 return std::nullopt;
3674 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3675 if (!cxx_record_decl)
3676 return std::nullopt;
3678 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3686 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3693 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3695 return tag_type->getDecl()->isEntityBeingDefined();
3706 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3707 if (class_type_ptr) {
3708 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3709 const clang::ObjCObjectPointerType *obj_pointer_type =
3710 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3711 if (obj_pointer_type ==
nullptr)
3712 class_type_ptr->
Clear();
3716 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3723 class_type_ptr->
Clear();
3750 {clang::Type::Typedef, clang::Type::Atomic});
3753 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3754 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3761 if (
auto *named_decl = qual_type->getAsTagDecl())
3773 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3774 printing_policy.SuppressTagKeyword =
true;
3775 printing_policy.SuppressScope =
false;
3776 printing_policy.SuppressUnwrittenScope =
true;
3777 printing_policy.SuppressInlineNamespace =
3778 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::All);
3779 return ConstString(qual_type.getAsString(printing_policy));
3788 if (pointee_or_element_clang_type)
3789 pointee_or_element_clang_type->
Clear();
3791 clang::QualType qual_type =
3794 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3795 switch (type_class) {
3796 case clang::Type::Attributed:
3797 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3800 pointee_or_element_clang_type);
3801 case clang::Type::BitInt: {
3802 uint32_t type_flags = eTypeIsScalar | eTypeIsInteger | eTypeHasValue;
3803 if (qual_type->isSignedIntegerType())
3804 type_flags |= eTypeIsSigned;
3808 case clang::Type::Builtin: {
3809 const clang::BuiltinType *builtin_type =
3810 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3812 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3813 switch (builtin_type->getKind()) {
3814 case clang::BuiltinType::ObjCId:
3815 case clang::BuiltinType::ObjCClass:
3816 if (pointee_or_element_clang_type)
3820 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3823 case clang::BuiltinType::ObjCSel:
3824 if (pointee_or_element_clang_type)
3827 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3830 case clang::BuiltinType::Bool:
3831 case clang::BuiltinType::Char_U:
3832 case clang::BuiltinType::UChar:
3833 case clang::BuiltinType::WChar_U:
3834 case clang::BuiltinType::Char16:
3835 case clang::BuiltinType::Char32:
3836 case clang::BuiltinType::UShort:
3837 case clang::BuiltinType::UInt:
3838 case clang::BuiltinType::ULong:
3839 case clang::BuiltinType::ULongLong:
3840 case clang::BuiltinType::UInt128:
3841 case clang::BuiltinType::Char_S:
3842 case clang::BuiltinType::SChar:
3843 case clang::BuiltinType::WChar_S:
3844 case clang::BuiltinType::Short:
3845 case clang::BuiltinType::Int:
3846 case clang::BuiltinType::Long:
3847 case clang::BuiltinType::LongLong:
3848 case clang::BuiltinType::Int128:
3849 case clang::BuiltinType::Float:
3850 case clang::BuiltinType::Double:
3851 case clang::BuiltinType::LongDouble:
3852 builtin_type_flags |= eTypeIsScalar;
3853 if (builtin_type->isInteger()) {
3854 builtin_type_flags |= eTypeIsInteger;
3855 if (builtin_type->isSignedInteger())
3856 builtin_type_flags |= eTypeIsSigned;
3857 }
else if (builtin_type->isFloatingPoint())
3858 builtin_type_flags |= eTypeIsFloat;
3863 return builtin_type_flags;
3866 case clang::Type::BlockPointer:
3867 if (pointee_or_element_clang_type)
3869 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3870 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3872 case clang::Type::Complex: {
3873 uint32_t complex_type_flags =
3874 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3875 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3876 qual_type->getCanonicalTypeInternal());
3878 clang::QualType complex_element_type(complex_type->getElementType());
3879 if (complex_element_type->isIntegerType())
3880 complex_type_flags |= eTypeIsInteger;
3881 else if (complex_element_type->isFloatingType())
3882 complex_type_flags |= eTypeIsFloat;
3884 return complex_type_flags;
3887 case clang::Type::ConstantArray:
3888 case clang::Type::DependentSizedArray:
3889 case clang::Type::IncompleteArray:
3890 case clang::Type::VariableArray:
3891 if (pointee_or_element_clang_type)
3893 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
3896 return eTypeHasChildren | eTypeIsArray;
3898 case clang::Type::DependentName:
3900 case clang::Type::DependentSizedExtVector:
3901 return eTypeHasChildren | eTypeIsVector;
3903 case clang::Type::Enum:
3904 if (pointee_or_element_clang_type)
3906 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
3908 ->getDefinitionOrSelf()
3911 return eTypeIsEnumeration | eTypeHasValue;
3913 case clang::Type::FunctionProto:
3914 return eTypeIsFuncPrototype | eTypeHasValue;
3915 case clang::Type::FunctionNoProto:
3916 return eTypeIsFuncPrototype | eTypeHasValue;
3917 case clang::Type::InjectedClassName:
3920 case clang::Type::LValueReference:
3921 case clang::Type::RValueReference:
3922 if (pointee_or_element_clang_type)
3925 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
3928 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
3930 case clang::Type::MemberPointer:
3931 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
3933 case clang::Type::ObjCObjectPointer:
3934 if (pointee_or_element_clang_type)
3936 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3937 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
3940 case clang::Type::ObjCObject:
3941 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
3942 case clang::Type::ObjCInterface:
3943 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
3945 case clang::Type::Pointer:
3946 if (pointee_or_element_clang_type)
3948 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3949 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
3951 case clang::Type::Record:
3952 if (qual_type->getAsCXXRecordDecl())
3953 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
3955 return eTypeHasChildren | eTypeIsStructUnion;
3957 case clang::Type::SubstTemplateTypeParm:
3958 return eTypeIsTemplate;
3959 case clang::Type::TemplateTypeParm:
3960 return eTypeIsTemplate;
3961 case clang::Type::TemplateSpecialization:
3962 return eTypeIsTemplate;
3964 case clang::Type::Typedef:
3965 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
3967 ->getUnderlyingType())
3969 case clang::Type::UnresolvedUsing:
3972 case clang::Type::ExtVector:
3973 case clang::Type::Vector: {
3974 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
3975 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
3976 qual_type->getCanonicalTypeInternal());
3980 QualType element_type = vector_type->getElementType();
3981 if (element_type.isNull())
3984 if (element_type->isIntegerType())
3985 vector_type_flags |= eTypeIsInteger;
3986 else if (element_type->isFloatingType())
3987 vector_type_flags |= eTypeIsFloat;
3988 return vector_type_flags;
4003 if (qual_type->isAnyPointerType()) {
4004 if (qual_type->isObjCObjectPointerType())
4006 if (qual_type->getPointeeCXXRecordDecl())
4009 clang::QualType pointee_type(qual_type->getPointeeType());
4010 if (pointee_type->getPointeeCXXRecordDecl())
4012 if (pointee_type->isObjCObjectOrInterfaceType())
4014 if (pointee_type->isObjCClassType())
4016 if (pointee_type.getTypePtr() ==
4020 if (qual_type->isObjCObjectOrInterfaceType())
4022 if (qual_type->getAsCXXRecordDecl())
4024 switch (qual_type->getTypeClass()) {
4027 case clang::Type::Builtin:
4028 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4030 case clang::BuiltinType::Void:
4031 case clang::BuiltinType::Bool:
4032 case clang::BuiltinType::Char_U:
4033 case clang::BuiltinType::UChar:
4034 case clang::BuiltinType::WChar_U:
4035 case clang::BuiltinType::Char16:
4036 case clang::BuiltinType::Char32:
4037 case clang::BuiltinType::UShort:
4038 case clang::BuiltinType::UInt:
4039 case clang::BuiltinType::ULong:
4040 case clang::BuiltinType::ULongLong:
4041 case clang::BuiltinType::UInt128:
4042 case clang::BuiltinType::Char_S:
4043 case clang::BuiltinType::SChar:
4044 case clang::BuiltinType::WChar_S:
4045 case clang::BuiltinType::Short:
4046 case clang::BuiltinType::Int:
4047 case clang::BuiltinType::Long:
4048 case clang::BuiltinType::LongLong:
4049 case clang::BuiltinType::Int128:
4050 case clang::BuiltinType::Float:
4051 case clang::BuiltinType::Double:
4052 case clang::BuiltinType::LongDouble:
4055 case clang::BuiltinType::NullPtr:
4058 case clang::BuiltinType::ObjCId:
4059 case clang::BuiltinType::ObjCClass:
4060 case clang::BuiltinType::ObjCSel:
4063 case clang::BuiltinType::Dependent:
4064 case clang::BuiltinType::Overload:
4065 case clang::BuiltinType::BoundMember:
4066 case clang::BuiltinType::UnknownAny:
4070 case clang::Type::Typedef:
4071 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4073 ->getUnderlyingType())
4083 return lldb::eTypeClassInvalid;
4085 clang::QualType qual_type =
4088 switch (qual_type->getTypeClass()) {
4089 case clang::Type::Atomic:
4090 case clang::Type::Auto:
4091 case clang::Type::CountAttributed:
4092 case clang::Type::Decltype:
4093 case clang::Type::Paren:
4094 case clang::Type::TypeOf:
4095 case clang::Type::TypeOfExpr:
4096 case clang::Type::Using:
4097 case clang::Type::PredefinedSugar:
4098 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4099 case clang::Type::UnaryTransform:
4101 case clang::Type::FunctionNoProto:
4102 return lldb::eTypeClassFunction;
4103 case clang::Type::FunctionProto:
4104 return lldb::eTypeClassFunction;
4105 case clang::Type::IncompleteArray:
4106 return lldb::eTypeClassArray;
4107 case clang::Type::VariableArray:
4108 return lldb::eTypeClassArray;
4109 case clang::Type::ConstantArray:
4110 return lldb::eTypeClassArray;
4111 case clang::Type::DependentSizedArray:
4112 return lldb::eTypeClassArray;
4113 case clang::Type::ArrayParameter:
4114 return lldb::eTypeClassArray;
4115 case clang::Type::DependentSizedExtVector:
4116 return lldb::eTypeClassVector;
4117 case clang::Type::DependentVector:
4118 return lldb::eTypeClassVector;
4119 case clang::Type::ExtVector:
4120 return lldb::eTypeClassVector;
4121 case clang::Type::Vector:
4122 return lldb::eTypeClassVector;
4123 case clang::Type::Builtin:
4125 case clang::Type::BitInt:
4126 case clang::Type::DependentBitInt:
4127 case clang::Type::OverflowBehavior:
4128 return lldb::eTypeClassBuiltin;
4129 case clang::Type::ObjCObjectPointer:
4130 return lldb::eTypeClassObjCObjectPointer;
4131 case clang::Type::BlockPointer:
4132 return lldb::eTypeClassBlockPointer;
4133 case clang::Type::Pointer:
4134 return lldb::eTypeClassPointer;
4135 case clang::Type::LValueReference:
4136 return lldb::eTypeClassReference;
4137 case clang::Type::RValueReference:
4138 return lldb::eTypeClassReference;
4139 case clang::Type::MemberPointer:
4140 return lldb::eTypeClassMemberPointer;
4141 case clang::Type::Complex:
4142 if (qual_type->isComplexType())
4143 return lldb::eTypeClassComplexFloat;
4145 return lldb::eTypeClassComplexInteger;
4146 case clang::Type::ObjCObject:
4147 return lldb::eTypeClassObjCObject;
4148 case clang::Type::ObjCInterface:
4149 return lldb::eTypeClassObjCInterface;
4150 case clang::Type::Record: {
4151 const clang::RecordType *record_type =
4152 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4153 const clang::RecordDecl *record_decl = record_type->getDecl();
4154 if (record_decl->isUnion())
4155 return lldb::eTypeClassUnion;
4156 else if (record_decl->isStruct())
4157 return lldb::eTypeClassStruct;
4159 return lldb::eTypeClassClass;
4161 case clang::Type::Enum:
4162 return lldb::eTypeClassEnumeration;
4163 case clang::Type::Typedef:
4164 return lldb::eTypeClassTypedef;
4165 case clang::Type::UnresolvedUsing:
4168 case clang::Type::Attributed:
4169 case clang::Type::BTFTagAttributed:
4171 case clang::Type::TemplateTypeParm:
4173 case clang::Type::SubstTemplateTypeParm:
4175 case clang::Type::SubstTemplateTypeParmPack:
4177 case clang::Type::InjectedClassName:
4179 case clang::Type::DependentName:
4181 case clang::Type::PackExpansion:
4184 case clang::Type::TemplateSpecialization:
4186 case clang::Type::DeducedTemplateSpecialization:
4188 case clang::Type::Pipe:
4192 case clang::Type::Decayed:
4194 case clang::Type::Adjusted:
4196 case clang::Type::ObjCTypeParam:
4199 case clang::Type::DependentAddressSpace:
4201 case clang::Type::MacroQualified:
4205 case clang::Type::ConstantMatrix:
4206 case clang::Type::DependentSizedMatrix:
4210 case clang::Type::PackIndexing:
4213 case clang::Type::HLSLAttributedResource:
4215 case clang::Type::HLSLInlineSpirv:
4217 case clang::Type::SubstBuiltinTemplatePack:
4221 return lldb::eTypeClassOther;
4226 return GetQualType(type).getQualifiers().getCVRQualifiers();
4238 const clang::Type *array_eletype =
4239 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4244 return GetType(clang::QualType(array_eletype, 0));
4255 return GetType(ast_ctx.getConstantArrayType(
4256 qual_type, llvm::APInt(64, size),
nullptr,
4257 clang::ArraySizeModifier::Normal, 0));
4259 return GetType(ast_ctx.getIncompleteArrayType(
4260 qual_type, clang::ArraySizeModifier::Normal, 0));
4274 clang::QualType qual_type) {
4275 if (qual_type->isPointerType())
4276 qual_type = ast->getPointerType(
4278 else if (
const ConstantArrayType *arr =
4279 ast->getAsConstantArrayType(qual_type)) {
4280 qual_type = ast->getConstantArrayType(
4282 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4283 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4285 qual_type = qual_type.getUnqualifiedType();
4286 qual_type.removeLocalConst();
4287 qual_type.removeLocalRestrict();
4288 qual_type.removeLocalVolatile();
4310 const clang::FunctionProtoType *func =
4313 return func->getNumParams();
4321 const clang::FunctionProtoType *func =
4322 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4324 const uint32_t num_args = func->getNumParams();
4326 return GetType(func->getParamType(idx));
4336 const clang::FunctionProtoType *func =
4337 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4339 return GetType(func->getReturnType());
4346 size_t num_functions = 0;
4349 switch (qual_type->getTypeClass()) {
4350 case clang::Type::Record:
4352 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4353 num_functions = std::distance(cxx_record_decl->method_begin(),
4354 cxx_record_decl->method_end());
4357 case clang::Type::ObjCObjectPointer: {
4358 const clang::ObjCObjectPointerType *objc_class_type =
4359 qual_type->castAs<clang::ObjCObjectPointerType>();
4360 const clang::ObjCInterfaceType *objc_interface_type =
4361 objc_class_type->getInterfaceType();
4362 if (objc_interface_type &&
4364 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4365 clang::ObjCInterfaceDecl *class_interface_decl =
4366 objc_interface_type->getDecl();
4367 if (class_interface_decl) {
4368 num_functions = std::distance(class_interface_decl->meth_begin(),
4369 class_interface_decl->meth_end());
4375 case clang::Type::ObjCObject:
4376 case clang::Type::ObjCInterface:
4378 const clang::ObjCObjectType *objc_class_type =
4379 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4380 if (objc_class_type) {
4381 clang::ObjCInterfaceDecl *class_interface_decl =
4382 objc_class_type->getInterface();
4383 if (class_interface_decl)
4384 num_functions = std::distance(class_interface_decl->meth_begin(),
4385 class_interface_decl->meth_end());
4394 return num_functions;
4406 switch (qual_type->getTypeClass()) {
4407 case clang::Type::Record:
4409 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4410 auto method_iter = cxx_record_decl->method_begin();
4411 auto method_end = cxx_record_decl->method_end();
4413 static_cast<size_t>(std::distance(method_iter, method_end))) {
4414 std::advance(method_iter, idx);
4415 clang::CXXMethodDecl *cxx_method_decl =
4416 method_iter->getCanonicalDecl();
4417 if (cxx_method_decl) {
4418 name = cxx_method_decl->getDeclName().getAsString();
4419 if (cxx_method_decl->isStatic())
4421 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4423 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4427 clang_type =
GetType(cxx_method_decl->getType());
4435 case clang::Type::ObjCObjectPointer: {
4436 const clang::ObjCObjectPointerType *objc_class_type =
4437 qual_type->castAs<clang::ObjCObjectPointerType>();
4438 const clang::ObjCInterfaceType *objc_interface_type =
4439 objc_class_type->getInterfaceType();
4440 if (objc_interface_type &&
4442 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4443 clang::ObjCInterfaceDecl *class_interface_decl =
4444 objc_interface_type->getDecl();
4445 if (class_interface_decl) {
4446 auto method_iter = class_interface_decl->meth_begin();
4447 auto method_end = class_interface_decl->meth_end();
4449 static_cast<size_t>(std::distance(method_iter, method_end))) {
4450 std::advance(method_iter, idx);
4451 clang::ObjCMethodDecl *objc_method_decl =
4452 method_iter->getCanonicalDecl();
4453 if (objc_method_decl) {
4455 name = objc_method_decl->getSelector().getAsString();
4456 if (objc_method_decl->isClassMethod())
4467 case clang::Type::ObjCObject:
4468 case clang::Type::ObjCInterface:
4470 const clang::ObjCObjectType *objc_class_type =
4471 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4472 if (objc_class_type) {
4473 clang::ObjCInterfaceDecl *class_interface_decl =
4474 objc_class_type->getInterface();
4475 if (class_interface_decl) {
4476 auto method_iter = class_interface_decl->meth_begin();
4477 auto method_end = class_interface_decl->meth_end();
4479 static_cast<size_t>(std::distance(method_iter, method_end))) {
4480 std::advance(method_iter, idx);
4481 clang::ObjCMethodDecl *objc_method_decl =
4482 method_iter->getCanonicalDecl();
4483 if (objc_method_decl) {
4485 name = objc_method_decl->getSelector().getAsString();
4486 if (objc_method_decl->isClassMethod())
4519 return GetType(qual_type.getTypePtr()->getPointeeType());
4529 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4530 case clang::Type::ObjCObject:
4531 case clang::Type::ObjCInterface:
4578 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4579 clang::QualType result =
4580 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4590 result.addVolatile();
4600 result.addRestrict();
4609 if (type && typedef_name && typedef_name[0]) {
4613 clang::DeclContext *decl_ctx =
4618 clang::TypedefDecl *decl =
4619 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4620 decl->setDeclContext(decl_ctx);
4621 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4622 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4623 decl_ctx->addDecl(decl);
4626 clang::TagDecl *tdecl =
nullptr;
4627 if (!qual_type.isNull()) {
4628 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4629 tdecl = rt->getDecl();
4630 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4631 tdecl = et->getDecl();
4637 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4638 tdecl->setTypedefNameForAnonDecl(decl);
4640 decl->setAccess(clang::AS_public);
4643 NestedNameSpecifier Qualifier =
4644 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4646 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4654 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4657 return GetType(typedef_type->getDecl()->getUnderlyingType());
4670 const FunctionType::ExtInfo generic_ext_info(
4679 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4684const llvm::fltSemantics &
4687 const size_t bit_size = byte_size * 8;
4688 if (bit_size == ast.getTypeSize(ast.FloatTy))
4689 return ast.getFloatTypeSemantics(ast.FloatTy);
4690 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4691 return ast.getFloatTypeSemantics(ast.DoubleTy);
4693 bit_size == ast.getTypeSize(ast.Float128Ty))
4694 return ast.getFloatTypeSemantics(ast.Float128Ty);
4695 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4696 bit_size == llvm::APFloat::semanticsSizeInBits(
4697 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4698 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4699 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4700 return ast.getFloatTypeSemantics(ast.HalfTy);
4701 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4702 return ast.getFloatTypeSemantics(ast.Float128Ty);
4703 return llvm::APFloatBase::Bogus();
4706llvm::Expected<uint64_t>
4709 assert(qual_type->isObjCObjectOrInterfaceType());
4714 if (std::optional<uint64_t> bit_size =
4715 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4719 static bool g_printed =
false;
4724 llvm::outs() <<
"warning: trying to determine the size of type ";
4726 llvm::outs() <<
"without a valid ExecutionContext. this is not "
4727 "reliable. please file a bug against LLDB.\n";
4728 llvm::outs() <<
"backtrace:\n";
4729 llvm::sys::PrintStackTrace(llvm::outs());
4730 llvm::outs() <<
"\n";
4739llvm::Expected<uint64_t>
4742 const bool base_name_only =
true;
4744 return llvm::createStringError(
4745 "could not complete type %s",
4749 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4750 switch (type_class) {
4751 case clang::Type::ConstantArray:
4752 case clang::Type::FunctionProto:
4753 case clang::Type::Record:
4755 case clang::Type::ObjCInterface:
4756 case clang::Type::ObjCObject:
4758 case clang::Type::IncompleteArray: {
4759 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4762 qual_type->getArrayElementTypeNoTypeQual()
4763 ->getCanonicalTypeUnqualified());
4768 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4772 return llvm::createStringError(
4773 "could not get size of type %s",
4777std::optional<size_t>
4791 switch (qual_type->getTypeClass()) {
4792 case clang::Type::Atomic:
4793 case clang::Type::Auto:
4794 case clang::Type::CountAttributed:
4795 case clang::Type::Decltype:
4796 case clang::Type::Paren:
4797 case clang::Type::Typedef:
4798 case clang::Type::TypeOf:
4799 case clang::Type::TypeOfExpr:
4800 case clang::Type::Using:
4801 case clang::Type::PredefinedSugar:
4802 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4804 case clang::Type::UnaryTransform:
4807 case clang::Type::FunctionNoProto:
4808 case clang::Type::FunctionProto:
4811 case clang::Type::IncompleteArray:
4812 case clang::Type::VariableArray:
4813 case clang::Type::ArrayParameter:
4816 case clang::Type::ConstantArray:
4819 case clang::Type::DependentVector:
4820 case clang::Type::ExtVector:
4821 case clang::Type::Vector:
4824 case clang::Type::BitInt:
4825 case clang::Type::DependentBitInt:
4826 case clang::Type::OverflowBehavior:
4830 case clang::Type::Builtin:
4831 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4832 case clang::BuiltinType::Void:
4835 case clang::BuiltinType::Char_S:
4836 case clang::BuiltinType::SChar:
4837 case clang::BuiltinType::WChar_S:
4838 case clang::BuiltinType::Short:
4839 case clang::BuiltinType::Int:
4840 case clang::BuiltinType::Long:
4841 case clang::BuiltinType::LongLong:
4842 case clang::BuiltinType::Int128:
4845 case clang::BuiltinType::Bool:
4846 case clang::BuiltinType::Char_U:
4847 case clang::BuiltinType::UChar:
4848 case clang::BuiltinType::WChar_U:
4849 case clang::BuiltinType::Char8:
4850 case clang::BuiltinType::Char16:
4851 case clang::BuiltinType::Char32:
4852 case clang::BuiltinType::UShort:
4853 case clang::BuiltinType::UInt:
4854 case clang::BuiltinType::ULong:
4855 case clang::BuiltinType::ULongLong:
4856 case clang::BuiltinType::UInt128:
4860 case clang::BuiltinType::ShortAccum:
4861 case clang::BuiltinType::Accum:
4862 case clang::BuiltinType::LongAccum:
4863 case clang::BuiltinType::UShortAccum:
4864 case clang::BuiltinType::UAccum:
4865 case clang::BuiltinType::ULongAccum:
4866 case clang::BuiltinType::ShortFract:
4867 case clang::BuiltinType::Fract:
4868 case clang::BuiltinType::LongFract:
4869 case clang::BuiltinType::UShortFract:
4870 case clang::BuiltinType::UFract:
4871 case clang::BuiltinType::ULongFract:
4872 case clang::BuiltinType::SatShortAccum:
4873 case clang::BuiltinType::SatAccum:
4874 case clang::BuiltinType::SatLongAccum:
4875 case clang::BuiltinType::SatUShortAccum:
4876 case clang::BuiltinType::SatUAccum:
4877 case clang::BuiltinType::SatULongAccum:
4878 case clang::BuiltinType::SatShortFract:
4879 case clang::BuiltinType::SatFract:
4880 case clang::BuiltinType::SatLongFract:
4881 case clang::BuiltinType::SatUShortFract:
4882 case clang::BuiltinType::SatUFract:
4883 case clang::BuiltinType::SatULongFract:
4886 case clang::BuiltinType::Half:
4887 case clang::BuiltinType::Float:
4888 case clang::BuiltinType::Float16:
4889 case clang::BuiltinType::Float128:
4890 case clang::BuiltinType::Double:
4891 case clang::BuiltinType::LongDouble:
4892 case clang::BuiltinType::BFloat16:
4893 case clang::BuiltinType::Ibm128:
4896 case clang::BuiltinType::ObjCClass:
4897 case clang::BuiltinType::ObjCId:
4898 case clang::BuiltinType::ObjCSel:
4901 case clang::BuiltinType::NullPtr:
4904 case clang::BuiltinType::Kind::ARCUnbridgedCast:
4905 case clang::BuiltinType::Kind::BoundMember:
4906 case clang::BuiltinType::Kind::BuiltinFn:
4907 case clang::BuiltinType::Kind::Dependent:
4908 case clang::BuiltinType::Kind::OCLClkEvent:
4909 case clang::BuiltinType::Kind::OCLEvent:
4910 case clang::BuiltinType::Kind::OCLImage1dRO:
4911 case clang::BuiltinType::Kind::OCLImage1dWO:
4912 case clang::BuiltinType::Kind::OCLImage1dRW:
4913 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
4914 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
4915 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
4916 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
4917 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
4918 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
4919 case clang::BuiltinType::Kind::OCLImage2dRO:
4920 case clang::BuiltinType::Kind::OCLImage2dWO:
4921 case clang::BuiltinType::Kind::OCLImage2dRW:
4922 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
4923 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
4924 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
4925 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
4926 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
4927 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
4928 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
4929 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
4930 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
4931 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
4932 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
4933 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
4934 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
4935 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
4936 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
4937 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
4938 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
4939 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
4940 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
4941 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
4942 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
4943 case clang::BuiltinType::Kind::OCLImage3dRO:
4944 case clang::BuiltinType::Kind::OCLImage3dWO:
4945 case clang::BuiltinType::Kind::OCLImage3dRW:
4946 case clang::BuiltinType::Kind::OCLQueue:
4947 case clang::BuiltinType::Kind::OCLReserveID:
4948 case clang::BuiltinType::Kind::OCLSampler:
4949 case clang::BuiltinType::Kind::HLSLResource:
4950 case clang::BuiltinType::Kind::ArraySection:
4951 case clang::BuiltinType::Kind::OMPArrayShaping:
4952 case clang::BuiltinType::Kind::OMPIterator:
4953 case clang::BuiltinType::Kind::Overload:
4954 case clang::BuiltinType::Kind::PseudoObject:
4955 case clang::BuiltinType::Kind::UnknownAny:
4958 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
4959 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
4960 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
4961 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
4962 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
4963 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
4964 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
4965 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
4966 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
4967 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
4968 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
4969 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
4973 case clang::BuiltinType::VectorPair:
4974 case clang::BuiltinType::VectorQuad:
4975 case clang::BuiltinType::DMR1024:
4976 case clang::BuiltinType::DMR2048:
4980#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
4981#include "clang/Basic/AArch64ACLETypes.def"
4985#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
4986#include "clang/Basic/RISCVVTypes.def"
4990 case clang::BuiltinType::WasmExternRef:
4993 case clang::BuiltinType::IncompleteMatrixIdx:
4996 case clang::BuiltinType::UnresolvedTemplate:
5000#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
5001 case clang::BuiltinType::Id:
5002#include "clang/Basic/AMDGPUTypes.def"
5008 case clang::Type::ObjCObjectPointer:
5009 case clang::Type::BlockPointer:
5010 case clang::Type::Pointer:
5011 case clang::Type::LValueReference:
5012 case clang::Type::RValueReference:
5013 case clang::Type::MemberPointer:
5015 case clang::Type::Complex: {
5017 if (qual_type->isComplexType())
5020 const clang::ComplexType *complex_type =
5021 qual_type->getAsComplexIntegerType();
5030 case clang::Type::ObjCInterface:
5032 case clang::Type::Record:
5034 case clang::Type::Enum:
5035 return qual_type->isUnsignedIntegerOrEnumerationType()
5038 case clang::Type::DependentSizedArray:
5039 case clang::Type::DependentSizedExtVector:
5040 case clang::Type::UnresolvedUsing:
5041 case clang::Type::Attributed:
5042 case clang::Type::BTFTagAttributed:
5043 case clang::Type::TemplateTypeParm:
5044 case clang::Type::SubstTemplateTypeParm:
5045 case clang::Type::SubstTemplateTypeParmPack:
5046 case clang::Type::InjectedClassName:
5047 case clang::Type::DependentName:
5048 case clang::Type::PackExpansion:
5049 case clang::Type::ObjCObject:
5051 case clang::Type::TemplateSpecialization:
5052 case clang::Type::DeducedTemplateSpecialization:
5053 case clang::Type::Adjusted:
5054 case clang::Type::Pipe:
5058 case clang::Type::Decayed:
5060 case clang::Type::ObjCTypeParam:
5063 case clang::Type::DependentAddressSpace:
5065 case clang::Type::MacroQualified:
5068 case clang::Type::ConstantMatrix:
5069 case clang::Type::DependentSizedMatrix:
5073 case clang::Type::PackIndexing:
5076 case clang::Type::HLSLAttributedResource:
5078 case clang::Type::HLSLInlineSpirv:
5080 case clang::Type::SubstBuiltinTemplatePack:
5093 switch (qual_type->getTypeClass()) {
5094 case clang::Type::Atomic:
5095 case clang::Type::Auto:
5096 case clang::Type::CountAttributed:
5097 case clang::Type::Decltype:
5098 case clang::Type::Paren:
5099 case clang::Type::Typedef:
5100 case clang::Type::TypeOf:
5101 case clang::Type::TypeOfExpr:
5102 case clang::Type::Using:
5103 case clang::Type::PredefinedSugar:
5104 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5105 case clang::Type::UnaryTransform:
5108 case clang::Type::FunctionNoProto:
5109 case clang::Type::FunctionProto:
5112 case clang::Type::IncompleteArray:
5113 case clang::Type::VariableArray:
5114 case clang::Type::ArrayParameter:
5117 case clang::Type::ConstantArray:
5120 case clang::Type::DependentVector:
5121 case clang::Type::ExtVector:
5122 case clang::Type::Vector:
5125 case clang::Type::BitInt:
5126 case clang::Type::DependentBitInt:
5127 case clang::Type::OverflowBehavior:
5131 case clang::Type::Builtin:
5132 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5133 case clang::BuiltinType::UnknownAny:
5134 case clang::BuiltinType::Void:
5135 case clang::BuiltinType::BoundMember:
5138 case clang::BuiltinType::Bool:
5140 case clang::BuiltinType::Char_S:
5141 case clang::BuiltinType::SChar:
5142 case clang::BuiltinType::WChar_S:
5143 case clang::BuiltinType::Char_U:
5144 case clang::BuiltinType::UChar:
5145 case clang::BuiltinType::WChar_U:
5147 case clang::BuiltinType::Char8:
5149 case clang::BuiltinType::Char16:
5151 case clang::BuiltinType::Char32:
5153 case clang::BuiltinType::UShort:
5155 case clang::BuiltinType::Short:
5157 case clang::BuiltinType::UInt:
5159 case clang::BuiltinType::Int:
5161 case clang::BuiltinType::ULong:
5163 case clang::BuiltinType::Long:
5165 case clang::BuiltinType::ULongLong:
5167 case clang::BuiltinType::LongLong:
5169 case clang::BuiltinType::UInt128:
5171 case clang::BuiltinType::Int128:
5173 case clang::BuiltinType::Half:
5174 case clang::BuiltinType::Float:
5175 case clang::BuiltinType::Double:
5176 case clang::BuiltinType::LongDouble:
5178 case clang::BuiltinType::Float128:
5184 case clang::Type::ObjCObjectPointer:
5186 case clang::Type::BlockPointer:
5188 case clang::Type::Pointer:
5190 case clang::Type::LValueReference:
5191 case clang::Type::RValueReference:
5193 case clang::Type::MemberPointer:
5195 case clang::Type::Complex: {
5196 if (qual_type->isComplexType())
5201 case clang::Type::ObjCInterface:
5203 case clang::Type::Record:
5205 case clang::Type::Enum:
5207 case clang::Type::DependentSizedArray:
5208 case clang::Type::DependentSizedExtVector:
5209 case clang::Type::UnresolvedUsing:
5210 case clang::Type::Attributed:
5211 case clang::Type::BTFTagAttributed:
5212 case clang::Type::TemplateTypeParm:
5213 case clang::Type::SubstTemplateTypeParm:
5214 case clang::Type::SubstTemplateTypeParmPack:
5215 case clang::Type::InjectedClassName:
5216 case clang::Type::DependentName:
5217 case clang::Type::PackExpansion:
5218 case clang::Type::ObjCObject:
5220 case clang::Type::TemplateSpecialization:
5221 case clang::Type::DeducedTemplateSpecialization:
5222 case clang::Type::Adjusted:
5223 case clang::Type::Pipe:
5227 case clang::Type::Decayed:
5229 case clang::Type::ObjCTypeParam:
5232 case clang::Type::DependentAddressSpace:
5234 case clang::Type::MacroQualified:
5238 case clang::Type::ConstantMatrix:
5239 case clang::Type::DependentSizedMatrix:
5243 case clang::Type::PackIndexing:
5246 case clang::Type::HLSLAttributedResource:
5248 case clang::Type::HLSLInlineSpirv:
5250 case clang::Type::SubstBuiltinTemplatePack:
5258 while (class_interface_decl) {
5259 if (class_interface_decl->ivar_size() > 0)
5262 class_interface_decl = class_interface_decl->getSuperClass();
5267static std::optional<SymbolFile::ArrayInfo>
5269 clang::QualType qual_type,
5271 if (qual_type->isIncompleteArrayType())
5272 if (std::optional<ClangASTMetadata> metadata =
5276 return std::nullopt;
5279llvm::Expected<uint32_t>
5281 bool omit_empty_base_classes,
5284 return llvm::createStringError(
"invalid clang type");
5286 uint32_t num_children = 0;
5288 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5289 switch (type_class) {
5290 case clang::Type::Builtin:
5291 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5292 case clang::BuiltinType::ObjCId:
5293 case clang::BuiltinType::ObjCClass:
5302 case clang::Type::Complex:
5304 case clang::Type::Record:
5306 const clang::RecordType *record_type =
5307 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5308 const clang::RecordDecl *record_decl =
5309 record_type->getDecl()->getDefinitionOrSelf();
5310 const clang::CXXRecordDecl *cxx_record_decl =
5311 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5315 num_children += std::distance(record_decl->field_begin(),
5316 record_decl->field_end());
5318 return llvm::createStringError(
5321 case clang::Type::ObjCObject:
5322 case clang::Type::ObjCInterface:
5324 const clang::ObjCObjectType *objc_class_type =
5325 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5326 assert(objc_class_type);
5327 if (objc_class_type) {
5328 clang::ObjCInterfaceDecl *class_interface_decl =
5329 objc_class_type->getInterface();
5331 if (class_interface_decl) {
5333 clang::ObjCInterfaceDecl *superclass_interface_decl =
5334 class_interface_decl->getSuperClass();
5335 if (superclass_interface_decl) {
5336 if (omit_empty_base_classes) {
5343 num_children += class_interface_decl->ivar_size();
5349 case clang::Type::LValueReference:
5350 case clang::Type::RValueReference:
5351 case clang::Type::ObjCObjectPointer: {
5354 uint32_t num_pointee_children = 0;
5356 auto num_children_or_err =
5357 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5358 if (!num_children_or_err)
5359 return num_children_or_err;
5360 num_pointee_children = *num_children_or_err;
5363 if (num_pointee_children == 0)
5366 num_children = num_pointee_children;
5369 case clang::Type::Vector:
5370 case clang::Type::ExtVector:
5372 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5375 case clang::Type::ConstantArray:
5376 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5380 case clang::Type::IncompleteArray:
5381 if (
auto array_info =
5384 num_children = array_info->element_orders.size()
5385 ? array_info->element_orders.back().value_or(0)
5389 case clang::Type::Pointer: {
5390 const clang::PointerType *pointer_type =
5391 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5392 clang::QualType pointee_type(pointer_type->getPointeeType());
5394 uint32_t num_pointee_children = 0;
5396 auto num_children_or_err =
5397 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5398 if (!num_children_or_err)
5399 return num_children_or_err;
5400 num_pointee_children = *num_children_or_err;
5402 if (num_pointee_children == 0) {
5407 num_children = num_pointee_children;
5413 return num_children;
5420 if (name_ref.consume_front(
"unsigned _BitInt(") ||
5421 name_ref.consume_front(
"_BitInt(")) {
5423 if (name_ref.consumeInteger(10, bit_size))
5426 if (!name_ref.consume_front(
")"))
5430 name.
GetStringRef().starts_with(
"unsigned"), bit_size));
5439 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5440 if (type_class == clang::Type::Builtin) {
5441 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5442 case clang::BuiltinType::Void:
5444 case clang::BuiltinType::Bool:
5446 case clang::BuiltinType::Char_S:
5448 case clang::BuiltinType::Char_U:
5450 case clang::BuiltinType::Char8:
5452 case clang::BuiltinType::Char16:
5454 case clang::BuiltinType::Char32:
5456 case clang::BuiltinType::UChar:
5458 case clang::BuiltinType::SChar:
5460 case clang::BuiltinType::WChar_S:
5462 case clang::BuiltinType::WChar_U:
5464 case clang::BuiltinType::Short:
5466 case clang::BuiltinType::UShort:
5468 case clang::BuiltinType::Int:
5470 case clang::BuiltinType::UInt:
5472 case clang::BuiltinType::Long:
5474 case clang::BuiltinType::ULong:
5476 case clang::BuiltinType::LongLong:
5478 case clang::BuiltinType::ULongLong:
5480 case clang::BuiltinType::Int128:
5482 case clang::BuiltinType::UInt128:
5485 case clang::BuiltinType::Half:
5487 case clang::BuiltinType::Float:
5489 case clang::BuiltinType::Double:
5491 case clang::BuiltinType::LongDouble:
5493 case clang::BuiltinType::Float128:
5496 case clang::BuiltinType::NullPtr:
5498 case clang::BuiltinType::ObjCId:
5500 case clang::BuiltinType::ObjCClass:
5502 case clang::BuiltinType::ObjCSel:
5516 const llvm::APSInt &value)>
const &callback) {
5517 const clang::EnumType *enum_type =
5520 const clang::EnumDecl *enum_decl =
5521 enum_type->getDecl()->getDefinitionOrSelf();
5525 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5526 for (enum_pos = enum_decl->enumerator_begin(),
5527 enum_end_pos = enum_decl->enumerator_end();
5528 enum_pos != enum_end_pos; ++enum_pos) {
5529 ConstString name(enum_pos->getNameAsString().c_str());
5530 if (!callback(integer_type, name, enum_pos->getInitVal()))
5537#pragma mark Aggregate Types
5545 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5546 switch (type_class) {
5547 case clang::Type::Record:
5549 const clang::RecordType *record_type =
5550 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5552 clang::RecordDecl *record_decl =
5553 record_type->getDecl()->getDefinition();
5555 count = std::distance(record_decl->field_begin(),
5556 record_decl->field_end());
5562 case clang::Type::ObjCObjectPointer: {
5563 const clang::ObjCObjectPointerType *objc_class_type =
5564 qual_type->castAs<clang::ObjCObjectPointerType>();
5565 const clang::ObjCInterfaceType *objc_interface_type =
5566 objc_class_type->getInterfaceType();
5567 if (objc_interface_type &&
5569 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5570 clang::ObjCInterfaceDecl *class_interface_decl =
5571 objc_interface_type->getDecl();
5572 if (class_interface_decl) {
5573 count = class_interface_decl->ivar_size();
5579 case clang::Type::ObjCObject:
5580 case clang::Type::ObjCInterface:
5582 const clang::ObjCObjectType *objc_class_type =
5583 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5584 if (objc_class_type) {
5585 clang::ObjCInterfaceDecl *class_interface_decl =
5586 objc_class_type->getInterface();
5588 if (class_interface_decl)
5589 count = class_interface_decl->ivar_size();
5602 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5603 std::string &name, uint64_t *bit_offset_ptr,
5604 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5605 if (class_interface_decl) {
5606 if (idx < (class_interface_decl->ivar_size())) {
5607 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5608 ivar_end = class_interface_decl->ivar_end();
5609 uint32_t ivar_idx = 0;
5611 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5612 ++ivar_pos, ++ivar_idx) {
5613 if (ivar_idx == idx) {
5614 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5616 clang::QualType ivar_qual_type(ivar_decl->getType());
5618 name.assign(ivar_decl->getNameAsString());
5620 if (bit_offset_ptr) {
5621 const clang::ASTRecordLayout &interface_layout =
5622 ast->getASTObjCInterfaceLayout(class_interface_decl);
5623 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5626 const bool is_bitfield = ivar_pos->isBitField();
5628 if (bitfield_bit_size_ptr) {
5629 *bitfield_bit_size_ptr = 0;
5631 if (is_bitfield && ast) {
5632 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5633 clang::Expr::EvalResult result;
5634 if (bitfield_bit_size_expr &&
5635 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5636 llvm::APSInt bitfield_apsint = result.Val.getInt();
5637 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5641 if (is_bitfield_ptr)
5642 *is_bitfield_ptr = is_bitfield;
5644 return ivar_qual_type.getAsOpaquePtr();
5653 size_t idx, std::string &name,
5654 uint64_t *bit_offset_ptr,
5655 uint32_t *bitfield_bit_size_ptr,
5656 bool *is_bitfield_ptr) {
5661 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5662 switch (type_class) {
5663 case clang::Type::Record:
5665 const clang::RecordType *record_type =
5666 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5667 const clang::RecordDecl *record_decl =
5668 record_type->getDecl()->getDefinitionOrSelf();
5669 uint32_t field_idx = 0;
5670 clang::RecordDecl::field_iterator field, field_end;
5671 for (field = record_decl->field_begin(),
5672 field_end = record_decl->field_end();
5673 field != field_end; ++field, ++field_idx) {
5674 if (idx == field_idx) {
5677 name.assign(field->getNameAsString());
5681 if (bit_offset_ptr) {
5682 const clang::ASTRecordLayout &record_layout =
5684 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5687 const bool is_bitfield = field->isBitField();
5689 if (bitfield_bit_size_ptr) {
5690 *bitfield_bit_size_ptr = 0;
5693 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5694 clang::Expr::EvalResult result;
5695 if (bitfield_bit_size_expr &&
5696 bitfield_bit_size_expr->EvaluateAsInt(result,
5698 llvm::APSInt bitfield_apsint = result.Val.getInt();
5699 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5703 if (is_bitfield_ptr)
5704 *is_bitfield_ptr = is_bitfield;
5706 return GetType(field->getType());
5712 case clang::Type::ObjCObjectPointer: {
5713 const clang::ObjCObjectPointerType *objc_class_type =
5714 qual_type->castAs<clang::ObjCObjectPointerType>();
5715 const clang::ObjCInterfaceType *objc_interface_type =
5716 objc_class_type->getInterfaceType();
5717 if (objc_interface_type &&
5719 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5720 clang::ObjCInterfaceDecl *class_interface_decl =
5721 objc_interface_type->getDecl();
5722 if (class_interface_decl) {
5726 name, bit_offset_ptr, bitfield_bit_size_ptr,
5733 case clang::Type::ObjCObject:
5734 case clang::Type::ObjCInterface:
5736 const clang::ObjCObjectType *objc_class_type =
5737 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5738 assert(objc_class_type);
5739 if (objc_class_type) {
5740 clang::ObjCInterfaceDecl *class_interface_decl =
5741 objc_class_type->getInterface();
5745 name, bit_offset_ptr, bitfield_bit_size_ptr,
5761 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5762 switch (type_class) {
5763 case clang::Type::Record:
5765 const clang::CXXRecordDecl *cxx_record_decl =
5766 qual_type->getAsCXXRecordDecl();
5767 if (cxx_record_decl)
5768 count = cxx_record_decl->getNumBases();
5772 case clang::Type::ObjCObjectPointer:
5776 case clang::Type::ObjCObject:
5778 const clang::ObjCObjectType *objc_class_type =
5779 qual_type->getAsObjCQualifiedInterfaceType();
5780 if (objc_class_type) {
5781 clang::ObjCInterfaceDecl *class_interface_decl =
5782 objc_class_type->getInterface();
5784 if (class_interface_decl && class_interface_decl->getSuperClass())
5789 case clang::Type::ObjCInterface:
5791 const clang::ObjCInterfaceType *objc_interface_type =
5792 qual_type->getAs<clang::ObjCInterfaceType>();
5793 if (objc_interface_type) {
5794 clang::ObjCInterfaceDecl *class_interface_decl =
5795 objc_interface_type->getInterface();
5797 if (class_interface_decl && class_interface_decl->getSuperClass())
5813 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5814 switch (type_class) {
5815 case clang::Type::Record:
5817 const clang::CXXRecordDecl *cxx_record_decl =
5818 qual_type->getAsCXXRecordDecl();
5819 if (cxx_record_decl)
5820 count = cxx_record_decl->getNumVBases();
5833 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5834 switch (type_class) {
5835 case clang::Type::Record:
5837 const clang::CXXRecordDecl *cxx_record_decl =
5838 qual_type->getAsCXXRecordDecl();
5839 if (cxx_record_decl) {
5840 uint32_t curr_idx = 0;
5841 clang::CXXRecordDecl::base_class_const_iterator base_class,
5843 for (base_class = cxx_record_decl->bases_begin(),
5844 base_class_end = cxx_record_decl->bases_end();
5845 base_class != base_class_end; ++base_class, ++curr_idx) {
5846 if (curr_idx == idx) {
5847 if (bit_offset_ptr) {
5848 const clang::ASTRecordLayout &record_layout =
5850 const clang::CXXRecordDecl *base_class_decl =
5851 llvm::cast<clang::CXXRecordDecl>(
5852 base_class->getType()
5853 ->castAs<clang::RecordType>()
5855 if (base_class->isVirtual())
5857 record_layout.getVBaseClassOffset(base_class_decl)
5862 record_layout.getBaseClassOffset(base_class_decl)
5866 return GetType(base_class->getType());
5873 case clang::Type::ObjCObjectPointer:
5876 case clang::Type::ObjCObject:
5878 const clang::ObjCObjectType *objc_class_type =
5879 qual_type->getAsObjCQualifiedInterfaceType();
5880 if (objc_class_type) {
5881 clang::ObjCInterfaceDecl *class_interface_decl =
5882 objc_class_type->getInterface();
5884 if (class_interface_decl) {
5885 clang::ObjCInterfaceDecl *superclass_interface_decl =
5886 class_interface_decl->getSuperClass();
5887 if (superclass_interface_decl) {
5889 *bit_offset_ptr = 0;
5891 superclass_interface_decl));
5897 case clang::Type::ObjCInterface:
5899 const clang::ObjCObjectType *objc_interface_type =
5900 qual_type->getAs<clang::ObjCInterfaceType>();
5901 if (objc_interface_type) {
5902 clang::ObjCInterfaceDecl *class_interface_decl =
5903 objc_interface_type->getInterface();
5905 if (class_interface_decl) {
5906 clang::ObjCInterfaceDecl *superclass_interface_decl =
5907 class_interface_decl->getSuperClass();
5908 if (superclass_interface_decl) {
5910 *bit_offset_ptr = 0;
5912 superclass_interface_decl));
5928 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5929 switch (type_class) {
5930 case clang::Type::Record:
5932 const clang::CXXRecordDecl *cxx_record_decl =
5933 qual_type->getAsCXXRecordDecl();
5934 if (cxx_record_decl) {
5935 uint32_t curr_idx = 0;
5936 clang::CXXRecordDecl::base_class_const_iterator base_class,
5938 for (base_class = cxx_record_decl->vbases_begin(),
5939 base_class_end = cxx_record_decl->vbases_end();
5940 base_class != base_class_end; ++base_class, ++curr_idx) {
5941 if (curr_idx == idx) {
5942 if (bit_offset_ptr) {
5943 const clang::ASTRecordLayout &record_layout =
5945 const clang::CXXRecordDecl *base_class_decl =
5946 llvm::cast<clang::CXXRecordDecl>(
5947 base_class->getType()
5948 ->castAs<clang::RecordType>()
5951 record_layout.getVBaseClassOffset(base_class_decl)
5955 return GetType(base_class->getType());
5970 llvm::StringRef name) {
5972 switch (qual_type->getTypeClass()) {
5973 case clang::Type::Record: {
5977 const clang::RecordType *record_type =
5978 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5979 const clang::RecordDecl *record_decl =
5980 record_type->getDecl()->getDefinitionOrSelf();
5982 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
5983 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
5984 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
5985 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
6009 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6010 switch (type_class) {
6011 case clang::Type::Builtin:
6012 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6013 case clang::BuiltinType::UnknownAny:
6014 case clang::BuiltinType::Void:
6015 case clang::BuiltinType::NullPtr:
6016 case clang::BuiltinType::OCLEvent:
6017 case clang::BuiltinType::OCLImage1dRO:
6018 case clang::BuiltinType::OCLImage1dWO:
6019 case clang::BuiltinType::OCLImage1dRW:
6020 case clang::BuiltinType::OCLImage1dArrayRO:
6021 case clang::BuiltinType::OCLImage1dArrayWO:
6022 case clang::BuiltinType::OCLImage1dArrayRW:
6023 case clang::BuiltinType::OCLImage1dBufferRO:
6024 case clang::BuiltinType::OCLImage1dBufferWO:
6025 case clang::BuiltinType::OCLImage1dBufferRW:
6026 case clang::BuiltinType::OCLImage2dRO:
6027 case clang::BuiltinType::OCLImage2dWO:
6028 case clang::BuiltinType::OCLImage2dRW:
6029 case clang::BuiltinType::OCLImage2dArrayRO:
6030 case clang::BuiltinType::OCLImage2dArrayWO:
6031 case clang::BuiltinType::OCLImage2dArrayRW:
6032 case clang::BuiltinType::OCLImage3dRO:
6033 case clang::BuiltinType::OCLImage3dWO:
6034 case clang::BuiltinType::OCLImage3dRW:
6035 case clang::BuiltinType::OCLSampler:
6036 case clang::BuiltinType::HLSLResource:
6038 case clang::BuiltinType::Bool:
6039 case clang::BuiltinType::Char_U:
6040 case clang::BuiltinType::UChar:
6041 case clang::BuiltinType::WChar_U:
6042 case clang::BuiltinType::Char16:
6043 case clang::BuiltinType::Char32:
6044 case clang::BuiltinType::UShort:
6045 case clang::BuiltinType::UInt:
6046 case clang::BuiltinType::ULong:
6047 case clang::BuiltinType::ULongLong:
6048 case clang::BuiltinType::UInt128:
6049 case clang::BuiltinType::Char_S:
6050 case clang::BuiltinType::SChar:
6051 case clang::BuiltinType::WChar_S:
6052 case clang::BuiltinType::Short:
6053 case clang::BuiltinType::Int:
6054 case clang::BuiltinType::Long:
6055 case clang::BuiltinType::LongLong:
6056 case clang::BuiltinType::Int128:
6057 case clang::BuiltinType::Float:
6058 case clang::BuiltinType::Double:
6059 case clang::BuiltinType::LongDouble:
6060 case clang::BuiltinType::Float128:
6061 case clang::BuiltinType::Dependent:
6062 case clang::BuiltinType::Overload:
6063 case clang::BuiltinType::ObjCId:
6064 case clang::BuiltinType::ObjCClass:
6065 case clang::BuiltinType::ObjCSel:
6066 case clang::BuiltinType::BoundMember:
6067 case clang::BuiltinType::Half:
6068 case clang::BuiltinType::ARCUnbridgedCast:
6069 case clang::BuiltinType::PseudoObject:
6070 case clang::BuiltinType::BuiltinFn:
6071 case clang::BuiltinType::ArraySection:
6078 case clang::Type::Complex:
6080 case clang::Type::Pointer:
6082 case clang::Type::BlockPointer:
6085 case clang::Type::LValueReference:
6087 case clang::Type::RValueReference:
6089 case clang::Type::MemberPointer:
6091 case clang::Type::ConstantArray:
6093 case clang::Type::IncompleteArray:
6095 case clang::Type::VariableArray:
6097 case clang::Type::DependentSizedArray:
6099 case clang::Type::DependentSizedExtVector:
6101 case clang::Type::Vector:
6103 case clang::Type::ExtVector:
6105 case clang::Type::FunctionProto:
6107 case clang::Type::FunctionNoProto:
6109 case clang::Type::UnresolvedUsing:
6111 case clang::Type::Record:
6113 case clang::Type::Enum:
6115 case clang::Type::TemplateTypeParm:
6117 case clang::Type::SubstTemplateTypeParm:
6119 case clang::Type::TemplateSpecialization:
6121 case clang::Type::InjectedClassName:
6123 case clang::Type::DependentName:
6125 case clang::Type::ObjCObject:
6127 case clang::Type::ObjCInterface:
6129 case clang::Type::ObjCObjectPointer:
6139 std::string &deref_name, uint32_t &deref_byte_size,
6140 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6144 return llvm::createStringError(
"not a pointer, reference or array type");
6145 uint32_t child_bitfield_bit_size = 0;
6146 uint32_t child_bitfield_bit_offset = 0;
6147 bool child_is_base_class;
6148 bool child_is_deref_of_parent;
6150 type, exe_ctx, 0,
false,
true,
false, deref_name, deref_byte_size,
6151 deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6152 child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
6157 bool transparent_pointers,
bool omit_empty_base_classes,
6158 bool ignore_array_bounds, std::string &child_name,
6159 uint32_t &child_byte_size, int32_t &child_byte_offset,
6160 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6161 bool &child_is_base_class,
bool &child_is_deref_of_parent,
6164 return llvm::createStringError(
"invalid type");
6166 auto get_exe_scope = [&exe_ctx]() {
6170 clang::QualType parent_qual_type(
6172 const clang::Type::TypeClass parent_type_class =
6173 parent_qual_type->getTypeClass();
6174 child_bitfield_bit_size = 0;
6175 child_bitfield_bit_offset = 0;
6176 child_is_base_class =
false;
6179 auto num_children_or_err =
6181 if (!num_children_or_err)
6182 return num_children_or_err.takeError();
6184 const bool idx_is_valid = idx < *num_children_or_err;
6186 switch (parent_type_class) {
6187 case clang::Type::Builtin:
6189 return llvm::createStringError(
"invalid index");
6191 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6192 case clang::BuiltinType::ObjCId:
6193 case clang::BuiltinType::ObjCClass:
6204 case clang::Type::Record: {
6206 return llvm::createStringError(
"invalid index");
6208 return llvm::createStringError(
"cannot complete type");
6210 const clang::RecordType *record_type =
6211 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6212 const clang::RecordDecl *record_decl =
6213 record_type->getDecl()->getDefinitionOrSelf();
6214 const clang::ASTRecordLayout &record_layout =
6216 uint32_t child_idx = 0;
6218 const clang::CXXRecordDecl *cxx_record_decl =
6219 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6220 if (cxx_record_decl) {
6222 clang::CXXRecordDecl::base_class_const_iterator base_class,
6224 for (base_class = cxx_record_decl->bases_begin(),
6225 base_class_end = cxx_record_decl->bases_end();
6226 base_class != base_class_end; ++base_class) {
6227 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6230 if (omit_empty_base_classes) {
6232 llvm::cast<clang::CXXRecordDecl>(
6233 base_class->getType()->getAs<clang::RecordType>()->getDecl())
6234 ->getDefinitionOrSelf();
6239 if (idx == child_idx) {
6240 if (base_class_decl ==
nullptr)
6241 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6242 base_class->getType()
6243 ->getAs<clang::RecordType>()
6245 ->getDefinitionOrSelf();
6247 if (base_class->isVirtual()) {
6248 bool handled =
false;
6250 clang::VTableContextBase *vtable_ctx =
6254 cxx_record_decl, base_class_decl,
6258 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6262 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6267 child_byte_offset = bit_offset / 8;
6270 auto size_or_err = base_class_clang_type.
GetBitSize(get_exe_scope());
6272 return llvm::joinErrors(
6273 llvm::createStringError(
"no size info for base class"),
6274 size_or_err.takeError());
6276 uint64_t base_class_clang_type_bit_size = *size_or_err;
6279 assert(base_class_clang_type_bit_size % 8 == 0);
6280 child_byte_size = base_class_clang_type_bit_size / 8;
6281 child_is_base_class =
true;
6282 return base_class_clang_type;
6290 uint32_t field_idx = 0;
6291 clang::RecordDecl::field_iterator field, field_end;
6292 for (field = record_decl->field_begin(),
6293 field_end = record_decl->field_end();
6294 field != field_end; ++field, ++field_idx, ++child_idx) {
6295 if (idx == child_idx) {
6298 child_name.assign(field->getNameAsString());
6303 assert(field_idx < record_layout.getFieldCount());
6304 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6306 return llvm::joinErrors(
6307 llvm::createStringError(
"no size info for field"),
6308 size_or_err.takeError());
6310 child_byte_size = *size_or_err;
6311 const uint32_t child_bit_size = child_byte_size * 8;
6315 bit_offset = record_layout.getFieldOffset(field_idx);
6317 child_bitfield_bit_offset = bit_offset % child_bit_size;
6318 const uint32_t child_bit_offset =
6319 bit_offset - child_bitfield_bit_offset;
6320 child_byte_offset = child_bit_offset / 8;
6322 child_byte_offset = bit_offset / 8;
6325 return field_clang_type;
6329 case clang::Type::ObjCObject:
6330 case clang::Type::ObjCInterface: {
6332 return llvm::createStringError(
"invalid index");
6334 return llvm::createStringError(
"cannot complete type");
6336 const clang::ObjCObjectType *objc_class_type =
6337 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6338 assert(objc_class_type);
6339 if (!objc_class_type)
6340 return llvm::createStringError(
"unexpected object type");
6342 uint32_t child_idx = 0;
6343 clang::ObjCInterfaceDecl *class_interface_decl =
6344 objc_class_type->getInterface();
6346 if (!class_interface_decl)
6347 return llvm::createStringError(
"cannot get interface decl");
6349 const clang::ASTRecordLayout &interface_layout =
6350 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6351 clang::ObjCInterfaceDecl *superclass_interface_decl =
6352 class_interface_decl->getSuperClass();
6353 if (superclass_interface_decl) {
6354 if (omit_empty_base_classes) {
6356 getASTContext().getObjCInterfaceType(superclass_interface_decl));
6357 if (llvm::expectedToStdOptional(base_class_clang_type.
GetNumChildren(
6358 omit_empty_base_classes, exe_ctx))
6361 clang::QualType ivar_qual_type(
getASTContext().getObjCInterfaceType(
6362 superclass_interface_decl));
6364 child_name.assign(superclass_interface_decl->getNameAsString());
6366 clang::TypeInfo ivar_type_info =
6369 child_byte_size = ivar_type_info.Width / 8;
6370 child_byte_offset = 0;
6371 child_is_base_class =
true;
6373 return GetType(ivar_qual_type);
6382 const uint32_t superclass_idx = child_idx;
6384 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6385 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6386 ivar_end = class_interface_decl->ivar_end();
6388 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
6390 if (child_idx == idx) {
6391 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6393 clang::QualType ivar_qual_type(ivar_decl->getType());
6395 child_name.assign(ivar_decl->getNameAsString());
6397 clang::TypeInfo ivar_type_info =
6400 child_byte_size = ivar_type_info.Width / 8;
6416 if (objc_runtime !=
nullptr) {
6419 parent_ast_type, ivar_decl->getNameAsString().c_str());
6427 if (child_byte_offset ==
6430 interface_layout.getFieldOffset(child_idx - superclass_idx);
6431 child_byte_offset = bit_offset / 8;
6443 interface_layout.getFieldOffset(child_idx - superclass_idx);
6445 child_bitfield_bit_offset = bit_offset % 8;
6447 return GetType(ivar_qual_type);
6454 case clang::Type::ObjCObjectPointer: {
6456 return llvm::createStringError(
"invalid index");
6460 child_is_deref_of_parent =
false;
6461 bool tmp_child_is_deref_of_parent =
false;
6463 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6464 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6465 child_bitfield_bit_size, child_bitfield_bit_offset,
6466 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6469 child_is_deref_of_parent =
true;
6470 const char *parent_name =
6473 child_name.assign(1,
'*');
6474 child_name += parent_name;
6479 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6481 return size_or_err.takeError();
6482 child_byte_size = *size_or_err;
6483 child_byte_offset = 0;
6484 return pointee_clang_type;
6489 case clang::Type::Vector:
6490 case clang::Type::ExtVector: {
6492 return llvm::createStringError(
"invalid index");
6493 const clang::VectorType *array =
6494 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6496 return llvm::createStringError(
"unexpected vector type");
6500 return llvm::createStringError(
"cannot complete type");
6502 char element_name[64];
6503 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6504 static_cast<uint64_t
>(idx));
6505 child_name.assign(element_name);
6506 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6508 return size_or_err.takeError();
6509 child_byte_size = *size_or_err;
6510 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6511 return element_type;
6513 case clang::Type::ConstantArray:
6514 case clang::Type::IncompleteArray: {
6515 if (!ignore_array_bounds && !idx_is_valid)
6516 return llvm::createStringError(
"invalid index");
6517 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6519 return llvm::createStringError(
"unexpected array type");
6522 return llvm::createStringError(
"cannot complete type");
6524 child_name = std::string(llvm::formatv(
"[{0}]", idx));
6525 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6527 return size_or_err.takeError();
6528 child_byte_size = *size_or_err;
6529 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6530 return element_type;
6532 case clang::Type::Pointer: {
6537 return llvm::createStringError(
"cannot dereference void *");
6540 child_is_deref_of_parent =
false;
6541 bool tmp_child_is_deref_of_parent =
false;
6543 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6544 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6545 child_bitfield_bit_size, child_bitfield_bit_offset,
6546 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6549 child_is_deref_of_parent =
true;
6553 child_name.assign(1,
'*');
6554 child_name += parent_name;
6559 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6561 return size_or_err.takeError();
6562 child_byte_size = *size_or_err;
6563 child_byte_offset = 0;
6564 return pointee_clang_type;
6569 case clang::Type::LValueReference:
6570 case clang::Type::RValueReference: {
6572 return llvm::createStringError(
"invalid index");
6573 const clang::ReferenceType *reference_type =
6574 llvm::cast<clang::ReferenceType>(
6578 child_is_deref_of_parent =
false;
6579 bool tmp_child_is_deref_of_parent =
false;
6581 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6582 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6583 child_bitfield_bit_size, child_bitfield_bit_offset,
6584 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6589 child_name.assign(1,
'&');
6590 child_name += parent_name;
6595 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6597 return size_or_err.takeError();
6598 child_byte_size = *size_or_err;
6599 child_byte_offset = 0;
6600 return pointee_clang_type;
6607 return llvm::createStringError(
"cannot enumerate children");
6611 const clang::RecordDecl *record_decl,
6612 const clang::CXXBaseSpecifier *base_spec,
6613 bool omit_empty_base_classes) {
6614 uint32_t child_idx = 0;
6616 const clang::CXXRecordDecl *cxx_record_decl =
6617 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6619 if (cxx_record_decl) {
6620 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6621 for (base_class = cxx_record_decl->bases_begin(),
6622 base_class_end = cxx_record_decl->bases_end();
6623 base_class != base_class_end; ++base_class) {
6624 if (omit_empty_base_classes) {
6629 if (base_class == base_spec)
6639 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6640 bool omit_empty_base_classes) {
6642 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6643 omit_empty_base_classes);
6645 clang::RecordDecl::field_iterator field, field_end;
6646 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6647 field != field_end; ++field, ++child_idx) {
6648 if (field->getCanonicalDecl() == canonical_decl)
6690 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6691 if (type && !name.empty()) {
6693 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6694 switch (type_class) {
6695 case clang::Type::Record:
6697 const clang::RecordType *record_type =
6698 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6699 const clang::RecordDecl *record_decl =
6700 record_type->getDecl()->getDefinitionOrSelf();
6702 assert(record_decl);
6703 uint32_t child_idx = 0;
6705 const clang::CXXRecordDecl *cxx_record_decl =
6706 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6709 clang::RecordDecl::field_iterator field, field_end;
6710 for (field = record_decl->field_begin(),
6711 field_end = record_decl->field_end();
6712 field != field_end; ++field, ++child_idx) {
6713 llvm::StringRef field_name = field->getName();
6714 if (field_name.empty()) {
6716 std::vector<uint32_t> save_indices = child_indexes;
6717 child_indexes.push_back(
6719 cxx_record_decl, omit_empty_base_classes));
6721 name, omit_empty_base_classes, child_indexes))
6722 return child_indexes.size();
6723 child_indexes = std::move(save_indices);
6724 }
else if (field_name == name) {
6726 child_indexes.push_back(
6728 cxx_record_decl, omit_empty_base_classes));
6729 return child_indexes.size();
6733 if (cxx_record_decl) {
6734 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6737 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6738 clang::DeclarationName decl_name(&ident_ref);
6740 clang::CXXBasePaths paths;
6741 if (cxx_record_decl->lookupInBases(
6742 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6743 clang::CXXBasePath &path) {
6744 CXXRecordDecl *record =
6745 specifier->getType()->getAsCXXRecordDecl();
6746 auto r = record->lookup(decl_name);
6747 path.Decls = r.begin();
6751 clang::CXXBasePaths::const_paths_iterator path,
6752 path_end = paths.end();
6753 for (path = paths.begin(); path != path_end; ++path) {
6754 const size_t num_path_elements = path->size();
6755 for (
size_t e = 0; e < num_path_elements; ++e) {
6756 clang::CXXBasePathElement elem = (*path)[e];
6759 omit_empty_base_classes);
6761 child_indexes.clear();
6764 child_indexes.push_back(child_idx);
6765 parent_record_decl = elem.Base->getType()
6766 ->castAs<clang::RecordType>()
6768 ->getDefinitionOrSelf();
6771 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6774 parent_record_decl, *I, omit_empty_base_classes);
6776 child_indexes.clear();
6779 child_indexes.push_back(child_idx);
6783 return child_indexes.size();
6789 case clang::Type::ObjCObject:
6790 case clang::Type::ObjCInterface:
6792 llvm::StringRef name_sref(name);
6793 const clang::ObjCObjectType *objc_class_type =
6794 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6795 assert(objc_class_type);
6796 if (objc_class_type) {
6797 uint32_t child_idx = 0;
6798 clang::ObjCInterfaceDecl *class_interface_decl =
6799 objc_class_type->getInterface();
6801 if (class_interface_decl) {
6802 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6803 ivar_end = class_interface_decl->ivar_end();
6804 clang::ObjCInterfaceDecl *superclass_interface_decl =
6805 class_interface_decl->getSuperClass();
6807 for (ivar_pos = class_interface_decl->ivar_begin();
6808 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6809 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6811 if (ivar_decl->getName() == name_sref) {
6812 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6813 (omit_empty_base_classes &&
6817 child_indexes.push_back(child_idx);
6818 return child_indexes.size();
6822 if (superclass_interface_decl) {
6826 child_indexes.push_back(0);
6830 superclass_interface_decl));
6832 name, omit_empty_base_classes, child_indexes)) {
6835 return child_indexes.size();
6840 child_indexes.pop_back();
6847 case clang::Type::ObjCObjectPointer: {
6849 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6850 ->getPointeeType());
6852 name, omit_empty_base_classes, child_indexes);
6855 case clang::Type::LValueReference:
6856 case clang::Type::RValueReference: {
6857 const clang::ReferenceType *reference_type =
6858 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
6859 clang::QualType pointee_type(reference_type->getPointeeType());
6864 name, omit_empty_base_classes, child_indexes);
6868 case clang::Type::Pointer: {
6873 name, omit_empty_base_classes, child_indexes);
6888llvm::Expected<uint32_t>
6890 llvm::StringRef name,
6891 bool omit_empty_base_classes) {
6892 if (type && !name.empty()) {
6895 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6897 switch (type_class) {
6898 case clang::Type::Record:
6900 const clang::RecordType *record_type =
6901 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6902 const clang::RecordDecl *record_decl =
6903 record_type->getDecl()->getDefinitionOrSelf();
6905 assert(record_decl);
6906 uint32_t child_idx = 0;
6908 const clang::CXXRecordDecl *cxx_record_decl =
6909 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6911 if (cxx_record_decl) {
6912 clang::CXXRecordDecl::base_class_const_iterator base_class,
6914 for (base_class = cxx_record_decl->bases_begin(),
6915 base_class_end = cxx_record_decl->bases_end();
6916 base_class != base_class_end; ++base_class) {
6918 clang::CXXRecordDecl *base_class_decl =
6919 llvm::cast<clang::CXXRecordDecl>(
6920 base_class->getType()
6921 ->castAs<clang::RecordType>()
6923 ->getDefinitionOrSelf();
6924 if (omit_empty_base_classes &&
6929 std::string base_class_type_name(
6931 if (base_class_type_name == name)
6938 clang::RecordDecl::field_iterator field, field_end;
6939 for (field = record_decl->field_begin(),
6940 field_end = record_decl->field_end();
6941 field != field_end; ++field, ++child_idx) {
6942 if (field->getName() == name)
6948 case clang::Type::ObjCObject:
6949 case clang::Type::ObjCInterface:
6951 const clang::ObjCObjectType *objc_class_type =
6952 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6953 assert(objc_class_type);
6954 if (objc_class_type) {
6955 uint32_t child_idx = 0;
6956 clang::ObjCInterfaceDecl *class_interface_decl =
6957 objc_class_type->getInterface();
6959 if (class_interface_decl) {
6960 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6961 ivar_end = class_interface_decl->ivar_end();
6962 clang::ObjCInterfaceDecl *superclass_interface_decl =
6963 class_interface_decl->getSuperClass();
6965 for (ivar_pos = class_interface_decl->ivar_begin();
6966 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6967 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6969 if (ivar_decl->getName() == name) {
6970 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6971 (omit_empty_base_classes &&
6979 if (superclass_interface_decl) {
6980 if (superclass_interface_decl->getName() == name)
6988 case clang::Type::ObjCObjectPointer: {
6990 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6991 ->getPointeeType());
6993 name, omit_empty_base_classes);
6996 case clang::Type::LValueReference:
6997 case clang::Type::RValueReference: {
6998 const clang::ReferenceType *reference_type =
6999 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7004 omit_empty_base_classes);
7008 case clang::Type::Pointer: {
7009 const clang::PointerType *pointer_type =
7010 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7015 omit_empty_base_classes);
7023 return llvm::createStringError(
"Type has no child named '%s'",
7024 name.str().c_str());
7029 llvm::StringRef name) {
7030 if (!type || name.empty())
7034 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7036 switch (type_class) {
7037 case clang::Type::Record: {
7040 const clang::RecordType *record_type =
7041 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7042 const clang::RecordDecl *record_decl =
7043 record_type->getDecl()->getDefinitionOrSelf();
7045 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7046 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7047 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7049 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7051 ElaboratedTypeKeyword::None, std::nullopt,
7067 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7068 return isa<clang::ClassTemplateSpecializationDecl>(
7069 cxx_record_decl->getDecl());
7080 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7081 switch (type_class) {
7082 case clang::Type::Record:
7084 const clang::CXXRecordDecl *cxx_record_decl =
7085 qual_type->getAsCXXRecordDecl();
7086 if (cxx_record_decl) {
7087 const clang::ClassTemplateSpecializationDecl *template_decl =
7088 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7090 if (template_decl) {
7091 const auto &template_arg_list = template_decl->getTemplateArgs();
7092 size_t num_args = template_arg_list.size();
7093 assert(num_args &&
"template specialization without any args");
7094 if (expand_pack && num_args) {
7095 const auto &pack = template_arg_list[num_args - 1];
7096 if (pack.getKind() == clang::TemplateArgument::Pack)
7097 num_args += pack.pack_size() - 1;
7112const clang::ClassTemplateSpecializationDecl *
7119 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7120 switch (type_class) {
7121 case clang::Type::Record: {
7124 const clang::CXXRecordDecl *cxx_record_decl =
7125 qual_type->getAsCXXRecordDecl();
7126 if (!cxx_record_decl)
7128 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7137const TemplateArgument *
7139 size_t idx,
bool expand_pack) {
7140 const auto &args = decl->getTemplateArgs();
7141 const size_t args_size = args.size();
7143 assert(args_size &&
"template specialization without any args");
7147 const size_t last_idx = args_size - 1;
7156 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7157 return idx >= args.size() ? nullptr : &args[idx];
7162 const auto &pack = args[last_idx];
7163 const size_t pack_idx = idx - last_idx;
7164 if (pack_idx >= pack.pack_size())
7166 return &pack.pack_elements()[pack_idx];
7171 size_t arg_idx,
bool expand_pack) {
7172 const clang::ClassTemplateSpecializationDecl *template_decl =
7181 switch (arg->getKind()) {
7182 case clang::TemplateArgument::Null:
7185 case clang::TemplateArgument::NullPtr:
7188 case clang::TemplateArgument::Type:
7191 case clang::TemplateArgument::Declaration:
7194 case clang::TemplateArgument::Integral:
7197 case clang::TemplateArgument::Template:
7200 case clang::TemplateArgument::TemplateExpansion:
7203 case clang::TemplateArgument::Expression:
7206 case clang::TemplateArgument::Pack:
7209 case clang::TemplateArgument::StructuralValue:
7212 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7217 size_t idx,
bool expand_pack) {
7218 const clang::ClassTemplateSpecializationDecl *template_decl =
7224 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7227 return GetType(arg->getAsType());
7230std::optional<CompilerType::IntegralTemplateArgument>
7232 size_t idx,
bool expand_pack) {
7233 const clang::ClassTemplateSpecializationDecl *template_decl =
7236 return std::nullopt;
7240 return std::nullopt;
7242 switch (arg->getKind()) {
7243 case clang::TemplateArgument::Integral:
7244 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7245 case clang::TemplateArgument::StructuralValue: {
7246 clang::APValue value = arg->getAsStructuralValue();
7249 if (value.isFloat())
7250 return {{value.getFloat(), type}};
7253 return {{value.getInt(), type}};
7255 return std::nullopt;
7258 return std::nullopt;
7272 bool is_signed =
false;
7273 bool isUnscopedEnumerationType =
7275 if (isUnscopedEnumerationType)
7296 llvm_unreachable(
"All cases handled above.");
7299llvm::Expected<CompilerType>
7316 uint64_t from_size = 0;
7324 llvm::Expected<uint64_t> from_size = from.
GetByteSize(exe_scope);
7326 return from_size.takeError();
7336 llvm::Expected<uint64_t> byte_size = type.GetByteSize(exe_scope);
7338 return byte_size.takeError();
7339 if (*from_size < *byte_size ||
7340 (*from_size == *byte_size && is_signed == type.IsSigned())) {
7344 llvm_unreachable(
"char type should fit into long long");
7349 llvm::Expected<uint64_t> int_byte_size = int_type.
GetByteSize(exe_scope);
7351 return int_byte_size.takeError();
7359 return (from_size == *int_byte_size)
7365 const clang::EnumType *enutype =
7368 return enutype->getDecl()->getDefinitionOrSelf();
7373 const clang::RecordType *record_type =
7376 return record_type->getDecl()->getDefinitionOrSelf();
7384clang::TypedefNameDecl *
7386 const clang::TypedefType *typedef_type =
7389 return typedef_type->getDecl();
7393clang::CXXRecordDecl *
7398clang::ObjCInterfaceDecl *
7400 const clang::ObjCObjectType *objc_class_type =
7401 llvm::dyn_cast<clang::ObjCObjectType>(
7403 if (objc_class_type)
7404 return objc_class_type->getInterface();
7410 const CompilerType &field_clang_type, uint32_t bitfield_bit_size) {
7416 clang::ASTContext &clang_ast = ast->getASTContext();
7417 clang::IdentifierInfo *ident =
nullptr;
7419 ident = &clang_ast.Idents.get(name);
7421 clang::FieldDecl *field =
nullptr;
7423 clang::Expr *bit_width =
nullptr;
7424 if (bitfield_bit_size != 0) {
7425 if (clang_ast.IntTy.isNull()) {
7428 "{0} failed: builtin ASTContext types have not been initialized");
7432 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7434 bit_width =
new (clang_ast)
7435 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7436 clang_ast.IntTy, clang::SourceLocation());
7437 bit_width = clang::ConstantExpr::Create(
7438 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7441 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7443 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7444 field->setDeclContext(record_decl);
7445 field->setDeclName(ident);
7448 field->setBitWidth(bit_width);
7454 if (
const clang::TagType *TagT =
7455 field->getType()->getAs<clang::TagType>()) {
7456 if (clang::RecordDecl *Rec =
7457 llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
7458 if (!Rec->getDeclName()) {
7459 Rec->setAnonymousStructOrUnion(
true);
7460 field->setImplicit();
7466 field->setAccess(AS_public);
7468 record_decl->addDecl(field);
7473 clang::ObjCInterfaceDecl *class_interface_decl =
7474 ast->GetAsObjCInterfaceDecl(type);
7476 if (class_interface_decl) {
7477 const bool is_synthesized =
false;
7482 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7483 ivar->setDeclContext(class_interface_decl);
7484 ivar->setDeclName(ident);
7486 ivar->setAccessControl(ObjCIvarDecl::AccessControl::Public);
7488 ivar->setBitWidth(bit_width);
7489 ivar->setSynthesize(is_synthesized);
7494 class_interface_decl->addDecl(field);
7511 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7516 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7518 IndirectFieldVector indirect_fields;
7519 clang::RecordDecl::field_iterator field_pos;
7520 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7521 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7522 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7523 last_field_pos = field_pos++) {
7524 if (field_pos->isAnonymousStructOrUnion()) {
7525 clang::QualType field_qual_type = field_pos->getType();
7527 const clang::RecordType *field_record_type =
7528 field_qual_type->getAs<clang::RecordType>();
7530 if (!field_record_type)
7533 clang::RecordDecl *field_record_decl =
7534 field_record_type->getDecl()->getDefinition();
7536 if (!field_record_decl)
7539 for (clang::RecordDecl::decl_iterator
7540 di = field_record_decl->decls_begin(),
7541 de = field_record_decl->decls_end();
7543 if (clang::FieldDecl *nested_field_decl =
7544 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7545 clang::NamedDecl **chain =
7546 new (ast->getASTContext()) clang::NamedDecl *[2];
7547 chain[0] = *field_pos;
7548 chain[1] = nested_field_decl;
7549 clang::IndirectFieldDecl *indirect_field =
7550 clang::IndirectFieldDecl::Create(
7551 ast->getASTContext(), record_decl, clang::SourceLocation(),
7552 nested_field_decl->getIdentifier(),
7553 nested_field_decl->getType(), {chain, 2});
7556 indirect_field->setImplicit();
7558 indirect_field->setAccess(AS_public);
7560 indirect_fields.push_back(indirect_field);
7561 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7562 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7563 size_t nested_chain_size =
7564 nested_indirect_field_decl->getChainingSize();
7565 clang::NamedDecl **chain =
new (ast->getASTContext())
7566 clang::NamedDecl *[nested_chain_size + 1];
7567 chain[0] = *field_pos;
7569 int chain_index = 1;
7570 for (clang::IndirectFieldDecl::chain_iterator
7571 nci = nested_indirect_field_decl->chain_begin(),
7572 nce = nested_indirect_field_decl->chain_end();
7574 chain[chain_index] = *nci;
7578 clang::IndirectFieldDecl *indirect_field =
7579 clang::IndirectFieldDecl::Create(
7580 ast->getASTContext(), record_decl, clang::SourceLocation(),
7581 nested_indirect_field_decl->getIdentifier(),
7582 nested_indirect_field_decl->getType(),
7583 {chain, nested_chain_size + 1});
7586 indirect_field->setImplicit();
7588 indirect_field->setAccess(AS_public);
7590 indirect_fields.push_back(indirect_field);
7598 if (last_field_pos != field_end_pos) {
7599 if (last_field_pos->getType()->isIncompleteArrayType())
7600 record_decl->hasFlexibleArrayMember();
7603 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7604 ife = indirect_fields.end();
7606 record_decl->addDecl(*ifi);
7619 record_decl->addAttr(
7620 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7627 llvm::StringRef name,
7636 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7640 clang::VarDecl *var_decl =
nullptr;
7641 clang::IdentifierInfo *ident =
nullptr;
7643 ident = &ast->getASTContext().Idents.get(name);
7646 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7647 var_decl->setDeclContext(record_decl);
7648 var_decl->setDeclName(ident);
7650 var_decl->setStorageClass(clang::SC_Static);
7655 var_decl->setAccess(AS_public);
7656 record_decl->addDecl(var_decl);
7658 VerifyDecl(var_decl);
7664 VarDecl *var,
const llvm::APInt &init_value) {
7665 assert(!var->hasInit() &&
"variable already initialized");
7667 clang::ASTContext &ast = var->getASTContext();
7668 QualType qt = var->getType();
7669 assert(qt->isIntegralOrEnumerationType() &&
7670 "only integer or enum types supported");
7673 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7674 const EnumDecl *enum_decl = enum_type->getDecl()->getDefinitionOrSelf();
7675 qt = enum_decl->getIntegerType();
7679 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7680 var->setInit(CXXBoolLiteralExpr::Create(
7681 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7683 var->setInit(IntegerLiteral::Create(
7684 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7689 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7690 assert(!var->hasInit() &&
"variable already initialized");
7692 clang::ASTContext &ast = var->getASTContext();
7693 QualType qt = var->getType();
7694 assert(qt->isFloatingType() &&
"only floating point types supported");
7695 var->setInit(FloatingLiteral::Create(
7696 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7699llvm::SmallVector<clang::ParmVarDecl *>
7701 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7702 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7704 assert(parameter_names.empty() ||
7705 parameter_names.size() == prototype.getNumParams());
7707 llvm::SmallVector<clang::ParmVarDecl *> params;
7708 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7710 llvm::StringRef name =
7711 !parameter_names.empty() ? parameter_names[param_index] :
"";
7715 GetType(prototype.getParamType(param_index)),
7716 clang::SC_None,
false);
7719 params.push_back(param);
7727 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7728 bool is_virtual,
bool is_static,
bool is_inline,
bool is_explicit,
7729 bool is_attr_used,
bool is_artificial) {
7730 if (!type || !method_clang_type.
IsValid() || name.empty())
7735 clang::CXXRecordDecl *cxx_record_decl =
7736 record_qual_type->getAsCXXRecordDecl();
7738 if (cxx_record_decl ==
nullptr)
7743 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7745 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7747 const clang::FunctionType *function_type =
7748 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7750 if (function_type ==
nullptr)
7753 const clang::FunctionProtoType *method_function_prototype(
7754 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7756 if (!method_function_prototype)
7759 unsigned int num_params = method_function_prototype->getNumParams();
7761 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7762 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7767 const clang::ExplicitSpecifier explicit_spec(
7768 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7769 : clang::ExplicitSpecKind::ResolvedFalse);
7771 if (name.starts_with(
"~")) {
7772 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7774 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7775 cxx_dtor_decl->setDeclName(
7778 cxx_dtor_decl->setType(method_qual_type);
7779 cxx_dtor_decl->setImplicit(is_artificial);
7780 cxx_dtor_decl->setInlineSpecified(is_inline);
7781 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7782 cxx_method_decl = cxx_dtor_decl;
7783 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7784 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7786 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7787 cxx_ctor_decl->setDeclName(
7790 cxx_ctor_decl->setType(method_qual_type);
7791 cxx_ctor_decl->setImplicit(is_artificial);
7792 cxx_ctor_decl->setInlineSpecified(is_inline);
7793 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7794 cxx_ctor_decl->setNumCtorInitializers(0);
7795 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7796 cxx_method_decl = cxx_ctor_decl;
7798 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7799 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7802 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7807 const bool is_method =
true;
7809 is_method, op_kind, num_params))
7811 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7813 cxx_method_decl->setDeclContext(cxx_record_decl);
7814 cxx_method_decl->setDeclName(
7815 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7816 cxx_method_decl->setType(method_qual_type);
7817 cxx_method_decl->setStorageClass(SC);
7818 cxx_method_decl->setInlineSpecified(is_inline);
7819 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7820 }
else if (num_params == 0) {
7822 auto *cxx_conversion_decl =
7823 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7825 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7826 cxx_conversion_decl->setDeclName(
7827 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7829 function_type->getReturnType())));
7830 cxx_conversion_decl->setType(method_qual_type);
7831 cxx_conversion_decl->setInlineSpecified(is_inline);
7832 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7833 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7834 cxx_method_decl = cxx_conversion_decl;
7838 if (cxx_method_decl ==
nullptr) {
7839 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7841 cxx_method_decl->setDeclContext(cxx_record_decl);
7842 cxx_method_decl->setDeclName(decl_name);
7843 cxx_method_decl->setType(method_qual_type);
7844 cxx_method_decl->setInlineSpecified(is_inline);
7845 cxx_method_decl->setStorageClass(SC);
7846 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7851 cxx_method_decl->setAccess(AS_public);
7852 cxx_method_decl->setVirtualAsWritten(is_virtual);
7855 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7857 if (!asm_label.empty())
7858 cxx_method_decl->addAttr(
7859 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7864 cxx_method_decl, *method_function_prototype, {}));
7866 cxx_record_decl->addDecl(cxx_method_decl);
7875 if (is_artificial) {
7876 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7877 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7878 (cxx_ctor_decl->isCopyConstructor() &&
7879 cxx_record_decl->hasTrivialCopyConstructor()) ||
7880 (cxx_ctor_decl->isMoveConstructor() &&
7881 cxx_record_decl->hasTrivialMoveConstructor()))) {
7882 cxx_ctor_decl->setDefaulted();
7883 cxx_ctor_decl->setTrivial(
true);
7884 }
else if (cxx_dtor_decl) {
7885 if (cxx_record_decl->hasTrivialDestructor()) {
7886 cxx_dtor_decl->setDefaulted();
7887 cxx_dtor_decl->setTrivial(
true);
7889 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7890 cxx_record_decl->hasTrivialCopyAssignment()) ||
7891 (cxx_method_decl->isMoveAssignmentOperator() &&
7892 cxx_record_decl->hasTrivialMoveAssignment())) {
7893 cxx_method_decl->setDefaulted();
7894 cxx_method_decl->setTrivial(
true);
7898 VerifyDecl(cxx_method_decl);
7900 return cxx_method_decl;
7906 for (
auto *method : record->methods())
7907 addOverridesForMethod(method);
7910#pragma mark C++ Base Classes
7912std::unique_ptr<clang::CXXBaseSpecifier>
7915 bool base_of_class) {
7919 return std::make_unique<clang::CXXBaseSpecifier>(
7920 clang::SourceRange(), is_virtual, base_of_class,
7923 clang::SourceLocation());
7928 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
7932 if (!cxx_record_decl)
7934 std::vector<clang::CXXBaseSpecifier *> raw_bases;
7935 raw_bases.reserve(bases.size());
7939 for (
auto &b : bases)
7940 raw_bases.push_back(b.get());
7941 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
7950 clang::ASTContext &clang_ast = ast->getASTContext();
7952 if (type && superclass_clang_type.
IsValid() &&
7954 clang::ObjCInterfaceDecl *class_interface_decl =
7956 clang::ObjCInterfaceDecl *super_interface_decl =
7958 if (class_interface_decl && super_interface_decl) {
7959 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
7960 clang_ast.getObjCInterfaceType(super_interface_decl)));
7969 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
7970 const char *property_setter_name,
const char *property_getter_name,
7972 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
7973 property_name[0] ==
'\0')
7978 clang::ASTContext &clang_ast = ast->getASTContext();
7981 if (!class_interface_decl)
7986 if (property_clang_type.
IsValid())
7987 property_clang_type_to_access = property_clang_type;
7989 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
7991 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
7994 clang::TypeSourceInfo *prop_type_source;
7996 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
7998 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
8001 clang::ObjCPropertyDecl *property_decl =
8002 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8003 property_decl->setDeclContext(class_interface_decl);
8004 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
8005 property_decl->setType(ivar_decl
8006 ? ivar_decl->getType()
8014 ast->SetMetadata(property_decl, metadata);
8016 class_interface_decl->addDecl(property_decl);
8018 clang::Selector setter_sel, getter_sel;
8020 if (property_setter_name) {
8021 std::string property_setter_no_colon(property_setter_name,
8022 strlen(property_setter_name) - 1);
8023 const clang::IdentifierInfo *setter_ident =
8024 &clang_ast.Idents.get(property_setter_no_colon);
8025 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8026 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
8027 std::string setter_sel_string(
"set");
8028 setter_sel_string.push_back(::toupper(property_name[0]));
8029 setter_sel_string.append(&property_name[1]);
8030 const clang::IdentifierInfo *setter_ident =
8031 &clang_ast.Idents.get(setter_sel_string);
8032 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8034 property_decl->setSetterName(setter_sel);
8035 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
8037 if (property_getter_name !=
nullptr) {
8038 const clang::IdentifierInfo *getter_ident =
8039 &clang_ast.Idents.get(property_getter_name);
8040 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8042 const clang::IdentifierInfo *getter_ident =
8043 &clang_ast.Idents.get(property_name);
8044 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8046 property_decl->setGetterName(getter_sel);
8047 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
8050 property_decl->setPropertyIvarDecl(ivar_decl);
8052 if (property_attributes & DW_APPLE_PROPERTY_readonly)
8053 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
8054 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
8055 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
8056 if (property_attributes & DW_APPLE_PROPERTY_assign)
8057 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
8058 if (property_attributes & DW_APPLE_PROPERTY_retain)
8059 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
8060 if (property_attributes & DW_APPLE_PROPERTY_copy)
8061 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
8062 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8063 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
8064 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
8065 property_decl->setPropertyAttributes(
8066 ObjCPropertyAttribute::kind_nullability);
8067 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
8068 property_decl->setPropertyAttributes(
8069 ObjCPropertyAttribute::kind_null_resettable);
8070 if (property_attributes & ObjCPropertyAttribute::kind_class)
8071 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8073 const bool isInstance =
8074 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8076 clang::ObjCMethodDecl *getter =
nullptr;
8077 if (!getter_sel.isNull())
8078 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8079 : class_interface_decl->lookupClassMethod(getter_sel);
8080 if (!getter_sel.isNull() && !getter) {
8081 const bool isVariadic =
false;
8082 const bool isPropertyAccessor =
true;
8083 const bool isSynthesizedAccessorStub =
false;
8084 const bool isImplicitlyDeclared =
true;
8085 const bool isDefined =
false;
8086 const clang::ObjCImplementationControl impControl =
8087 clang::ObjCImplementationControl::None;
8088 const bool HasRelatedResultType =
false;
8091 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8092 getter->setDeclName(getter_sel);
8094 getter->setDeclContext(class_interface_decl);
8095 getter->setInstanceMethod(isInstance);
8096 getter->setVariadic(isVariadic);
8097 getter->setPropertyAccessor(isPropertyAccessor);
8098 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8099 getter->setImplicit(isImplicitlyDeclared);
8100 getter->setDefined(isDefined);
8101 getter->setDeclImplementation(impControl);
8102 getter->setRelatedResultType(HasRelatedResultType);
8106 ast->SetMetadata(getter, metadata);
8108 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8109 llvm::ArrayRef<clang::SourceLocation>());
8110 class_interface_decl->addDecl(getter);
8114 getter->setPropertyAccessor(
true);
8115 property_decl->setGetterMethodDecl(getter);
8118 clang::ObjCMethodDecl *setter =
nullptr;
8119 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8120 : class_interface_decl->lookupClassMethod(setter_sel);
8121 if (!setter_sel.isNull() && !setter) {
8122 clang::QualType result_type = clang_ast.VoidTy;
8123 const bool isVariadic =
false;
8124 const bool isPropertyAccessor =
true;
8125 const bool isSynthesizedAccessorStub =
false;
8126 const bool isImplicitlyDeclared =
true;
8127 const bool isDefined =
false;
8128 const clang::ObjCImplementationControl impControl =
8129 clang::ObjCImplementationControl::None;
8130 const bool HasRelatedResultType =
false;
8133 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8134 setter->setDeclName(setter_sel);
8135 setter->setReturnType(result_type);
8136 setter->setDeclContext(class_interface_decl);
8137 setter->setInstanceMethod(isInstance);
8138 setter->setVariadic(isVariadic);
8139 setter->setPropertyAccessor(isPropertyAccessor);
8140 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8141 setter->setImplicit(isImplicitlyDeclared);
8142 setter->setDefined(isDefined);
8143 setter->setDeclImplementation(impControl);
8144 setter->setRelatedResultType(HasRelatedResultType);
8148 ast->SetMetadata(setter, metadata);
8150 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8151 params.push_back(clang::ParmVarDecl::Create(
8152 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8155 clang::SC_Auto,
nullptr));
8157 setter->setMethodParams(clang_ast,
8158 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8159 llvm::ArrayRef<clang::SourceLocation>());
8161 class_interface_decl->addDecl(setter);
8165 setter->setPropertyAccessor(
true);
8166 property_decl->setSetterMethodDecl(setter);
8177 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8178 bool is_objc_direct_call) {
8179 if (!type || !method_clang_type.
IsValid())
8184 if (class_interface_decl ==
nullptr)
8187 if (lldb_ast ==
nullptr)
8189 clang::ASTContext &ast = lldb_ast->getASTContext();
8191 const char *selector_start = ::strchr(name,
' ');
8192 if (selector_start ==
nullptr)
8196 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8201 unsigned num_selectors_with_args = 0;
8202 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8204 len = ::strcspn(start,
":]");
8205 bool has_arg = (start[len] ==
':');
8207 ++num_selectors_with_args;
8208 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8213 if (selector_idents.size() == 0)
8216 clang::Selector method_selector = ast.Selectors.getSelector(
8217 num_selectors_with_args ? selector_idents.size() : 0,
8218 selector_idents.data());
8223 const clang::Type *method_type(method_qual_type.getTypePtr());
8225 if (method_type ==
nullptr)
8228 const clang::FunctionProtoType *method_function_prototype(
8229 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8231 if (!method_function_prototype)
8234 const bool isInstance = (name[0] ==
'-');
8235 const bool isVariadic = is_variadic;
8236 const bool isPropertyAccessor =
false;
8237 const bool isSynthesizedAccessorStub =
false;
8239 const bool isImplicitlyDeclared =
true;
8240 const bool isDefined =
false;
8241 const clang::ObjCImplementationControl impControl =
8242 clang::ObjCImplementationControl::None;
8243 const bool HasRelatedResultType =
false;
8245 const unsigned num_args = method_function_prototype->getNumParams();
8247 if (num_args != num_selectors_with_args)
8251 auto *objc_method_decl =
8252 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8253 objc_method_decl->setDeclName(method_selector);
8254 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8255 objc_method_decl->setDeclContext(
8257 objc_method_decl->setInstanceMethod(isInstance);
8258 objc_method_decl->setVariadic(isVariadic);
8259 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8260 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8261 objc_method_decl->setImplicit(isImplicitlyDeclared);
8262 objc_method_decl->setDefined(isDefined);
8263 objc_method_decl->setDeclImplementation(impControl);
8264 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8267 if (objc_method_decl ==
nullptr)
8271 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8273 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8274 params.push_back(clang::ParmVarDecl::Create(
8275 ast, objc_method_decl, clang::SourceLocation(),
8276 clang::SourceLocation(),
8278 method_function_prototype->getParamType(param_index),
nullptr,
8279 clang::SC_Auto,
nullptr));
8282 objc_method_decl->setMethodParams(
8283 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8284 llvm::ArrayRef<clang::SourceLocation>());
8287 if (is_objc_direct_call) {
8290 objc_method_decl->addAttr(
8291 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8296 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8299 class_interface_decl->addDecl(objc_method_decl);
8301 VerifyDecl(objc_method_decl);
8303 return objc_method_decl;
8313 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8314 switch (type_class) {
8315 case clang::Type::Record: {
8316 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8317 if (cxx_record_decl) {
8318 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8319 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8324 case clang::Type::Enum: {
8325 clang::EnumDecl *enum_decl =
8326 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8328 enum_decl->setHasExternalLexicalStorage(has_extern);
8329 enum_decl->setHasExternalVisibleStorage(has_extern);
8334 case clang::Type::ObjCObject:
8335 case clang::Type::ObjCInterface: {
8336 const clang::ObjCObjectType *objc_class_type =
8337 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8338 assert(objc_class_type);
8339 if (objc_class_type) {
8340 clang::ObjCInterfaceDecl *class_interface_decl =
8341 objc_class_type->getInterface();
8343 if (class_interface_decl) {
8344 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8345 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8361 if (!qual_type.isNull()) {
8362 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8364 clang::TagDecl *tag_decl = tag_type->getDecl();
8366 tag_decl->startDefinition();
8371 const clang::ObjCObjectType *object_type =
8372 qual_type->getAs<clang::ObjCObjectType>();
8374 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8375 if (interface_decl) {
8376 interface_decl->startDefinition();
8387 if (qual_type.isNull())
8391 if (lldb_ast ==
nullptr)
8397 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8399 clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinitionOrSelf();
8401 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8411 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8412 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8413 if (cxx_record_decl->needsImplicitCopyConstructor())
8414 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8415 if (cxx_record_decl->needsImplicitCopyAssignment())
8416 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8419 if (!cxx_record_decl->isCompleteDefinition())
8420 cxx_record_decl->completeDefinition();
8421 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8422 cxx_record_decl->setHasExternalLexicalStorage(
false);
8423 cxx_record_decl->setHasExternalVisibleStorage(
false);
8428 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8432 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8434 if (enum_decl->isCompleteDefinition())
8437 QualType integer_type(enum_decl->getIntegerType());
8438 if (!integer_type.isNull()) {
8439 clang::ASTContext &ast = lldb_ast->getASTContext();
8441 unsigned NumNegativeBits = 0;
8442 unsigned NumPositiveBits = 0;
8443 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8446 clang::QualType BestPromotionType;
8447 clang::QualType BestType;
8448 ast.computeBestEnumTypes(
false, NumNegativeBits,
8449 NumPositiveBits, BestType, BestPromotionType);
8451 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8452 BestPromotionType, NumPositiveBits,
8460 const llvm::APSInt &value) {
8471 if (!enum_opaque_compiler_type)
8474 clang::QualType enum_qual_type(
8477 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8482 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8487 clang::EnumConstantDecl *enumerator_decl =
8488 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8490 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8491 enumerator_decl->setDeclContext(enum_decl);
8492 if (name && name[0])
8493 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8494 enumerator_decl->setType(clang::QualType(enutype, 0));
8496 enumerator_decl->setAccess(AS_public);
8502 enum_decl->addDecl(enumerator_decl);
8504 VerifyDecl(enumerator_decl);
8505 return enumerator_decl;
8510 uint64_t enum_value, uint32_t enum_value_bit_size) {
8512 llvm::APSInt value(enum_value_bit_size,
8521 const clang::Type *clang_type = qt.getTypePtrOrNull();
8522 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8526 return GetType(enum_type->getDecl()->getDefinitionOrSelf()->getIntegerType());
8532 if (type && pointee_type.
IsValid() &&
8537 return ast->GetType(ast->getASTContext().getMemberPointerType(
8546#define DEPTH_INCREMENT 2
8549LLVM_DUMP_METHOD
void
8559struct ScopedASTColor {
8560 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8561 : ast(ast), old_show_colors(ast.getDiagnostics().getShowColors()) {
8562 ast.getDiagnostics().setShowColors(show_colors);
8565 ~ScopedASTColor() { ast.getDiagnostics().setShowColors(old_show_colors); }
8567 clang::ASTContext *
8568 const bool old_show_colors;
8577 clang::CreateASTDumper(output, filter,
8581 false, clang::ADOF_Default);
8584 consumer->HandleTranslationUnit(*
m_ast_up);
8588 llvm::StringRef symbol_name) {
8595 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8596 size_t ntypes = type_list.
GetSize();
8598 for (
size_t i = 0; i < ntypes; ++i) {
8601 if (!symbol_name.empty())
8602 if (symbol_name != type->GetName().GetStringRef())
8605 s << type->GetName().AsCString() <<
"\n";
8608 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8616 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8618 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8630 size_t byte_size, uint32_t bitfield_bit_offset,
8631 uint32_t bitfield_bit_size) {
8632 const clang::EnumType *enutype =
8633 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8634 const clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8636 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8637 const uint64_t enum_svalue =
8640 bitfield_bit_offset)
8642 bitfield_bit_offset);
8643 bool can_be_bitfield =
true;
8644 uint64_t covered_bits = 0;
8645 int num_enumerators = 0;
8653 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8654 if (enumerators.empty())
8655 can_be_bitfield =
false;
8657 for (
auto *enumerator : enumerators) {
8658 llvm::APSInt init_val = enumerator->getInitVal();
8659 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8660 : init_val.getZExtValue();
8661 if (qual_type_is_signed)
8662 val = llvm::SignExtend64(val, 8 * byte_size);
8663 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8664 can_be_bitfield =
false;
8665 covered_bits |= val;
8667 if (val == enum_svalue) {
8676 offset = byte_offset;
8678 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8682 if (!can_be_bitfield) {
8683 if (qual_type_is_signed)
8684 s.
Printf(
"%" PRIi64, enum_svalue);
8686 s.
Printf(
"%" PRIu64, enum_uvalue);
8693 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8697 uint64_t remaining_value = enum_uvalue;
8698 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8699 values.reserve(num_enumerators);
8700 for (
auto *enumerator : enum_decl->enumerators())
8701 if (
auto val = enumerator->getInitVal().getZExtValue())
8702 values.emplace_back(val, enumerator->getName());
8707 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8708 return llvm::popcount(a.first) > llvm::popcount(b.first);
8711 for (
const auto &val : values) {
8712 if ((remaining_value & val.first) != val.first)
8714 remaining_value &= ~val.first;
8716 if (remaining_value)
8722 if (remaining_value)
8723 s.
Printf(
"0x%" PRIx64, remaining_value);
8731 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8740 switch (qual_type->getTypeClass()) {
8741 case clang::Type::Typedef: {
8742 clang::QualType typedef_qual_type =
8743 llvm::cast<clang::TypedefType>(qual_type)
8745 ->getUnderlyingType();
8748 format = typedef_clang_type.
GetFormat();
8749 clang::TypeInfo typedef_type_info =
8751 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8761 bitfield_bit_offset,
8766 case clang::Type::Enum:
8771 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8772 bitfield_bit_offset, bitfield_bit_size);
8780 uint32_t item_count = 1;
8820 item_count = byte_size;
8825 item_count = byte_size / 2;
8830 item_count = byte_size / 4;
8836 bitfield_bit_size, bitfield_bit_offset,
8852 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(clang_type)) {
8861 clang::QualType qual_type =
8864 llvm::SmallVector<char, 1024> buf;
8865 llvm::raw_svector_ostream llvm_ostrm(buf);
8867 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8868 switch (type_class) {
8869 case clang::Type::ObjCObject:
8870 case clang::Type::ObjCInterface: {
8873 auto *objc_class_type =
8874 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8875 assert(objc_class_type);
8876 if (!objc_class_type)
8878 clang::ObjCInterfaceDecl *class_interface_decl =
8879 objc_class_type->getInterface();
8880 if (!class_interface_decl)
8883 class_interface_decl->dump(llvm_ostrm);
8885 class_interface_decl->print(llvm_ostrm,
8890 case clang::Type::Typedef: {
8891 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8894 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
8896 typedef_decl->dump(llvm_ostrm);
8899 if (!clang_typedef_name.empty()) {
8906 case clang::Type::Record: {
8909 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
8910 const clang::RecordDecl *record_decl = record_type->getDecl();
8912 record_decl->dump(llvm_ostrm);
8914 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
8920 if (
auto *tag_type =
8921 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
8922 if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
8924 tag_decl->dump(llvm_ostrm);
8926 tag_decl->print(llvm_ostrm, 0);
8932 std::string clang_type_name(qual_type.getAsString());
8933 if (!clang_type_name.empty())
8940 if (buf.size() > 0) {
8941 s.
Write(buf.data(), buf.size());
8948 clang::QualType qual_type(
8951 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8952 switch (type_class) {
8953 case clang::Type::Record: {
8954 const clang::CXXRecordDecl *cxx_record_decl =
8955 qual_type->getAsCXXRecordDecl();
8956 if (cxx_record_decl)
8957 printf(
"class %s", cxx_record_decl->getName().str().c_str());
8960 case clang::Type::Enum: {
8961 clang::EnumDecl *enum_decl =
8962 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8964 printf(
"enum %s", enum_decl->getName().str().c_str());
8968 case clang::Type::ObjCObject:
8969 case clang::Type::ObjCInterface: {
8970 const clang::ObjCObjectType *objc_class_type =
8971 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
8972 if (objc_class_type) {
8973 clang::ObjCInterfaceDecl *class_interface_decl =
8974 objc_class_type->getInterface();
8978 if (class_interface_decl)
8979 printf(
"@class %s", class_interface_decl->getName().str().c_str());
8983 case clang::Type::Typedef:
8984 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
8991 case clang::Type::Auto:
8994 llvm::cast<clang::AutoType>(qual_type)
8996 .getAsOpaquePtr()));
8998 case clang::Type::Paren:
9002 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
9005 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
9013 const char *parent_name,
int tag_decl_kind,
9015 if (template_param_infos.
IsValid()) {
9016 std::string template_basename(parent_name);
9018 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
9019 template_basename.erase(i);
9022 template_basename.c_str(), tag_decl_kind,
9023 template_param_infos);
9038 clang::ObjCInterfaceDecl *decl) {
9062 std::make_unique<npdb::PdbAstBuilderClang>(*
this);
9067 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9068 uint64_t &alignment,
9069 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9070 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9072 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9085 field_offsets, base_offsets, vbase_offsets);
9092 clang::NamedDecl *nd =
9093 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9103 if (!label_or_err) {
9104 llvm::consumeError(label_or_err.takeError());
9108 llvm::StringRef mangled = label_or_err->lookup_name;
9116 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9117 static_cast<clang::Decl *
>(opaque_decl));
9119 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9123 if (!mc || !mc->shouldMangleCXXName(nd))
9128 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9133 llvm::SmallVector<char, 1024> buf;
9134 llvm::raw_svector_ostream llvm_ostrm(buf);
9135 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9137 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9140 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9142 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9146 mc->mangleName(nd, llvm_ostrm);
9162 if (clang::FunctionDecl *func_decl =
9163 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9164 return GetType(func_decl->getReturnType());
9165 if (clang::ObjCMethodDecl *objc_method =
9166 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9167 return GetType(objc_method->getReturnType());
9173 if (clang::FunctionDecl *func_decl =
9174 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9175 return func_decl->param_size();
9176 if (clang::ObjCMethodDecl *objc_method =
9177 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9178 return objc_method->param_size();
9184 clang::DeclContext
const *decl_ctx) {
9185 switch (clang_kind) {
9186 case Decl::TranslationUnit:
9188 case Decl::Namespace:
9199 if (decl_ctx->isFunctionOrMethod())
9201 if (decl_ctx->isRecord())
9211 std::vector<lldb_private::CompilerContext> &context) {
9212 if (decl_ctx ==
nullptr)
9215 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9216 if (clang_kind == Decl::TranslationUnit)
9221 context.push_back({compiler_kind, decl_ctx_name});
9224std::vector<lldb_private::CompilerContext>
9226 std::vector<lldb_private::CompilerContext> context;
9229 clang::Decl *decl = (clang::Decl *)opaque_decl;
9231 clang::DeclContext *decl_ctx = decl->getDeclContext();
9234 auto compiler_kind =
9236 context.push_back({compiler_kind, decl_name});
9243 if (clang::FunctionDecl *func_decl =
9244 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9245 if (idx < func_decl->param_size()) {
9246 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9248 return GetType(var_decl->getOriginalType());
9250 }
else if (clang::ObjCMethodDecl *objc_method =
9251 llvm::dyn_cast<clang::ObjCMethodDecl>(
9252 (clang::Decl *)opaque_decl)) {
9253 if (idx < objc_method->param_size())
9254 return GetType(objc_method->parameters()[idx]->getOriginalType());
9260 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9261 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9264 clang::Expr *init_expr = var_decl->getInit();
9267 std::optional<llvm::APSInt> value =
9277 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9278 std::vector<CompilerDecl> found_decls;
9280 if (opaque_decl_ctx && symbol_file) {
9281 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9282 std::set<DeclContext *> searched;
9283 std::multimap<DeclContext *, DeclContext *> search_queue;
9285 for (clang::DeclContext *decl_context = root_decl_ctx;
9286 decl_context !=
nullptr && found_decls.empty();
9287 decl_context = decl_context->getParent()) {
9288 search_queue.insert(std::make_pair(decl_context, decl_context));
9290 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9292 if (!searched.insert(it->second).second)
9297 for (clang::Decl *child : it->second->decls()) {
9298 if (clang::UsingDirectiveDecl *ud =
9299 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9300 if (ignore_using_decls)
9302 clang::DeclContext *from = ud->getCommonAncestor();
9303 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9304 search_queue.insert(
9305 std::make_pair(from, ud->getNominatedNamespace()));
9306 }
else if (clang::UsingDecl *ud =
9307 llvm::dyn_cast<clang::UsingDecl>(child)) {
9308 if (ignore_using_decls)
9310 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9311 clang::Decl *target = usd->getTargetDecl();
9312 if (clang::NamedDecl *nd =
9313 llvm::dyn_cast<clang::NamedDecl>(target)) {
9314 IdentifierInfo *ii = nd->getIdentifier();
9315 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9319 }
else if (clang::NamedDecl *nd =
9320 llvm::dyn_cast<clang::NamedDecl>(child)) {
9321 IdentifierInfo *ii = nd->getIdentifier();
9322 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9373 clang::DeclContext *child_decl_ctx,
9377 if (frame_decl_ctx && symbol_file) {
9378 std::set<DeclContext *> searched;
9379 std::multimap<DeclContext *, DeclContext *> search_queue;
9382 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9386 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9387 decl_ctx = decl_ctx->getParent()) {
9388 if (!decl_ctx->isLookupContext())
9390 if (decl_ctx == parent_decl_ctx)
9393 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9394 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9396 if (searched.find(it->second) != searched.end())
9404 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9407 searched.insert(it->second);
9411 for (clang::Decl *child : it->second->decls()) {
9412 if (clang::UsingDirectiveDecl *ud =
9413 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9414 clang::DeclContext *ns = ud->getNominatedNamespace();
9415 if (ns == parent_decl_ctx)
9418 clang::DeclContext *from = ud->getCommonAncestor();
9419 if (searched.find(ns) == searched.end())
9420 search_queue.insert(std::make_pair(from, ns));
9421 }
else if (child_name) {
9422 if (clang::UsingDecl *ud =
9423 llvm::dyn_cast<clang::UsingDecl>(child)) {
9424 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9425 clang::Decl *target = usd->getTargetDecl();
9426 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9430 IdentifierInfo *ii = nd->getIdentifier();
9431 if (ii ==
nullptr ||
9432 ii->getName() != child_name->
AsCString(
nullptr))
9455 if (opaque_decl_ctx) {
9456 clang::NamedDecl *named_decl =
9457 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9460 llvm::raw_string_ostream stream{name};
9462 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9463 named_decl->getNameForDiagnostic(stream, policy,
false);
9472 if (opaque_decl_ctx) {
9473 clang::NamedDecl *named_decl =
9474 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9482 if (!opaque_decl_ctx)
9485 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9486 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9488 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9490 }
else if (clang::FunctionDecl *fun_decl =
9491 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9492 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9493 return metadata->HasObjectPtr();
9499std::vector<lldb_private::CompilerContext>
9501 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9502 std::vector<lldb_private::CompilerContext> context;
9508 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9509 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9510 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9514 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9515 if (DC->isInlineNamespace())
9518 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9519 return NS->isAnonymousNamespace();
9526 if (decl_ctx == other)
9528 }
while (is_transparent_lookup_allowed(other) &&
9529 (other = other->getParent()));
9536 if (!opaque_decl_ctx)
9539 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9540 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9542 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9544 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9545 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9546 return metadata->GetObjectPtrLanguage();
9566 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9574 return llvm::dyn_cast<clang::CXXMethodDecl>(
9579clang::FunctionDecl *
9582 return llvm::dyn_cast<clang::FunctionDecl>(
9587clang::NamespaceDecl *
9590 return llvm::dyn_cast<clang::NamespaceDecl>(
9595std::optional<ClangASTMetadata>
9597 const Decl *
object) {
9605 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9628 lldbassert(started &&
"Unable to start a class type definition.");
9633 ts->SetDeclIsForcefullyCompleted(td);
9647 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9648 std::unique_ptr<ClangASTSource> ast_source)
9650 m_scratch_ast_source_up(std::move(ast_source)) {
9652 m_scratch_ast_source_up->InstallASTContext(*
this);
9653 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9654 m_scratch_ast_source_up->CreateProxy();
9655 SetExternalSource(proxy_ast_source);
9659 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9667 llvm::Triple triple)
9674 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9686 std::optional<IsolatedASTKind> ast_kind,
9687 bool create_on_demand) {
9690 if (
auto err = type_system_or_err.takeError()) {
9692 "Couldn't get scratch TypeSystemClang: {0}");
9695 auto ts_sp = *type_system_or_err;
9697 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9702 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9704 return std::static_pointer_cast<TypeSystemClang>(
9709static llvm::StringRef
9713 return "C++ modules";
9715 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9719 llvm::StringRef filter,
bool show_color) {
9721 output <<
"State of scratch Clang type system:\n";
9725 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9726 std::vector<KeyAndTS> sorted_typesystems;
9728 sorted_typesystems.emplace_back(a.first, a.second.get());
9729 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9732 for (
const auto &a : sorted_typesystems) {
9735 output <<
"State of scratch Clang type subsystem "
9737 a.second->Dump(output, filter, show_color);
9742 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9750 desired_type, options, ctx_obj);
9755 const ValueList &arg_value_list,
const char *name) {
9760 Process *process = target_sp->GetProcessSP().get();
9765 arg_value_list, name);
9768std::unique_ptr<UtilityFunction>
9775 return std::make_unique<ClangUtilityFunction>(
9776 *target_sp.get(), std::move(text), std::move(name),
9777 target_sp->GetDebugUtilityExpression());
9791 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9795 return std::make_unique<ClangASTSource>(
9800static llvm::StringRef
9804 return "scratch ASTContext for C++ module types";
9806 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9813 return *found_ast->second;
9816 std::shared_ptr<TypeSystemClang> new_ast_sp =
9826 const clang::RecordType *record_type =
9827 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9829 const clang::RecordDecl *record_decl =
9830 record_type->getDecl()->getDefinitionOrSelf();
9831 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9832 return metadata->IsForcefullyCompleted();
9841 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9845 metadata->SetIsForcefullyCompleted();
9853 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
lldb::BasicType GetBasicTypeEnumeration() const
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
void SetCompilerType(lldb::TypeSystemWP type_system, lldb::opaque_compiler_type_t type)
size_t GetIndexOfChildMemberWithName(llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) const
Lookup a child member given a name.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
lldb::Encoding GetEncoding() const
bool IsPromotableIntegerType() const
uint32_t GetNumDirectBaseClasses() const
ConstString GetTypeName(bool BaseOnly=false) const
bool IsEnumerationIntegerTypeSigned() const
bool DumpTypeValue(Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope)
bool IsAggregateType() const
bool IsInteger() const
This is used when you don't care about the signedness of the integer.
lldb::Format GetFormat() const
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const
CompilerType GetDirectBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
bool GetCompleteType() const
Type Completion.
bool IsUnscopedEnumerationType() const
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
llvm::Expected< uint32_t > GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const
Lookup a child given a name.
llvm::Expected< uint32_t > GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
CompilerType GetCanonicalType() const
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
A class that describes the declaration location of a lldb object.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
Process * GetProcessPtr() const
Returns a pointer to the process object.
static FileSystem & Instance()
bool Test(ValueType bit) const
Test a single flag bit.
bool AnySet(ValueType mask) const
Test one or more flags.
Encapsulates a function that can be called.
static bool LanguageIsC(lldb::LanguageType language)
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
static bool LanguageIsPascal(lldb::LanguageType language)
static bool LanguageIsObjC(lldb::LanguageType language)
static bool IsMangledName(llvm::StringRef name)
A class that describes an executable image and its associated object and symbol files.
virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type, const char *ivar_name)
static ObjCLanguageRuntime * Get(Process &process)
unsigned GetValue() const
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Status &error)
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
uint32_t GetAddressByteSize() const
void Finalize() override
Free up any resources associated with this TypeSystem.
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
llvm::Triple m_triple
The target triple.
std::unique_ptr< ClangASTSource > CreateASTSource()
lldb::TargetWP m_target_wp
TypeSystemClang & GetIsolatedAST(IsolatedASTKind feature)
Returns the requested sub-AST.
UserExpression * GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language, Expression::ResultType desired_type, const EvaluateExpressionOptions &options, ValueObject *ctx_obj) override
std::unique_ptr< ClangASTSource > m_scratch_ast_source_up
The ExternalASTSource that performs lookups and completes minimally imported types.
IsolatedASTKind
The different kinds of isolated ASTs within the scratch TypeSystem.
@ CppModules
The isolated AST for declarations/types from expressions that imported type information from a C++ mo...
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< ClangPersistentVariables > m_persistent_variables
The persistent variables associated with this process for the expression parser.
static char ID
LLVM RTTI support.
PersistentExpressionState * GetPersistentExpressionState() override
FunctionCaller * GetFunctionCaller(const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, const char *name) override
std::unique_ptr< UtilityFunction > CreateUtilityFunction(std::string text, std::string name) override
void ForgetSource(clang::ASTContext *src_ctx, ClangASTImporter &importer)
Unregisters the given ASTContext as a source from the scratch AST (and all sub-ASTs).
static const std::nullopt_t DefaultAST
Alias for requesting the default scratch TypeSystemClang in GetForTarget.
ScratchTypeSystemClang(Target &target, llvm::Triple triple)
llvm::DenseMap< IsolatedASTKey, std::shared_ptr< TypeSystemClang > > m_isolated_asts
Map from IsolatedASTKind to their actual TypeSystemClang instance.
bool Fail() const
Test for error condition.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
unsigned GetIndentLevel() const
Get the current indentation level.
Provides public interface for all SymbolFiles.
virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx)
virtual bool CompleteType(CompilerType &compiler_type)=0
virtual void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list)=0
virtual std::optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx)=0
If type_uid points to an array type, return its characteristics.
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
const ArchSpec & GetArchitecture() const
void Insert(_KeyType k, _ValueType v)
_ValueType Lookup(_KeyType k)
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
The implementation of lldb::Type's m_payload field for TypeSystemClang.
void SetIsCompleteObjCClass(bool is_complete_objc_class)
bool IsCompleteObjCClass()
Type::Payload m_payload
The payload is used for typedefs and ptrauth types.
TypePayloadClang()=default
void SetOwningModule(OptionalClangModuleID id)
static constexpr unsigned ObjCClassBit
llvm::ArrayRef< clang::TemplateArgument > GetParameterPackArgs() const
clang::TemplateArgument const & Front() const
llvm::StringRef GetPackName() const
bool hasParameterPack() const
TemplateParameterInfos const & GetParameterPack() const
llvm::ArrayRef< const char * > GetNames() const
llvm::ArrayRef< clang::TemplateArgument > GetArgs() const
A TypeSystem implementation based on Clang.
bool IsMemberFunctionPointerType(lldb::opaque_compiler_type_t type) override
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
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
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
llvm::Expected< CompilerType > DoIntegralPromotion(CompilerType from, ExecutionContextScope *exe_scope) override
Perform integral promotion on a given type.
static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc)
bool IsTypedefType(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override
std::optional< size_t > GetTypeBitAlign(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< clang::Builtin::Context > m_builtins_up
CompilerType GetBuiltinTypeByName(ConstString name) override
bool GetCompleteDecl(clang::Decl *decl)
static bool StartTagDeclarationDefinition(const CompilerType &type)
uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl, bool omit_empty_base_classes)
bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, CompilerType *target_type, bool check_cplusplus, bool check_objc) override
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
Checks if the type is eligible for integral promotion.
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override
static LanguageSet GetSupportedLanguagesForTypes()
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
ConstString DeclContextGetName(void *opaque_decl_ctx) override
size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack) override
ConstString DeclGetName(void *opaque_decl) override
virtual SymbolFile * GetSymbolFile() const
bool m_has_forcefully_completed_types
Used for reporting statistics.
Encapsulates a one-time expression for use in lldb.
virtual uint64_t GetData(DataExtractor &data, Status &error)
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.