11#include "clang/AST/DeclBase.h"
12#include "clang/AST/ExprCXX.h"
13#include "clang/Frontend/ASTConsumers.h"
14#include "llvm/ADT/ScopeExit.h"
15#include "llvm/Support/Casting.h"
16#include "llvm/Support/FormatAdapters.h"
17#include "llvm/Support/FormatVariadic.h"
24#include "clang/AST/ASTContext.h"
25#include "clang/AST/ASTImporter.h"
26#include "clang/AST/Attr.h"
27#include "clang/AST/CXXInheritance.h"
28#include "clang/AST/DeclObjC.h"
29#include "clang/AST/DeclTemplate.h"
30#include "clang/AST/Mangle.h"
31#include "clang/AST/QualTypeNames.h"
32#include "clang/AST/RecordLayout.h"
33#include "clang/AST/Type.h"
34#include "clang/AST/VTableBuilder.h"
35#include "clang/Basic/Builtins.h"
36#include "clang/Basic/Diagnostic.h"
37#include "clang/Basic/FileManager.h"
38#include "clang/Basic/FileSystemOptions.h"
39#include "clang/Basic/LangStandard.h"
40#include "clang/Basic/SourceManager.h"
41#include "clang/Basic/TargetInfo.h"
42#include "clang/Basic/TargetOptions.h"
43#include "clang/Frontend/FrontendOptions.h"
44#include "clang/Lex/HeaderSearch.h"
45#include "clang/Lex/HeaderSearchOptions.h"
46#include "clang/Lex/ModuleMap.h"
47#include "clang/Sema/Sema.h"
49#include "llvm/Support/Signals.h"
50#include "llvm/Support/Threading.h"
94using namespace llvm::dwarf;
96using llvm::StringSwitch;
101static void VerifyDecl(clang::Decl *decl) {
102 assert(decl &&
"VerifyDecl called with nullptr?");
128bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) {
130 lldbassert(&m1->getASTContext() == &m2->getASTContext() &&
131 "Methods should have the same AST context");
132 clang::ASTContext &context = m1->getASTContext();
134 const auto *m1Type = llvm::cast<clang::FunctionProtoType>(
135 context.getCanonicalType(m1->getType()));
137 const auto *m2Type = llvm::cast<clang::FunctionProtoType>(
138 context.getCanonicalType(m2->getType()));
140 auto compareArgTypes = [&context](
const clang::QualType &m1p,
141 const clang::QualType &m2p) {
142 return context.hasSameType(m1p.getUnqualifiedType(),
143 m2p.getUnqualifiedType());
148 return (m1->getNumParams() != m2->getNumParams()) ||
149 !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(),
150 m2Type->param_type_begin(), compareArgTypes);
156void addOverridesForMethod(clang::CXXMethodDecl *decl) {
157 if (!decl->isVirtual())
160 clang::CXXBasePaths paths;
161 llvm::SmallVector<clang::NamedDecl *, 4> decls;
163 auto find_overridden_methods =
164 [&decls, decl](
const clang::CXXBaseSpecifier *specifier,
165 clang::CXXBasePath &path) {
166 if (
auto *base_record = specifier->getType()->getAsCXXRecordDecl()) {
168 clang::DeclarationName name = decl->getDeclName();
172 if (name.getNameKind() == clang::DeclarationName::CXXDestructorName)
173 if (
auto *baseDtorDecl = base_record->getDestructor()) {
174 if (baseDtorDecl->isVirtual()) {
175 decls.push_back(baseDtorDecl);
182 for (path.Decls = base_record->lookup(name).begin();
183 path.Decls != path.Decls.end(); ++path.Decls) {
184 if (
auto *method_decl =
185 llvm::dyn_cast<clang::CXXMethodDecl>(*path.Decls))
186 if (method_decl->isVirtual() && !isOverload(decl, method_decl)) {
187 decls.push_back(method_decl);
196 if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) {
197 for (
auto *overridden_decl : decls)
198 decl->addOverriddenMethod(
199 llvm::cast<clang::CXXMethodDecl>(overridden_decl));
205 VTableContextBase &vtable_ctx,
207 const ASTRecordLayout &record_layout) {
211 uint32_t type_info = this_type.
GetTypeInfo(&pointee_type);
216 bool ptr_or_ref =
false;
217 if (type_info & (eTypeIsPointer | eTypeIsReference)) {
223 const uint32_t cpp_class = eTypeIsClass | eTypeIsCPlusPlus;
224 if ((type_info & cpp_class) != cpp_class)
229 vtable_ctx.isMicrosoft() ? record_layout.getVBPtrOffset().getQuantity()
243 vbtable_ptr_addr += vbtable_ptr_offset;
254 auto size = valobj.
GetData(data, err);
262 VTableContextBase &vtable_ctx,
264 const CXXRecordDecl *cxx_record_decl,
265 const CXXRecordDecl *base_class_decl) {
266 if (vtable_ctx.isMicrosoft()) {
267 clang::MicrosoftVTableContext &msoft_vtable_ctx =
268 static_cast<clang::MicrosoftVTableContext &
>(vtable_ctx);
272 const unsigned vbtable_index =
273 msoft_vtable_ctx.getVBTableIndex(cxx_record_decl, base_class_decl);
274 const lldb::addr_t base_offset_addr = vtable_ptr + vbtable_index * 4;
280 clang::ItaniumVTableContext &itanium_vtable_ctx =
281 static_cast<clang::ItaniumVTableContext &
>(vtable_ctx);
283 clang::CharUnits base_offset_offset =
284 itanium_vtable_ctx.getVirtualBaseOffsetOffset(cxx_record_decl,
287 vtable_ptr + base_offset_offset.getQuantity();
296 const ASTRecordLayout &record_layout,
297 const CXXRecordDecl *cxx_record_decl,
298 const CXXRecordDecl *base_class_decl,
299 int32_t &bit_offset) {
311 *process, vtable_ctx, vtable_ptr, cxx_record_decl, base_class_decl);
312 if (base_offset == INT64_MAX)
315 bit_offset = base_offset * 8;
325 static llvm::once_flag g_once_flag;
326 llvm::call_once(g_once_flag, []() {
333 bool is_complete_objc_class)
346 const clang::Decl *parent) {
347 if (!member || !parent)
354 member->setFromASTFile();
355 member->setOwningModuleID(
id.GetValue());
356 member->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
357 if (llvm::isa<clang::NamedDecl>(member))
358 if (
auto *dc = llvm::dyn_cast<clang::DeclContext>(parent)) {
359 dc->setHasExternalVisibleStorage(
true);
362 dc->setHasExternalLexicalStorage(
true);
369 clang::OverloadedOperatorKind &op_kind) {
371 if (!name.consume_front(
"operator"))
376 bool space_after_operator = name.consume_front(
" ");
378 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
379 .Case(
"+", clang::OO_Plus)
380 .Case(
"+=", clang::OO_PlusEqual)
381 .Case(
"++", clang::OO_PlusPlus)
382 .Case(
"-", clang::OO_Minus)
383 .Case(
"-=", clang::OO_MinusEqual)
384 .Case(
"--", clang::OO_MinusMinus)
385 .Case(
"->", clang::OO_Arrow)
386 .Case(
"->*", clang::OO_ArrowStar)
387 .Case(
"*", clang::OO_Star)
388 .Case(
"*=", clang::OO_StarEqual)
389 .Case(
"/", clang::OO_Slash)
390 .Case(
"/=", clang::OO_SlashEqual)
391 .Case(
"%", clang::OO_Percent)
392 .Case(
"%=", clang::OO_PercentEqual)
393 .Case(
"^", clang::OO_Caret)
394 .Case(
"^=", clang::OO_CaretEqual)
395 .Case(
"&", clang::OO_Amp)
396 .Case(
"&=", clang::OO_AmpEqual)
397 .Case(
"&&", clang::OO_AmpAmp)
398 .Case(
"|", clang::OO_Pipe)
399 .Case(
"|=", clang::OO_PipeEqual)
400 .Case(
"||", clang::OO_PipePipe)
401 .Case(
"~", clang::OO_Tilde)
402 .Case(
"!", clang::OO_Exclaim)
403 .Case(
"!=", clang::OO_ExclaimEqual)
404 .Case(
"=", clang::OO_Equal)
405 .Case(
"==", clang::OO_EqualEqual)
406 .Case(
"<", clang::OO_Less)
407 .Case(
"<=>", clang::OO_Spaceship)
408 .Case(
"<<", clang::OO_LessLess)
409 .Case(
"<<=", clang::OO_LessLessEqual)
410 .Case(
"<=", clang::OO_LessEqual)
411 .Case(
">", clang::OO_Greater)
412 .Case(
">>", clang::OO_GreaterGreater)
413 .Case(
">>=", clang::OO_GreaterGreaterEqual)
414 .Case(
">=", clang::OO_GreaterEqual)
415 .Case(
"()", clang::OO_Call)
416 .Case(
"[]", clang::OO_Subscript)
417 .Case(
",", clang::OO_Comma)
418 .Default(clang::NUM_OVERLOADED_OPERATORS);
421 if (op_kind != clang::NUM_OVERLOADED_OPERATORS)
433 if (!space_after_operator)
438 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
439 .Case(
"new", clang::OO_New)
440 .Case(
"new[]", clang::OO_Array_New)
441 .Case(
"delete", clang::OO_Delete)
442 .Case(
"delete[]", clang::OO_Array_Delete)
444 .Default(clang::NUM_OVERLOADED_OPERATORS);
449clang::AccessSpecifier
469 std::vector<std::string> Includes;
470 LangOptions::setLangDefaults(Opts, clang::Language::ObjCXX, arch.
GetTriple(),
471 Includes, clang::LangStandard::lang_gnucxx98);
473 Opts.setValueVisibilityMode(DefaultVisibility);
477 Opts.Trigraphs = !Opts.GNUMode;
482 Opts.ModulesLocalVisibility = 1;
486 llvm::Triple target_triple) {
488 if (!target_triple.str().empty())
498 ASTContext &existing_ctxt) {
514 if (!TypeSystemClangSupportsLanguage(language))
518 arch =
module->GetArchitecture();
528 if (triple.getVendor() == llvm::Triple::Apple &&
529 triple.getOS() == llvm::Triple::UnknownOS) {
530 if (triple.getArch() == llvm::Triple::arm ||
531 triple.getArch() == llvm::Triple::aarch64 ||
532 triple.getArch() == llvm::Triple::aarch64_32 ||
533 triple.getArch() == llvm::Triple::thumb) {
534 triple.setOS(llvm::Triple::IOS);
536 triple.setOS(llvm::Triple::MacOSX);
541 std::string ast_name =
542 "ASTContext for '" +
module->GetFileSpec().GetPath() + "'";
543 return std::make_shared<TypeSystemClang>(ast_name, triple);
544 }
else if (target && target->
IsValid())
545 return std::make_shared<ScratchTypeSystemClang>(*target, triple);
607 assert(s ==
nullptr || &s->getASTContext() ==
m_ast_up.get());
620 llvm::IntrusiveRefCntPtr<ExternalASTSource> ast_source_sp) {
622 ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(
true);
623 ast.setExternalSource(std::move(ast_source_sp));
636 const clang::Diagnostic &info)
override {
638 llvm::SmallVector<char, 32> diag_str(10);
639 info.FormatDiagnostic(diag_str);
640 diag_str.push_back(
'\0');
645 DiagnosticConsumer *
clone(DiagnosticsEngine &Diags)
const {
666 clang::FileSystemOptions file_system_options;
676 m_ast_up = std::make_unique<ASTContext>(
688 m_ast_up->InitBuiltinTypes(*target_info);
692 "Failed to initialize builtin ASTContext types for target '{0}'. "
693 "Printing variables may behave unexpectedly.",
699 static std::once_flag s_uninitialized_target_warning;
701 &s_uninitialized_target_warning);
707 llvm::makeIntrusiveRefCnt<ClangExternalASTSourceCallbacks>(*
this);
739#pragma mark Basic Types
742 ASTContext &ast, QualType qual_type) {
743 uint64_t qual_type_bit_size = ast.getTypeSize(qual_type);
744 return qual_type_bit_size == bit_size;
763 return GetType(ast.UnsignedCharTy);
765 return GetType(ast.UnsignedShortTy);
767 return GetType(ast.UnsignedIntTy);
769 return GetType(ast.UnsignedLongTy);
771 return GetType(ast.UnsignedLongLongTy);
773 return GetType(ast.UnsignedInt128Ty);
778 return GetType(ast.SignedCharTy);
786 return GetType(ast.LongLongTy);
797 return GetType(ast.LongDoubleTy);
801 return GetType(ast.Float128Ty);
806 if (bit_size && !(bit_size & 0x7u))
807 return GetType(ast.getExtVectorType(ast.UnsignedCharTy, bit_size / 8));
815 static const llvm::StringMap<lldb::BasicType> g_type_map = {
880 auto iter = g_type_map.find(name);
881 if (iter == g_type_map.end())
908 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
927 return GetType(ast.UnsignedCharTy);
929 return GetType(ast.UnsignedShortTy);
931 return GetType(ast.UnsignedIntTy);
936 if (type_name.contains(
"complex")) {
945 case DW_ATE_complex_float: {
946 CanQualType FloatComplexTy = ast.getComplexType(ast.FloatTy);
948 return GetType(FloatComplexTy);
950 CanQualType DoubleComplexTy = ast.getComplexType(ast.DoubleTy);
952 return GetType(DoubleComplexTy);
954 CanQualType LongDoubleComplexTy = ast.getComplexType(ast.LongDoubleTy);
956 return GetType(LongDoubleComplexTy);
966 if (type_name ==
"float" &&
969 if (type_name ==
"double" &&
972 if (type_name ==
"long double" &&
974 return GetType(ast.LongDoubleTy);
975 if (type_name ==
"__bf16" &&
977 return GetType(ast.BFloat16Ty);
978 if (type_name ==
"_Float16" &&
984 if ((type_name ==
"__float128" || type_name ==
"_Float128" ||
985 type_name ==
"f128") &&
987 return GetType(ast.Float128Ty);
994 return GetType(ast.LongDoubleTy);
998 return GetType(ast.Float128Ty);
1002 if (!type_name.empty()) {
1003 if (type_name.starts_with(
"_BitInt"))
1004 return GetType(ast.getBitIntType(
false, bit_size));
1005 if (type_name ==
"wchar_t" &&
1010 if (type_name ==
"void" &&
1013 if (type_name.contains(
"long long") &&
1015 return GetType(ast.LongLongTy);
1016 if (type_name.contains(
"long") &&
1019 if (type_name.contains(
"short") &&
1022 if (type_name.contains(
"char")) {
1026 return GetType(ast.SignedCharTy);
1028 if (type_name.contains(
"int")) {
1045 return GetType(ast.LongLongTy);
1050 case DW_ATE_signed_char:
1051 if (type_name ==
"char") {
1056 return GetType(ast.SignedCharTy);
1059 case DW_ATE_unsigned:
1060 if (!type_name.empty()) {
1061 if (type_name.starts_with(
"unsigned _BitInt"))
1062 return GetType(ast.getBitIntType(
true, bit_size));
1063 if (type_name ==
"wchar_t") {
1070 if (type_name.contains(
"long long")) {
1072 return GetType(ast.UnsignedLongLongTy);
1073 }
else if (type_name.contains(
"long")) {
1075 return GetType(ast.UnsignedLongTy);
1076 }
else if (type_name.contains(
"short")) {
1078 return GetType(ast.UnsignedShortTy);
1079 }
else if (type_name.contains(
"char")) {
1081 return GetType(ast.UnsignedCharTy);
1082 }
else if (type_name.contains(
"int")) {
1084 return GetType(ast.UnsignedIntTy);
1086 return GetType(ast.UnsignedInt128Ty);
1091 return GetType(ast.UnsignedCharTy);
1093 return GetType(ast.UnsignedShortTy);
1095 return GetType(ast.UnsignedIntTy);
1097 return GetType(ast.UnsignedLongTy);
1099 return GetType(ast.UnsignedLongLongTy);
1101 return GetType(ast.UnsignedInt128Ty);
1104 case DW_ATE_unsigned_char:
1105 if (type_name ==
"char") {
1110 return GetType(ast.UnsignedCharTy);
1112 return GetType(ast.UnsignedShortTy);
1115 case DW_ATE_imaginary_float:
1127 if (!type_name.empty()) {
1128 if (type_name ==
"char16_t")
1130 if (type_name ==
"char32_t")
1132 if (type_name ==
"char8_t")
1141 "error: need to add support for DW_TAG_base_type '{0}' "
1142 "encoded with DW_ATE = {1:x}, bit_size = {2}",
1143 type_name, dw_ate, bit_size);
1149 QualType char_type(ast.CharTy);
1152 char_type.addConst();
1154 return GetType(ast.getPointerType(char_type));
1158 bool ignore_qualifiers) {
1169 if (ignore_qualifiers) {
1170 type1_qual = type1_qual.getUnqualifiedType();
1171 type2_qual = type2_qual.getUnqualifiedType();
1174 return ast->getASTContext().hasSameType(type1_qual, type2_qual);
1181 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
1182 if (
auto *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl))
1194 if (clang::ObjCInterfaceDecl *interface_decl =
1195 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
1197 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
1199 if (clang::ValueDecl *value_decl = llvm::dyn_cast<clang::ValueDecl>(decl))
1213 return GetType(value_decl->getType());
1216#pragma mark Structure, Unions, Classes
1220 if (!decl || !owning_module.
HasValue())
1223 decl->setFromASTFile();
1224 decl->setOwningModuleID(owning_module.
GetValue());
1225 decl->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
1231 bool is_framework,
bool is_explicit) {
1233 auto *ast_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1235 assert(ast_source &&
"external ast source was lost");
1253 clang::Module *module;
1254 auto parent_desc = ast_source->getSourceDescriptor(parent.
GetValue());
1256 name, parent_desc ? parent_desc->getModuleOrNull() :
nullptr,
1257 is_framework, is_explicit);
1259 return ast_source->GetIDForModule(module);
1261 return ast_source->RegisterModule(module);
1266 AccessType access_type, llvm::StringRef name,
int kind,
1267 LanguageType language, std::optional<ClangASTMetadata> metadata,
1268 bool exports_symbols) {
1271 if (decl_ctx ==
nullptr)
1272 decl_ctx = ast.getTranslationUnitDecl();
1276 bool isInternal =
false;
1277 return CreateObjCClass(name, decl_ctx, owning_module, isInternal, metadata);
1286 bool has_name = !name.empty();
1287 CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1288 decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1289 decl->setDeclContext(decl_ctx);
1291 decl->setDeclName(&ast.Idents.get(name));
1319 if (isa<CXXRecordDecl>(decl_ctx) && exports_symbols)
1320 decl->setAnonymousStructOrUnion(
true);
1330 decl_ctx->addDecl(decl);
1332 return GetType(ast.getCanonicalTagType(decl));
1339QualType GetValueParamType(
const clang::TemplateArgument &argument) {
1340 switch (argument.getKind()) {
1341 case TemplateArgument::Integral:
1342 return argument.getIntegralType();
1343 case TemplateArgument::StructuralValue:
1344 return argument.getStructuralValueType();
1350void AddAccessSpecifierDecl(clang::CXXRecordDecl *cxx_record_decl,
1352 clang::AccessSpecifier previous_access,
1353 clang::AccessSpecifier access_specifier) {
1354 if (!cxx_record_decl->isClass() && !cxx_record_decl->isStruct())
1356 if (previous_access != access_specifier) {
1359 if ((cxx_record_decl->isStruct() &&
1360 previous_access == clang::AccessSpecifier::AS_none &&
1361 access_specifier == clang::AccessSpecifier::AS_public) ||
1362 (cxx_record_decl->isClass() &&
1363 previous_access == clang::AccessSpecifier::AS_none &&
1364 access_specifier == clang::AccessSpecifier::AS_private)) {
1367 cxx_record_decl->addDecl(
1368 AccessSpecDecl::Create(ct, access_specifier, cxx_record_decl,
1369 SourceLocation(), SourceLocation()));
1377 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1378 const bool parameter_pack =
false;
1379 const bool is_typename =
false;
1380 const unsigned depth = 0;
1381 const size_t num_template_params = template_param_infos.
Size();
1382 DeclContext *
const decl_context =
1383 ast.getTranslationUnitDecl();
1385 auto const &args = template_param_infos.
GetArgs();
1386 auto const &names = template_param_infos.
GetNames();
1387 for (
size_t i = 0; i < num_template_params; ++i) {
1388 const char *name = names[i];
1390 IdentifierInfo *identifier_info =
nullptr;
1391 if (name && name[0])
1392 identifier_info = &ast.Idents.get(name);
1393 TemplateArgument
const &targ = args[i];
1394 QualType template_param_type = GetValueParamType(targ);
1395 if (!template_param_type.isNull()) {
1396 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1397 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1398 identifier_info, template_param_type, parameter_pack,
1399 ast.getTrivialTypeSourceInfo(template_param_type)));
1401 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1402 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1403 identifier_info, is_typename, parameter_pack));
1408 IdentifierInfo *identifier_info =
nullptr;
1410 identifier_info = &ast.Idents.get(template_param_infos.
GetPackName());
1411 const bool parameter_pack_true =
true;
1413 QualType template_param_type =
1417 if (!template_param_type.isNull()) {
1418 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1419 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1420 num_template_params, identifier_info, template_param_type,
1421 parameter_pack_true,
1422 ast.getTrivialTypeSourceInfo(template_param_type)));
1424 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1425 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1426 num_template_params, identifier_info, is_typename,
1427 parameter_pack_true));
1430 clang::Expr *
const requires_clause =
nullptr;
1431 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1432 ast, SourceLocation(), SourceLocation(), template_param_decls,
1433 SourceLocation(), requires_clause);
1434 return template_param_list;
1439 clang::FunctionDecl *func_decl,
1444 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1446 ast, template_param_infos, template_param_decls);
1447 FunctionTemplateDecl *func_tmpl_decl =
1448 FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1449 func_tmpl_decl->setDeclContext(decl_ctx);
1450 func_tmpl_decl->setLocation(func_decl->getLocation());
1451 func_tmpl_decl->setDeclName(func_decl->getDeclName());
1452 func_tmpl_decl->setTemplateParameters(template_param_list);
1453 func_tmpl_decl->init(func_decl);
1456 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1457 i < template_param_decl_count; ++i) {
1459 template_param_decls[i]->setDeclContext(func_decl);
1464 if (decl_ctx->isRecord())
1465 func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
1467 return func_tmpl_decl;
1471 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1473 TemplateArgumentList *template_args_ptr = TemplateArgumentList::CreateCopy(
1474 func_decl->getASTContext(), infos.
GetArgs());
1476 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
1477 template_args_ptr,
nullptr);
1484 const TemplateArgument &value) {
1485 if (llvm::isa<TemplateTypeParmDecl>(param)) {
1487 if (value.getKind() != TemplateArgument::Type)
1489 }
else if (
auto *type_param =
1490 llvm::dyn_cast<NonTypeTemplateParmDecl>(param)) {
1492 QualType value_param_type = GetValueParamType(value);
1493 if (value_param_type.isNull())
1497 if (type_param->getType() != value_param_type)
1505 "Don't know how to compare template parameter to passed"
1506 " value. Decl kind of parameter is: {0}",
1507 param->getDeclKindName());
1508 lldbassert(
false &&
"Can't compare this TemplateParmDecl subclass");
1523 ClassTemplateDecl *class_template_decl,
1526 TemplateParameterList ¶ms = *class_template_decl->getTemplateParameters();
1532 std::optional<NamedDecl *> pack_parameter;
1534 size_t non_pack_params = params.size();
1535 for (
size_t i = 0; i < params.size(); ++i) {
1536 NamedDecl *param = params.getParam(i);
1537 if (param->isParameterPack()) {
1538 pack_parameter = param;
1539 non_pack_params = i;
1547 if (non_pack_params != instantiation_values.
Size())
1565 for (
const auto pair :
1566 llvm::zip_first(instantiation_values.
GetArgs(), params)) {
1567 const TemplateArgument &passed_arg = std::get<0>(pair);
1568 NamedDecl *found_param = std::get<1>(pair);
1573 return class_template_decl;
1582 ClassTemplateDecl *class_template_decl =
nullptr;
1583 if (decl_ctx ==
nullptr)
1584 decl_ctx = ast.getTranslationUnitDecl();
1586 IdentifierInfo &identifier_info = ast.Idents.get(class_name);
1587 DeclarationName decl_name(&identifier_info);
1590 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1591 for (NamedDecl *decl : result) {
1592 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1593 if (!class_template_decl)
1602 template_param_infos))
1604 return class_template_decl;
1607 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1610 ast, template_param_infos, template_param_decls);
1612 CXXRecordDecl *template_cxx_decl =
1613 CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1614 template_cxx_decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1616 template_cxx_decl->setDeclContext(decl_ctx);
1617 template_cxx_decl->setDeclName(decl_name);
1620 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1621 i < template_param_decl_count; ++i) {
1622 template_param_decls[i]->setDeclContext(template_cxx_decl);
1630 class_template_decl =
1631 ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1633 class_template_decl->setDeclContext(decl_ctx);
1634 class_template_decl->setDeclName(decl_name);
1635 class_template_decl->setTemplateParameters(template_param_list);
1636 class_template_decl->init(template_cxx_decl);
1637 template_cxx_decl->setDescribedClassTemplate(class_template_decl);
1641 class_template_decl->setAccess(
1644 decl_ctx->addDecl(class_template_decl);
1646 VerifyDecl(class_template_decl);
1648 return class_template_decl;
1651TemplateTemplateParmDecl *
1655 auto *decl_ctx = ast.getTranslationUnitDecl();
1657 IdentifierInfo &identifier_info = ast.Idents.get(template_name);
1658 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1662 ast, template_param_infos, template_param_decls);
1668 return TemplateTemplateParmDecl::Create(
1669 ast, decl_ctx, SourceLocation(),
1671 false, &identifier_info,
1672 TemplateNameKind::TNK_Type_template,
true,
1673 template_param_list);
1676ClassTemplateSpecializationDecl *
1679 ClassTemplateDecl *class_template_decl,
int kind,
1682 llvm::SmallVector<clang::TemplateArgument, 2> args(
1683 template_param_infos.
Size() +
1686 auto const &orig_args = template_param_infos.
GetArgs();
1687 std::copy(orig_args.begin(), orig_args.end(), args.begin());
1689 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1692 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1693 ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
1694 class_template_specialization_decl->setTagKind(
1695 static_cast<TagDecl::TagKind
>(kind));
1696 class_template_specialization_decl->setDeclContext(decl_ctx);
1697 class_template_specialization_decl->setInstantiationOf(class_template_decl);
1698 class_template_specialization_decl->setTemplateArgs(
1699 TemplateArgumentList::CreateCopy(ast, args));
1700 void *insert_pos =
nullptr;
1701 if (class_template_decl->findSpecialization(args, insert_pos))
1703 class_template_decl->AddSpecialization(class_template_specialization_decl,
1705 class_template_specialization_decl->setDeclName(
1706 class_template_decl->getDeclName());
1711 class_template_specialization_decl->setStrictPackMatch(
false);
1714 decl_ctx->addDecl(class_template_specialization_decl);
1716 class_template_specialization_decl->setSpecializationKind(
1717 TSK_ExplicitSpecialization);
1719 return class_template_specialization_decl;
1723 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1724 if (class_template_specialization_decl) {
1726 return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
1732 clang::OverloadedOperatorKind op_kind,
1733 bool unary,
bool binary,
1734 uint32_t num_params) {
1736 if (op_kind == OO_Call)
1742 if (num_params == 1)
1744 if (num_params == 2)
1751 bool is_method, clang::OverloadedOperatorKind op_kind,
1752 uint32_t num_params) {
1760 case OO_Array_Delete:
1764#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1766 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1768#include "clang/Basic/OperatorKinds.def"
1775clang::AccessSpecifier
1777 clang::AccessSpecifier rhs) {
1780 if (lhs == AS_none || rhs == AS_none)
1782 if (lhs == AS_private || rhs == AS_private)
1784 if (lhs == AS_protected || rhs == AS_protected)
1785 return AS_protected;
1790 uint32_t &bitfield_bit_size) {
1792 if (field ==
nullptr)
1795 if (field->isBitField()) {
1796 Expr *bit_width_expr = field->getBitWidth();
1797 if (bit_width_expr) {
1798 if (std::optional<llvm::APSInt> bit_width_apsint =
1799 bit_width_expr->getIntegerConstantExpr(ast)) {
1800 bitfield_bit_size = bit_width_apsint->getLimitedValue(
UINT32_MAX);
1809 if (record_decl ==
nullptr)
1812 if (!record_decl->field_empty())
1816 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1817 if (cxx_record_decl) {
1818 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1819 for (base_class = cxx_record_decl->bases_begin(),
1820 base_class_end = cxx_record_decl->bases_end();
1821 base_class != base_class_end; ++base_class) {
1822 assert(record_decl != base_class->getType()->getAsCXXRecordDecl() &&
1823 "Base can't inherit from itself.");
1835 if (std::optional<ClangASTMetadata> meta_data =
GetMetadata(record_decl);
1836 meta_data && meta_data->IsForcefullyCompleted())
1842#pragma mark Objective-C Classes
1845 llvm::StringRef name, clang::DeclContext *decl_ctx,
1847 std::optional<ClangASTMetadata> metadata) {
1849 assert(!name.empty());
1851 decl_ctx = ast.getTranslationUnitDecl();
1853 ObjCInterfaceDecl *decl =
1854 ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
1855 decl->setDeclContext(decl_ctx);
1856 decl->setDeclName(&ast.Idents.get(name));
1857 decl->setImplicit(isInternal);
1863 return GetType(ast.getObjCInterfaceType(decl));
1872 bool omit_empty_base_classes) {
1873 uint32_t num_bases = 0;
1874 if (cxx_record_decl) {
1875 if (omit_empty_base_classes) {
1876 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1877 for (base_class = cxx_record_decl->bases_begin(),
1878 base_class_end = cxx_record_decl->bases_end();
1879 base_class != base_class_end; ++base_class) {
1886 num_bases = cxx_record_decl->getNumBases();
1891#pragma mark Namespace Declarations
1894 const char *name, clang::DeclContext *decl_ctx,
1896 NamespaceDecl *namespace_decl =
nullptr;
1898 TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
1900 decl_ctx = translation_unit_decl;
1903 IdentifierInfo &identifier_info = ast.Idents.get(name);
1904 DeclarationName decl_name(&identifier_info);
1905 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1906 for (NamedDecl *decl : result) {
1907 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1909 return namespace_decl;
1912 namespace_decl = NamespaceDecl::Create(ast, decl_ctx, is_inline,
1913 SourceLocation(), SourceLocation(),
1914 &identifier_info,
nullptr,
false);
1916 decl_ctx->addDecl(namespace_decl);
1918 if (decl_ctx == translation_unit_decl) {
1919 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1921 return namespace_decl;
1924 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1925 SourceLocation(),
nullptr,
nullptr,
false);
1926 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1927 translation_unit_decl->addDecl(namespace_decl);
1928 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace());
1930 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1931 if (parent_namespace_decl) {
1932 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1934 return namespace_decl;
1936 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1937 SourceLocation(),
nullptr,
nullptr,
false);
1938 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1939 parent_namespace_decl->addDecl(namespace_decl);
1940 assert(namespace_decl ==
1941 parent_namespace_decl->getAnonymousNamespace());
1943 assert(
false &&
"GetUniqueNamespaceDeclaration called with no name and "
1944 "no namespace as decl_ctx");
1952 VerifyDecl(namespace_decl);
1953 return namespace_decl;
1960 clang::BlockDecl *decl =
1961 clang::BlockDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1962 decl->setDeclContext(ctx);
1971 clang::DeclContext *right,
1972 clang::DeclContext *root) {
1973 if (root ==
nullptr)
1976 std::set<clang::DeclContext *> path_left;
1977 for (clang::DeclContext *d = left; d !=
nullptr; d = d->getParent())
1978 path_left.insert(d);
1980 for (clang::DeclContext *d = right; d !=
nullptr; d = d->getParent())
1981 if (path_left.find(d) != path_left.end())
1989 clang::NamespaceDecl *ns_decl) {
1990 if (decl_ctx && ns_decl) {
1991 auto *translation_unit =
getASTContext().getTranslationUnitDecl();
1992 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
1994 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
1995 clang::SourceLocation(), ns_decl,
1998 decl_ctx->addDecl(using_decl);
2008 clang::NamedDecl *target) {
2009 if (current_decl_ctx && target) {
2010 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
2012 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(),
false);
2014 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
2016 target->getDeclName(), using_decl, target);
2018 using_decl->addShadowDecl(shadow_decl);
2019 current_decl_ctx->addDecl(using_decl);
2027 const char *name, clang::QualType type) {
2029 clang::VarDecl *var_decl =
2030 clang::VarDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
2031 var_decl->setDeclContext(decl_context);
2032 if (name && name[0])
2033 var_decl->setDeclName(&
getASTContext().Idents.getOwn(name));
2034 var_decl->setType(type);
2036 var_decl->setAccess(clang::AS_public);
2037 decl_context->addDecl(var_decl);
2046 switch (basic_type) {
2048 return ast->VoidTy.getAsOpaquePtr();
2050 return ast->CharTy.getAsOpaquePtr();
2052 return ast->SignedCharTy.getAsOpaquePtr();
2054 return ast->UnsignedCharTy.getAsOpaquePtr();
2056 return ast->getWCharType().getAsOpaquePtr();
2058 return ast->getSignedWCharType().getAsOpaquePtr();
2060 return ast->getUnsignedWCharType().getAsOpaquePtr();
2062 return ast->Char8Ty.getAsOpaquePtr();
2064 return ast->Char16Ty.getAsOpaquePtr();
2066 return ast->Char32Ty.getAsOpaquePtr();
2068 return ast->ShortTy.getAsOpaquePtr();
2070 return ast->UnsignedShortTy.getAsOpaquePtr();
2072 return ast->IntTy.getAsOpaquePtr();
2074 return ast->UnsignedIntTy.getAsOpaquePtr();
2076 return ast->LongTy.getAsOpaquePtr();
2078 return ast->UnsignedLongTy.getAsOpaquePtr();
2080 return ast->LongLongTy.getAsOpaquePtr();
2082 return ast->UnsignedLongLongTy.getAsOpaquePtr();
2084 return ast->Int128Ty.getAsOpaquePtr();
2086 return ast->UnsignedInt128Ty.getAsOpaquePtr();
2088 return ast->BoolTy.getAsOpaquePtr();
2090 return ast->HalfTy.getAsOpaquePtr();
2092 return ast->FloatTy.getAsOpaquePtr();
2094 return ast->DoubleTy.getAsOpaquePtr();
2096 return ast->LongDoubleTy.getAsOpaquePtr();
2098 return ast->Float128Ty.getAsOpaquePtr();
2100 return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
2102 return ast->getComplexType(ast->DoubleTy).getAsOpaquePtr();
2104 return ast->getComplexType(ast->LongDoubleTy).getAsOpaquePtr();
2106 return ast->getObjCIdType().getAsOpaquePtr();
2108 return ast->getObjCClassType().getAsOpaquePtr();
2110 return ast->getObjCSelType().getAsOpaquePtr();
2112 return ast->NullPtrTy.getAsOpaquePtr();
2118#pragma mark Function Types
2120clang::DeclarationName
2123 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2124 if (!
IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2133 const clang::FunctionProtoType *function_type =
2134 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2135 if (function_type ==
nullptr)
2136 return clang::DeclarationName();
2138 const bool is_method =
false;
2139 const unsigned int num_params = function_type->getNumParams();
2141 is_method, op_kind, num_params))
2142 return clang::DeclarationName();
2144 return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
2148 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
2149 printing_policy.SuppressTagKeyword =
true;
2152 printing_policy.SuppressInlineNamespace =
2153 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None);
2154 printing_policy.SuppressUnwrittenScope =
false;
2166 printing_policy.SuppressDefaultTemplateArgs =
false;
2167 return printing_policy;
2174 llvm::raw_string_ostream os(result);
2175 named_decl->getNameForDiagnostic(os, printing_policy, qualified);
2181 llvm::StringRef name,
const CompilerType &function_clang_type,
2182 clang::StorageClass storage,
bool is_inline, llvm::StringRef asm_label) {
2183 FunctionDecl *func_decl =
nullptr;
2186 decl_ctx = ast.getTranslationUnitDecl();
2188 const bool hasWrittenPrototype =
true;
2189 const bool isConstexprSpecified =
false;
2191 clang::DeclarationName declarationName =
2193 func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
2194 func_decl->setDeclContext(decl_ctx);
2195 func_decl->setDeclName(declarationName);
2197 func_decl->setStorageClass(storage);
2198 func_decl->setInlineSpecified(is_inline);
2199 func_decl->setHasWrittenPrototype(hasWrittenPrototype);
2200 func_decl->setConstexprKind(isConstexprSpecified
2201 ? ConstexprSpecKind::Constexpr
2202 : ConstexprSpecKind::Unspecified);
2214 if (!asm_label.empty())
2215 func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label));
2218 decl_ctx->addDecl(func_decl);
2220 VerifyDecl(func_decl);
2226 const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
2227 bool is_variadic,
unsigned type_quals, clang::CallingConv cc,
2228 clang::RefQualifierKind ref_qual) {
2232 std::vector<QualType> qual_type_args;
2234 for (
const auto &arg : args) {
2249 FunctionProtoType::ExtProtoInfo proto_info;
2250 proto_info.ExtInfo = cc;
2251 proto_info.Variadic = is_variadic;
2252 proto_info.ExceptionSpec = EST_None;
2253 proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
2254 proto_info.RefQualifier = ref_qual;
2262 const char *name,
const CompilerType ¶m_type,
int storage,
2265 auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
2266 decl->setDeclContext(decl_ctx);
2267 if (name && name[0])
2268 decl->setDeclName(&ast.Idents.get(name));
2270 decl->setStorageClass(
static_cast<clang::StorageClass
>(storage));
2273 decl_ctx->addDecl(decl);
2280 QualType block_type =
m_ast_up->getBlockPointerType(
2286#pragma mark Array Types
2290 std::optional<size_t> element_count,
2303 clang::ArraySizeModifier::Normal, 0));
2309 llvm::APInt ap_element_count(64, *element_count);
2311 ap_element_count,
nullptr,
2312 clang::ArraySizeModifier::Normal, 0));
2316 llvm::StringRef type_name,
2317 const std::initializer_list<std::pair<const char *, CompilerType>>
2324 lldbassert(0 &&
"Trying to create a type for an existing name");
2332 for (
const auto &field : type_fields)
2342 llvm::StringRef type_name,
2343 const std::initializer_list<std::pair<const char *, CompilerType>>
2355#pragma mark Enumeration Types
2358 llvm::StringRef name, clang::DeclContext *decl_ctx,
2360 const CompilerType &integer_clang_type,
bool is_scoped,
2361 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind) {
2368 EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
2369 enum_decl->setDeclContext(decl_ctx);
2371 enum_decl->setDeclName(&ast.Idents.get(name));
2372 enum_decl->setScoped(is_scoped);
2373 enum_decl->setScopedUsingClassTag(is_scoped);
2374 enum_decl->setFixed(
false);
2377 decl_ctx->addDecl(enum_decl);
2381 clang::EnumExtensibilityAttr::CreateImplicit(ast, *enum_kind));
2386 enum_decl->setAccess(AS_public);
2388 return GetType(ast.getCanonicalTagType(enum_decl));
2399 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
2400 return GetType(ast.SignedCharTy);
2402 if (bit_size == ast.getTypeSize(ast.ShortTy))
2405 if (bit_size == ast.getTypeSize(ast.IntTy))
2408 if (bit_size == ast.getTypeSize(ast.LongTy))
2411 if (bit_size == ast.getTypeSize(ast.LongLongTy))
2412 return GetType(ast.LongLongTy);
2414 if (bit_size == ast.getTypeSize(ast.Int128Ty))
2417 if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
2418 return GetType(ast.UnsignedCharTy);
2420 if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
2421 return GetType(ast.UnsignedShortTy);
2423 if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
2424 return GetType(ast.UnsignedIntTy);
2426 if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
2427 return GetType(ast.UnsignedLongTy);
2429 if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
2430 return GetType(ast.UnsignedLongLongTy);
2432 if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
2433 return GetType(ast.UnsignedInt128Ty);
2450 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2452 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2453 named_decl->getDeclName().getAsString().c_str());
2455 printf(
"%20s\n", decl_ctx->getDeclKindName());
2461 if (decl ==
nullptr)
2465 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2467 bool is_injected_class_name =
2468 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2469 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2470 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2471 record_decl->getDeclName().getAsString().c_str(),
2472 is_injected_class_name ?
" (injected class name)" :
"");
2475 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2477 printf(
"%20s: %s\n", decl->getDeclKindName(),
2478 named_decl->getDeclName().getAsString().c_str());
2480 printf(
"%20s\n", decl->getDeclKindName());
2486 clang::Decl *decl) {
2490 ExternalASTSource *ast_source = ast->getExternalSource();
2495 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2496 if (tag_decl->isCompleteDefinition())
2499 if (!tag_decl->hasExternalLexicalStorage())
2502 ast_source->CompleteType(tag_decl);
2504 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2505 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2506 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2507 if (objc_interface_decl->getDefinition())
2510 if (!objc_interface_decl->hasExternalLexicalStorage())
2513 ast_source->CompleteType(objc_interface_decl);
2515 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2545std::optional<ClangASTMetadata>
2551 return std::nullopt;
2554std::optional<ClangASTMetadata>
2560 return std::nullopt;
2564 clang::AccessSpecifier access) {
2565 if (access == clang::AccessSpecifier::AS_none)
2571clang::AccessSpecifier
2576 return clang::AccessSpecifier::AS_none;
2598 if (find(mask, type->getTypeClass()) != mask.end())
2600 switch (type->getTypeClass()) {
2603 case clang::Type::Atomic:
2604 type = cast<clang::AtomicType>(type)->getValueType();
2606 case clang::Type::Auto:
2607 case clang::Type::Decltype:
2608 case clang::Type::Paren:
2609 case clang::Type::SubstTemplateTypeParm:
2610 case clang::Type::TemplateSpecialization:
2611 case clang::Type::Typedef:
2612 case clang::Type::TypeOf:
2613 case clang::Type::TypeOfExpr:
2614 case clang::Type::Using:
2615 case clang::Type::PredefinedSugar:
2616 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2630 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2631 switch (type_class) {
2632 case clang::Type::ObjCInterface:
2633 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2635 case clang::Type::ObjCObjectPointer:
2637 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2638 ->getPointeeType());
2639 case clang::Type::Enum:
2640 case clang::Type::Record:
2641 return llvm::cast<clang::TagType>(qual_type)
2643 ->getDefinitionOrSelf();
2656 clang::QualType qual_type,
2657 bool allow_completion) {
2658 assert(qual_type->isRecordType());
2660 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2662 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2666 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2669 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2670 const bool fields_loaded =
2671 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2674 if (is_complete && fields_loaded)
2677 if (!allow_completion)
2685 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2686 if (external_ast_source) {
2687 external_ast_source->CompleteType(cxx_record_decl);
2688 if (cxx_record_decl->isCompleteDefinition()) {
2689 cxx_record_decl->field_begin();
2690 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
2702 clang::QualType qual_type,
2703 bool allow_completion) {
2704 assert(qual_type->isEnumeralType());
2707 const clang::EnumType *enum_type =
2708 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2710 auto *tag_decl = enum_type->getAsTagDecl();
2714 if (tag_decl->getDefinition())
2717 if (!allow_completion)
2721 if (!tag_decl->hasExternalLexicalStorage())
2725 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2726 if (!external_ast_source)
2729 external_ast_source->CompleteType(tag_decl);
2737static const clang::ObjCObjectType *
2739 bool allow_completion) {
2740 assert(qual_type->isObjCObjectType());
2743 const clang::ObjCObjectType *objc_class_type =
2744 llvm::cast<clang::ObjCObjectType>(qual_type);
2746 clang::ObjCInterfaceDecl *class_interface_decl =
2747 objc_class_type->getInterface();
2750 if (!class_interface_decl)
2751 return objc_class_type;
2754 if (class_interface_decl->getDefinition())
2755 return objc_class_type;
2757 if (!allow_completion)
2761 if (!class_interface_decl->hasExternalLexicalStorage())
2765 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2766 if (!external_ast_source)
2769 external_ast_source->CompleteType(class_interface_decl);
2770 return objc_class_type;
2774 clang::QualType qual_type,
2775 bool allow_completion =
true) {
2777 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2778 switch (type_class) {
2779 case clang::Type::ConstantArray:
2780 case clang::Type::IncompleteArray:
2781 case clang::Type::VariableArray: {
2782 const clang::ArrayType *array_type =
2783 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2789 case clang::Type::Record: {
2790 if (
const auto *RT =
2792 return !RT->isIncompleteType();
2797 case clang::Type::Enum: {
2799 return !ET->isIncompleteType();
2803 case clang::Type::ObjCObject:
2804 case clang::Type::ObjCInterface: {
2805 if (
const auto *OT =
2807 return !OT->isIncompleteType();
2812 case clang::Type::Attributed:
2814 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType(),
2817 case clang::Type::MemberPointer:
2820 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2821 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2822 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2826 return !qual_type.getTypePtr()->isIncompleteType();
2837static clang::ObjCIvarDecl::AccessControl
2841 return clang::ObjCIvarDecl::None;
2843 return clang::ObjCIvarDecl::Public;
2845 return clang::ObjCIvarDecl::Private;
2847 return clang::ObjCIvarDecl::Protected;
2849 return clang::ObjCIvarDecl::Package;
2851 return clang::ObjCIvarDecl::None;
2858 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2865 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2866 switch (type_class) {
2867 case clang::Type::IncompleteArray:
2868 case clang::Type::VariableArray:
2869 case clang::Type::ConstantArray:
2870 case clang::Type::ExtVector:
2871 case clang::Type::Vector:
2872 case clang::Type::Record:
2873 case clang::Type::ObjCObject:
2874 case clang::Type::ObjCInterface:
2886 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2887 switch (type_class) {
2888 case clang::Type::Record: {
2889 if (
const clang::RecordType *record_type =
2890 llvm::dyn_cast_or_null<clang::RecordType>(
2891 qual_type.getTypePtrOrNull())) {
2892 if (
const clang::RecordDecl *record_decl = record_type->getDecl()) {
2893 return record_decl->isAnonymousStructOrUnion();
2907 uint64_t *size,
bool *is_incomplete) {
2910 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2911 switch (type_class) {
2915 case clang::Type::ConstantArray:
2916 if (element_type_ptr)
2918 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2922 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2924 .getLimitedValue(ULLONG_MAX);
2926 *is_incomplete =
false;
2929 case clang::Type::IncompleteArray:
2930 if (element_type_ptr)
2932 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2938 *is_incomplete =
true;
2941 case clang::Type::VariableArray:
2942 if (element_type_ptr)
2944 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2950 *is_incomplete =
false;
2953 case clang::Type::DependentSizedArray:
2954 if (element_type_ptr)
2957 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2963 *is_incomplete =
false;
2966 if (element_type_ptr)
2967 element_type_ptr->
Clear();
2971 *is_incomplete =
false;
2979 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2980 switch (type_class) {
2981 case clang::Type::Vector: {
2982 const clang::VectorType *vector_type =
2983 qual_type->getAs<clang::VectorType>();
2986 *size = vector_type->getNumElements();
2988 *element_type =
GetType(vector_type->getElementType());
2992 case clang::Type::ExtVector: {
2993 const clang::ExtVectorType *ext_vector_type =
2994 qual_type->getAs<clang::ExtVectorType>();
2995 if (ext_vector_type) {
2997 *size = ext_vector_type->getNumElements();
3001 ext_vector_type->getElementType().getAsOpaquePtr());
3017 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
3020 clang::ObjCInterfaceDecl *result_iface_decl =
3021 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
3023 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
3027 return (ast_metadata->GetISAPtr() != 0);
3031 return GetQualType(type).getUnqualifiedType()->isCharType();
3040 const bool allow_completion =
true;
3055 if (!pointee_or_element_clang_type.
IsValid())
3058 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
3059 if (pointee_or_element_clang_type.
IsCharType()) {
3060 if (type_flags.
Test(eTypeIsArray)) {
3063 length = llvm::cast<clang::ConstantArrayType>(
3077 if (
auto pointer_auth = qual_type.getPointerAuth())
3078 return pointer_auth.getKey();
3087 if (
auto pointer_auth = qual_type.getPointerAuth())
3088 return pointer_auth.getExtraDiscriminator();
3097 if (
auto pointer_auth = qual_type.getPointerAuth())
3098 return pointer_auth.isAddressDiscriminated();
3104 auto isFunctionType = [&](clang::QualType qual_type) {
3105 return qual_type->isFunctionType();
3119 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3120 switch (type_class) {
3121 case clang::Type::Record:
3123 const clang::CXXRecordDecl *cxx_record_decl =
3124 qual_type->getAsCXXRecordDecl();
3125 if (cxx_record_decl) {
3126 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3129 const clang::RecordType *record_type =
3130 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3132 if (
const clang::RecordDecl *record_decl =
3133 record_type->getDecl()->getDefinition()) {
3136 clang::RecordDecl::field_iterator field_pos,
3137 field_end = record_decl->field_end();
3138 uint32_t num_fields = 0;
3139 bool is_hva =
false;
3140 bool is_hfa =
false;
3141 clang::QualType base_qual_type;
3142 uint64_t base_bitwidth = 0;
3143 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3145 clang::QualType field_qual_type = field_pos->getType();
3146 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3147 if (field_qual_type->isFloatingType()) {
3148 if (field_qual_type->isComplexType())
3151 if (num_fields == 0)
3152 base_qual_type = field_qual_type;
3157 if (field_qual_type.getTypePtr() !=
3158 base_qual_type.getTypePtr())
3162 }
else if (field_qual_type->isVectorType() ||
3163 field_qual_type->isExtVectorType()) {
3164 if (num_fields == 0) {
3165 base_qual_type = field_qual_type;
3166 base_bitwidth = field_bitwidth;
3171 if (base_bitwidth != field_bitwidth)
3173 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3182 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3199 const clang::FunctionProtoType *func =
3200 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3202 return func->getNumParams();
3209 const size_t index) {
3212 const clang::FunctionProtoType *func =
3213 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3215 if (index < func->getNumParams())
3216 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3224 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3228 if (predicate(qual_type))
3231 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3232 switch (type_class) {
3236 case clang::Type::LValueReference:
3237 case clang::Type::RValueReference: {
3238 const clang::ReferenceType *reference_type =
3239 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3241 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3250 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3251 return qual_type->isMemberFunctionPointerType();
3254 return IsTypeImpl(type, isMemberFunctionPointerType);
3258 auto isFunctionPointerType = [](clang::QualType qual_type) {
3259 return qual_type->isFunctionPointerType();
3262 return IsTypeImpl(type, isFunctionPointerType);
3268 auto isBlockPointerType = [&](clang::QualType qual_type) {
3269 if (qual_type->isBlockPointerType()) {
3270 if (function_pointer_type_ptr) {
3271 const clang::BlockPointerType *block_pointer_type =
3272 qual_type->castAs<clang::BlockPointerType>();
3273 QualType pointee_type = block_pointer_type->getPointeeType();
3274 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3276 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3293 const clang::BuiltinType *builtin_type =
3294 llvm::dyn_cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3297 if (builtin_type->isInteger()) {
3298 is_signed = builtin_type->isSignedInteger();
3309 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3314 ->getDefinitionOrSelf()
3328 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3332 return enum_type->isScopedEnumeralType();
3343 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3344 switch (type_class) {
3345 case clang::Type::Builtin:
3346 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3349 case clang::BuiltinType::ObjCId:
3350 case clang::BuiltinType::ObjCClass:
3354 case clang::Type::ObjCObjectPointer:
3358 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3362 case clang::Type::BlockPointer:
3365 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3369 case clang::Type::Pointer:
3372 llvm::cast<clang::PointerType>(qual_type)
3376 case clang::Type::MemberPointer:
3379 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3388 pointee_type->
Clear();
3396 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3397 switch (type_class) {
3398 case clang::Type::Builtin:
3399 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3402 case clang::BuiltinType::ObjCId:
3403 case clang::BuiltinType::ObjCClass:
3407 case clang::Type::ObjCObjectPointer:
3411 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3415 case clang::Type::BlockPointer:
3418 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3422 case clang::Type::Pointer:
3425 llvm::cast<clang::PointerType>(qual_type)
3429 case clang::Type::MemberPointer:
3432 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3436 case clang::Type::LValueReference:
3439 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3443 case clang::Type::RValueReference:
3446 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3455 pointee_type->
Clear();
3464 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3466 switch (type_class) {
3467 case clang::Type::LValueReference:
3470 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3476 case clang::Type::RValueReference:
3479 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3491 pointee_type->
Clear();
3500 if (
const clang::BuiltinType *BT = llvm::dyn_cast<clang::BuiltinType>(
3501 qual_type->getCanonicalTypeInternal())) {
3502 clang::BuiltinType::Kind kind = BT->getKind();
3503 if (kind >= clang::BuiltinType::Float &&
3504 kind <= clang::BuiltinType::LongDouble) {
3508 }
else if (
const clang::ComplexType *CT =
3509 llvm::dyn_cast<clang::ComplexType>(
3510 qual_type->getCanonicalTypeInternal())) {
3516 }
else if (
const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(
3517 qual_type->getCanonicalTypeInternal())) {
3534 const clang::TagType *tag_type =
3535 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3537 if (clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinition())
3538 return tag_decl->isCompleteDefinition();
3541 const clang::ObjCObjectType *objc_class_type =
3542 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3543 if (objc_class_type) {
3544 clang::ObjCInterfaceDecl *class_interface_decl =
3545 objc_class_type->getInterface();
3546 if (class_interface_decl)
3547 return class_interface_decl->getDefinition() !=
nullptr;
3558 const clang::ObjCObjectPointerType *obj_pointer_type =
3559 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3561 if (obj_pointer_type)
3562 return obj_pointer_type->isObjCClassType();
3577 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3578 return (type_class == clang::Type::Record);
3585 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3586 return (type_class == clang::Type::Enum);
3592 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3593 switch (type_class) {
3594 case clang::Type::Record:
3596 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3603 return cxx_record_decl->isDynamicClass();
3617 bool check_cplusplus,
3619 if (dynamic_pointee_type)
3620 dynamic_pointee_type->
Clear();
3624 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3625 if (dynamic_pointee_type)
3627 type.getAsOpaquePtr());
3630 clang::QualType pointee_qual_type;
3632 switch (qual_type->getTypeClass()) {
3633 case clang::Type::Builtin:
3634 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3635 clang::BuiltinType::ObjCId) {
3636 set_dynamic_pointee_type(qual_type);
3641 case clang::Type::ObjCObjectPointer:
3644 if (
const auto *objc_pointee_type =
3645 qual_type->getPointeeType().getTypePtrOrNull()) {
3646 if (
const auto *objc_object_type =
3647 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3648 objc_pointee_type)) {
3649 if (objc_object_type->isObjCClass())
3653 set_dynamic_pointee_type(
3654 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3657 case clang::Type::Pointer:
3659 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3662 case clang::Type::LValueReference:
3663 case clang::Type::RValueReference:
3665 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3675 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3676 case clang::Type::Builtin:
3677 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3678 case clang::BuiltinType::UnknownAny:
3679 case clang::BuiltinType::Void:
3680 set_dynamic_pointee_type(pointee_qual_type);
3686 case clang::Type::Record: {
3687 if (!check_cplusplus)
3689 clang::CXXRecordDecl *cxx_record_decl =
3690 pointee_qual_type->getAsCXXRecordDecl();
3691 if (!cxx_record_decl)
3695 if (cxx_record_decl->isCompleteDefinition())
3696 success = cxx_record_decl->isDynamicClass();
3698 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3699 std::optional<bool> is_dynamic =
3700 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3702 success = *is_dynamic;
3704 success = cxx_record_decl->isDynamicClass();
3710 set_dynamic_pointee_type(pointee_qual_type);
3714 case clang::Type::ObjCObject:
3715 case clang::Type::ObjCInterface:
3717 set_dynamic_pointee_type(pointee_qual_type);
3732 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3739 ->getTypeClass() == clang::Type::Typedef;
3749 if (
auto *record_decl =
3751 return record_decl->canPassInRegisters();
3757 return TypeSystemClangSupportsLanguage(language);
3760std::optional<std::string>
3763 return std::nullopt;
3766 if (qual_type.isNull())
3767 return std::nullopt;
3769 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3770 if (!cxx_record_decl)
3771 return std::nullopt;
3773 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3781 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3788 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3790 return tag_type->getDecl()->isEntityBeingDefined();
3801 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3802 if (class_type_ptr) {
3803 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3804 const clang::ObjCObjectPointerType *obj_pointer_type =
3805 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3806 if (obj_pointer_type ==
nullptr)
3807 class_type_ptr->
Clear();
3811 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3818 class_type_ptr->
Clear();
3827 const bool allow_completion =
true;
3847 {clang::Type::Typedef, clang::Type::Atomic});
3850 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3851 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3858 if (
auto *named_decl = qual_type->getAsTagDecl())
3870 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3871 printing_policy.SuppressTagKeyword =
true;
3872 printing_policy.SuppressScope =
false;
3873 printing_policy.SuppressUnwrittenScope =
true;
3874 printing_policy.SuppressInlineNamespace =
3875 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::All);
3876 return ConstString(qual_type.getAsString(printing_policy));
3885 if (pointee_or_element_clang_type)
3886 pointee_or_element_clang_type->
Clear();
3888 clang::QualType qual_type =
3891 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3892 switch (type_class) {
3893 case clang::Type::Attributed:
3894 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3897 pointee_or_element_clang_type);
3898 case clang::Type::BitInt: {
3899 uint32_t type_flags = eTypeIsScalar | eTypeIsInteger | eTypeHasValue;
3900 if (qual_type->isSignedIntegerType())
3901 type_flags |= eTypeIsSigned;
3905 case clang::Type::Builtin: {
3906 const clang::BuiltinType *builtin_type =
3907 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3909 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3910 switch (builtin_type->getKind()) {
3911 case clang::BuiltinType::ObjCId:
3912 case clang::BuiltinType::ObjCClass:
3913 if (pointee_or_element_clang_type)
3917 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3920 case clang::BuiltinType::ObjCSel:
3921 if (pointee_or_element_clang_type)
3924 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3927 case clang::BuiltinType::Bool:
3928 case clang::BuiltinType::Char_U:
3929 case clang::BuiltinType::UChar:
3930 case clang::BuiltinType::WChar_U:
3931 case clang::BuiltinType::Char16:
3932 case clang::BuiltinType::Char32:
3933 case clang::BuiltinType::UShort:
3934 case clang::BuiltinType::UInt:
3935 case clang::BuiltinType::ULong:
3936 case clang::BuiltinType::ULongLong:
3937 case clang::BuiltinType::UInt128:
3938 case clang::BuiltinType::Char_S:
3939 case clang::BuiltinType::SChar:
3940 case clang::BuiltinType::WChar_S:
3941 case clang::BuiltinType::Short:
3942 case clang::BuiltinType::Int:
3943 case clang::BuiltinType::Long:
3944 case clang::BuiltinType::LongLong:
3945 case clang::BuiltinType::Int128:
3946 case clang::BuiltinType::Float:
3947 case clang::BuiltinType::Double:
3948 case clang::BuiltinType::LongDouble:
3949 builtin_type_flags |= eTypeIsScalar;
3950 if (builtin_type->isInteger()) {
3951 builtin_type_flags |= eTypeIsInteger;
3952 if (builtin_type->isSignedInteger())
3953 builtin_type_flags |= eTypeIsSigned;
3954 }
else if (builtin_type->isFloatingPoint())
3955 builtin_type_flags |= eTypeIsFloat;
3960 return builtin_type_flags;
3963 case clang::Type::BlockPointer:
3964 if (pointee_or_element_clang_type)
3966 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3967 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3969 case clang::Type::Complex: {
3970 uint32_t complex_type_flags =
3971 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3972 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3973 qual_type->getCanonicalTypeInternal());
3975 clang::QualType complex_element_type(complex_type->getElementType());
3976 if (complex_element_type->isIntegerType())
3977 complex_type_flags |= eTypeIsInteger;
3978 else if (complex_element_type->isFloatingType())
3979 complex_type_flags |= eTypeIsFloat;
3981 return complex_type_flags;
3984 case clang::Type::ConstantArray:
3985 case clang::Type::DependentSizedArray:
3986 case clang::Type::IncompleteArray:
3987 case clang::Type::VariableArray:
3988 if (pointee_or_element_clang_type)
3990 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
3993 return eTypeHasChildren | eTypeIsArray;
3995 case clang::Type::DependentName:
3997 case clang::Type::DependentSizedExtVector:
3998 return eTypeHasChildren | eTypeIsVector;
4000 case clang::Type::Enum:
4001 if (pointee_or_element_clang_type)
4003 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
4005 ->getDefinitionOrSelf()
4008 return eTypeIsEnumeration | eTypeHasValue;
4010 case clang::Type::FunctionProto:
4011 return eTypeIsFuncPrototype | eTypeHasValue;
4012 case clang::Type::FunctionNoProto:
4013 return eTypeIsFuncPrototype | eTypeHasValue;
4014 case clang::Type::InjectedClassName:
4017 case clang::Type::LValueReference:
4018 case clang::Type::RValueReference:
4019 if (pointee_or_element_clang_type)
4022 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
4025 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
4027 case clang::Type::MemberPointer:
4028 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
4030 case clang::Type::ObjCObjectPointer:
4031 if (pointee_or_element_clang_type)
4033 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4034 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
4037 case clang::Type::ObjCObject:
4038 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4039 case clang::Type::ObjCInterface:
4040 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4042 case clang::Type::Pointer:
4043 if (pointee_or_element_clang_type)
4045 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4046 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
4048 case clang::Type::Record:
4049 if (qual_type->getAsCXXRecordDecl())
4050 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
4052 return eTypeHasChildren | eTypeIsStructUnion;
4054 case clang::Type::SubstTemplateTypeParm:
4055 return eTypeIsTemplate;
4056 case clang::Type::TemplateTypeParm:
4057 return eTypeIsTemplate;
4058 case clang::Type::TemplateSpecialization:
4059 return eTypeIsTemplate;
4061 case clang::Type::Typedef:
4062 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
4064 ->getUnderlyingType())
4066 case clang::Type::UnresolvedUsing:
4069 case clang::Type::ExtVector:
4070 case clang::Type::Vector: {
4071 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
4072 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
4073 qual_type->getCanonicalTypeInternal());
4077 QualType element_type = vector_type->getElementType();
4078 if (element_type.isNull())
4081 if (element_type->isIntegerType())
4082 vector_type_flags |= eTypeIsInteger;
4083 else if (element_type->isFloatingType())
4084 vector_type_flags |= eTypeIsFloat;
4085 return vector_type_flags;
4100 if (qual_type->isAnyPointerType()) {
4101 if (qual_type->isObjCObjectPointerType())
4103 if (qual_type->getPointeeCXXRecordDecl())
4106 clang::QualType pointee_type(qual_type->getPointeeType());
4107 if (pointee_type->getPointeeCXXRecordDecl())
4109 if (pointee_type->isObjCObjectOrInterfaceType())
4111 if (pointee_type->isObjCClassType())
4113 if (pointee_type.getTypePtr() ==
4117 if (qual_type->isObjCObjectOrInterfaceType())
4119 if (qual_type->getAsCXXRecordDecl())
4121 switch (qual_type->getTypeClass()) {
4124 case clang::Type::Builtin:
4125 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4127 case clang::BuiltinType::Void:
4128 case clang::BuiltinType::Bool:
4129 case clang::BuiltinType::Char_U:
4130 case clang::BuiltinType::UChar:
4131 case clang::BuiltinType::WChar_U:
4132 case clang::BuiltinType::Char16:
4133 case clang::BuiltinType::Char32:
4134 case clang::BuiltinType::UShort:
4135 case clang::BuiltinType::UInt:
4136 case clang::BuiltinType::ULong:
4137 case clang::BuiltinType::ULongLong:
4138 case clang::BuiltinType::UInt128:
4139 case clang::BuiltinType::Char_S:
4140 case clang::BuiltinType::SChar:
4141 case clang::BuiltinType::WChar_S:
4142 case clang::BuiltinType::Short:
4143 case clang::BuiltinType::Int:
4144 case clang::BuiltinType::Long:
4145 case clang::BuiltinType::LongLong:
4146 case clang::BuiltinType::Int128:
4147 case clang::BuiltinType::Float:
4148 case clang::BuiltinType::Double:
4149 case clang::BuiltinType::LongDouble:
4152 case clang::BuiltinType::NullPtr:
4155 case clang::BuiltinType::ObjCId:
4156 case clang::BuiltinType::ObjCClass:
4157 case clang::BuiltinType::ObjCSel:
4160 case clang::BuiltinType::Dependent:
4161 case clang::BuiltinType::Overload:
4162 case clang::BuiltinType::BoundMember:
4163 case clang::BuiltinType::UnknownAny:
4167 case clang::Type::Typedef:
4168 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4170 ->getUnderlyingType())
4180 return lldb::eTypeClassInvalid;
4182 clang::QualType qual_type =
4185 switch (qual_type->getTypeClass()) {
4186 case clang::Type::Atomic:
4187 case clang::Type::Auto:
4188 case clang::Type::CountAttributed:
4189 case clang::Type::Decltype:
4190 case clang::Type::Paren:
4191 case clang::Type::TypeOf:
4192 case clang::Type::TypeOfExpr:
4193 case clang::Type::Using:
4194 case clang::Type::PredefinedSugar:
4195 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4196 case clang::Type::UnaryTransform:
4198 case clang::Type::FunctionNoProto:
4199 return lldb::eTypeClassFunction;
4200 case clang::Type::FunctionProto:
4201 return lldb::eTypeClassFunction;
4202 case clang::Type::IncompleteArray:
4203 return lldb::eTypeClassArray;
4204 case clang::Type::VariableArray:
4205 return lldb::eTypeClassArray;
4206 case clang::Type::ConstantArray:
4207 return lldb::eTypeClassArray;
4208 case clang::Type::DependentSizedArray:
4209 return lldb::eTypeClassArray;
4210 case clang::Type::ArrayParameter:
4211 return lldb::eTypeClassArray;
4212 case clang::Type::DependentSizedExtVector:
4213 return lldb::eTypeClassVector;
4214 case clang::Type::DependentVector:
4215 return lldb::eTypeClassVector;
4216 case clang::Type::ExtVector:
4217 return lldb::eTypeClassVector;
4218 case clang::Type::Vector:
4219 return lldb::eTypeClassVector;
4220 case clang::Type::Builtin:
4222 case clang::Type::BitInt:
4223 case clang::Type::DependentBitInt:
4224 return lldb::eTypeClassBuiltin;
4225 case clang::Type::ObjCObjectPointer:
4226 return lldb::eTypeClassObjCObjectPointer;
4227 case clang::Type::BlockPointer:
4228 return lldb::eTypeClassBlockPointer;
4229 case clang::Type::Pointer:
4230 return lldb::eTypeClassPointer;
4231 case clang::Type::LValueReference:
4232 return lldb::eTypeClassReference;
4233 case clang::Type::RValueReference:
4234 return lldb::eTypeClassReference;
4235 case clang::Type::MemberPointer:
4236 return lldb::eTypeClassMemberPointer;
4237 case clang::Type::Complex:
4238 if (qual_type->isComplexType())
4239 return lldb::eTypeClassComplexFloat;
4241 return lldb::eTypeClassComplexInteger;
4242 case clang::Type::ObjCObject:
4243 return lldb::eTypeClassObjCObject;
4244 case clang::Type::ObjCInterface:
4245 return lldb::eTypeClassObjCInterface;
4246 case clang::Type::Record: {
4247 const clang::RecordType *record_type =
4248 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4249 const clang::RecordDecl *record_decl = record_type->getDecl();
4250 if (record_decl->isUnion())
4251 return lldb::eTypeClassUnion;
4252 else if (record_decl->isStruct())
4253 return lldb::eTypeClassStruct;
4255 return lldb::eTypeClassClass;
4257 case clang::Type::Enum:
4258 return lldb::eTypeClassEnumeration;
4259 case clang::Type::Typedef:
4260 return lldb::eTypeClassTypedef;
4261 case clang::Type::UnresolvedUsing:
4264 case clang::Type::Attributed:
4265 case clang::Type::BTFTagAttributed:
4267 case clang::Type::TemplateTypeParm:
4269 case clang::Type::SubstTemplateTypeParm:
4271 case clang::Type::SubstTemplateTypeParmPack:
4273 case clang::Type::InjectedClassName:
4275 case clang::Type::DependentName:
4277 case clang::Type::PackExpansion:
4280 case clang::Type::TemplateSpecialization:
4282 case clang::Type::DeducedTemplateSpecialization:
4284 case clang::Type::Pipe:
4288 case clang::Type::Decayed:
4290 case clang::Type::Adjusted:
4292 case clang::Type::ObjCTypeParam:
4295 case clang::Type::DependentAddressSpace:
4297 case clang::Type::MacroQualified:
4301 case clang::Type::ConstantMatrix:
4302 case clang::Type::DependentSizedMatrix:
4306 case clang::Type::PackIndexing:
4309 case clang::Type::HLSLAttributedResource:
4311 case clang::Type::HLSLInlineSpirv:
4313 case clang::Type::SubstBuiltinTemplatePack:
4317 return lldb::eTypeClassOther;
4322 return GetQualType(type).getQualifiers().getCVRQualifiers();
4334 const clang::Type *array_eletype =
4335 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4340 return GetType(clang::QualType(array_eletype, 0));
4351 return GetType(ast_ctx.getConstantArrayType(
4352 qual_type, llvm::APInt(64, size),
nullptr,
4353 clang::ArraySizeModifier::Normal, 0));
4355 return GetType(ast_ctx.getIncompleteArrayType(
4356 qual_type, clang::ArraySizeModifier::Normal, 0));
4370 clang::QualType qual_type) {
4371 if (qual_type->isPointerType())
4372 qual_type = ast->getPointerType(
4374 else if (
const ConstantArrayType *arr =
4375 ast->getAsConstantArrayType(qual_type)) {
4376 qual_type = ast->getConstantArrayType(
4378 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4379 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4381 qual_type = qual_type.getUnqualifiedType();
4382 qual_type.removeLocalConst();
4383 qual_type.removeLocalRestrict();
4384 qual_type.removeLocalVolatile();
4406 const clang::FunctionProtoType *func =
4409 return func->getNumParams();
4417 const clang::FunctionProtoType *func =
4418 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4420 const uint32_t num_args = func->getNumParams();
4422 return GetType(func->getParamType(idx));
4432 const clang::FunctionProtoType *func =
4433 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4435 return GetType(func->getReturnType());
4442 size_t num_functions = 0;
4445 switch (qual_type->getTypeClass()) {
4446 case clang::Type::Record:
4448 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4449 num_functions = std::distance(cxx_record_decl->method_begin(),
4450 cxx_record_decl->method_end());
4453 case clang::Type::ObjCObjectPointer: {
4454 const clang::ObjCObjectPointerType *objc_class_type =
4455 qual_type->castAs<clang::ObjCObjectPointerType>();
4456 const clang::ObjCInterfaceType *objc_interface_type =
4457 objc_class_type->getInterfaceType();
4458 if (objc_interface_type &&
4460 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4461 clang::ObjCInterfaceDecl *class_interface_decl =
4462 objc_interface_type->getDecl();
4463 if (class_interface_decl) {
4464 num_functions = std::distance(class_interface_decl->meth_begin(),
4465 class_interface_decl->meth_end());
4471 case clang::Type::ObjCObject:
4472 case clang::Type::ObjCInterface:
4474 const clang::ObjCObjectType *objc_class_type =
4475 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4476 if (objc_class_type) {
4477 clang::ObjCInterfaceDecl *class_interface_decl =
4478 objc_class_type->getInterface();
4479 if (class_interface_decl)
4480 num_functions = std::distance(class_interface_decl->meth_begin(),
4481 class_interface_decl->meth_end());
4490 return num_functions;
4502 switch (qual_type->getTypeClass()) {
4503 case clang::Type::Record:
4505 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4506 auto method_iter = cxx_record_decl->method_begin();
4507 auto method_end = cxx_record_decl->method_end();
4509 static_cast<size_t>(std::distance(method_iter, method_end))) {
4510 std::advance(method_iter, idx);
4511 clang::CXXMethodDecl *cxx_method_decl =
4512 method_iter->getCanonicalDecl();
4513 if (cxx_method_decl) {
4514 name = cxx_method_decl->getDeclName().getAsString();
4515 if (cxx_method_decl->isStatic())
4517 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4519 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4523 clang_type =
GetType(cxx_method_decl->getType());
4531 case clang::Type::ObjCObjectPointer: {
4532 const clang::ObjCObjectPointerType *objc_class_type =
4533 qual_type->castAs<clang::ObjCObjectPointerType>();
4534 const clang::ObjCInterfaceType *objc_interface_type =
4535 objc_class_type->getInterfaceType();
4536 if (objc_interface_type &&
4538 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4539 clang::ObjCInterfaceDecl *class_interface_decl =
4540 objc_interface_type->getDecl();
4541 if (class_interface_decl) {
4542 auto method_iter = class_interface_decl->meth_begin();
4543 auto method_end = class_interface_decl->meth_end();
4545 static_cast<size_t>(std::distance(method_iter, method_end))) {
4546 std::advance(method_iter, idx);
4547 clang::ObjCMethodDecl *objc_method_decl =
4548 method_iter->getCanonicalDecl();
4549 if (objc_method_decl) {
4551 name = objc_method_decl->getSelector().getAsString();
4552 if (objc_method_decl->isClassMethod())
4563 case clang::Type::ObjCObject:
4564 case clang::Type::ObjCInterface:
4566 const clang::ObjCObjectType *objc_class_type =
4567 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4568 if (objc_class_type) {
4569 clang::ObjCInterfaceDecl *class_interface_decl =
4570 objc_class_type->getInterface();
4571 if (class_interface_decl) {
4572 auto method_iter = class_interface_decl->meth_begin();
4573 auto method_end = class_interface_decl->meth_end();
4575 static_cast<size_t>(std::distance(method_iter, method_end))) {
4576 std::advance(method_iter, idx);
4577 clang::ObjCMethodDecl *objc_method_decl =
4578 method_iter->getCanonicalDecl();
4579 if (objc_method_decl) {
4581 name = objc_method_decl->getSelector().getAsString();
4582 if (objc_method_decl->isClassMethod())
4615 return GetType(qual_type.getTypePtr()->getPointeeType());
4625 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4626 case clang::Type::ObjCObject:
4627 case clang::Type::ObjCInterface:
4674 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4675 clang::QualType result =
4676 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4686 result.addVolatile();
4696 result.addRestrict();
4705 if (type && typedef_name && typedef_name[0]) {
4709 clang::DeclContext *decl_ctx =
4714 clang::TypedefDecl *decl =
4715 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4716 decl->setDeclContext(decl_ctx);
4717 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4718 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4719 decl_ctx->addDecl(decl);
4722 clang::TagDecl *tdecl =
nullptr;
4723 if (!qual_type.isNull()) {
4724 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4725 tdecl = rt->getDecl();
4726 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4727 tdecl = et->getDecl();
4733 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4734 tdecl->setTypedefNameForAnonDecl(decl);
4736 decl->setAccess(clang::AS_public);
4739 NestedNameSpecifier Qualifier =
4740 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4742 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4750 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4753 return GetType(typedef_type->getDecl()->getUnderlyingType());
4766 const FunctionType::ExtInfo generic_ext_info(
4775 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4780const llvm::fltSemantics &
4783 const size_t bit_size = byte_size * 8;
4784 if (bit_size == ast.getTypeSize(ast.FloatTy))
4785 return ast.getFloatTypeSemantics(ast.FloatTy);
4786 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4787 return ast.getFloatTypeSemantics(ast.DoubleTy);
4789 bit_size == ast.getTypeSize(ast.Float128Ty))
4790 return ast.getFloatTypeSemantics(ast.Float128Ty);
4791 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4792 bit_size == llvm::APFloat::semanticsSizeInBits(
4793 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4794 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4795 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4796 return ast.getFloatTypeSemantics(ast.HalfTy);
4797 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4798 return ast.getFloatTypeSemantics(ast.Float128Ty);
4799 return llvm::APFloatBase::Bogus();
4802llvm::Expected<uint64_t>
4805 assert(qual_type->isObjCObjectOrInterfaceType());
4810 if (std::optional<uint64_t> bit_size =
4811 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4815 static bool g_printed =
false;
4820 llvm::outs() <<
"warning: trying to determine the size of type ";
4822 llvm::outs() <<
"without a valid ExecutionContext. this is not "
4823 "reliable. please file a bug against LLDB.\n";
4824 llvm::outs() <<
"backtrace:\n";
4825 llvm::sys::PrintStackTrace(llvm::outs());
4826 llvm::outs() <<
"\n";
4835llvm::Expected<uint64_t>
4838 const bool base_name_only =
true;
4840 return llvm::createStringError(
4841 "could not complete type %s",
4845 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4846 switch (type_class) {
4847 case clang::Type::ConstantArray:
4848 case clang::Type::FunctionProto:
4849 case clang::Type::Record:
4851 case clang::Type::ObjCInterface:
4852 case clang::Type::ObjCObject:
4854 case clang::Type::IncompleteArray: {
4855 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4858 qual_type->getArrayElementTypeNoTypeQual()
4859 ->getCanonicalTypeUnqualified());
4864 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4868 return llvm::createStringError(
4869 "could not get size of type %s",
4873std::optional<size_t>
4887 switch (qual_type->getTypeClass()) {
4888 case clang::Type::Atomic:
4889 case clang::Type::Auto:
4890 case clang::Type::CountAttributed:
4891 case clang::Type::Decltype:
4892 case clang::Type::Paren:
4893 case clang::Type::Typedef:
4894 case clang::Type::TypeOf:
4895 case clang::Type::TypeOfExpr:
4896 case clang::Type::Using:
4897 case clang::Type::PredefinedSugar:
4898 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4900 case clang::Type::UnaryTransform:
4903 case clang::Type::FunctionNoProto:
4904 case clang::Type::FunctionProto:
4907 case clang::Type::IncompleteArray:
4908 case clang::Type::VariableArray:
4909 case clang::Type::ArrayParameter:
4912 case clang::Type::ConstantArray:
4915 case clang::Type::DependentVector:
4916 case clang::Type::ExtVector:
4917 case clang::Type::Vector:
4920 case clang::Type::BitInt:
4921 case clang::Type::DependentBitInt:
4925 case clang::Type::Builtin:
4926 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4927 case clang::BuiltinType::Void:
4930 case clang::BuiltinType::Char_S:
4931 case clang::BuiltinType::SChar:
4932 case clang::BuiltinType::WChar_S:
4933 case clang::BuiltinType::Short:
4934 case clang::BuiltinType::Int:
4935 case clang::BuiltinType::Long:
4936 case clang::BuiltinType::LongLong:
4937 case clang::BuiltinType::Int128:
4940 case clang::BuiltinType::Bool:
4941 case clang::BuiltinType::Char_U:
4942 case clang::BuiltinType::UChar:
4943 case clang::BuiltinType::WChar_U:
4944 case clang::BuiltinType::Char8:
4945 case clang::BuiltinType::Char16:
4946 case clang::BuiltinType::Char32:
4947 case clang::BuiltinType::UShort:
4948 case clang::BuiltinType::UInt:
4949 case clang::BuiltinType::ULong:
4950 case clang::BuiltinType::ULongLong:
4951 case clang::BuiltinType::UInt128:
4955 case clang::BuiltinType::ShortAccum:
4956 case clang::BuiltinType::Accum:
4957 case clang::BuiltinType::LongAccum:
4958 case clang::BuiltinType::UShortAccum:
4959 case clang::BuiltinType::UAccum:
4960 case clang::BuiltinType::ULongAccum:
4961 case clang::BuiltinType::ShortFract:
4962 case clang::BuiltinType::Fract:
4963 case clang::BuiltinType::LongFract:
4964 case clang::BuiltinType::UShortFract:
4965 case clang::BuiltinType::UFract:
4966 case clang::BuiltinType::ULongFract:
4967 case clang::BuiltinType::SatShortAccum:
4968 case clang::BuiltinType::SatAccum:
4969 case clang::BuiltinType::SatLongAccum:
4970 case clang::BuiltinType::SatUShortAccum:
4971 case clang::BuiltinType::SatUAccum:
4972 case clang::BuiltinType::SatULongAccum:
4973 case clang::BuiltinType::SatShortFract:
4974 case clang::BuiltinType::SatFract:
4975 case clang::BuiltinType::SatLongFract:
4976 case clang::BuiltinType::SatUShortFract:
4977 case clang::BuiltinType::SatUFract:
4978 case clang::BuiltinType::SatULongFract:
4981 case clang::BuiltinType::Half:
4982 case clang::BuiltinType::Float:
4983 case clang::BuiltinType::Float16:
4984 case clang::BuiltinType::Float128:
4985 case clang::BuiltinType::Double:
4986 case clang::BuiltinType::LongDouble:
4987 case clang::BuiltinType::BFloat16:
4988 case clang::BuiltinType::Ibm128:
4991 case clang::BuiltinType::ObjCClass:
4992 case clang::BuiltinType::ObjCId:
4993 case clang::BuiltinType::ObjCSel:
4996 case clang::BuiltinType::NullPtr:
4999 case clang::BuiltinType::Kind::ARCUnbridgedCast:
5000 case clang::BuiltinType::Kind::BoundMember:
5001 case clang::BuiltinType::Kind::BuiltinFn:
5002 case clang::BuiltinType::Kind::Dependent:
5003 case clang::BuiltinType::Kind::OCLClkEvent:
5004 case clang::BuiltinType::Kind::OCLEvent:
5005 case clang::BuiltinType::Kind::OCLImage1dRO:
5006 case clang::BuiltinType::Kind::OCLImage1dWO:
5007 case clang::BuiltinType::Kind::OCLImage1dRW:
5008 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
5009 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
5010 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
5011 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
5012 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
5013 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
5014 case clang::BuiltinType::Kind::OCLImage2dRO:
5015 case clang::BuiltinType::Kind::OCLImage2dWO:
5016 case clang::BuiltinType::Kind::OCLImage2dRW:
5017 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
5018 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
5019 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
5020 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
5021 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
5022 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
5023 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
5024 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
5025 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
5026 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
5027 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
5028 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
5029 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
5030 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
5031 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
5032 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
5033 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
5034 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
5035 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
5036 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
5037 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
5038 case clang::BuiltinType::Kind::OCLImage3dRO:
5039 case clang::BuiltinType::Kind::OCLImage3dWO:
5040 case clang::BuiltinType::Kind::OCLImage3dRW:
5041 case clang::BuiltinType::Kind::OCLQueue:
5042 case clang::BuiltinType::Kind::OCLReserveID:
5043 case clang::BuiltinType::Kind::OCLSampler:
5044 case clang::BuiltinType::Kind::HLSLResource:
5045 case clang::BuiltinType::Kind::ArraySection:
5046 case clang::BuiltinType::Kind::OMPArrayShaping:
5047 case clang::BuiltinType::Kind::OMPIterator:
5048 case clang::BuiltinType::Kind::Overload:
5049 case clang::BuiltinType::Kind::PseudoObject:
5050 case clang::BuiltinType::Kind::UnknownAny:
5053 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
5054 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
5055 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
5056 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
5057 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
5058 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
5059 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
5060 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
5061 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
5062 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
5063 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
5064 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
5068 case clang::BuiltinType::VectorPair:
5069 case clang::BuiltinType::VectorQuad:
5070 case clang::BuiltinType::DMR1024:
5071 case clang::BuiltinType::DMR2048:
5075#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5076#include "clang/Basic/AArch64ACLETypes.def"
5080#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5081#include "clang/Basic/RISCVVTypes.def"
5085 case clang::BuiltinType::WasmExternRef:
5088 case clang::BuiltinType::IncompleteMatrixIdx:
5091 case clang::BuiltinType::UnresolvedTemplate:
5095#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
5096 case clang::BuiltinType::Id:
5097#include "clang/Basic/AMDGPUTypes.def"
5103 case clang::Type::ObjCObjectPointer:
5104 case clang::Type::BlockPointer:
5105 case clang::Type::Pointer:
5106 case clang::Type::LValueReference:
5107 case clang::Type::RValueReference:
5108 case clang::Type::MemberPointer:
5110 case clang::Type::Complex: {
5112 if (qual_type->isComplexType())
5115 const clang::ComplexType *complex_type =
5116 qual_type->getAsComplexIntegerType();
5125 case clang::Type::ObjCInterface:
5127 case clang::Type::Record:
5129 case clang::Type::Enum:
5130 return qual_type->isUnsignedIntegerOrEnumerationType()
5133 case clang::Type::DependentSizedArray:
5134 case clang::Type::DependentSizedExtVector:
5135 case clang::Type::UnresolvedUsing:
5136 case clang::Type::Attributed:
5137 case clang::Type::BTFTagAttributed:
5138 case clang::Type::TemplateTypeParm:
5139 case clang::Type::SubstTemplateTypeParm:
5140 case clang::Type::SubstTemplateTypeParmPack:
5141 case clang::Type::InjectedClassName:
5142 case clang::Type::DependentName:
5143 case clang::Type::PackExpansion:
5144 case clang::Type::ObjCObject:
5146 case clang::Type::TemplateSpecialization:
5147 case clang::Type::DeducedTemplateSpecialization:
5148 case clang::Type::Adjusted:
5149 case clang::Type::Pipe:
5153 case clang::Type::Decayed:
5155 case clang::Type::ObjCTypeParam:
5158 case clang::Type::DependentAddressSpace:
5160 case clang::Type::MacroQualified:
5163 case clang::Type::ConstantMatrix:
5164 case clang::Type::DependentSizedMatrix:
5168 case clang::Type::PackIndexing:
5171 case clang::Type::HLSLAttributedResource:
5173 case clang::Type::HLSLInlineSpirv:
5175 case clang::Type::SubstBuiltinTemplatePack:
5188 switch (qual_type->getTypeClass()) {
5189 case clang::Type::Atomic:
5190 case clang::Type::Auto:
5191 case clang::Type::CountAttributed:
5192 case clang::Type::Decltype:
5193 case clang::Type::Paren:
5194 case clang::Type::Typedef:
5195 case clang::Type::TypeOf:
5196 case clang::Type::TypeOfExpr:
5197 case clang::Type::Using:
5198 case clang::Type::PredefinedSugar:
5199 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5200 case clang::Type::UnaryTransform:
5203 case clang::Type::FunctionNoProto:
5204 case clang::Type::FunctionProto:
5207 case clang::Type::IncompleteArray:
5208 case clang::Type::VariableArray:
5209 case clang::Type::ArrayParameter:
5212 case clang::Type::ConstantArray:
5215 case clang::Type::DependentVector:
5216 case clang::Type::ExtVector:
5217 case clang::Type::Vector:
5220 case clang::Type::BitInt:
5221 case clang::Type::DependentBitInt:
5225 case clang::Type::Builtin:
5226 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5227 case clang::BuiltinType::UnknownAny:
5228 case clang::BuiltinType::Void:
5229 case clang::BuiltinType::BoundMember:
5232 case clang::BuiltinType::Bool:
5234 case clang::BuiltinType::Char_S:
5235 case clang::BuiltinType::SChar:
5236 case clang::BuiltinType::WChar_S:
5237 case clang::BuiltinType::Char_U:
5238 case clang::BuiltinType::UChar:
5239 case clang::BuiltinType::WChar_U:
5241 case clang::BuiltinType::Char8:
5243 case clang::BuiltinType::Char16:
5245 case clang::BuiltinType::Char32:
5247 case clang::BuiltinType::UShort:
5249 case clang::BuiltinType::Short:
5251 case clang::BuiltinType::UInt:
5253 case clang::BuiltinType::Int:
5255 case clang::BuiltinType::ULong:
5257 case clang::BuiltinType::Long:
5259 case clang::BuiltinType::ULongLong:
5261 case clang::BuiltinType::LongLong:
5263 case clang::BuiltinType::UInt128:
5265 case clang::BuiltinType::Int128:
5267 case clang::BuiltinType::Half:
5268 case clang::BuiltinType::Float:
5269 case clang::BuiltinType::Double:
5270 case clang::BuiltinType::LongDouble:
5272 case clang::BuiltinType::Float128:
5278 case clang::Type::ObjCObjectPointer:
5280 case clang::Type::BlockPointer:
5282 case clang::Type::Pointer:
5284 case clang::Type::LValueReference:
5285 case clang::Type::RValueReference:
5287 case clang::Type::MemberPointer:
5289 case clang::Type::Complex: {
5290 if (qual_type->isComplexType())
5295 case clang::Type::ObjCInterface:
5297 case clang::Type::Record:
5299 case clang::Type::Enum:
5301 case clang::Type::DependentSizedArray:
5302 case clang::Type::DependentSizedExtVector:
5303 case clang::Type::UnresolvedUsing:
5304 case clang::Type::Attributed:
5305 case clang::Type::BTFTagAttributed:
5306 case clang::Type::TemplateTypeParm:
5307 case clang::Type::SubstTemplateTypeParm:
5308 case clang::Type::SubstTemplateTypeParmPack:
5309 case clang::Type::InjectedClassName:
5310 case clang::Type::DependentName:
5311 case clang::Type::PackExpansion:
5312 case clang::Type::ObjCObject:
5314 case clang::Type::TemplateSpecialization:
5315 case clang::Type::DeducedTemplateSpecialization:
5316 case clang::Type::Adjusted:
5317 case clang::Type::Pipe:
5321 case clang::Type::Decayed:
5323 case clang::Type::ObjCTypeParam:
5326 case clang::Type::DependentAddressSpace:
5328 case clang::Type::MacroQualified:
5332 case clang::Type::ConstantMatrix:
5333 case clang::Type::DependentSizedMatrix:
5337 case clang::Type::PackIndexing:
5340 case clang::Type::HLSLAttributedResource:
5342 case clang::Type::HLSLInlineSpirv:
5344 case clang::Type::SubstBuiltinTemplatePack:
5352 while (class_interface_decl) {
5353 if (class_interface_decl->ivar_size() > 0)
5356 class_interface_decl = class_interface_decl->getSuperClass();
5361static std::optional<SymbolFile::ArrayInfo>
5363 clang::QualType qual_type,
5365 if (qual_type->isIncompleteArrayType())
5366 if (std::optional<ClangASTMetadata> metadata =
5370 return std::nullopt;
5373llvm::Expected<uint32_t>
5375 bool omit_empty_base_classes,
5378 return llvm::createStringError(
"invalid clang type");
5380 uint32_t num_children = 0;
5382 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5383 switch (type_class) {
5384 case clang::Type::Builtin:
5385 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5386 case clang::BuiltinType::ObjCId:
5387 case clang::BuiltinType::ObjCClass:
5396 case clang::Type::Complex:
5398 case clang::Type::Record:
5400 const clang::RecordType *record_type =
5401 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5402 const clang::RecordDecl *record_decl =
5403 record_type->getDecl()->getDefinitionOrSelf();
5404 const clang::CXXRecordDecl *cxx_record_decl =
5405 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5409 num_children += std::distance(record_decl->field_begin(),
5410 record_decl->field_end());
5412 return llvm::createStringError(
5415 case clang::Type::ObjCObject:
5416 case clang::Type::ObjCInterface:
5418 const clang::ObjCObjectType *objc_class_type =
5419 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5420 assert(objc_class_type);
5421 if (objc_class_type) {
5422 clang::ObjCInterfaceDecl *class_interface_decl =
5423 objc_class_type->getInterface();
5425 if (class_interface_decl) {
5427 clang::ObjCInterfaceDecl *superclass_interface_decl =
5428 class_interface_decl->getSuperClass();
5429 if (superclass_interface_decl) {
5430 if (omit_empty_base_classes) {
5437 num_children += class_interface_decl->ivar_size();
5443 case clang::Type::LValueReference:
5444 case clang::Type::RValueReference:
5445 case clang::Type::ObjCObjectPointer: {
5448 uint32_t num_pointee_children = 0;
5450 auto num_children_or_err =
5451 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5452 if (!num_children_or_err)
5453 return num_children_or_err;
5454 num_pointee_children = *num_children_or_err;
5457 if (num_pointee_children == 0)
5460 num_children = num_pointee_children;
5463 case clang::Type::Vector:
5464 case clang::Type::ExtVector:
5466 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5469 case clang::Type::ConstantArray:
5470 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5474 case clang::Type::IncompleteArray:
5475 if (
auto array_info =
5478 num_children = array_info->element_orders.size()
5479 ? array_info->element_orders.back().value_or(0)
5483 case clang::Type::Pointer: {
5484 const clang::PointerType *pointer_type =
5485 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5486 clang::QualType pointee_type(pointer_type->getPointeeType());
5488 uint32_t num_pointee_children = 0;
5490 auto num_children_or_err =
5491 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5492 if (!num_children_or_err)
5493 return num_children_or_err;
5494 num_pointee_children = *num_children_or_err;
5496 if (num_pointee_children == 0) {
5501 num_children = num_pointee_children;
5507 return num_children;
5518 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5519 if (type_class == clang::Type::Builtin) {
5520 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5521 case clang::BuiltinType::Void:
5523 case clang::BuiltinType::Bool:
5525 case clang::BuiltinType::Char_S:
5527 case clang::BuiltinType::Char_U:
5529 case clang::BuiltinType::Char8:
5531 case clang::BuiltinType::Char16:
5533 case clang::BuiltinType::Char32:
5535 case clang::BuiltinType::UChar:
5537 case clang::BuiltinType::SChar:
5539 case clang::BuiltinType::WChar_S:
5541 case clang::BuiltinType::WChar_U:
5543 case clang::BuiltinType::Short:
5545 case clang::BuiltinType::UShort:
5547 case clang::BuiltinType::Int:
5549 case clang::BuiltinType::UInt:
5551 case clang::BuiltinType::Long:
5553 case clang::BuiltinType::ULong:
5555 case clang::BuiltinType::LongLong:
5557 case clang::BuiltinType::ULongLong:
5559 case clang::BuiltinType::Int128:
5561 case clang::BuiltinType::UInt128:
5564 case clang::BuiltinType::Half:
5566 case clang::BuiltinType::Float:
5568 case clang::BuiltinType::Double:
5570 case clang::BuiltinType::LongDouble:
5572 case clang::BuiltinType::Float128:
5575 case clang::BuiltinType::NullPtr:
5577 case clang::BuiltinType::ObjCId:
5579 case clang::BuiltinType::ObjCClass:
5581 case clang::BuiltinType::ObjCSel:
5595 const llvm::APSInt &value)>
const &callback) {
5596 const clang::EnumType *enum_type =
5599 const clang::EnumDecl *enum_decl =
5600 enum_type->getDecl()->getDefinitionOrSelf();
5604 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5605 for (enum_pos = enum_decl->enumerator_begin(),
5606 enum_end_pos = enum_decl->enumerator_end();
5607 enum_pos != enum_end_pos; ++enum_pos) {
5608 ConstString name(enum_pos->getNameAsString().c_str());
5609 if (!callback(integer_type, name, enum_pos->getInitVal()))
5616#pragma mark Aggregate Types
5624 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5625 switch (type_class) {
5626 case clang::Type::Record:
5628 const clang::RecordType *record_type =
5629 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5631 clang::RecordDecl *record_decl =
5632 record_type->getDecl()->getDefinition();
5634 count = std::distance(record_decl->field_begin(),
5635 record_decl->field_end());
5641 case clang::Type::ObjCObjectPointer: {
5642 const clang::ObjCObjectPointerType *objc_class_type =
5643 qual_type->castAs<clang::ObjCObjectPointerType>();
5644 const clang::ObjCInterfaceType *objc_interface_type =
5645 objc_class_type->getInterfaceType();
5646 if (objc_interface_type &&
5648 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5649 clang::ObjCInterfaceDecl *class_interface_decl =
5650 objc_interface_type->getDecl();
5651 if (class_interface_decl) {
5652 count = class_interface_decl->ivar_size();
5658 case clang::Type::ObjCObject:
5659 case clang::Type::ObjCInterface:
5661 const clang::ObjCObjectType *objc_class_type =
5662 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5663 if (objc_class_type) {
5664 clang::ObjCInterfaceDecl *class_interface_decl =
5665 objc_class_type->getInterface();
5667 if (class_interface_decl)
5668 count = class_interface_decl->ivar_size();
5681 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5682 std::string &name, uint64_t *bit_offset_ptr,
5683 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5684 if (class_interface_decl) {
5685 if (idx < (class_interface_decl->ivar_size())) {
5686 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5687 ivar_end = class_interface_decl->ivar_end();
5688 uint32_t ivar_idx = 0;
5690 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5691 ++ivar_pos, ++ivar_idx) {
5692 if (ivar_idx == idx) {
5693 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5695 clang::QualType ivar_qual_type(ivar_decl->getType());
5697 name.assign(ivar_decl->getNameAsString());
5699 if (bit_offset_ptr) {
5700 const clang::ASTRecordLayout &interface_layout =
5701 ast->getASTObjCInterfaceLayout(class_interface_decl);
5702 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5705 const bool is_bitfield = ivar_pos->isBitField();
5707 if (bitfield_bit_size_ptr) {
5708 *bitfield_bit_size_ptr = 0;
5710 if (is_bitfield && ast) {
5711 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5712 clang::Expr::EvalResult result;
5713 if (bitfield_bit_size_expr &&
5714 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5715 llvm::APSInt bitfield_apsint = result.Val.getInt();
5716 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5720 if (is_bitfield_ptr)
5721 *is_bitfield_ptr = is_bitfield;
5723 return ivar_qual_type.getAsOpaquePtr();
5732 size_t idx, std::string &name,
5733 uint64_t *bit_offset_ptr,
5734 uint32_t *bitfield_bit_size_ptr,
5735 bool *is_bitfield_ptr) {
5740 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5741 switch (type_class) {
5742 case clang::Type::Record:
5744 const clang::RecordType *record_type =
5745 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5746 const clang::RecordDecl *record_decl =
5747 record_type->getDecl()->getDefinitionOrSelf();
5748 uint32_t field_idx = 0;
5749 clang::RecordDecl::field_iterator field, field_end;
5750 for (field = record_decl->field_begin(),
5751 field_end = record_decl->field_end();
5752 field != field_end; ++field, ++field_idx) {
5753 if (idx == field_idx) {
5756 name.assign(field->getNameAsString());
5760 if (bit_offset_ptr) {
5761 const clang::ASTRecordLayout &record_layout =
5763 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5766 const bool is_bitfield = field->isBitField();
5768 if (bitfield_bit_size_ptr) {
5769 *bitfield_bit_size_ptr = 0;
5772 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5773 clang::Expr::EvalResult result;
5774 if (bitfield_bit_size_expr &&
5775 bitfield_bit_size_expr->EvaluateAsInt(result,
5777 llvm::APSInt bitfield_apsint = result.Val.getInt();
5778 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5782 if (is_bitfield_ptr)
5783 *is_bitfield_ptr = is_bitfield;
5785 return GetType(field->getType());
5791 case clang::Type::ObjCObjectPointer: {
5792 const clang::ObjCObjectPointerType *objc_class_type =
5793 qual_type->castAs<clang::ObjCObjectPointerType>();
5794 const clang::ObjCInterfaceType *objc_interface_type =
5795 objc_class_type->getInterfaceType();
5796 if (objc_interface_type &&
5798 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5799 clang::ObjCInterfaceDecl *class_interface_decl =
5800 objc_interface_type->getDecl();
5801 if (class_interface_decl) {
5805 name, bit_offset_ptr, bitfield_bit_size_ptr,
5812 case clang::Type::ObjCObject:
5813 case clang::Type::ObjCInterface:
5815 const clang::ObjCObjectType *objc_class_type =
5816 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5817 assert(objc_class_type);
5818 if (objc_class_type) {
5819 clang::ObjCInterfaceDecl *class_interface_decl =
5820 objc_class_type->getInterface();
5824 name, bit_offset_ptr, bitfield_bit_size_ptr,
5840 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5841 switch (type_class) {
5842 case clang::Type::Record:
5844 const clang::CXXRecordDecl *cxx_record_decl =
5845 qual_type->getAsCXXRecordDecl();
5846 if (cxx_record_decl)
5847 count = cxx_record_decl->getNumBases();
5851 case clang::Type::ObjCObjectPointer:
5855 case clang::Type::ObjCObject:
5857 const clang::ObjCObjectType *objc_class_type =
5858 qual_type->getAsObjCQualifiedInterfaceType();
5859 if (objc_class_type) {
5860 clang::ObjCInterfaceDecl *class_interface_decl =
5861 objc_class_type->getInterface();
5863 if (class_interface_decl && class_interface_decl->getSuperClass())
5868 case clang::Type::ObjCInterface:
5870 const clang::ObjCInterfaceType *objc_interface_type =
5871 qual_type->getAs<clang::ObjCInterfaceType>();
5872 if (objc_interface_type) {
5873 clang::ObjCInterfaceDecl *class_interface_decl =
5874 objc_interface_type->getInterface();
5876 if (class_interface_decl && class_interface_decl->getSuperClass())
5892 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5893 switch (type_class) {
5894 case clang::Type::Record:
5896 const clang::CXXRecordDecl *cxx_record_decl =
5897 qual_type->getAsCXXRecordDecl();
5898 if (cxx_record_decl)
5899 count = cxx_record_decl->getNumVBases();
5912 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5913 switch (type_class) {
5914 case clang::Type::Record:
5916 const clang::CXXRecordDecl *cxx_record_decl =
5917 qual_type->getAsCXXRecordDecl();
5918 if (cxx_record_decl) {
5919 uint32_t curr_idx = 0;
5920 clang::CXXRecordDecl::base_class_const_iterator base_class,
5922 for (base_class = cxx_record_decl->bases_begin(),
5923 base_class_end = cxx_record_decl->bases_end();
5924 base_class != base_class_end; ++base_class, ++curr_idx) {
5925 if (curr_idx == idx) {
5926 if (bit_offset_ptr) {
5927 const clang::ASTRecordLayout &record_layout =
5929 const clang::CXXRecordDecl *base_class_decl =
5930 llvm::cast<clang::CXXRecordDecl>(
5931 base_class->getType()
5932 ->castAs<clang::RecordType>()
5934 if (base_class->isVirtual())
5936 record_layout.getVBaseClassOffset(base_class_decl)
5941 record_layout.getBaseClassOffset(base_class_decl)
5945 return GetType(base_class->getType());
5952 case clang::Type::ObjCObjectPointer:
5955 case clang::Type::ObjCObject:
5957 const clang::ObjCObjectType *objc_class_type =
5958 qual_type->getAsObjCQualifiedInterfaceType();
5959 if (objc_class_type) {
5960 clang::ObjCInterfaceDecl *class_interface_decl =
5961 objc_class_type->getInterface();
5963 if (class_interface_decl) {
5964 clang::ObjCInterfaceDecl *superclass_interface_decl =
5965 class_interface_decl->getSuperClass();
5966 if (superclass_interface_decl) {
5968 *bit_offset_ptr = 0;
5970 superclass_interface_decl));
5976 case clang::Type::ObjCInterface:
5978 const clang::ObjCObjectType *objc_interface_type =
5979 qual_type->getAs<clang::ObjCInterfaceType>();
5980 if (objc_interface_type) {
5981 clang::ObjCInterfaceDecl *class_interface_decl =
5982 objc_interface_type->getInterface();
5984 if (class_interface_decl) {
5985 clang::ObjCInterfaceDecl *superclass_interface_decl =
5986 class_interface_decl->getSuperClass();
5987 if (superclass_interface_decl) {
5989 *bit_offset_ptr = 0;
5991 superclass_interface_decl));
6007 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6008 switch (type_class) {
6009 case clang::Type::Record:
6011 const clang::CXXRecordDecl *cxx_record_decl =
6012 qual_type->getAsCXXRecordDecl();
6013 if (cxx_record_decl) {
6014 uint32_t curr_idx = 0;
6015 clang::CXXRecordDecl::base_class_const_iterator base_class,
6017 for (base_class = cxx_record_decl->vbases_begin(),
6018 base_class_end = cxx_record_decl->vbases_end();
6019 base_class != base_class_end; ++base_class, ++curr_idx) {
6020 if (curr_idx == idx) {
6021 if (bit_offset_ptr) {
6022 const clang::ASTRecordLayout &record_layout =
6024 const clang::CXXRecordDecl *base_class_decl =
6025 llvm::cast<clang::CXXRecordDecl>(
6026 base_class->getType()
6027 ->castAs<clang::RecordType>()
6030 record_layout.getVBaseClassOffset(base_class_decl)
6034 return GetType(base_class->getType());
6049 llvm::StringRef name) {
6051 switch (qual_type->getTypeClass()) {
6052 case clang::Type::Record: {
6056 const clang::RecordType *record_type =
6057 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6058 const clang::RecordDecl *record_decl =
6059 record_type->getDecl()->getDefinitionOrSelf();
6061 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
6062 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
6063 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
6064 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
6088 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6089 switch (type_class) {
6090 case clang::Type::Builtin:
6091 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6092 case clang::BuiltinType::UnknownAny:
6093 case clang::BuiltinType::Void:
6094 case clang::BuiltinType::NullPtr:
6095 case clang::BuiltinType::OCLEvent:
6096 case clang::BuiltinType::OCLImage1dRO:
6097 case clang::BuiltinType::OCLImage1dWO:
6098 case clang::BuiltinType::OCLImage1dRW:
6099 case clang::BuiltinType::OCLImage1dArrayRO:
6100 case clang::BuiltinType::OCLImage1dArrayWO:
6101 case clang::BuiltinType::OCLImage1dArrayRW:
6102 case clang::BuiltinType::OCLImage1dBufferRO:
6103 case clang::BuiltinType::OCLImage1dBufferWO:
6104 case clang::BuiltinType::OCLImage1dBufferRW:
6105 case clang::BuiltinType::OCLImage2dRO:
6106 case clang::BuiltinType::OCLImage2dWO:
6107 case clang::BuiltinType::OCLImage2dRW:
6108 case clang::BuiltinType::OCLImage2dArrayRO:
6109 case clang::BuiltinType::OCLImage2dArrayWO:
6110 case clang::BuiltinType::OCLImage2dArrayRW:
6111 case clang::BuiltinType::OCLImage3dRO:
6112 case clang::BuiltinType::OCLImage3dWO:
6113 case clang::BuiltinType::OCLImage3dRW:
6114 case clang::BuiltinType::OCLSampler:
6115 case clang::BuiltinType::HLSLResource:
6117 case clang::BuiltinType::Bool:
6118 case clang::BuiltinType::Char_U:
6119 case clang::BuiltinType::UChar:
6120 case clang::BuiltinType::WChar_U:
6121 case clang::BuiltinType::Char16:
6122 case clang::BuiltinType::Char32:
6123 case clang::BuiltinType::UShort:
6124 case clang::BuiltinType::UInt:
6125 case clang::BuiltinType::ULong:
6126 case clang::BuiltinType::ULongLong:
6127 case clang::BuiltinType::UInt128:
6128 case clang::BuiltinType::Char_S:
6129 case clang::BuiltinType::SChar:
6130 case clang::BuiltinType::WChar_S:
6131 case clang::BuiltinType::Short:
6132 case clang::BuiltinType::Int:
6133 case clang::BuiltinType::Long:
6134 case clang::BuiltinType::LongLong:
6135 case clang::BuiltinType::Int128:
6136 case clang::BuiltinType::Float:
6137 case clang::BuiltinType::Double:
6138 case clang::BuiltinType::LongDouble:
6139 case clang::BuiltinType::Float128:
6140 case clang::BuiltinType::Dependent:
6141 case clang::BuiltinType::Overload:
6142 case clang::BuiltinType::ObjCId:
6143 case clang::BuiltinType::ObjCClass:
6144 case clang::BuiltinType::ObjCSel:
6145 case clang::BuiltinType::BoundMember:
6146 case clang::BuiltinType::Half:
6147 case clang::BuiltinType::ARCUnbridgedCast:
6148 case clang::BuiltinType::PseudoObject:
6149 case clang::BuiltinType::BuiltinFn:
6150 case clang::BuiltinType::ArraySection:
6157 case clang::Type::Complex:
6159 case clang::Type::Pointer:
6161 case clang::Type::BlockPointer:
6164 case clang::Type::LValueReference:
6166 case clang::Type::RValueReference:
6168 case clang::Type::MemberPointer:
6170 case clang::Type::ConstantArray:
6172 case clang::Type::IncompleteArray:
6174 case clang::Type::VariableArray:
6176 case clang::Type::DependentSizedArray:
6178 case clang::Type::DependentSizedExtVector:
6180 case clang::Type::Vector:
6182 case clang::Type::ExtVector:
6184 case clang::Type::FunctionProto:
6186 case clang::Type::FunctionNoProto:
6188 case clang::Type::UnresolvedUsing:
6190 case clang::Type::Record:
6192 case clang::Type::Enum:
6194 case clang::Type::TemplateTypeParm:
6196 case clang::Type::SubstTemplateTypeParm:
6198 case clang::Type::TemplateSpecialization:
6200 case clang::Type::InjectedClassName:
6202 case clang::Type::DependentName:
6204 case clang::Type::ObjCObject:
6206 case clang::Type::ObjCInterface:
6208 case clang::Type::ObjCObjectPointer:
6218 std::string &deref_name, uint32_t &deref_byte_size,
6219 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6223 return llvm::createStringError(
"not a pointer, reference or array type");
6224 uint32_t child_bitfield_bit_size = 0;
6225 uint32_t child_bitfield_bit_offset = 0;
6226 bool child_is_base_class;
6227 bool child_is_deref_of_parent;
6229 type, exe_ctx, 0,
false,
true,
false, deref_name, deref_byte_size,
6230 deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6231 child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
6236 bool transparent_pointers,
bool omit_empty_base_classes,
6237 bool ignore_array_bounds, std::string &child_name,
6238 uint32_t &child_byte_size, int32_t &child_byte_offset,
6239 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6240 bool &child_is_base_class,
bool &child_is_deref_of_parent,
6245 auto get_exe_scope = [&exe_ctx]() {
6249 clang::QualType parent_qual_type(
6251 const clang::Type::TypeClass parent_type_class =
6252 parent_qual_type->getTypeClass();
6253 child_bitfield_bit_size = 0;
6254 child_bitfield_bit_offset = 0;
6255 child_is_base_class =
false;
6258 auto num_children_or_err =
6260 if (!num_children_or_err)
6261 return num_children_or_err.takeError();
6263 const bool idx_is_valid = idx < *num_children_or_err;
6265 switch (parent_type_class) {
6266 case clang::Type::Builtin:
6268 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6269 case clang::BuiltinType::ObjCId:
6270 case clang::BuiltinType::ObjCClass:
6283 case clang::Type::Record:
6285 const clang::RecordType *record_type =
6286 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6287 const clang::RecordDecl *record_decl =
6288 record_type->getDecl()->getDefinitionOrSelf();
6289 const clang::ASTRecordLayout &record_layout =
6291 uint32_t child_idx = 0;
6293 const clang::CXXRecordDecl *cxx_record_decl =
6294 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6295 if (cxx_record_decl) {
6297 clang::CXXRecordDecl::base_class_const_iterator base_class,
6299 for (base_class = cxx_record_decl->bases_begin(),
6300 base_class_end = cxx_record_decl->bases_end();
6301 base_class != base_class_end; ++base_class) {
6302 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6305 if (omit_empty_base_classes) {
6306 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6307 base_class->getType()
6308 ->getAs<clang::RecordType>()
6310 ->getDefinitionOrSelf();
6315 if (idx == child_idx) {
6316 if (base_class_decl ==
nullptr)
6317 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6318 base_class->getType()
6319 ->getAs<clang::RecordType>()
6321 ->getDefinitionOrSelf();
6323 if (base_class->isVirtual()) {
6324 bool handled =
false;
6326 clang::VTableContextBase *vtable_ctx =
6330 record_layout, cxx_record_decl,
6331 base_class_decl, bit_offset);
6334 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6338 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6343 child_byte_offset = bit_offset / 8;
6347 base_class_clang_type.
GetBitSize(get_exe_scope());
6349 return llvm::joinErrors(
6350 llvm::createStringError(
"no size info for base class"),
6351 size_or_err.takeError());
6353 uint64_t base_class_clang_type_bit_size = *size_or_err;
6356 assert(base_class_clang_type_bit_size % 8 == 0);
6357 child_byte_size = base_class_clang_type_bit_size / 8;
6358 child_is_base_class =
true;
6359 return base_class_clang_type;
6367 uint32_t field_idx = 0;
6368 clang::RecordDecl::field_iterator field, field_end;
6369 for (field = record_decl->field_begin(),
6370 field_end = record_decl->field_end();
6371 field != field_end; ++field, ++field_idx, ++child_idx) {
6372 if (idx == child_idx) {
6375 child_name.assign(field->getNameAsString());
6380 assert(field_idx < record_layout.getFieldCount());
6381 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6383 return llvm::joinErrors(
6384 llvm::createStringError(
"no size info for field"),
6385 size_or_err.takeError());
6387 child_byte_size = *size_or_err;
6388 const uint32_t child_bit_size = child_byte_size * 8;
6392 bit_offset = record_layout.getFieldOffset(field_idx);
6394 child_bitfield_bit_offset = bit_offset % child_bit_size;
6395 const uint32_t child_bit_offset =
6396 bit_offset - child_bitfield_bit_offset;
6397 child_byte_offset = child_bit_offset / 8;
6399 child_byte_offset = bit_offset / 8;
6402 return field_clang_type;
6408 case clang::Type::ObjCObject:
6409 case clang::Type::ObjCInterface:
6411 const clang::ObjCObjectType *objc_class_type =
6412 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6413 assert(objc_class_type);
6414 if (objc_class_type) {
6415 uint32_t child_idx = 0;
6416 clang::ObjCInterfaceDecl *class_interface_decl =
6417 objc_class_type->getInterface();
6419 if (class_interface_decl) {
6421 const clang::ASTRecordLayout &interface_layout =
6422 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6423 clang::ObjCInterfaceDecl *superclass_interface_decl =
6424 class_interface_decl->getSuperClass();
6425 if (superclass_interface_decl) {
6426 if (omit_empty_base_classes) {
6429 superclass_interface_decl));
6430 if (llvm::expectedToStdOptional(
6432 omit_empty_base_classes, exe_ctx))
6435 clang::QualType ivar_qual_type(
6437 superclass_interface_decl));
6440 superclass_interface_decl->getNameAsString());
6442 clang::TypeInfo ivar_type_info =
6445 child_byte_size = ivar_type_info.Width / 8;
6446 child_byte_offset = 0;
6447 child_is_base_class =
true;
6449 return GetType(ivar_qual_type);
6458 const uint32_t superclass_idx = child_idx;
6460 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6461 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6462 ivar_end = class_interface_decl->ivar_end();
6464 for (ivar_pos = class_interface_decl->ivar_begin();
6465 ivar_pos != ivar_end; ++ivar_pos) {
6466 if (child_idx == idx) {
6467 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6469 clang::QualType ivar_qual_type(ivar_decl->getType());
6471 child_name.assign(ivar_decl->getNameAsString());
6473 clang::TypeInfo ivar_type_info =
6476 child_byte_size = ivar_type_info.Width / 8;
6492 if (objc_runtime !=
nullptr) {
6495 parent_ast_type, ivar_decl->getNameAsString().c_str());
6503 if (child_byte_offset ==
6505 bit_offset = interface_layout.getFieldOffset(child_idx -
6507 child_byte_offset = bit_offset / 8;
6518 bit_offset = interface_layout.getFieldOffset(
6519 child_idx - superclass_idx);
6521 child_bitfield_bit_offset = bit_offset % 8;
6523 return GetType(ivar_qual_type);
6533 case clang::Type::ObjCObjectPointer:
6538 child_is_deref_of_parent =
false;
6539 bool tmp_child_is_deref_of_parent =
false;
6541 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6542 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6543 child_bitfield_bit_size, child_bitfield_bit_offset,
6544 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6547 child_is_deref_of_parent =
true;
6548 const char *parent_name =
6551 child_name.assign(1,
'*');
6552 child_name += parent_name;
6557 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6559 return size_or_err.takeError();
6560 child_byte_size = *size_or_err;
6561 child_byte_offset = 0;
6562 return pointee_clang_type;
6568 case clang::Type::Vector:
6569 case clang::Type::ExtVector:
6571 const clang::VectorType *array =
6572 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6576 char element_name[64];
6577 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6578 static_cast<uint64_t
>(idx));
6579 child_name.assign(element_name);
6580 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6582 return size_or_err.takeError();
6583 child_byte_size = *size_or_err;
6584 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6585 return element_type;
6591 case clang::Type::ConstantArray:
6592 case clang::Type::IncompleteArray:
6593 if (ignore_array_bounds || idx_is_valid) {
6594 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6598 child_name = std::string(llvm::formatv(
"[{0}]", idx));
6599 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6601 return size_or_err.takeError();
6602 child_byte_size = *size_or_err;
6603 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6604 return element_type;
6610 case clang::Type::Pointer: {
6618 child_is_deref_of_parent =
false;
6619 bool tmp_child_is_deref_of_parent =
false;
6621 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6622 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6623 child_bitfield_bit_size, child_bitfield_bit_offset,
6624 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6627 child_is_deref_of_parent =
true;
6629 const char *parent_name =
6632 child_name.assign(1,
'*');
6633 child_name += parent_name;
6638 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6640 return size_or_err.takeError();
6641 child_byte_size = *size_or_err;
6642 child_byte_offset = 0;
6643 return pointee_clang_type;
6649 case clang::Type::LValueReference:
6650 case clang::Type::RValueReference:
6652 const clang::ReferenceType *reference_type =
6653 llvm::cast<clang::ReferenceType>(
6656 GetType(reference_type->getPointeeType());
6658 child_is_deref_of_parent =
false;
6659 bool tmp_child_is_deref_of_parent =
false;
6661 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6662 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6663 child_bitfield_bit_size, child_bitfield_bit_offset,
6664 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6667 const char *parent_name =
6670 child_name.assign(1,
'&');
6671 child_name += parent_name;
6676 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6678 return size_or_err.takeError();
6679 child_byte_size = *size_or_err;
6680 child_byte_offset = 0;
6681 return pointee_clang_type;
6694 const clang::RecordDecl *record_decl,
6695 const clang::CXXBaseSpecifier *base_spec,
6696 bool omit_empty_base_classes) {
6697 uint32_t child_idx = 0;
6699 const clang::CXXRecordDecl *cxx_record_decl =
6700 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6702 if (cxx_record_decl) {
6703 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6704 for (base_class = cxx_record_decl->bases_begin(),
6705 base_class_end = cxx_record_decl->bases_end();
6706 base_class != base_class_end; ++base_class) {
6707 if (omit_empty_base_classes) {
6712 if (base_class == base_spec)
6722 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6723 bool omit_empty_base_classes) {
6725 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6726 omit_empty_base_classes);
6728 clang::RecordDecl::field_iterator field, field_end;
6729 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6730 field != field_end; ++field, ++child_idx) {
6731 if (field->getCanonicalDecl() == canonical_decl)
6773 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6774 if (type && !name.empty()) {
6776 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6777 switch (type_class) {
6778 case clang::Type::Record:
6780 const clang::RecordType *record_type =
6781 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6782 const clang::RecordDecl *record_decl =
6783 record_type->getDecl()->getDefinitionOrSelf();
6785 assert(record_decl);
6786 uint32_t child_idx = 0;
6788 const clang::CXXRecordDecl *cxx_record_decl =
6789 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6792 clang::RecordDecl::field_iterator field, field_end;
6793 for (field = record_decl->field_begin(),
6794 field_end = record_decl->field_end();
6795 field != field_end; ++field, ++child_idx) {
6796 llvm::StringRef field_name = field->getName();
6797 if (field_name.empty()) {
6799 std::vector<uint32_t> save_indices = child_indexes;
6800 child_indexes.push_back(
6802 cxx_record_decl, omit_empty_base_classes));
6804 name, omit_empty_base_classes, child_indexes))
6805 return child_indexes.size();
6806 child_indexes = std::move(save_indices);
6807 }
else if (field_name == name) {
6809 child_indexes.push_back(
6811 cxx_record_decl, omit_empty_base_classes));
6812 return child_indexes.size();
6816 if (cxx_record_decl) {
6817 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6820 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6821 clang::DeclarationName decl_name(&ident_ref);
6823 clang::CXXBasePaths paths;
6824 if (cxx_record_decl->lookupInBases(
6825 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6826 clang::CXXBasePath &path) {
6827 CXXRecordDecl *record =
6828 specifier->getType()->getAsCXXRecordDecl();
6829 auto r = record->lookup(decl_name);
6830 path.Decls = r.begin();
6834 clang::CXXBasePaths::const_paths_iterator path,
6835 path_end = paths.end();
6836 for (path = paths.begin(); path != path_end; ++path) {
6837 const size_t num_path_elements = path->size();
6838 for (
size_t e = 0; e < num_path_elements; ++e) {
6839 clang::CXXBasePathElement elem = (*path)[e];
6842 omit_empty_base_classes);
6844 child_indexes.clear();
6847 child_indexes.push_back(child_idx);
6848 parent_record_decl = elem.Base->getType()
6849 ->castAs<clang::RecordType>()
6851 ->getDefinitionOrSelf();
6854 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6857 parent_record_decl, *I, omit_empty_base_classes);
6859 child_indexes.clear();
6862 child_indexes.push_back(child_idx);
6866 return child_indexes.size();
6872 case clang::Type::ObjCObject:
6873 case clang::Type::ObjCInterface:
6875 llvm::StringRef name_sref(name);
6876 const clang::ObjCObjectType *objc_class_type =
6877 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6878 assert(objc_class_type);
6879 if (objc_class_type) {
6880 uint32_t child_idx = 0;
6881 clang::ObjCInterfaceDecl *class_interface_decl =
6882 objc_class_type->getInterface();
6884 if (class_interface_decl) {
6885 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6886 ivar_end = class_interface_decl->ivar_end();
6887 clang::ObjCInterfaceDecl *superclass_interface_decl =
6888 class_interface_decl->getSuperClass();
6890 for (ivar_pos = class_interface_decl->ivar_begin();
6891 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6892 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6894 if (ivar_decl->getName() == name_sref) {
6895 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6896 (omit_empty_base_classes &&
6900 child_indexes.push_back(child_idx);
6901 return child_indexes.size();
6905 if (superclass_interface_decl) {
6909 child_indexes.push_back(0);
6913 superclass_interface_decl));
6915 name, omit_empty_base_classes, child_indexes)) {
6918 return child_indexes.size();
6923 child_indexes.pop_back();
6930 case clang::Type::ObjCObjectPointer: {
6932 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6933 ->getPointeeType());
6935 name, omit_empty_base_classes, child_indexes);
6938 case clang::Type::LValueReference:
6939 case clang::Type::RValueReference: {
6940 const clang::ReferenceType *reference_type =
6941 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
6942 clang::QualType pointee_type(reference_type->getPointeeType());
6947 name, omit_empty_base_classes, child_indexes);
6951 case clang::Type::Pointer: {
6956 name, omit_empty_base_classes, child_indexes);
6971llvm::Expected<uint32_t>
6973 llvm::StringRef name,
6974 bool omit_empty_base_classes) {
6975 if (type && !name.empty()) {
6978 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6980 switch (type_class) {
6981 case clang::Type::Record:
6983 const clang::RecordType *record_type =
6984 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6985 const clang::RecordDecl *record_decl =
6986 record_type->getDecl()->getDefinitionOrSelf();
6988 assert(record_decl);
6989 uint32_t child_idx = 0;
6991 const clang::CXXRecordDecl *cxx_record_decl =
6992 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6994 if (cxx_record_decl) {
6995 clang::CXXRecordDecl::base_class_const_iterator base_class,
6997 for (base_class = cxx_record_decl->bases_begin(),
6998 base_class_end = cxx_record_decl->bases_end();
6999 base_class != base_class_end; ++base_class) {
7001 clang::CXXRecordDecl *base_class_decl =
7002 llvm::cast<clang::CXXRecordDecl>(
7003 base_class->getType()
7004 ->castAs<clang::RecordType>()
7006 ->getDefinitionOrSelf();
7007 if (omit_empty_base_classes &&
7012 std::string base_class_type_name(
7014 if (base_class_type_name == name)
7021 clang::RecordDecl::field_iterator field, field_end;
7022 for (field = record_decl->field_begin(),
7023 field_end = record_decl->field_end();
7024 field != field_end; ++field, ++child_idx) {
7025 if (field->getName() == name)
7031 case clang::Type::ObjCObject:
7032 case clang::Type::ObjCInterface:
7034 const clang::ObjCObjectType *objc_class_type =
7035 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
7036 assert(objc_class_type);
7037 if (objc_class_type) {
7038 uint32_t child_idx = 0;
7039 clang::ObjCInterfaceDecl *class_interface_decl =
7040 objc_class_type->getInterface();
7042 if (class_interface_decl) {
7043 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
7044 ivar_end = class_interface_decl->ivar_end();
7045 clang::ObjCInterfaceDecl *superclass_interface_decl =
7046 class_interface_decl->getSuperClass();
7048 for (ivar_pos = class_interface_decl->ivar_begin();
7049 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
7050 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
7052 if (ivar_decl->getName() == name) {
7053 if ((!omit_empty_base_classes && superclass_interface_decl) ||
7054 (omit_empty_base_classes &&
7062 if (superclass_interface_decl) {
7063 if (superclass_interface_decl->getName() == name)
7071 case clang::Type::ObjCObjectPointer: {
7073 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7074 ->getPointeeType());
7076 name, omit_empty_base_classes);
7079 case clang::Type::LValueReference:
7080 case clang::Type::RValueReference: {
7081 const clang::ReferenceType *reference_type =
7082 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7087 omit_empty_base_classes);
7091 case clang::Type::Pointer: {
7092 const clang::PointerType *pointer_type =
7093 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7098 omit_empty_base_classes);
7106 return llvm::createStringError(
"Type has no child named '%s'",
7107 name.str().c_str());
7112 llvm::StringRef name) {
7113 if (!type || name.empty())
7117 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7119 switch (type_class) {
7120 case clang::Type::Record: {
7123 const clang::RecordType *record_type =
7124 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7125 const clang::RecordDecl *record_decl =
7126 record_type->getDecl()->getDefinitionOrSelf();
7128 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7129 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7130 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7132 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7134 ElaboratedTypeKeyword::None, std::nullopt,
7150 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7151 return isa<clang::ClassTemplateSpecializationDecl>(
7152 cxx_record_decl->getDecl());
7163 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7164 switch (type_class) {
7165 case clang::Type::Record:
7167 const clang::CXXRecordDecl *cxx_record_decl =
7168 qual_type->getAsCXXRecordDecl();
7169 if (cxx_record_decl) {
7170 const clang::ClassTemplateSpecializationDecl *template_decl =
7171 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7173 if (template_decl) {
7174 const auto &template_arg_list = template_decl->getTemplateArgs();
7175 size_t num_args = template_arg_list.size();
7176 assert(num_args &&
"template specialization without any args");
7177 if (expand_pack && num_args) {
7178 const auto &pack = template_arg_list[num_args - 1];
7179 if (pack.getKind() == clang::TemplateArgument::Pack)
7180 num_args += pack.pack_size() - 1;
7195const clang::ClassTemplateSpecializationDecl *
7202 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7203 switch (type_class) {
7204 case clang::Type::Record: {
7207 const clang::CXXRecordDecl *cxx_record_decl =
7208 qual_type->getAsCXXRecordDecl();
7209 if (!cxx_record_decl)
7211 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7220const TemplateArgument *
7222 size_t idx,
bool expand_pack) {
7223 const auto &args = decl->getTemplateArgs();
7224 const size_t args_size = args.size();
7226 assert(args_size &&
"template specialization without any args");
7230 const size_t last_idx = args_size - 1;
7239 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7240 return idx >= args.size() ? nullptr : &args[idx];
7245 const auto &pack = args[last_idx];
7246 const size_t pack_idx = idx - last_idx;
7247 if (pack_idx >= pack.pack_size())
7249 return &pack.pack_elements()[pack_idx];
7254 size_t arg_idx,
bool expand_pack) {
7255 const clang::ClassTemplateSpecializationDecl *template_decl =
7264 switch (arg->getKind()) {
7265 case clang::TemplateArgument::Null:
7268 case clang::TemplateArgument::NullPtr:
7271 case clang::TemplateArgument::Type:
7274 case clang::TemplateArgument::Declaration:
7277 case clang::TemplateArgument::Integral:
7280 case clang::TemplateArgument::Template:
7283 case clang::TemplateArgument::TemplateExpansion:
7286 case clang::TemplateArgument::Expression:
7289 case clang::TemplateArgument::Pack:
7292 case clang::TemplateArgument::StructuralValue:
7295 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7300 size_t idx,
bool expand_pack) {
7301 const clang::ClassTemplateSpecializationDecl *template_decl =
7307 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7310 return GetType(arg->getAsType());
7313std::optional<CompilerType::IntegralTemplateArgument>
7315 size_t idx,
bool expand_pack) {
7316 const clang::ClassTemplateSpecializationDecl *template_decl =
7319 return std::nullopt;
7323 return std::nullopt;
7325 switch (arg->getKind()) {
7326 case clang::TemplateArgument::Integral:
7327 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7328 case clang::TemplateArgument::StructuralValue: {
7329 clang::APValue value = arg->getAsStructuralValue();
7332 if (value.isFloat())
7333 return {{value.getFloat(), type}};
7336 return {{value.getInt(), type}};
7338 return std::nullopt;
7341 return std::nullopt;
7355 bool is_signed =
false;
7356 bool isUnscopedEnumerationType =
7358 if (isUnscopedEnumerationType)
7379 llvm_unreachable(
"All cases handled above.");
7382llvm::Expected<CompilerType>
7399 uint64_t from_size = 0;
7407 llvm::Expected<uint64_t> from_size = from.
GetByteSize(exe_scope);
7409 return from_size.takeError();
7419 llvm::Expected<uint64_t> byte_size = type.GetByteSize(exe_scope);
7421 return byte_size.takeError();
7422 if (*from_size < *byte_size ||
7423 (*from_size == *byte_size && is_signed == type.IsSigned())) {
7427 llvm_unreachable(
"char type should fit into long long");
7432 llvm::Expected<uint64_t> int_byte_size = int_type.
GetByteSize(exe_scope);
7434 return int_byte_size.takeError();
7442 return (from_size == *int_byte_size)
7448 const clang::EnumType *enutype =
7451 return enutype->getDecl()->getDefinitionOrSelf();
7456 const clang::RecordType *record_type =
7459 return record_type->getDecl()->getDefinitionOrSelf();
7467clang::TypedefNameDecl *
7469 const clang::TypedefType *typedef_type =
7472 return typedef_type->getDecl();
7476clang::CXXRecordDecl *
7481clang::ObjCInterfaceDecl *
7483 const clang::ObjCObjectType *objc_class_type =
7484 llvm::dyn_cast<clang::ObjCObjectType>(
7486 if (objc_class_type)
7487 return objc_class_type->getInterface();
7494 uint32_t bitfield_bit_size) {
7500 clang::ASTContext &clang_ast = ast->getASTContext();
7501 clang::IdentifierInfo *ident =
nullptr;
7503 ident = &clang_ast.Idents.get(name);
7505 clang::FieldDecl *field =
nullptr;
7507 clang::Expr *bit_width =
nullptr;
7508 if (bitfield_bit_size != 0) {
7509 if (clang_ast.IntTy.isNull()) {
7512 "{0} failed: builtin ASTContext types have not been initialized");
7516 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7518 bit_width =
new (clang_ast)
7519 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7520 clang_ast.IntTy, clang::SourceLocation());
7521 bit_width = clang::ConstantExpr::Create(
7522 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7525 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7527 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7528 field->setDeclContext(record_decl);
7529 field->setDeclName(ident);
7532 field->setBitWidth(bit_width);
7538 if (
const clang::TagType *TagT =
7539 field->getType()->getAs<clang::TagType>()) {
7540 if (clang::RecordDecl *Rec =
7541 llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
7542 if (!Rec->getDeclName()) {
7543 Rec->setAnonymousStructOrUnion(
true);
7544 field->setImplicit();
7550 clang::AccessSpecifier access_specifier =
7552 field->setAccess(access_specifier);
7554 if (clang::CXXRecordDecl *cxx_record_decl =
7555 llvm::dyn_cast<CXXRecordDecl>(record_decl)) {
7556 AddAccessSpecifierDecl(cxx_record_decl, ast->getASTContext(),
7557 ast->GetCXXRecordDeclAccess(cxx_record_decl),
7559 ast->SetCXXRecordDeclAccess(cxx_record_decl, access_specifier);
7561 record_decl->addDecl(field);
7566 clang::ObjCInterfaceDecl *class_interface_decl =
7567 ast->GetAsObjCInterfaceDecl(type);
7569 if (class_interface_decl) {
7570 const bool is_synthesized =
false;
7575 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7576 ivar->setDeclContext(class_interface_decl);
7577 ivar->setDeclName(ident);
7581 ivar->setBitWidth(bit_width);
7582 ivar->setSynthesize(is_synthesized);
7587 class_interface_decl->addDecl(field);
7604 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7609 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7611 IndirectFieldVector indirect_fields;
7612 clang::RecordDecl::field_iterator field_pos;
7613 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7614 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7615 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7616 last_field_pos = field_pos++) {
7617 if (field_pos->isAnonymousStructOrUnion()) {
7618 clang::QualType field_qual_type = field_pos->getType();
7620 const clang::RecordType *field_record_type =
7621 field_qual_type->getAs<clang::RecordType>();
7623 if (!field_record_type)
7626 clang::RecordDecl *field_record_decl =
7627 field_record_type->getDecl()->getDefinition();
7629 if (!field_record_decl)
7632 for (clang::RecordDecl::decl_iterator
7633 di = field_record_decl->decls_begin(),
7634 de = field_record_decl->decls_end();
7636 if (clang::FieldDecl *nested_field_decl =
7637 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7638 clang::NamedDecl **chain =
7639 new (ast->getASTContext()) clang::NamedDecl *[2];
7640 chain[0] = *field_pos;
7641 chain[1] = nested_field_decl;
7642 clang::IndirectFieldDecl *indirect_field =
7643 clang::IndirectFieldDecl::Create(
7644 ast->getASTContext(), record_decl, clang::SourceLocation(),
7645 nested_field_decl->getIdentifier(),
7646 nested_field_decl->getType(), {chain, 2});
7649 indirect_field->setImplicit();
7652 field_pos->getAccess(), nested_field_decl->getAccess()));
7654 indirect_fields.push_back(indirect_field);
7655 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7656 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7657 size_t nested_chain_size =
7658 nested_indirect_field_decl->getChainingSize();
7659 clang::NamedDecl **chain =
new (ast->getASTContext())
7660 clang::NamedDecl *[nested_chain_size + 1];
7661 chain[0] = *field_pos;
7663 int chain_index = 1;
7664 for (clang::IndirectFieldDecl::chain_iterator
7665 nci = nested_indirect_field_decl->chain_begin(),
7666 nce = nested_indirect_field_decl->chain_end();
7668 chain[chain_index] = *nci;
7672 clang::IndirectFieldDecl *indirect_field =
7673 clang::IndirectFieldDecl::Create(
7674 ast->getASTContext(), record_decl, clang::SourceLocation(),
7675 nested_indirect_field_decl->getIdentifier(),
7676 nested_indirect_field_decl->getType(),
7677 {chain, nested_chain_size + 1});
7680 indirect_field->setImplicit();
7683 field_pos->getAccess(), nested_indirect_field_decl->getAccess()));
7685 indirect_fields.push_back(indirect_field);
7693 if (last_field_pos != field_end_pos) {
7694 if (last_field_pos->getType()->isIncompleteArrayType())
7695 record_decl->hasFlexibleArrayMember();
7698 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7699 ife = indirect_fields.end();
7701 record_decl->addDecl(*ifi);
7714 record_decl->addAttr(
7715 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7730 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7734 clang::VarDecl *var_decl =
nullptr;
7735 clang::IdentifierInfo *ident =
nullptr;
7737 ident = &ast->getASTContext().Idents.get(name);
7740 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7741 var_decl->setDeclContext(record_decl);
7742 var_decl->setDeclName(ident);
7744 var_decl->setStorageClass(clang::SC_Static);
7749 var_decl->setAccess(
7751 record_decl->addDecl(var_decl);
7753 VerifyDecl(var_decl);
7759 VarDecl *var,
const llvm::APInt &init_value) {
7760 assert(!var->hasInit() &&
"variable already initialized");
7762 clang::ASTContext &ast = var->getASTContext();
7763 QualType qt = var->getType();
7764 assert(qt->isIntegralOrEnumerationType() &&
7765 "only integer or enum types supported");
7768 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7769 const EnumDecl *enum_decl = enum_type->getDecl()->getDefinitionOrSelf();
7770 qt = enum_decl->getIntegerType();
7774 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7775 var->setInit(CXXBoolLiteralExpr::Create(
7776 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7778 var->setInit(IntegerLiteral::Create(
7779 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7784 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7785 assert(!var->hasInit() &&
"variable already initialized");
7787 clang::ASTContext &ast = var->getASTContext();
7788 QualType qt = var->getType();
7789 assert(qt->isFloatingType() &&
"only floating point types supported");
7790 var->setInit(FloatingLiteral::Create(
7791 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7794llvm::SmallVector<clang::ParmVarDecl *>
7796 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7797 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7799 assert(parameter_names.empty() ||
7800 parameter_names.size() == prototype.getNumParams());
7802 llvm::SmallVector<clang::ParmVarDecl *> params;
7803 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7805 llvm::StringRef name =
7806 !parameter_names.empty() ? parameter_names[param_index] :
"";
7810 GetType(prototype.getParamType(param_index)),
7811 clang::SC_None,
false);
7814 params.push_back(param);
7822 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7824 bool is_explicit,
bool is_attr_used,
bool is_artificial) {
7825 if (!type || !method_clang_type.
IsValid() || name.empty())
7830 clang::CXXRecordDecl *cxx_record_decl =
7831 record_qual_type->getAsCXXRecordDecl();
7833 if (cxx_record_decl ==
nullptr)
7838 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7840 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7842 const clang::FunctionType *function_type =
7843 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7845 if (function_type ==
nullptr)
7848 const clang::FunctionProtoType *method_function_prototype(
7849 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7851 if (!method_function_prototype)
7854 unsigned int num_params = method_function_prototype->getNumParams();
7856 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7857 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7862 const clang::ExplicitSpecifier explicit_spec(
7863 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7864 : clang::ExplicitSpecKind::ResolvedFalse);
7866 if (name.starts_with(
"~")) {
7867 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7869 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7870 cxx_dtor_decl->setDeclName(
7873 cxx_dtor_decl->setType(method_qual_type);
7874 cxx_dtor_decl->setImplicit(is_artificial);
7875 cxx_dtor_decl->setInlineSpecified(is_inline);
7876 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7877 cxx_method_decl = cxx_dtor_decl;
7878 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7879 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7881 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7882 cxx_ctor_decl->setDeclName(
7885 cxx_ctor_decl->setType(method_qual_type);
7886 cxx_ctor_decl->setImplicit(is_artificial);
7887 cxx_ctor_decl->setInlineSpecified(is_inline);
7888 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7889 cxx_ctor_decl->setNumCtorInitializers(0);
7890 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7891 cxx_method_decl = cxx_ctor_decl;
7893 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7894 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7897 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7902 const bool is_method =
true;
7904 is_method, op_kind, num_params))
7906 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7908 cxx_method_decl->setDeclContext(cxx_record_decl);
7909 cxx_method_decl->setDeclName(
7910 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7911 cxx_method_decl->setType(method_qual_type);
7912 cxx_method_decl->setStorageClass(SC);
7913 cxx_method_decl->setInlineSpecified(is_inline);
7914 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7915 }
else if (num_params == 0) {
7917 auto *cxx_conversion_decl =
7918 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7920 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7921 cxx_conversion_decl->setDeclName(
7922 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7924 function_type->getReturnType())));
7925 cxx_conversion_decl->setType(method_qual_type);
7926 cxx_conversion_decl->setInlineSpecified(is_inline);
7927 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7928 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7929 cxx_method_decl = cxx_conversion_decl;
7933 if (cxx_method_decl ==
nullptr) {
7934 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7936 cxx_method_decl->setDeclContext(cxx_record_decl);
7937 cxx_method_decl->setDeclName(decl_name);
7938 cxx_method_decl->setType(method_qual_type);
7939 cxx_method_decl->setInlineSpecified(is_inline);
7940 cxx_method_decl->setStorageClass(SC);
7941 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7946 clang::AccessSpecifier access_specifier =
7949 cxx_method_decl->setAccess(access_specifier);
7950 cxx_method_decl->setVirtualAsWritten(is_virtual);
7953 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7955 if (!asm_label.empty())
7956 cxx_method_decl->addAttr(
7957 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7962 cxx_method_decl, *method_function_prototype, {}));
7969 cxx_record_decl->addDecl(cxx_method_decl);
7978 if (is_artificial) {
7979 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7980 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7981 (cxx_ctor_decl->isCopyConstructor() &&
7982 cxx_record_decl->hasTrivialCopyConstructor()) ||
7983 (cxx_ctor_decl->isMoveConstructor() &&
7984 cxx_record_decl->hasTrivialMoveConstructor()))) {
7985 cxx_ctor_decl->setDefaulted();
7986 cxx_ctor_decl->setTrivial(
true);
7987 }
else if (cxx_dtor_decl) {
7988 if (cxx_record_decl->hasTrivialDestructor()) {
7989 cxx_dtor_decl->setDefaulted();
7990 cxx_dtor_decl->setTrivial(
true);
7992 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7993 cxx_record_decl->hasTrivialCopyAssignment()) ||
7994 (cxx_method_decl->isMoveAssignmentOperator() &&
7995 cxx_record_decl->hasTrivialMoveAssignment())) {
7996 cxx_method_decl->setDefaulted();
7997 cxx_method_decl->setTrivial(
true);
8001 VerifyDecl(cxx_method_decl);
8003 return cxx_method_decl;
8009 for (
auto *method : record->methods())
8010 addOverridesForMethod(method);
8013#pragma mark C++ Base Classes
8015std::unique_ptr<clang::CXXBaseSpecifier>
8018 bool base_of_class) {
8022 return std::make_unique<clang::CXXBaseSpecifier>(
8023 clang::SourceRange(), is_virtual, base_of_class,
8026 clang::SourceLocation());
8031 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
8035 if (!cxx_record_decl)
8037 std::vector<clang::CXXBaseSpecifier *> raw_bases;
8038 raw_bases.reserve(bases.size());
8042 for (
auto &b : bases)
8043 raw_bases.push_back(b.get());
8044 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
8053 clang::ASTContext &clang_ast = ast->getASTContext();
8055 if (type && superclass_clang_type.
IsValid() &&
8057 clang::ObjCInterfaceDecl *class_interface_decl =
8059 clang::ObjCInterfaceDecl *super_interface_decl =
8061 if (class_interface_decl && super_interface_decl) {
8062 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
8063 clang_ast.getObjCInterfaceType(super_interface_decl)));
8072 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
8073 const char *property_setter_name,
const char *property_getter_name,
8075 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
8076 property_name[0] ==
'\0')
8081 clang::ASTContext &clang_ast = ast->getASTContext();
8084 if (!class_interface_decl)
8089 if (property_clang_type.
IsValid())
8090 property_clang_type_to_access = property_clang_type;
8092 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
8094 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
8097 clang::TypeSourceInfo *prop_type_source;
8099 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
8101 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
8104 clang::ObjCPropertyDecl *property_decl =
8105 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8106 property_decl->setDeclContext(class_interface_decl);
8107 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
8108 property_decl->setType(ivar_decl
8109 ? ivar_decl->getType()
8117 ast->SetMetadata(property_decl, metadata);
8119 class_interface_decl->addDecl(property_decl);
8121 clang::Selector setter_sel, getter_sel;
8123 if (property_setter_name) {
8124 std::string property_setter_no_colon(property_setter_name,
8125 strlen(property_setter_name) - 1);
8126 const clang::IdentifierInfo *setter_ident =
8127 &clang_ast.Idents.get(property_setter_no_colon);
8128 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8129 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
8130 std::string setter_sel_string(
"set");
8131 setter_sel_string.push_back(::toupper(property_name[0]));
8132 setter_sel_string.append(&property_name[1]);
8133 const clang::IdentifierInfo *setter_ident =
8134 &clang_ast.Idents.get(setter_sel_string);
8135 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8137 property_decl->setSetterName(setter_sel);
8138 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
8140 if (property_getter_name !=
nullptr) {
8141 const clang::IdentifierInfo *getter_ident =
8142 &clang_ast.Idents.get(property_getter_name);
8143 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8145 const clang::IdentifierInfo *getter_ident =
8146 &clang_ast.Idents.get(property_name);
8147 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8149 property_decl->setGetterName(getter_sel);
8150 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
8153 property_decl->setPropertyIvarDecl(ivar_decl);
8155 if (property_attributes & DW_APPLE_PROPERTY_readonly)
8156 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
8157 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
8158 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
8159 if (property_attributes & DW_APPLE_PROPERTY_assign)
8160 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
8161 if (property_attributes & DW_APPLE_PROPERTY_retain)
8162 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
8163 if (property_attributes & DW_APPLE_PROPERTY_copy)
8164 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
8165 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8166 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
8167 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
8168 property_decl->setPropertyAttributes(
8169 ObjCPropertyAttribute::kind_nullability);
8170 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
8171 property_decl->setPropertyAttributes(
8172 ObjCPropertyAttribute::kind_null_resettable);
8173 if (property_attributes & ObjCPropertyAttribute::kind_class)
8174 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8176 const bool isInstance =
8177 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8179 clang::ObjCMethodDecl *getter =
nullptr;
8180 if (!getter_sel.isNull())
8181 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8182 : class_interface_decl->lookupClassMethod(getter_sel);
8183 if (!getter_sel.isNull() && !getter) {
8184 const bool isVariadic =
false;
8185 const bool isPropertyAccessor =
true;
8186 const bool isSynthesizedAccessorStub =
false;
8187 const bool isImplicitlyDeclared =
true;
8188 const bool isDefined =
false;
8189 const clang::ObjCImplementationControl impControl =
8190 clang::ObjCImplementationControl::None;
8191 const bool HasRelatedResultType =
false;
8194 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8195 getter->setDeclName(getter_sel);
8197 getter->setDeclContext(class_interface_decl);
8198 getter->setInstanceMethod(isInstance);
8199 getter->setVariadic(isVariadic);
8200 getter->setPropertyAccessor(isPropertyAccessor);
8201 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8202 getter->setImplicit(isImplicitlyDeclared);
8203 getter->setDefined(isDefined);
8204 getter->setDeclImplementation(impControl);
8205 getter->setRelatedResultType(HasRelatedResultType);
8209 ast->SetMetadata(getter, metadata);
8211 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8212 llvm::ArrayRef<clang::SourceLocation>());
8213 class_interface_decl->addDecl(getter);
8217 getter->setPropertyAccessor(
true);
8218 property_decl->setGetterMethodDecl(getter);
8221 clang::ObjCMethodDecl *setter =
nullptr;
8222 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8223 : class_interface_decl->lookupClassMethod(setter_sel);
8224 if (!setter_sel.isNull() && !setter) {
8225 clang::QualType result_type = clang_ast.VoidTy;
8226 const bool isVariadic =
false;
8227 const bool isPropertyAccessor =
true;
8228 const bool isSynthesizedAccessorStub =
false;
8229 const bool isImplicitlyDeclared =
true;
8230 const bool isDefined =
false;
8231 const clang::ObjCImplementationControl impControl =
8232 clang::ObjCImplementationControl::None;
8233 const bool HasRelatedResultType =
false;
8236 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8237 setter->setDeclName(setter_sel);
8238 setter->setReturnType(result_type);
8239 setter->setDeclContext(class_interface_decl);
8240 setter->setInstanceMethod(isInstance);
8241 setter->setVariadic(isVariadic);
8242 setter->setPropertyAccessor(isPropertyAccessor);
8243 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8244 setter->setImplicit(isImplicitlyDeclared);
8245 setter->setDefined(isDefined);
8246 setter->setDeclImplementation(impControl);
8247 setter->setRelatedResultType(HasRelatedResultType);
8251 ast->SetMetadata(setter, metadata);
8253 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8254 params.push_back(clang::ParmVarDecl::Create(
8255 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8258 clang::SC_Auto,
nullptr));
8260 setter->setMethodParams(clang_ast,
8261 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8262 llvm::ArrayRef<clang::SourceLocation>());
8264 class_interface_decl->addDecl(setter);
8268 setter->setPropertyAccessor(
true);
8269 property_decl->setSetterMethodDecl(setter);
8280 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8281 bool is_objc_direct_call) {
8282 if (!type || !method_clang_type.
IsValid())
8287 if (class_interface_decl ==
nullptr)
8290 if (lldb_ast ==
nullptr)
8292 clang::ASTContext &ast = lldb_ast->getASTContext();
8294 const char *selector_start = ::strchr(name,
' ');
8295 if (selector_start ==
nullptr)
8299 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8304 unsigned num_selectors_with_args = 0;
8305 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8307 len = ::strcspn(start,
":]");
8308 bool has_arg = (start[len] ==
':');
8310 ++num_selectors_with_args;
8311 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8316 if (selector_idents.size() == 0)
8319 clang::Selector method_selector = ast.Selectors.getSelector(
8320 num_selectors_with_args ? selector_idents.size() : 0,
8321 selector_idents.data());
8326 const clang::Type *method_type(method_qual_type.getTypePtr());
8328 if (method_type ==
nullptr)
8331 const clang::FunctionProtoType *method_function_prototype(
8332 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8334 if (!method_function_prototype)
8337 const bool isInstance = (name[0] ==
'-');
8338 const bool isVariadic = is_variadic;
8339 const bool isPropertyAccessor =
false;
8340 const bool isSynthesizedAccessorStub =
false;
8342 const bool isImplicitlyDeclared =
true;
8343 const bool isDefined =
false;
8344 const clang::ObjCImplementationControl impControl =
8345 clang::ObjCImplementationControl::None;
8346 const bool HasRelatedResultType =
false;
8348 const unsigned num_args = method_function_prototype->getNumParams();
8350 if (num_args != num_selectors_with_args)
8354 auto *objc_method_decl =
8355 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8356 objc_method_decl->setDeclName(method_selector);
8357 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8358 objc_method_decl->setDeclContext(
8360 objc_method_decl->setInstanceMethod(isInstance);
8361 objc_method_decl->setVariadic(isVariadic);
8362 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8363 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8364 objc_method_decl->setImplicit(isImplicitlyDeclared);
8365 objc_method_decl->setDefined(isDefined);
8366 objc_method_decl->setDeclImplementation(impControl);
8367 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8370 if (objc_method_decl ==
nullptr)
8374 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8376 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8377 params.push_back(clang::ParmVarDecl::Create(
8378 ast, objc_method_decl, clang::SourceLocation(),
8379 clang::SourceLocation(),
8381 method_function_prototype->getParamType(param_index),
nullptr,
8382 clang::SC_Auto,
nullptr));
8385 objc_method_decl->setMethodParams(
8386 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8387 llvm::ArrayRef<clang::SourceLocation>());
8390 if (is_objc_direct_call) {
8393 objc_method_decl->addAttr(
8394 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8399 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8402 class_interface_decl->addDecl(objc_method_decl);
8404 VerifyDecl(objc_method_decl);
8406 return objc_method_decl;
8416 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8417 switch (type_class) {
8418 case clang::Type::Record: {
8419 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8420 if (cxx_record_decl) {
8421 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8422 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8427 case clang::Type::Enum: {
8428 clang::EnumDecl *enum_decl =
8429 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8431 enum_decl->setHasExternalLexicalStorage(has_extern);
8432 enum_decl->setHasExternalVisibleStorage(has_extern);
8437 case clang::Type::ObjCObject:
8438 case clang::Type::ObjCInterface: {
8439 const clang::ObjCObjectType *objc_class_type =
8440 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8441 assert(objc_class_type);
8442 if (objc_class_type) {
8443 clang::ObjCInterfaceDecl *class_interface_decl =
8444 objc_class_type->getInterface();
8446 if (class_interface_decl) {
8447 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8448 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8464 if (!qual_type.isNull()) {
8465 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8467 clang::TagDecl *tag_decl = tag_type->getDecl();
8469 tag_decl->startDefinition();
8474 const clang::ObjCObjectType *object_type =
8475 qual_type->getAs<clang::ObjCObjectType>();
8477 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8478 if (interface_decl) {
8479 interface_decl->startDefinition();
8490 if (qual_type.isNull())
8494 if (lldb_ast ==
nullptr)
8500 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8502 clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinitionOrSelf();
8504 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8514 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8515 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8516 if (cxx_record_decl->needsImplicitCopyConstructor())
8517 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8518 if (cxx_record_decl->needsImplicitCopyAssignment())
8519 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8522 if (!cxx_record_decl->isCompleteDefinition())
8523 cxx_record_decl->completeDefinition();
8524 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8525 cxx_record_decl->setHasExternalLexicalStorage(
false);
8526 cxx_record_decl->setHasExternalVisibleStorage(
false);
8527 lldb_ast->SetCXXRecordDeclAccess(cxx_record_decl,
8528 clang::AccessSpecifier::AS_none);
8533 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8537 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8539 if (enum_decl->isCompleteDefinition())
8542 QualType integer_type(enum_decl->getIntegerType());
8543 if (!integer_type.isNull()) {
8544 clang::ASTContext &ast = lldb_ast->getASTContext();
8546 unsigned NumNegativeBits = 0;
8547 unsigned NumPositiveBits = 0;
8548 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8551 clang::QualType BestPromotionType;
8552 clang::QualType BestType;
8553 ast.computeBestEnumTypes(
false, NumNegativeBits,
8554 NumPositiveBits, BestType, BestPromotionType);
8556 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8557 BestPromotionType, NumPositiveBits,
8565 const llvm::APSInt &value) {
8576 if (!enum_opaque_compiler_type)
8579 clang::QualType enum_qual_type(
8582 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8587 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8592 clang::EnumConstantDecl *enumerator_decl =
8593 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8595 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8596 enumerator_decl->setDeclContext(enum_decl);
8597 if (name && name[0])
8598 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8599 enumerator_decl->setType(clang::QualType(enutype, 0));
8603 if (!enumerator_decl)
8606 enum_decl->addDecl(enumerator_decl);
8608 VerifyDecl(enumerator_decl);
8609 return enumerator_decl;
8614 uint64_t enum_value, uint32_t enum_value_bit_size) {
8616 llvm::APSInt value(enum_value_bit_size,
8625 const clang::Type *clang_type = qt.getTypePtrOrNull();
8626 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8630 return GetType(enum_type->getDecl()->getDefinitionOrSelf()->getIntegerType());
8636 if (type && pointee_type.
IsValid() &&
8641 return ast->GetType(ast->getASTContext().getMemberPointerType(
8650#define DEPTH_INCREMENT 2
8653LLVM_DUMP_METHOD
void
8663struct ScopedASTColor {
8664 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8665 : ast(ast), old_show_colors(ast.getDiagnostics().getShowColors()) {
8666 ast.getDiagnostics().setShowColors(show_colors);
8669 ~ScopedASTColor() { ast.getDiagnostics().setShowColors(old_show_colors); }
8671 clang::ASTContext *
8672 const bool old_show_colors;
8681 clang::CreateASTDumper(output, filter,
8685 false, clang::ADOF_Default);
8688 consumer->HandleTranslationUnit(*
m_ast_up);
8692 llvm::StringRef symbol_name) {
8699 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8700 size_t ntypes = type_list.
GetSize();
8702 for (
size_t i = 0; i < ntypes; ++i) {
8705 if (!symbol_name.empty())
8706 if (symbol_name != type->GetName().GetStringRef())
8709 s << type->GetName().AsCString() <<
"\n";
8712 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8720 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8722 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8734 size_t byte_size, uint32_t bitfield_bit_offset,
8735 uint32_t bitfield_bit_size) {
8736 const clang::EnumType *enutype =
8737 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8738 const clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8740 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8741 const uint64_t enum_svalue =
8744 bitfield_bit_offset)
8746 bitfield_bit_offset);
8747 bool can_be_bitfield =
true;
8748 uint64_t covered_bits = 0;
8749 int num_enumerators = 0;
8757 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8758 if (enumerators.empty())
8759 can_be_bitfield =
false;
8761 for (
auto *enumerator : enumerators) {
8762 llvm::APSInt init_val = enumerator->getInitVal();
8763 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8764 : init_val.getZExtValue();
8765 if (qual_type_is_signed)
8766 val = llvm::SignExtend64(val, 8 * byte_size);
8767 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8768 can_be_bitfield =
false;
8769 covered_bits |= val;
8771 if (val == enum_svalue) {
8780 offset = byte_offset;
8782 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8786 if (!can_be_bitfield) {
8787 if (qual_type_is_signed)
8788 s.
Printf(
"%" PRIi64, enum_svalue);
8790 s.
Printf(
"%" PRIu64, enum_uvalue);
8797 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8801 uint64_t remaining_value = enum_uvalue;
8802 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8803 values.reserve(num_enumerators);
8804 for (
auto *enumerator : enum_decl->enumerators())
8805 if (
auto val = enumerator->getInitVal().getZExtValue())
8806 values.emplace_back(val, enumerator->getName());
8811 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8812 return llvm::popcount(a.first) > llvm::popcount(b.first);
8815 for (
const auto &val : values) {
8816 if ((remaining_value & val.first) != val.first)
8818 remaining_value &= ~val.first;
8820 if (remaining_value)
8826 if (remaining_value)
8827 s.
Printf(
"0x%" PRIx64, remaining_value);
8835 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8844 switch (qual_type->getTypeClass()) {
8845 case clang::Type::Typedef: {
8846 clang::QualType typedef_qual_type =
8847 llvm::cast<clang::TypedefType>(qual_type)
8849 ->getUnderlyingType();
8852 format = typedef_clang_type.
GetFormat();
8853 clang::TypeInfo typedef_type_info =
8855 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8865 bitfield_bit_offset,
8870 case clang::Type::Enum:
8875 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8876 bitfield_bit_offset, bitfield_bit_size);
8884 uint32_t item_count = 1;
8924 item_count = byte_size;
8929 item_count = byte_size / 2;
8934 item_count = byte_size / 4;
8940 bitfield_bit_size, bitfield_bit_offset,
8956 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(clang_type)) {
8965 clang::QualType qual_type =
8968 llvm::SmallVector<char, 1024> buf;
8969 llvm::raw_svector_ostream llvm_ostrm(buf);
8971 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8972 switch (type_class) {
8973 case clang::Type::ObjCObject:
8974 case clang::Type::ObjCInterface: {
8977 auto *objc_class_type =
8978 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8979 assert(objc_class_type);
8980 if (!objc_class_type)
8982 clang::ObjCInterfaceDecl *class_interface_decl =
8983 objc_class_type->getInterface();
8984 if (!class_interface_decl)
8987 class_interface_decl->dump(llvm_ostrm);
8989 class_interface_decl->print(llvm_ostrm,
8994 case clang::Type::Typedef: {
8995 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8998 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
9000 typedef_decl->dump(llvm_ostrm);
9003 if (!clang_typedef_name.empty()) {
9010 case clang::Type::Record: {
9013 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
9014 const clang::RecordDecl *record_decl = record_type->getDecl();
9016 record_decl->dump(llvm_ostrm);
9018 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
9024 if (
auto *tag_type =
9025 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
9026 if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
9028 tag_decl->dump(llvm_ostrm);
9030 tag_decl->print(llvm_ostrm, 0);
9036 std::string clang_type_name(qual_type.getAsString());
9037 if (!clang_type_name.empty())
9044 if (buf.size() > 0) {
9045 s.
Write(buf.data(), buf.size());
9052 clang::QualType qual_type(
9055 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
9056 switch (type_class) {
9057 case clang::Type::Record: {
9058 const clang::CXXRecordDecl *cxx_record_decl =
9059 qual_type->getAsCXXRecordDecl();
9060 if (cxx_record_decl)
9061 printf(
"class %s", cxx_record_decl->getName().str().c_str());
9064 case clang::Type::Enum: {
9065 clang::EnumDecl *enum_decl =
9066 llvm::cast<clang::EnumType>(qual_type)->getDecl();
9068 printf(
"enum %s", enum_decl->getName().str().c_str());
9072 case clang::Type::ObjCObject:
9073 case clang::Type::ObjCInterface: {
9074 const clang::ObjCObjectType *objc_class_type =
9075 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
9076 if (objc_class_type) {
9077 clang::ObjCInterfaceDecl *class_interface_decl =
9078 objc_class_type->getInterface();
9082 if (class_interface_decl)
9083 printf(
"@class %s", class_interface_decl->getName().str().c_str());
9087 case clang::Type::Typedef:
9088 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
9095 case clang::Type::Auto:
9098 llvm::cast<clang::AutoType>(qual_type)
9100 .getAsOpaquePtr()));
9102 case clang::Type::Paren:
9106 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
9109 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
9119 if (template_param_infos.
IsValid()) {
9120 std::string template_basename(parent_name);
9122 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
9123 template_basename.erase(i);
9126 template_basename.c_str(), tag_decl_kind,
9127 template_param_infos);
9142 clang::ObjCInterfaceDecl *decl) {
9170 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9171 uint64_t &alignment,
9172 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9173 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9175 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9188 field_offsets, base_offsets, vbase_offsets);
9195 clang::NamedDecl *nd =
9196 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9206 if (!label_or_err) {
9207 llvm::consumeError(label_or_err.takeError());
9211 llvm::StringRef mangled = label_or_err->lookup_name;
9219 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9220 static_cast<clang::Decl *
>(opaque_decl));
9222 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9226 if (!mc || !mc->shouldMangleCXXName(nd))
9231 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9236 llvm::SmallVector<char, 1024> buf;
9237 llvm::raw_svector_ostream llvm_ostrm(buf);
9238 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9240 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9243 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9245 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9249 mc->mangleName(nd, llvm_ostrm);
9265 if (clang::FunctionDecl *func_decl =
9266 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9267 return GetType(func_decl->getReturnType());
9268 if (clang::ObjCMethodDecl *objc_method =
9269 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9270 return GetType(objc_method->getReturnType());
9276 if (clang::FunctionDecl *func_decl =
9277 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9278 return func_decl->param_size();
9279 if (clang::ObjCMethodDecl *objc_method =
9280 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9281 return objc_method->param_size();
9287 clang::DeclContext
const *decl_ctx) {
9288 switch (clang_kind) {
9289 case Decl::TranslationUnit:
9291 case Decl::Namespace:
9302 if (decl_ctx->isFunctionOrMethod())
9304 if (decl_ctx->isRecord())
9314 std::vector<lldb_private::CompilerContext> &context) {
9315 if (decl_ctx ==
nullptr)
9318 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9319 if (clang_kind == Decl::TranslationUnit)
9324 context.push_back({compiler_kind, decl_ctx_name});
9327std::vector<lldb_private::CompilerContext>
9329 std::vector<lldb_private::CompilerContext> context;
9332 clang::Decl *decl = (clang::Decl *)opaque_decl;
9334 clang::DeclContext *decl_ctx = decl->getDeclContext();
9337 auto compiler_kind =
9339 context.push_back({compiler_kind, decl_name});
9346 if (clang::FunctionDecl *func_decl =
9347 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9348 if (idx < func_decl->param_size()) {
9349 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9351 return GetType(var_decl->getOriginalType());
9353 }
else if (clang::ObjCMethodDecl *objc_method =
9354 llvm::dyn_cast<clang::ObjCMethodDecl>(
9355 (clang::Decl *)opaque_decl)) {
9356 if (idx < objc_method->param_size())
9357 return GetType(objc_method->parameters()[idx]->getOriginalType());
9363 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9364 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9367 clang::Expr *init_expr = var_decl->getInit();
9370 std::optional<llvm::APSInt> value =
9380 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9381 std::vector<CompilerDecl> found_decls;
9383 if (opaque_decl_ctx && symbol_file) {
9384 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9385 std::set<DeclContext *> searched;
9386 std::multimap<DeclContext *, DeclContext *> search_queue;
9388 for (clang::DeclContext *decl_context = root_decl_ctx;
9389 decl_context !=
nullptr && found_decls.empty();
9390 decl_context = decl_context->getParent()) {
9391 search_queue.insert(std::make_pair(decl_context, decl_context));
9393 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9395 if (!searched.insert(it->second).second)
9400 for (clang::Decl *child : it->second->decls()) {
9401 if (clang::UsingDirectiveDecl *ud =
9402 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9403 if (ignore_using_decls)
9405 clang::DeclContext *from = ud->getCommonAncestor();
9406 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9407 search_queue.insert(
9408 std::make_pair(from, ud->getNominatedNamespace()));
9409 }
else if (clang::UsingDecl *ud =
9410 llvm::dyn_cast<clang::UsingDecl>(child)) {
9411 if (ignore_using_decls)
9413 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9414 clang::Decl *target = usd->getTargetDecl();
9415 if (clang::NamedDecl *nd =
9416 llvm::dyn_cast<clang::NamedDecl>(target)) {
9417 IdentifierInfo *ii = nd->getIdentifier();
9418 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9422 }
else if (clang::NamedDecl *nd =
9423 llvm::dyn_cast<clang::NamedDecl>(child)) {
9424 IdentifierInfo *ii = nd->getIdentifier();
9425 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9476 clang::DeclContext *child_decl_ctx,
9480 if (frame_decl_ctx && symbol_file) {
9481 std::set<DeclContext *> searched;
9482 std::multimap<DeclContext *, DeclContext *> search_queue;
9485 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9489 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9490 decl_ctx = decl_ctx->getParent()) {
9491 if (!decl_ctx->isLookupContext())
9493 if (decl_ctx == parent_decl_ctx)
9496 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9497 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9499 if (searched.find(it->second) != searched.end())
9507 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9510 searched.insert(it->second);
9514 for (clang::Decl *child : it->second->decls()) {
9515 if (clang::UsingDirectiveDecl *ud =
9516 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9517 clang::DeclContext *ns = ud->getNominatedNamespace();
9518 if (ns == parent_decl_ctx)
9521 clang::DeclContext *from = ud->getCommonAncestor();
9522 if (searched.find(ns) == searched.end())
9523 search_queue.insert(std::make_pair(from, ns));
9524 }
else if (child_name) {
9525 if (clang::UsingDecl *ud =
9526 llvm::dyn_cast<clang::UsingDecl>(child)) {
9527 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9528 clang::Decl *target = usd->getTargetDecl();
9529 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9533 IdentifierInfo *ii = nd->getIdentifier();
9534 if (ii ==
nullptr ||
9535 ii->getName() != child_name->
AsCString(
nullptr))
9558 if (opaque_decl_ctx) {
9559 clang::NamedDecl *named_decl =
9560 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9563 llvm::raw_string_ostream stream{name};
9565 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9566 named_decl->getNameForDiagnostic(stream, policy,
false);
9575 if (opaque_decl_ctx) {
9576 clang::NamedDecl *named_decl =
9577 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9585 if (!opaque_decl_ctx)
9588 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9589 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9591 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9593 }
else if (clang::FunctionDecl *fun_decl =
9594 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9595 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9596 return metadata->HasObjectPtr();
9602std::vector<lldb_private::CompilerContext>
9604 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9605 std::vector<lldb_private::CompilerContext> context;
9611 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9612 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9613 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9617 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9618 if (DC->isInlineNamespace())
9621 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9622 return NS->isAnonymousNamespace();
9629 if (decl_ctx == other)
9631 }
while (is_transparent_lookup_allowed(other) &&
9632 (other = other->getParent()));
9639 if (!opaque_decl_ctx)
9642 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9643 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9645 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9647 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9648 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9649 return metadata->GetObjectPtrLanguage();
9669 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9677 return llvm::dyn_cast<clang::CXXMethodDecl>(
9682clang::FunctionDecl *
9685 return llvm::dyn_cast<clang::FunctionDecl>(
9690clang::NamespaceDecl *
9693 return llvm::dyn_cast<clang::NamespaceDecl>(
9698std::optional<ClangASTMetadata>
9700 const Decl *
object) {
9708 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9730 lldbassert(started &&
"Unable to start a class type definition.");
9735 ts->SetDeclIsForcefullyCompleted(td);
9749 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9750 std::unique_ptr<ClangASTSource> ast_source)
9752 m_scratch_ast_source_up(std::move(ast_source)) {
9754 m_scratch_ast_source_up->InstallASTContext(*
this);
9755 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9756 m_scratch_ast_source_up->CreateProxy();
9757 SetExternalSource(proxy_ast_source);
9761 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9769 llvm::Triple triple)
9776 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9788 std::optional<IsolatedASTKind> ast_kind,
9789 bool create_on_demand) {
9792 if (
auto err = type_system_or_err.takeError()) {
9794 "Couldn't get scratch TypeSystemClang: {0}");
9797 auto ts_sp = *type_system_or_err;
9799 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9804 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9806 return std::static_pointer_cast<TypeSystemClang>(
9811static llvm::StringRef
9815 return "C++ modules";
9817 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9821 llvm::StringRef filter,
bool show_color) {
9823 output <<
"State of scratch Clang type system:\n";
9827 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9828 std::vector<KeyAndTS> sorted_typesystems;
9830 sorted_typesystems.emplace_back(a.first, a.second.get());
9831 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9834 for (
const auto &a : sorted_typesystems) {
9837 output <<
"State of scratch Clang type subsystem "
9839 a.second->Dump(output, filter, show_color);
9844 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9852 desired_type, options, ctx_obj);
9857 const ValueList &arg_value_list,
const char *name) {
9862 Process *process = target_sp->GetProcessSP().get();
9867 arg_value_list, name);
9870std::unique_ptr<UtilityFunction>
9877 return std::make_unique<ClangUtilityFunction>(
9878 *target_sp.get(), std::move(text), std::move(name),
9879 target_sp->GetDebugUtilityExpression());
9893 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9897 return std::make_unique<ClangASTSource>(
9902static llvm::StringRef
9906 return "scratch ASTContext for C++ module types";
9908 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9915 return *found_ast->second;
9918 std::shared_ptr<TypeSystemClang> new_ast_sp =
9928 const clang::RecordType *record_type =
9929 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9931 const clang::RecordDecl *record_decl =
9932 record_type->getDecl()->getDefinitionOrSelf();
9933 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9934 return metadata->IsForcefullyCompleted();
9943 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9947 metadata->SetIsForcefullyCompleted();
9955 LLDB_LOG(log,
"Created new TypeSystem for (ASTContext*){0:x} '{1}'",
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
static bool DumpEnumValue(const clang::QualType &qual_type, Stream &s, const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_offset, uint32_t bitfield_bit_size)
static lldb::opaque_compiler_type_t GetObjCFieldAtIndex(clang::ASTContext *ast, clang::ObjCInterfaceDecl *class_interface_decl, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr)
static void ParseLangArgs(LangOptions &Opts, ArchSpec arch)
static clang::QualType GetFullyUnqualifiedType_Impl(clang::ASTContext *ast, clang::QualType qual_type)
const TemplateArgument * GetNthTemplateArgument(const clang::ClassTemplateSpecializationDecl *decl, size_t idx, bool expand_pack)
static int64_t ReadVBaseOffsetFromVTable(Process &process, VTableContextBase &vtable_ctx, lldb::addr_t vtable_ptr, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl)
static const clang::RecordType * GetCompleteRecordType(clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion)
Returns the clang::RecordType of the specified qual_type.
lldb_private::ThreadSafeDenseMap< clang::ASTContext *, TypeSystemClang * > ClangASTMap
static bool IsClangDeclContext(const CompilerDeclContext &dc)
static bool TemplateParameterAllowsValue(NamedDecl *param, const TemplateArgument &value)
Returns true if the given template parameter can represent the given value.
static CompilerContextKind GetCompilerKind(clang::Decl::Kind clang_kind, clang::DeclContext const *decl_ctx)
static QualType RemoveWrappingTypes(QualType type, ArrayRef< clang::Type::TypeClass > mask={})
Aggressively desugar the provided type, skipping past various kinds of syntactic sugar and other cons...
static TemplateParameterList * CreateTemplateParameterList(ASTContext &ast, const TypeSystemClang::TemplateParameterInfos &template_param_infos, llvm::SmallVector< NamedDecl *, 8 > &template_param_decls)
clang::DeclContext * FindLCABetweenDecls(clang::DeclContext *left, clang::DeclContext *right, clang::DeclContext *root)
static bool check_op_param(bool is_method, clang::OverloadedOperatorKind op_kind, bool unary, bool binary, uint32_t num_params)
static llvm::StringRef GetSpecializedASTName(ScratchTypeSystemClang::IsolatedASTKind feature)
static bool ObjCDeclHasIVars(clang::ObjCInterfaceDecl *class_interface_decl)
static const clang::ObjCObjectType * GetCompleteObjCObjectType(clang::ASTContext *ast, QualType qual_type, bool allow_completion)
Returns the clang::ObjCObjectType of the specified qual_type.
static lldb::addr_t GetVTableAddress(Process &process, VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout)
static clang::ObjCIvarDecl::AccessControl ConvertAccessTypeToObjCIvarAccessControl(AccessType access)
static std::optional< SymbolFile::ArrayInfo > GetDynamicArrayInfo(TypeSystemClang &ast, SymbolFile *sym_file, clang::QualType qual_type, const ExecutionContext *exe_ctx)
static ConstString ExtractMangledNameFromFunctionCallLabel(llvm::StringRef label)
static llvm::StringRef GetNameForIsolatedASTKind(ScratchTypeSystemClang::IsolatedASTKind kind)
Returns a human-readable name that uniquely identifiers the sub-AST kind.
static void InsertCompilerContext(TypeSystemClang *ts, clang::DeclContext *decl_ctx, std::vector< lldb_private::CompilerContext > &context)
static bool GetVBaseBitOffset(VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl, int32_t &bit_offset)
static const clang::EnumType * GetCompleteEnumType(clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion)
Returns the clang::EnumType of the specified qual_type.
static bool QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext &ast, QualType qual_type)
static ClangASTMap & GetASTMap()
static bool GetCompleteQualType(clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion=true)
static void SetMemberOwningModule(clang::Decl *member, const clang::Decl *parent)
static bool ClassTemplateAllowsToInstantiationArgs(ClassTemplateDecl *class_template_decl, const TypeSystemClang::TemplateParameterInfos &instantiation_values)
Returns true if the given class template declaration could produce an instantiation with the specifie...
#define LLDB_INVALID_DECL_LEVEL
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &info) override
DiagnosticConsumer * clone(DiagnosticsEngine &Diags) const
A section + offset based address class.
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool CharIsSignedByDefault() const
Returns true if 'char' is a signed type by default in the architecture false otherwise.
Manages and observes all Clang AST node importing in LLDB.
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &bit_size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets)
void ForgetSource(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx)
"lldb/Expression/ClangFunctionCaller.h" Encapsulates a function that can be called.
"lldb/Expression/ClangPersistentVariables.h" Manages persistent values that need to be preserved betw...
"lldb/Expression/ClangUserExpression.h" Encapsulates a single expression for use with Clang
Represents a generic declaration context in a program.
TypeSystem * GetTypeSystem() const
void * GetOpaqueDeclContext() const
Represents a generic declaration such as a function declaration.
lldb::TypeSystemSP GetSharedPointer() const
Generic representation of a type in a programming language.
lldb::LanguageType GetMinimumLanguage()
bool IsEnumerationType(bool &is_signed) const
lldb::BasicType GetBasicTypeEnumeration() const
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
void SetCompilerType(lldb::TypeSystemWP type_system, lldb::opaque_compiler_type_t type)
size_t GetIndexOfChildMemberWithName(llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) const
Lookup a child member given a name.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
lldb::Encoding GetEncoding() const
bool IsPromotableIntegerType() const
uint32_t GetNumDirectBaseClasses() const
ConstString GetTypeName(bool BaseOnly=false) const
bool IsEnumerationIntegerTypeSigned() const
bool DumpTypeValue(Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope)
bool IsAggregateType() const
bool IsInteger() const
This is used when you don't care about the signedness of the integer.
lldb::Format GetFormat() const
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const
CompilerType GetDirectBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
bool GetCompleteType() const
Type Completion.
bool IsUnscopedEnumerationType() const
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
llvm::Expected< uint32_t > GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const
Lookup a child given a name.
llvm::Expected< uint32_t > GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
CompilerType GetCanonicalType() const
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const char * GetCString() const
Get the string value as a C string.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
A class that describes the declaration location of a lldb object.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
Process * GetProcessPtr() const
Returns a pointer to the process object.
static FileSystem & Instance()
bool Test(ValueType bit) const
Test a single flag bit.
bool AnySet(ValueType mask) const
Test one or more flags.
Encapsulates a function that can be called.
static bool LanguageIsC(lldb::LanguageType language)
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
static bool LanguageIsPascal(lldb::LanguageType language)
static bool LanguageIsObjC(lldb::LanguageType language)
static bool IsMangledName(llvm::StringRef name)
A class that describes an executable image and its associated object and symbol files.
virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type, const char *ivar_name)
static ObjCLanguageRuntime * Get(Process &process)
unsigned GetValue() const
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Status &error)
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
uint32_t GetAddressByteSize() const
void Finalize() override
Free up any resources associated with this TypeSystem.
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
llvm::Triple m_triple
The target triple.
std::unique_ptr< ClangASTSource > CreateASTSource()
lldb::TargetWP m_target_wp
TypeSystemClang & GetIsolatedAST(IsolatedASTKind feature)
Returns the requested sub-AST.
UserExpression * GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language, Expression::ResultType desired_type, const EvaluateExpressionOptions &options, ValueObject *ctx_obj) override
std::unique_ptr< ClangASTSource > m_scratch_ast_source_up
The ExternalASTSource that performs lookups and completes minimally imported types.
IsolatedASTKind
The different kinds of isolated ASTs within the scratch TypeSystem.
@ CppModules
The isolated AST for declarations/types from expressions that imported type information from a C++ mo...
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< ClangPersistentVariables > m_persistent_variables
The persistent variables associated with this process for the expression parser.
static char ID
LLVM RTTI support.
PersistentExpressionState * GetPersistentExpressionState() override
FunctionCaller * GetFunctionCaller(const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, const char *name) override
std::unique_ptr< UtilityFunction > CreateUtilityFunction(std::string text, std::string name) override
void ForgetSource(clang::ASTContext *src_ctx, ClangASTImporter &importer)
Unregisters the given ASTContext as a source from the scratch AST (and all sub-ASTs).
static const std::nullopt_t DefaultAST
Alias for requesting the default scratch TypeSystemClang in GetForTarget.
ScratchTypeSystemClang(Target &target, llvm::Triple triple)
llvm::DenseMap< IsolatedASTKey, std::shared_ptr< TypeSystemClang > > m_isolated_asts
Map from IsolatedASTKind to their actual TypeSystemClang instance.
bool Fail() const
Test for error condition.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
unsigned GetIndentLevel() const
Get the current indentation level.
Provides public interface for all SymbolFiles.
virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx)
virtual bool CompleteType(CompilerType &compiler_type)=0
virtual void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list)=0
virtual std::optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx)=0
If type_uid points to an array type, return its characteristics.
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
const ArchSpec & GetArchitecture() const
void Insert(_KeyType k, _ValueType v)
_ValueType Lookup(_KeyType k)
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
The implementation of lldb::Type's m_payload field for TypeSystemClang.
void SetIsCompleteObjCClass(bool is_complete_objc_class)
bool IsCompleteObjCClass()
Type::Payload m_payload
The payload is used for typedefs and ptrauth types.
TypePayloadClang()=default
void SetOwningModule(OptionalClangModuleID id)
static constexpr unsigned ObjCClassBit
llvm::ArrayRef< clang::TemplateArgument > GetParameterPackArgs() const
clang::TemplateArgument const & Front() const
llvm::StringRef GetPackName() const
bool hasParameterPack() const
TemplateParameterInfos const & GetParameterPack() const
llvm::ArrayRef< const char * > GetNames() const
llvm::ArrayRef< clang::TemplateArgument > GetArgs() const
A TypeSystem implementation based on Clang.
bool IsMemberFunctionPointerType(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeForIdentifier(const clang::ASTContext &Ctx, llvm::StringRef type_name, clang::DeclContext *decl_context=nullptr)
llvm::Expected< uint64_t > GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
CompilerType CreateFunctionType(const CompilerType &result_type, llvm::ArrayRef< CompilerType > args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
size_t GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) override
static clang::TypedefNameDecl * GetAsTypedefDecl(const CompilerType &type)
std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl, bool qualified=true)
Returns the internal type name for the given NamedDecl using the type printing policy.
static clang::ObjCInterfaceDecl * GetAsObjCInterfaceDecl(const CompilerType &type)
uint32_t m_pointer_byte_size
bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream &s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override
std::string m_display_name
A string describing what this TypeSystemClang represents (e.g., AST for debug information,...
ConstString GetTypeName(lldb::opaque_compiler_type_t type, bool base_only) override
static void SetOwningModule(clang::Decl *decl, OptionalClangModuleID owning_module)
Set the owning module for decl.
llvm::Expected< uint64_t > GetObjCBitSize(clang::QualType qual_type, ExecutionContextScope *exe_scope)
std::unique_ptr< clang::TargetInfo > m_target_info_up
std::unique_ptr< clang::LangOptions > m_language_options_up
Scalar DeclGetConstantValue(void *opaque_decl) override
llvm::Expected< CompilerType > GetDereferencedType(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, std::string &deref_name, uint32_t &deref_byte_size, int32_t &deref_byte_offset, ValueObject *valobj, uint64_t &language_flags) override
bool BaseSpecifierIsEmpty(const clang::CXXBaseSpecifier *b)
static uint32_t GetNumPointeeChildren(clang::QualType type)
ConstString DeclGetMangledName(void *opaque_decl) override
CompilerType GetBasicType(lldb::BasicType type)
clang::ClassTemplateDecl * CreateClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef class_name, int kind, const TemplateParameterInfos &infos)
std::unique_ptr< clang::HeaderSearchOptions > m_header_search_opts_up
clang::UsingDecl * CreateUsingDeclaration(clang::DeclContext *current_decl_ctx, OptionalClangModuleID owning_module, clang::NamedDecl *target)
static clang::AccessSpecifier ConvertAccessTypeToAccessSpecifier(lldb::AccessType access)
CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override
bool IsForcefullyCompleted(lldb::opaque_compiler_type_t type) override
bool SupportsLanguage(lldb::LanguageType language) override
uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override
OptionalClangModuleID GetOrCreateClangModule(llvm::StringRef name, OptionalClangModuleID parent, bool is_framework=false, bool is_explicit=false)
Synthesize a clang::Module and return its ID or a default-constructed ID.
void CompleteTagDecl(clang::TagDecl *)
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size)
std::shared_ptr< clang::TargetOptions > & getTargetOptions()
static TypeSystemClang * GetASTContext(clang::ASTContext *ast_ctx)
bool IsReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool *is_rvalue) override
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
const char * GetTargetTriple()
TypeSystemClang(llvm::StringRef name, llvm::Triple triple)
Constructs a TypeSystemClang with an ASTContext using the given triple.
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, Module *module, Target *target)
clang::TargetInfo * getTargetInfo()
clang::FunctionTemplateDecl * CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::FunctionDecl *func_decl, const TemplateParameterInfos &infos)
CompilerType CreateArrayType(const CompilerType &element_type, std::optional< size_t > element_count, bool is_vector)
static bool AreTypesSame(CompilerType type1, CompilerType type2, bool ignore_qualifiers=false)
CompilerType GetArrayType(lldb::opaque_compiler_type_t type, uint64_t size) override
bool IsFunctionType(lldb::opaque_compiler_type_t type) override
CompilerType GetFunctionReturnType(lldb::opaque_compiler_type_t type) override
std::optional< ClangASTMetadata > GetMetadata(const clang::Decl *object)
CompilerType GetLValueReferenceType(lldb::opaque_compiler_type_t type) override
bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td)
lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override
bool CanPassInRegisters(const CompilerType &type) override
CompilerDecl GetStaticFieldWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
bool IsEnumerationType(lldb::opaque_compiler_type_t type, bool &is_signed) override
bool IsTemplateType(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
static bool IsCXXClassType(const CompilerType &type)
bool IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed) override
void SetCXXRecordDeclAccess(const clang::CXXRecordDecl *object, clang::AccessSpecifier access)
uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override
static bool IsOperator(llvm::StringRef name, clang::OverloadedOperatorKind &op_kind)
bool IsCharType(lldb::opaque_compiler_type_t type) override
CompilerType CreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
static void SetFloatingInitializerForVariable(clang::VarDecl *var, const llvm::APFloat &init_value)
Initializes a variable with a floating point value.
uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) override
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) override
CompilerType GetType(clang::QualType qt)
Creates a CompilerType from the given QualType with the current TypeSystemClang instance as the Compi...
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override
std::string m_target_triple
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > bases)
bool IsBeingDefined(lldb::opaque_compiler_type_t type) override
ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override
std::unique_ptr< clang::IdentifierTable > m_identifier_table_up
static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name)
static void SetIntegerInitializerForVariable(clang::VarDecl *var, const llvm::APInt &init_value)
Initializes a variable with an integer value.
bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override
CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets)
bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::SourceManager > m_source_manager_up
bool IsVoidType(lldb::opaque_compiler_type_t type) override
static void SetIsPacked(const CompilerType &type)
void ForEachEnumerator(lldb::opaque_compiler_type_t type, std::function< bool(const CompilerType &integer_type, ConstString name, const llvm::APSInt &value)> const &callback) override
clang::AccessSpecifier GetCXXRecordDeclAccess(const clang::CXXRecordDecl *object)
CompilerType CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *class_template_specialization_decl)
bool IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
std::unique_ptr< clang::DiagnosticOptions > m_diagnostic_options_up
void CreateFunctionTemplateSpecializationInfo(clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template, const TemplateParameterInfos &infos)
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, uint64_t enum_value, uint32_t enum_value_bit_size)
llvm::StringRef getDisplayName() const
Returns the display name of this TypeSystemClang that indicates what purpose it serves in LLDB.
bool IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length)
CompilerType GetRValueReferenceType(lldb::opaque_compiler_type_t type) override
CompilerDecl GetCompilerDecl(clang::Decl *decl)
Creates a CompilerDecl from the given Decl with the current TypeSystemClang instance as its typesyste...
unsigned GetPtrAuthDiscriminator(lldb::opaque_compiler_type_t type) override
CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override
bool GetCompleteType(lldb::opaque_compiler_type_t type) override
bool IsBlockPointerType(lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) override
bool IsConst(lldb::opaque_compiler_type_t type) override
static clang::AccessSpecifier UnifyAccessSpecifiers(clang::AccessSpecifier lhs, clang::AccessSpecifier rhs)
std::unique_ptr< clang::CXXBaseSpecifier > CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class)
CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override
std::vector< CompilerDecl > DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_using_decls) override
const llvm::fltSemantics & GetFloatTypeSemantics(size_t byte_size, lldb::Format format) override
llvm::Expected< uint32_t > GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes) override
void setSema(clang::Sema *s)
uint32_t GetPointerByteSize() override
bool IsCompleteType(lldb::opaque_compiler_type_t type) override
CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed)
clang::MangleContext * getMangleContext()
void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *)
unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override
static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx)
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
CompilerType GetTypeForFormatters(void *type) override
void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id)
bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override
This is used by swift.
static LanguageSet GetSupportedLanguagesForExpressions()
clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, const CompilerType &function_Type, clang::StorageClass storage, bool is_inline, llvm::StringRef asm_label)
CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override
CompilerDeclContext GetCompilerDeclContextForType(const CompilerType &type) override
Returns the direct parent context of specified type.
std::unique_ptr< clang::SelectorTable > m_selector_table_up
PDBASTParser * GetPDBParser() override
std::optional< CompilerType::IntegralTemplateArgument > GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
bool DeclContextIsClassMethod(void *opaque_decl_ctx) override
void SetTargetTriple(llvm::StringRef target_triple)
CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
static bool CheckOverloadedOperatorKindParameterCount(bool is_method, clang::OverloadedOperatorKind op_kind, uint32_t num_params)
clang::DeclarationName GetDeclarationName(llvm::StringRef name, const CompilerType &function_clang_type)
DeclMetadataMap m_decl_metadata
Maps Decls to their associated ClangASTMetadata.
static clang::CXXMethodDecl * DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc)
CompilerType GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override
uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx, clang::DeclContext *child_decl_ctx, ConstString *child_name=nullptr, CompilerType *child_type=nullptr)
static clang::QualType GetQualType(lldb::opaque_compiler_type_t type)
clang::PrintingPolicy GetTypePrintingPolicy()
Returns the PrintingPolicy used when generating the internal type names.
uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override
static clang::RecordDecl * GetAsRecordDecl(const CompilerType &type)
CompilerType GetPointerSizedIntType(bool is_signed)
uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl, bool omit_empty_base_classes)
lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) override
std::unique_ptr< DWARFASTParserClang > m_dwarf_ast_parser_up
CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size)
lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type) override
bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override
int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override
static void BuildIndirectFields(const CompilerType &type)
std::unique_ptr< clang::FileManager > m_file_manager_up
uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl, const clang::CXXBaseSpecifier *base_spec, bool omit_empty_base_classes)
bool IsAnonymousType(lldb::opaque_compiler_type_t type) override
bool Verify(lldb::opaque_compiler_type_t type) override
Verify the integrity of the type to catch CompilerTypes that mix and match invalid TypeSystem/Opaque ...
size_t GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override
void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type)
CompilerType CreateBlockPointerType(const CompilerType &function_type)
lldb::LanguageType GetMinimumLanguage(lldb::opaque_compiler_type_t type) override
bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size)
clang::ClassTemplateSpecializationDecl * CreateClassTemplateSpecializationDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::ClassTemplateDecl *class_template_decl, int kind, const TemplateParameterInfos &infos)
llvm::SmallVector< clang::ParmVarDecl * > CreateParameterDeclarations(clang::FunctionDecl *context, const clang::FunctionProtoType &prototype, const llvm::SmallVector< llvm::StringRef > ¶m_names)
For each parameter type of prototype, creates a clang::ParmVarDecl whose clang::DeclContext is contex...
std::unique_ptr< clang::HeaderSearch > m_header_search_up
void Finalize() override
Free up any resources associated with this TypeSystem.
static clang::ASTContext * DeclContextGetTypeSystemClang(const CompilerDeclContext &dc)
uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, CompilerType *base_type_ptr) override
LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override
Convenience LLVM-style dump method for use in the debugger only.
CXXRecordDeclAccessMap m_cxx_record_decl_access
Maps CXXRecordDecl to their most recent added method/field's AccessSpecifier.
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
std::unique_ptr< clang::ASTContext > m_ast_up
CompilerType CreateGenericFunctionPrototype() override
static clang::QualType GetCanonicalQualType(lldb::opaque_compiler_type_t type)
CompilerType DeclGetFunctionReturnType(void *opaque_decl) override
static bool IsEnumType(lldb::opaque_compiler_type_t type)
std::unique_ptr< npdb::PdbAstBuilder > m_native_pdb_ast_parser_up
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
CompilerType GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static bool SetObjCSuperClass(const CompilerType &type, const CompilerType &superclass_compiler_type)
clang::UsingDirectiveDecl * CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::NamespaceDecl *ns_decl)
static lldb::opaque_compiler_type_t GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type)
bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override
void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name)
Dump clang AST types from the symbol file.
CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override
static void DumpDeclHiearchy(clang::Decl *decl)
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
static clang::FunctionDecl * DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc)
bool IsScalarType(lldb::opaque_compiler_type_t type) override
bool GetPtrAuthAddressDiversity(lldb::opaque_compiler_type_t type) override
std::shared_ptr< clang::TargetOptions > m_target_options_rp
lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override
static bool IsClassType(lldb::opaque_compiler_type_t type)
bool IsDefined(lldb::opaque_compiler_type_t type) override
static bool IsObjCClassType(const CompilerType &type)
TypeMetadataMap m_type_metadata
Maps Types to their associated ClangASTMetadata.
CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override
bool RecordHasFields(const clang::RecordDecl *record_decl)
CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index) override
static std::optional< ClangASTMetadata > DeclContextGetMetaData(const CompilerDeclContext &dc, const clang::Decl *object)
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override
static clang::ObjCMethodDecl * AddMethodToObjCObjectType(const CompilerType &type, const char *name, const CompilerType &method_compiler_type, bool is_artificial, bool is_variadic, bool is_objc_direct_call)
~TypeSystemClang() override
CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, std::optional< ClangASTMetadata > metadata=std::nullopt, bool exports_symbols=false)
bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, void *other_opaque_decl_ctx) override
CompilerType AddPtrAuthModifier(lldb::opaque_compiler_type_t type, uint32_t payload) override
static bool AddObjCClassProperty(const CompilerType &type, const char *property_name, const CompilerType &property_compiler_type, clang::ObjCIvarDecl *ivar_decl, const char *property_setter_name, const char *property_getter_name, uint32_t property_attributes, ClangASTMetadata metadata)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
void SetMetadata(const clang::Decl *object, ClangASTMetadata meta_data)
clang::ParmVarDecl * CreateParameterDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType ¶m_type, int storage, bool add_decl=false)
void DumpTypeDescription(lldb::opaque_compiler_type_t type, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) override
Dump the type to stdout.
CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
static clang::NamespaceDecl * DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped, std::optional< clang::EnumExtensibilityAttr::Kind > enum_kind=std::nullopt)
npdb::PdbAstBuilder * GetNativePDBParser() override
std::unique_ptr< clang::DiagnosticConsumer > m_diagnostic_consumer_up
CompilerType CreateObjCClass(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool isInternal, std::optional< ClangASTMetadata > metadata=std::nullopt)
CompilerType GetTypeForDecl(clang::NamedDecl *decl)
CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
llvm::Expected< CompilerType > DoIntegralPromotion(CompilerType from, ExecutionContextScope *exe_scope) override
Perform integral promotion on a given type.
static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc)
bool IsTypedefType(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override
std::optional< size_t > GetTypeBitAlign(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< clang::Builtin::Context > m_builtins_up
CompilerType GetBuiltinTypeByName(ConstString name) override
bool GetCompleteDecl(clang::Decl *decl)
static bool StartTagDeclarationDefinition(const CompilerType &type)
uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl, bool omit_empty_base_classes)
bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, CompilerType *target_type, bool check_cplusplus, bool check_objc) override
CompilerType GetOrCreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
void LogCreation() const
Emits information about this TypeSystem into the expression log.
static llvm::StringRef GetPluginNameStatic()
clang::Sema * m_sema
The sema associated that is currently used to build this ASTContext.
size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override
static clang::VarDecl * AddVariableToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &var_type, lldb::AccessType access)
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override
const clang::ClassTemplateSpecializationDecl * GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type)
std::unique_ptr< clang::MangleContext > m_mangle_ctx_up
TypeMemberFunctionImpl GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
bool IsTypeImpl(lldb::opaque_compiler_type_t type, llvm::function_ref< bool(clang::QualType)> predicate) const
size_t DeclGetFunctionNumArguments(void *opaque_decl) override
CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< PDBASTParser > m_pdb_ast_parser_up
std::unique_ptr< clang::DiagnosticsEngine > m_diagnostics_engine_up
static std::optional< std::string > GetCXXClassName(const CompilerType &type)
static void DumpTypeName(const CompilerType &type)
plugin::dwarf::DWARFASTParser * GetDWARFParser() override
CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx) override
bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
static clang::EnumDecl * GetAsEnumDecl(const CompilerType &type)
bool IsFloatingPointType(lldb::opaque_compiler_type_t type, bool &is_complex) override
CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::ModuleMap > m_module_map_up
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, llvm::StringRef asm_label, const CompilerType &method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
static bool IsObjCObjectOrInterfaceType(const CompilerType &type)
static void RequireCompleteType(CompilerType type)
Complete a type from debug info, or mark it as forcefully completed if there is no definition of the ...
CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload) override
Using the current type, create a new typedef to that type using "typedef_name" as the name and "decl_...
llvm::Expected< uint32_t > GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes, const ExecutionContext *exe_ctx) override
CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override
clang::TemplateTemplateParmDecl * CreateTemplateTemplateParmDecl(const char *template_name)
lldb::TemplateArgumentKind GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
clang::ClassTemplateDecl * ParseClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, const char *parent_name, int tag_decl_kind, const TypeSystemClang::TemplateParameterInfos &template_param_infos)
clang::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
std::vector< lldb_private::CompilerContext > DeclGetCompilerContext(void *opaque_decl) override
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
std::vector< lldb_private::CompilerContext > DeclContextGetCompilerContext(void *opaque_decl_ctx) override
void CreateASTContext()
Creates the internal ASTContext.
void SetExternalSource(llvm::IntrusiveRefCntPtr< clang::ExternalASTSource > ast_source_sp)
CompilerType GetCStringType(bool is_const)
bool IsAggregateType(lldb::opaque_compiler_type_t type) override
bool IsPromotableIntegerType(lldb::opaque_compiler_type_t type) override
Checks if the type is eligible for integral promotion.
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override
static LanguageSet GetSupportedLanguagesForTypes()
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
llvm::Expected< uint64_t > GetByteSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope)
ConstString DeclContextGetName(void *opaque_decl_ctx) override
size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack) override
ConstString DeclGetName(void *opaque_decl) override
virtual SymbolFile * GetSymbolFile() const
bool m_has_forcefully_completed_types
Used for reporting statistics.
Encapsulates a one-time expression for use in lldb.
virtual uint64_t GetData(DataExtractor &data, Status &error)
CompilerType GetCompilerType()
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
AddressType GetAddressTypeOfChildren()
ConstString GetName() const
const ExecutionContextRef & GetExecutionContextRef() const
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_IVAR_OFFSET
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, uint32_t item_bit_size, uint32_t item_bit_offset, ExecutionContextScope *exe_scope=nullptr, bool show_memory_tags=false)
Dumps item_count objects into the stream s.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
void * opaque_compiler_type_t
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eBasicTypeUnsignedShort
@ eBasicTypeUnsignedInt128
@ eBasicTypeUnsignedWChar
@ eBasicTypeLongDoubleComplex
@ eBasicTypeUnsignedLongLong
@ eBasicTypeDoubleComplex
Format
Display format definitions.
@ eFormatCString
NULL terminated C strings.
@ eFormatCharArray
Print characters with no single quotes, used for character arrays that can contain non printable char...
@ eFormatVoid
Do not print this.
@ eFormatComplex
Floating point complex type.
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
@ eFormatComplexInteger
Integer complex type.
@ eFormatFloat128
Disambiguate between 128-bit long double (which uses eFormatFloat) and __float128 (which uses eFormat...
LanguageType
Programming language type.
@ eLanguageTypeC_plus_plus_20
ISO C++:2020.
@ eLanguageTypeC_plus_plus_14
ISO C++:2014.
@ eLanguageTypeC11
ISO C:2011.
@ eLanguageTypeC99
ISO C:1999.
@ eLanguageTypeC_plus_plus_03
ISO C++:2003.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeC_plus_plus_17
ISO C++:2017.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
@ eLanguageTypeC_plus_plus_11
ISO C++:2011.
@ eLanguageTypeC89
ISO C:1989.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
@ eLanguageTypeDylan
Dylan.
std::shared_ptr< lldb_private::Type > TypeSP
@ eTemplateArgumentKindTemplate
@ eTemplateArgumentKindTemplateExpansion
@ eTemplateArgumentKindNull
@ eTemplateArgumentKindNullPtr
@ eTemplateArgumentKindDeclaration
@ eTemplateArgumentKindIntegral
@ eTemplateArgumentKindPack
@ eTemplateArgumentKindType
@ eTemplateArgumentKindStructuralValue
@ eTemplateArgumentKindExpression
Encoding
Register encoding definitions.
@ eEncodingVector
vector registers
@ eEncodingUint
unsigned integer
@ eEncodingSint
signed integer
MemberFunctionKind
Kind of member function.
@ eMemberFunctionKindInstanceMethod
A function that applies to a specific instance.
@ eMemberFunctionKindConstructor
A function used to create instances.
@ eMemberFunctionKindUnknown
Not sure what the type of this is.
@ eMemberFunctionKindDestructor
A function used to tear down existing instances.
@ eMemberFunctionKindStaticMethod
A function that applies to a type rather than any instance.
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Target > TargetSP
static clang::QualType GetQualType(const CompilerType &ct)
static clang::QualType GetCanonicalQualType(const CompilerType &ct)
static bool IsClangType(const CompilerType &ct)
static CompilerType RemoveFastQualifiers(const CompilerType &ct)
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
static llvm::Expected< FunctionCallLabel > fromString(llvm::StringRef label)
Decodes the specified function label into a FunctionCallLabel.
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
void Insert(lldb::LanguageType language)
A type-erased pair of llvm::dwarf::SourceLanguageName and version.