11#include "clang/AST/DeclBase.h"
12#include "clang/AST/ExprCXX.h"
13#include "clang/Frontend/ASTConsumers.h"
14#include "llvm/ADT/ScopeExit.h"
15#include "llvm/Support/Casting.h"
16#include "llvm/Support/FormatAdapters.h"
17#include "llvm/Support/FormatVariadic.h"
24#include "clang/AST/ASTContext.h"
25#include "clang/AST/ASTImporter.h"
26#include "clang/AST/Attr.h"
27#include "clang/AST/CXXInheritance.h"
28#include "clang/AST/DeclObjC.h"
29#include "clang/AST/DeclTemplate.h"
30#include "clang/AST/Mangle.h"
31#include "clang/AST/QualTypeNames.h"
32#include "clang/AST/RecordLayout.h"
33#include "clang/AST/Type.h"
34#include "clang/AST/VTableBuilder.h"
35#include "clang/Basic/Builtins.h"
36#include "clang/Basic/Diagnostic.h"
37#include "clang/Basic/FileManager.h"
38#include "clang/Basic/FileSystemOptions.h"
39#include "clang/Basic/LangStandard.h"
40#include "clang/Basic/SourceManager.h"
41#include "clang/Basic/TargetInfo.h"
42#include "clang/Basic/TargetOptions.h"
43#include "clang/Frontend/FrontendOptions.h"
44#include "clang/Lex/HeaderSearch.h"
45#include "clang/Lex/HeaderSearchOptions.h"
46#include "clang/Lex/ModuleMap.h"
47#include "clang/Sema/Sema.h"
49#include "llvm/Support/Signals.h"
50#include "llvm/Support/Threading.h"
94using namespace llvm::dwarf;
96using llvm::StringSwitch;
101static void VerifyDecl(clang::Decl *decl) {
102 assert(decl &&
"VerifyDecl called with nullptr?");
128bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) {
130 lldbassert(&m1->getASTContext() == &m2->getASTContext() &&
131 "Methods should have the same AST context");
132 clang::ASTContext &context = m1->getASTContext();
134 const auto *m1Type = llvm::cast<clang::FunctionProtoType>(
135 context.getCanonicalType(m1->getType()));
137 const auto *m2Type = llvm::cast<clang::FunctionProtoType>(
138 context.getCanonicalType(m2->getType()));
140 auto compareArgTypes = [&context](
const clang::QualType &m1p,
141 const clang::QualType &m2p) {
142 return context.hasSameType(m1p.getUnqualifiedType(),
143 m2p.getUnqualifiedType());
148 return (m1->getNumParams() != m2->getNumParams()) ||
149 !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(),
150 m2Type->param_type_begin(), compareArgTypes);
156void addOverridesForMethod(clang::CXXMethodDecl *decl) {
157 if (!decl->isVirtual())
160 clang::CXXBasePaths paths;
161 llvm::SmallVector<clang::NamedDecl *, 4> decls;
163 auto find_overridden_methods =
164 [&decls, decl](
const clang::CXXBaseSpecifier *specifier,
165 clang::CXXBasePath &path) {
166 if (
auto *base_record = specifier->getType()->getAsCXXRecordDecl()) {
168 clang::DeclarationName name = decl->getDeclName();
172 if (name.getNameKind() == clang::DeclarationName::CXXDestructorName)
173 if (
auto *baseDtorDecl = base_record->getDestructor()) {
174 if (baseDtorDecl->isVirtual()) {
175 decls.push_back(baseDtorDecl);
182 for (path.Decls = base_record->lookup(name).begin();
183 path.Decls != path.Decls.end(); ++path.Decls) {
184 if (
auto *method_decl =
185 llvm::dyn_cast<clang::CXXMethodDecl>(*path.Decls))
186 if (method_decl->isVirtual() && !isOverload(decl, method_decl)) {
187 decls.push_back(method_decl);
196 if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) {
197 for (
auto *overridden_decl : decls)
198 decl->addOverriddenMethod(
199 llvm::cast<clang::CXXMethodDecl>(overridden_decl));
205 VTableContextBase &vtable_ctx,
207 const ASTRecordLayout &record_layout) {
211 uint32_t type_info = this_type.
GetTypeInfo(&pointee_type);
216 bool ptr_or_ref =
false;
217 if (type_info & (eTypeIsPointer | eTypeIsReference)) {
223 const uint32_t cpp_class = eTypeIsClass | eTypeIsCPlusPlus;
224 if ((type_info & cpp_class) != cpp_class)
229 vtable_ctx.isMicrosoft() ? record_layout.getVBPtrOffset().getQuantity()
243 vbtable_ptr_addr += vbtable_ptr_offset;
254 auto size = valobj.
GetData(data, err);
262 VTableContextBase &vtable_ctx,
264 const CXXRecordDecl *cxx_record_decl,
265 const CXXRecordDecl *base_class_decl) {
266 if (vtable_ctx.isMicrosoft()) {
267 clang::MicrosoftVTableContext &msoft_vtable_ctx =
268 static_cast<clang::MicrosoftVTableContext &
>(vtable_ctx);
272 const unsigned vbtable_index =
273 msoft_vtable_ctx.getVBTableIndex(cxx_record_decl, base_class_decl);
274 const lldb::addr_t base_offset_addr = vtable_ptr + vbtable_index * 4;
280 clang::ItaniumVTableContext &itanium_vtable_ctx =
281 static_cast<clang::ItaniumVTableContext &
>(vtable_ctx);
283 clang::CharUnits base_offset_offset =
284 itanium_vtable_ctx.getVirtualBaseOffsetOffset(cxx_record_decl,
287 vtable_ptr + base_offset_offset.getQuantity();
296 const ASTRecordLayout &record_layout,
297 const CXXRecordDecl *cxx_record_decl,
298 const CXXRecordDecl *base_class_decl,
299 int32_t &bit_offset) {
311 *process, vtable_ctx, vtable_ptr, cxx_record_decl, base_class_decl);
312 if (base_offset == INT64_MAX)
315 bit_offset = base_offset * 8;
325 static llvm::once_flag g_once_flag;
326 llvm::call_once(g_once_flag, []() {
333 bool is_complete_objc_class)
346 const clang::Decl *parent) {
347 if (!member || !parent)
354 member->setFromASTFile();
355 member->setOwningModuleID(
id.GetValue());
356 member->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
357 if (llvm::isa<clang::NamedDecl>(member))
358 if (
auto *dc = llvm::dyn_cast<clang::DeclContext>(parent)) {
359 dc->setHasExternalVisibleStorage(
true);
362 dc->setHasExternalLexicalStorage(
true);
369 clang::OverloadedOperatorKind &op_kind) {
371 if (!name.consume_front(
"operator"))
376 bool space_after_operator = name.consume_front(
" ");
378 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
379 .Case(
"+", clang::OO_Plus)
380 .Case(
"+=", clang::OO_PlusEqual)
381 .Case(
"++", clang::OO_PlusPlus)
382 .Case(
"-", clang::OO_Minus)
383 .Case(
"-=", clang::OO_MinusEqual)
384 .Case(
"--", clang::OO_MinusMinus)
385 .Case(
"->", clang::OO_Arrow)
386 .Case(
"->*", clang::OO_ArrowStar)
387 .Case(
"*", clang::OO_Star)
388 .Case(
"*=", clang::OO_StarEqual)
389 .Case(
"/", clang::OO_Slash)
390 .Case(
"/=", clang::OO_SlashEqual)
391 .Case(
"%", clang::OO_Percent)
392 .Case(
"%=", clang::OO_PercentEqual)
393 .Case(
"^", clang::OO_Caret)
394 .Case(
"^=", clang::OO_CaretEqual)
395 .Case(
"&", clang::OO_Amp)
396 .Case(
"&=", clang::OO_AmpEqual)
397 .Case(
"&&", clang::OO_AmpAmp)
398 .Case(
"|", clang::OO_Pipe)
399 .Case(
"|=", clang::OO_PipeEqual)
400 .Case(
"||", clang::OO_PipePipe)
401 .Case(
"~", clang::OO_Tilde)
402 .Case(
"!", clang::OO_Exclaim)
403 .Case(
"!=", clang::OO_ExclaimEqual)
404 .Case(
"=", clang::OO_Equal)
405 .Case(
"==", clang::OO_EqualEqual)
406 .Case(
"<", clang::OO_Less)
407 .Case(
"<=>", clang::OO_Spaceship)
408 .Case(
"<<", clang::OO_LessLess)
409 .Case(
"<<=", clang::OO_LessLessEqual)
410 .Case(
"<=", clang::OO_LessEqual)
411 .Case(
">", clang::OO_Greater)
412 .Case(
">>", clang::OO_GreaterGreater)
413 .Case(
">>=", clang::OO_GreaterGreaterEqual)
414 .Case(
">=", clang::OO_GreaterEqual)
415 .Case(
"()", clang::OO_Call)
416 .Case(
"[]", clang::OO_Subscript)
417 .Case(
",", clang::OO_Comma)
418 .Default(clang::NUM_OVERLOADED_OPERATORS);
421 if (op_kind != clang::NUM_OVERLOADED_OPERATORS)
433 if (!space_after_operator)
438 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
439 .Case(
"new", clang::OO_New)
440 .Case(
"new[]", clang::OO_Array_New)
441 .Case(
"delete", clang::OO_Delete)
442 .Case(
"delete[]", clang::OO_Array_Delete)
444 .Default(clang::NUM_OVERLOADED_OPERATORS);
449clang::AccessSpecifier
469 std::vector<std::string> Includes;
470 LangOptions::setLangDefaults(Opts, clang::Language::ObjCXX, arch.
GetTriple(),
471 Includes, clang::LangStandard::lang_gnucxx98);
473 Opts.setValueVisibilityMode(DefaultVisibility);
477 Opts.Trigraphs = !Opts.GNUMode;
482 Opts.ModulesLocalVisibility = 1;
486 llvm::Triple target_triple) {
488 if (!target_triple.str().empty())
498 ASTContext &existing_ctxt) {
514 if (!TypeSystemClangSupportsLanguage(language))
518 arch =
module->GetArchitecture();
528 if (triple.getVendor() == llvm::Triple::Apple &&
529 triple.getOS() == llvm::Triple::UnknownOS) {
530 if (triple.getArch() == llvm::Triple::arm ||
531 triple.getArch() == llvm::Triple::aarch64 ||
532 triple.getArch() == llvm::Triple::aarch64_32 ||
533 triple.getArch() == llvm::Triple::thumb) {
534 triple.setOS(llvm::Triple::IOS);
536 triple.setOS(llvm::Triple::MacOSX);
541 std::string ast_name =
542 "ASTContext for '" +
module->GetFileSpec().GetPath() + "'";
543 return std::make_shared<TypeSystemClang>(ast_name, triple);
544 }
else if (target && target->
IsValid())
545 return std::make_shared<ScratchTypeSystemClang>(*target, triple);
607 assert(s ==
nullptr || &s->getASTContext() ==
m_ast_up.get());
620 llvm::IntrusiveRefCntPtr<ExternalASTSource> ast_source_sp) {
622 ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(
true);
623 ast.setExternalSource(std::move(ast_source_sp));
636 const clang::Diagnostic &info)
override {
638 llvm::SmallVector<char, 32> diag_str(10);
639 info.FormatDiagnostic(diag_str);
640 diag_str.push_back(
'\0');
645 DiagnosticConsumer *
clone(DiagnosticsEngine &Diags)
const {
666 clang::FileSystemOptions file_system_options;
676 m_ast_up = std::make_unique<ASTContext>(
688 m_ast_up->InitBuiltinTypes(*target_info);
692 "Failed to initialize builtin ASTContext types for target '{0}'. "
693 "Printing variables may behave unexpectedly.",
699 static std::once_flag s_uninitialized_target_warning;
701 &s_uninitialized_target_warning);
707 llvm::makeIntrusiveRefCnt<ClangExternalASTSourceCallbacks>(*
this);
739#pragma mark Basic Types
742 ASTContext &ast, QualType qual_type) {
743 uint64_t qual_type_bit_size = ast.getTypeSize(qual_type);
744 return qual_type_bit_size == bit_size;
763 return GetType(ast.UnsignedCharTy);
765 return GetType(ast.UnsignedShortTy);
767 return GetType(ast.UnsignedIntTy);
769 return GetType(ast.UnsignedLongTy);
771 return GetType(ast.UnsignedLongLongTy);
773 return GetType(ast.UnsignedInt128Ty);
778 return GetType(ast.SignedCharTy);
786 return GetType(ast.LongLongTy);
797 return GetType(ast.LongDoubleTy);
801 return GetType(ast.Float128Ty);
806 if (bit_size && !(bit_size & 0x7u))
807 return GetType(ast.getExtVectorType(ast.UnsignedCharTy, bit_size / 8));
815 static const llvm::StringMap<lldb::BasicType> g_type_map = {
880 auto iter = g_type_map.find(name);
881 if (iter == g_type_map.end())
912 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
931 return GetType(ast.UnsignedCharTy);
933 return GetType(ast.UnsignedShortTy);
935 return GetType(ast.UnsignedIntTy);
940 if (type_name.contains(
"complex")) {
949 case DW_ATE_complex_float: {
950 CanQualType FloatComplexTy = ast.getComplexType(ast.FloatTy);
952 return GetType(FloatComplexTy);
954 CanQualType DoubleComplexTy = ast.getComplexType(ast.DoubleTy);
956 return GetType(DoubleComplexTy);
958 CanQualType LongDoubleComplexTy = ast.getComplexType(ast.LongDoubleTy);
960 return GetType(LongDoubleComplexTy);
970 if (type_name ==
"float" &&
973 if (type_name ==
"double" &&
976 if (type_name ==
"long double" &&
978 return GetType(ast.LongDoubleTy);
979 if (type_name ==
"__bf16" &&
981 return GetType(ast.BFloat16Ty);
982 if (type_name ==
"_Float16" &&
988 if ((type_name ==
"__float128" || type_name ==
"_Float128" ||
989 type_name ==
"f128") &&
991 return GetType(ast.Float128Ty);
998 return GetType(ast.LongDoubleTy);
1002 return GetType(ast.Float128Ty);
1006 if (!type_name.empty()) {
1007 if (type_name.starts_with(
"_BitInt"))
1008 return GetType(ast.getBitIntType(
false, bit_size));
1009 if (type_name ==
"wchar_t" &&
1014 if (type_name ==
"void" &&
1017 if (type_name.contains(
"long long") &&
1019 return GetType(ast.LongLongTy);
1020 if (type_name.contains(
"long") &&
1023 if (type_name.contains(
"short") &&
1026 if (type_name.contains(
"char")) {
1030 return GetType(ast.SignedCharTy);
1032 if (type_name.contains(
"int")) {
1049 return GetType(ast.LongLongTy);
1054 case DW_ATE_signed_char:
1055 if (type_name ==
"char") {
1060 return GetType(ast.SignedCharTy);
1063 case DW_ATE_unsigned:
1064 if (!type_name.empty()) {
1065 if (type_name.starts_with(
"unsigned _BitInt"))
1066 return GetType(ast.getBitIntType(
true, bit_size));
1067 if (type_name ==
"wchar_t") {
1074 if (type_name.contains(
"long long")) {
1076 return GetType(ast.UnsignedLongLongTy);
1077 }
else if (type_name.contains(
"long")) {
1079 return GetType(ast.UnsignedLongTy);
1080 }
else if (type_name.contains(
"short")) {
1082 return GetType(ast.UnsignedShortTy);
1083 }
else if (type_name.contains(
"char")) {
1085 return GetType(ast.UnsignedCharTy);
1086 }
else if (type_name.contains(
"int")) {
1088 return GetType(ast.UnsignedIntTy);
1090 return GetType(ast.UnsignedInt128Ty);
1095 return GetType(ast.UnsignedCharTy);
1097 return GetType(ast.UnsignedShortTy);
1099 return GetType(ast.UnsignedIntTy);
1101 return GetType(ast.UnsignedLongTy);
1103 return GetType(ast.UnsignedLongLongTy);
1105 return GetType(ast.UnsignedInt128Ty);
1108 case DW_ATE_unsigned_char:
1109 if (type_name ==
"char") {
1114 return GetType(ast.UnsignedCharTy);
1116 return GetType(ast.UnsignedShortTy);
1119 case DW_ATE_imaginary_float:
1131 if (!type_name.empty()) {
1132 if (type_name ==
"char16_t")
1134 if (type_name ==
"char32_t")
1136 if (type_name ==
"char8_t")
1145 "error: need to add support for DW_TAG_base_type '{0}' "
1146 "encoded with DW_ATE = {1:x}, bit_size = {2}",
1147 type_name, dw_ate, bit_size);
1153 QualType char_type(ast.CharTy);
1156 char_type.addConst();
1158 return GetType(ast.getPointerType(char_type));
1162 bool ignore_qualifiers) {
1173 if (ignore_qualifiers) {
1174 type1_qual = type1_qual.getUnqualifiedType();
1175 type2_qual = type2_qual.getUnqualifiedType();
1178 return ast->getASTContext().hasSameType(type1_qual, type2_qual);
1185 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
1186 if (
auto *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl))
1198 if (clang::ObjCInterfaceDecl *interface_decl =
1199 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
1201 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
1203 if (clang::ValueDecl *value_decl = llvm::dyn_cast<clang::ValueDecl>(decl))
1217 return GetType(value_decl->getType());
1220#pragma mark Structure, Unions, Classes
1224 if (!decl || !owning_module.
HasValue())
1227 decl->setFromASTFile();
1228 decl->setOwningModuleID(owning_module.
GetValue());
1229 decl->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
1235 bool is_framework,
bool is_explicit) {
1237 auto *ast_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1239 assert(ast_source &&
"external ast source was lost");
1257 clang::Module *module;
1258 auto parent_desc = ast_source->getSourceDescriptor(parent.
GetValue());
1260 name, parent_desc ? parent_desc->getModuleOrNull() :
nullptr,
1261 is_framework, is_explicit);
1263 return ast_source->GetIDForModule(module);
1265 return ast_source->RegisterModule(module);
1271 std::optional<ClangASTMetadata> metadata,
bool exports_symbols) {
1274 if (decl_ctx ==
nullptr)
1275 decl_ctx = ast.getTranslationUnitDecl();
1279 bool isInternal =
false;
1280 return CreateObjCClass(name, decl_ctx, owning_module, isInternal, metadata);
1289 bool has_name = !name.empty();
1290 CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1291 decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1292 decl->setDeclContext(decl_ctx);
1294 decl->setDeclName(&ast.Idents.get(name));
1322 if (isa<CXXRecordDecl>(decl_ctx) && exports_symbols)
1323 decl->setAnonymousStructOrUnion(
true);
1329 decl->setAccess(AS_public);
1332 decl_ctx->addDecl(decl);
1334 return GetType(ast.getCanonicalTagType(decl));
1341QualType GetValueParamType(
const clang::TemplateArgument &argument) {
1342 switch (argument.getKind()) {
1343 case TemplateArgument::Integral:
1344 return argument.getIntegralType();
1345 case TemplateArgument::StructuralValue:
1346 return argument.getStructuralValueType();
1356 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1357 const bool parameter_pack =
false;
1358 const bool is_typename =
false;
1359 const unsigned depth = 0;
1360 const size_t num_template_params = template_param_infos.
Size();
1361 DeclContext *
const decl_context =
1362 ast.getTranslationUnitDecl();
1364 auto const &args = template_param_infos.
GetArgs();
1365 auto const &names = template_param_infos.
GetNames();
1366 for (
size_t i = 0; i < num_template_params; ++i) {
1367 const char *name = names[i];
1369 IdentifierInfo *identifier_info =
nullptr;
1370 if (name && name[0])
1371 identifier_info = &ast.Idents.get(name);
1372 TemplateArgument
const &targ = args[i];
1373 QualType template_param_type = GetValueParamType(targ);
1374 if (!template_param_type.isNull()) {
1375 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1376 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1377 identifier_info, template_param_type, parameter_pack,
1378 ast.getTrivialTypeSourceInfo(template_param_type)));
1380 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1381 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1382 identifier_info, is_typename, parameter_pack));
1387 IdentifierInfo *identifier_info =
nullptr;
1389 identifier_info = &ast.Idents.get(template_param_infos.
GetPackName());
1390 const bool parameter_pack_true =
true;
1392 QualType template_param_type =
1396 if (!template_param_type.isNull()) {
1397 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1398 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1399 num_template_params, identifier_info, template_param_type,
1400 parameter_pack_true,
1401 ast.getTrivialTypeSourceInfo(template_param_type)));
1403 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1404 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1405 num_template_params, identifier_info, is_typename,
1406 parameter_pack_true));
1409 clang::Expr *
const requires_clause =
nullptr;
1410 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1411 ast, SourceLocation(), SourceLocation(), template_param_decls,
1412 SourceLocation(), requires_clause);
1413 return template_param_list;
1418 clang::FunctionDecl *func_decl,
1423 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1425 ast, template_param_infos, template_param_decls);
1426 FunctionTemplateDecl *func_tmpl_decl =
1427 FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1428 func_tmpl_decl->setDeclContext(decl_ctx);
1429 func_tmpl_decl->setLocation(func_decl->getLocation());
1430 func_tmpl_decl->setDeclName(func_decl->getDeclName());
1431 func_tmpl_decl->setTemplateParameters(template_param_list);
1432 func_tmpl_decl->init(func_decl);
1435 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1436 i < template_param_decl_count; ++i) {
1438 template_param_decls[i]->setDeclContext(func_decl);
1440 func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
1442 return func_tmpl_decl;
1446 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1448 TemplateArgumentList *template_args_ptr = TemplateArgumentList::CreateCopy(
1449 func_decl->getASTContext(), infos.
GetArgs());
1451 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
1452 template_args_ptr,
nullptr);
1459 const TemplateArgument &value) {
1460 if (llvm::isa<TemplateTypeParmDecl>(param)) {
1462 if (value.getKind() != TemplateArgument::Type)
1464 }
else if (
auto *type_param =
1465 llvm::dyn_cast<NonTypeTemplateParmDecl>(param)) {
1467 QualType value_param_type = GetValueParamType(value);
1468 if (value_param_type.isNull())
1472 if (type_param->getType() != value_param_type)
1480 "Don't know how to compare template parameter to passed"
1481 " value. Decl kind of parameter is: {0}",
1482 param->getDeclKindName());
1483 lldbassert(
false &&
"Can't compare this TemplateParmDecl subclass");
1498 ClassTemplateDecl *class_template_decl,
1501 TemplateParameterList ¶ms = *class_template_decl->getTemplateParameters();
1507 std::optional<NamedDecl *> pack_parameter;
1509 size_t non_pack_params = params.size();
1510 for (
size_t i = 0; i < params.size(); ++i) {
1511 NamedDecl *param = params.getParam(i);
1512 if (param->isParameterPack()) {
1513 pack_parameter = param;
1514 non_pack_params = i;
1522 if (non_pack_params != instantiation_values.
Size())
1540 for (
const auto pair :
1541 llvm::zip_first(instantiation_values.
GetArgs(), params)) {
1542 const TemplateArgument &passed_arg = std::get<0>(pair);
1543 NamedDecl *found_param = std::get<1>(pair);
1548 return class_template_decl;
1553 llvm::StringRef class_name,
int kind,
1557 ClassTemplateDecl *class_template_decl =
nullptr;
1558 if (decl_ctx ==
nullptr)
1559 decl_ctx = ast.getTranslationUnitDecl();
1561 IdentifierInfo &identifier_info = ast.Idents.get(class_name);
1562 DeclarationName decl_name(&identifier_info);
1565 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1566 for (NamedDecl *decl : result) {
1567 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1568 if (!class_template_decl)
1577 template_param_infos))
1579 return class_template_decl;
1582 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1585 ast, template_param_infos, template_param_decls);
1587 CXXRecordDecl *template_cxx_decl =
1588 CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1589 template_cxx_decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1591 template_cxx_decl->setDeclContext(decl_ctx);
1592 template_cxx_decl->setDeclName(decl_name);
1595 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1596 i < template_param_decl_count; ++i) {
1597 template_param_decls[i]->setDeclContext(template_cxx_decl);
1605 class_template_decl =
1606 ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1608 class_template_decl->setDeclContext(decl_ctx);
1609 class_template_decl->setDeclName(decl_name);
1610 class_template_decl->setTemplateParameters(template_param_list);
1611 class_template_decl->init(template_cxx_decl);
1612 template_cxx_decl->setDescribedClassTemplate(class_template_decl);
1615 class_template_decl->setAccess(AS_public);
1617 decl_ctx->addDecl(class_template_decl);
1619 VerifyDecl(class_template_decl);
1621 return class_template_decl;
1624TemplateTemplateParmDecl *
1628 auto *decl_ctx = ast.getTranslationUnitDecl();
1630 IdentifierInfo &identifier_info = ast.Idents.get(template_name);
1631 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1635 ast, template_param_infos, template_param_decls);
1641 return TemplateTemplateParmDecl::Create(
1642 ast, decl_ctx, SourceLocation(),
1644 false, &identifier_info,
1645 TemplateNameKind::TNK_Type_template,
true,
1646 template_param_list);
1649ClassTemplateSpecializationDecl *
1652 ClassTemplateDecl *class_template_decl,
int kind,
1655 llvm::SmallVector<clang::TemplateArgument, 2> args(
1656 template_param_infos.
Size() +
1659 auto const &orig_args = template_param_infos.
GetArgs();
1660 std::copy(orig_args.begin(), orig_args.end(), args.begin());
1662 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1665 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1666 ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
1667 class_template_specialization_decl->setTagKind(
1668 static_cast<TagDecl::TagKind
>(kind));
1669 class_template_specialization_decl->setDeclContext(decl_ctx);
1670 class_template_specialization_decl->setInstantiationOf(class_template_decl);
1671 class_template_specialization_decl->setTemplateArgs(
1672 TemplateArgumentList::CreateCopy(ast, args));
1673 void *insert_pos =
nullptr;
1674 if (class_template_decl->findSpecialization(args, insert_pos))
1676 class_template_decl->AddSpecialization(class_template_specialization_decl,
1678 class_template_specialization_decl->setDeclName(
1679 class_template_decl->getDeclName());
1684 class_template_specialization_decl->setStrictPackMatch(
false);
1687 decl_ctx->addDecl(class_template_specialization_decl);
1689 class_template_specialization_decl->setSpecializationKind(
1690 TSK_ExplicitSpecialization);
1692 return class_template_specialization_decl;
1696 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1697 if (class_template_specialization_decl) {
1699 return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
1705 clang::OverloadedOperatorKind op_kind,
1706 bool unary,
bool binary,
1707 uint32_t num_params) {
1709 if (op_kind == OO_Call)
1715 if (num_params == 1)
1717 if (num_params == 2)
1724 bool is_method, clang::OverloadedOperatorKind op_kind,
1725 uint32_t num_params) {
1733 case OO_Array_Delete:
1737#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1739 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1741#include "clang/Basic/OperatorKinds.def"
1749 uint32_t &bitfield_bit_size) {
1751 if (field ==
nullptr)
1754 if (field->isBitField()) {
1755 Expr *bit_width_expr = field->getBitWidth();
1756 if (bit_width_expr) {
1757 if (std::optional<llvm::APSInt> bit_width_apsint =
1758 bit_width_expr->getIntegerConstantExpr(ast)) {
1759 bitfield_bit_size = bit_width_apsint->getLimitedValue(
UINT32_MAX);
1768 if (record_decl ==
nullptr)
1771 if (!record_decl->field_empty())
1775 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1776 if (cxx_record_decl) {
1777 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1778 for (base_class = cxx_record_decl->bases_begin(),
1779 base_class_end = cxx_record_decl->bases_end();
1780 base_class != base_class_end; ++base_class) {
1781 assert(record_decl != base_class->getType()->getAsCXXRecordDecl() &&
1782 "Base can't inherit from itself.");
1794 if (std::optional<ClangASTMetadata> meta_data =
GetMetadata(record_decl);
1795 meta_data && meta_data->IsForcefullyCompleted())
1801#pragma mark Objective-C Classes
1804 llvm::StringRef name, clang::DeclContext *decl_ctx,
1806 std::optional<ClangASTMetadata> metadata) {
1808 assert(!name.empty());
1810 decl_ctx = ast.getTranslationUnitDecl();
1812 ObjCInterfaceDecl *decl =
1813 ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
1814 decl->setDeclContext(decl_ctx);
1815 decl->setDeclName(&ast.Idents.get(name));
1816 decl->setImplicit(isInternal);
1822 return GetType(ast.getObjCInterfaceType(decl));
1831 bool omit_empty_base_classes) {
1832 uint32_t num_bases = 0;
1833 if (cxx_record_decl) {
1834 if (omit_empty_base_classes) {
1835 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1836 for (base_class = cxx_record_decl->bases_begin(),
1837 base_class_end = cxx_record_decl->bases_end();
1838 base_class != base_class_end; ++base_class) {
1845 num_bases = cxx_record_decl->getNumBases();
1850#pragma mark Namespace Declarations
1853 const char *name, clang::DeclContext *decl_ctx,
1855 NamespaceDecl *namespace_decl =
nullptr;
1857 TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
1859 decl_ctx = translation_unit_decl;
1862 IdentifierInfo &identifier_info = ast.Idents.get(name);
1863 DeclarationName decl_name(&identifier_info);
1864 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1865 for (NamedDecl *decl : result) {
1866 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1868 return namespace_decl;
1871 namespace_decl = NamespaceDecl::Create(ast, decl_ctx, is_inline,
1872 SourceLocation(), SourceLocation(),
1873 &identifier_info,
nullptr,
false);
1875 decl_ctx->addDecl(namespace_decl);
1877 if (decl_ctx == translation_unit_decl) {
1878 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1880 return namespace_decl;
1883 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1884 SourceLocation(),
nullptr,
nullptr,
false);
1885 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1886 translation_unit_decl->addDecl(namespace_decl);
1887 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace());
1889 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1890 if (parent_namespace_decl) {
1891 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1893 return namespace_decl;
1895 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1896 SourceLocation(),
nullptr,
nullptr,
false);
1897 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1898 parent_namespace_decl->addDecl(namespace_decl);
1899 assert(namespace_decl ==
1900 parent_namespace_decl->getAnonymousNamespace());
1902 assert(
false &&
"GetUniqueNamespaceDeclaration called with no name and "
1903 "no namespace as decl_ctx");
1911 VerifyDecl(namespace_decl);
1912 return namespace_decl;
1919 clang::BlockDecl *decl =
1920 clang::BlockDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1921 decl->setDeclContext(ctx);
1930 clang::DeclContext *right,
1931 clang::DeclContext *root) {
1932 if (root ==
nullptr)
1935 std::set<clang::DeclContext *> path_left;
1936 for (clang::DeclContext *d = left; d !=
nullptr; d = d->getParent())
1937 path_left.insert(d);
1939 for (clang::DeclContext *d = right; d !=
nullptr; d = d->getParent())
1940 if (path_left.find(d) != path_left.end())
1948 clang::NamespaceDecl *ns_decl) {
1949 if (decl_ctx && ns_decl) {
1950 auto *translation_unit =
getASTContext().getTranslationUnitDecl();
1951 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
1953 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
1954 clang::SourceLocation(), ns_decl,
1957 decl_ctx->addDecl(using_decl);
1967 clang::NamedDecl *target) {
1968 if (current_decl_ctx && target) {
1969 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
1971 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(),
false);
1973 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
1975 target->getDeclName(), using_decl, target);
1977 using_decl->addShadowDecl(shadow_decl);
1978 current_decl_ctx->addDecl(using_decl);
1986 const char *name, clang::QualType type) {
1988 clang::VarDecl *var_decl =
1989 clang::VarDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1990 var_decl->setDeclContext(decl_context);
1991 if (name && name[0])
1992 var_decl->setDeclName(&
getASTContext().Idents.getOwn(name));
1993 var_decl->setType(type);
1995 var_decl->setAccess(clang::AS_public);
1996 decl_context->addDecl(var_decl);
2005 switch (basic_type) {
2007 return ast->VoidTy.getAsOpaquePtr();
2009 return ast->CharTy.getAsOpaquePtr();
2011 return ast->SignedCharTy.getAsOpaquePtr();
2013 return ast->UnsignedCharTy.getAsOpaquePtr();
2015 return ast->getWCharType().getAsOpaquePtr();
2017 return ast->getSignedWCharType().getAsOpaquePtr();
2019 return ast->getUnsignedWCharType().getAsOpaquePtr();
2021 return ast->Char8Ty.getAsOpaquePtr();
2023 return ast->Char16Ty.getAsOpaquePtr();
2025 return ast->Char32Ty.getAsOpaquePtr();
2027 return ast->ShortTy.getAsOpaquePtr();
2029 return ast->UnsignedShortTy.getAsOpaquePtr();
2031 return ast->IntTy.getAsOpaquePtr();
2033 return ast->UnsignedIntTy.getAsOpaquePtr();
2035 return ast->LongTy.getAsOpaquePtr();
2037 return ast->UnsignedLongTy.getAsOpaquePtr();
2039 return ast->LongLongTy.getAsOpaquePtr();
2041 return ast->UnsignedLongLongTy.getAsOpaquePtr();
2043 return ast->Int128Ty.getAsOpaquePtr();
2045 return ast->UnsignedInt128Ty.getAsOpaquePtr();
2047 return ast->BoolTy.getAsOpaquePtr();
2049 return ast->HalfTy.getAsOpaquePtr();
2051 return ast->FloatTy.getAsOpaquePtr();
2053 return ast->DoubleTy.getAsOpaquePtr();
2055 return ast->LongDoubleTy.getAsOpaquePtr();
2057 return ast->Float128Ty.getAsOpaquePtr();
2059 return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
2061 return ast->getComplexType(ast->DoubleTy).getAsOpaquePtr();
2063 return ast->getComplexType(ast->LongDoubleTy).getAsOpaquePtr();
2065 return ast->getObjCIdType().getAsOpaquePtr();
2067 return ast->getObjCClassType().getAsOpaquePtr();
2069 return ast->getObjCSelType().getAsOpaquePtr();
2071 return ast->NullPtrTy.getAsOpaquePtr();
2077#pragma mark Function Types
2079clang::DeclarationName
2082 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2083 if (!
IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2092 const clang::FunctionProtoType *function_type =
2093 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2094 if (function_type ==
nullptr)
2095 return clang::DeclarationName();
2097 const bool is_method =
false;
2098 const unsigned int num_params = function_type->getNumParams();
2100 is_method, op_kind, num_params))
2101 return clang::DeclarationName();
2103 return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
2107 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
2108 printing_policy.SuppressTagKeyword =
true;
2111 printing_policy.SuppressInlineNamespace =
2112 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None);
2113 printing_policy.SuppressUnwrittenScope =
false;
2125 printing_policy.SuppressDefaultTemplateArgs =
false;
2126 return printing_policy;
2133 llvm::raw_string_ostream os(result);
2134 named_decl->getNameForDiagnostic(os, printing_policy, qualified);
2140 llvm::StringRef name,
const CompilerType &function_clang_type,
2141 clang::StorageClass storage,
bool is_inline, llvm::StringRef asm_label) {
2142 FunctionDecl *func_decl =
nullptr;
2145 decl_ctx = ast.getTranslationUnitDecl();
2147 const bool hasWrittenPrototype =
true;
2148 const bool isConstexprSpecified =
false;
2150 clang::DeclarationName declarationName =
2152 func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
2153 func_decl->setDeclContext(decl_ctx);
2154 func_decl->setDeclName(declarationName);
2156 func_decl->setStorageClass(storage);
2157 func_decl->setInlineSpecified(is_inline);
2158 func_decl->setHasWrittenPrototype(hasWrittenPrototype);
2159 func_decl->setConstexprKind(isConstexprSpecified
2160 ? ConstexprSpecKind::Constexpr
2161 : ConstexprSpecKind::Unspecified);
2173 if (!asm_label.empty())
2174 func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label));
2177 decl_ctx->addDecl(func_decl);
2179 VerifyDecl(func_decl);
2185 const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
2186 bool is_variadic,
unsigned type_quals, clang::CallingConv cc,
2187 clang::RefQualifierKind ref_qual) {
2191 std::vector<QualType> qual_type_args;
2193 for (
const auto &arg : args) {
2208 FunctionProtoType::ExtProtoInfo proto_info;
2209 proto_info.ExtInfo = cc;
2210 proto_info.Variadic = is_variadic;
2211 proto_info.ExceptionSpec = EST_None;
2212 proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
2213 proto_info.RefQualifier = ref_qual;
2221 const char *name,
const CompilerType ¶m_type,
int storage,
2224 auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
2225 decl->setDeclContext(decl_ctx);
2226 if (name && name[0])
2227 decl->setDeclName(&ast.Idents.get(name));
2229 decl->setStorageClass(
static_cast<clang::StorageClass
>(storage));
2232 decl_ctx->addDecl(decl);
2239 QualType block_type =
m_ast_up->getBlockPointerType(
2245#pragma mark Array Types
2249 std::optional<size_t> element_count,
2262 clang::ArraySizeModifier::Normal, 0));
2268 llvm::APInt ap_element_count(64, *element_count);
2270 ap_element_count,
nullptr,
2271 clang::ArraySizeModifier::Normal, 0));
2275 llvm::StringRef type_name,
2276 const std::initializer_list<std::pair<const char *, CompilerType>>
2283 lldbassert(0 &&
"Trying to create a type for an existing name");
2288 llvm::to_underlying(clang::TagTypeKind::Struct),
2291 for (
const auto &field : type_fields)
2300 llvm::StringRef type_name,
2301 const std::initializer_list<std::pair<const char *, CompilerType>>
2313#pragma mark Enumeration Types
2316 llvm::StringRef name, clang::DeclContext *decl_ctx,
2318 const CompilerType &integer_clang_type,
bool is_scoped,
2319 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind) {
2326 EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
2327 enum_decl->setDeclContext(decl_ctx);
2329 enum_decl->setDeclName(&ast.Idents.get(name));
2330 enum_decl->setScoped(is_scoped);
2331 enum_decl->setScopedUsingClassTag(is_scoped);
2332 enum_decl->setFixed(
false);
2335 decl_ctx->addDecl(enum_decl);
2339 clang::EnumExtensibilityAttr::CreateImplicit(ast, *enum_kind));
2344 enum_decl->setAccess(AS_public);
2346 return GetType(ast.getCanonicalTagType(enum_decl));
2357 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
2358 return GetType(ast.SignedCharTy);
2360 if (bit_size == ast.getTypeSize(ast.ShortTy))
2363 if (bit_size == ast.getTypeSize(ast.IntTy))
2366 if (bit_size == ast.getTypeSize(ast.LongTy))
2369 if (bit_size == ast.getTypeSize(ast.LongLongTy))
2370 return GetType(ast.LongLongTy);
2372 if (bit_size == ast.getTypeSize(ast.Int128Ty))
2375 if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
2376 return GetType(ast.UnsignedCharTy);
2378 if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
2379 return GetType(ast.UnsignedShortTy);
2381 if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
2382 return GetType(ast.UnsignedIntTy);
2384 if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
2385 return GetType(ast.UnsignedLongTy);
2387 if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
2388 return GetType(ast.UnsignedLongLongTy);
2390 if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
2391 return GetType(ast.UnsignedInt128Ty);
2418 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2420 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2421 named_decl->getDeclName().getAsString().c_str());
2423 printf(
"%20s\n", decl_ctx->getDeclKindName());
2429 if (decl ==
nullptr)
2433 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2435 bool is_injected_class_name =
2436 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2437 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2438 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2439 record_decl->getDeclName().getAsString().c_str(),
2440 is_injected_class_name ?
" (injected class name)" :
"");
2443 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2445 printf(
"%20s: %s\n", decl->getDeclKindName(),
2446 named_decl->getDeclName().getAsString().c_str());
2448 printf(
"%20s\n", decl->getDeclKindName());
2454 clang::Decl *decl) {
2458 ExternalASTSource *ast_source = ast->getExternalSource();
2463 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2464 if (tag_decl->isCompleteDefinition())
2467 if (!tag_decl->hasExternalLexicalStorage())
2470 ast_source->CompleteType(tag_decl);
2472 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2473 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2474 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2475 if (objc_interface_decl->getDefinition())
2478 if (!objc_interface_decl->hasExternalLexicalStorage())
2481 ast_source->CompleteType(objc_interface_decl);
2483 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2513std::optional<ClangASTMetadata>
2519 return std::nullopt;
2522std::optional<ClangASTMetadata>
2528 return std::nullopt;
2550 if (find(mask, type->getTypeClass()) != mask.end())
2552 switch (type->getTypeClass()) {
2555 case clang::Type::Atomic:
2556 type = cast<clang::AtomicType>(type)->getValueType();
2558 case clang::Type::Auto:
2559 case clang::Type::Decltype:
2560 case clang::Type::Paren:
2561 case clang::Type::SubstTemplateTypeParm:
2562 case clang::Type::TemplateSpecialization:
2563 case clang::Type::Typedef:
2564 case clang::Type::TypeOf:
2565 case clang::Type::TypeOfExpr:
2566 case clang::Type::Using:
2567 case clang::Type::PredefinedSugar:
2568 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2582 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2583 switch (type_class) {
2584 case clang::Type::ObjCInterface:
2585 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2587 case clang::Type::ObjCObjectPointer:
2589 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2590 ->getPointeeType());
2591 case clang::Type::Enum:
2592 case clang::Type::Record:
2593 return llvm::cast<clang::TagType>(qual_type)
2595 ->getDefinitionOrSelf();
2607static const clang::RecordType *
2609 assert(qual_type->isRecordType());
2611 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2613 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2617 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2620 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2621 const bool fields_loaded =
2622 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2625 if (is_complete && fields_loaded)
2633 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2634 if (external_ast_source) {
2635 external_ast_source->CompleteType(cxx_record_decl);
2636 if (cxx_record_decl->isCompleteDefinition()) {
2637 cxx_record_decl->field_begin();
2638 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
2650 clang::QualType qual_type) {
2651 assert(qual_type->isEnumeralType());
2654 const clang::EnumType *enum_type =
2655 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2657 auto *tag_decl = enum_type->getAsTagDecl();
2661 if (tag_decl->getDefinition())
2665 if (!tag_decl->hasExternalLexicalStorage())
2669 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2670 if (!external_ast_source)
2673 external_ast_source->CompleteType(tag_decl);
2681static const clang::ObjCObjectType *
2683 assert(qual_type->isObjCObjectType());
2686 const clang::ObjCObjectType *objc_class_type =
2687 llvm::cast<clang::ObjCObjectType>(qual_type);
2689 clang::ObjCInterfaceDecl *class_interface_decl =
2690 objc_class_type->getInterface();
2693 if (!class_interface_decl)
2694 return objc_class_type;
2697 if (class_interface_decl->getDefinition())
2698 return objc_class_type;
2701 if (!class_interface_decl->hasExternalLexicalStorage())
2705 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2706 if (!external_ast_source)
2709 external_ast_source->CompleteType(class_interface_decl);
2710 return objc_class_type;
2714 clang::QualType qual_type) {
2716 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2717 switch (type_class) {
2718 case clang::Type::ConstantArray:
2719 case clang::Type::IncompleteArray:
2720 case clang::Type::VariableArray: {
2721 const clang::ArrayType *array_type =
2722 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2727 case clang::Type::Record: {
2729 return !RT->isIncompleteType();
2734 case clang::Type::Enum: {
2736 return !ET->isIncompleteType();
2740 case clang::Type::ObjCObject:
2741 case clang::Type::ObjCInterface: {
2743 return !OT->isIncompleteType();
2748 case clang::Type::Attributed:
2750 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType());
2752 case clang::Type::MemberPointer:
2755 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2756 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2757 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2760 return !qual_type.getTypePtr()->isIncompleteType();
2775 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2782 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2783 switch (type_class) {
2784 case clang::Type::IncompleteArray:
2785 case clang::Type::VariableArray:
2786 case clang::Type::ConstantArray:
2787 case clang::Type::ExtVector:
2788 case clang::Type::Vector:
2789 case clang::Type::Record:
2790 case clang::Type::ObjCObject:
2791 case clang::Type::ObjCInterface:
2803 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2804 switch (type_class) {
2805 case clang::Type::Record: {
2806 if (
const clang::RecordType *record_type =
2807 llvm::dyn_cast_or_null<clang::RecordType>(
2808 qual_type.getTypePtrOrNull())) {
2809 if (
const clang::RecordDecl *record_decl = record_type->getDecl()) {
2810 return record_decl->isAnonymousStructOrUnion();
2824 uint64_t *size,
bool *is_incomplete) {
2827 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2828 switch (type_class) {
2832 case clang::Type::ConstantArray:
2833 if (element_type_ptr)
2835 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2839 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2841 .getLimitedValue(ULLONG_MAX);
2843 *is_incomplete =
false;
2846 case clang::Type::IncompleteArray:
2847 if (element_type_ptr)
2849 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2855 *is_incomplete =
true;
2858 case clang::Type::VariableArray:
2859 if (element_type_ptr)
2861 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2867 *is_incomplete =
false;
2870 case clang::Type::DependentSizedArray:
2871 if (element_type_ptr)
2874 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2880 *is_incomplete =
false;
2883 if (element_type_ptr)
2884 element_type_ptr->
Clear();
2888 *is_incomplete =
false;
2896 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2897 switch (type_class) {
2898 case clang::Type::Vector: {
2899 const clang::VectorType *vector_type =
2900 qual_type->getAs<clang::VectorType>();
2903 *size = vector_type->getNumElements();
2905 *element_type =
GetType(vector_type->getElementType());
2909 case clang::Type::ExtVector: {
2910 const clang::ExtVectorType *ext_vector_type =
2911 qual_type->getAs<clang::ExtVectorType>();
2912 if (ext_vector_type) {
2914 *size = ext_vector_type->getNumElements();
2918 ext_vector_type->getElementType().getAsOpaquePtr());
2934 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
2937 clang::ObjCInterfaceDecl *result_iface_decl =
2938 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
2940 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
2944 return (ast_metadata->GetISAPtr() != 0);
2948 return GetQualType(type).getUnqualifiedType()->isCharType();
2970 if (!pointee_or_element_clang_type.
IsValid())
2973 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
2974 if (pointee_or_element_clang_type.
IsCharType()) {
2975 if (type_flags.
Test(eTypeIsArray)) {
2978 length = llvm::cast<clang::ConstantArrayType>(
2992 if (
auto pointer_auth = qual_type.getPointerAuth())
2993 return pointer_auth.getKey();
3002 if (
auto pointer_auth = qual_type.getPointerAuth())
3003 return pointer_auth.getExtraDiscriminator();
3012 if (
auto pointer_auth = qual_type.getPointerAuth())
3013 return pointer_auth.isAddressDiscriminated();
3019 auto isFunctionType = [&](clang::QualType qual_type) {
3020 return qual_type->isFunctionType();
3034 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3035 switch (type_class) {
3036 case clang::Type::Record:
3038 const clang::CXXRecordDecl *cxx_record_decl =
3039 qual_type->getAsCXXRecordDecl();
3040 if (cxx_record_decl) {
3041 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3044 const clang::RecordType *record_type =
3045 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3047 if (
const clang::RecordDecl *record_decl =
3048 record_type->getDecl()->getDefinition()) {
3051 clang::RecordDecl::field_iterator field_pos,
3052 field_end = record_decl->field_end();
3053 uint32_t num_fields = 0;
3054 bool is_hva =
false;
3055 bool is_hfa =
false;
3056 clang::QualType base_qual_type;
3057 uint64_t base_bitwidth = 0;
3058 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3060 clang::QualType field_qual_type = field_pos->getType();
3061 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3062 if (field_qual_type->isFloatingType()) {
3063 if (field_qual_type->isComplexType())
3066 if (num_fields == 0)
3067 base_qual_type = field_qual_type;
3072 if (field_qual_type.getTypePtr() !=
3073 base_qual_type.getTypePtr())
3077 }
else if (field_qual_type->isVectorType() ||
3078 field_qual_type->isExtVectorType()) {
3079 if (num_fields == 0) {
3080 base_qual_type = field_qual_type;
3081 base_bitwidth = field_bitwidth;
3086 if (base_bitwidth != field_bitwidth)
3088 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3097 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3114 const clang::FunctionProtoType *func =
3115 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3117 return func->getNumParams();
3124 const size_t index) {
3127 const clang::FunctionProtoType *func =
3128 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3130 if (index < func->getNumParams())
3131 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3139 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3143 if (predicate(qual_type))
3146 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3147 switch (type_class) {
3151 case clang::Type::LValueReference:
3152 case clang::Type::RValueReference: {
3153 const clang::ReferenceType *reference_type =
3154 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3156 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3165 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3166 return qual_type->isMemberFunctionPointerType();
3169 return IsTypeImpl(type, isMemberFunctionPointerType);
3173 auto isFunctionPointerType = [](clang::QualType qual_type) {
3174 return qual_type->isFunctionPointerType();
3177 return IsTypeImpl(type, isFunctionPointerType);
3183 auto isBlockPointerType = [&](clang::QualType qual_type) {
3184 if (qual_type->isBlockPointerType()) {
3185 if (function_pointer_type_ptr) {
3186 const clang::BlockPointerType *block_pointer_type =
3187 qual_type->castAs<clang::BlockPointerType>();
3188 QualType pointee_type = block_pointer_type->getPointeeType();
3189 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3191 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3208 if (qual_type.isNull())
3217 is_signed = qual_type->isSignedIntegerType();
3225 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3229 is_signed = enum_type->isSignedIntegerOrEnumerationType();
3240 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3244 return enum_type->isScopedEnumeralType();
3255 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3256 switch (type_class) {
3257 case clang::Type::Builtin:
3258 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3261 case clang::BuiltinType::ObjCId:
3262 case clang::BuiltinType::ObjCClass:
3266 case clang::Type::ObjCObjectPointer:
3270 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3274 case clang::Type::BlockPointer:
3277 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3281 case clang::Type::Pointer:
3284 llvm::cast<clang::PointerType>(qual_type)
3288 case clang::Type::MemberPointer:
3291 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3300 pointee_type->
Clear();
3308 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3309 switch (type_class) {
3310 case clang::Type::Builtin:
3311 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3314 case clang::BuiltinType::ObjCId:
3315 case clang::BuiltinType::ObjCClass:
3319 case clang::Type::ObjCObjectPointer:
3323 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3327 case clang::Type::BlockPointer:
3330 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3334 case clang::Type::Pointer:
3337 llvm::cast<clang::PointerType>(qual_type)
3341 case clang::Type::MemberPointer:
3344 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3348 case clang::Type::LValueReference:
3351 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3355 case clang::Type::RValueReference:
3358 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3367 pointee_type->
Clear();
3376 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3378 switch (type_class) {
3379 case clang::Type::LValueReference:
3382 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3388 case clang::Type::RValueReference:
3391 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3403 pointee_type->
Clear();
3412 if (qual_type.isNull())
3415 return qual_type->isFloatingType();
3423 const clang::TagType *tag_type =
3424 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3426 if (clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinition())
3427 return tag_decl->isCompleteDefinition();
3430 const clang::ObjCObjectType *objc_class_type =
3431 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3432 if (objc_class_type) {
3433 clang::ObjCInterfaceDecl *class_interface_decl =
3434 objc_class_type->getInterface();
3435 if (class_interface_decl)
3436 return class_interface_decl->getDefinition() !=
nullptr;
3447 const clang::ObjCObjectPointerType *obj_pointer_type =
3448 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3450 if (obj_pointer_type)
3451 return obj_pointer_type->isObjCClassType();
3466 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3467 return (type_class == clang::Type::Record);
3474 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3475 return (type_class == clang::Type::Enum);
3481 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3482 switch (type_class) {
3483 case clang::Type::Record:
3485 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3492 return cxx_record_decl->isDynamicClass();
3506 bool check_cplusplus,
3508 if (dynamic_pointee_type)
3509 dynamic_pointee_type->
Clear();
3513 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3514 if (dynamic_pointee_type)
3516 type.getAsOpaquePtr());
3519 clang::QualType pointee_qual_type;
3521 switch (qual_type->getTypeClass()) {
3522 case clang::Type::Builtin:
3523 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3524 clang::BuiltinType::ObjCId) {
3525 set_dynamic_pointee_type(qual_type);
3530 case clang::Type::ObjCObjectPointer:
3533 if (
const auto *objc_pointee_type =
3534 qual_type->getPointeeType().getTypePtrOrNull()) {
3535 if (
const auto *objc_object_type =
3536 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3537 objc_pointee_type)) {
3538 if (objc_object_type->isObjCClass())
3542 set_dynamic_pointee_type(
3543 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3546 case clang::Type::Pointer:
3548 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3551 case clang::Type::LValueReference:
3552 case clang::Type::RValueReference:
3554 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3564 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3565 case clang::Type::Builtin:
3566 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3567 case clang::BuiltinType::UnknownAny:
3568 case clang::BuiltinType::Void:
3569 set_dynamic_pointee_type(pointee_qual_type);
3575 case clang::Type::Record: {
3576 if (!check_cplusplus)
3578 clang::CXXRecordDecl *cxx_record_decl =
3579 pointee_qual_type->getAsCXXRecordDecl();
3580 if (!cxx_record_decl)
3584 if (cxx_record_decl->isCompleteDefinition())
3585 success = cxx_record_decl->isDynamicClass();
3587 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3588 std::optional<bool> is_dynamic =
3589 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3591 success = *is_dynamic;
3593 success = cxx_record_decl->isDynamicClass();
3599 set_dynamic_pointee_type(pointee_qual_type);
3603 case clang::Type::ObjCObject:
3604 case clang::Type::ObjCInterface:
3606 set_dynamic_pointee_type(pointee_qual_type);
3621 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3628 ->getTypeClass() == clang::Type::Typedef;
3638 if (
auto *record_decl =
3640 return record_decl->canPassInRegisters();
3646 return TypeSystemClangSupportsLanguage(language);
3649std::optional<std::string>
3652 return std::nullopt;
3655 if (qual_type.isNull())
3656 return std::nullopt;
3658 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3659 if (!cxx_record_decl)
3660 return std::nullopt;
3662 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3670 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3677 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3679 return tag_type->getDecl()->isEntityBeingDefined();
3690 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3691 if (class_type_ptr) {
3692 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3693 const clang::ObjCObjectPointerType *obj_pointer_type =
3694 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3695 if (obj_pointer_type ==
nullptr)
3696 class_type_ptr->
Clear();
3700 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3707 class_type_ptr->
Clear();
3734 {clang::Type::Typedef, clang::Type::Atomic});
3737 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3738 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3745 if (
auto *named_decl = qual_type->getAsTagDecl())
3757 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3758 printing_policy.SuppressTagKeyword =
true;
3759 printing_policy.SuppressScope =
false;
3760 printing_policy.SuppressUnwrittenScope =
true;
3761 printing_policy.SuppressInlineNamespace =
3762 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::All);
3763 return ConstString(qual_type.getAsString(printing_policy));
3772 if (pointee_or_element_clang_type)
3773 pointee_or_element_clang_type->
Clear();
3775 clang::QualType qual_type =
3778 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3779 switch (type_class) {
3780 case clang::Type::Attributed:
3781 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3784 pointee_or_element_clang_type);
3785 case clang::Type::BitInt: {
3786 uint32_t type_flags = eTypeIsScalar | eTypeIsInteger | eTypeHasValue;
3787 if (qual_type->isSignedIntegerType())
3788 type_flags |= eTypeIsSigned;
3792 case clang::Type::Builtin: {
3793 const clang::BuiltinType *builtin_type =
3794 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3796 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3797 switch (builtin_type->getKind()) {
3798 case clang::BuiltinType::ObjCId:
3799 case clang::BuiltinType::ObjCClass:
3800 if (pointee_or_element_clang_type)
3804 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3807 case clang::BuiltinType::ObjCSel:
3808 if (pointee_or_element_clang_type)
3811 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3814 case clang::BuiltinType::Bool:
3815 case clang::BuiltinType::Char_U:
3816 case clang::BuiltinType::UChar:
3817 case clang::BuiltinType::WChar_U:
3818 case clang::BuiltinType::Char16:
3819 case clang::BuiltinType::Char32:
3820 case clang::BuiltinType::UShort:
3821 case clang::BuiltinType::UInt:
3822 case clang::BuiltinType::ULong:
3823 case clang::BuiltinType::ULongLong:
3824 case clang::BuiltinType::UInt128:
3825 case clang::BuiltinType::Char_S:
3826 case clang::BuiltinType::SChar:
3827 case clang::BuiltinType::WChar_S:
3828 case clang::BuiltinType::Short:
3829 case clang::BuiltinType::Int:
3830 case clang::BuiltinType::Long:
3831 case clang::BuiltinType::LongLong:
3832 case clang::BuiltinType::Int128:
3833 case clang::BuiltinType::Float:
3834 case clang::BuiltinType::Double:
3835 case clang::BuiltinType::LongDouble:
3836 builtin_type_flags |= eTypeIsScalar;
3837 if (builtin_type->isInteger()) {
3838 builtin_type_flags |= eTypeIsInteger;
3839 if (builtin_type->isSignedInteger())
3840 builtin_type_flags |= eTypeIsSigned;
3841 }
else if (builtin_type->isFloatingPoint())
3842 builtin_type_flags |= eTypeIsFloat;
3847 return builtin_type_flags;
3850 case clang::Type::BlockPointer:
3851 if (pointee_or_element_clang_type)
3853 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3854 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3856 case clang::Type::Complex: {
3857 uint32_t complex_type_flags =
3858 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3859 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3860 qual_type->getCanonicalTypeInternal());
3862 clang::QualType complex_element_type(complex_type->getElementType());
3863 if (complex_element_type->isIntegerType())
3864 complex_type_flags |= eTypeIsInteger;
3865 else if (complex_element_type->isFloatingType())
3866 complex_type_flags |= eTypeIsFloat;
3868 return complex_type_flags;
3871 case clang::Type::ConstantArray:
3872 case clang::Type::DependentSizedArray:
3873 case clang::Type::IncompleteArray:
3874 case clang::Type::VariableArray:
3875 if (pointee_or_element_clang_type)
3877 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
3880 return eTypeHasChildren | eTypeIsArray;
3882 case clang::Type::DependentName:
3884 case clang::Type::DependentSizedExtVector:
3885 return eTypeHasChildren | eTypeIsVector;
3887 case clang::Type::Enum:
3888 if (pointee_or_element_clang_type)
3890 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
3892 ->getDefinitionOrSelf()
3895 return eTypeIsEnumeration | eTypeHasValue;
3897 case clang::Type::FunctionProto:
3898 return eTypeIsFuncPrototype | eTypeHasValue;
3899 case clang::Type::FunctionNoProto:
3900 return eTypeIsFuncPrototype | eTypeHasValue;
3901 case clang::Type::InjectedClassName:
3904 case clang::Type::LValueReference:
3905 case clang::Type::RValueReference:
3906 if (pointee_or_element_clang_type)
3909 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
3912 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
3914 case clang::Type::MemberPointer:
3915 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
3917 case clang::Type::ObjCObjectPointer:
3918 if (pointee_or_element_clang_type)
3920 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3921 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
3924 case clang::Type::ObjCObject:
3925 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
3926 case clang::Type::ObjCInterface:
3927 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
3929 case clang::Type::Pointer:
3930 if (pointee_or_element_clang_type)
3932 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3933 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
3935 case clang::Type::Record:
3936 if (qual_type->getAsCXXRecordDecl())
3937 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
3939 return eTypeHasChildren | eTypeIsStructUnion;
3941 case clang::Type::SubstTemplateTypeParm:
3942 return eTypeIsTemplate;
3943 case clang::Type::TemplateTypeParm:
3944 return eTypeIsTemplate;
3945 case clang::Type::TemplateSpecialization:
3946 return eTypeIsTemplate;
3948 case clang::Type::Typedef:
3949 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
3951 ->getUnderlyingType())
3953 case clang::Type::UnresolvedUsing:
3956 case clang::Type::ExtVector:
3957 case clang::Type::Vector: {
3958 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
3959 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
3960 qual_type->getCanonicalTypeInternal());
3964 QualType element_type = vector_type->getElementType();
3965 if (element_type.isNull())
3968 if (element_type->isIntegerType())
3969 vector_type_flags |= eTypeIsInteger;
3970 else if (element_type->isFloatingType())
3971 vector_type_flags |= eTypeIsFloat;
3972 return vector_type_flags;
3987 if (qual_type->isAnyPointerType()) {
3988 if (qual_type->isObjCObjectPointerType())
3990 if (qual_type->getPointeeCXXRecordDecl())
3993 clang::QualType pointee_type(qual_type->getPointeeType());
3994 if (pointee_type->getPointeeCXXRecordDecl())
3996 if (pointee_type->isObjCObjectOrInterfaceType())
3998 if (pointee_type->isObjCClassType())
4000 if (pointee_type.getTypePtr() ==
4004 if (qual_type->isObjCObjectOrInterfaceType())
4006 if (qual_type->getAsCXXRecordDecl())
4008 switch (qual_type->getTypeClass()) {
4011 case clang::Type::Builtin:
4012 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4014 case clang::BuiltinType::Void:
4015 case clang::BuiltinType::Bool:
4016 case clang::BuiltinType::Char_U:
4017 case clang::BuiltinType::UChar:
4018 case clang::BuiltinType::WChar_U:
4019 case clang::BuiltinType::Char16:
4020 case clang::BuiltinType::Char32:
4021 case clang::BuiltinType::UShort:
4022 case clang::BuiltinType::UInt:
4023 case clang::BuiltinType::ULong:
4024 case clang::BuiltinType::ULongLong:
4025 case clang::BuiltinType::UInt128:
4026 case clang::BuiltinType::Char_S:
4027 case clang::BuiltinType::SChar:
4028 case clang::BuiltinType::WChar_S:
4029 case clang::BuiltinType::Short:
4030 case clang::BuiltinType::Int:
4031 case clang::BuiltinType::Long:
4032 case clang::BuiltinType::LongLong:
4033 case clang::BuiltinType::Int128:
4034 case clang::BuiltinType::Float:
4035 case clang::BuiltinType::Double:
4036 case clang::BuiltinType::LongDouble:
4039 case clang::BuiltinType::NullPtr:
4042 case clang::BuiltinType::ObjCId:
4043 case clang::BuiltinType::ObjCClass:
4044 case clang::BuiltinType::ObjCSel:
4047 case clang::BuiltinType::Dependent:
4048 case clang::BuiltinType::Overload:
4049 case clang::BuiltinType::BoundMember:
4050 case clang::BuiltinType::UnknownAny:
4054 case clang::Type::Typedef:
4055 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4057 ->getUnderlyingType())
4067 return lldb::eTypeClassInvalid;
4069 clang::QualType qual_type =
4072 switch (qual_type->getTypeClass()) {
4073 case clang::Type::Atomic:
4074 case clang::Type::Auto:
4075 case clang::Type::CountAttributed:
4076 case clang::Type::Decltype:
4077 case clang::Type::Paren:
4078 case clang::Type::TypeOf:
4079 case clang::Type::TypeOfExpr:
4080 case clang::Type::Using:
4081 case clang::Type::PredefinedSugar:
4082 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4083 case clang::Type::UnaryTransform:
4085 case clang::Type::FunctionNoProto:
4086 return lldb::eTypeClassFunction;
4087 case clang::Type::FunctionProto:
4088 return lldb::eTypeClassFunction;
4089 case clang::Type::IncompleteArray:
4090 return lldb::eTypeClassArray;
4091 case clang::Type::VariableArray:
4092 return lldb::eTypeClassArray;
4093 case clang::Type::ConstantArray:
4094 return lldb::eTypeClassArray;
4095 case clang::Type::DependentSizedArray:
4096 return lldb::eTypeClassArray;
4097 case clang::Type::ArrayParameter:
4098 return lldb::eTypeClassArray;
4099 case clang::Type::DependentSizedExtVector:
4100 return lldb::eTypeClassVector;
4101 case clang::Type::DependentVector:
4102 return lldb::eTypeClassVector;
4103 case clang::Type::ExtVector:
4104 return lldb::eTypeClassVector;
4105 case clang::Type::Vector:
4106 return lldb::eTypeClassVector;
4107 case clang::Type::Builtin:
4109 case clang::Type::BitInt:
4110 case clang::Type::DependentBitInt:
4111 case clang::Type::OverflowBehavior:
4112 return lldb::eTypeClassBuiltin;
4113 case clang::Type::ObjCObjectPointer:
4114 return lldb::eTypeClassObjCObjectPointer;
4115 case clang::Type::BlockPointer:
4116 return lldb::eTypeClassBlockPointer;
4117 case clang::Type::Pointer:
4118 return lldb::eTypeClassPointer;
4119 case clang::Type::LValueReference:
4120 return lldb::eTypeClassReference;
4121 case clang::Type::RValueReference:
4122 return lldb::eTypeClassReference;
4123 case clang::Type::MemberPointer:
4124 return lldb::eTypeClassMemberPointer;
4125 case clang::Type::Complex:
4126 if (qual_type->isComplexType())
4127 return lldb::eTypeClassComplexFloat;
4129 return lldb::eTypeClassComplexInteger;
4130 case clang::Type::ObjCObject:
4131 return lldb::eTypeClassObjCObject;
4132 case clang::Type::ObjCInterface:
4133 return lldb::eTypeClassObjCInterface;
4134 case clang::Type::Record: {
4135 const clang::RecordType *record_type =
4136 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4137 const clang::RecordDecl *record_decl = record_type->getDecl();
4138 if (record_decl->isUnion())
4139 return lldb::eTypeClassUnion;
4140 else if (record_decl->isStruct())
4141 return lldb::eTypeClassStruct;
4143 return lldb::eTypeClassClass;
4145 case clang::Type::Enum:
4146 return lldb::eTypeClassEnumeration;
4147 case clang::Type::Typedef:
4148 return lldb::eTypeClassTypedef;
4149 case clang::Type::UnresolvedUsing:
4152 case clang::Type::Attributed:
4153 case clang::Type::BTFTagAttributed:
4155 case clang::Type::TemplateTypeParm:
4157 case clang::Type::SubstTemplateTypeParm:
4159 case clang::Type::SubstTemplateTypeParmPack:
4161 case clang::Type::InjectedClassName:
4163 case clang::Type::DependentName:
4165 case clang::Type::PackExpansion:
4168 case clang::Type::TemplateSpecialization:
4170 case clang::Type::DeducedTemplateSpecialization:
4172 case clang::Type::Pipe:
4176 case clang::Type::Decayed:
4178 case clang::Type::Adjusted:
4180 case clang::Type::ObjCTypeParam:
4183 case clang::Type::DependentAddressSpace:
4185 case clang::Type::MacroQualified:
4189 case clang::Type::ConstantMatrix:
4190 case clang::Type::DependentSizedMatrix:
4194 case clang::Type::PackIndexing:
4197 case clang::Type::HLSLAttributedResource:
4199 case clang::Type::HLSLInlineSpirv:
4201 case clang::Type::SubstBuiltinTemplatePack:
4205 return lldb::eTypeClassOther;
4210 return GetQualType(type).getQualifiers().getCVRQualifiers();
4222 const clang::Type *array_eletype =
4223 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4228 return GetType(clang::QualType(array_eletype, 0));
4239 return GetType(ast_ctx.getConstantArrayType(
4240 qual_type, llvm::APInt(64, size),
nullptr,
4241 clang::ArraySizeModifier::Normal, 0));
4243 return GetType(ast_ctx.getIncompleteArrayType(
4244 qual_type, clang::ArraySizeModifier::Normal, 0));
4258 clang::QualType qual_type) {
4259 if (qual_type->isPointerType())
4260 qual_type = ast->getPointerType(
4262 else if (
const ConstantArrayType *arr =
4263 ast->getAsConstantArrayType(qual_type)) {
4264 qual_type = ast->getConstantArrayType(
4266 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4267 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4269 qual_type = qual_type.getUnqualifiedType();
4270 qual_type.removeLocalConst();
4271 qual_type.removeLocalRestrict();
4272 qual_type.removeLocalVolatile();
4294 const clang::FunctionProtoType *func =
4297 return func->getNumParams();
4305 const clang::FunctionProtoType *func =
4306 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4308 const uint32_t num_args = func->getNumParams();
4310 return GetType(func->getParamType(idx));
4320 const clang::FunctionProtoType *func =
4321 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4323 return GetType(func->getReturnType());
4330 size_t num_functions = 0;
4333 switch (qual_type->getTypeClass()) {
4334 case clang::Type::Record:
4336 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4337 num_functions = std::distance(cxx_record_decl->method_begin(),
4338 cxx_record_decl->method_end());
4341 case clang::Type::ObjCObjectPointer: {
4342 const clang::ObjCObjectPointerType *objc_class_type =
4343 qual_type->castAs<clang::ObjCObjectPointerType>();
4344 const clang::ObjCInterfaceType *objc_interface_type =
4345 objc_class_type->getInterfaceType();
4346 if (objc_interface_type &&
4348 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4349 clang::ObjCInterfaceDecl *class_interface_decl =
4350 objc_interface_type->getDecl();
4351 if (class_interface_decl) {
4352 num_functions = std::distance(class_interface_decl->meth_begin(),
4353 class_interface_decl->meth_end());
4359 case clang::Type::ObjCObject:
4360 case clang::Type::ObjCInterface:
4362 const clang::ObjCObjectType *objc_class_type =
4363 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4364 if (objc_class_type) {
4365 clang::ObjCInterfaceDecl *class_interface_decl =
4366 objc_class_type->getInterface();
4367 if (class_interface_decl)
4368 num_functions = std::distance(class_interface_decl->meth_begin(),
4369 class_interface_decl->meth_end());
4378 return num_functions;
4390 switch (qual_type->getTypeClass()) {
4391 case clang::Type::Record:
4393 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4394 auto method_iter = cxx_record_decl->method_begin();
4395 auto method_end = cxx_record_decl->method_end();
4397 static_cast<size_t>(std::distance(method_iter, method_end))) {
4398 std::advance(method_iter, idx);
4399 clang::CXXMethodDecl *cxx_method_decl =
4400 method_iter->getCanonicalDecl();
4401 if (cxx_method_decl) {
4402 name = cxx_method_decl->getDeclName().getAsString();
4403 if (cxx_method_decl->isStatic())
4405 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4407 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4411 clang_type =
GetType(cxx_method_decl->getType());
4419 case clang::Type::ObjCObjectPointer: {
4420 const clang::ObjCObjectPointerType *objc_class_type =
4421 qual_type->castAs<clang::ObjCObjectPointerType>();
4422 const clang::ObjCInterfaceType *objc_interface_type =
4423 objc_class_type->getInterfaceType();
4424 if (objc_interface_type &&
4426 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4427 clang::ObjCInterfaceDecl *class_interface_decl =
4428 objc_interface_type->getDecl();
4429 if (class_interface_decl) {
4430 auto method_iter = class_interface_decl->meth_begin();
4431 auto method_end = class_interface_decl->meth_end();
4433 static_cast<size_t>(std::distance(method_iter, method_end))) {
4434 std::advance(method_iter, idx);
4435 clang::ObjCMethodDecl *objc_method_decl =
4436 method_iter->getCanonicalDecl();
4437 if (objc_method_decl) {
4439 name = objc_method_decl->getSelector().getAsString();
4440 if (objc_method_decl->isClassMethod())
4451 case clang::Type::ObjCObject:
4452 case clang::Type::ObjCInterface:
4454 const clang::ObjCObjectType *objc_class_type =
4455 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4456 if (objc_class_type) {
4457 clang::ObjCInterfaceDecl *class_interface_decl =
4458 objc_class_type->getInterface();
4459 if (class_interface_decl) {
4460 auto method_iter = class_interface_decl->meth_begin();
4461 auto method_end = class_interface_decl->meth_end();
4463 static_cast<size_t>(std::distance(method_iter, method_end))) {
4464 std::advance(method_iter, idx);
4465 clang::ObjCMethodDecl *objc_method_decl =
4466 method_iter->getCanonicalDecl();
4467 if (objc_method_decl) {
4469 name = objc_method_decl->getSelector().getAsString();
4470 if (objc_method_decl->isClassMethod())
4503 return GetType(qual_type.getTypePtr()->getPointeeType());
4513 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4514 case clang::Type::ObjCObject:
4515 case clang::Type::ObjCInterface:
4562 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4563 clang::QualType result =
4564 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4574 result.addVolatile();
4584 result.addRestrict();
4593 if (type && typedef_name && typedef_name[0]) {
4597 clang::DeclContext *decl_ctx =
4602 clang::TypedefDecl *decl =
4603 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4604 decl->setDeclContext(decl_ctx);
4605 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4606 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4607 decl_ctx->addDecl(decl);
4610 clang::TagDecl *tdecl =
nullptr;
4611 if (!qual_type.isNull()) {
4612 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4613 tdecl = rt->getDecl();
4614 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4615 tdecl = et->getDecl();
4621 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4622 tdecl->setTypedefNameForAnonDecl(decl);
4624 decl->setAccess(clang::AS_public);
4627 NestedNameSpecifier Qualifier =
4628 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4630 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4638 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4641 return GetType(typedef_type->getDecl()->getUnderlyingType());
4654 const FunctionType::ExtInfo generic_ext_info(
4663 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4668const llvm::fltSemantics &
4671 const size_t bit_size = byte_size * 8;
4672 if (bit_size == ast.getTypeSize(ast.FloatTy))
4673 return ast.getFloatTypeSemantics(ast.FloatTy);
4674 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4675 return ast.getFloatTypeSemantics(ast.DoubleTy);
4677 bit_size == ast.getTypeSize(ast.Float128Ty))
4678 return ast.getFloatTypeSemantics(ast.Float128Ty);
4679 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4680 bit_size == llvm::APFloat::semanticsSizeInBits(
4681 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4682 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4683 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4684 return ast.getFloatTypeSemantics(ast.HalfTy);
4685 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4686 return ast.getFloatTypeSemantics(ast.Float128Ty);
4687 return llvm::APFloatBase::Bogus();
4690llvm::Expected<uint64_t>
4693 assert(qual_type->isObjCObjectOrInterfaceType());
4698 if (std::optional<uint64_t> bit_size =
4699 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4703 static bool g_printed =
false;
4708 llvm::outs() <<
"warning: trying to determine the size of type ";
4710 llvm::outs() <<
"without a valid ExecutionContext. this is not "
4711 "reliable. please file a bug against LLDB.\n";
4712 llvm::outs() <<
"backtrace:\n";
4713 llvm::sys::PrintStackTrace(llvm::outs());
4714 llvm::outs() <<
"\n";
4723llvm::Expected<uint64_t>
4726 const bool base_name_only =
true;
4728 return llvm::createStringError(
4729 "could not complete type %s",
4733 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4734 switch (type_class) {
4735 case clang::Type::ConstantArray:
4736 case clang::Type::FunctionProto:
4737 case clang::Type::Record:
4739 case clang::Type::ObjCInterface:
4740 case clang::Type::ObjCObject:
4742 case clang::Type::IncompleteArray: {
4743 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4746 qual_type->getArrayElementTypeNoTypeQual()
4747 ->getCanonicalTypeUnqualified());
4752 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4756 return llvm::createStringError(
4757 "could not get size of type %s",
4761std::optional<size_t>
4775 switch (qual_type->getTypeClass()) {
4776 case clang::Type::Atomic:
4777 case clang::Type::Auto:
4778 case clang::Type::CountAttributed:
4779 case clang::Type::Decltype:
4780 case clang::Type::Paren:
4781 case clang::Type::Typedef:
4782 case clang::Type::TypeOf:
4783 case clang::Type::TypeOfExpr:
4784 case clang::Type::Using:
4785 case clang::Type::PredefinedSugar:
4786 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4788 case clang::Type::UnaryTransform:
4791 case clang::Type::FunctionNoProto:
4792 case clang::Type::FunctionProto:
4795 case clang::Type::IncompleteArray:
4796 case clang::Type::VariableArray:
4797 case clang::Type::ArrayParameter:
4800 case clang::Type::ConstantArray:
4803 case clang::Type::DependentVector:
4804 case clang::Type::ExtVector:
4805 case clang::Type::Vector:
4808 case clang::Type::BitInt:
4809 case clang::Type::DependentBitInt:
4810 case clang::Type::OverflowBehavior:
4814 case clang::Type::Builtin:
4815 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4816 case clang::BuiltinType::Void:
4819 case clang::BuiltinType::Char_S:
4820 case clang::BuiltinType::SChar:
4821 case clang::BuiltinType::WChar_S:
4822 case clang::BuiltinType::Short:
4823 case clang::BuiltinType::Int:
4824 case clang::BuiltinType::Long:
4825 case clang::BuiltinType::LongLong:
4826 case clang::BuiltinType::Int128:
4829 case clang::BuiltinType::Bool:
4830 case clang::BuiltinType::Char_U:
4831 case clang::BuiltinType::UChar:
4832 case clang::BuiltinType::WChar_U:
4833 case clang::BuiltinType::Char8:
4834 case clang::BuiltinType::Char16:
4835 case clang::BuiltinType::Char32:
4836 case clang::BuiltinType::UShort:
4837 case clang::BuiltinType::UInt:
4838 case clang::BuiltinType::ULong:
4839 case clang::BuiltinType::ULongLong:
4840 case clang::BuiltinType::UInt128:
4844 case clang::BuiltinType::ShortAccum:
4845 case clang::BuiltinType::Accum:
4846 case clang::BuiltinType::LongAccum:
4847 case clang::BuiltinType::UShortAccum:
4848 case clang::BuiltinType::UAccum:
4849 case clang::BuiltinType::ULongAccum:
4850 case clang::BuiltinType::ShortFract:
4851 case clang::BuiltinType::Fract:
4852 case clang::BuiltinType::LongFract:
4853 case clang::BuiltinType::UShortFract:
4854 case clang::BuiltinType::UFract:
4855 case clang::BuiltinType::ULongFract:
4856 case clang::BuiltinType::SatShortAccum:
4857 case clang::BuiltinType::SatAccum:
4858 case clang::BuiltinType::SatLongAccum:
4859 case clang::BuiltinType::SatUShortAccum:
4860 case clang::BuiltinType::SatUAccum:
4861 case clang::BuiltinType::SatULongAccum:
4862 case clang::BuiltinType::SatShortFract:
4863 case clang::BuiltinType::SatFract:
4864 case clang::BuiltinType::SatLongFract:
4865 case clang::BuiltinType::SatUShortFract:
4866 case clang::BuiltinType::SatUFract:
4867 case clang::BuiltinType::SatULongFract:
4870 case clang::BuiltinType::Half:
4871 case clang::BuiltinType::Float:
4872 case clang::BuiltinType::Float16:
4873 case clang::BuiltinType::Float128:
4874 case clang::BuiltinType::Double:
4875 case clang::BuiltinType::LongDouble:
4876 case clang::BuiltinType::BFloat16:
4877 case clang::BuiltinType::Ibm128:
4880 case clang::BuiltinType::ObjCClass:
4881 case clang::BuiltinType::ObjCId:
4882 case clang::BuiltinType::ObjCSel:
4885 case clang::BuiltinType::NullPtr:
4888 case clang::BuiltinType::Kind::ARCUnbridgedCast:
4889 case clang::BuiltinType::Kind::BoundMember:
4890 case clang::BuiltinType::Kind::BuiltinFn:
4891 case clang::BuiltinType::Kind::Dependent:
4892 case clang::BuiltinType::Kind::OCLClkEvent:
4893 case clang::BuiltinType::Kind::OCLEvent:
4894 case clang::BuiltinType::Kind::OCLImage1dRO:
4895 case clang::BuiltinType::Kind::OCLImage1dWO:
4896 case clang::BuiltinType::Kind::OCLImage1dRW:
4897 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
4898 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
4899 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
4900 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
4901 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
4902 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
4903 case clang::BuiltinType::Kind::OCLImage2dRO:
4904 case clang::BuiltinType::Kind::OCLImage2dWO:
4905 case clang::BuiltinType::Kind::OCLImage2dRW:
4906 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
4907 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
4908 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
4909 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
4910 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
4911 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
4912 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
4913 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
4914 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
4915 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
4916 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
4917 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
4918 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
4919 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
4920 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
4921 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
4922 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
4923 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
4924 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
4925 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
4926 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
4927 case clang::BuiltinType::Kind::OCLImage3dRO:
4928 case clang::BuiltinType::Kind::OCLImage3dWO:
4929 case clang::BuiltinType::Kind::OCLImage3dRW:
4930 case clang::BuiltinType::Kind::OCLQueue:
4931 case clang::BuiltinType::Kind::OCLReserveID:
4932 case clang::BuiltinType::Kind::OCLSampler:
4933 case clang::BuiltinType::Kind::HLSLResource:
4934 case clang::BuiltinType::Kind::ArraySection:
4935 case clang::BuiltinType::Kind::OMPArrayShaping:
4936 case clang::BuiltinType::Kind::OMPIterator:
4937 case clang::BuiltinType::Kind::Overload:
4938 case clang::BuiltinType::Kind::PseudoObject:
4939 case clang::BuiltinType::Kind::UnknownAny:
4942 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
4943 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
4944 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
4945 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
4946 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
4947 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
4948 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
4949 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
4950 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
4951 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
4952 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
4953 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
4957 case clang::BuiltinType::VectorPair:
4958 case clang::BuiltinType::VectorQuad:
4959 case clang::BuiltinType::DMR1024:
4960 case clang::BuiltinType::DMR2048:
4964#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
4965#include "clang/Basic/AArch64ACLETypes.def"
4969#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
4970#include "clang/Basic/RISCVVTypes.def"
4974 case clang::BuiltinType::WasmExternRef:
4977 case clang::BuiltinType::IncompleteMatrixIdx:
4980 case clang::BuiltinType::UnresolvedTemplate:
4984#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
4985 case clang::BuiltinType::Id:
4986#include "clang/Basic/AMDGPUTypes.def"
4992 case clang::Type::ObjCObjectPointer:
4993 case clang::Type::BlockPointer:
4994 case clang::Type::Pointer:
4995 case clang::Type::LValueReference:
4996 case clang::Type::RValueReference:
4997 case clang::Type::MemberPointer:
4999 case clang::Type::Complex: {
5001 if (qual_type->isComplexType())
5004 const clang::ComplexType *complex_type =
5005 qual_type->getAsComplexIntegerType();
5014 case clang::Type::ObjCInterface:
5016 case clang::Type::Record:
5018 case clang::Type::Enum:
5019 return qual_type->isUnsignedIntegerOrEnumerationType()
5022 case clang::Type::DependentSizedArray:
5023 case clang::Type::DependentSizedExtVector:
5024 case clang::Type::UnresolvedUsing:
5025 case clang::Type::Attributed:
5026 case clang::Type::BTFTagAttributed:
5027 case clang::Type::TemplateTypeParm:
5028 case clang::Type::SubstTemplateTypeParm:
5029 case clang::Type::SubstTemplateTypeParmPack:
5030 case clang::Type::InjectedClassName:
5031 case clang::Type::DependentName:
5032 case clang::Type::PackExpansion:
5033 case clang::Type::ObjCObject:
5035 case clang::Type::TemplateSpecialization:
5036 case clang::Type::DeducedTemplateSpecialization:
5037 case clang::Type::Adjusted:
5038 case clang::Type::Pipe:
5042 case clang::Type::Decayed:
5044 case clang::Type::ObjCTypeParam:
5047 case clang::Type::DependentAddressSpace:
5049 case clang::Type::MacroQualified:
5052 case clang::Type::ConstantMatrix:
5053 case clang::Type::DependentSizedMatrix:
5057 case clang::Type::PackIndexing:
5060 case clang::Type::HLSLAttributedResource:
5062 case clang::Type::HLSLInlineSpirv:
5064 case clang::Type::SubstBuiltinTemplatePack:
5077 switch (qual_type->getTypeClass()) {
5078 case clang::Type::Atomic:
5079 case clang::Type::Auto:
5080 case clang::Type::CountAttributed:
5081 case clang::Type::Decltype:
5082 case clang::Type::Paren:
5083 case clang::Type::Typedef:
5084 case clang::Type::TypeOf:
5085 case clang::Type::TypeOfExpr:
5086 case clang::Type::Using:
5087 case clang::Type::PredefinedSugar:
5088 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5089 case clang::Type::UnaryTransform:
5092 case clang::Type::FunctionNoProto:
5093 case clang::Type::FunctionProto:
5096 case clang::Type::IncompleteArray:
5097 case clang::Type::VariableArray:
5098 case clang::Type::ArrayParameter:
5101 case clang::Type::ConstantArray:
5104 case clang::Type::DependentVector:
5105 case clang::Type::ExtVector:
5106 case clang::Type::Vector:
5109 case clang::Type::BitInt:
5110 case clang::Type::DependentBitInt:
5111 case clang::Type::OverflowBehavior:
5115 case clang::Type::Builtin:
5116 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5117 case clang::BuiltinType::UnknownAny:
5118 case clang::BuiltinType::Void:
5119 case clang::BuiltinType::BoundMember:
5122 case clang::BuiltinType::Bool:
5124 case clang::BuiltinType::Char_S:
5125 case clang::BuiltinType::SChar:
5126 case clang::BuiltinType::WChar_S:
5127 case clang::BuiltinType::Char_U:
5128 case clang::BuiltinType::UChar:
5129 case clang::BuiltinType::WChar_U:
5131 case clang::BuiltinType::Char8:
5133 case clang::BuiltinType::Char16:
5135 case clang::BuiltinType::Char32:
5137 case clang::BuiltinType::UShort:
5139 case clang::BuiltinType::Short:
5141 case clang::BuiltinType::UInt:
5143 case clang::BuiltinType::Int:
5145 case clang::BuiltinType::ULong:
5147 case clang::BuiltinType::Long:
5149 case clang::BuiltinType::ULongLong:
5151 case clang::BuiltinType::LongLong:
5153 case clang::BuiltinType::UInt128:
5155 case clang::BuiltinType::Int128:
5157 case clang::BuiltinType::Half:
5158 case clang::BuiltinType::Float:
5159 case clang::BuiltinType::Double:
5160 case clang::BuiltinType::LongDouble:
5162 case clang::BuiltinType::Float128:
5168 case clang::Type::ObjCObjectPointer:
5170 case clang::Type::BlockPointer:
5172 case clang::Type::Pointer:
5174 case clang::Type::LValueReference:
5175 case clang::Type::RValueReference:
5177 case clang::Type::MemberPointer:
5179 case clang::Type::Complex: {
5180 if (qual_type->isComplexType())
5185 case clang::Type::ObjCInterface:
5187 case clang::Type::Record:
5189 case clang::Type::Enum:
5191 case clang::Type::DependentSizedArray:
5192 case clang::Type::DependentSizedExtVector:
5193 case clang::Type::UnresolvedUsing:
5194 case clang::Type::Attributed:
5195 case clang::Type::BTFTagAttributed:
5196 case clang::Type::TemplateTypeParm:
5197 case clang::Type::SubstTemplateTypeParm:
5198 case clang::Type::SubstTemplateTypeParmPack:
5199 case clang::Type::InjectedClassName:
5200 case clang::Type::DependentName:
5201 case clang::Type::PackExpansion:
5202 case clang::Type::ObjCObject:
5204 case clang::Type::TemplateSpecialization:
5205 case clang::Type::DeducedTemplateSpecialization:
5206 case clang::Type::Adjusted:
5207 case clang::Type::Pipe:
5211 case clang::Type::Decayed:
5213 case clang::Type::ObjCTypeParam:
5216 case clang::Type::DependentAddressSpace:
5218 case clang::Type::MacroQualified:
5222 case clang::Type::ConstantMatrix:
5223 case clang::Type::DependentSizedMatrix:
5227 case clang::Type::PackIndexing:
5230 case clang::Type::HLSLAttributedResource:
5232 case clang::Type::HLSLInlineSpirv:
5234 case clang::Type::SubstBuiltinTemplatePack:
5242 while (class_interface_decl) {
5243 if (class_interface_decl->ivar_size() > 0)
5246 class_interface_decl = class_interface_decl->getSuperClass();
5251static std::optional<SymbolFile::ArrayInfo>
5253 clang::QualType qual_type,
5255 if (qual_type->isIncompleteArrayType())
5256 if (std::optional<ClangASTMetadata> metadata =
5260 return std::nullopt;
5263llvm::Expected<uint32_t>
5265 bool omit_empty_base_classes,
5268 return llvm::createStringError(
"invalid clang type");
5270 uint32_t num_children = 0;
5272 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5273 switch (type_class) {
5274 case clang::Type::Builtin:
5275 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5276 case clang::BuiltinType::ObjCId:
5277 case clang::BuiltinType::ObjCClass:
5286 case clang::Type::Complex:
5288 case clang::Type::Record:
5290 const clang::RecordType *record_type =
5291 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5292 const clang::RecordDecl *record_decl =
5293 record_type->getDecl()->getDefinitionOrSelf();
5294 const clang::CXXRecordDecl *cxx_record_decl =
5295 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5299 num_children += std::distance(record_decl->field_begin(),
5300 record_decl->field_end());
5302 return llvm::createStringError(
5305 case clang::Type::ObjCObject:
5306 case clang::Type::ObjCInterface:
5308 const clang::ObjCObjectType *objc_class_type =
5309 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5310 assert(objc_class_type);
5311 if (objc_class_type) {
5312 clang::ObjCInterfaceDecl *class_interface_decl =
5313 objc_class_type->getInterface();
5315 if (class_interface_decl) {
5317 clang::ObjCInterfaceDecl *superclass_interface_decl =
5318 class_interface_decl->getSuperClass();
5319 if (superclass_interface_decl) {
5320 if (omit_empty_base_classes) {
5327 num_children += class_interface_decl->ivar_size();
5333 case clang::Type::LValueReference:
5334 case clang::Type::RValueReference:
5335 case clang::Type::ObjCObjectPointer: {
5338 uint32_t num_pointee_children = 0;
5340 auto num_children_or_err =
5341 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5342 if (!num_children_or_err)
5343 return num_children_or_err;
5344 num_pointee_children = *num_children_or_err;
5347 if (num_pointee_children == 0)
5350 num_children = num_pointee_children;
5353 case clang::Type::Vector:
5354 case clang::Type::ExtVector:
5356 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5359 case clang::Type::ConstantArray:
5360 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5364 case clang::Type::IncompleteArray:
5365 if (
auto array_info =
5368 num_children = array_info->element_orders.size()
5369 ? array_info->element_orders.back().value_or(0)
5373 case clang::Type::Pointer: {
5374 const clang::PointerType *pointer_type =
5375 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5376 clang::QualType pointee_type(pointer_type->getPointeeType());
5378 uint32_t num_pointee_children = 0;
5380 auto num_children_or_err =
5381 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5382 if (!num_children_or_err)
5383 return num_children_or_err;
5384 num_pointee_children = *num_children_or_err;
5386 if (num_pointee_children == 0) {
5391 num_children = num_pointee_children;
5397 return num_children;
5404 if (name_ref.consume_front(
"unsigned _BitInt(") ||
5405 name_ref.consume_front(
"_BitInt(")) {
5407 if (name_ref.consumeInteger(10, bit_size))
5410 if (!name_ref.consume_front(
")"))
5414 name.
GetStringRef().starts_with(
"unsigned"), bit_size));
5423 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5424 if (type_class == clang::Type::Builtin) {
5425 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5426 case clang::BuiltinType::Void:
5428 case clang::BuiltinType::Bool:
5430 case clang::BuiltinType::Char_S:
5432 case clang::BuiltinType::Char_U:
5434 case clang::BuiltinType::Char8:
5436 case clang::BuiltinType::Char16:
5438 case clang::BuiltinType::Char32:
5440 case clang::BuiltinType::UChar:
5442 case clang::BuiltinType::SChar:
5444 case clang::BuiltinType::WChar_S:
5446 case clang::BuiltinType::WChar_U:
5448 case clang::BuiltinType::Short:
5450 case clang::BuiltinType::UShort:
5452 case clang::BuiltinType::Int:
5454 case clang::BuiltinType::UInt:
5456 case clang::BuiltinType::Long:
5458 case clang::BuiltinType::ULong:
5460 case clang::BuiltinType::LongLong:
5462 case clang::BuiltinType::ULongLong:
5464 case clang::BuiltinType::Int128:
5466 case clang::BuiltinType::UInt128:
5469 case clang::BuiltinType::Half:
5471 case clang::BuiltinType::Float:
5473 case clang::BuiltinType::Double:
5475 case clang::BuiltinType::LongDouble:
5477 case clang::BuiltinType::Float128:
5480 case clang::BuiltinType::NullPtr:
5482 case clang::BuiltinType::ObjCId:
5484 case clang::BuiltinType::ObjCClass:
5486 case clang::BuiltinType::ObjCSel:
5500 const llvm::APSInt &value)>
const &callback) {
5501 const clang::EnumType *enum_type =
5504 const clang::EnumDecl *enum_decl =
5505 enum_type->getDecl()->getDefinitionOrSelf();
5509 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5510 for (enum_pos = enum_decl->enumerator_begin(),
5511 enum_end_pos = enum_decl->enumerator_end();
5512 enum_pos != enum_end_pos; ++enum_pos) {
5513 ConstString name(enum_pos->getNameAsString().c_str());
5514 if (!callback(integer_type, name, enum_pos->getInitVal()))
5521#pragma mark Aggregate Types
5529 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5530 switch (type_class) {
5531 case clang::Type::Record:
5533 const clang::RecordType *record_type =
5534 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5536 clang::RecordDecl *record_decl =
5537 record_type->getDecl()->getDefinition();
5539 count = std::distance(record_decl->field_begin(),
5540 record_decl->field_end());
5546 case clang::Type::ObjCObjectPointer: {
5547 const clang::ObjCObjectPointerType *objc_class_type =
5548 qual_type->castAs<clang::ObjCObjectPointerType>();
5549 const clang::ObjCInterfaceType *objc_interface_type =
5550 objc_class_type->getInterfaceType();
5551 if (objc_interface_type &&
5553 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5554 clang::ObjCInterfaceDecl *class_interface_decl =
5555 objc_interface_type->getDecl();
5556 if (class_interface_decl) {
5557 count = class_interface_decl->ivar_size();
5563 case clang::Type::ObjCObject:
5564 case clang::Type::ObjCInterface:
5566 const clang::ObjCObjectType *objc_class_type =
5567 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5568 if (objc_class_type) {
5569 clang::ObjCInterfaceDecl *class_interface_decl =
5570 objc_class_type->getInterface();
5572 if (class_interface_decl)
5573 count = class_interface_decl->ivar_size();
5586 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5587 std::string &name, uint64_t *bit_offset_ptr,
5588 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5589 if (class_interface_decl) {
5590 if (idx < (class_interface_decl->ivar_size())) {
5591 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5592 ivar_end = class_interface_decl->ivar_end();
5593 uint32_t ivar_idx = 0;
5595 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5596 ++ivar_pos, ++ivar_idx) {
5597 if (ivar_idx == idx) {
5598 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5600 clang::QualType ivar_qual_type(ivar_decl->getType());
5602 name.assign(ivar_decl->getNameAsString());
5604 if (bit_offset_ptr) {
5605 const clang::ASTRecordLayout &interface_layout =
5606 ast->getASTObjCInterfaceLayout(class_interface_decl);
5607 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5610 const bool is_bitfield = ivar_pos->isBitField();
5612 if (bitfield_bit_size_ptr) {
5613 *bitfield_bit_size_ptr = 0;
5615 if (is_bitfield && ast) {
5616 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5617 clang::Expr::EvalResult result;
5618 if (bitfield_bit_size_expr &&
5619 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5620 llvm::APSInt bitfield_apsint = result.Val.getInt();
5621 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5625 if (is_bitfield_ptr)
5626 *is_bitfield_ptr = is_bitfield;
5628 return ivar_qual_type.getAsOpaquePtr();
5637 size_t idx, std::string &name,
5638 uint64_t *bit_offset_ptr,
5639 uint32_t *bitfield_bit_size_ptr,
5640 bool *is_bitfield_ptr) {
5645 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5646 switch (type_class) {
5647 case clang::Type::Record:
5649 const clang::RecordType *record_type =
5650 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5651 const clang::RecordDecl *record_decl =
5652 record_type->getDecl()->getDefinitionOrSelf();
5653 uint32_t field_idx = 0;
5654 clang::RecordDecl::field_iterator field, field_end;
5655 for (field = record_decl->field_begin(),
5656 field_end = record_decl->field_end();
5657 field != field_end; ++field, ++field_idx) {
5658 if (idx == field_idx) {
5661 name.assign(field->getNameAsString());
5665 if (bit_offset_ptr) {
5666 const clang::ASTRecordLayout &record_layout =
5668 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5671 const bool is_bitfield = field->isBitField();
5673 if (bitfield_bit_size_ptr) {
5674 *bitfield_bit_size_ptr = 0;
5677 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5678 clang::Expr::EvalResult result;
5679 if (bitfield_bit_size_expr &&
5680 bitfield_bit_size_expr->EvaluateAsInt(result,
5682 llvm::APSInt bitfield_apsint = result.Val.getInt();
5683 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5687 if (is_bitfield_ptr)
5688 *is_bitfield_ptr = is_bitfield;
5690 return GetType(field->getType());
5696 case clang::Type::ObjCObjectPointer: {
5697 const clang::ObjCObjectPointerType *objc_class_type =
5698 qual_type->castAs<clang::ObjCObjectPointerType>();
5699 const clang::ObjCInterfaceType *objc_interface_type =
5700 objc_class_type->getInterfaceType();
5701 if (objc_interface_type &&
5703 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5704 clang::ObjCInterfaceDecl *class_interface_decl =
5705 objc_interface_type->getDecl();
5706 if (class_interface_decl) {
5710 name, bit_offset_ptr, bitfield_bit_size_ptr,
5717 case clang::Type::ObjCObject:
5718 case clang::Type::ObjCInterface:
5720 const clang::ObjCObjectType *objc_class_type =
5721 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5722 assert(objc_class_type);
5723 if (objc_class_type) {
5724 clang::ObjCInterfaceDecl *class_interface_decl =
5725 objc_class_type->getInterface();
5729 name, bit_offset_ptr, bitfield_bit_size_ptr,
5745 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5746 switch (type_class) {
5747 case clang::Type::Record:
5749 const clang::CXXRecordDecl *cxx_record_decl =
5750 qual_type->getAsCXXRecordDecl();
5751 if (cxx_record_decl)
5752 count = cxx_record_decl->getNumBases();
5756 case clang::Type::ObjCObjectPointer:
5760 case clang::Type::ObjCObject:
5762 const clang::ObjCObjectType *objc_class_type =
5763 qual_type->getAsObjCQualifiedInterfaceType();
5764 if (objc_class_type) {
5765 clang::ObjCInterfaceDecl *class_interface_decl =
5766 objc_class_type->getInterface();
5768 if (class_interface_decl && class_interface_decl->getSuperClass())
5773 case clang::Type::ObjCInterface:
5775 const clang::ObjCInterfaceType *objc_interface_type =
5776 qual_type->getAs<clang::ObjCInterfaceType>();
5777 if (objc_interface_type) {
5778 clang::ObjCInterfaceDecl *class_interface_decl =
5779 objc_interface_type->getInterface();
5781 if (class_interface_decl && class_interface_decl->getSuperClass())
5797 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5798 switch (type_class) {
5799 case clang::Type::Record:
5801 const clang::CXXRecordDecl *cxx_record_decl =
5802 qual_type->getAsCXXRecordDecl();
5803 if (cxx_record_decl)
5804 count = cxx_record_decl->getNumVBases();
5817 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5818 switch (type_class) {
5819 case clang::Type::Record:
5821 const clang::CXXRecordDecl *cxx_record_decl =
5822 qual_type->getAsCXXRecordDecl();
5823 if (cxx_record_decl) {
5824 uint32_t curr_idx = 0;
5825 clang::CXXRecordDecl::base_class_const_iterator base_class,
5827 for (base_class = cxx_record_decl->bases_begin(),
5828 base_class_end = cxx_record_decl->bases_end();
5829 base_class != base_class_end; ++base_class, ++curr_idx) {
5830 if (curr_idx == idx) {
5831 if (bit_offset_ptr) {
5832 const clang::ASTRecordLayout &record_layout =
5834 const clang::CXXRecordDecl *base_class_decl =
5835 llvm::cast<clang::CXXRecordDecl>(
5836 base_class->getType()
5837 ->castAs<clang::RecordType>()
5839 if (base_class->isVirtual())
5841 record_layout.getVBaseClassOffset(base_class_decl)
5846 record_layout.getBaseClassOffset(base_class_decl)
5850 return GetType(base_class->getType());
5857 case clang::Type::ObjCObjectPointer:
5860 case clang::Type::ObjCObject:
5862 const clang::ObjCObjectType *objc_class_type =
5863 qual_type->getAsObjCQualifiedInterfaceType();
5864 if (objc_class_type) {
5865 clang::ObjCInterfaceDecl *class_interface_decl =
5866 objc_class_type->getInterface();
5868 if (class_interface_decl) {
5869 clang::ObjCInterfaceDecl *superclass_interface_decl =
5870 class_interface_decl->getSuperClass();
5871 if (superclass_interface_decl) {
5873 *bit_offset_ptr = 0;
5875 superclass_interface_decl));
5881 case clang::Type::ObjCInterface:
5883 const clang::ObjCObjectType *objc_interface_type =
5884 qual_type->getAs<clang::ObjCInterfaceType>();
5885 if (objc_interface_type) {
5886 clang::ObjCInterfaceDecl *class_interface_decl =
5887 objc_interface_type->getInterface();
5889 if (class_interface_decl) {
5890 clang::ObjCInterfaceDecl *superclass_interface_decl =
5891 class_interface_decl->getSuperClass();
5892 if (superclass_interface_decl) {
5894 *bit_offset_ptr = 0;
5896 superclass_interface_decl));
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->vbases_begin(),
5923 base_class_end = cxx_record_decl->vbases_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>()
5935 record_layout.getVBaseClassOffset(base_class_decl)
5939 return GetType(base_class->getType());
5954 llvm::StringRef name) {
5956 switch (qual_type->getTypeClass()) {
5957 case clang::Type::Record: {
5961 const clang::RecordType *record_type =
5962 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5963 const clang::RecordDecl *record_decl =
5964 record_type->getDecl()->getDefinitionOrSelf();
5966 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
5967 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
5968 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
5969 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
5993 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5994 switch (type_class) {
5995 case clang::Type::Builtin:
5996 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5997 case clang::BuiltinType::UnknownAny:
5998 case clang::BuiltinType::Void:
5999 case clang::BuiltinType::NullPtr:
6000 case clang::BuiltinType::OCLEvent:
6001 case clang::BuiltinType::OCLImage1dRO:
6002 case clang::BuiltinType::OCLImage1dWO:
6003 case clang::BuiltinType::OCLImage1dRW:
6004 case clang::BuiltinType::OCLImage1dArrayRO:
6005 case clang::BuiltinType::OCLImage1dArrayWO:
6006 case clang::BuiltinType::OCLImage1dArrayRW:
6007 case clang::BuiltinType::OCLImage1dBufferRO:
6008 case clang::BuiltinType::OCLImage1dBufferWO:
6009 case clang::BuiltinType::OCLImage1dBufferRW:
6010 case clang::BuiltinType::OCLImage2dRO:
6011 case clang::BuiltinType::OCLImage2dWO:
6012 case clang::BuiltinType::OCLImage2dRW:
6013 case clang::BuiltinType::OCLImage2dArrayRO:
6014 case clang::BuiltinType::OCLImage2dArrayWO:
6015 case clang::BuiltinType::OCLImage2dArrayRW:
6016 case clang::BuiltinType::OCLImage3dRO:
6017 case clang::BuiltinType::OCLImage3dWO:
6018 case clang::BuiltinType::OCLImage3dRW:
6019 case clang::BuiltinType::OCLSampler:
6020 case clang::BuiltinType::HLSLResource:
6022 case clang::BuiltinType::Bool:
6023 case clang::BuiltinType::Char_U:
6024 case clang::BuiltinType::UChar:
6025 case clang::BuiltinType::WChar_U:
6026 case clang::BuiltinType::Char16:
6027 case clang::BuiltinType::Char32:
6028 case clang::BuiltinType::UShort:
6029 case clang::BuiltinType::UInt:
6030 case clang::BuiltinType::ULong:
6031 case clang::BuiltinType::ULongLong:
6032 case clang::BuiltinType::UInt128:
6033 case clang::BuiltinType::Char_S:
6034 case clang::BuiltinType::SChar:
6035 case clang::BuiltinType::WChar_S:
6036 case clang::BuiltinType::Short:
6037 case clang::BuiltinType::Int:
6038 case clang::BuiltinType::Long:
6039 case clang::BuiltinType::LongLong:
6040 case clang::BuiltinType::Int128:
6041 case clang::BuiltinType::Float:
6042 case clang::BuiltinType::Double:
6043 case clang::BuiltinType::LongDouble:
6044 case clang::BuiltinType::Float128:
6045 case clang::BuiltinType::Dependent:
6046 case clang::BuiltinType::Overload:
6047 case clang::BuiltinType::ObjCId:
6048 case clang::BuiltinType::ObjCClass:
6049 case clang::BuiltinType::ObjCSel:
6050 case clang::BuiltinType::BoundMember:
6051 case clang::BuiltinType::Half:
6052 case clang::BuiltinType::ARCUnbridgedCast:
6053 case clang::BuiltinType::PseudoObject:
6054 case clang::BuiltinType::BuiltinFn:
6055 case clang::BuiltinType::ArraySection:
6062 case clang::Type::Complex:
6064 case clang::Type::Pointer:
6066 case clang::Type::BlockPointer:
6069 case clang::Type::LValueReference:
6071 case clang::Type::RValueReference:
6073 case clang::Type::MemberPointer:
6075 case clang::Type::ConstantArray:
6077 case clang::Type::IncompleteArray:
6079 case clang::Type::VariableArray:
6081 case clang::Type::DependentSizedArray:
6083 case clang::Type::DependentSizedExtVector:
6085 case clang::Type::Vector:
6087 case clang::Type::ExtVector:
6089 case clang::Type::FunctionProto:
6091 case clang::Type::FunctionNoProto:
6093 case clang::Type::UnresolvedUsing:
6095 case clang::Type::Record:
6097 case clang::Type::Enum:
6099 case clang::Type::TemplateTypeParm:
6101 case clang::Type::SubstTemplateTypeParm:
6103 case clang::Type::TemplateSpecialization:
6105 case clang::Type::InjectedClassName:
6107 case clang::Type::DependentName:
6109 case clang::Type::ObjCObject:
6111 case clang::Type::ObjCInterface:
6113 case clang::Type::ObjCObjectPointer:
6123 std::string &deref_name, uint32_t &deref_byte_size,
6124 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6128 return llvm::createStringError(
"not a pointer, reference or array type");
6129 uint32_t child_bitfield_bit_size = 0;
6130 uint32_t child_bitfield_bit_offset = 0;
6131 bool child_is_base_class;
6132 bool child_is_deref_of_parent;
6134 type, exe_ctx, 0,
false,
true,
false, deref_name, deref_byte_size,
6135 deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6136 child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
6141 bool transparent_pointers,
bool omit_empty_base_classes,
6142 bool ignore_array_bounds, std::string &child_name,
6143 uint32_t &child_byte_size, int32_t &child_byte_offset,
6144 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6145 bool &child_is_base_class,
bool &child_is_deref_of_parent,
6148 return llvm::createStringError(
"invalid type");
6150 auto get_exe_scope = [&exe_ctx]() {
6154 clang::QualType parent_qual_type(
6156 const clang::Type::TypeClass parent_type_class =
6157 parent_qual_type->getTypeClass();
6158 child_bitfield_bit_size = 0;
6159 child_bitfield_bit_offset = 0;
6160 child_is_base_class =
false;
6163 auto num_children_or_err =
6165 if (!num_children_or_err)
6166 return num_children_or_err.takeError();
6168 const bool idx_is_valid = idx < *num_children_or_err;
6170 switch (parent_type_class) {
6171 case clang::Type::Builtin:
6173 return llvm::createStringError(
"invalid index");
6175 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6176 case clang::BuiltinType::ObjCId:
6177 case clang::BuiltinType::ObjCClass:
6188 case clang::Type::Record: {
6190 return llvm::createStringError(
"invalid index");
6192 return llvm::createStringError(
"cannot complete type");
6194 const clang::RecordType *record_type =
6195 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6196 const clang::RecordDecl *record_decl =
6197 record_type->getDecl()->getDefinitionOrSelf();
6198 const clang::ASTRecordLayout &record_layout =
6200 uint32_t child_idx = 0;
6202 const clang::CXXRecordDecl *cxx_record_decl =
6203 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6204 if (cxx_record_decl) {
6206 clang::CXXRecordDecl::base_class_const_iterator base_class,
6208 for (base_class = cxx_record_decl->bases_begin(),
6209 base_class_end = cxx_record_decl->bases_end();
6210 base_class != base_class_end; ++base_class) {
6211 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6214 if (omit_empty_base_classes) {
6216 llvm::cast<clang::CXXRecordDecl>(
6217 base_class->getType()->getAs<clang::RecordType>()->getDecl())
6218 ->getDefinitionOrSelf();
6223 if (idx == child_idx) {
6224 if (base_class_decl ==
nullptr)
6225 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6226 base_class->getType()
6227 ->getAs<clang::RecordType>()
6229 ->getDefinitionOrSelf();
6231 if (base_class->isVirtual()) {
6232 bool handled =
false;
6234 clang::VTableContextBase *vtable_ctx =
6238 cxx_record_decl, base_class_decl,
6242 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6246 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6251 child_byte_offset = bit_offset / 8;
6254 auto size_or_err = base_class_clang_type.
GetBitSize(get_exe_scope());
6256 return llvm::joinErrors(
6257 llvm::createStringError(
"no size info for base class"),
6258 size_or_err.takeError());
6260 uint64_t base_class_clang_type_bit_size = *size_or_err;
6263 assert(base_class_clang_type_bit_size % 8 == 0);
6264 child_byte_size = base_class_clang_type_bit_size / 8;
6265 child_is_base_class =
true;
6266 return base_class_clang_type;
6274 uint32_t field_idx = 0;
6275 clang::RecordDecl::field_iterator field, field_end;
6276 for (field = record_decl->field_begin(),
6277 field_end = record_decl->field_end();
6278 field != field_end; ++field, ++field_idx, ++child_idx) {
6279 if (idx == child_idx) {
6282 child_name.assign(field->getNameAsString());
6287 assert(field_idx < record_layout.getFieldCount());
6288 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6290 return llvm::joinErrors(
6291 llvm::createStringError(
"no size info for field"),
6292 size_or_err.takeError());
6294 child_byte_size = *size_or_err;
6295 const uint32_t child_bit_size = child_byte_size * 8;
6299 bit_offset = record_layout.getFieldOffset(field_idx);
6301 child_bitfield_bit_offset = bit_offset % child_bit_size;
6302 const uint32_t child_bit_offset =
6303 bit_offset - child_bitfield_bit_offset;
6304 child_byte_offset = child_bit_offset / 8;
6306 child_byte_offset = bit_offset / 8;
6309 return field_clang_type;
6313 case clang::Type::ObjCObject:
6314 case clang::Type::ObjCInterface: {
6316 return llvm::createStringError(
"invalid index");
6318 return llvm::createStringError(
"cannot complete type");
6320 const clang::ObjCObjectType *objc_class_type =
6321 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6322 assert(objc_class_type);
6323 if (!objc_class_type)
6324 return llvm::createStringError(
"unexpected object type");
6326 uint32_t child_idx = 0;
6327 clang::ObjCInterfaceDecl *class_interface_decl =
6328 objc_class_type->getInterface();
6330 if (!class_interface_decl)
6331 return llvm::createStringError(
"cannot get interface decl");
6333 const clang::ASTRecordLayout &interface_layout =
6334 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6335 clang::ObjCInterfaceDecl *superclass_interface_decl =
6336 class_interface_decl->getSuperClass();
6337 if (superclass_interface_decl) {
6338 if (omit_empty_base_classes) {
6340 getASTContext().getObjCInterfaceType(superclass_interface_decl));
6341 if (llvm::expectedToStdOptional(base_class_clang_type.
GetNumChildren(
6342 omit_empty_base_classes, exe_ctx))
6345 clang::QualType ivar_qual_type(
getASTContext().getObjCInterfaceType(
6346 superclass_interface_decl));
6348 child_name.assign(superclass_interface_decl->getNameAsString());
6350 clang::TypeInfo ivar_type_info =
6353 child_byte_size = ivar_type_info.Width / 8;
6354 child_byte_offset = 0;
6355 child_is_base_class =
true;
6357 return GetType(ivar_qual_type);
6366 const uint32_t superclass_idx = child_idx;
6368 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6369 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6370 ivar_end = class_interface_decl->ivar_end();
6372 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
6374 if (child_idx == idx) {
6375 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6377 clang::QualType ivar_qual_type(ivar_decl->getType());
6379 child_name.assign(ivar_decl->getNameAsString());
6381 clang::TypeInfo ivar_type_info =
6384 child_byte_size = ivar_type_info.Width / 8;
6400 if (objc_runtime !=
nullptr) {
6403 parent_ast_type, ivar_decl->getNameAsString().c_str());
6411 if (child_byte_offset ==
6414 interface_layout.getFieldOffset(child_idx - superclass_idx);
6415 child_byte_offset = bit_offset / 8;
6427 interface_layout.getFieldOffset(child_idx - superclass_idx);
6429 child_bitfield_bit_offset = bit_offset % 8;
6431 return GetType(ivar_qual_type);
6438 case clang::Type::ObjCObjectPointer: {
6440 return llvm::createStringError(
"invalid index");
6444 child_is_deref_of_parent =
false;
6445 bool tmp_child_is_deref_of_parent =
false;
6447 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6448 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6449 child_bitfield_bit_size, child_bitfield_bit_offset,
6450 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6453 child_is_deref_of_parent =
true;
6454 const char *parent_name =
6457 child_name.assign(1,
'*');
6458 child_name += parent_name;
6463 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6465 return size_or_err.takeError();
6466 child_byte_size = *size_or_err;
6467 child_byte_offset = 0;
6468 return pointee_clang_type;
6473 case clang::Type::Vector:
6474 case clang::Type::ExtVector: {
6476 return llvm::createStringError(
"invalid index");
6477 const clang::VectorType *array =
6478 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6480 return llvm::createStringError(
"unexpected vector type");
6484 return llvm::createStringError(
"cannot complete type");
6486 char element_name[64];
6487 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6488 static_cast<uint64_t
>(idx));
6489 child_name.assign(element_name);
6490 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6492 return size_or_err.takeError();
6493 child_byte_size = *size_or_err;
6494 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6495 return element_type;
6497 case clang::Type::ConstantArray:
6498 case clang::Type::IncompleteArray: {
6499 if (!ignore_array_bounds && !idx_is_valid)
6500 return llvm::createStringError(
"invalid index");
6501 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6503 return llvm::createStringError(
"unexpected array type");
6506 return llvm::createStringError(
"cannot complete type");
6508 child_name = std::string(llvm::formatv(
"[{0}]", idx));
6509 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6511 return size_or_err.takeError();
6512 child_byte_size = *size_or_err;
6513 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6514 return element_type;
6516 case clang::Type::Pointer: {
6521 return llvm::createStringError(
"cannot dereference void *");
6524 child_is_deref_of_parent =
false;
6525 bool tmp_child_is_deref_of_parent =
false;
6527 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6528 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6529 child_bitfield_bit_size, child_bitfield_bit_offset,
6530 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6533 child_is_deref_of_parent =
true;
6537 child_name.assign(1,
'*');
6538 child_name += parent_name;
6543 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6545 return size_or_err.takeError();
6546 child_byte_size = *size_or_err;
6547 child_byte_offset = 0;
6548 return pointee_clang_type;
6553 case clang::Type::LValueReference:
6554 case clang::Type::RValueReference: {
6556 return llvm::createStringError(
"invalid index");
6557 const clang::ReferenceType *reference_type =
6558 llvm::cast<clang::ReferenceType>(
6562 child_is_deref_of_parent =
false;
6563 bool tmp_child_is_deref_of_parent =
false;
6565 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6566 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6567 child_bitfield_bit_size, child_bitfield_bit_offset,
6568 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6573 child_name.assign(1,
'&');
6574 child_name += parent_name;
6579 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6581 return size_or_err.takeError();
6582 child_byte_size = *size_or_err;
6583 child_byte_offset = 0;
6584 return pointee_clang_type;
6591 return llvm::createStringError(
"cannot enumerate children");
6595 const clang::RecordDecl *record_decl,
6596 const clang::CXXBaseSpecifier *base_spec,
6597 bool omit_empty_base_classes) {
6598 uint32_t child_idx = 0;
6600 const clang::CXXRecordDecl *cxx_record_decl =
6601 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6603 if (cxx_record_decl) {
6604 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6605 for (base_class = cxx_record_decl->bases_begin(),
6606 base_class_end = cxx_record_decl->bases_end();
6607 base_class != base_class_end; ++base_class) {
6608 if (omit_empty_base_classes) {
6613 if (base_class == base_spec)
6623 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6624 bool omit_empty_base_classes) {
6626 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6627 omit_empty_base_classes);
6629 clang::RecordDecl::field_iterator field, field_end;
6630 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6631 field != field_end; ++field, ++child_idx) {
6632 if (field->getCanonicalDecl() == canonical_decl)
6674 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6675 if (type && !name.empty()) {
6677 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6678 switch (type_class) {
6679 case clang::Type::Record:
6681 const clang::RecordType *record_type =
6682 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6683 const clang::RecordDecl *record_decl =
6684 record_type->getDecl()->getDefinitionOrSelf();
6686 assert(record_decl);
6687 uint32_t child_idx = 0;
6689 const clang::CXXRecordDecl *cxx_record_decl =
6690 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6693 clang::RecordDecl::field_iterator field, field_end;
6694 for (field = record_decl->field_begin(),
6695 field_end = record_decl->field_end();
6696 field != field_end; ++field, ++child_idx) {
6697 llvm::StringRef field_name = field->getName();
6698 if (field_name.empty()) {
6700 std::vector<uint32_t> save_indices = child_indexes;
6701 child_indexes.push_back(
6703 cxx_record_decl, omit_empty_base_classes));
6705 name, omit_empty_base_classes, child_indexes))
6706 return child_indexes.size();
6707 child_indexes = std::move(save_indices);
6708 }
else if (field_name == name) {
6710 child_indexes.push_back(
6712 cxx_record_decl, omit_empty_base_classes));
6713 return child_indexes.size();
6717 if (cxx_record_decl) {
6718 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6721 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6722 clang::DeclarationName decl_name(&ident_ref);
6724 clang::CXXBasePaths paths;
6725 if (cxx_record_decl->lookupInBases(
6726 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6727 clang::CXXBasePath &path) {
6728 CXXRecordDecl *record =
6729 specifier->getType()->getAsCXXRecordDecl();
6730 auto r = record->lookup(decl_name);
6731 path.Decls = r.begin();
6735 clang::CXXBasePaths::const_paths_iterator path,
6736 path_end = paths.end();
6737 for (path = paths.begin(); path != path_end; ++path) {
6738 const size_t num_path_elements = path->size();
6739 for (
size_t e = 0; e < num_path_elements; ++e) {
6740 clang::CXXBasePathElement elem = (*path)[e];
6743 omit_empty_base_classes);
6745 child_indexes.clear();
6748 child_indexes.push_back(child_idx);
6749 parent_record_decl = elem.Base->getType()
6750 ->castAs<clang::RecordType>()
6752 ->getDefinitionOrSelf();
6755 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6758 parent_record_decl, *I, omit_empty_base_classes);
6760 child_indexes.clear();
6763 child_indexes.push_back(child_idx);
6767 return child_indexes.size();
6773 case clang::Type::ObjCObject:
6774 case clang::Type::ObjCInterface:
6776 llvm::StringRef name_sref(name);
6777 const clang::ObjCObjectType *objc_class_type =
6778 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6779 assert(objc_class_type);
6780 if (objc_class_type) {
6781 uint32_t child_idx = 0;
6782 clang::ObjCInterfaceDecl *class_interface_decl =
6783 objc_class_type->getInterface();
6785 if (class_interface_decl) {
6786 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6787 ivar_end = class_interface_decl->ivar_end();
6788 clang::ObjCInterfaceDecl *superclass_interface_decl =
6789 class_interface_decl->getSuperClass();
6791 for (ivar_pos = class_interface_decl->ivar_begin();
6792 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6793 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6795 if (ivar_decl->getName() == name_sref) {
6796 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6797 (omit_empty_base_classes &&
6801 child_indexes.push_back(child_idx);
6802 return child_indexes.size();
6806 if (superclass_interface_decl) {
6810 child_indexes.push_back(0);
6814 superclass_interface_decl));
6816 name, omit_empty_base_classes, child_indexes)) {
6819 return child_indexes.size();
6824 child_indexes.pop_back();
6831 case clang::Type::ObjCObjectPointer: {
6833 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6834 ->getPointeeType());
6836 name, omit_empty_base_classes, child_indexes);
6839 case clang::Type::LValueReference:
6840 case clang::Type::RValueReference: {
6841 const clang::ReferenceType *reference_type =
6842 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
6843 clang::QualType pointee_type(reference_type->getPointeeType());
6848 name, omit_empty_base_classes, child_indexes);
6852 case clang::Type::Pointer: {
6857 name, omit_empty_base_classes, child_indexes);
6872llvm::Expected<uint32_t>
6874 llvm::StringRef name,
6875 bool omit_empty_base_classes) {
6876 if (type && !name.empty()) {
6879 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6881 switch (type_class) {
6882 case clang::Type::Record:
6884 const clang::RecordType *record_type =
6885 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6886 const clang::RecordDecl *record_decl =
6887 record_type->getDecl()->getDefinitionOrSelf();
6889 assert(record_decl);
6890 uint32_t child_idx = 0;
6892 const clang::CXXRecordDecl *cxx_record_decl =
6893 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6895 if (cxx_record_decl) {
6896 clang::CXXRecordDecl::base_class_const_iterator base_class,
6898 for (base_class = cxx_record_decl->bases_begin(),
6899 base_class_end = cxx_record_decl->bases_end();
6900 base_class != base_class_end; ++base_class) {
6902 clang::CXXRecordDecl *base_class_decl =
6903 llvm::cast<clang::CXXRecordDecl>(
6904 base_class->getType()
6905 ->castAs<clang::RecordType>()
6907 ->getDefinitionOrSelf();
6908 if (omit_empty_base_classes &&
6913 std::string base_class_type_name(
6915 if (base_class_type_name == name)
6922 clang::RecordDecl::field_iterator field, field_end;
6923 for (field = record_decl->field_begin(),
6924 field_end = record_decl->field_end();
6925 field != field_end; ++field, ++child_idx) {
6926 if (field->getName() == name)
6932 case clang::Type::ObjCObject:
6933 case clang::Type::ObjCInterface:
6935 const clang::ObjCObjectType *objc_class_type =
6936 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6937 assert(objc_class_type);
6938 if (objc_class_type) {
6939 uint32_t child_idx = 0;
6940 clang::ObjCInterfaceDecl *class_interface_decl =
6941 objc_class_type->getInterface();
6943 if (class_interface_decl) {
6944 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6945 ivar_end = class_interface_decl->ivar_end();
6946 clang::ObjCInterfaceDecl *superclass_interface_decl =
6947 class_interface_decl->getSuperClass();
6949 for (ivar_pos = class_interface_decl->ivar_begin();
6950 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6951 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6953 if (ivar_decl->getName() == name) {
6954 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6955 (omit_empty_base_classes &&
6963 if (superclass_interface_decl) {
6964 if (superclass_interface_decl->getName() == name)
6972 case clang::Type::ObjCObjectPointer: {
6974 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6975 ->getPointeeType());
6977 name, omit_empty_base_classes);
6980 case clang::Type::LValueReference:
6981 case clang::Type::RValueReference: {
6982 const clang::ReferenceType *reference_type =
6983 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
6988 omit_empty_base_classes);
6992 case clang::Type::Pointer: {
6993 const clang::PointerType *pointer_type =
6994 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
6999 omit_empty_base_classes);
7007 return llvm::createStringError(
"Type has no child named '%s'",
7008 name.str().c_str());
7013 llvm::StringRef name) {
7014 if (!type || name.empty())
7018 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7020 switch (type_class) {
7021 case clang::Type::Record: {
7024 const clang::RecordType *record_type =
7025 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7026 const clang::RecordDecl *record_decl =
7027 record_type->getDecl()->getDefinitionOrSelf();
7029 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7030 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7031 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7033 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7035 ElaboratedTypeKeyword::None, std::nullopt,
7051 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7052 return isa<clang::ClassTemplateSpecializationDecl>(
7053 cxx_record_decl->getDecl());
7064 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7065 switch (type_class) {
7066 case clang::Type::Record:
7068 const clang::CXXRecordDecl *cxx_record_decl =
7069 qual_type->getAsCXXRecordDecl();
7070 if (cxx_record_decl) {
7071 const clang::ClassTemplateSpecializationDecl *template_decl =
7072 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7074 if (template_decl) {
7075 const auto &template_arg_list = template_decl->getTemplateArgs();
7076 size_t num_args = template_arg_list.size();
7077 assert(num_args &&
"template specialization without any args");
7078 if (expand_pack && num_args) {
7079 const auto &pack = template_arg_list[num_args - 1];
7080 if (pack.getKind() == clang::TemplateArgument::Pack)
7081 num_args += pack.pack_size() - 1;
7096const clang::ClassTemplateSpecializationDecl *
7103 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7104 switch (type_class) {
7105 case clang::Type::Record: {
7108 const clang::CXXRecordDecl *cxx_record_decl =
7109 qual_type->getAsCXXRecordDecl();
7110 if (!cxx_record_decl)
7112 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7121const TemplateArgument *
7123 size_t idx,
bool expand_pack) {
7124 const auto &args = decl->getTemplateArgs();
7125 const size_t args_size = args.size();
7127 assert(args_size &&
"template specialization without any args");
7131 const size_t last_idx = args_size - 1;
7140 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7141 return idx >= args.size() ? nullptr : &args[idx];
7146 const auto &pack = args[last_idx];
7147 const size_t pack_idx = idx - last_idx;
7148 if (pack_idx >= pack.pack_size())
7150 return &pack.pack_elements()[pack_idx];
7155 size_t arg_idx,
bool expand_pack) {
7156 const clang::ClassTemplateSpecializationDecl *template_decl =
7165 switch (arg->getKind()) {
7166 case clang::TemplateArgument::Null:
7169 case clang::TemplateArgument::NullPtr:
7172 case clang::TemplateArgument::Type:
7175 case clang::TemplateArgument::Declaration:
7178 case clang::TemplateArgument::Integral:
7181 case clang::TemplateArgument::Template:
7184 case clang::TemplateArgument::TemplateExpansion:
7187 case clang::TemplateArgument::Expression:
7190 case clang::TemplateArgument::Pack:
7193 case clang::TemplateArgument::StructuralValue:
7196 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7201 size_t idx,
bool expand_pack) {
7202 const clang::ClassTemplateSpecializationDecl *template_decl =
7208 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7211 return GetType(arg->getAsType());
7214std::optional<CompilerType::IntegralTemplateArgument>
7216 size_t idx,
bool expand_pack) {
7217 const clang::ClassTemplateSpecializationDecl *template_decl =
7220 return std::nullopt;
7224 return std::nullopt;
7226 switch (arg->getKind()) {
7227 case clang::TemplateArgument::Integral:
7228 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7229 case clang::TemplateArgument::StructuralValue: {
7230 clang::APValue value = arg->getAsStructuralValue();
7233 if (value.isFloat())
7234 return {{value.getFloat(), type}};
7237 return {{value.getInt(), type}};
7239 return std::nullopt;
7242 return std::nullopt;
7256 bool is_signed =
false;
7257 bool isUnscopedEnumerationType =
7259 if (isUnscopedEnumerationType)
7280 llvm_unreachable(
"All cases handled above.");
7283llvm::Expected<CompilerType>
7300 uint64_t from_size = 0;
7308 llvm::Expected<uint64_t> from_size = from.
GetByteSize(exe_scope);
7310 return from_size.takeError();
7320 llvm::Expected<uint64_t> byte_size = type.GetByteSize(exe_scope);
7322 return byte_size.takeError();
7323 if (*from_size < *byte_size ||
7324 (*from_size == *byte_size && is_signed == type.IsSigned())) {
7328 llvm_unreachable(
"char type should fit into long long");
7333 llvm::Expected<uint64_t> int_byte_size = int_type.
GetByteSize(exe_scope);
7335 return int_byte_size.takeError();
7343 return (from_size == *int_byte_size)
7349 const clang::EnumType *enutype =
7352 return enutype->getDecl()->getDefinitionOrSelf();
7357 const clang::RecordType *record_type =
7360 return record_type->getDecl()->getDefinitionOrSelf();
7368clang::TypedefNameDecl *
7370 const clang::TypedefType *typedef_type =
7373 return typedef_type->getDecl();
7377clang::CXXRecordDecl *
7382clang::ObjCInterfaceDecl *
7384 const clang::ObjCObjectType *objc_class_type =
7385 llvm::dyn_cast<clang::ObjCObjectType>(
7387 if (objc_class_type)
7388 return objc_class_type->getInterface();
7394 const CompilerType &field_clang_type, uint32_t bitfield_bit_size) {
7400 clang::ASTContext &clang_ast = ast->getASTContext();
7401 clang::IdentifierInfo *ident =
nullptr;
7403 ident = &clang_ast.Idents.get(name);
7405 clang::FieldDecl *field =
nullptr;
7407 clang::Expr *bit_width =
nullptr;
7408 if (bitfield_bit_size != 0) {
7409 if (clang_ast.IntTy.isNull()) {
7412 "{0} failed: builtin ASTContext types have not been initialized");
7416 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7418 bit_width =
new (clang_ast)
7419 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7420 clang_ast.IntTy, clang::SourceLocation());
7421 bit_width = clang::ConstantExpr::Create(
7422 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7425 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7427 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7428 field->setDeclContext(record_decl);
7429 field->setDeclName(ident);
7432 field->setBitWidth(bit_width);
7438 if (
const clang::TagType *TagT =
7439 field->getType()->getAs<clang::TagType>()) {
7440 if (clang::RecordDecl *Rec =
7441 llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
7442 if (!Rec->getDeclName()) {
7443 Rec->setAnonymousStructOrUnion(
true);
7444 field->setImplicit();
7450 field->setAccess(AS_public);
7452 record_decl->addDecl(field);
7457 clang::ObjCInterfaceDecl *class_interface_decl =
7458 ast->GetAsObjCInterfaceDecl(type);
7460 if (class_interface_decl) {
7461 const bool is_synthesized =
false;
7466 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7467 ivar->setDeclContext(class_interface_decl);
7468 ivar->setDeclName(ident);
7470 ivar->setAccessControl(ObjCIvarDecl::AccessControl::Public);
7472 ivar->setBitWidth(bit_width);
7473 ivar->setSynthesize(is_synthesized);
7478 class_interface_decl->addDecl(field);
7495 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7500 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7502 IndirectFieldVector indirect_fields;
7503 clang::RecordDecl::field_iterator field_pos;
7504 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7505 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7506 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7507 last_field_pos = field_pos++) {
7508 if (field_pos->isAnonymousStructOrUnion()) {
7509 clang::QualType field_qual_type = field_pos->getType();
7511 const clang::RecordType *field_record_type =
7512 field_qual_type->getAs<clang::RecordType>();
7514 if (!field_record_type)
7517 clang::RecordDecl *field_record_decl =
7518 field_record_type->getDecl()->getDefinition();
7520 if (!field_record_decl)
7523 for (clang::RecordDecl::decl_iterator
7524 di = field_record_decl->decls_begin(),
7525 de = field_record_decl->decls_end();
7527 if (clang::FieldDecl *nested_field_decl =
7528 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7529 clang::NamedDecl **chain =
7530 new (ast->getASTContext()) clang::NamedDecl *[2];
7531 chain[0] = *field_pos;
7532 chain[1] = nested_field_decl;
7533 clang::IndirectFieldDecl *indirect_field =
7534 clang::IndirectFieldDecl::Create(
7535 ast->getASTContext(), record_decl, clang::SourceLocation(),
7536 nested_field_decl->getIdentifier(),
7537 nested_field_decl->getType(), {chain, 2});
7540 indirect_field->setImplicit();
7542 indirect_field->setAccess(AS_public);
7544 indirect_fields.push_back(indirect_field);
7545 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7546 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7547 size_t nested_chain_size =
7548 nested_indirect_field_decl->getChainingSize();
7549 clang::NamedDecl **chain =
new (ast->getASTContext())
7550 clang::NamedDecl *[nested_chain_size + 1];
7551 chain[0] = *field_pos;
7553 int chain_index = 1;
7554 for (clang::IndirectFieldDecl::chain_iterator
7555 nci = nested_indirect_field_decl->chain_begin(),
7556 nce = nested_indirect_field_decl->chain_end();
7558 chain[chain_index] = *nci;
7562 clang::IndirectFieldDecl *indirect_field =
7563 clang::IndirectFieldDecl::Create(
7564 ast->getASTContext(), record_decl, clang::SourceLocation(),
7565 nested_indirect_field_decl->getIdentifier(),
7566 nested_indirect_field_decl->getType(),
7567 {chain, nested_chain_size + 1});
7570 indirect_field->setImplicit();
7572 indirect_field->setAccess(AS_public);
7574 indirect_fields.push_back(indirect_field);
7582 if (last_field_pos != field_end_pos) {
7583 if (last_field_pos->getType()->isIncompleteArrayType())
7584 record_decl->hasFlexibleArrayMember();
7587 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7588 ife = indirect_fields.end();
7590 record_decl->addDecl(*ifi);
7603 record_decl->addAttr(
7604 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7611 llvm::StringRef name,
7620 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7624 clang::VarDecl *var_decl =
nullptr;
7625 clang::IdentifierInfo *ident =
nullptr;
7627 ident = &ast->getASTContext().Idents.get(name);
7630 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7631 var_decl->setDeclContext(record_decl);
7632 var_decl->setDeclName(ident);
7634 var_decl->setStorageClass(clang::SC_Static);
7639 var_decl->setAccess(AS_public);
7640 record_decl->addDecl(var_decl);
7642 VerifyDecl(var_decl);
7648 VarDecl *var,
const llvm::APInt &init_value) {
7649 assert(!var->hasInit() &&
"variable already initialized");
7651 clang::ASTContext &ast = var->getASTContext();
7652 QualType qt = var->getType();
7653 assert(qt->isIntegralOrEnumerationType() &&
7654 "only integer or enum types supported");
7657 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7658 const EnumDecl *enum_decl = enum_type->getDecl()->getDefinitionOrSelf();
7659 qt = enum_decl->getIntegerType();
7663 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7664 var->setInit(CXXBoolLiteralExpr::Create(
7665 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7667 var->setInit(IntegerLiteral::Create(
7668 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7673 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7674 assert(!var->hasInit() &&
"variable already initialized");
7676 clang::ASTContext &ast = var->getASTContext();
7677 QualType qt = var->getType();
7678 assert(qt->isFloatingType() &&
"only floating point types supported");
7679 var->setInit(FloatingLiteral::Create(
7680 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7683llvm::SmallVector<clang::ParmVarDecl *>
7685 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7686 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7688 assert(parameter_names.empty() ||
7689 parameter_names.size() == prototype.getNumParams());
7691 llvm::SmallVector<clang::ParmVarDecl *> params;
7692 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7694 llvm::StringRef name =
7695 !parameter_names.empty() ? parameter_names[param_index] :
"";
7699 GetType(prototype.getParamType(param_index)),
7700 clang::SC_None,
false);
7703 params.push_back(param);
7711 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7712 bool is_virtual,
bool is_static,
bool is_inline,
bool is_explicit,
7713 bool is_attr_used,
bool is_artificial) {
7714 if (!type || !method_clang_type.
IsValid() || name.empty())
7719 clang::CXXRecordDecl *cxx_record_decl =
7720 record_qual_type->getAsCXXRecordDecl();
7722 if (cxx_record_decl ==
nullptr)
7727 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7729 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7731 const clang::FunctionType *function_type =
7732 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7734 if (function_type ==
nullptr)
7737 const clang::FunctionProtoType *method_function_prototype(
7738 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7740 if (!method_function_prototype)
7743 unsigned int num_params = method_function_prototype->getNumParams();
7745 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7746 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7751 const clang::ExplicitSpecifier explicit_spec(
7752 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7753 : clang::ExplicitSpecKind::ResolvedFalse);
7755 if (name.starts_with(
"~")) {
7756 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7758 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7759 cxx_dtor_decl->setDeclName(
7762 cxx_dtor_decl->setType(method_qual_type);
7763 cxx_dtor_decl->setImplicit(is_artificial);
7764 cxx_dtor_decl->setInlineSpecified(is_inline);
7765 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7766 cxx_method_decl = cxx_dtor_decl;
7767 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7768 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7770 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7771 cxx_ctor_decl->setDeclName(
7774 cxx_ctor_decl->setType(method_qual_type);
7775 cxx_ctor_decl->setImplicit(is_artificial);
7776 cxx_ctor_decl->setInlineSpecified(is_inline);
7777 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7778 cxx_ctor_decl->setNumCtorInitializers(0);
7779 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7780 cxx_method_decl = cxx_ctor_decl;
7782 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7783 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7786 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7791 const bool is_method =
true;
7793 is_method, op_kind, num_params))
7795 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7797 cxx_method_decl->setDeclContext(cxx_record_decl);
7798 cxx_method_decl->setDeclName(
7799 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7800 cxx_method_decl->setType(method_qual_type);
7801 cxx_method_decl->setStorageClass(SC);
7802 cxx_method_decl->setInlineSpecified(is_inline);
7803 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7804 }
else if (num_params == 0) {
7806 auto *cxx_conversion_decl =
7807 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7809 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7810 cxx_conversion_decl->setDeclName(
7811 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7813 function_type->getReturnType())));
7814 cxx_conversion_decl->setType(method_qual_type);
7815 cxx_conversion_decl->setInlineSpecified(is_inline);
7816 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7817 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7818 cxx_method_decl = cxx_conversion_decl;
7822 if (cxx_method_decl ==
nullptr) {
7823 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7825 cxx_method_decl->setDeclContext(cxx_record_decl);
7826 cxx_method_decl->setDeclName(decl_name);
7827 cxx_method_decl->setType(method_qual_type);
7828 cxx_method_decl->setInlineSpecified(is_inline);
7829 cxx_method_decl->setStorageClass(SC);
7830 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7835 cxx_method_decl->setAccess(AS_public);
7836 cxx_method_decl->setVirtualAsWritten(is_virtual);
7839 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7841 if (!asm_label.empty())
7842 cxx_method_decl->addAttr(
7843 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7848 cxx_method_decl, *method_function_prototype, {}));
7850 cxx_record_decl->addDecl(cxx_method_decl);
7859 if (is_artificial) {
7860 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7861 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7862 (cxx_ctor_decl->isCopyConstructor() &&
7863 cxx_record_decl->hasTrivialCopyConstructor()) ||
7864 (cxx_ctor_decl->isMoveConstructor() &&
7865 cxx_record_decl->hasTrivialMoveConstructor()))) {
7866 cxx_ctor_decl->setDefaulted();
7867 cxx_ctor_decl->setTrivial(
true);
7868 }
else if (cxx_dtor_decl) {
7869 if (cxx_record_decl->hasTrivialDestructor()) {
7870 cxx_dtor_decl->setDefaulted();
7871 cxx_dtor_decl->setTrivial(
true);
7873 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7874 cxx_record_decl->hasTrivialCopyAssignment()) ||
7875 (cxx_method_decl->isMoveAssignmentOperator() &&
7876 cxx_record_decl->hasTrivialMoveAssignment())) {
7877 cxx_method_decl->setDefaulted();
7878 cxx_method_decl->setTrivial(
true);
7882 VerifyDecl(cxx_method_decl);
7884 return cxx_method_decl;
7890 for (
auto *method : record->methods())
7891 addOverridesForMethod(method);
7894#pragma mark C++ Base Classes
7896std::unique_ptr<clang::CXXBaseSpecifier>
7899 bool base_of_class) {
7903 return std::make_unique<clang::CXXBaseSpecifier>(
7904 clang::SourceRange(), is_virtual, base_of_class,
7907 clang::SourceLocation());
7912 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
7916 if (!cxx_record_decl)
7918 std::vector<clang::CXXBaseSpecifier *> raw_bases;
7919 raw_bases.reserve(bases.size());
7923 for (
auto &b : bases)
7924 raw_bases.push_back(b.get());
7925 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
7934 clang::ASTContext &clang_ast = ast->getASTContext();
7936 if (type && superclass_clang_type.
IsValid() &&
7938 clang::ObjCInterfaceDecl *class_interface_decl =
7940 clang::ObjCInterfaceDecl *super_interface_decl =
7942 if (class_interface_decl && super_interface_decl) {
7943 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
7944 clang_ast.getObjCInterfaceType(super_interface_decl)));
7953 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
7954 const char *property_setter_name,
const char *property_getter_name,
7956 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
7957 property_name[0] ==
'\0')
7962 clang::ASTContext &clang_ast = ast->getASTContext();
7965 if (!class_interface_decl)
7970 if (property_clang_type.
IsValid())
7971 property_clang_type_to_access = property_clang_type;
7973 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
7975 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
7978 clang::TypeSourceInfo *prop_type_source;
7980 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
7982 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
7985 clang::ObjCPropertyDecl *property_decl =
7986 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7987 property_decl->setDeclContext(class_interface_decl);
7988 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
7989 property_decl->setType(ivar_decl
7990 ? ivar_decl->getType()
7998 ast->SetMetadata(property_decl, metadata);
8000 class_interface_decl->addDecl(property_decl);
8002 clang::Selector setter_sel, getter_sel;
8004 if (property_setter_name) {
8005 std::string property_setter_no_colon(property_setter_name,
8006 strlen(property_setter_name) - 1);
8007 const clang::IdentifierInfo *setter_ident =
8008 &clang_ast.Idents.get(property_setter_no_colon);
8009 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8010 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
8011 std::string setter_sel_string(
"set");
8012 setter_sel_string.push_back(::toupper(property_name[0]));
8013 setter_sel_string.append(&property_name[1]);
8014 const clang::IdentifierInfo *setter_ident =
8015 &clang_ast.Idents.get(setter_sel_string);
8016 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8018 property_decl->setSetterName(setter_sel);
8019 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
8021 if (property_getter_name !=
nullptr) {
8022 const clang::IdentifierInfo *getter_ident =
8023 &clang_ast.Idents.get(property_getter_name);
8024 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8026 const clang::IdentifierInfo *getter_ident =
8027 &clang_ast.Idents.get(property_name);
8028 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8030 property_decl->setGetterName(getter_sel);
8031 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
8034 property_decl->setPropertyIvarDecl(ivar_decl);
8036 if (property_attributes & DW_APPLE_PROPERTY_readonly)
8037 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
8038 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
8039 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
8040 if (property_attributes & DW_APPLE_PROPERTY_assign)
8041 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
8042 if (property_attributes & DW_APPLE_PROPERTY_retain)
8043 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
8044 if (property_attributes & DW_APPLE_PROPERTY_copy)
8045 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
8046 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8047 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
8048 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
8049 property_decl->setPropertyAttributes(
8050 ObjCPropertyAttribute::kind_nullability);
8051 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
8052 property_decl->setPropertyAttributes(
8053 ObjCPropertyAttribute::kind_null_resettable);
8054 if (property_attributes & ObjCPropertyAttribute::kind_class)
8055 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8057 const bool isInstance =
8058 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8060 clang::ObjCMethodDecl *getter =
nullptr;
8061 if (!getter_sel.isNull())
8062 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8063 : class_interface_decl->lookupClassMethod(getter_sel);
8064 if (!getter_sel.isNull() && !getter) {
8065 const bool isVariadic =
false;
8066 const bool isPropertyAccessor =
true;
8067 const bool isSynthesizedAccessorStub =
false;
8068 const bool isImplicitlyDeclared =
true;
8069 const bool isDefined =
false;
8070 const clang::ObjCImplementationControl impControl =
8071 clang::ObjCImplementationControl::None;
8072 const bool HasRelatedResultType =
false;
8075 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8076 getter->setDeclName(getter_sel);
8078 getter->setDeclContext(class_interface_decl);
8079 getter->setInstanceMethod(isInstance);
8080 getter->setVariadic(isVariadic);
8081 getter->setPropertyAccessor(isPropertyAccessor);
8082 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8083 getter->setImplicit(isImplicitlyDeclared);
8084 getter->setDefined(isDefined);
8085 getter->setDeclImplementation(impControl);
8086 getter->setRelatedResultType(HasRelatedResultType);
8090 ast->SetMetadata(getter, metadata);
8092 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8093 llvm::ArrayRef<clang::SourceLocation>());
8094 class_interface_decl->addDecl(getter);
8098 getter->setPropertyAccessor(
true);
8099 property_decl->setGetterMethodDecl(getter);
8102 clang::ObjCMethodDecl *setter =
nullptr;
8103 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8104 : class_interface_decl->lookupClassMethod(setter_sel);
8105 if (!setter_sel.isNull() && !setter) {
8106 clang::QualType result_type = clang_ast.VoidTy;
8107 const bool isVariadic =
false;
8108 const bool isPropertyAccessor =
true;
8109 const bool isSynthesizedAccessorStub =
false;
8110 const bool isImplicitlyDeclared =
true;
8111 const bool isDefined =
false;
8112 const clang::ObjCImplementationControl impControl =
8113 clang::ObjCImplementationControl::None;
8114 const bool HasRelatedResultType =
false;
8117 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8118 setter->setDeclName(setter_sel);
8119 setter->setReturnType(result_type);
8120 setter->setDeclContext(class_interface_decl);
8121 setter->setInstanceMethod(isInstance);
8122 setter->setVariadic(isVariadic);
8123 setter->setPropertyAccessor(isPropertyAccessor);
8124 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8125 setter->setImplicit(isImplicitlyDeclared);
8126 setter->setDefined(isDefined);
8127 setter->setDeclImplementation(impControl);
8128 setter->setRelatedResultType(HasRelatedResultType);
8132 ast->SetMetadata(setter, metadata);
8134 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8135 params.push_back(clang::ParmVarDecl::Create(
8136 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8139 clang::SC_Auto,
nullptr));
8141 setter->setMethodParams(clang_ast,
8142 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8143 llvm::ArrayRef<clang::SourceLocation>());
8145 class_interface_decl->addDecl(setter);
8149 setter->setPropertyAccessor(
true);
8150 property_decl->setSetterMethodDecl(setter);
8161 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8162 bool is_objc_direct_call) {
8163 if (!type || !method_clang_type.
IsValid())
8168 if (class_interface_decl ==
nullptr)
8171 if (lldb_ast ==
nullptr)
8173 clang::ASTContext &ast = lldb_ast->getASTContext();
8175 const char *selector_start = ::strchr(name,
' ');
8176 if (selector_start ==
nullptr)
8180 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8185 unsigned num_selectors_with_args = 0;
8186 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8188 len = ::strcspn(start,
":]");
8189 bool has_arg = (start[len] ==
':');
8191 ++num_selectors_with_args;
8192 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8197 if (selector_idents.size() == 0)
8200 clang::Selector method_selector = ast.Selectors.getSelector(
8201 num_selectors_with_args ? selector_idents.size() : 0,
8202 selector_idents.data());
8207 const clang::Type *method_type(method_qual_type.getTypePtr());
8209 if (method_type ==
nullptr)
8212 const clang::FunctionProtoType *method_function_prototype(
8213 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8215 if (!method_function_prototype)
8218 const bool isInstance = (name[0] ==
'-');
8219 const bool isVariadic = is_variadic;
8220 const bool isPropertyAccessor =
false;
8221 const bool isSynthesizedAccessorStub =
false;
8223 const bool isImplicitlyDeclared =
true;
8224 const bool isDefined =
false;
8225 const clang::ObjCImplementationControl impControl =
8226 clang::ObjCImplementationControl::None;
8227 const bool HasRelatedResultType =
false;
8229 const unsigned num_args = method_function_prototype->getNumParams();
8231 if (num_args != num_selectors_with_args)
8235 auto *objc_method_decl =
8236 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8237 objc_method_decl->setDeclName(method_selector);
8238 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8239 objc_method_decl->setDeclContext(
8241 objc_method_decl->setInstanceMethod(isInstance);
8242 objc_method_decl->setVariadic(isVariadic);
8243 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8244 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8245 objc_method_decl->setImplicit(isImplicitlyDeclared);
8246 objc_method_decl->setDefined(isDefined);
8247 objc_method_decl->setDeclImplementation(impControl);
8248 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8251 if (objc_method_decl ==
nullptr)
8255 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8257 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8258 params.push_back(clang::ParmVarDecl::Create(
8259 ast, objc_method_decl, clang::SourceLocation(),
8260 clang::SourceLocation(),
8262 method_function_prototype->getParamType(param_index),
nullptr,
8263 clang::SC_Auto,
nullptr));
8266 objc_method_decl->setMethodParams(
8267 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8268 llvm::ArrayRef<clang::SourceLocation>());
8271 if (is_objc_direct_call) {
8274 objc_method_decl->addAttr(
8275 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8280 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8283 class_interface_decl->addDecl(objc_method_decl);
8285 VerifyDecl(objc_method_decl);
8287 return objc_method_decl;
8297 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8298 switch (type_class) {
8299 case clang::Type::Record: {
8300 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8301 if (cxx_record_decl) {
8302 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8303 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8308 case clang::Type::Enum: {
8309 clang::EnumDecl *enum_decl =
8310 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8312 enum_decl->setHasExternalLexicalStorage(has_extern);
8313 enum_decl->setHasExternalVisibleStorage(has_extern);
8318 case clang::Type::ObjCObject:
8319 case clang::Type::ObjCInterface: {
8320 const clang::ObjCObjectType *objc_class_type =
8321 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8322 assert(objc_class_type);
8323 if (objc_class_type) {
8324 clang::ObjCInterfaceDecl *class_interface_decl =
8325 objc_class_type->getInterface();
8327 if (class_interface_decl) {
8328 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8329 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8345 if (!qual_type.isNull()) {
8346 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8348 clang::TagDecl *tag_decl = tag_type->getDecl();
8350 tag_decl->startDefinition();
8355 const clang::ObjCObjectType *object_type =
8356 qual_type->getAs<clang::ObjCObjectType>();
8358 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8359 if (interface_decl) {
8360 interface_decl->startDefinition();
8371 if (qual_type.isNull())
8375 if (lldb_ast ==
nullptr)
8381 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8383 clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinitionOrSelf();
8385 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8395 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8396 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8397 if (cxx_record_decl->needsImplicitCopyConstructor())
8398 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8399 if (cxx_record_decl->needsImplicitCopyAssignment())
8400 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8403 if (!cxx_record_decl->isCompleteDefinition())
8404 cxx_record_decl->completeDefinition();
8405 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8406 cxx_record_decl->setHasExternalLexicalStorage(
false);
8407 cxx_record_decl->setHasExternalVisibleStorage(
false);
8412 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8416 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8418 if (enum_decl->isCompleteDefinition())
8421 QualType integer_type(enum_decl->getIntegerType());
8422 if (!integer_type.isNull()) {
8423 clang::ASTContext &ast = lldb_ast->getASTContext();
8425 unsigned NumNegativeBits = 0;
8426 unsigned NumPositiveBits = 0;
8427 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8430 clang::QualType BestPromotionType;
8431 clang::QualType BestType;
8432 ast.computeBestEnumTypes(
false, NumNegativeBits,
8433 NumPositiveBits, BestType, BestPromotionType);
8435 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8436 BestPromotionType, NumPositiveBits,
8444 const llvm::APSInt &value) {
8455 if (!enum_opaque_compiler_type)
8458 clang::QualType enum_qual_type(
8461 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8466 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8471 clang::EnumConstantDecl *enumerator_decl =
8472 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8474 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8475 enumerator_decl->setDeclContext(enum_decl);
8476 if (name && name[0])
8477 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8478 enumerator_decl->setType(clang::QualType(enutype, 0));
8480 enumerator_decl->setAccess(AS_public);
8486 enum_decl->addDecl(enumerator_decl);
8488 VerifyDecl(enumerator_decl);
8489 return enumerator_decl;
8494 uint64_t enum_value, uint32_t enum_value_bit_size) {
8496 llvm::APSInt value(enum_value_bit_size,
8505 const clang::Type *clang_type = qt.getTypePtrOrNull();
8506 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8510 return GetType(enum_type->getDecl()->getDefinitionOrSelf()->getIntegerType());
8516 if (type && pointee_type.
IsValid() &&
8521 return ast->GetType(ast->getASTContext().getMemberPointerType(
8530#define DEPTH_INCREMENT 2
8533LLVM_DUMP_METHOD
void
8543struct ScopedASTColor {
8544 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8545 : ast(ast), old_show_colors(ast.getDiagnostics().getShowColors()) {
8546 ast.getDiagnostics().setShowColors(show_colors);
8549 ~ScopedASTColor() { ast.getDiagnostics().setShowColors(old_show_colors); }
8551 clang::ASTContext *
8552 const bool old_show_colors;
8561 clang::CreateASTDumper(output, filter,
8565 false, clang::ADOF_Default);
8568 consumer->HandleTranslationUnit(*
m_ast_up);
8572 llvm::StringRef symbol_name) {
8579 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8580 size_t ntypes = type_list.
GetSize();
8582 for (
size_t i = 0; i < ntypes; ++i) {
8585 if (!symbol_name.empty())
8586 if (symbol_name != type->GetName().GetStringRef())
8589 s << type->GetName().AsCString() <<
"\n";
8592 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8600 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8602 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8614 size_t byte_size, uint32_t bitfield_bit_offset,
8615 uint32_t bitfield_bit_size) {
8616 const clang::EnumType *enutype =
8617 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8618 const clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8620 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8621 const uint64_t enum_svalue =
8624 bitfield_bit_offset)
8626 bitfield_bit_offset);
8627 bool can_be_bitfield =
true;
8628 uint64_t covered_bits = 0;
8629 int num_enumerators = 0;
8637 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8638 if (enumerators.empty())
8639 can_be_bitfield =
false;
8641 for (
auto *enumerator : enumerators) {
8642 llvm::APSInt init_val = enumerator->getInitVal();
8643 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8644 : init_val.getZExtValue();
8645 if (qual_type_is_signed)
8646 val = llvm::SignExtend64(val, 8 * byte_size);
8647 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8648 can_be_bitfield =
false;
8649 covered_bits |= val;
8651 if (val == enum_svalue) {
8660 offset = byte_offset;
8662 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8666 if (!can_be_bitfield) {
8667 if (qual_type_is_signed)
8668 s.
Printf(
"%" PRIi64, enum_svalue);
8670 s.
Printf(
"%" PRIu64, enum_uvalue);
8677 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8681 uint64_t remaining_value = enum_uvalue;
8682 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8683 values.reserve(num_enumerators);
8684 for (
auto *enumerator : enum_decl->enumerators())
8685 if (
auto val = enumerator->getInitVal().getZExtValue())
8686 values.emplace_back(val, enumerator->getName());
8691 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8692 return llvm::popcount(a.first) > llvm::popcount(b.first);
8695 for (
const auto &val : values) {
8696 if ((remaining_value & val.first) != val.first)
8698 remaining_value &= ~val.first;
8700 if (remaining_value)
8706 if (remaining_value)
8707 s.
Printf(
"0x%" PRIx64, remaining_value);
8715 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8724 switch (qual_type->getTypeClass()) {
8725 case clang::Type::Typedef: {
8726 clang::QualType typedef_qual_type =
8727 llvm::cast<clang::TypedefType>(qual_type)
8729 ->getUnderlyingType();
8732 format = typedef_clang_type.
GetFormat();
8733 clang::TypeInfo typedef_type_info =
8735 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8745 bitfield_bit_offset,
8750 case clang::Type::Enum:
8755 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8756 bitfield_bit_offset, bitfield_bit_size);
8764 uint32_t item_count = 1;
8804 item_count = byte_size;
8809 item_count = byte_size / 2;
8814 item_count = byte_size / 4;
8820 bitfield_bit_size, bitfield_bit_offset,
8836 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(clang_type)) {
8845 clang::QualType qual_type =
8848 llvm::SmallVector<char, 1024> buf;
8849 llvm::raw_svector_ostream llvm_ostrm(buf);
8851 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8852 switch (type_class) {
8853 case clang::Type::ObjCObject:
8854 case clang::Type::ObjCInterface: {
8857 auto *objc_class_type =
8858 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8859 assert(objc_class_type);
8860 if (!objc_class_type)
8862 clang::ObjCInterfaceDecl *class_interface_decl =
8863 objc_class_type->getInterface();
8864 if (!class_interface_decl)
8867 class_interface_decl->dump(llvm_ostrm);
8869 class_interface_decl->print(llvm_ostrm,
8874 case clang::Type::Typedef: {
8875 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8878 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
8880 typedef_decl->dump(llvm_ostrm);
8883 if (!clang_typedef_name.empty()) {
8890 case clang::Type::Record: {
8893 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
8894 const clang::RecordDecl *record_decl = record_type->getDecl();
8896 record_decl->dump(llvm_ostrm);
8898 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
8904 if (
auto *tag_type =
8905 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
8906 if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
8908 tag_decl->dump(llvm_ostrm);
8910 tag_decl->print(llvm_ostrm, 0);
8916 std::string clang_type_name(qual_type.getAsString());
8917 if (!clang_type_name.empty())
8924 if (buf.size() > 0) {
8925 s.
Write(buf.data(), buf.size());
8932 clang::QualType qual_type(
8935 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8936 switch (type_class) {
8937 case clang::Type::Record: {
8938 const clang::CXXRecordDecl *cxx_record_decl =
8939 qual_type->getAsCXXRecordDecl();
8940 if (cxx_record_decl)
8941 printf(
"class %s", cxx_record_decl->getName().str().c_str());
8944 case clang::Type::Enum: {
8945 clang::EnumDecl *enum_decl =
8946 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8948 printf(
"enum %s", enum_decl->getName().str().c_str());
8952 case clang::Type::ObjCObject:
8953 case clang::Type::ObjCInterface: {
8954 const clang::ObjCObjectType *objc_class_type =
8955 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
8956 if (objc_class_type) {
8957 clang::ObjCInterfaceDecl *class_interface_decl =
8958 objc_class_type->getInterface();
8962 if (class_interface_decl)
8963 printf(
"@class %s", class_interface_decl->getName().str().c_str());
8967 case clang::Type::Typedef:
8968 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
8975 case clang::Type::Auto:
8978 llvm::cast<clang::AutoType>(qual_type)
8980 .getAsOpaquePtr()));
8982 case clang::Type::Paren:
8986 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
8989 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
8997 const char *parent_name,
int tag_decl_kind,
8999 if (template_param_infos.
IsValid()) {
9000 std::string template_basename(parent_name);
9002 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
9003 template_basename.erase(i);
9006 template_basename.c_str(), tag_decl_kind,
9007 template_param_infos);
9022 clang::ObjCInterfaceDecl *decl) {
9046 std::make_unique<npdb::PdbAstBuilderClang>(*
this);
9051 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9052 uint64_t &alignment,
9053 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9054 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9056 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9069 field_offsets, base_offsets, vbase_offsets);
9076 clang::NamedDecl *nd =
9077 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9087 if (!label_or_err) {
9088 llvm::consumeError(label_or_err.takeError());
9092 llvm::StringRef mangled = label_or_err->lookup_name;
9100 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9101 static_cast<clang::Decl *
>(opaque_decl));
9103 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9107 if (!mc || !mc->shouldMangleCXXName(nd))
9112 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9117 llvm::SmallVector<char, 1024> buf;
9118 llvm::raw_svector_ostream llvm_ostrm(buf);
9119 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9121 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9124 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9126 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9130 mc->mangleName(nd, llvm_ostrm);
9146 if (clang::FunctionDecl *func_decl =
9147 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9148 return GetType(func_decl->getReturnType());
9149 if (clang::ObjCMethodDecl *objc_method =
9150 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9151 return GetType(objc_method->getReturnType());
9157 if (clang::FunctionDecl *func_decl =
9158 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9159 return func_decl->param_size();
9160 if (clang::ObjCMethodDecl *objc_method =
9161 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9162 return objc_method->param_size();
9168 clang::DeclContext
const *decl_ctx) {
9169 switch (clang_kind) {
9170 case Decl::TranslationUnit:
9172 case Decl::Namespace:
9183 if (decl_ctx->isFunctionOrMethod())
9185 if (decl_ctx->isRecord())
9195 std::vector<lldb_private::CompilerContext> &context) {
9196 if (decl_ctx ==
nullptr)
9199 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9200 if (clang_kind == Decl::TranslationUnit)
9205 context.push_back({compiler_kind, decl_ctx_name});
9208std::vector<lldb_private::CompilerContext>
9210 std::vector<lldb_private::CompilerContext> context;
9213 clang::Decl *decl = (clang::Decl *)opaque_decl;
9215 clang::DeclContext *decl_ctx = decl->getDeclContext();
9218 auto compiler_kind =
9220 context.push_back({compiler_kind, decl_name});
9227 if (clang::FunctionDecl *func_decl =
9228 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9229 if (idx < func_decl->param_size()) {
9230 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9232 return GetType(var_decl->getOriginalType());
9234 }
else if (clang::ObjCMethodDecl *objc_method =
9235 llvm::dyn_cast<clang::ObjCMethodDecl>(
9236 (clang::Decl *)opaque_decl)) {
9237 if (idx < objc_method->param_size())
9238 return GetType(objc_method->parameters()[idx]->getOriginalType());
9244 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9245 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9248 clang::Expr *init_expr = var_decl->getInit();
9251 std::optional<llvm::APSInt> value =
9261 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9262 std::vector<CompilerDecl> found_decls;
9264 if (opaque_decl_ctx && symbol_file) {
9265 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9266 std::set<DeclContext *> searched;
9267 std::multimap<DeclContext *, DeclContext *> search_queue;
9269 for (clang::DeclContext *decl_context = root_decl_ctx;
9270 decl_context !=
nullptr && found_decls.empty();
9271 decl_context = decl_context->getParent()) {
9272 search_queue.insert(std::make_pair(decl_context, decl_context));
9274 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9276 if (!searched.insert(it->second).second)
9281 for (clang::Decl *child : it->second->decls()) {
9282 if (clang::UsingDirectiveDecl *ud =
9283 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9284 if (ignore_using_decls)
9286 clang::DeclContext *from = ud->getCommonAncestor();
9287 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9288 search_queue.insert(
9289 std::make_pair(from, ud->getNominatedNamespace()));
9290 }
else if (clang::UsingDecl *ud =
9291 llvm::dyn_cast<clang::UsingDecl>(child)) {
9292 if (ignore_using_decls)
9294 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9295 clang::Decl *target = usd->getTargetDecl();
9296 if (clang::NamedDecl *nd =
9297 llvm::dyn_cast<clang::NamedDecl>(target)) {
9298 IdentifierInfo *ii = nd->getIdentifier();
9299 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9303 }
else if (clang::NamedDecl *nd =
9304 llvm::dyn_cast<clang::NamedDecl>(child)) {
9305 IdentifierInfo *ii = nd->getIdentifier();
9306 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9357 clang::DeclContext *child_decl_ctx,
9361 if (frame_decl_ctx && symbol_file) {
9362 std::set<DeclContext *> searched;
9363 std::multimap<DeclContext *, DeclContext *> search_queue;
9366 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9370 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9371 decl_ctx = decl_ctx->getParent()) {
9372 if (!decl_ctx->isLookupContext())
9374 if (decl_ctx == parent_decl_ctx)
9377 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9378 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9380 if (searched.find(it->second) != searched.end())
9388 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9391 searched.insert(it->second);
9395 for (clang::Decl *child : it->second->decls()) {
9396 if (clang::UsingDirectiveDecl *ud =
9397 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9398 clang::DeclContext *ns = ud->getNominatedNamespace();
9399 if (ns == parent_decl_ctx)
9402 clang::DeclContext *from = ud->getCommonAncestor();
9403 if (searched.find(ns) == searched.end())
9404 search_queue.insert(std::make_pair(from, ns));
9405 }
else if (child_name) {
9406 if (clang::UsingDecl *ud =
9407 llvm::dyn_cast<clang::UsingDecl>(child)) {
9408 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9409 clang::Decl *target = usd->getTargetDecl();
9410 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9414 IdentifierInfo *ii = nd->getIdentifier();
9415 if (ii ==
nullptr ||
9416 ii->getName() != child_name->
AsCString(
nullptr))
9439 if (opaque_decl_ctx) {
9440 clang::NamedDecl *named_decl =
9441 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9444 llvm::raw_string_ostream stream{name};
9446 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9447 named_decl->getNameForDiagnostic(stream, policy,
false);
9456 if (opaque_decl_ctx) {
9457 clang::NamedDecl *named_decl =
9458 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9466 if (!opaque_decl_ctx)
9469 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9470 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9472 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9474 }
else if (clang::FunctionDecl *fun_decl =
9475 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9476 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9477 return metadata->HasObjectPtr();
9483std::vector<lldb_private::CompilerContext>
9485 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9486 std::vector<lldb_private::CompilerContext> context;
9492 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9493 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9494 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9498 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9499 if (DC->isInlineNamespace())
9502 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9503 return NS->isAnonymousNamespace();
9510 if (decl_ctx == other)
9512 }
while (is_transparent_lookup_allowed(other) &&
9513 (other = other->getParent()));
9520 if (!opaque_decl_ctx)
9523 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9524 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9526 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9528 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9529 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9530 return metadata->GetObjectPtrLanguage();
9550 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9558 return llvm::dyn_cast<clang::CXXMethodDecl>(
9563clang::FunctionDecl *
9566 return llvm::dyn_cast<clang::FunctionDecl>(
9571clang::NamespaceDecl *
9574 return llvm::dyn_cast<clang::NamespaceDecl>(
9579std::optional<ClangASTMetadata>
9581 const Decl *
object) {
9589 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9612 lldbassert(started &&
"Unable to start a class type definition.");
9617 ts->SetDeclIsForcefullyCompleted(td);
9631 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9632 std::unique_ptr<ClangASTSource> ast_source)
9634 m_scratch_ast_source_up(std::move(ast_source)) {
9636 m_scratch_ast_source_up->InstallASTContext(*
this);
9637 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9638 m_scratch_ast_source_up->CreateProxy();
9639 SetExternalSource(proxy_ast_source);
9643 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9651 llvm::Triple triple)
9658 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9670 std::optional<IsolatedASTKind> ast_kind,
9671 bool create_on_demand) {
9674 if (
auto err = type_system_or_err.takeError()) {
9676 "Couldn't get scratch TypeSystemClang: {0}");
9679 auto ts_sp = *type_system_or_err;
9681 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9686 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9688 return std::static_pointer_cast<TypeSystemClang>(
9693static llvm::StringRef
9697 return "C++ modules";
9699 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9703 llvm::StringRef filter,
bool show_color) {
9705 output <<
"State of scratch Clang type system:\n";
9709 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9710 std::vector<KeyAndTS> sorted_typesystems;
9712 sorted_typesystems.emplace_back(a.first, a.second.get());
9713 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9716 for (
const auto &a : sorted_typesystems) {
9719 output <<
"State of scratch Clang type subsystem "
9721 a.second->Dump(output, filter, show_color);
9726 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9734 desired_type, options, ctx_obj);
9739 const ValueList &arg_value_list,
const char *name) {
9744 Process *process = target_sp->GetProcessSP().get();
9749 arg_value_list, name);
9752std::unique_ptr<UtilityFunction>
9759 return std::make_unique<ClangUtilityFunction>(
9760 *target_sp.get(), std::move(text), std::move(name),
9761 target_sp->GetDebugUtilityExpression());
9775 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9779 return std::make_unique<ClangASTSource>(
9784static llvm::StringRef
9788 return "scratch ASTContext for C++ module types";
9790 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9797 return *found_ast->second;
9800 std::shared_ptr<TypeSystemClang> new_ast_sp =
9810 const clang::RecordType *record_type =
9811 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9813 const clang::RecordDecl *record_decl =
9814 record_type->getDecl()->getDefinitionOrSelf();
9815 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9816 return metadata->IsForcefullyCompleted();
9825 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9829 metadata->SetIsForcefullyCompleted();
9837 LLDB_LOG(log,
"Created new TypeSystem for (ASTContext*){0:x} '{1}'",
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
static bool DumpEnumValue(const clang::QualType &qual_type, Stream &s, const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_offset, uint32_t bitfield_bit_size)
static lldb::opaque_compiler_type_t GetObjCFieldAtIndex(clang::ASTContext *ast, clang::ObjCInterfaceDecl *class_interface_decl, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr)
static void ParseLangArgs(LangOptions &Opts, ArchSpec arch)
static clang::QualType GetFullyUnqualifiedType_Impl(clang::ASTContext *ast, clang::QualType qual_type)
const TemplateArgument * GetNthTemplateArgument(const clang::ClassTemplateSpecializationDecl *decl, size_t idx, bool expand_pack)
static int64_t ReadVBaseOffsetFromVTable(Process &process, VTableContextBase &vtable_ctx, lldb::addr_t vtable_ptr, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl)
lldb_private::ThreadSafeDenseMap< clang::ASTContext *, TypeSystemClang * > ClangASTMap
static const clang::RecordType * GetCompleteRecordType(clang::ASTContext *ast, clang::QualType qual_type)
Returns the clang::RecordType of the specified qual_type.
static bool IsClangDeclContext(const CompilerDeclContext &dc)
static bool TemplateParameterAllowsValue(NamedDecl *param, const TemplateArgument &value)
Returns true if the given template parameter can represent the given value.
static CompilerContextKind GetCompilerKind(clang::Decl::Kind clang_kind, clang::DeclContext const *decl_ctx)
static QualType RemoveWrappingTypes(QualType type, ArrayRef< clang::Type::TypeClass > mask={})
Aggressively desugar the provided type, skipping past various kinds of syntactic sugar and other cons...
static TemplateParameterList * CreateTemplateParameterList(ASTContext &ast, const TypeSystemClang::TemplateParameterInfos &template_param_infos, llvm::SmallVector< NamedDecl *, 8 > &template_param_decls)
clang::DeclContext * FindLCABetweenDecls(clang::DeclContext *left, clang::DeclContext *right, clang::DeclContext *root)
static bool check_op_param(bool is_method, clang::OverloadedOperatorKind op_kind, bool unary, bool binary, uint32_t num_params)
static llvm::StringRef GetSpecializedASTName(ScratchTypeSystemClang::IsolatedASTKind feature)
static bool ObjCDeclHasIVars(clang::ObjCInterfaceDecl *class_interface_decl)
static lldb::addr_t GetVTableAddress(Process &process, VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout)
static bool GetCompleteQualType(clang::ASTContext *ast, clang::QualType qual_type)
static std::optional< SymbolFile::ArrayInfo > GetDynamicArrayInfo(TypeSystemClang &ast, SymbolFile *sym_file, clang::QualType qual_type, const ExecutionContext *exe_ctx)
static ConstString ExtractMangledNameFromFunctionCallLabel(llvm::StringRef label)
static const clang::EnumType * GetCompleteEnumType(clang::ASTContext *ast, clang::QualType qual_type)
Returns the clang::EnumType of the specified qual_type.
static llvm::StringRef GetNameForIsolatedASTKind(ScratchTypeSystemClang::IsolatedASTKind kind)
Returns a human-readable name that uniquely identifiers the sub-AST kind.
static void InsertCompilerContext(TypeSystemClang *ts, clang::DeclContext *decl_ctx, std::vector< lldb_private::CompilerContext > &context)
static bool GetVBaseBitOffset(VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl, int32_t &bit_offset)
static bool QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext &ast, QualType qual_type)
static const clang::ObjCObjectType * GetCompleteObjCObjectType(clang::ASTContext *ast, QualType qual_type)
Returns the clang::ObjCObjectType of the specified qual_type.
static ClangASTMap & GetASTMap()
static void SetMemberOwningModule(clang::Decl *member, const clang::Decl *parent)
static bool ClassTemplateAllowsToInstantiationArgs(ClassTemplateDecl *class_template_decl, const TypeSystemClang::TemplateParameterInfos &instantiation_values)
Returns true if the given class template declaration could produce an instantiation with the specifie...
#define LLDB_INVALID_DECL_LEVEL
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &info) override
DiagnosticConsumer * clone(DiagnosticsEngine &Diags) const
A section + offset based address class.
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool CharIsSignedByDefault() const
Returns true if 'char' is a signed type by default in the architecture false otherwise.
Manages and observes all Clang AST node importing in LLDB.
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &bit_size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets)
void ForgetSource(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx)
"lldb/Expression/ClangFunctionCaller.h" Encapsulates a function that can be called.
"lldb/Expression/ClangPersistentVariables.h" Manages persistent values that need to be preserved betw...
"lldb/Expression/ClangUserExpression.h" Encapsulates a single expression for use with Clang
Represents a generic declaration context in a program.
TypeSystem * GetTypeSystem() const
void * GetOpaqueDeclContext() const
Represents a generic declaration such as a function declaration.
lldb::TypeSystemSP GetSharedPointer() const
Generic representation of a type in a programming language.
lldb::LanguageType GetMinimumLanguage()
bool IsEnumerationType(bool &is_signed) const
lldb::BasicType GetBasicTypeEnumeration() const
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
void SetCompilerType(lldb::TypeSystemWP type_system, lldb::opaque_compiler_type_t type)
size_t GetIndexOfChildMemberWithName(llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) const
Lookup a child member given a name.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
lldb::Encoding GetEncoding() const
bool IsPromotableIntegerType() const
uint32_t GetNumDirectBaseClasses() const
ConstString GetTypeName(bool BaseOnly=false) const
bool IsEnumerationIntegerTypeSigned() const
bool DumpTypeValue(Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope)
bool IsAggregateType() const
bool IsInteger() const
This is used when you don't care about the signedness of the integer.
lldb::Format GetFormat() const
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const
CompilerType GetDirectBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
bool GetCompleteType() const
Type Completion.
bool IsUnscopedEnumerationType() const
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
llvm::Expected< uint32_t > GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const
Lookup a child given a name.
llvm::Expected< uint32_t > GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
CompilerType GetCanonicalType() const
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
A class that describes the declaration location of a lldb object.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
Process * GetProcessPtr() const
Returns a pointer to the process object.
static FileSystem & Instance()
bool Test(ValueType bit) const
Test a single flag bit.
bool AnySet(ValueType mask) const
Test one or more flags.
Encapsulates a function that can be called.
static bool LanguageIsC(lldb::LanguageType language)
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
static bool LanguageIsPascal(lldb::LanguageType language)
static bool LanguageIsObjC(lldb::LanguageType language)
static bool IsMangledName(llvm::StringRef name)
A class that describes an executable image and its associated object and symbol files.
virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type, const char *ivar_name)
static ObjCLanguageRuntime * Get(Process &process)
unsigned GetValue() const
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Status &error)
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
uint32_t GetAddressByteSize() const
void Finalize() override
Free up any resources associated with this TypeSystem.
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
llvm::Triple m_triple
The target triple.
std::unique_ptr< ClangASTSource > CreateASTSource()
lldb::TargetWP m_target_wp
TypeSystemClang & GetIsolatedAST(IsolatedASTKind feature)
Returns the requested sub-AST.
UserExpression * GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language, Expression::ResultType desired_type, const EvaluateExpressionOptions &options, ValueObject *ctx_obj) override
std::unique_ptr< ClangASTSource > m_scratch_ast_source_up
The ExternalASTSource that performs lookups and completes minimally imported types.
IsolatedASTKind
The different kinds of isolated ASTs within the scratch TypeSystem.
@ CppModules
The isolated AST for declarations/types from expressions that imported type information from a C++ mo...
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< ClangPersistentVariables > m_persistent_variables
The persistent variables associated with this process for the expression parser.
static char ID
LLVM RTTI support.
PersistentExpressionState * GetPersistentExpressionState() override
FunctionCaller * GetFunctionCaller(const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, const char *name) override
std::unique_ptr< UtilityFunction > CreateUtilityFunction(std::string text, std::string name) override
void ForgetSource(clang::ASTContext *src_ctx, ClangASTImporter &importer)
Unregisters the given ASTContext as a source from the scratch AST (and all sub-ASTs).
static const std::nullopt_t DefaultAST
Alias for requesting the default scratch TypeSystemClang in GetForTarget.
ScratchTypeSystemClang(Target &target, llvm::Triple triple)
llvm::DenseMap< IsolatedASTKey, std::shared_ptr< TypeSystemClang > > m_isolated_asts
Map from IsolatedASTKind to their actual TypeSystemClang instance.
bool Fail() const
Test for error condition.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
unsigned GetIndentLevel() const
Get the current indentation level.
Provides public interface for all SymbolFiles.
virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx)
virtual bool CompleteType(CompilerType &compiler_type)=0
virtual void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list)=0
virtual std::optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx)=0
If type_uid points to an array type, return its characteristics.
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
const ArchSpec & GetArchitecture() const
void Insert(_KeyType k, _ValueType v)
_ValueType Lookup(_KeyType k)
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
The implementation of lldb::Type's m_payload field for TypeSystemClang.
void SetIsCompleteObjCClass(bool is_complete_objc_class)
bool IsCompleteObjCClass()
Type::Payload m_payload
The payload is used for typedefs and ptrauth types.
TypePayloadClang()=default
void SetOwningModule(OptionalClangModuleID id)
static constexpr unsigned ObjCClassBit
llvm::ArrayRef< clang::TemplateArgument > GetParameterPackArgs() const
clang::TemplateArgument const & Front() const
llvm::StringRef GetPackName() const
bool hasParameterPack() const
TemplateParameterInfos const & GetParameterPack() const
llvm::ArrayRef< const char * > GetNames() const
llvm::ArrayRef< clang::TemplateArgument > GetArgs() const
A TypeSystem implementation based on Clang.
bool IsMemberFunctionPointerType(lldb::opaque_compiler_type_t type) override
clang::ClassTemplateDecl * CreateClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef class_name, int kind, const TemplateParameterInfos &infos)
clang::ClassTemplateDecl * ParseClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *parent_name, int tag_decl_kind, const TypeSystemClang::TemplateParameterInfos &template_param_infos)
CompilerType GetTypeForIdentifier(const clang::ASTContext &Ctx, llvm::StringRef type_name, clang::DeclContext *decl_context=nullptr)
llvm::Expected< uint64_t > GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
CompilerType CreateFunctionType(const CompilerType &result_type, llvm::ArrayRef< CompilerType > args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
size_t GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) override
static clang::TypedefNameDecl * GetAsTypedefDecl(const CompilerType &type)
std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl, bool qualified=true)
Returns the internal type name for the given NamedDecl using the type printing policy.
static clang::ObjCInterfaceDecl * GetAsObjCInterfaceDecl(const CompilerType &type)
uint32_t m_pointer_byte_size
bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream &s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override
std::string m_display_name
A string describing what this TypeSystemClang represents (e.g., AST for debug information,...
ConstString GetTypeName(lldb::opaque_compiler_type_t type, bool base_only) override
static void SetOwningModule(clang::Decl *decl, OptionalClangModuleID owning_module)
Set the owning module for decl.
llvm::Expected< uint64_t > GetObjCBitSize(clang::QualType qual_type, ExecutionContextScope *exe_scope)
std::unique_ptr< clang::TargetInfo > m_target_info_up
std::unique_ptr< clang::LangOptions > m_language_options_up
Scalar DeclGetConstantValue(void *opaque_decl) override
llvm::Expected< CompilerType > GetDereferencedType(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, std::string &deref_name, uint32_t &deref_byte_size, int32_t &deref_byte_offset, ValueObject *valobj, uint64_t &language_flags) override
bool BaseSpecifierIsEmpty(const clang::CXXBaseSpecifier *b)
static uint32_t GetNumPointeeChildren(clang::QualType type)
ConstString DeclGetMangledName(void *opaque_decl) override
CompilerType GetBasicType(lldb::BasicType type)
std::unique_ptr< clang::HeaderSearchOptions > m_header_search_opts_up
clang::UsingDecl * CreateUsingDeclaration(clang::DeclContext *current_decl_ctx, OptionalClangModuleID owning_module, clang::NamedDecl *target)
static clang::AccessSpecifier ConvertAccessTypeToAccessSpecifier(lldb::AccessType access)
CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override
bool IsForcefullyCompleted(lldb::opaque_compiler_type_t type) override
bool SupportsLanguage(lldb::LanguageType language) override
uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override
OptionalClangModuleID GetOrCreateClangModule(llvm::StringRef name, OptionalClangModuleID parent, bool is_framework=false, bool is_explicit=false)
Synthesize a clang::Module and return its ID or a default-constructed ID.
void CompleteTagDecl(clang::TagDecl *)
std::shared_ptr< clang::TargetOptions > & getTargetOptions()
static TypeSystemClang * GetASTContext(clang::ASTContext *ast_ctx)
bool IsReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool *is_rvalue) override
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
const char * GetTargetTriple()
TypeSystemClang(llvm::StringRef name, llvm::Triple triple)
Constructs a TypeSystemClang with an ASTContext using the given triple.
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, Module *module, Target *target)
clang::TargetInfo * getTargetInfo()
clang::FunctionTemplateDecl * CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::FunctionDecl *func_decl, const TemplateParameterInfos &infos)
CompilerType CreateArrayType(const CompilerType &element_type, std::optional< size_t > element_count, bool is_vector)
static bool AreTypesSame(CompilerType type1, CompilerType type2, bool ignore_qualifiers=false)
CompilerType GetArrayType(lldb::opaque_compiler_type_t type, uint64_t size) override
bool IsFunctionType(lldb::opaque_compiler_type_t type) override
CompilerType GetFunctionReturnType(lldb::opaque_compiler_type_t type) override
std::optional< ClangASTMetadata > GetMetadata(const clang::Decl *object)
CompilerType GetLValueReferenceType(lldb::opaque_compiler_type_t type) override
bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td)
lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override
bool CanPassInRegisters(const CompilerType &type) override
CompilerDecl GetStaticFieldWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
bool IsEnumerationType(lldb::opaque_compiler_type_t type, bool &is_signed) override
bool IsTemplateType(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
static bool IsCXXClassType(const CompilerType &type)
bool IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed) override
std::unique_ptr< npdb::PdbAstBuilderClang > m_native_pdb_ast_parser_up
uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override
static bool IsOperator(llvm::StringRef name, clang::OverloadedOperatorKind &op_kind)
bool IsCharType(lldb::opaque_compiler_type_t type) override
CompilerType CreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
static void SetFloatingInitializerForVariable(clang::VarDecl *var, const llvm::APFloat &init_value)
Initializes a variable with a floating point value.
uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) override
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) override
CompilerType GetType(clang::QualType qt)
Creates a CompilerType from the given QualType with the current TypeSystemClang instance as the Compi...
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override
std::string m_target_triple
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > bases)
bool IsBeingDefined(lldb::opaque_compiler_type_t type) override
ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override
std::unique_ptr< clang::IdentifierTable > m_identifier_table_up
static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name)
static void SetIntegerInitializerForVariable(clang::VarDecl *var, const llvm::APInt &init_value)
Initializes a variable with an integer value.
bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override
CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets)
bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::SourceManager > m_source_manager_up
bool IsVoidType(lldb::opaque_compiler_type_t type) override
static void SetIsPacked(const CompilerType &type)
void ForEachEnumerator(lldb::opaque_compiler_type_t type, std::function< bool(const CompilerType &integer_type, ConstString name, const llvm::APSInt &value)> const &callback) override
CompilerType CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *class_template_specialization_decl)
bool IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
std::unique_ptr< clang::DiagnosticOptions > m_diagnostic_options_up
void CreateFunctionTemplateSpecializationInfo(clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template, const TemplateParameterInfos &infos)
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, uint64_t enum_value, uint32_t enum_value_bit_size)
llvm::StringRef getDisplayName() const
Returns the display name of this TypeSystemClang that indicates what purpose it serves in LLDB.
static clang::VarDecl * AddVariableToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &var_type)
bool IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length)
CompilerType GetRValueReferenceType(lldb::opaque_compiler_type_t type) override
CompilerDecl GetCompilerDecl(clang::Decl *decl)
Creates a CompilerDecl from the given Decl with the current TypeSystemClang instance as its typesyste...
unsigned GetPtrAuthDiscriminator(lldb::opaque_compiler_type_t type) override
CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override
bool GetCompleteType(lldb::opaque_compiler_type_t type) override
bool IsBlockPointerType(lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) override
bool IsConst(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::CXXBaseSpecifier > CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class)
CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override
std::vector< CompilerDecl > DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_using_decls) override
const llvm::fltSemantics & GetFloatTypeSemantics(size_t byte_size, lldb::Format format) override
bool IsFloatingPointType(lldb::opaque_compiler_type_t type) override
llvm::Expected< uint32_t > GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes) override
void setSema(clang::Sema *s)
uint32_t GetPointerByteSize() override
bool IsCompleteType(lldb::opaque_compiler_type_t type) override
CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed)
clang::MangleContext * getMangleContext()
void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *)
unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override
static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx)
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
CompilerType GetTypeForFormatters(void *type) override
void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id)
bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override
This is used by swift.
static LanguageSet GetSupportedLanguagesForExpressions()
clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, const CompilerType &function_Type, clang::StorageClass storage, bool is_inline, llvm::StringRef asm_label)
CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override
CompilerDeclContext GetCompilerDeclContextForType(const CompilerType &type) override
Returns the direct parent context of specified type.
std::unique_ptr< clang::SelectorTable > m_selector_table_up
PDBASTParser * GetPDBParser() override
std::optional< CompilerType::IntegralTemplateArgument > GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
bool DeclContextIsClassMethod(void *opaque_decl_ctx) override
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...
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, int kind, lldb::LanguageType language, std::optional< ClangASTMetadata > metadata=std::nullopt, bool exports_symbols=false)
std::unique_ptr< clang::HeaderSearch > m_header_search_up
void Finalize() override
Free up any resources associated with this TypeSystem.
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, llvm::StringRef asm_label, const CompilerType &method_type, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
static clang::ASTContext * DeclContextGetTypeSystemClang(const CompilerDeclContext &dc)
uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, CompilerType *base_type_ptr) override
LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override
Convenience LLVM-style dump method for use in the debugger only.
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
std::unique_ptr< clang::ASTContext > m_ast_up
CompilerType CreateGenericFunctionPrototype() override
static clang::QualType GetCanonicalQualType(lldb::opaque_compiler_type_t type)
CompilerType DeclGetFunctionReturnType(void *opaque_decl) override
static bool IsEnumType(lldb::opaque_compiler_type_t type)
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
CompilerType GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static bool SetObjCSuperClass(const CompilerType &type, const CompilerType &superclass_compiler_type)
clang::UsingDirectiveDecl * CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::NamespaceDecl *ns_decl)
static lldb::opaque_compiler_type_t GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type)
bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override
void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name)
Dump clang AST types from the symbol file.
CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override
static void DumpDeclHiearchy(clang::Decl *decl)
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
static clang::FunctionDecl * DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc)
bool IsScalarType(lldb::opaque_compiler_type_t type) override
bool GetPtrAuthAddressDiversity(lldb::opaque_compiler_type_t type) override
std::shared_ptr< clang::TargetOptions > m_target_options_rp
lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override
static bool IsClassType(lldb::opaque_compiler_type_t type)
bool IsDefined(lldb::opaque_compiler_type_t type) override
static bool IsObjCClassType(const CompilerType &type)
TypeMetadataMap m_type_metadata
Maps Types to their associated ClangASTMetadata.
CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override
bool RecordHasFields(const clang::RecordDecl *record_decl)
CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index) override
static std::optional< ClangASTMetadata > DeclContextGetMetaData(const CompilerDeclContext &dc, const clang::Decl *object)
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerDiffType(bool is_signed) override
static clang::ObjCMethodDecl * AddMethodToObjCObjectType(const CompilerType &type, const char *name, const CompilerType &method_compiler_type, bool is_artificial, bool is_variadic, bool is_objc_direct_call)
~TypeSystemClang() override
CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override
bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, void *other_opaque_decl_ctx) override
CompilerType AddPtrAuthModifier(lldb::opaque_compiler_type_t type, uint32_t payload) override
static bool AddObjCClassProperty(const CompilerType &type, const char *property_name, const CompilerType &property_compiler_type, clang::ObjCIvarDecl *ivar_decl, const char *property_setter_name, const char *property_getter_name, uint32_t property_attributes, ClangASTMetadata metadata)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
void SetMetadata(const clang::Decl *object, ClangASTMetadata meta_data)
clang::ParmVarDecl * CreateParameterDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType ¶m_type, int storage, bool add_decl=false)
void DumpTypeDescription(lldb::opaque_compiler_type_t type, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) override
Dump the type to stdout.
CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
static clang::NamespaceDecl * DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped, std::optional< clang::EnumExtensibilityAttr::Kind > enum_kind=std::nullopt)
npdb::PdbAstBuilder * GetNativePDBParser() override
std::unique_ptr< clang::DiagnosticConsumer > m_diagnostic_consumer_up
CompilerType CreateObjCClass(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool isInternal, std::optional< ClangASTMetadata > metadata=std::nullopt)
CompilerType GetTypeForDecl(clang::NamedDecl *decl)
CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
llvm::Expected< CompilerType > DoIntegralPromotion(CompilerType from, ExecutionContextScope *exe_scope) override
Perform integral promotion on a given type.
static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc)
bool IsTypedefType(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override
std::optional< size_t > GetTypeBitAlign(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< clang::Builtin::Context > m_builtins_up
CompilerType GetBuiltinTypeByName(ConstString name) override
bool GetCompleteDecl(clang::Decl *decl)
static bool StartTagDeclarationDefinition(const CompilerType &type)
uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl, bool omit_empty_base_classes)
bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, CompilerType *target_type, bool check_cplusplus, bool check_objc) override
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, uint32_t bitfield_bit_size)
CompilerType GetOrCreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
void LogCreation() const
Emits information about this TypeSystem into the expression log.
static llvm::StringRef GetPluginNameStatic()
clang::Sema * m_sema
The sema associated that is currently used to build this ASTContext.
size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override
const clang::ClassTemplateSpecializationDecl * GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type)
std::unique_ptr< clang::MangleContext > m_mangle_ctx_up
TypeMemberFunctionImpl GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
bool IsTypeImpl(lldb::opaque_compiler_type_t type, llvm::function_ref< bool(clang::QualType)> predicate) const
size_t DeclGetFunctionNumArguments(void *opaque_decl) override
CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< PDBASTParser > m_pdb_ast_parser_up
std::unique_ptr< clang::DiagnosticsEngine > m_diagnostics_engine_up
static std::optional< std::string > GetCXXClassName(const CompilerType &type)
static void DumpTypeName(const CompilerType &type)
plugin::dwarf::DWARFASTParser * GetDWARFParser() override
CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx) override
bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
static clang::EnumDecl * GetAsEnumDecl(const CompilerType &type)
CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::ModuleMap > m_module_map_up
static bool IsObjCObjectOrInterfaceType(const CompilerType &type)
static void RequireCompleteType(CompilerType type)
Complete a type from debug info, or mark it as forcefully completed if there is no definition of the ...
CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload) override
Using the current type, create a new typedef to that type using "typedef_name" as the name and "decl_...
llvm::Expected< uint32_t > GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes, const ExecutionContext *exe_ctx) override
CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override
clang::TemplateTemplateParmDecl * CreateTemplateTemplateParmDecl(const char *template_name)
lldb::TemplateArgumentKind GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
clang::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
std::vector< lldb_private::CompilerContext > DeclGetCompilerContext(void *opaque_decl) override
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
std::vector< lldb_private::CompilerContext > DeclContextGetCompilerContext(void *opaque_decl_ctx) override
void CreateASTContext()
Creates the internal ASTContext.
void SetExternalSource(llvm::IntrusiveRefCntPtr< clang::ExternalASTSource > ast_source_sp)
CompilerType GetCStringType(bool is_const)
bool IsAggregateType(lldb::opaque_compiler_type_t type) override
bool IsPromotableIntegerType(lldb::opaque_compiler_type_t type) override
Checks if the type is eligible for integral promotion.
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override
static LanguageSet GetSupportedLanguagesForTypes()
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
ConstString DeclContextGetName(void *opaque_decl_ctx) override
size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack) override
ConstString DeclGetName(void *opaque_decl) override
virtual SymbolFile * GetSymbolFile() const
bool m_has_forcefully_completed_types
Used for reporting statistics.
Encapsulates a one-time expression for use in lldb.
virtual uint64_t GetData(DataExtractor &data, Status &error)
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
AddressType GetAddressTypeOfChildren()
CompilerType GetCompilerType()
ConstString GetName() const
const ExecutionContextRef & GetExecutionContextRef() const
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_IVAR_OFFSET
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, uint32_t item_bit_size, uint32_t item_bit_offset, ExecutionContextScope *exe_scope=nullptr, bool show_memory_tags=false)
Dumps item_count objects into the stream s.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
void * opaque_compiler_type_t
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eBasicTypeUnsignedShort
@ eBasicTypeUnsignedInt128
@ eBasicTypeUnsignedWChar
@ eBasicTypeLongDoubleComplex
@ eBasicTypeUnsignedLongLong
@ eBasicTypeDoubleComplex
Format
Display format definitions.
@ eFormatCString
NULL terminated C strings.
@ eFormatCharArray
Print characters with no single quotes, used for character arrays that can contain non printable char...
@ eFormatVoid
Do not print this.
@ eFormatComplex
Floating point complex type.
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
@ eFormatComplexInteger
Integer complex type.
@ eFormatFloat128
Disambiguate between 128-bit long double (which uses eFormatFloat) and __float128 (which uses eFormat...
LanguageType
Programming language type.
@ eLanguageTypeC_plus_plus_20
ISO C++:2020.
@ eLanguageTypeC_plus_plus_14
ISO C++:2014.
@ eLanguageTypeC11
ISO C:2011.
@ eLanguageTypeC99
ISO C:1999.
@ eLanguageTypeC_plus_plus_03
ISO C++:2003.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeC_plus_plus_17
ISO C++:2017.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
@ eLanguageTypeC_plus_plus_11
ISO C++:2011.
@ eLanguageTypeC89
ISO C:1989.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
@ eLanguageTypeDylan
Dylan.
std::shared_ptr< lldb_private::Type > TypeSP
@ eTemplateArgumentKindTemplate
@ eTemplateArgumentKindTemplateExpansion
@ eTemplateArgumentKindNull
@ eTemplateArgumentKindNullPtr
@ eTemplateArgumentKindDeclaration
@ eTemplateArgumentKindIntegral
@ eTemplateArgumentKindPack
@ eTemplateArgumentKindType
@ eTemplateArgumentKindStructuralValue
@ eTemplateArgumentKindExpression
Encoding
Register encoding definitions.
@ eEncodingVector
vector registers
@ eEncodingUint
unsigned integer
@ eEncodingSint
signed integer
MemberFunctionKind
Kind of member function.
@ eMemberFunctionKindInstanceMethod
A function that applies to a specific instance.
@ eMemberFunctionKindConstructor
A function used to create instances.
@ eMemberFunctionKindUnknown
Not sure what the type of this is.
@ eMemberFunctionKindDestructor
A function used to tear down existing instances.
@ eMemberFunctionKindStaticMethod
A function that applies to a type rather than any instance.
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Target > TargetSP
static clang::QualType GetQualType(const CompilerType &ct)
static clang::QualType GetCanonicalQualType(const CompilerType &ct)
static bool IsClangType(const CompilerType &ct)
static CompilerType RemoveFastQualifiers(const CompilerType &ct)
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
static llvm::Expected< FunctionCallLabel > fromString(llvm::StringRef label)
Decodes the specified function label into a FunctionCallLabel.
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
void Insert(lldb::LanguageType language)
A type-erased pair of llvm::dwarf::SourceLanguageName and version.