11#include "clang/AST/DeclBase.h"
12#include "clang/AST/ExprCXX.h"
13#include "clang/Frontend/ASTConsumers.h"
14#include "llvm/ADT/ScopeExit.h"
15#include "llvm/Support/Casting.h"
16#include "llvm/Support/ErrorExtras.h"
17#include "llvm/Support/FormatAdapters.h"
18#include "llvm/Support/FormatVariadic.h"
25#include "clang/AST/ASTContext.h"
26#include "clang/AST/ASTImporter.h"
27#include "clang/AST/Attr.h"
28#include "clang/AST/CXXInheritance.h"
29#include "clang/AST/DeclObjC.h"
30#include "clang/AST/DeclTemplate.h"
31#include "clang/AST/Mangle.h"
32#include "clang/AST/QualTypeNames.h"
33#include "clang/AST/RecordLayout.h"
34#include "clang/AST/Type.h"
35#include "clang/AST/VTableBuilder.h"
36#include "clang/Basic/Builtins.h"
37#include "clang/Basic/Diagnostic.h"
38#include "clang/Basic/FileManager.h"
39#include "clang/Basic/FileSystemOptions.h"
40#include "clang/Basic/LangStandard.h"
41#include "clang/Basic/SourceManager.h"
42#include "clang/Basic/TargetInfo.h"
43#include "clang/Basic/TargetOptions.h"
44#include "clang/Frontend/FrontendOptions.h"
45#include "clang/Lex/HeaderSearch.h"
46#include "clang/Lex/HeaderSearchOptions.h"
47#include "clang/Lex/ModuleMap.h"
48#include "clang/Sema/Sema.h"
50#include "llvm/Support/Signals.h"
51#include "llvm/Support/Threading.h"
95using namespace llvm::dwarf;
97using llvm::StringSwitch;
102static void VerifyDecl(clang::Decl *decl) {
103 assert(decl &&
"VerifyDecl called with nullptr?");
129bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) {
131 lldbassert(&m1->getASTContext() == &m2->getASTContext() &&
132 "Methods should have the same AST context");
133 clang::ASTContext &context = m1->getASTContext();
135 const auto *m1Type = llvm::cast<clang::FunctionProtoType>(
136 context.getCanonicalType(m1->getType()));
138 const auto *m2Type = llvm::cast<clang::FunctionProtoType>(
139 context.getCanonicalType(m2->getType()));
141 auto compareArgTypes = [&context](
const clang::QualType &m1p,
142 const clang::QualType &m2p) {
143 return context.hasSameType(m1p.getUnqualifiedType(),
144 m2p.getUnqualifiedType());
149 return (m1->getNumParams() != m2->getNumParams()) ||
150 !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(),
151 m2Type->param_type_begin(), compareArgTypes);
157void addOverridesForMethod(clang::CXXMethodDecl *decl) {
158 if (!decl->isVirtual())
161 clang::CXXBasePaths paths;
162 llvm::SmallVector<clang::NamedDecl *, 4> decls;
164 auto find_overridden_methods =
165 [&decls, decl](
const clang::CXXBaseSpecifier *specifier,
166 clang::CXXBasePath &path) {
167 if (
auto *base_record = specifier->getType()->getAsCXXRecordDecl()) {
169 clang::DeclarationName name = decl->getDeclName();
173 if (name.getNameKind() == clang::DeclarationName::CXXDestructorName)
174 if (
auto *baseDtorDecl = base_record->getDestructor()) {
175 if (baseDtorDecl->isVirtual()) {
176 decls.push_back(baseDtorDecl);
183 for (path.Decls = base_record->lookup(name).begin();
184 path.Decls != path.Decls.end(); ++path.Decls) {
185 if (
auto *method_decl =
186 llvm::dyn_cast<clang::CXXMethodDecl>(*path.Decls))
187 if (method_decl->isVirtual() && !isOverload(decl, method_decl)) {
188 decls.push_back(method_decl);
197 if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) {
198 for (
auto *overridden_decl : decls)
199 decl->addOverriddenMethod(
200 llvm::cast<clang::CXXMethodDecl>(overridden_decl));
206 VTableContextBase &vtable_ctx,
208 const ASTRecordLayout &record_layout) {
212 uint32_t type_info = this_type.
GetTypeInfo(&pointee_type);
217 bool ptr_or_ref =
false;
218 if (type_info & (eTypeIsPointer | eTypeIsReference)) {
224 const uint32_t cpp_class = eTypeIsClass | eTypeIsCPlusPlus;
225 if ((type_info & cpp_class) != cpp_class)
230 vtable_ctx.isMicrosoft() ? record_layout.getVBPtrOffset().getQuantity()
244 vbtable_ptr_addr += vbtable_ptr_offset;
255 auto size = valobj.
GetData(data, err);
263 VTableContextBase &vtable_ctx,
265 const CXXRecordDecl *cxx_record_decl,
266 const CXXRecordDecl *base_class_decl) {
267 if (vtable_ctx.isMicrosoft()) {
268 clang::MicrosoftVTableContext &msoft_vtable_ctx =
269 static_cast<clang::MicrosoftVTableContext &
>(vtable_ctx);
273 const unsigned vbtable_index =
274 msoft_vtable_ctx.getVBTableIndex(cxx_record_decl, base_class_decl);
275 const lldb::addr_t base_offset_addr = vtable_ptr + vbtable_index * 4;
281 clang::ItaniumVTableContext &itanium_vtable_ctx =
282 static_cast<clang::ItaniumVTableContext &
>(vtable_ctx);
284 clang::CharUnits base_offset_offset =
285 itanium_vtable_ctx.getVirtualBaseOffsetOffset(cxx_record_decl,
288 vtable_ptr + base_offset_offset.getQuantity();
297 const ASTRecordLayout &record_layout,
298 const CXXRecordDecl *cxx_record_decl,
299 const CXXRecordDecl *base_class_decl,
300 int32_t &bit_offset) {
312 *process, vtable_ctx, vtable_ptr, cxx_record_decl, base_class_decl);
313 if (base_offset == INT64_MAX)
316 bit_offset = base_offset * 8;
326 static llvm::once_flag g_once_flag;
327 llvm::call_once(g_once_flag, []() {
334 bool is_complete_objc_class)
347 const clang::Decl *parent) {
348 if (!member || !parent)
355 member->setFromASTFile();
356 member->setOwningModuleID(
id.GetValue());
357 member->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
358 if (llvm::isa<clang::NamedDecl>(member))
359 if (
auto *dc = llvm::dyn_cast<clang::DeclContext>(parent)) {
360 dc->setHasExternalVisibleStorage(
true);
363 dc->setHasExternalLexicalStorage(
true);
370 clang::OverloadedOperatorKind &op_kind) {
372 if (!name.consume_front(
"operator"))
377 bool space_after_operator = name.consume_front(
" ");
379 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
380 .Case(
"+", clang::OO_Plus)
381 .Case(
"+=", clang::OO_PlusEqual)
382 .Case(
"++", clang::OO_PlusPlus)
383 .Case(
"-", clang::OO_Minus)
384 .Case(
"-=", clang::OO_MinusEqual)
385 .Case(
"--", clang::OO_MinusMinus)
386 .Case(
"->", clang::OO_Arrow)
387 .Case(
"->*", clang::OO_ArrowStar)
388 .Case(
"*", clang::OO_Star)
389 .Case(
"*=", clang::OO_StarEqual)
390 .Case(
"/", clang::OO_Slash)
391 .Case(
"/=", clang::OO_SlashEqual)
392 .Case(
"%", clang::OO_Percent)
393 .Case(
"%=", clang::OO_PercentEqual)
394 .Case(
"^", clang::OO_Caret)
395 .Case(
"^=", clang::OO_CaretEqual)
396 .Case(
"&", clang::OO_Amp)
397 .Case(
"&=", clang::OO_AmpEqual)
398 .Case(
"&&", clang::OO_AmpAmp)
399 .Case(
"|", clang::OO_Pipe)
400 .Case(
"|=", clang::OO_PipeEqual)
401 .Case(
"||", clang::OO_PipePipe)
402 .Case(
"~", clang::OO_Tilde)
403 .Case(
"!", clang::OO_Exclaim)
404 .Case(
"!=", clang::OO_ExclaimEqual)
405 .Case(
"=", clang::OO_Equal)
406 .Case(
"==", clang::OO_EqualEqual)
407 .Case(
"<", clang::OO_Less)
408 .Case(
"<=>", clang::OO_Spaceship)
409 .Case(
"<<", clang::OO_LessLess)
410 .Case(
"<<=", clang::OO_LessLessEqual)
411 .Case(
"<=", clang::OO_LessEqual)
412 .Case(
">", clang::OO_Greater)
413 .Case(
">>", clang::OO_GreaterGreater)
414 .Case(
">>=", clang::OO_GreaterGreaterEqual)
415 .Case(
">=", clang::OO_GreaterEqual)
416 .Case(
"()", clang::OO_Call)
417 .Case(
"[]", clang::OO_Subscript)
418 .Case(
",", clang::OO_Comma)
419 .Default(clang::NUM_OVERLOADED_OPERATORS);
422 if (op_kind != clang::NUM_OVERLOADED_OPERATORS)
434 if (!space_after_operator)
439 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
440 .Case(
"new", clang::OO_New)
441 .Case(
"new[]", clang::OO_Array_New)
442 .Case(
"delete", clang::OO_Delete)
443 .Case(
"delete[]", clang::OO_Array_Delete)
445 .Default(clang::NUM_OVERLOADED_OPERATORS);
450clang::AccessSpecifier
470 std::vector<std::string> Includes;
471 LangOptions::setLangDefaults(Opts, clang::Language::ObjCXX, arch.
GetTriple(),
472 Includes, clang::LangStandard::lang_gnucxx98);
474 Opts.setValueVisibilityMode(DefaultVisibility);
478 Opts.Trigraphs = !Opts.GNUMode;
483 Opts.ModulesLocalVisibility = 1;
487 llvm::Triple target_triple) {
489 if (!target_triple.str().empty())
499 ASTContext &existing_ctxt) {
515 if (!TypeSystemClangSupportsLanguage(language))
519 arch =
module->GetArchitecture();
529 if (triple.getVendor() == llvm::Triple::Apple &&
530 triple.getOS() == llvm::Triple::UnknownOS) {
531 if (triple.getArch() == llvm::Triple::arm ||
532 triple.getArch() == llvm::Triple::aarch64 ||
533 triple.getArch() == llvm::Triple::aarch64_32 ||
534 triple.getArch() == llvm::Triple::thumb) {
535 triple.setOS(llvm::Triple::IOS);
537 triple.setOS(llvm::Triple::MacOSX);
542 std::string ast_name =
543 "ASTContext for '" +
module->GetFileSpec().GetPath() + "'";
544 return std::make_shared<TypeSystemClang>(ast_name, triple);
545 }
else if (target && target->
IsValid())
546 return std::make_shared<ScratchTypeSystemClang>(*target, triple);
608 assert(s ==
nullptr || &s->getASTContext() ==
m_ast_up.get());
621 llvm::IntrusiveRefCntPtr<ExternalASTSource> ast_source_sp) {
623 ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(
true);
624 ast.setExternalSource(std::move(ast_source_sp));
637 const clang::Diagnostic &info)
override {
639 llvm::SmallVector<char, 32> diag_str(10);
640 info.FormatDiagnostic(diag_str);
641 diag_str.push_back(
'\0');
646 DiagnosticConsumer *
clone(DiagnosticsEngine &Diags)
const {
667 clang::FileSystemOptions file_system_options;
677 m_ast_up = std::make_unique<ASTContext>(
689 m_ast_up->InitBuiltinTypes(*target_info);
693 "Failed to initialize builtin ASTContext types for target '{0}'. "
694 "Printing variables may behave unexpectedly.",
700 static std::once_flag s_uninitialized_target_warning;
702 &s_uninitialized_target_warning);
708 llvm::makeIntrusiveRefCnt<ClangExternalASTSourceCallbacks>(*
this);
740#pragma mark Basic Types
743 ASTContext &ast, QualType qual_type) {
744 uint64_t qual_type_bit_size = ast.getTypeSize(qual_type);
745 return qual_type_bit_size == bit_size;
764 return GetType(ast.UnsignedCharTy);
766 return GetType(ast.UnsignedShortTy);
768 return GetType(ast.UnsignedIntTy);
770 return GetType(ast.UnsignedLongTy);
772 return GetType(ast.UnsignedLongLongTy);
774 return GetType(ast.UnsignedInt128Ty);
779 return GetType(ast.SignedCharTy);
787 return GetType(ast.LongLongTy);
798 return GetType(ast.LongDoubleTy);
802 return GetType(ast.Float128Ty);
807 if (bit_size && !(bit_size & 0x7u))
808 return GetType(ast.getExtVectorType(ast.UnsignedCharTy, bit_size / 8));
816 static const llvm::StringMap<lldb::BasicType> g_type_map = {
881 auto iter = g_type_map.find(name);
882 if (iter == g_type_map.end())
913 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
932 return GetType(ast.UnsignedCharTy);
934 return GetType(ast.UnsignedShortTy);
936 return GetType(ast.UnsignedIntTy);
941 if (type_name.contains(
"complex")) {
950 case DW_ATE_complex_float: {
951 CanQualType FloatComplexTy = ast.getComplexType(ast.FloatTy);
953 return GetType(FloatComplexTy);
955 CanQualType DoubleComplexTy = ast.getComplexType(ast.DoubleTy);
957 return GetType(DoubleComplexTy);
959 CanQualType LongDoubleComplexTy = ast.getComplexType(ast.LongDoubleTy);
961 return GetType(LongDoubleComplexTy);
971 if (type_name ==
"float" &&
974 if (type_name ==
"double" &&
977 if (type_name ==
"long double" &&
979 return GetType(ast.LongDoubleTy);
980 if (type_name ==
"__bf16" &&
982 return GetType(ast.BFloat16Ty);
983 if (type_name ==
"_Float16" &&
989 if ((type_name ==
"__float128" || type_name ==
"_Float128" ||
990 type_name ==
"f128") &&
992 return GetType(ast.Float128Ty);
999 return GetType(ast.LongDoubleTy);
1003 return GetType(ast.Float128Ty);
1007 if (!type_name.empty()) {
1008 if (type_name.starts_with(
"_BitInt"))
1009 return GetType(ast.getBitIntType(
false, bit_size));
1010 if (type_name ==
"wchar_t" &&
1015 if (type_name ==
"void" &&
1018 if (type_name.contains(
"long long") &&
1020 return GetType(ast.LongLongTy);
1021 if (type_name.contains(
"long") &&
1024 if (type_name.contains(
"short") &&
1027 if (type_name.contains(
"char")) {
1031 return GetType(ast.SignedCharTy);
1033 if (type_name.contains(
"int")) {
1050 return GetType(ast.LongLongTy);
1055 case DW_ATE_signed_char:
1056 if (type_name ==
"char") {
1061 return GetType(ast.SignedCharTy);
1064 case DW_ATE_unsigned:
1065 if (!type_name.empty()) {
1066 if (type_name.starts_with(
"unsigned _BitInt"))
1067 return GetType(ast.getBitIntType(
true, bit_size));
1068 if (type_name ==
"wchar_t") {
1075 if (type_name.contains(
"long long")) {
1077 return GetType(ast.UnsignedLongLongTy);
1078 }
else if (type_name.contains(
"long")) {
1080 return GetType(ast.UnsignedLongTy);
1081 }
else if (type_name.contains(
"short")) {
1083 return GetType(ast.UnsignedShortTy);
1084 }
else if (type_name.contains(
"char")) {
1086 return GetType(ast.UnsignedCharTy);
1087 }
else if (type_name.contains(
"int")) {
1089 return GetType(ast.UnsignedIntTy);
1091 return GetType(ast.UnsignedInt128Ty);
1096 return GetType(ast.UnsignedCharTy);
1098 return GetType(ast.UnsignedShortTy);
1100 return GetType(ast.UnsignedIntTy);
1102 return GetType(ast.UnsignedLongTy);
1104 return GetType(ast.UnsignedLongLongTy);
1106 return GetType(ast.UnsignedInt128Ty);
1109 case DW_ATE_unsigned_char:
1110 if (type_name ==
"char") {
1115 return GetType(ast.UnsignedCharTy);
1117 return GetType(ast.UnsignedShortTy);
1120 case DW_ATE_imaginary_float:
1132 if (!type_name.empty()) {
1133 if (type_name ==
"char16_t")
1135 if (type_name ==
"char32_t")
1137 if (type_name ==
"char8_t")
1146 "error: need to add support for DW_TAG_base_type '{0}' "
1147 "encoded with DW_ATE = {1:x}, bit_size = {2}",
1148 type_name, dw_ate, bit_size);
1154 QualType char_type(ast.CharTy);
1157 char_type.addConst();
1159 return GetType(ast.getPointerType(char_type));
1163 bool ignore_qualifiers) {
1174 if (ignore_qualifiers) {
1175 type1_qual = type1_qual.getUnqualifiedType();
1176 type2_qual = type2_qual.getUnqualifiedType();
1179 return ast->getASTContext().hasSameType(type1_qual, type2_qual);
1186 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
1187 if (
auto *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl))
1199 if (clang::ObjCInterfaceDecl *interface_decl =
1200 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
1202 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
1204 if (clang::ValueDecl *value_decl = llvm::dyn_cast<clang::ValueDecl>(decl))
1218 return GetType(value_decl->getType());
1221#pragma mark Structure, Unions, Classes
1225 if (!decl || !owning_module.
HasValue())
1228 decl->setFromASTFile();
1229 decl->setOwningModuleID(owning_module.
GetValue());
1230 decl->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
1236 bool is_framework,
bool is_explicit) {
1238 auto *ast_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1240 assert(ast_source &&
"external ast source was lost");
1258 clang::Module *module;
1259 auto parent_desc = ast_source->getSourceDescriptor(parent.
GetValue());
1261 name, parent_desc ? parent_desc->getModuleOrNull() :
nullptr,
1262 is_framework, is_explicit);
1264 return ast_source->GetIDForModule(module);
1266 return ast_source->RegisterModule(module);
1272 std::optional<ClangASTMetadata> metadata,
bool exports_symbols) {
1275 if (decl_ctx ==
nullptr)
1276 decl_ctx = ast.getTranslationUnitDecl();
1280 bool isInternal =
false;
1281 return CreateObjCClass(name, decl_ctx, owning_module, isInternal, metadata);
1290 bool has_name = !name.empty();
1291 CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1292 decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1293 decl->setDeclContext(decl_ctx);
1295 decl->setDeclName(&ast.Idents.get(name));
1323 if (isa<CXXRecordDecl>(decl_ctx) && exports_symbols)
1324 decl->setAnonymousStructOrUnion(
true);
1330 decl->setAccess(AS_public);
1333 decl_ctx->addDecl(decl);
1335 return GetType(ast.getCanonicalTagType(decl));
1342QualType GetValueParamType(
const clang::TemplateArgument &argument) {
1343 switch (argument.getKind()) {
1344 case TemplateArgument::Integral:
1345 return argument.getIntegralType();
1346 case TemplateArgument::StructuralValue:
1347 return argument.getStructuralValueType();
1357 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1358 const bool parameter_pack =
false;
1359 const bool is_typename =
false;
1360 const unsigned depth = 0;
1361 const size_t num_template_params = template_param_infos.
Size();
1362 DeclContext *
const decl_context =
1363 ast.getTranslationUnitDecl();
1365 auto const &args = template_param_infos.
GetArgs();
1366 auto const &names = template_param_infos.
GetNames();
1367 for (
size_t i = 0; i < num_template_params; ++i) {
1368 const char *name = names[i];
1370 IdentifierInfo *identifier_info =
nullptr;
1371 if (name && name[0])
1372 identifier_info = &ast.Idents.get(name);
1373 TemplateArgument
const &targ = args[i];
1374 QualType template_param_type = GetValueParamType(targ);
1375 if (!template_param_type.isNull()) {
1376 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1377 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1378 identifier_info, template_param_type, parameter_pack,
1379 ast.getTrivialTypeSourceInfo(template_param_type)));
1381 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1382 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1383 identifier_info, is_typename, parameter_pack));
1388 IdentifierInfo *identifier_info =
nullptr;
1390 identifier_info = &ast.Idents.get(template_param_infos.
GetPackName());
1391 const bool parameter_pack_true =
true;
1393 QualType template_param_type =
1397 if (!template_param_type.isNull()) {
1398 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1399 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1400 num_template_params, identifier_info, template_param_type,
1401 parameter_pack_true,
1402 ast.getTrivialTypeSourceInfo(template_param_type)));
1404 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1405 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1406 num_template_params, identifier_info, is_typename,
1407 parameter_pack_true));
1410 clang::Expr *
const requires_clause =
nullptr;
1411 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1412 ast, SourceLocation(), SourceLocation(), template_param_decls,
1413 SourceLocation(), requires_clause);
1414 return template_param_list;
1419 clang::FunctionDecl *func_decl,
1424 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1426 ast, template_param_infos, template_param_decls);
1427 FunctionTemplateDecl *func_tmpl_decl =
1428 FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1429 func_tmpl_decl->setDeclContext(decl_ctx);
1430 func_tmpl_decl->setLocation(func_decl->getLocation());
1431 func_tmpl_decl->setDeclName(func_decl->getDeclName());
1432 func_tmpl_decl->setTemplateParameters(template_param_list);
1433 func_tmpl_decl->init(func_decl);
1436 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1437 i < template_param_decl_count; ++i) {
1439 template_param_decls[i]->setDeclContext(func_decl);
1441 func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
1443 return func_tmpl_decl;
1447 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1449 TemplateArgumentList *template_args_ptr = TemplateArgumentList::CreateCopy(
1450 func_decl->getASTContext(), infos.
GetArgs());
1452 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
1453 template_args_ptr,
nullptr);
1460 const TemplateArgument &value) {
1461 if (llvm::isa<TemplateTypeParmDecl>(param)) {
1463 if (value.getKind() != TemplateArgument::Type)
1465 }
else if (
auto *type_param =
1466 llvm::dyn_cast<NonTypeTemplateParmDecl>(param)) {
1468 QualType value_param_type = GetValueParamType(value);
1469 if (value_param_type.isNull())
1473 if (type_param->getType() != value_param_type)
1481 "Don't know how to compare template parameter to passed"
1482 " value. Decl kind of parameter is: {0}",
1483 param->getDeclKindName());
1484 lldbassert(
false &&
"Can't compare this TemplateParmDecl subclass");
1499 ClassTemplateDecl *class_template_decl,
1502 TemplateParameterList ¶ms = *class_template_decl->getTemplateParameters();
1508 std::optional<NamedDecl *> pack_parameter;
1510 size_t non_pack_params = params.size();
1511 for (
size_t i = 0; i < params.size(); ++i) {
1512 NamedDecl *param = params.getParam(i);
1513 if (param->isParameterPack()) {
1514 pack_parameter = param;
1515 non_pack_params = i;
1523 if (non_pack_params != instantiation_values.
Size())
1541 for (
const auto pair :
1542 llvm::zip_first(instantiation_values.
GetArgs(), params)) {
1543 const TemplateArgument &passed_arg = std::get<0>(pair);
1544 NamedDecl *found_param = std::get<1>(pair);
1549 return class_template_decl;
1554 llvm::StringRef class_name,
int kind,
1558 ClassTemplateDecl *class_template_decl =
nullptr;
1559 if (decl_ctx ==
nullptr)
1560 decl_ctx = ast.getTranslationUnitDecl();
1562 IdentifierInfo &identifier_info = ast.Idents.get(class_name);
1563 DeclarationName decl_name(&identifier_info);
1566 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1567 for (NamedDecl *decl : result) {
1568 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1569 if (!class_template_decl)
1578 template_param_infos))
1580 return class_template_decl;
1583 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1586 ast, template_param_infos, template_param_decls);
1588 CXXRecordDecl *template_cxx_decl =
1589 CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1590 template_cxx_decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1592 template_cxx_decl->setDeclContext(decl_ctx);
1593 template_cxx_decl->setDeclName(decl_name);
1596 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1597 i < template_param_decl_count; ++i) {
1598 template_param_decls[i]->setDeclContext(template_cxx_decl);
1606 class_template_decl =
1607 ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1609 class_template_decl->setDeclContext(decl_ctx);
1610 class_template_decl->setDeclName(decl_name);
1611 class_template_decl->setTemplateParameters(template_param_list);
1612 class_template_decl->init(template_cxx_decl);
1613 template_cxx_decl->setDescribedClassTemplate(class_template_decl);
1616 class_template_decl->setAccess(AS_public);
1618 decl_ctx->addDecl(class_template_decl);
1620 VerifyDecl(class_template_decl);
1622 return class_template_decl;
1625TemplateTemplateParmDecl *
1629 auto *decl_ctx = ast.getTranslationUnitDecl();
1631 IdentifierInfo &identifier_info = ast.Idents.get(template_name);
1632 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1636 std::make_unique<TemplateParameterInfos>());
1638 ast, template_param_infos, template_param_decls);
1644 return TemplateTemplateParmDecl::Create(
1645 ast, decl_ctx, SourceLocation(),
1647 false, &identifier_info,
1648 TemplateNameKind::TNK_Type_template,
true,
1649 template_param_list);
1652ClassTemplateSpecializationDecl *
1655 ClassTemplateDecl *class_template_decl,
int kind,
1658 llvm::SmallVector<clang::TemplateArgument, 2> args(
1659 template_param_infos.
Size() +
1662 auto const &orig_args = template_param_infos.
GetArgs();
1663 std::copy(orig_args.begin(), orig_args.end(), args.begin());
1665 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1668 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1669 ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
1670 class_template_specialization_decl->setTagKind(
1671 static_cast<TagDecl::TagKind
>(kind));
1672 class_template_specialization_decl->setDeclContext(decl_ctx);
1673 class_template_specialization_decl->setInstantiationOf(class_template_decl);
1674 class_template_specialization_decl->setTemplateArgs(
1675 TemplateArgumentList::CreateCopy(ast, args));
1676 void *insert_pos =
nullptr;
1677 if (class_template_decl->findSpecialization(args, insert_pos))
1679 class_template_decl->AddSpecialization(class_template_specialization_decl,
1681 class_template_specialization_decl->setDeclName(
1682 class_template_decl->getDeclName());
1687 class_template_specialization_decl->setStrictPackMatch(
false);
1690 decl_ctx->addDecl(class_template_specialization_decl);
1692 class_template_specialization_decl->setSpecializationKind(
1693 TSK_ExplicitSpecialization);
1695 return class_template_specialization_decl;
1699 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1700 if (class_template_specialization_decl) {
1702 return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
1708 clang::OverloadedOperatorKind op_kind,
1709 bool unary,
bool binary,
1710 uint32_t num_params) {
1712 if (op_kind == OO_Call)
1718 if (num_params == 1)
1720 if (num_params == 2)
1727 bool is_method, clang::OverloadedOperatorKind op_kind,
1728 uint32_t num_params) {
1736 case OO_Array_Delete:
1740#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1742 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1744#include "clang/Basic/OperatorKinds.def"
1752 uint32_t &bitfield_bit_size) {
1754 if (field ==
nullptr)
1757 if (field->isBitField()) {
1758 Expr *bit_width_expr = field->getBitWidth();
1759 if (bit_width_expr) {
1760 if (std::optional<llvm::APSInt> bit_width_apsint =
1761 bit_width_expr->getIntegerConstantExpr(ast)) {
1762 bitfield_bit_size = bit_width_apsint->getLimitedValue(
UINT32_MAX);
1771 if (record_decl ==
nullptr)
1774 if (!record_decl->field_empty())
1778 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1779 if (cxx_record_decl) {
1780 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1781 for (base_class = cxx_record_decl->bases_begin(),
1782 base_class_end = cxx_record_decl->bases_end();
1783 base_class != base_class_end; ++base_class) {
1784 assert(record_decl != base_class->getType()->getAsCXXRecordDecl() &&
1785 "Base can't inherit from itself.");
1797 if (std::optional<ClangASTMetadata> meta_data =
GetMetadata(record_decl);
1798 meta_data && meta_data->IsForcefullyCompleted())
1804#pragma mark Objective-C Classes
1807 llvm::StringRef name, clang::DeclContext *decl_ctx,
1809 std::optional<ClangASTMetadata> metadata) {
1811 assert(!name.empty());
1813 decl_ctx = ast.getTranslationUnitDecl();
1815 ObjCInterfaceDecl *decl =
1816 ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
1817 decl->setDeclContext(decl_ctx);
1818 decl->setDeclName(&ast.Idents.get(name));
1819 decl->setImplicit(isInternal);
1825 return GetType(ast.getObjCInterfaceType(decl));
1834 bool omit_empty_base_classes) {
1835 uint32_t num_bases = 0;
1836 if (cxx_record_decl) {
1837 if (omit_empty_base_classes) {
1838 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1839 for (base_class = cxx_record_decl->bases_begin(),
1840 base_class_end = cxx_record_decl->bases_end();
1841 base_class != base_class_end; ++base_class) {
1848 num_bases = cxx_record_decl->getNumBases();
1853#pragma mark Namespace Declarations
1856 const char *name, clang::DeclContext *decl_ctx,
1858 NamespaceDecl *namespace_decl =
nullptr;
1860 TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
1862 decl_ctx = translation_unit_decl;
1865 IdentifierInfo &identifier_info = ast.Idents.get(name);
1866 DeclarationName decl_name(&identifier_info);
1867 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1868 for (NamedDecl *decl : result) {
1869 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1871 return namespace_decl;
1874 namespace_decl = NamespaceDecl::Create(ast, decl_ctx, is_inline,
1875 SourceLocation(), SourceLocation(),
1876 &identifier_info,
nullptr,
false);
1878 decl_ctx->addDecl(namespace_decl);
1880 if (decl_ctx == translation_unit_decl) {
1881 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1883 return namespace_decl;
1886 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1887 SourceLocation(),
nullptr,
nullptr,
false);
1888 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1889 translation_unit_decl->addDecl(namespace_decl);
1890 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace());
1892 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1893 if (parent_namespace_decl) {
1894 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1896 return namespace_decl;
1898 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1899 SourceLocation(),
nullptr,
nullptr,
false);
1900 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1901 parent_namespace_decl->addDecl(namespace_decl);
1902 assert(namespace_decl ==
1903 parent_namespace_decl->getAnonymousNamespace());
1905 assert(
false &&
"GetUniqueNamespaceDeclaration called with no name and "
1906 "no namespace as decl_ctx");
1914 VerifyDecl(namespace_decl);
1915 return namespace_decl;
1922 clang::BlockDecl *decl =
1923 clang::BlockDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1924 decl->setDeclContext(ctx);
1933 clang::DeclContext *right,
1934 clang::DeclContext *root) {
1935 if (root ==
nullptr)
1938 std::set<clang::DeclContext *> path_left;
1939 for (clang::DeclContext *d = left; d !=
nullptr; d = d->getParent())
1940 path_left.insert(d);
1942 for (clang::DeclContext *d = right; d !=
nullptr; d = d->getParent())
1943 if (path_left.find(d) != path_left.end())
1951 clang::NamespaceDecl *ns_decl) {
1952 if (decl_ctx && ns_decl) {
1953 auto *translation_unit =
getASTContext().getTranslationUnitDecl();
1954 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
1956 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
1957 clang::SourceLocation(), ns_decl,
1960 decl_ctx->addDecl(using_decl);
1970 clang::NamedDecl *target) {
1971 if (current_decl_ctx && target) {
1972 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
1974 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(),
false);
1976 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
1978 target->getDeclName(), using_decl, target);
1980 using_decl->addShadowDecl(shadow_decl);
1981 current_decl_ctx->addDecl(using_decl);
1989 const char *name, clang::QualType type) {
1991 clang::VarDecl *var_decl =
1992 clang::VarDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
1993 var_decl->setDeclContext(decl_context);
1994 if (name && name[0])
1995 var_decl->setDeclName(&
getASTContext().Idents.getOwn(name));
1996 var_decl->setType(type);
1998 var_decl->setAccess(clang::AS_public);
1999 decl_context->addDecl(var_decl);
2008 switch (basic_type) {
2010 return ast->VoidTy.getAsOpaquePtr();
2012 return ast->CharTy.getAsOpaquePtr();
2014 return ast->SignedCharTy.getAsOpaquePtr();
2016 return ast->UnsignedCharTy.getAsOpaquePtr();
2018 return ast->getWCharType().getAsOpaquePtr();
2020 return ast->getSignedWCharType().getAsOpaquePtr();
2022 return ast->getUnsignedWCharType().getAsOpaquePtr();
2024 return ast->Char8Ty.getAsOpaquePtr();
2026 return ast->Char16Ty.getAsOpaquePtr();
2028 return ast->Char32Ty.getAsOpaquePtr();
2030 return ast->ShortTy.getAsOpaquePtr();
2032 return ast->UnsignedShortTy.getAsOpaquePtr();
2034 return ast->IntTy.getAsOpaquePtr();
2036 return ast->UnsignedIntTy.getAsOpaquePtr();
2038 return ast->LongTy.getAsOpaquePtr();
2040 return ast->UnsignedLongTy.getAsOpaquePtr();
2042 return ast->LongLongTy.getAsOpaquePtr();
2044 return ast->UnsignedLongLongTy.getAsOpaquePtr();
2046 return ast->Int128Ty.getAsOpaquePtr();
2048 return ast->UnsignedInt128Ty.getAsOpaquePtr();
2050 return ast->BoolTy.getAsOpaquePtr();
2052 return ast->HalfTy.getAsOpaquePtr();
2054 return ast->FloatTy.getAsOpaquePtr();
2056 return ast->DoubleTy.getAsOpaquePtr();
2058 return ast->LongDoubleTy.getAsOpaquePtr();
2060 return ast->Float128Ty.getAsOpaquePtr();
2062 return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
2064 return ast->getComplexType(ast->DoubleTy).getAsOpaquePtr();
2066 return ast->getComplexType(ast->LongDoubleTy).getAsOpaquePtr();
2068 return ast->getObjCIdType().getAsOpaquePtr();
2070 return ast->getObjCClassType().getAsOpaquePtr();
2072 return ast->getObjCSelType().getAsOpaquePtr();
2074 return ast->NullPtrTy.getAsOpaquePtr();
2080#pragma mark Function Types
2082clang::DeclarationName
2085 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2086 if (!
IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2095 const clang::FunctionProtoType *function_type =
2096 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2097 if (function_type ==
nullptr)
2098 return clang::DeclarationName();
2100 const bool is_method =
false;
2101 const unsigned int num_params = function_type->getNumParams();
2103 is_method, op_kind, num_params))
2104 return clang::DeclarationName();
2106 return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
2110 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
2111 printing_policy.SuppressTagKeyword =
true;
2114 printing_policy.SuppressInlineNamespace =
2115 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None);
2116 printing_policy.SuppressUnwrittenScope =
false;
2128 printing_policy.SuppressDefaultTemplateArgs =
false;
2129 return printing_policy;
2136 llvm::raw_string_ostream os(result);
2137 named_decl->getNameForDiagnostic(os, printing_policy, qualified);
2143 llvm::StringRef name,
const CompilerType &function_clang_type,
2144 clang::StorageClass storage,
bool is_inline, llvm::StringRef asm_label) {
2145 FunctionDecl *func_decl =
nullptr;
2148 decl_ctx = ast.getTranslationUnitDecl();
2150 const bool hasWrittenPrototype =
true;
2151 const bool isConstexprSpecified =
false;
2153 clang::DeclarationName declarationName =
2155 func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
2156 func_decl->setDeclContext(decl_ctx);
2157 func_decl->setDeclName(declarationName);
2159 func_decl->setStorageClass(storage);
2160 func_decl->setInlineSpecified(is_inline);
2161 func_decl->setHasWrittenPrototype(hasWrittenPrototype);
2162 func_decl->setConstexprKind(isConstexprSpecified
2163 ? ConstexprSpecKind::Constexpr
2164 : ConstexprSpecKind::Unspecified);
2176 if (!asm_label.empty())
2177 func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label));
2180 decl_ctx->addDecl(func_decl);
2182 VerifyDecl(func_decl);
2188 const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
2189 bool is_variadic,
unsigned type_quals, clang::CallingConv cc,
2190 clang::RefQualifierKind ref_qual) {
2194 std::vector<QualType> qual_type_args;
2196 for (
const auto &arg : args) {
2211 FunctionProtoType::ExtProtoInfo proto_info;
2212 proto_info.ExtInfo = cc;
2213 proto_info.Variadic = is_variadic;
2214 proto_info.ExceptionSpec = EST_None;
2215 proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
2216 proto_info.RefQualifier = ref_qual;
2224 const char *name,
const CompilerType ¶m_type,
int storage,
2227 auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
2228 decl->setDeclContext(decl_ctx);
2229 if (name && name[0])
2230 decl->setDeclName(&ast.Idents.get(name));
2232 decl->setStorageClass(
static_cast<clang::StorageClass
>(storage));
2235 decl_ctx->addDecl(decl);
2242 QualType block_type =
m_ast_up->getBlockPointerType(
2248#pragma mark Array Types
2252 std::optional<size_t> element_count,
2265 clang::ArraySizeModifier::Normal, 0));
2271 llvm::APInt ap_element_count(64, *element_count);
2273 ap_element_count,
nullptr,
2274 clang::ArraySizeModifier::Normal, 0));
2278 llvm::StringRef type_name,
2279 const std::initializer_list<std::pair<const char *, CompilerType>>
2286 lldbassert(0 &&
"Trying to create a type for an existing name");
2291 llvm::to_underlying(clang::TagTypeKind::Struct),
2294 for (
const auto &field : type_fields)
2303 llvm::StringRef type_name,
2304 const std::initializer_list<std::pair<const char *, CompilerType>>
2316#pragma mark Enumeration Types
2319 llvm::StringRef name, clang::DeclContext *decl_ctx,
2321 const CompilerType &integer_clang_type,
bool is_scoped,
2322 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind) {
2329 EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
2330 enum_decl->setDeclContext(decl_ctx);
2332 enum_decl->setDeclName(&ast.Idents.get(name));
2333 enum_decl->setScoped(is_scoped);
2334 enum_decl->setScopedUsingClassTag(is_scoped);
2335 enum_decl->setFixed(
false);
2338 decl_ctx->addDecl(enum_decl);
2342 clang::EnumExtensibilityAttr::CreateImplicit(ast, *enum_kind));
2347 enum_decl->setAccess(AS_public);
2349 return GetType(ast.getCanonicalTagType(enum_decl));
2360 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
2361 return GetType(ast.SignedCharTy);
2363 if (bit_size == ast.getTypeSize(ast.ShortTy))
2366 if (bit_size == ast.getTypeSize(ast.IntTy))
2369 if (bit_size == ast.getTypeSize(ast.LongTy))
2372 if (bit_size == ast.getTypeSize(ast.LongLongTy))
2373 return GetType(ast.LongLongTy);
2375 if (bit_size == ast.getTypeSize(ast.Int128Ty))
2378 if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
2379 return GetType(ast.UnsignedCharTy);
2381 if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
2382 return GetType(ast.UnsignedShortTy);
2384 if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
2385 return GetType(ast.UnsignedIntTy);
2387 if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
2388 return GetType(ast.UnsignedLongTy);
2390 if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
2391 return GetType(ast.UnsignedLongLongTy);
2393 if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
2394 return GetType(ast.UnsignedInt128Ty);
2421 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2423 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2424 named_decl->getDeclName().getAsString().c_str());
2426 printf(
"%20s\n", decl_ctx->getDeclKindName());
2432 if (decl ==
nullptr)
2436 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2438 bool is_injected_class_name =
2439 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2440 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2441 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2442 record_decl->getDeclName().getAsString().c_str(),
2443 is_injected_class_name ?
" (injected class name)" :
"");
2446 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2448 printf(
"%20s: %s\n", decl->getDeclKindName(),
2449 named_decl->getDeclName().getAsString().c_str());
2451 printf(
"%20s\n", decl->getDeclKindName());
2457 clang::Decl *decl) {
2461 ExternalASTSource *ast_source = ast->getExternalSource();
2466 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2467 if (tag_decl->isCompleteDefinition())
2470 if (!tag_decl->hasExternalLexicalStorage())
2473 ast_source->CompleteType(tag_decl);
2475 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2476 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2477 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2478 if (objc_interface_decl->getDefinition())
2481 if (!objc_interface_decl->hasExternalLexicalStorage())
2484 ast_source->CompleteType(objc_interface_decl);
2486 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2516std::optional<ClangASTMetadata>
2522 return std::nullopt;
2525std::optional<ClangASTMetadata>
2531 return std::nullopt;
2553 if (find(mask, type->getTypeClass()) != mask.end())
2555 switch (type->getTypeClass()) {
2558 case clang::Type::Atomic:
2559 type = cast<clang::AtomicType>(type)->getValueType();
2561 case clang::Type::Auto:
2562 case clang::Type::Decltype:
2563 case clang::Type::Paren:
2564 case clang::Type::SubstTemplateTypeParm:
2565 case clang::Type::TemplateSpecialization:
2566 case clang::Type::Typedef:
2567 case clang::Type::TypeOf:
2568 case clang::Type::TypeOfExpr:
2569 case clang::Type::Using:
2570 case clang::Type::PredefinedSugar:
2571 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2585 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2586 switch (type_class) {
2587 case clang::Type::ObjCInterface:
2588 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2590 case clang::Type::ObjCObjectPointer:
2592 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2593 ->getPointeeType());
2594 case clang::Type::Enum:
2595 case clang::Type::Record:
2596 return llvm::cast<clang::TagType>(qual_type)
2598 ->getDefinitionOrSelf();
2610static const clang::RecordType *
2612 assert(qual_type->isRecordType());
2614 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2616 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2620 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2623 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2624 const bool fields_loaded =
2625 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2628 if (is_complete && fields_loaded)
2636 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2637 if (external_ast_source) {
2638 external_ast_source->CompleteType(cxx_record_decl);
2639 if (cxx_record_decl->isCompleteDefinition()) {
2640 cxx_record_decl->field_begin();
2641 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
2653 clang::QualType qual_type) {
2654 assert(qual_type->isEnumeralType());
2657 const clang::EnumType *enum_type =
2658 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2660 auto *tag_decl = enum_type->getAsTagDecl();
2664 if (tag_decl->getDefinition())
2668 if (!tag_decl->hasExternalLexicalStorage())
2672 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2673 if (!external_ast_source)
2676 external_ast_source->CompleteType(tag_decl);
2684static const clang::ObjCObjectType *
2686 assert(qual_type->isObjCObjectType());
2689 const clang::ObjCObjectType *objc_class_type =
2690 llvm::cast<clang::ObjCObjectType>(qual_type);
2692 clang::ObjCInterfaceDecl *class_interface_decl =
2693 objc_class_type->getInterface();
2696 if (!class_interface_decl)
2697 return objc_class_type;
2700 if (class_interface_decl->getDefinition())
2701 return objc_class_type;
2704 if (!class_interface_decl->hasExternalLexicalStorage())
2708 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2709 if (!external_ast_source)
2712 external_ast_source->CompleteType(class_interface_decl);
2713 return objc_class_type;
2717 clang::QualType qual_type) {
2719 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2720 switch (type_class) {
2721 case clang::Type::ConstantArray:
2722 case clang::Type::IncompleteArray:
2723 case clang::Type::VariableArray: {
2724 const clang::ArrayType *array_type =
2725 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2730 case clang::Type::Record: {
2732 return !RT->isIncompleteType();
2737 case clang::Type::Enum: {
2739 return !ET->isIncompleteType();
2743 case clang::Type::ObjCObject:
2744 case clang::Type::ObjCInterface: {
2746 return !OT->isIncompleteType();
2751 case clang::Type::Attributed:
2753 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType());
2755 case clang::Type::MemberPointer:
2758 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2759 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2760 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2763 return !qual_type.getTypePtr()->isIncompleteType();
2778 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2785 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2786 switch (type_class) {
2787 case clang::Type::IncompleteArray:
2788 case clang::Type::VariableArray:
2789 case clang::Type::ConstantArray:
2790 case clang::Type::ExtVector:
2791 case clang::Type::Vector:
2792 case clang::Type::Record:
2793 case clang::Type::ObjCObject:
2794 case clang::Type::ObjCInterface:
2806 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2807 switch (type_class) {
2808 case clang::Type::Record: {
2809 if (
const clang::RecordType *record_type =
2810 llvm::dyn_cast_or_null<clang::RecordType>(
2811 qual_type.getTypePtrOrNull())) {
2812 if (
const clang::RecordDecl *record_decl = record_type->getDecl()) {
2813 return record_decl->isAnonymousStructOrUnion();
2827 uint64_t *size,
bool *is_incomplete) {
2830 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2831 switch (type_class) {
2835 case clang::Type::ConstantArray:
2836 if (element_type_ptr)
2838 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2842 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2844 .getLimitedValue(ULLONG_MAX);
2846 *is_incomplete =
false;
2849 case clang::Type::IncompleteArray:
2850 if (element_type_ptr)
2852 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2858 *is_incomplete =
true;
2861 case clang::Type::VariableArray:
2862 if (element_type_ptr)
2864 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2870 *is_incomplete =
false;
2873 case clang::Type::DependentSizedArray:
2874 if (element_type_ptr)
2877 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2883 *is_incomplete =
false;
2886 if (element_type_ptr)
2887 element_type_ptr->
Clear();
2891 *is_incomplete =
false;
2899 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2900 switch (type_class) {
2901 case clang::Type::Vector: {
2902 const clang::VectorType *vector_type =
2903 qual_type->getAs<clang::VectorType>();
2906 *size = vector_type->getNumElements();
2908 *element_type =
GetType(vector_type->getElementType());
2912 case clang::Type::ExtVector: {
2913 const clang::ExtVectorType *ext_vector_type =
2914 qual_type->getAs<clang::ExtVectorType>();
2915 if (ext_vector_type) {
2917 *size = ext_vector_type->getNumElements();
2921 ext_vector_type->getElementType().getAsOpaquePtr());
2937 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
2940 clang::ObjCInterfaceDecl *result_iface_decl =
2941 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
2943 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
2947 return (ast_metadata->GetISAPtr() != 0);
2951 return GetQualType(type).getUnqualifiedType()->isCharType();
2973 if (!pointee_or_element_clang_type.
IsValid())
2976 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
2977 if (pointee_or_element_clang_type.
IsCharType()) {
2978 if (type_flags.
Test(eTypeIsArray)) {
2981 length = llvm::cast<clang::ConstantArrayType>(
2995 if (
auto pointer_auth = qual_type.getPointerAuth())
2996 return pointer_auth.getKey();
3005 if (
auto pointer_auth = qual_type.getPointerAuth())
3006 return pointer_auth.getExtraDiscriminator();
3015 if (
auto pointer_auth = qual_type.getPointerAuth())
3016 return pointer_auth.isAddressDiscriminated();
3022 auto isFunctionType = [&](clang::QualType qual_type) {
3023 return qual_type->isFunctionType();
3037 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3038 switch (type_class) {
3039 case clang::Type::Record:
3041 const clang::CXXRecordDecl *cxx_record_decl =
3042 qual_type->getAsCXXRecordDecl();
3043 if (cxx_record_decl) {
3044 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3047 const clang::RecordType *record_type =
3048 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3050 if (
const clang::RecordDecl *record_decl =
3051 record_type->getDecl()->getDefinition()) {
3054 clang::RecordDecl::field_iterator field_pos,
3055 field_end = record_decl->field_end();
3056 uint32_t num_fields = 0;
3057 bool is_hva =
false;
3058 bool is_hfa =
false;
3059 clang::QualType base_qual_type;
3060 uint64_t base_bitwidth = 0;
3061 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3063 clang::QualType field_qual_type = field_pos->getType();
3064 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3065 if (field_qual_type->isFloatingType()) {
3066 if (field_qual_type->isComplexType())
3069 if (num_fields == 0)
3070 base_qual_type = field_qual_type;
3075 if (field_qual_type.getTypePtr() !=
3076 base_qual_type.getTypePtr())
3080 }
else if (field_qual_type->isVectorType() ||
3081 field_qual_type->isExtVectorType()) {
3082 if (num_fields == 0) {
3083 base_qual_type = field_qual_type;
3084 base_bitwidth = field_bitwidth;
3089 if (base_bitwidth != field_bitwidth)
3091 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3100 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3117 const clang::FunctionProtoType *func =
3118 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3120 return func->getNumParams();
3127 const size_t index) {
3130 const clang::FunctionProtoType *func =
3131 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3133 if (index < func->getNumParams())
3134 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3142 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3146 if (predicate(qual_type))
3149 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3150 switch (type_class) {
3154 case clang::Type::LValueReference:
3155 case clang::Type::RValueReference: {
3156 const clang::ReferenceType *reference_type =
3157 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3159 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3168 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3169 return qual_type->isMemberFunctionPointerType();
3172 return IsTypeImpl(type, isMemberFunctionPointerType);
3177 auto isMemberDataPointerType = [](clang::QualType qual_type) {
3178 return qual_type->isMemberDataPointerType();
3181 return IsTypeImpl(type, isMemberDataPointerType);
3185 auto isFunctionPointerType = [](clang::QualType qual_type) {
3186 return qual_type->isFunctionPointerType();
3189 return IsTypeImpl(type, isFunctionPointerType);
3195 auto isBlockPointerType = [&](clang::QualType qual_type) {
3196 if (qual_type->isBlockPointerType()) {
3197 if (function_pointer_type_ptr) {
3198 const clang::BlockPointerType *block_pointer_type =
3199 qual_type->castAs<clang::BlockPointerType>();
3200 QualType pointee_type = block_pointer_type->getPointeeType();
3201 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3203 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3220 if (qual_type.isNull())
3229 is_signed = qual_type->isSignedIntegerType();
3237 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3241 is_signed = enum_type->isSignedIntegerOrEnumerationType();
3252 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3256 return enum_type->isScopedEnumeralType();
3267 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3268 switch (type_class) {
3269 case clang::Type::Builtin:
3270 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3273 case clang::BuiltinType::ObjCId:
3274 case clang::BuiltinType::ObjCClass:
3278 case clang::Type::ObjCObjectPointer:
3282 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3286 case clang::Type::BlockPointer:
3289 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3293 case clang::Type::Pointer:
3296 llvm::cast<clang::PointerType>(qual_type)
3300 case clang::Type::MemberPointer:
3303 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3312 pointee_type->
Clear();
3320 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3321 switch (type_class) {
3322 case clang::Type::Builtin:
3323 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3326 case clang::BuiltinType::ObjCId:
3327 case clang::BuiltinType::ObjCClass:
3331 case clang::Type::ObjCObjectPointer:
3335 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3339 case clang::Type::BlockPointer:
3342 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3346 case clang::Type::Pointer:
3349 llvm::cast<clang::PointerType>(qual_type)
3353 case clang::Type::MemberPointer:
3356 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3360 case clang::Type::LValueReference:
3363 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3367 case clang::Type::RValueReference:
3370 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3379 pointee_type->
Clear();
3388 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3390 switch (type_class) {
3391 case clang::Type::LValueReference:
3394 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3400 case clang::Type::RValueReference:
3403 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3415 pointee_type->
Clear();
3424 if (qual_type.isNull())
3427 return qual_type->isFloatingType();
3435 const clang::TagType *tag_type =
3436 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3438 if (clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinition())
3439 return tag_decl->isCompleteDefinition();
3442 const clang::ObjCObjectType *objc_class_type =
3443 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3444 if (objc_class_type) {
3445 clang::ObjCInterfaceDecl *class_interface_decl =
3446 objc_class_type->getInterface();
3447 if (class_interface_decl)
3448 return class_interface_decl->getDefinition() !=
nullptr;
3459 const clang::ObjCObjectPointerType *obj_pointer_type =
3460 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3462 if (obj_pointer_type)
3463 return obj_pointer_type->isObjCClassType();
3478 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3479 return (type_class == clang::Type::Record);
3486 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3487 return (type_class == clang::Type::Enum);
3493 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3494 switch (type_class) {
3495 case clang::Type::Record:
3497 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3504 return cxx_record_decl->isDynamicClass();
3518 bool check_cplusplus,
3520 if (dynamic_pointee_type)
3521 dynamic_pointee_type->
Clear();
3525 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3526 if (dynamic_pointee_type)
3528 type.getAsOpaquePtr());
3531 clang::QualType pointee_qual_type;
3533 switch (qual_type->getTypeClass()) {
3534 case clang::Type::Builtin:
3535 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3536 clang::BuiltinType::ObjCId) {
3537 set_dynamic_pointee_type(qual_type);
3542 case clang::Type::ObjCObjectPointer:
3545 if (
const auto *objc_pointee_type =
3546 qual_type->getPointeeType().getTypePtrOrNull()) {
3547 if (
const auto *objc_object_type =
3548 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3549 objc_pointee_type)) {
3550 if (objc_object_type->isObjCClass())
3554 set_dynamic_pointee_type(
3555 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3558 case clang::Type::Pointer:
3560 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3563 case clang::Type::LValueReference:
3564 case clang::Type::RValueReference:
3566 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3576 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3577 case clang::Type::Builtin:
3578 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3579 case clang::BuiltinType::UnknownAny:
3580 case clang::BuiltinType::Void:
3581 set_dynamic_pointee_type(pointee_qual_type);
3587 case clang::Type::Record: {
3588 if (!check_cplusplus)
3590 clang::CXXRecordDecl *cxx_record_decl =
3591 pointee_qual_type->getAsCXXRecordDecl();
3592 if (!cxx_record_decl)
3596 if (cxx_record_decl->isCompleteDefinition())
3597 success = cxx_record_decl->isDynamicClass();
3599 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3600 std::optional<bool> is_dynamic =
3601 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3603 success = *is_dynamic;
3605 success = cxx_record_decl->isDynamicClass();
3611 set_dynamic_pointee_type(pointee_qual_type);
3615 case clang::Type::ObjCObject:
3616 case clang::Type::ObjCInterface:
3618 set_dynamic_pointee_type(pointee_qual_type);
3633 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3640 ->getTypeClass() == clang::Type::Typedef;
3657 if (
auto *record_decl =
3659 return record_decl->canPassInRegisters();
3665 return TypeSystemClangSupportsLanguage(language);
3668std::optional<std::string>
3671 return std::nullopt;
3674 if (qual_type.isNull())
3675 return std::nullopt;
3677 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3678 if (!cxx_record_decl)
3679 return std::nullopt;
3681 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3689 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3696 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3698 return tag_type->getDecl()->isEntityBeingDefined();
3709 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3710 if (class_type_ptr) {
3711 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3712 const clang::ObjCObjectPointerType *obj_pointer_type =
3713 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3714 if (obj_pointer_type ==
nullptr)
3715 class_type_ptr->
Clear();
3719 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3726 class_type_ptr->
Clear();
3753 {clang::Type::Typedef, clang::Type::Atomic});
3756 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3757 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3764 if (
auto *named_decl = qual_type->getAsTagDecl())
3776 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3777 printing_policy.SuppressTagKeyword =
true;
3778 printing_policy.SuppressScope =
false;
3779 printing_policy.SuppressUnwrittenScope =
true;
3780 printing_policy.SuppressInlineNamespace =
3781 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::All);
3782 return ConstString(qual_type.getAsString(printing_policy));
3791 if (pointee_or_element_clang_type)
3792 pointee_or_element_clang_type->
Clear();
3794 clang::QualType qual_type =
3797 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3798 switch (type_class) {
3799 case clang::Type::Attributed:
3800 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3803 pointee_or_element_clang_type);
3804 case clang::Type::BitInt: {
3805 uint32_t type_flags = eTypeIsScalar | eTypeIsInteger | eTypeHasValue;
3806 if (qual_type->isSignedIntegerType())
3807 type_flags |= eTypeIsSigned;
3811 case clang::Type::Builtin: {
3812 const clang::BuiltinType *builtin_type =
3813 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3815 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3816 switch (builtin_type->getKind()) {
3817 case clang::BuiltinType::ObjCId:
3818 case clang::BuiltinType::ObjCClass:
3819 if (pointee_or_element_clang_type)
3823 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3826 case clang::BuiltinType::ObjCSel:
3827 if (pointee_or_element_clang_type)
3830 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3833 case clang::BuiltinType::Bool:
3834 case clang::BuiltinType::Char_U:
3835 case clang::BuiltinType::UChar:
3836 case clang::BuiltinType::WChar_U:
3837 case clang::BuiltinType::Char16:
3838 case clang::BuiltinType::Char32:
3839 case clang::BuiltinType::UShort:
3840 case clang::BuiltinType::UInt:
3841 case clang::BuiltinType::ULong:
3842 case clang::BuiltinType::ULongLong:
3843 case clang::BuiltinType::UInt128:
3844 case clang::BuiltinType::Char_S:
3845 case clang::BuiltinType::SChar:
3846 case clang::BuiltinType::WChar_S:
3847 case clang::BuiltinType::Short:
3848 case clang::BuiltinType::Int:
3849 case clang::BuiltinType::Long:
3850 case clang::BuiltinType::LongLong:
3851 case clang::BuiltinType::Int128:
3852 case clang::BuiltinType::Float:
3853 case clang::BuiltinType::Double:
3854 case clang::BuiltinType::LongDouble:
3855 builtin_type_flags |= eTypeIsScalar;
3856 if (builtin_type->isInteger()) {
3857 builtin_type_flags |= eTypeIsInteger;
3858 if (builtin_type->isSignedInteger())
3859 builtin_type_flags |= eTypeIsSigned;
3860 }
else if (builtin_type->isFloatingPoint())
3861 builtin_type_flags |= eTypeIsFloat;
3866 return builtin_type_flags;
3869 case clang::Type::BlockPointer:
3870 if (pointee_or_element_clang_type)
3872 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3873 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3875 case clang::Type::Complex: {
3876 uint32_t complex_type_flags =
3877 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3878 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3879 qual_type->getCanonicalTypeInternal());
3881 clang::QualType complex_element_type(complex_type->getElementType());
3882 if (complex_element_type->isIntegerType())
3883 complex_type_flags |= eTypeIsInteger;
3884 else if (complex_element_type->isFloatingType())
3885 complex_type_flags |= eTypeIsFloat;
3887 return complex_type_flags;
3890 case clang::Type::ConstantArray:
3891 case clang::Type::DependentSizedArray:
3892 case clang::Type::IncompleteArray:
3893 case clang::Type::VariableArray:
3894 if (pointee_or_element_clang_type)
3896 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
3899 return eTypeHasChildren | eTypeIsArray;
3901 case clang::Type::DependentName:
3903 case clang::Type::DependentSizedExtVector:
3904 return eTypeHasChildren | eTypeIsVector;
3906 case clang::Type::Enum:
3907 if (pointee_or_element_clang_type)
3909 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
3911 ->getDefinitionOrSelf()
3914 return eTypeIsEnumeration | eTypeHasValue;
3916 case clang::Type::FunctionProto:
3917 return eTypeIsFuncPrototype | eTypeHasValue;
3918 case clang::Type::FunctionNoProto:
3919 return eTypeIsFuncPrototype | eTypeHasValue;
3920 case clang::Type::InjectedClassName:
3923 case clang::Type::LValueReference:
3924 case clang::Type::RValueReference:
3925 if (pointee_or_element_clang_type)
3928 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
3931 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
3933 case clang::Type::MemberPointer:
3934 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
3936 case clang::Type::ObjCObjectPointer:
3937 if (pointee_or_element_clang_type)
3939 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3940 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
3943 case clang::Type::ObjCObject:
3944 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
3945 case clang::Type::ObjCInterface:
3946 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
3948 case clang::Type::Pointer:
3949 if (pointee_or_element_clang_type)
3951 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3952 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
3954 case clang::Type::Record:
3955 if (qual_type->getAsCXXRecordDecl())
3956 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
3958 return eTypeHasChildren | eTypeIsStructUnion;
3960 case clang::Type::SubstTemplateTypeParm:
3961 return eTypeIsTemplate;
3962 case clang::Type::TemplateTypeParm:
3963 return eTypeIsTemplate;
3964 case clang::Type::TemplateSpecialization:
3965 return eTypeIsTemplate;
3967 case clang::Type::Typedef:
3968 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
3970 ->getUnderlyingType())
3972 case clang::Type::UnresolvedUsing:
3975 case clang::Type::ExtVector:
3976 case clang::Type::Vector: {
3977 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
3978 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
3979 qual_type->getCanonicalTypeInternal());
3983 QualType element_type = vector_type->getElementType();
3984 if (element_type.isNull())
3987 if (element_type->isIntegerType())
3988 vector_type_flags |= eTypeIsInteger;
3989 else if (element_type->isFloatingType())
3990 vector_type_flags |= eTypeIsFloat;
3991 return vector_type_flags;
4006 if (qual_type->isAnyPointerType()) {
4007 if (qual_type->isObjCObjectPointerType())
4009 if (qual_type->getPointeeCXXRecordDecl())
4012 clang::QualType pointee_type(qual_type->getPointeeType());
4013 if (pointee_type->getPointeeCXXRecordDecl())
4015 if (pointee_type->isObjCObjectOrInterfaceType())
4017 if (pointee_type->isObjCClassType())
4019 if (pointee_type.getTypePtr() ==
4023 if (qual_type->isObjCObjectOrInterfaceType())
4025 if (qual_type->getAsCXXRecordDecl())
4027 switch (qual_type->getTypeClass()) {
4030 case clang::Type::Builtin:
4031 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4033 case clang::BuiltinType::Void:
4034 case clang::BuiltinType::Bool:
4035 case clang::BuiltinType::Char_U:
4036 case clang::BuiltinType::UChar:
4037 case clang::BuiltinType::WChar_U:
4038 case clang::BuiltinType::Char16:
4039 case clang::BuiltinType::Char32:
4040 case clang::BuiltinType::UShort:
4041 case clang::BuiltinType::UInt:
4042 case clang::BuiltinType::ULong:
4043 case clang::BuiltinType::ULongLong:
4044 case clang::BuiltinType::UInt128:
4045 case clang::BuiltinType::Char_S:
4046 case clang::BuiltinType::SChar:
4047 case clang::BuiltinType::WChar_S:
4048 case clang::BuiltinType::Short:
4049 case clang::BuiltinType::Int:
4050 case clang::BuiltinType::Long:
4051 case clang::BuiltinType::LongLong:
4052 case clang::BuiltinType::Int128:
4053 case clang::BuiltinType::Float:
4054 case clang::BuiltinType::Double:
4055 case clang::BuiltinType::LongDouble:
4058 case clang::BuiltinType::NullPtr:
4061 case clang::BuiltinType::ObjCId:
4062 case clang::BuiltinType::ObjCClass:
4063 case clang::BuiltinType::ObjCSel:
4066 case clang::BuiltinType::Dependent:
4067 case clang::BuiltinType::Overload:
4068 case clang::BuiltinType::BoundMember:
4069 case clang::BuiltinType::UnknownAny:
4073 case clang::Type::Typedef:
4074 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4076 ->getUnderlyingType())
4086 return lldb::eTypeClassInvalid;
4088 clang::QualType qual_type =
4091 switch (qual_type->getTypeClass()) {
4092 case clang::Type::Atomic:
4093 case clang::Type::Auto:
4094 case clang::Type::CountAttributed:
4095 case clang::Type::Decltype:
4096 case clang::Type::Paren:
4097 case clang::Type::TypeOf:
4098 case clang::Type::TypeOfExpr:
4099 case clang::Type::Using:
4100 case clang::Type::PredefinedSugar:
4101 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4102 case clang::Type::LateParsedAttr:
4103 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
4104 "that is resolved before the AST is finalized.");
4105 case clang::Type::UnaryTransform:
4107 case clang::Type::FunctionNoProto:
4108 return lldb::eTypeClassFunction;
4109 case clang::Type::FunctionProto:
4110 return lldb::eTypeClassFunction;
4111 case clang::Type::IncompleteArray:
4112 return lldb::eTypeClassArray;
4113 case clang::Type::VariableArray:
4114 return lldb::eTypeClassArray;
4115 case clang::Type::ConstantArray:
4116 return lldb::eTypeClassArray;
4117 case clang::Type::DependentSizedArray:
4118 return lldb::eTypeClassArray;
4119 case clang::Type::ArrayParameter:
4120 return lldb::eTypeClassArray;
4121 case clang::Type::DependentSizedExtVector:
4122 return lldb::eTypeClassVector;
4123 case clang::Type::DependentVector:
4124 return lldb::eTypeClassVector;
4125 case clang::Type::ExtVector:
4126 return lldb::eTypeClassVector;
4127 case clang::Type::Vector:
4128 return lldb::eTypeClassVector;
4129 case clang::Type::Builtin:
4131 case clang::Type::BitInt:
4132 case clang::Type::DependentBitInt:
4133 case clang::Type::OverflowBehavior:
4134 return lldb::eTypeClassBuiltin;
4135 case clang::Type::ObjCObjectPointer:
4136 return lldb::eTypeClassObjCObjectPointer;
4137 case clang::Type::BlockPointer:
4138 return lldb::eTypeClassBlockPointer;
4139 case clang::Type::Pointer:
4140 return lldb::eTypeClassPointer;
4141 case clang::Type::LValueReference:
4142 return lldb::eTypeClassReference;
4143 case clang::Type::RValueReference:
4144 return lldb::eTypeClassReference;
4145 case clang::Type::MemberPointer:
4146 return lldb::eTypeClassMemberPointer;
4147 case clang::Type::Complex:
4148 if (qual_type->isComplexType())
4149 return lldb::eTypeClassComplexFloat;
4151 return lldb::eTypeClassComplexInteger;
4152 case clang::Type::ObjCObject:
4153 return lldb::eTypeClassObjCObject;
4154 case clang::Type::ObjCInterface:
4155 return lldb::eTypeClassObjCInterface;
4156 case clang::Type::Record: {
4157 const clang::RecordType *record_type =
4158 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4159 const clang::RecordDecl *record_decl = record_type->getDecl();
4160 if (record_decl->isUnion())
4161 return lldb::eTypeClassUnion;
4162 else if (record_decl->isStruct())
4163 return lldb::eTypeClassStruct;
4165 return lldb::eTypeClassClass;
4167 case clang::Type::Enum:
4168 return lldb::eTypeClassEnumeration;
4169 case clang::Type::Typedef:
4170 return lldb::eTypeClassTypedef;
4171 case clang::Type::UnresolvedUsing:
4174 case clang::Type::Attributed:
4175 case clang::Type::BTFTagAttributed:
4177 case clang::Type::TemplateTypeParm:
4179 case clang::Type::SubstTemplateTypeParm:
4181 case clang::Type::SubstTemplateTypeParmPack:
4183 case clang::Type::InjectedClassName:
4185 case clang::Type::DependentName:
4187 case clang::Type::PackExpansion:
4190 case clang::Type::TemplateSpecialization:
4192 case clang::Type::DeducedTemplateSpecialization:
4194 case clang::Type::Pipe:
4198 case clang::Type::Decayed:
4200 case clang::Type::Adjusted:
4202 case clang::Type::ObjCTypeParam:
4205 case clang::Type::DependentAddressSpace:
4207 case clang::Type::MacroQualified:
4211 case clang::Type::ConstantMatrix:
4212 case clang::Type::DependentSizedMatrix:
4216 case clang::Type::PackIndexing:
4219 case clang::Type::HLSLAttributedResource:
4221 case clang::Type::HLSLInlineSpirv:
4223 case clang::Type::SubstBuiltinTemplatePack:
4227 return lldb::eTypeClassOther;
4232 return GetQualType(type).getQualifiers().getCVRQualifiers();
4244 const clang::Type *array_eletype =
4245 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4250 return GetType(clang::QualType(array_eletype, 0));
4261 return GetType(ast_ctx.getConstantArrayType(
4262 qual_type, llvm::APInt(64, size),
nullptr,
4263 clang::ArraySizeModifier::Normal, 0));
4265 return GetType(ast_ctx.getIncompleteArrayType(
4266 qual_type, clang::ArraySizeModifier::Normal, 0));
4280 clang::QualType qual_type) {
4281 if (qual_type->isPointerType())
4282 qual_type = ast->getPointerType(
4284 else if (
const ConstantArrayType *arr =
4285 ast->getAsConstantArrayType(qual_type)) {
4286 qual_type = ast->getConstantArrayType(
4288 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4289 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4291 qual_type = qual_type.getUnqualifiedType();
4292 qual_type.removeLocalConst();
4293 qual_type.removeLocalRestrict();
4294 qual_type.removeLocalVolatile();
4316 const clang::FunctionProtoType *func =
4319 return func->getNumParams();
4327 const clang::FunctionProtoType *func =
4328 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4330 const uint32_t num_args = func->getNumParams();
4332 return GetType(func->getParamType(idx));
4342 const clang::FunctionProtoType *func =
4343 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4345 return GetType(func->getReturnType());
4352 size_t num_functions = 0;
4355 switch (qual_type->getTypeClass()) {
4356 case clang::Type::Record:
4358 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4359 num_functions = std::distance(cxx_record_decl->method_begin(),
4360 cxx_record_decl->method_end());
4363 case clang::Type::ObjCObjectPointer: {
4364 const clang::ObjCObjectPointerType *objc_class_type =
4365 qual_type->castAs<clang::ObjCObjectPointerType>();
4366 const clang::ObjCInterfaceType *objc_interface_type =
4367 objc_class_type->getInterfaceType();
4368 if (objc_interface_type &&
4370 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4371 clang::ObjCInterfaceDecl *class_interface_decl =
4372 objc_interface_type->getDecl();
4373 if (class_interface_decl) {
4374 num_functions = std::distance(class_interface_decl->meth_begin(),
4375 class_interface_decl->meth_end());
4381 case clang::Type::ObjCObject:
4382 case clang::Type::ObjCInterface:
4384 const clang::ObjCObjectType *objc_class_type =
4385 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4386 if (objc_class_type) {
4387 clang::ObjCInterfaceDecl *class_interface_decl =
4388 objc_class_type->getInterface();
4389 if (class_interface_decl)
4390 num_functions = std::distance(class_interface_decl->meth_begin(),
4391 class_interface_decl->meth_end());
4400 return num_functions;
4412 switch (qual_type->getTypeClass()) {
4413 case clang::Type::Record:
4415 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4416 auto method_iter = cxx_record_decl->method_begin();
4417 auto method_end = cxx_record_decl->method_end();
4419 static_cast<size_t>(std::distance(method_iter, method_end))) {
4420 std::advance(method_iter, idx);
4421 clang::CXXMethodDecl *cxx_method_decl =
4422 method_iter->getCanonicalDecl();
4423 if (cxx_method_decl) {
4424 name = cxx_method_decl->getDeclName().getAsString();
4425 if (cxx_method_decl->isStatic())
4427 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4429 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4433 clang_type =
GetType(cxx_method_decl->getType());
4441 case clang::Type::ObjCObjectPointer: {
4442 const clang::ObjCObjectPointerType *objc_class_type =
4443 qual_type->castAs<clang::ObjCObjectPointerType>();
4444 const clang::ObjCInterfaceType *objc_interface_type =
4445 objc_class_type->getInterfaceType();
4446 if (objc_interface_type &&
4448 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4449 clang::ObjCInterfaceDecl *class_interface_decl =
4450 objc_interface_type->getDecl();
4451 if (class_interface_decl) {
4452 auto method_iter = class_interface_decl->meth_begin();
4453 auto method_end = class_interface_decl->meth_end();
4455 static_cast<size_t>(std::distance(method_iter, method_end))) {
4456 std::advance(method_iter, idx);
4457 clang::ObjCMethodDecl *objc_method_decl =
4458 method_iter->getCanonicalDecl();
4459 if (objc_method_decl) {
4461 name = objc_method_decl->getSelector().getAsString();
4462 if (objc_method_decl->isClassMethod())
4473 case clang::Type::ObjCObject:
4474 case clang::Type::ObjCInterface:
4476 const clang::ObjCObjectType *objc_class_type =
4477 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4478 if (objc_class_type) {
4479 clang::ObjCInterfaceDecl *class_interface_decl =
4480 objc_class_type->getInterface();
4481 if (class_interface_decl) {
4482 auto method_iter = class_interface_decl->meth_begin();
4483 auto method_end = class_interface_decl->meth_end();
4485 static_cast<size_t>(std::distance(method_iter, method_end))) {
4486 std::advance(method_iter, idx);
4487 clang::ObjCMethodDecl *objc_method_decl =
4488 method_iter->getCanonicalDecl();
4489 if (objc_method_decl) {
4491 name = objc_method_decl->getSelector().getAsString();
4492 if (objc_method_decl->isClassMethod())
4525 return GetType(qual_type.getTypePtr()->getPointeeType());
4535 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4536 case clang::Type::ObjCObject:
4537 case clang::Type::ObjCInterface:
4584 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4585 clang::QualType result =
4586 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4596 result.addVolatile();
4606 result.addRestrict();
4615 if (type && typedef_name && typedef_name[0]) {
4619 clang::DeclContext *decl_ctx =
4624 clang::TypedefDecl *decl =
4625 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4626 decl->setDeclContext(decl_ctx);
4627 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4628 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4629 decl_ctx->addDecl(decl);
4632 clang::TagDecl *tdecl =
nullptr;
4633 if (!qual_type.isNull()) {
4634 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4635 tdecl = rt->getDecl();
4636 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4637 tdecl = et->getDecl();
4643 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4644 tdecl->setTypedefNameForAnonDecl(decl);
4646 decl->setAccess(clang::AS_public);
4649 NestedNameSpecifier Qualifier =
4650 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4652 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4660 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4663 return GetType(typedef_type->getDecl()->getUnderlyingType());
4676 const FunctionType::ExtInfo generic_ext_info(
4685 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4690const llvm::fltSemantics &
4693 const size_t bit_size = byte_size * 8;
4694 if (bit_size == ast.getTypeSize(ast.FloatTy))
4695 return ast.getFloatTypeSemantics(ast.FloatTy);
4696 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4697 return ast.getFloatTypeSemantics(ast.DoubleTy);
4699 bit_size == ast.getTypeSize(ast.Float128Ty))
4700 return ast.getFloatTypeSemantics(ast.Float128Ty);
4701 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4702 bit_size == llvm::APFloat::semanticsSizeInBits(
4703 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4704 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4705 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4706 return ast.getFloatTypeSemantics(ast.HalfTy);
4707 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4708 return ast.getFloatTypeSemantics(ast.Float128Ty);
4709 return llvm::APFloatBase::Bogus();
4712llvm::Expected<uint64_t>
4715 assert(qual_type->isObjCObjectOrInterfaceType());
4720 if (std::optional<uint64_t> bit_size =
4721 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4725 static bool g_printed =
false;
4730 llvm::outs() <<
"warning: trying to determine the size of type ";
4732 llvm::outs() <<
"without a valid ExecutionContext. this is not "
4733 "reliable. please file a bug against LLDB.\n";
4734 llvm::outs() <<
"backtrace:\n";
4735 llvm::sys::PrintStackTrace(llvm::outs());
4736 llvm::outs() <<
"\n";
4745llvm::Expected<uint64_t>
4748 const bool base_name_only =
true;
4750 return llvm::createStringError(
4751 "could not complete type %s",
4755 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4756 switch (type_class) {
4757 case clang::Type::ConstantArray:
4758 case clang::Type::FunctionProto:
4759 case clang::Type::Record:
4761 case clang::Type::ObjCInterface:
4762 case clang::Type::ObjCObject:
4764 case clang::Type::IncompleteArray: {
4765 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4768 qual_type->getArrayElementTypeNoTypeQual()
4769 ->getCanonicalTypeUnqualified());
4774 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4778 return llvm::createStringError(
4779 "could not get size of type %s",
4783std::optional<size_t>
4797 switch (qual_type->getTypeClass()) {
4798 case clang::Type::Atomic:
4799 case clang::Type::Auto:
4800 case clang::Type::CountAttributed:
4801 case clang::Type::Decltype:
4802 case clang::Type::Paren:
4803 case clang::Type::Typedef:
4804 case clang::Type::TypeOf:
4805 case clang::Type::TypeOfExpr:
4806 case clang::Type::Using:
4807 case clang::Type::PredefinedSugar:
4808 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4809 case clang::Type::LateParsedAttr:
4810 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
4811 "that is resolved before the AST is finalized.");
4813 case clang::Type::UnaryTransform:
4816 case clang::Type::FunctionNoProto:
4817 case clang::Type::FunctionProto:
4820 case clang::Type::IncompleteArray:
4821 case clang::Type::VariableArray:
4822 case clang::Type::ArrayParameter:
4825 case clang::Type::ConstantArray:
4828 case clang::Type::DependentVector:
4829 case clang::Type::ExtVector:
4830 case clang::Type::Vector:
4833 case clang::Type::BitInt:
4834 case clang::Type::DependentBitInt:
4835 case clang::Type::OverflowBehavior:
4839 case clang::Type::Builtin:
4840 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4841 case clang::BuiltinType::Void:
4844 case clang::BuiltinType::Char_S:
4845 case clang::BuiltinType::SChar:
4846 case clang::BuiltinType::WChar_S:
4847 case clang::BuiltinType::Short:
4848 case clang::BuiltinType::Int:
4849 case clang::BuiltinType::Long:
4850 case clang::BuiltinType::LongLong:
4851 case clang::BuiltinType::Int128:
4854 case clang::BuiltinType::Bool:
4855 case clang::BuiltinType::Char_U:
4856 case clang::BuiltinType::UChar:
4857 case clang::BuiltinType::WChar_U:
4858 case clang::BuiltinType::Char8:
4859 case clang::BuiltinType::Char16:
4860 case clang::BuiltinType::Char32:
4861 case clang::BuiltinType::UShort:
4862 case clang::BuiltinType::UInt:
4863 case clang::BuiltinType::ULong:
4864 case clang::BuiltinType::ULongLong:
4865 case clang::BuiltinType::UInt128:
4869 case clang::BuiltinType::ShortAccum:
4870 case clang::BuiltinType::Accum:
4871 case clang::BuiltinType::LongAccum:
4872 case clang::BuiltinType::UShortAccum:
4873 case clang::BuiltinType::UAccum:
4874 case clang::BuiltinType::ULongAccum:
4875 case clang::BuiltinType::ShortFract:
4876 case clang::BuiltinType::Fract:
4877 case clang::BuiltinType::LongFract:
4878 case clang::BuiltinType::UShortFract:
4879 case clang::BuiltinType::UFract:
4880 case clang::BuiltinType::ULongFract:
4881 case clang::BuiltinType::SatShortAccum:
4882 case clang::BuiltinType::SatAccum:
4883 case clang::BuiltinType::SatLongAccum:
4884 case clang::BuiltinType::SatUShortAccum:
4885 case clang::BuiltinType::SatUAccum:
4886 case clang::BuiltinType::SatULongAccum:
4887 case clang::BuiltinType::SatShortFract:
4888 case clang::BuiltinType::SatFract:
4889 case clang::BuiltinType::SatLongFract:
4890 case clang::BuiltinType::SatUShortFract:
4891 case clang::BuiltinType::SatUFract:
4892 case clang::BuiltinType::SatULongFract:
4895 case clang::BuiltinType::Half:
4896 case clang::BuiltinType::Float:
4897 case clang::BuiltinType::Float16:
4898 case clang::BuiltinType::Float128:
4899 case clang::BuiltinType::Double:
4900 case clang::BuiltinType::LongDouble:
4901 case clang::BuiltinType::BFloat16:
4902 case clang::BuiltinType::Ibm128:
4905 case clang::BuiltinType::ObjCClass:
4906 case clang::BuiltinType::ObjCId:
4907 case clang::BuiltinType::ObjCSel:
4910 case clang::BuiltinType::NullPtr:
4913 case clang::BuiltinType::Kind::ARCUnbridgedCast:
4914 case clang::BuiltinType::Kind::BoundMember:
4915 case clang::BuiltinType::Kind::BuiltinFn:
4916 case clang::BuiltinType::Kind::Dependent:
4917 case clang::BuiltinType::Kind::OCLClkEvent:
4918 case clang::BuiltinType::Kind::OCLEvent:
4919 case clang::BuiltinType::Kind::OCLImage1dRO:
4920 case clang::BuiltinType::Kind::OCLImage1dWO:
4921 case clang::BuiltinType::Kind::OCLImage1dRW:
4922 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
4923 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
4924 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
4925 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
4926 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
4927 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
4928 case clang::BuiltinType::Kind::OCLImage2dRO:
4929 case clang::BuiltinType::Kind::OCLImage2dWO:
4930 case clang::BuiltinType::Kind::OCLImage2dRW:
4931 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
4932 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
4933 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
4934 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
4935 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
4936 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
4937 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
4938 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
4939 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
4940 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
4941 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
4942 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
4943 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
4944 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
4945 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
4946 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
4947 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
4948 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
4949 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
4950 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
4951 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
4952 case clang::BuiltinType::Kind::OCLImage3dRO:
4953 case clang::BuiltinType::Kind::OCLImage3dWO:
4954 case clang::BuiltinType::Kind::OCLImage3dRW:
4955 case clang::BuiltinType::Kind::OCLQueue:
4956 case clang::BuiltinType::Kind::OCLReserveID:
4957 case clang::BuiltinType::Kind::OCLSampler:
4958 case clang::BuiltinType::Kind::HLSLResource:
4959 case clang::BuiltinType::Kind::ArraySection:
4960 case clang::BuiltinType::Kind::OMPArrayShaping:
4961 case clang::BuiltinType::Kind::OMPIterator:
4962 case clang::BuiltinType::Kind::Overload:
4963 case clang::BuiltinType::Kind::PseudoObject:
4964 case clang::BuiltinType::Kind::UnknownAny:
4967 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
4968 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
4969 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
4970 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
4971 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
4972 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
4973 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
4974 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
4975 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
4976 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
4977 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
4978 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
4982 case clang::BuiltinType::VectorPair:
4983 case clang::BuiltinType::VectorQuad:
4984 case clang::BuiltinType::DMR1024:
4985 case clang::BuiltinType::DMR2048:
4989#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
4990#include "clang/Basic/AArch64ACLETypes.def"
4994#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
4995#include "clang/Basic/RISCVVTypes.def"
4999 case clang::BuiltinType::WasmExternRef:
5002 case clang::BuiltinType::IncompleteMatrixIdx:
5005 case clang::BuiltinType::UnresolvedTemplate:
5009#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
5010 case clang::BuiltinType::Id:
5011#include "clang/Basic/AMDGPUTypes.def"
5017 case clang::Type::ObjCObjectPointer:
5018 case clang::Type::BlockPointer:
5019 case clang::Type::Pointer:
5020 case clang::Type::LValueReference:
5021 case clang::Type::RValueReference:
5022 case clang::Type::MemberPointer:
5024 case clang::Type::Complex: {
5026 if (qual_type->isComplexType())
5029 const clang::ComplexType *complex_type =
5030 qual_type->getAsComplexIntegerType();
5039 case clang::Type::ObjCInterface:
5041 case clang::Type::Record:
5043 case clang::Type::Enum:
5044 return qual_type->isUnsignedIntegerOrEnumerationType()
5047 case clang::Type::DependentSizedArray:
5048 case clang::Type::DependentSizedExtVector:
5049 case clang::Type::UnresolvedUsing:
5050 case clang::Type::Attributed:
5051 case clang::Type::BTFTagAttributed:
5052 case clang::Type::TemplateTypeParm:
5053 case clang::Type::SubstTemplateTypeParm:
5054 case clang::Type::SubstTemplateTypeParmPack:
5055 case clang::Type::InjectedClassName:
5056 case clang::Type::DependentName:
5057 case clang::Type::PackExpansion:
5058 case clang::Type::ObjCObject:
5060 case clang::Type::TemplateSpecialization:
5061 case clang::Type::DeducedTemplateSpecialization:
5062 case clang::Type::Adjusted:
5063 case clang::Type::Pipe:
5067 case clang::Type::Decayed:
5069 case clang::Type::ObjCTypeParam:
5072 case clang::Type::DependentAddressSpace:
5074 case clang::Type::MacroQualified:
5077 case clang::Type::ConstantMatrix:
5078 case clang::Type::DependentSizedMatrix:
5082 case clang::Type::PackIndexing:
5085 case clang::Type::HLSLAttributedResource:
5087 case clang::Type::HLSLInlineSpirv:
5089 case clang::Type::SubstBuiltinTemplatePack:
5102 switch (qual_type->getTypeClass()) {
5103 case clang::Type::Atomic:
5104 case clang::Type::Auto:
5105 case clang::Type::CountAttributed:
5106 case clang::Type::Decltype:
5107 case clang::Type::Paren:
5108 case clang::Type::Typedef:
5109 case clang::Type::TypeOf:
5110 case clang::Type::TypeOfExpr:
5111 case clang::Type::Using:
5112 case clang::Type::PredefinedSugar:
5113 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5114 case clang::Type::LateParsedAttr:
5115 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
5116 "that is resolved before the AST is finalized.");
5117 case clang::Type::UnaryTransform:
5120 case clang::Type::FunctionNoProto:
5121 case clang::Type::FunctionProto:
5124 case clang::Type::IncompleteArray:
5125 case clang::Type::VariableArray:
5126 case clang::Type::ArrayParameter:
5129 case clang::Type::ConstantArray:
5132 case clang::Type::DependentVector:
5133 case clang::Type::ExtVector:
5134 case clang::Type::Vector:
5137 case clang::Type::BitInt:
5138 case clang::Type::DependentBitInt:
5139 case clang::Type::OverflowBehavior:
5143 case clang::Type::Builtin:
5144 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5145 case clang::BuiltinType::UnknownAny:
5146 case clang::BuiltinType::Void:
5147 case clang::BuiltinType::BoundMember:
5150 case clang::BuiltinType::Bool:
5152 case clang::BuiltinType::Char_S:
5153 case clang::BuiltinType::SChar:
5154 case clang::BuiltinType::WChar_S:
5155 case clang::BuiltinType::Char_U:
5156 case clang::BuiltinType::UChar:
5157 case clang::BuiltinType::WChar_U:
5159 case clang::BuiltinType::Char8:
5161 case clang::BuiltinType::Char16:
5163 case clang::BuiltinType::Char32:
5165 case clang::BuiltinType::UShort:
5167 case clang::BuiltinType::Short:
5169 case clang::BuiltinType::UInt:
5171 case clang::BuiltinType::Int:
5173 case clang::BuiltinType::ULong:
5175 case clang::BuiltinType::Long:
5177 case clang::BuiltinType::ULongLong:
5179 case clang::BuiltinType::LongLong:
5181 case clang::BuiltinType::UInt128:
5183 case clang::BuiltinType::Int128:
5185 case clang::BuiltinType::Half:
5186 case clang::BuiltinType::Float:
5187 case clang::BuiltinType::Double:
5188 case clang::BuiltinType::LongDouble:
5190 case clang::BuiltinType::Float128:
5196 case clang::Type::ObjCObjectPointer:
5198 case clang::Type::BlockPointer:
5200 case clang::Type::Pointer:
5202 case clang::Type::LValueReference:
5203 case clang::Type::RValueReference:
5205 case clang::Type::MemberPointer:
5207 case clang::Type::Complex: {
5208 if (qual_type->isComplexType())
5213 case clang::Type::ObjCInterface:
5215 case clang::Type::Record:
5217 case clang::Type::Enum:
5219 case clang::Type::DependentSizedArray:
5220 case clang::Type::DependentSizedExtVector:
5221 case clang::Type::UnresolvedUsing:
5222 case clang::Type::Attributed:
5223 case clang::Type::BTFTagAttributed:
5224 case clang::Type::TemplateTypeParm:
5225 case clang::Type::SubstTemplateTypeParm:
5226 case clang::Type::SubstTemplateTypeParmPack:
5227 case clang::Type::InjectedClassName:
5228 case clang::Type::DependentName:
5229 case clang::Type::PackExpansion:
5230 case clang::Type::ObjCObject:
5232 case clang::Type::TemplateSpecialization:
5233 case clang::Type::DeducedTemplateSpecialization:
5234 case clang::Type::Adjusted:
5235 case clang::Type::Pipe:
5239 case clang::Type::Decayed:
5241 case clang::Type::ObjCTypeParam:
5244 case clang::Type::DependentAddressSpace:
5246 case clang::Type::MacroQualified:
5250 case clang::Type::ConstantMatrix:
5251 case clang::Type::DependentSizedMatrix:
5255 case clang::Type::PackIndexing:
5258 case clang::Type::HLSLAttributedResource:
5260 case clang::Type::HLSLInlineSpirv:
5262 case clang::Type::SubstBuiltinTemplatePack:
5270 while (class_interface_decl) {
5271 if (class_interface_decl->ivar_size() > 0)
5274 class_interface_decl = class_interface_decl->getSuperClass();
5279static std::optional<SymbolFile::ArrayInfo>
5281 clang::QualType qual_type,
5283 if (qual_type->isIncompleteArrayType())
5284 if (std::optional<ClangASTMetadata> metadata =
5288 return std::nullopt;
5291llvm::Expected<uint32_t>
5293 bool omit_empty_base_classes,
5296 return llvm::createStringError(
"invalid clang type");
5298 uint32_t num_children = 0;
5300 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5301 switch (type_class) {
5302 case clang::Type::Builtin:
5303 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5304 case clang::BuiltinType::ObjCId:
5305 case clang::BuiltinType::ObjCClass:
5314 case clang::Type::Complex:
5316 case clang::Type::Record:
5318 const clang::RecordType *record_type =
5319 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5320 const clang::RecordDecl *record_decl =
5321 record_type->getDecl()->getDefinitionOrSelf();
5322 const clang::CXXRecordDecl *cxx_record_decl =
5323 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5327 num_children += std::distance(record_decl->field_begin(),
5328 record_decl->field_end());
5330 return llvm::createStringError(
5333 case clang::Type::ObjCObject:
5334 case clang::Type::ObjCInterface:
5336 const clang::ObjCObjectType *objc_class_type =
5337 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5338 assert(objc_class_type);
5339 if (objc_class_type) {
5340 clang::ObjCInterfaceDecl *class_interface_decl =
5341 objc_class_type->getInterface();
5343 if (class_interface_decl) {
5345 clang::ObjCInterfaceDecl *superclass_interface_decl =
5346 class_interface_decl->getSuperClass();
5347 if (superclass_interface_decl) {
5348 if (omit_empty_base_classes) {
5355 num_children += class_interface_decl->ivar_size();
5361 case clang::Type::LValueReference:
5362 case clang::Type::RValueReference:
5363 case clang::Type::ObjCObjectPointer: {
5366 uint32_t num_pointee_children = 0;
5368 auto num_children_or_err =
5369 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5370 if (!num_children_or_err)
5371 return num_children_or_err;
5372 num_pointee_children = *num_children_or_err;
5375 if (num_pointee_children == 0)
5378 num_children = num_pointee_children;
5381 case clang::Type::Vector:
5382 case clang::Type::ExtVector:
5384 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5387 case clang::Type::ConstantArray:
5388 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5392 case clang::Type::IncompleteArray:
5393 if (
auto array_info =
5396 num_children = array_info->element_orders.size()
5397 ? array_info->element_orders.back().value_or(0)
5401 case clang::Type::Pointer: {
5402 const clang::PointerType *pointer_type =
5403 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5404 clang::QualType pointee_type(pointer_type->getPointeeType());
5406 uint32_t num_pointee_children = 0;
5408 auto num_children_or_err =
5409 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5410 if (!num_children_or_err)
5411 return num_children_or_err;
5412 num_pointee_children = *num_children_or_err;
5414 if (num_pointee_children == 0) {
5419 num_children = num_pointee_children;
5425 return num_children;
5432 if (name_ref.consume_front(
"unsigned _BitInt(") ||
5433 name_ref.consume_front(
"_BitInt(")) {
5435 if (name_ref.consumeInteger(10, bit_size))
5438 if (!name_ref.consume_front(
")"))
5442 name.
GetStringRef().starts_with(
"unsigned"), bit_size));
5451 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5452 if (type_class == clang::Type::Builtin) {
5453 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5454 case clang::BuiltinType::Void:
5456 case clang::BuiltinType::Bool:
5458 case clang::BuiltinType::Char_S:
5460 case clang::BuiltinType::Char_U:
5462 case clang::BuiltinType::Char8:
5464 case clang::BuiltinType::Char16:
5466 case clang::BuiltinType::Char32:
5468 case clang::BuiltinType::UChar:
5470 case clang::BuiltinType::SChar:
5472 case clang::BuiltinType::WChar_S:
5474 case clang::BuiltinType::WChar_U:
5476 case clang::BuiltinType::Short:
5478 case clang::BuiltinType::UShort:
5480 case clang::BuiltinType::Int:
5482 case clang::BuiltinType::UInt:
5484 case clang::BuiltinType::Long:
5486 case clang::BuiltinType::ULong:
5488 case clang::BuiltinType::LongLong:
5490 case clang::BuiltinType::ULongLong:
5492 case clang::BuiltinType::Int128:
5494 case clang::BuiltinType::UInt128:
5497 case clang::BuiltinType::Half:
5499 case clang::BuiltinType::Float:
5501 case clang::BuiltinType::Double:
5503 case clang::BuiltinType::LongDouble:
5505 case clang::BuiltinType::Float128:
5508 case clang::BuiltinType::NullPtr:
5510 case clang::BuiltinType::ObjCId:
5512 case clang::BuiltinType::ObjCClass:
5514 case clang::BuiltinType::ObjCSel:
5528 const llvm::APSInt &value)>
const &callback) {
5529 const clang::EnumType *enum_type =
5532 const clang::EnumDecl *enum_decl =
5533 enum_type->getDecl()->getDefinitionOrSelf();
5537 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5538 for (enum_pos = enum_decl->enumerator_begin(),
5539 enum_end_pos = enum_decl->enumerator_end();
5540 enum_pos != enum_end_pos; ++enum_pos) {
5542 if (!callback(integer_type, name, enum_pos->getInitVal()))
5549#pragma mark Aggregate Types
5557 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5558 switch (type_class) {
5559 case clang::Type::Record:
5561 const clang::RecordType *record_type =
5562 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5564 clang::RecordDecl *record_decl =
5565 record_type->getDecl()->getDefinition();
5567 count = std::distance(record_decl->field_begin(),
5568 record_decl->field_end());
5574 case clang::Type::ObjCObjectPointer: {
5575 const clang::ObjCObjectPointerType *objc_class_type =
5576 qual_type->castAs<clang::ObjCObjectPointerType>();
5577 const clang::ObjCInterfaceType *objc_interface_type =
5578 objc_class_type->getInterfaceType();
5579 if (objc_interface_type &&
5581 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5582 clang::ObjCInterfaceDecl *class_interface_decl =
5583 objc_interface_type->getDecl();
5584 if (class_interface_decl) {
5585 count = class_interface_decl->ivar_size();
5591 case clang::Type::ObjCObject:
5592 case clang::Type::ObjCInterface:
5594 const clang::ObjCObjectType *objc_class_type =
5595 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5596 if (objc_class_type) {
5597 clang::ObjCInterfaceDecl *class_interface_decl =
5598 objc_class_type->getInterface();
5600 if (class_interface_decl)
5601 count = class_interface_decl->ivar_size();
5614 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5615 std::string &name, uint64_t *bit_offset_ptr,
5616 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5617 if (class_interface_decl) {
5618 if (idx < (class_interface_decl->ivar_size())) {
5619 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5620 ivar_end = class_interface_decl->ivar_end();
5621 uint32_t ivar_idx = 0;
5623 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5624 ++ivar_pos, ++ivar_idx) {
5625 if (ivar_idx == idx) {
5626 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5628 clang::QualType ivar_qual_type(ivar_decl->getType());
5630 name.assign(ivar_decl->getNameAsString());
5632 if (bit_offset_ptr) {
5633 const clang::ASTRecordLayout &interface_layout =
5634 ast->getASTObjCInterfaceLayout(class_interface_decl);
5635 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5638 const bool is_bitfield = ivar_pos->isBitField();
5640 if (bitfield_bit_size_ptr) {
5641 *bitfield_bit_size_ptr = 0;
5643 if (is_bitfield && ast) {
5644 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5645 clang::Expr::EvalResult result;
5646 if (bitfield_bit_size_expr &&
5647 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5648 llvm::APSInt bitfield_apsint = result.Val.getInt();
5649 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5653 if (is_bitfield_ptr)
5654 *is_bitfield_ptr = is_bitfield;
5656 return ivar_qual_type.getAsOpaquePtr();
5665 size_t idx, std::string &name,
5666 uint64_t *bit_offset_ptr,
5667 uint32_t *bitfield_bit_size_ptr,
5668 bool *is_bitfield_ptr) {
5673 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5674 switch (type_class) {
5675 case clang::Type::Record:
5677 const clang::RecordType *record_type =
5678 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5679 const clang::RecordDecl *record_decl =
5680 record_type->getDecl()->getDefinitionOrSelf();
5681 uint32_t field_idx = 0;
5682 clang::RecordDecl::field_iterator field, field_end;
5683 for (field = record_decl->field_begin(),
5684 field_end = record_decl->field_end();
5685 field != field_end; ++field, ++field_idx) {
5686 if (idx == field_idx) {
5689 name.assign(field->getNameAsString());
5693 if (bit_offset_ptr) {
5694 const clang::ASTRecordLayout &record_layout =
5696 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5699 const bool is_bitfield = field->isBitField();
5701 if (bitfield_bit_size_ptr) {
5702 *bitfield_bit_size_ptr = 0;
5705 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5706 clang::Expr::EvalResult result;
5707 if (bitfield_bit_size_expr &&
5708 bitfield_bit_size_expr->EvaluateAsInt(result,
5710 llvm::APSInt bitfield_apsint = result.Val.getInt();
5711 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5715 if (is_bitfield_ptr)
5716 *is_bitfield_ptr = is_bitfield;
5718 return GetType(field->getType());
5724 case clang::Type::ObjCObjectPointer: {
5725 const clang::ObjCObjectPointerType *objc_class_type =
5726 qual_type->castAs<clang::ObjCObjectPointerType>();
5727 const clang::ObjCInterfaceType *objc_interface_type =
5728 objc_class_type->getInterfaceType();
5729 if (objc_interface_type &&
5731 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5732 clang::ObjCInterfaceDecl *class_interface_decl =
5733 objc_interface_type->getDecl();
5734 if (class_interface_decl) {
5738 name, bit_offset_ptr, bitfield_bit_size_ptr,
5745 case clang::Type::ObjCObject:
5746 case clang::Type::ObjCInterface:
5748 const clang::ObjCObjectType *objc_class_type =
5749 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5750 assert(objc_class_type);
5751 if (objc_class_type) {
5752 clang::ObjCInterfaceDecl *class_interface_decl =
5753 objc_class_type->getInterface();
5757 name, bit_offset_ptr, bitfield_bit_size_ptr,
5773 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5774 switch (type_class) {
5775 case clang::Type::Record:
5777 const clang::CXXRecordDecl *cxx_record_decl =
5778 qual_type->getAsCXXRecordDecl();
5779 if (cxx_record_decl)
5780 count = cxx_record_decl->getNumBases();
5784 case clang::Type::ObjCObjectPointer:
5788 case clang::Type::ObjCObject:
5790 const clang::ObjCObjectType *objc_class_type =
5791 qual_type->getAsObjCQualifiedInterfaceType();
5792 if (objc_class_type) {
5793 clang::ObjCInterfaceDecl *class_interface_decl =
5794 objc_class_type->getInterface();
5796 if (class_interface_decl && class_interface_decl->getSuperClass())
5801 case clang::Type::ObjCInterface:
5803 const clang::ObjCInterfaceType *objc_interface_type =
5804 qual_type->getAs<clang::ObjCInterfaceType>();
5805 if (objc_interface_type) {
5806 clang::ObjCInterfaceDecl *class_interface_decl =
5807 objc_interface_type->getInterface();
5809 if (class_interface_decl && class_interface_decl->getSuperClass())
5825 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5826 switch (type_class) {
5827 case clang::Type::Record:
5829 const clang::CXXRecordDecl *cxx_record_decl =
5830 qual_type->getAsCXXRecordDecl();
5831 if (cxx_record_decl)
5832 count = cxx_record_decl->getNumVBases();
5845 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5846 switch (type_class) {
5847 case clang::Type::Record:
5849 const clang::CXXRecordDecl *cxx_record_decl =
5850 qual_type->getAsCXXRecordDecl();
5851 if (cxx_record_decl) {
5852 uint32_t curr_idx = 0;
5853 clang::CXXRecordDecl::base_class_const_iterator base_class,
5855 for (base_class = cxx_record_decl->bases_begin(),
5856 base_class_end = cxx_record_decl->bases_end();
5857 base_class != base_class_end; ++base_class, ++curr_idx) {
5858 if (curr_idx == idx) {
5859 if (bit_offset_ptr) {
5860 const clang::ASTRecordLayout &record_layout =
5862 const clang::CXXRecordDecl *base_class_decl =
5863 llvm::cast<clang::CXXRecordDecl>(
5864 base_class->getType()
5865 ->castAs<clang::RecordType>()
5867 if (base_class->isVirtual())
5869 record_layout.getVBaseClassOffset(base_class_decl)
5874 record_layout.getBaseClassOffset(base_class_decl)
5878 return GetType(base_class->getType());
5885 case clang::Type::ObjCObjectPointer:
5888 case clang::Type::ObjCObject:
5890 const clang::ObjCObjectType *objc_class_type =
5891 qual_type->getAsObjCQualifiedInterfaceType();
5892 if (objc_class_type) {
5893 clang::ObjCInterfaceDecl *class_interface_decl =
5894 objc_class_type->getInterface();
5896 if (class_interface_decl) {
5897 clang::ObjCInterfaceDecl *superclass_interface_decl =
5898 class_interface_decl->getSuperClass();
5899 if (superclass_interface_decl) {
5901 *bit_offset_ptr = 0;
5903 superclass_interface_decl));
5909 case clang::Type::ObjCInterface:
5911 const clang::ObjCObjectType *objc_interface_type =
5912 qual_type->getAs<clang::ObjCInterfaceType>();
5913 if (objc_interface_type) {
5914 clang::ObjCInterfaceDecl *class_interface_decl =
5915 objc_interface_type->getInterface();
5917 if (class_interface_decl) {
5918 clang::ObjCInterfaceDecl *superclass_interface_decl =
5919 class_interface_decl->getSuperClass();
5920 if (superclass_interface_decl) {
5922 *bit_offset_ptr = 0;
5924 superclass_interface_decl));
5940 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5941 switch (type_class) {
5942 case clang::Type::Record:
5944 const clang::CXXRecordDecl *cxx_record_decl =
5945 qual_type->getAsCXXRecordDecl();
5946 if (cxx_record_decl) {
5947 uint32_t curr_idx = 0;
5948 clang::CXXRecordDecl::base_class_const_iterator base_class,
5950 for (base_class = cxx_record_decl->vbases_begin(),
5951 base_class_end = cxx_record_decl->vbases_end();
5952 base_class != base_class_end; ++base_class, ++curr_idx) {
5953 if (curr_idx == idx) {
5954 if (bit_offset_ptr) {
5955 const clang::ASTRecordLayout &record_layout =
5957 const clang::CXXRecordDecl *base_class_decl =
5958 llvm::cast<clang::CXXRecordDecl>(
5959 base_class->getType()
5960 ->castAs<clang::RecordType>()
5963 record_layout.getVBaseClassOffset(base_class_decl)
5967 return GetType(base_class->getType());
5982 llvm::StringRef name) {
5984 switch (qual_type->getTypeClass()) {
5985 case clang::Type::Record: {
5989 const clang::RecordType *record_type =
5990 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5991 const clang::RecordDecl *record_decl =
5992 record_type->getDecl()->getDefinitionOrSelf();
5994 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
5995 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
5996 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
5997 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
6021 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6022 switch (type_class) {
6023 case clang::Type::Builtin:
6024 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6025 case clang::BuiltinType::UnknownAny:
6026 case clang::BuiltinType::Void:
6027 case clang::BuiltinType::NullPtr:
6028 case clang::BuiltinType::OCLEvent:
6029 case clang::BuiltinType::OCLImage1dRO:
6030 case clang::BuiltinType::OCLImage1dWO:
6031 case clang::BuiltinType::OCLImage1dRW:
6032 case clang::BuiltinType::OCLImage1dArrayRO:
6033 case clang::BuiltinType::OCLImage1dArrayWO:
6034 case clang::BuiltinType::OCLImage1dArrayRW:
6035 case clang::BuiltinType::OCLImage1dBufferRO:
6036 case clang::BuiltinType::OCLImage1dBufferWO:
6037 case clang::BuiltinType::OCLImage1dBufferRW:
6038 case clang::BuiltinType::OCLImage2dRO:
6039 case clang::BuiltinType::OCLImage2dWO:
6040 case clang::BuiltinType::OCLImage2dRW:
6041 case clang::BuiltinType::OCLImage2dArrayRO:
6042 case clang::BuiltinType::OCLImage2dArrayWO:
6043 case clang::BuiltinType::OCLImage2dArrayRW:
6044 case clang::BuiltinType::OCLImage3dRO:
6045 case clang::BuiltinType::OCLImage3dWO:
6046 case clang::BuiltinType::OCLImage3dRW:
6047 case clang::BuiltinType::OCLSampler:
6048 case clang::BuiltinType::HLSLResource:
6050 case clang::BuiltinType::Bool:
6051 case clang::BuiltinType::Char_U:
6052 case clang::BuiltinType::UChar:
6053 case clang::BuiltinType::WChar_U:
6054 case clang::BuiltinType::Char16:
6055 case clang::BuiltinType::Char32:
6056 case clang::BuiltinType::UShort:
6057 case clang::BuiltinType::UInt:
6058 case clang::BuiltinType::ULong:
6059 case clang::BuiltinType::ULongLong:
6060 case clang::BuiltinType::UInt128:
6061 case clang::BuiltinType::Char_S:
6062 case clang::BuiltinType::SChar:
6063 case clang::BuiltinType::WChar_S:
6064 case clang::BuiltinType::Short:
6065 case clang::BuiltinType::Int:
6066 case clang::BuiltinType::Long:
6067 case clang::BuiltinType::LongLong:
6068 case clang::BuiltinType::Int128:
6069 case clang::BuiltinType::Float:
6070 case clang::BuiltinType::Double:
6071 case clang::BuiltinType::LongDouble:
6072 case clang::BuiltinType::Float128:
6073 case clang::BuiltinType::Dependent:
6074 case clang::BuiltinType::Overload:
6075 case clang::BuiltinType::ObjCId:
6076 case clang::BuiltinType::ObjCClass:
6077 case clang::BuiltinType::ObjCSel:
6078 case clang::BuiltinType::BoundMember:
6079 case clang::BuiltinType::Half:
6080 case clang::BuiltinType::ARCUnbridgedCast:
6081 case clang::BuiltinType::PseudoObject:
6082 case clang::BuiltinType::BuiltinFn:
6083 case clang::BuiltinType::ArraySection:
6090 case clang::Type::Complex:
6092 case clang::Type::Pointer:
6094 case clang::Type::BlockPointer:
6097 case clang::Type::LValueReference:
6099 case clang::Type::RValueReference:
6101 case clang::Type::MemberPointer:
6103 case clang::Type::ConstantArray:
6105 case clang::Type::IncompleteArray:
6107 case clang::Type::VariableArray:
6109 case clang::Type::DependentSizedArray:
6111 case clang::Type::DependentSizedExtVector:
6113 case clang::Type::Vector:
6115 case clang::Type::ExtVector:
6117 case clang::Type::FunctionProto:
6119 case clang::Type::FunctionNoProto:
6121 case clang::Type::UnresolvedUsing:
6123 case clang::Type::Record:
6125 case clang::Type::Enum:
6127 case clang::Type::TemplateTypeParm:
6129 case clang::Type::SubstTemplateTypeParm:
6131 case clang::Type::TemplateSpecialization:
6133 case clang::Type::InjectedClassName:
6135 case clang::Type::DependentName:
6137 case clang::Type::ObjCObject:
6139 case clang::Type::ObjCInterface:
6141 case clang::Type::ObjCObjectPointer:
6151 std::string &deref_name, uint32_t &deref_byte_size,
6152 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6156 return llvm::createStringError(
"not a pointer, reference or array type");
6157 uint32_t child_bitfield_bit_size = 0;
6158 uint32_t child_bitfield_bit_offset = 0;
6159 bool child_is_base_class;
6160 bool child_is_deref_of_parent;
6162 type, exe_ctx, 0,
false,
true,
false, deref_name, deref_byte_size,
6163 deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6164 child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
6169 bool transparent_pointers,
bool omit_empty_base_classes,
6170 bool ignore_array_bounds, std::string &child_name,
6171 uint32_t &child_byte_size, int32_t &child_byte_offset,
6172 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6173 bool &child_is_base_class,
bool &child_is_deref_of_parent,
6176 return llvm::createStringError(
"invalid type");
6178 auto get_exe_scope = [&exe_ctx]() {
6182 clang::QualType parent_qual_type(
6184 const clang::Type::TypeClass parent_type_class =
6185 parent_qual_type->getTypeClass();
6186 child_bitfield_bit_size = 0;
6187 child_bitfield_bit_offset = 0;
6188 child_is_base_class =
false;
6191 auto num_children_or_err =
6193 if (!num_children_or_err)
6194 return num_children_or_err.takeError();
6196 const bool idx_is_valid = idx < *num_children_or_err;
6198 switch (parent_type_class) {
6199 case clang::Type::Builtin:
6201 return llvm::createStringError(
"invalid index");
6203 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6204 case clang::BuiltinType::ObjCId:
6205 case clang::BuiltinType::ObjCClass:
6216 case clang::Type::Record: {
6218 return llvm::createStringError(
"invalid index");
6220 return llvm::createStringError(
"cannot complete type");
6222 const clang::RecordType *record_type =
6223 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6224 const clang::RecordDecl *record_decl =
6225 record_type->getDecl()->getDefinitionOrSelf();
6226 const clang::ASTRecordLayout &record_layout =
6228 uint32_t child_idx = 0;
6230 const clang::CXXRecordDecl *cxx_record_decl =
6231 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6232 if (cxx_record_decl) {
6234 clang::CXXRecordDecl::base_class_const_iterator base_class,
6236 for (base_class = cxx_record_decl->bases_begin(),
6237 base_class_end = cxx_record_decl->bases_end();
6238 base_class != base_class_end; ++base_class) {
6239 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6242 if (omit_empty_base_classes) {
6244 llvm::cast<clang::CXXRecordDecl>(
6245 base_class->getType()->getAs<clang::RecordType>()->getDecl())
6246 ->getDefinitionOrSelf();
6251 if (idx == child_idx) {
6252 if (base_class_decl ==
nullptr)
6253 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6254 base_class->getType()
6255 ->getAs<clang::RecordType>()
6257 ->getDefinitionOrSelf();
6259 if (base_class->isVirtual()) {
6260 bool handled =
false;
6262 clang::VTableContextBase *vtable_ctx =
6266 cxx_record_decl, base_class_decl,
6270 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6274 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6279 child_byte_offset = bit_offset / 8;
6282 auto size_or_err = base_class_clang_type.
GetBitSize(get_exe_scope());
6284 return llvm::joinErrors(
6285 llvm::createStringError(
"no size info for base class"),
6286 size_or_err.takeError());
6288 uint64_t base_class_clang_type_bit_size = *size_or_err;
6291 assert(base_class_clang_type_bit_size % 8 == 0);
6292 child_byte_size = base_class_clang_type_bit_size / 8;
6293 child_is_base_class =
true;
6294 return base_class_clang_type;
6302 uint32_t field_idx = 0;
6303 clang::RecordDecl::field_iterator field, field_end;
6304 for (field = record_decl->field_begin(),
6305 field_end = record_decl->field_end();
6306 field != field_end; ++field, ++field_idx, ++child_idx) {
6307 if (idx == child_idx) {
6310 child_name.assign(field->getNameAsString());
6315 assert(field_idx < record_layout.getFieldCount());
6316 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6318 return llvm::joinErrors(
6319 llvm::createStringError(
"no size info for field"),
6320 size_or_err.takeError());
6322 child_byte_size = *size_or_err;
6323 const uint32_t child_bit_size = child_byte_size * 8;
6327 bit_offset = record_layout.getFieldOffset(field_idx);
6329 child_bitfield_bit_offset = bit_offset % child_bit_size;
6330 const uint32_t child_bit_offset =
6331 bit_offset - child_bitfield_bit_offset;
6332 child_byte_offset = child_bit_offset / 8;
6334 child_byte_offset = bit_offset / 8;
6337 return field_clang_type;
6341 case clang::Type::ObjCObject:
6342 case clang::Type::ObjCInterface: {
6344 return llvm::createStringError(
"invalid index");
6346 return llvm::createStringError(
"cannot complete type");
6348 const clang::ObjCObjectType *objc_class_type =
6349 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6350 assert(objc_class_type);
6351 if (!objc_class_type)
6352 return llvm::createStringError(
"unexpected object type");
6354 uint32_t child_idx = 0;
6355 clang::ObjCInterfaceDecl *class_interface_decl =
6356 objc_class_type->getInterface();
6358 if (!class_interface_decl)
6359 return llvm::createStringError(
"cannot get interface decl");
6361 const clang::ASTRecordLayout &interface_layout =
6362 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6363 clang::ObjCInterfaceDecl *superclass_interface_decl =
6364 class_interface_decl->getSuperClass();
6365 if (superclass_interface_decl) {
6366 if (omit_empty_base_classes) {
6368 getASTContext().getObjCInterfaceType(superclass_interface_decl));
6369 if (llvm::expectedToOptional(base_class_clang_type.
GetNumChildren(
6370 omit_empty_base_classes, exe_ctx))
6373 clang::QualType ivar_qual_type(
getASTContext().getObjCInterfaceType(
6374 superclass_interface_decl));
6376 child_name.assign(superclass_interface_decl->getNameAsString());
6378 clang::TypeInfo ivar_type_info =
6381 child_byte_size = ivar_type_info.Width / 8;
6382 child_byte_offset = 0;
6383 child_is_base_class =
true;
6385 return GetType(ivar_qual_type);
6394 const uint32_t superclass_idx = child_idx;
6396 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6397 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6398 ivar_end = class_interface_decl->ivar_end();
6400 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
6402 if (child_idx == idx) {
6403 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6405 clang::QualType ivar_qual_type(ivar_decl->getType());
6407 child_name.assign(ivar_decl->getNameAsString());
6409 clang::TypeInfo ivar_type_info =
6412 child_byte_size = ivar_type_info.Width / 8;
6428 if (objc_runtime !=
nullptr) {
6431 parent_ast_type, ivar_decl->getNameAsString().c_str());
6439 if (child_byte_offset ==
6442 interface_layout.getFieldOffset(child_idx - superclass_idx);
6443 child_byte_offset = bit_offset / 8;
6455 interface_layout.getFieldOffset(child_idx - superclass_idx);
6457 child_bitfield_bit_offset = bit_offset % 8;
6459 return GetType(ivar_qual_type);
6466 case clang::Type::ObjCObjectPointer: {
6468 return llvm::createStringError(
"invalid index");
6472 child_is_deref_of_parent =
false;
6473 bool tmp_child_is_deref_of_parent =
false;
6475 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6476 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6477 child_bitfield_bit_size, child_bitfield_bit_offset,
6478 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6481 child_is_deref_of_parent =
true;
6482 const char *parent_name =
6485 child_name.assign(1,
'*');
6486 child_name += parent_name;
6491 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6493 return size_or_err.takeError();
6494 child_byte_size = *size_or_err;
6495 child_byte_offset = 0;
6496 return pointee_clang_type;
6501 case clang::Type::Vector:
6502 case clang::Type::ExtVector: {
6504 return llvm::createStringError(
"invalid index");
6505 const clang::VectorType *array =
6506 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6508 return llvm::createStringError(
"unexpected vector type");
6512 return llvm::createStringError(
"cannot complete type");
6514 char element_name[64];
6515 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6516 static_cast<uint64_t
>(idx));
6517 child_name.assign(element_name);
6518 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6520 return size_or_err.takeError();
6521 child_byte_size = *size_or_err;
6522 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6523 return element_type;
6525 case clang::Type::ConstantArray:
6526 case clang::Type::IncompleteArray: {
6527 if (!ignore_array_bounds && !idx_is_valid)
6528 return llvm::createStringError(
"invalid index");
6529 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6531 return llvm::createStringError(
"unexpected array type");
6534 return llvm::createStringError(
"cannot complete type");
6536 child_name = std::string(llvm::formatv(
"[{0}]", idx));
6537 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6539 return size_or_err.takeError();
6540 child_byte_size = *size_or_err;
6541 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6542 return element_type;
6544 case clang::Type::Pointer: {
6549 return llvm::createStringError(
"cannot dereference void *");
6552 child_is_deref_of_parent =
false;
6553 bool tmp_child_is_deref_of_parent =
false;
6555 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6556 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6557 child_bitfield_bit_size, child_bitfield_bit_offset,
6558 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6561 child_is_deref_of_parent =
true;
6565 child_name.assign(1,
'*');
6566 child_name += parent_name;
6571 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6573 return size_or_err.takeError();
6574 child_byte_size = *size_or_err;
6575 child_byte_offset = 0;
6576 return pointee_clang_type;
6581 case clang::Type::LValueReference:
6582 case clang::Type::RValueReference: {
6584 return llvm::createStringError(
"invalid index");
6585 const clang::ReferenceType *reference_type =
6586 llvm::cast<clang::ReferenceType>(
6590 child_is_deref_of_parent =
false;
6591 bool tmp_child_is_deref_of_parent =
false;
6593 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6594 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6595 child_bitfield_bit_size, child_bitfield_bit_offset,
6596 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6601 child_name.assign(1,
'&');
6602 child_name += parent_name;
6607 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6609 return size_or_err.takeError();
6610 child_byte_size = *size_or_err;
6611 child_byte_offset = 0;
6612 return pointee_clang_type;
6619 return llvm::createStringError(
"cannot enumerate children");
6623 const clang::RecordDecl *record_decl,
6624 const clang::CXXBaseSpecifier *base_spec,
6625 bool omit_empty_base_classes) {
6626 uint32_t child_idx = 0;
6628 const clang::CXXRecordDecl *cxx_record_decl =
6629 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6631 if (cxx_record_decl) {
6632 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6633 for (base_class = cxx_record_decl->bases_begin(),
6634 base_class_end = cxx_record_decl->bases_end();
6635 base_class != base_class_end; ++base_class) {
6636 if (omit_empty_base_classes) {
6641 if (base_class == base_spec)
6651 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6652 bool omit_empty_base_classes) {
6654 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6655 omit_empty_base_classes);
6657 clang::RecordDecl::field_iterator field, field_end;
6658 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6659 field != field_end; ++field, ++child_idx) {
6660 if (field->getCanonicalDecl() == canonical_decl)
6702 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6703 if (type && !name.empty()) {
6705 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6706 switch (type_class) {
6707 case clang::Type::Record:
6709 const clang::RecordType *record_type =
6710 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6711 const clang::RecordDecl *record_decl =
6712 record_type->getDecl()->getDefinitionOrSelf();
6714 assert(record_decl);
6715 uint32_t child_idx = 0;
6717 const clang::CXXRecordDecl *cxx_record_decl =
6718 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6721 clang::RecordDecl::field_iterator field, field_end;
6722 for (field = record_decl->field_begin(),
6723 field_end = record_decl->field_end();
6724 field != field_end; ++field, ++child_idx) {
6725 llvm::StringRef field_name = field->getName();
6726 if (field_name.empty()) {
6728 std::vector<uint32_t> save_indices = child_indexes;
6729 child_indexes.push_back(
6731 cxx_record_decl, omit_empty_base_classes));
6733 name, omit_empty_base_classes, child_indexes))
6734 return child_indexes.size();
6735 child_indexes = std::move(save_indices);
6736 }
else if (field_name == name) {
6738 child_indexes.push_back(
6740 cxx_record_decl, omit_empty_base_classes));
6741 return child_indexes.size();
6745 if (cxx_record_decl) {
6746 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6749 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6750 clang::DeclarationName decl_name(&ident_ref);
6752 clang::CXXBasePaths paths;
6753 if (cxx_record_decl->lookupInBases(
6754 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6755 clang::CXXBasePath &path) {
6756 CXXRecordDecl *record =
6757 specifier->getType()->getAsCXXRecordDecl();
6758 auto r = record->lookup(decl_name);
6759 path.Decls = r.begin();
6763 clang::CXXBasePaths::const_paths_iterator path,
6764 path_end = paths.end();
6765 for (path = paths.begin(); path != path_end; ++path) {
6766 const size_t num_path_elements = path->size();
6767 for (
size_t e = 0; e < num_path_elements; ++e) {
6768 clang::CXXBasePathElement elem = (*path)[e];
6771 omit_empty_base_classes);
6773 child_indexes.clear();
6776 child_indexes.push_back(child_idx);
6777 parent_record_decl = elem.Base->getType()
6778 ->castAs<clang::RecordType>()
6780 ->getDefinitionOrSelf();
6783 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6786 parent_record_decl, *I, omit_empty_base_classes);
6788 child_indexes.clear();
6791 child_indexes.push_back(child_idx);
6795 return child_indexes.size();
6801 case clang::Type::ObjCObject:
6802 case clang::Type::ObjCInterface:
6804 llvm::StringRef name_sref(name);
6805 const clang::ObjCObjectType *objc_class_type =
6806 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6807 assert(objc_class_type);
6808 if (objc_class_type) {
6809 uint32_t child_idx = 0;
6810 clang::ObjCInterfaceDecl *class_interface_decl =
6811 objc_class_type->getInterface();
6813 if (class_interface_decl) {
6814 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6815 ivar_end = class_interface_decl->ivar_end();
6816 clang::ObjCInterfaceDecl *superclass_interface_decl =
6817 class_interface_decl->getSuperClass();
6819 for (ivar_pos = class_interface_decl->ivar_begin();
6820 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6821 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6823 if (ivar_decl->getName() == name_sref) {
6824 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6825 (omit_empty_base_classes &&
6829 child_indexes.push_back(child_idx);
6830 return child_indexes.size();
6834 if (superclass_interface_decl) {
6838 child_indexes.push_back(0);
6842 superclass_interface_decl));
6844 name, omit_empty_base_classes, child_indexes)) {
6847 return child_indexes.size();
6852 child_indexes.pop_back();
6859 case clang::Type::ObjCObjectPointer: {
6861 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6862 ->getPointeeType());
6864 name, omit_empty_base_classes, child_indexes);
6867 case clang::Type::LValueReference:
6868 case clang::Type::RValueReference: {
6869 const clang::ReferenceType *reference_type =
6870 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
6871 clang::QualType pointee_type(reference_type->getPointeeType());
6876 name, omit_empty_base_classes, child_indexes);
6880 case clang::Type::Pointer: {
6885 name, omit_empty_base_classes, child_indexes);
6900llvm::Expected<uint32_t>
6902 llvm::StringRef name,
6903 bool omit_empty_base_classes) {
6904 if (type && !name.empty()) {
6907 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6909 switch (type_class) {
6910 case clang::Type::Record:
6912 const clang::RecordType *record_type =
6913 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6914 const clang::RecordDecl *record_decl =
6915 record_type->getDecl()->getDefinitionOrSelf();
6917 assert(record_decl);
6918 uint32_t child_idx = 0;
6920 const clang::CXXRecordDecl *cxx_record_decl =
6921 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6923 if (cxx_record_decl) {
6924 clang::CXXRecordDecl::base_class_const_iterator base_class,
6926 for (base_class = cxx_record_decl->bases_begin(),
6927 base_class_end = cxx_record_decl->bases_end();
6928 base_class != base_class_end; ++base_class) {
6930 clang::CXXRecordDecl *base_class_decl =
6931 llvm::cast<clang::CXXRecordDecl>(
6932 base_class->getType()
6933 ->castAs<clang::RecordType>()
6935 ->getDefinitionOrSelf();
6936 if (omit_empty_base_classes &&
6941 std::string base_class_type_name(
6943 if (base_class_type_name == name)
6950 clang::RecordDecl::field_iterator field, field_end;
6951 for (field = record_decl->field_begin(),
6952 field_end = record_decl->field_end();
6953 field != field_end; ++field, ++child_idx) {
6954 if (field->getName() == name)
6960 case clang::Type::ObjCObject:
6961 case clang::Type::ObjCInterface:
6963 const clang::ObjCObjectType *objc_class_type =
6964 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6965 assert(objc_class_type);
6966 if (objc_class_type) {
6967 uint32_t child_idx = 0;
6968 clang::ObjCInterfaceDecl *class_interface_decl =
6969 objc_class_type->getInterface();
6971 if (class_interface_decl) {
6972 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6973 ivar_end = class_interface_decl->ivar_end();
6974 clang::ObjCInterfaceDecl *superclass_interface_decl =
6975 class_interface_decl->getSuperClass();
6977 for (ivar_pos = class_interface_decl->ivar_begin();
6978 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6979 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6981 if (ivar_decl->getName() == name) {
6982 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6983 (omit_empty_base_classes &&
6991 if (superclass_interface_decl) {
6992 if (superclass_interface_decl->getName() == name)
7000 case clang::Type::ObjCObjectPointer: {
7002 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7003 ->getPointeeType());
7005 name, omit_empty_base_classes);
7008 case clang::Type::LValueReference:
7009 case clang::Type::RValueReference: {
7010 const clang::ReferenceType *reference_type =
7011 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7016 omit_empty_base_classes);
7020 case clang::Type::Pointer: {
7021 const clang::PointerType *pointer_type =
7022 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7027 omit_empty_base_classes);
7035 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
7040 llvm::StringRef name) {
7041 if (!type || name.empty())
7045 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7047 switch (type_class) {
7048 case clang::Type::Record: {
7051 const clang::RecordType *record_type =
7052 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7053 const clang::RecordDecl *record_decl =
7054 record_type->getDecl()->getDefinitionOrSelf();
7056 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7057 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7058 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7060 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7062 ElaboratedTypeKeyword::None, std::nullopt,
7078 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7079 return isa<clang::ClassTemplateSpecializationDecl>(
7080 cxx_record_decl->getDecl());
7091 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7092 switch (type_class) {
7093 case clang::Type::Record:
7095 const clang::CXXRecordDecl *cxx_record_decl =
7096 qual_type->getAsCXXRecordDecl();
7097 if (cxx_record_decl) {
7098 const clang::ClassTemplateSpecializationDecl *template_decl =
7099 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7101 if (template_decl) {
7102 const auto &template_arg_list = template_decl->getTemplateArgs();
7103 size_t num_args = template_arg_list.size();
7104 assert(num_args &&
"template specialization without any args");
7105 if (expand_pack && num_args) {
7106 const auto &pack = template_arg_list[num_args - 1];
7107 if (pack.getKind() == clang::TemplateArgument::Pack)
7108 num_args += pack.pack_size() - 1;
7123const clang::ClassTemplateSpecializationDecl *
7130 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7131 switch (type_class) {
7132 case clang::Type::Record: {
7135 const clang::CXXRecordDecl *cxx_record_decl =
7136 qual_type->getAsCXXRecordDecl();
7137 if (!cxx_record_decl)
7139 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7148const TemplateArgument *
7150 size_t idx,
bool expand_pack) {
7151 const auto &args = decl->getTemplateArgs();
7152 const size_t args_size = args.size();
7154 assert(args_size &&
"template specialization without any args");
7158 const size_t last_idx = args_size - 1;
7167 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7168 return idx >= args.size() ? nullptr : &args[idx];
7173 const auto &pack = args[last_idx];
7174 const size_t pack_idx = idx - last_idx;
7175 if (pack_idx >= pack.pack_size())
7177 return &pack.pack_elements()[pack_idx];
7182 size_t arg_idx,
bool expand_pack) {
7183 const clang::ClassTemplateSpecializationDecl *template_decl =
7192 switch (arg->getKind()) {
7193 case clang::TemplateArgument::Null:
7196 case clang::TemplateArgument::NullPtr:
7199 case clang::TemplateArgument::Type:
7202 case clang::TemplateArgument::Declaration:
7205 case clang::TemplateArgument::Integral:
7208 case clang::TemplateArgument::Template:
7211 case clang::TemplateArgument::TemplateExpansion:
7214 case clang::TemplateArgument::Expression:
7217 case clang::TemplateArgument::Pack:
7220 case clang::TemplateArgument::StructuralValue:
7223 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7228 size_t idx,
bool expand_pack) {
7229 const clang::ClassTemplateSpecializationDecl *template_decl =
7235 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7238 return GetType(arg->getAsType());
7241std::optional<CompilerType::IntegralTemplateArgument>
7243 size_t idx,
bool expand_pack) {
7244 const clang::ClassTemplateSpecializationDecl *template_decl =
7247 return std::nullopt;
7251 return std::nullopt;
7253 switch (arg->getKind()) {
7254 case clang::TemplateArgument::Integral:
7255 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7256 case clang::TemplateArgument::StructuralValue: {
7257 clang::APValue value = arg->getAsStructuralValue();
7260 if (value.isFloat())
7261 return {{value.getFloat(), type}};
7264 return {{value.getInt(), type}};
7266 return std::nullopt;
7269 return std::nullopt;
7294 const clang::EnumType *enutype =
7297 return enutype->getDecl()->getDefinitionOrSelf();
7302 const clang::RecordType *record_type =
7305 return record_type->getDecl()->getDefinitionOrSelf();
7313clang::TypedefNameDecl *
7315 const clang::TypedefType *typedef_type =
7318 return typedef_type->getDecl();
7322clang::CXXRecordDecl *
7327clang::ObjCInterfaceDecl *
7329 const clang::ObjCObjectType *objc_class_type =
7330 llvm::dyn_cast<clang::ObjCObjectType>(
7332 if (objc_class_type)
7333 return objc_class_type->getInterface();
7339 const CompilerType &field_clang_type, uint32_t bitfield_bit_size) {
7345 clang::ASTContext &clang_ast = ast->getASTContext();
7346 clang::IdentifierInfo *ident =
nullptr;
7348 ident = &clang_ast.Idents.get(name);
7350 clang::FieldDecl *field =
nullptr;
7352 clang::Expr *bit_width =
nullptr;
7353 if (bitfield_bit_size != 0) {
7354 if (clang_ast.IntTy.isNull()) {
7356 "builtin ASTContext types have not been initialized");
7360 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7362 bit_width =
new (clang_ast)
7363 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7364 clang_ast.IntTy, clang::SourceLocation());
7365 bit_width = clang::ConstantExpr::Create(
7366 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7369 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7371 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7372 field->setDeclContext(record_decl);
7373 field->setDeclName(ident);
7376 field->setBitWidth(bit_width);
7382 if (
const clang::TagType *TagT =
7383 field->getType()->getAs<clang::TagType>()) {
7384 if (clang::RecordDecl *Rec =
7385 llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
7386 if (!Rec->getDeclName()) {
7387 Rec->setAnonymousStructOrUnion(
true);
7388 field->setImplicit();
7394 field->setAccess(AS_public);
7396 record_decl->addDecl(field);
7401 clang::ObjCInterfaceDecl *class_interface_decl =
7402 ast->GetAsObjCInterfaceDecl(type);
7404 if (class_interface_decl) {
7405 const bool is_synthesized =
false;
7410 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7411 ivar->setDeclContext(class_interface_decl);
7412 ivar->setDeclName(ident);
7414 ivar->setAccessControl(ObjCIvarDecl::AccessControl::Public);
7416 ivar->setBitWidth(bit_width);
7417 ivar->setSynthesize(is_synthesized);
7422 class_interface_decl->addDecl(field);
7439 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7444 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7446 IndirectFieldVector indirect_fields;
7447 clang::RecordDecl::field_iterator field_pos;
7448 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7449 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7450 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7451 last_field_pos = field_pos++) {
7452 if (field_pos->isAnonymousStructOrUnion()) {
7453 clang::QualType field_qual_type = field_pos->getType();
7455 const clang::RecordType *field_record_type =
7456 field_qual_type->getAs<clang::RecordType>();
7458 if (!field_record_type)
7461 clang::RecordDecl *field_record_decl =
7462 field_record_type->getDecl()->getDefinition();
7464 if (!field_record_decl)
7467 for (clang::RecordDecl::decl_iterator
7468 di = field_record_decl->decls_begin(),
7469 de = field_record_decl->decls_end();
7471 if (clang::FieldDecl *nested_field_decl =
7472 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7473 clang::NamedDecl **chain =
7474 new (ast->getASTContext()) clang::NamedDecl *[2];
7475 chain[0] = *field_pos;
7476 chain[1] = nested_field_decl;
7477 clang::IndirectFieldDecl *indirect_field =
7478 clang::IndirectFieldDecl::Create(
7479 ast->getASTContext(), record_decl, clang::SourceLocation(),
7480 nested_field_decl->getIdentifier(),
7481 nested_field_decl->getType(), {chain, 2});
7484 indirect_field->setImplicit();
7486 indirect_field->setAccess(AS_public);
7488 indirect_fields.push_back(indirect_field);
7489 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7490 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7491 size_t nested_chain_size =
7492 nested_indirect_field_decl->getChainingSize();
7493 clang::NamedDecl **chain =
new (ast->getASTContext())
7494 clang::NamedDecl *[nested_chain_size + 1];
7495 chain[0] = *field_pos;
7497 int chain_index = 1;
7498 for (clang::IndirectFieldDecl::chain_iterator
7499 nci = nested_indirect_field_decl->chain_begin(),
7500 nce = nested_indirect_field_decl->chain_end();
7502 chain[chain_index] = *nci;
7506 clang::IndirectFieldDecl *indirect_field =
7507 clang::IndirectFieldDecl::Create(
7508 ast->getASTContext(), record_decl, clang::SourceLocation(),
7509 nested_indirect_field_decl->getIdentifier(),
7510 nested_indirect_field_decl->getType(),
7511 {chain, nested_chain_size + 1});
7514 indirect_field->setImplicit();
7516 indirect_field->setAccess(AS_public);
7518 indirect_fields.push_back(indirect_field);
7526 if (last_field_pos != field_end_pos) {
7527 if (last_field_pos->getType()->isIncompleteArrayType())
7528 record_decl->hasFlexibleArrayMember();
7531 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7532 ife = indirect_fields.end();
7534 record_decl->addDecl(*ifi);
7547 record_decl->addAttr(
7548 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7555 llvm::StringRef name,
7564 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7568 clang::VarDecl *var_decl =
nullptr;
7569 clang::IdentifierInfo *ident =
nullptr;
7571 ident = &ast->getASTContext().Idents.get(name);
7574 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7575 var_decl->setDeclContext(record_decl);
7576 var_decl->setDeclName(ident);
7578 var_decl->setStorageClass(clang::SC_Static);
7583 var_decl->setAccess(AS_public);
7584 record_decl->addDecl(var_decl);
7586 VerifyDecl(var_decl);
7592 VarDecl *var,
const llvm::APInt &init_value) {
7593 assert(!var->hasInit() &&
"variable already initialized");
7595 clang::ASTContext &ast = var->getASTContext();
7596 QualType qt = var->getType();
7597 assert(qt->isIntegralOrEnumerationType() &&
7598 "only integer or enum types supported");
7601 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7602 const EnumDecl *enum_decl = enum_type->getDecl()->getDefinitionOrSelf();
7603 qt = enum_decl->getIntegerType();
7607 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7608 var->setInit(CXXBoolLiteralExpr::Create(
7609 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7611 var->setInit(IntegerLiteral::Create(
7612 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7617 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7618 assert(!var->hasInit() &&
"variable already initialized");
7620 clang::ASTContext &ast = var->getASTContext();
7621 QualType qt = var->getType();
7622 assert(qt->isFloatingType() &&
"only floating point types supported");
7623 var->setInit(FloatingLiteral::Create(
7624 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7627llvm::SmallVector<clang::ParmVarDecl *>
7629 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7630 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7632 assert(parameter_names.empty() ||
7633 parameter_names.size() == prototype.getNumParams());
7635 llvm::SmallVector<clang::ParmVarDecl *> params;
7636 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7638 llvm::StringRef name =
7639 !parameter_names.empty() ? parameter_names[param_index] :
"";
7643 GetType(prototype.getParamType(param_index)),
7644 clang::SC_None,
false);
7647 params.push_back(param);
7655 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7656 bool is_virtual,
bool is_static,
bool is_inline,
bool is_explicit,
7657 bool is_attr_used,
bool is_artificial) {
7658 if (!type || !method_clang_type.
IsValid() || name.empty())
7663 clang::CXXRecordDecl *cxx_record_decl =
7664 record_qual_type->getAsCXXRecordDecl();
7666 if (cxx_record_decl ==
nullptr)
7671 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7673 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7675 const clang::FunctionType *function_type =
7676 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7678 if (function_type ==
nullptr)
7681 const clang::FunctionProtoType *method_function_prototype(
7682 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7684 if (!method_function_prototype)
7687 unsigned int num_params = method_function_prototype->getNumParams();
7689 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7690 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7695 const clang::ExplicitSpecifier explicit_spec(
7696 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7697 : clang::ExplicitSpecKind::ResolvedFalse);
7699 if (name.starts_with(
"~")) {
7700 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7702 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7703 cxx_dtor_decl->setDeclName(
7706 cxx_dtor_decl->setType(method_qual_type);
7707 cxx_dtor_decl->setImplicit(is_artificial);
7708 cxx_dtor_decl->setInlineSpecified(is_inline);
7709 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7710 cxx_method_decl = cxx_dtor_decl;
7711 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7712 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7714 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7715 cxx_ctor_decl->setDeclName(
7718 cxx_ctor_decl->setType(method_qual_type);
7719 cxx_ctor_decl->setImplicit(is_artificial);
7720 cxx_ctor_decl->setInlineSpecified(is_inline);
7721 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7722 cxx_ctor_decl->setNumCtorInitializers(0);
7723 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7724 cxx_method_decl = cxx_ctor_decl;
7726 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7727 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7730 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7735 const bool is_method =
true;
7737 is_method, op_kind, num_params))
7739 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7741 cxx_method_decl->setDeclContext(cxx_record_decl);
7742 cxx_method_decl->setDeclName(
7743 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7744 cxx_method_decl->setType(method_qual_type);
7745 cxx_method_decl->setStorageClass(SC);
7746 cxx_method_decl->setInlineSpecified(is_inline);
7747 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7748 }
else if (num_params == 0) {
7750 auto *cxx_conversion_decl =
7751 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7753 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7754 cxx_conversion_decl->setDeclName(
7755 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7757 function_type->getReturnType())));
7758 cxx_conversion_decl->setType(method_qual_type);
7759 cxx_conversion_decl->setInlineSpecified(is_inline);
7760 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7761 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7762 cxx_method_decl = cxx_conversion_decl;
7766 if (cxx_method_decl ==
nullptr) {
7767 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7769 cxx_method_decl->setDeclContext(cxx_record_decl);
7770 cxx_method_decl->setDeclName(decl_name);
7771 cxx_method_decl->setType(method_qual_type);
7772 cxx_method_decl->setInlineSpecified(is_inline);
7773 cxx_method_decl->setStorageClass(SC);
7774 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7779 cxx_method_decl->setAccess(AS_public);
7780 cxx_method_decl->setVirtualAsWritten(is_virtual);
7783 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7785 if (!asm_label.empty())
7786 cxx_method_decl->addAttr(
7787 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7792 cxx_method_decl, *method_function_prototype, {}));
7794 cxx_record_decl->addDecl(cxx_method_decl);
7803 if (is_artificial) {
7804 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7805 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7806 (cxx_ctor_decl->isCopyConstructor() &&
7807 cxx_record_decl->hasTrivialCopyConstructor()) ||
7808 (cxx_ctor_decl->isMoveConstructor() &&
7809 cxx_record_decl->hasTrivialMoveConstructor()))) {
7810 cxx_ctor_decl->setDefaulted();
7811 cxx_ctor_decl->setTrivial(
true);
7812 }
else if (cxx_dtor_decl) {
7813 if (cxx_record_decl->hasTrivialDestructor()) {
7814 cxx_dtor_decl->setDefaulted();
7815 cxx_dtor_decl->setTrivial(
true);
7817 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7818 cxx_record_decl->hasTrivialCopyAssignment()) ||
7819 (cxx_method_decl->isMoveAssignmentOperator() &&
7820 cxx_record_decl->hasTrivialMoveAssignment())) {
7821 cxx_method_decl->setDefaulted();
7822 cxx_method_decl->setTrivial(
true);
7826 VerifyDecl(cxx_method_decl);
7828 return cxx_method_decl;
7834 for (
auto *method : record->methods())
7835 addOverridesForMethod(method);
7838#pragma mark C++ Base Classes
7840std::unique_ptr<clang::CXXBaseSpecifier>
7843 bool base_of_class) {
7847 return std::make_unique<clang::CXXBaseSpecifier>(
7848 clang::SourceRange(), is_virtual, base_of_class,
7851 clang::SourceLocation());
7856 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
7860 if (!cxx_record_decl)
7862 std::vector<clang::CXXBaseSpecifier *> raw_bases;
7863 raw_bases.reserve(bases.size());
7867 for (
auto &b : bases)
7868 raw_bases.push_back(b.get());
7869 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
7878 clang::ASTContext &clang_ast = ast->getASTContext();
7880 if (type && superclass_clang_type.
IsValid() &&
7882 clang::ObjCInterfaceDecl *class_interface_decl =
7884 clang::ObjCInterfaceDecl *super_interface_decl =
7886 if (class_interface_decl && super_interface_decl) {
7887 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
7888 clang_ast.getObjCInterfaceType(super_interface_decl)));
7897 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
7898 const char *property_setter_name,
const char *property_getter_name,
7900 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
7901 property_name[0] ==
'\0')
7906 clang::ASTContext &clang_ast = ast->getASTContext();
7909 if (!class_interface_decl)
7914 if (property_clang_type.
IsValid())
7915 property_clang_type_to_access = property_clang_type;
7917 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
7919 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
7922 clang::TypeSourceInfo *prop_type_source;
7924 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
7926 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
7929 clang::ObjCPropertyDecl *property_decl =
7930 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7931 property_decl->setDeclContext(class_interface_decl);
7932 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
7933 property_decl->setType(ivar_decl
7934 ? ivar_decl->getType()
7942 ast->SetMetadata(property_decl, metadata);
7944 class_interface_decl->addDecl(property_decl);
7946 clang::Selector setter_sel, getter_sel;
7948 if (property_setter_name) {
7949 std::string property_setter_no_colon(property_setter_name,
7950 strlen(property_setter_name) - 1);
7951 const clang::IdentifierInfo *setter_ident =
7952 &clang_ast.Idents.get(property_setter_no_colon);
7953 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
7954 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
7955 std::string setter_sel_string(
"set");
7956 setter_sel_string.push_back(::toupper(property_name[0]));
7957 setter_sel_string.append(&property_name[1]);
7958 const clang::IdentifierInfo *setter_ident =
7959 &clang_ast.Idents.get(setter_sel_string);
7960 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
7962 property_decl->setSetterName(setter_sel);
7963 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
7965 if (property_getter_name !=
nullptr) {
7966 const clang::IdentifierInfo *getter_ident =
7967 &clang_ast.Idents.get(property_getter_name);
7968 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
7970 const clang::IdentifierInfo *getter_ident =
7971 &clang_ast.Idents.get(property_name);
7972 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
7974 property_decl->setGetterName(getter_sel);
7975 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
7978 property_decl->setPropertyIvarDecl(ivar_decl);
7980 if (property_attributes & DW_APPLE_PROPERTY_readonly)
7981 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
7982 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
7983 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
7984 if (property_attributes & DW_APPLE_PROPERTY_assign)
7985 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
7986 if (property_attributes & DW_APPLE_PROPERTY_retain)
7987 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
7988 if (property_attributes & DW_APPLE_PROPERTY_copy)
7989 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
7990 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
7991 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
7992 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
7993 property_decl->setPropertyAttributes(
7994 ObjCPropertyAttribute::kind_nullability);
7995 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
7996 property_decl->setPropertyAttributes(
7997 ObjCPropertyAttribute::kind_null_resettable);
7998 if (property_attributes & ObjCPropertyAttribute::kind_class)
7999 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8001 const bool isInstance =
8002 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8004 clang::ObjCMethodDecl *getter =
nullptr;
8005 if (!getter_sel.isNull())
8006 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8007 : class_interface_decl->lookupClassMethod(getter_sel);
8008 if (!getter_sel.isNull() && !getter) {
8009 const bool isVariadic =
false;
8010 const bool isPropertyAccessor =
true;
8011 const bool isSynthesizedAccessorStub =
false;
8012 const bool isImplicitlyDeclared =
true;
8013 const bool isDefined =
false;
8014 const clang::ObjCImplementationControl impControl =
8015 clang::ObjCImplementationControl::None;
8016 const bool HasRelatedResultType =
false;
8019 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8020 getter->setDeclName(getter_sel);
8022 getter->setDeclContext(class_interface_decl);
8023 getter->setInstanceMethod(isInstance);
8024 getter->setVariadic(isVariadic);
8025 getter->setPropertyAccessor(isPropertyAccessor);
8026 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8027 getter->setImplicit(isImplicitlyDeclared);
8028 getter->setDefined(isDefined);
8029 getter->setDeclImplementation(impControl);
8030 getter->setRelatedResultType(HasRelatedResultType);
8034 ast->SetMetadata(getter, metadata);
8036 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8037 llvm::ArrayRef<clang::SourceLocation>());
8038 class_interface_decl->addDecl(getter);
8042 getter->setPropertyAccessor(
true);
8043 property_decl->setGetterMethodDecl(getter);
8046 clang::ObjCMethodDecl *setter =
nullptr;
8047 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8048 : class_interface_decl->lookupClassMethod(setter_sel);
8049 if (!setter_sel.isNull() && !setter) {
8050 clang::QualType result_type = clang_ast.VoidTy;
8051 const bool isVariadic =
false;
8052 const bool isPropertyAccessor =
true;
8053 const bool isSynthesizedAccessorStub =
false;
8054 const bool isImplicitlyDeclared =
true;
8055 const bool isDefined =
false;
8056 const clang::ObjCImplementationControl impControl =
8057 clang::ObjCImplementationControl::None;
8058 const bool HasRelatedResultType =
false;
8061 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8062 setter->setDeclName(setter_sel);
8063 setter->setReturnType(result_type);
8064 setter->setDeclContext(class_interface_decl);
8065 setter->setInstanceMethod(isInstance);
8066 setter->setVariadic(isVariadic);
8067 setter->setPropertyAccessor(isPropertyAccessor);
8068 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8069 setter->setImplicit(isImplicitlyDeclared);
8070 setter->setDefined(isDefined);
8071 setter->setDeclImplementation(impControl);
8072 setter->setRelatedResultType(HasRelatedResultType);
8076 ast->SetMetadata(setter, metadata);
8078 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8079 params.push_back(clang::ParmVarDecl::Create(
8080 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8083 clang::SC_Auto,
nullptr));
8085 setter->setMethodParams(clang_ast,
8086 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8087 llvm::ArrayRef<clang::SourceLocation>());
8089 class_interface_decl->addDecl(setter);
8093 setter->setPropertyAccessor(
true);
8094 property_decl->setSetterMethodDecl(setter);
8105 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8106 bool is_objc_direct_call) {
8107 if (!type || !method_clang_type.
IsValid())
8112 if (class_interface_decl ==
nullptr)
8115 if (lldb_ast ==
nullptr)
8117 clang::ASTContext &ast = lldb_ast->getASTContext();
8119 const char *selector_start = ::strchr(name,
' ');
8120 if (selector_start ==
nullptr)
8124 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8129 unsigned num_selectors_with_args = 0;
8130 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8132 len = ::strcspn(start,
":]");
8133 bool has_arg = (start[len] ==
':');
8135 ++num_selectors_with_args;
8136 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8141 if (selector_idents.size() == 0)
8144 clang::Selector method_selector = ast.Selectors.getSelector(
8145 num_selectors_with_args ? selector_idents.size() : 0,
8146 selector_idents.data());
8151 const clang::Type *method_type(method_qual_type.getTypePtr());
8153 if (method_type ==
nullptr)
8156 const clang::FunctionProtoType *method_function_prototype(
8157 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8159 if (!method_function_prototype)
8162 const bool isInstance = (name[0] ==
'-');
8163 const bool isVariadic = is_variadic;
8164 const bool isPropertyAccessor =
false;
8165 const bool isSynthesizedAccessorStub =
false;
8167 const bool isImplicitlyDeclared =
true;
8168 const bool isDefined =
false;
8169 const clang::ObjCImplementationControl impControl =
8170 clang::ObjCImplementationControl::None;
8171 const bool HasRelatedResultType =
false;
8173 const unsigned num_args = method_function_prototype->getNumParams();
8175 if (num_args != num_selectors_with_args)
8179 auto *objc_method_decl =
8180 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8181 objc_method_decl->setDeclName(method_selector);
8182 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8183 objc_method_decl->setDeclContext(
8185 objc_method_decl->setInstanceMethod(isInstance);
8186 objc_method_decl->setVariadic(isVariadic);
8187 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8188 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8189 objc_method_decl->setImplicit(isImplicitlyDeclared);
8190 objc_method_decl->setDefined(isDefined);
8191 objc_method_decl->setDeclImplementation(impControl);
8192 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8195 if (objc_method_decl ==
nullptr)
8199 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8201 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8202 params.push_back(clang::ParmVarDecl::Create(
8203 ast, objc_method_decl, clang::SourceLocation(),
8204 clang::SourceLocation(),
8206 method_function_prototype->getParamType(param_index),
nullptr,
8207 clang::SC_Auto,
nullptr));
8210 objc_method_decl->setMethodParams(
8211 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8212 llvm::ArrayRef<clang::SourceLocation>());
8215 if (is_objc_direct_call) {
8218 objc_method_decl->addAttr(
8219 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8224 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8227 class_interface_decl->addDecl(objc_method_decl);
8229 VerifyDecl(objc_method_decl);
8231 return objc_method_decl;
8241 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8242 switch (type_class) {
8243 case clang::Type::Record: {
8244 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8245 if (cxx_record_decl) {
8246 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8247 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8252 case clang::Type::Enum: {
8253 clang::EnumDecl *enum_decl =
8254 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8256 enum_decl->setHasExternalLexicalStorage(has_extern);
8257 enum_decl->setHasExternalVisibleStorage(has_extern);
8262 case clang::Type::ObjCObject:
8263 case clang::Type::ObjCInterface: {
8264 const clang::ObjCObjectType *objc_class_type =
8265 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8266 assert(objc_class_type);
8267 if (objc_class_type) {
8268 clang::ObjCInterfaceDecl *class_interface_decl =
8269 objc_class_type->getInterface();
8271 if (class_interface_decl) {
8272 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8273 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8289 if (!qual_type.isNull()) {
8290 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8292 clang::TagDecl *tag_decl = tag_type->getDecl();
8294 tag_decl->startDefinition();
8299 const clang::ObjCObjectType *object_type =
8300 qual_type->getAs<clang::ObjCObjectType>();
8302 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8303 if (interface_decl) {
8304 interface_decl->startDefinition();
8315 if (qual_type.isNull())
8319 if (lldb_ast ==
nullptr)
8325 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8327 clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinitionOrSelf();
8329 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8339 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8340 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8341 if (cxx_record_decl->needsImplicitCopyConstructor())
8342 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8343 if (cxx_record_decl->needsImplicitCopyAssignment())
8344 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8347 if (!cxx_record_decl->isCompleteDefinition())
8348 cxx_record_decl->completeDefinition();
8349 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8350 cxx_record_decl->setHasExternalLexicalStorage(
false);
8351 cxx_record_decl->setHasExternalVisibleStorage(
false);
8356 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8360 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8362 if (enum_decl->isCompleteDefinition())
8365 QualType integer_type(enum_decl->getIntegerType());
8366 if (!integer_type.isNull()) {
8367 clang::ASTContext &ast = lldb_ast->getASTContext();
8369 unsigned NumNegativeBits = 0;
8370 unsigned NumPositiveBits = 0;
8371 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8374 clang::QualType BestPromotionType;
8375 clang::QualType BestType;
8376 ast.computeBestEnumTypes(
false, NumNegativeBits,
8377 NumPositiveBits, BestType, BestPromotionType);
8379 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8380 BestPromotionType, NumPositiveBits,
8388 const llvm::APSInt &value) {
8399 if (!enum_opaque_compiler_type)
8402 clang::QualType enum_qual_type(
8405 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8410 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8415 clang::EnumConstantDecl *enumerator_decl =
8416 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8418 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8419 enumerator_decl->setDeclContext(enum_decl);
8420 if (name && name[0])
8421 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8422 enumerator_decl->setType(clang::QualType(enutype, 0));
8424 enumerator_decl->setAccess(AS_public);
8430 enum_decl->addDecl(enumerator_decl);
8432 VerifyDecl(enumerator_decl);
8433 return enumerator_decl;
8438 uint64_t enum_value, uint32_t enum_value_bit_size) {
8440 llvm::APSInt value(enum_value_bit_size,
8449 const clang::Type *clang_type = qt.getTypePtrOrNull();
8450 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8454 return GetType(enum_type->getDecl()->getDefinitionOrSelf()->getIntegerType());
8460 if (type && pointee_type.
IsValid() &&
8465 return ast->GetType(ast->getASTContext().getMemberPointerType(
8474#define DEPTH_INCREMENT 2
8477LLVM_DUMP_METHOD
void
8487struct ScopedASTColor {
8488 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8491 ast.getDiagnostics().getDiagnosticOptions().getShowColors()) {
8492 ast.getDiagnostics().getDiagnosticOptions().setShowColors(
8493 show_colors ? clang::ShowColorsKind::On : clang::ShowColorsKind::Off);
8497 ast.getDiagnostics().getDiagnosticOptions().setShowColors(old_show_colors);
8500 clang::ASTContext *
8501 const clang::ShowColorsKind old_show_colors;
8510 clang::CreateASTDumper(output, filter,
8514 false, clang::ADOF_Default);
8517 consumer->HandleTranslationUnit(*
m_ast_up);
8521 llvm::StringRef symbol_name) {
8528 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8529 size_t ntypes = type_list.
GetSize();
8531 for (
size_t i = 0; i < ntypes; ++i) {
8534 if (!symbol_name.empty())
8535 if (symbol_name != type->GetName().GetStringRef())
8538 s << type->GetName() <<
"\n";
8541 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8549 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8551 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8563 size_t byte_size, uint32_t bitfield_bit_offset,
8564 uint32_t bitfield_bit_size) {
8565 const clang::EnumType *enutype =
8566 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8567 const clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8569 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8570 const uint64_t enum_svalue =
8573 bitfield_bit_offset)
8575 bitfield_bit_offset);
8576 bool can_be_bitfield =
true;
8577 uint64_t covered_bits = 0;
8578 int num_enumerators = 0;
8586 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8587 if (enumerators.empty())
8588 can_be_bitfield =
false;
8590 for (
auto *enumerator : enumerators) {
8591 llvm::APSInt init_val = enumerator->getInitVal();
8592 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8593 : init_val.getZExtValue();
8594 if (qual_type_is_signed)
8595 val = llvm::SignExtend64(val, 8 * byte_size);
8596 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8597 can_be_bitfield =
false;
8598 covered_bits |= val;
8600 if (val == enum_svalue) {
8609 offset = byte_offset;
8611 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8615 if (!can_be_bitfield) {
8616 if (qual_type_is_signed)
8617 s.
Printf(
"%" PRIi64, enum_svalue);
8619 s.
Printf(
"%" PRIu64, enum_uvalue);
8626 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8630 uint64_t remaining_value = enum_uvalue;
8631 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8632 values.reserve(num_enumerators);
8633 for (
auto *enumerator : enum_decl->enumerators())
8634 if (
auto val = enumerator->getInitVal().getZExtValue())
8635 values.emplace_back(val, enumerator->getName());
8640 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8641 return llvm::popcount(a.first) > llvm::popcount(b.first);
8644 for (
const auto &val : values) {
8645 if ((remaining_value & val.first) != val.first)
8647 remaining_value &= ~val.first;
8649 if (remaining_value)
8655 if (remaining_value)
8656 s.
Printf(
"0x%" PRIx64, remaining_value);
8664 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8673 switch (qual_type->getTypeClass()) {
8674 case clang::Type::Typedef: {
8675 clang::QualType typedef_qual_type =
8676 llvm::cast<clang::TypedefType>(qual_type)
8678 ->getUnderlyingType();
8681 format = typedef_clang_type.
GetFormat();
8682 clang::TypeInfo typedef_type_info =
8684 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8694 bitfield_bit_offset,
8699 case clang::Type::Enum:
8704 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8705 bitfield_bit_offset, bitfield_bit_size);
8713 uint32_t item_count = 1;
8753 item_count = byte_size;
8758 item_count = byte_size / 2;
8763 item_count = byte_size / 4;
8769 bitfield_bit_size, bitfield_bit_offset,
8785 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(clang_type)) {
8794 clang::QualType qual_type =
8797 llvm::SmallVector<char, 1024> buf;
8798 llvm::raw_svector_ostream llvm_ostrm(buf);
8800 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8801 switch (type_class) {
8802 case clang::Type::ObjCObject:
8803 case clang::Type::ObjCInterface: {
8806 auto *objc_class_type =
8807 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8808 assert(objc_class_type);
8809 if (!objc_class_type)
8811 clang::ObjCInterfaceDecl *class_interface_decl =
8812 objc_class_type->getInterface();
8813 if (!class_interface_decl)
8816 class_interface_decl->dump(llvm_ostrm);
8818 class_interface_decl->print(llvm_ostrm,
8823 case clang::Type::Typedef: {
8824 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8827 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
8829 typedef_decl->dump(llvm_ostrm);
8832 if (!clang_typedef_name.empty()) {
8839 case clang::Type::Record: {
8842 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
8843 const clang::RecordDecl *record_decl = record_type->getDecl();
8845 record_decl->dump(llvm_ostrm);
8847 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
8853 if (
auto *tag_type =
8854 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
8855 if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
8857 tag_decl->dump(llvm_ostrm);
8859 tag_decl->print(llvm_ostrm, 0);
8865 std::string clang_type_name(qual_type.getAsString());
8866 if (!clang_type_name.empty())
8873 if (buf.size() > 0) {
8874 s.
Write(buf.data(), buf.size());
8881 clang::QualType qual_type(
8884 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8885 switch (type_class) {
8886 case clang::Type::Record: {
8887 const clang::CXXRecordDecl *cxx_record_decl =
8888 qual_type->getAsCXXRecordDecl();
8889 if (cxx_record_decl)
8890 printf(
"class %s", cxx_record_decl->getName().str().c_str());
8893 case clang::Type::Enum: {
8894 clang::EnumDecl *enum_decl =
8895 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8897 printf(
"enum %s", enum_decl->getName().str().c_str());
8901 case clang::Type::ObjCObject:
8902 case clang::Type::ObjCInterface: {
8903 const clang::ObjCObjectType *objc_class_type =
8904 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
8905 if (objc_class_type) {
8906 clang::ObjCInterfaceDecl *class_interface_decl =
8907 objc_class_type->getInterface();
8911 if (class_interface_decl)
8912 printf(
"@class %s", class_interface_decl->getName().str().c_str());
8916 case clang::Type::Typedef:
8917 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
8924 case clang::Type::Auto:
8927 llvm::cast<clang::AutoType>(qual_type)
8929 .getAsOpaquePtr()));
8931 case clang::Type::Paren:
8935 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
8938 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
8946 const char *parent_name,
int tag_decl_kind,
8948 if (template_param_infos.
IsValid()) {
8949 std::string template_basename(parent_name);
8951 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
8952 template_basename.erase(i);
8955 template_basename.c_str(), tag_decl_kind,
8956 template_param_infos);
8971 clang::ObjCInterfaceDecl *decl) {
8995 std::make_unique<npdb::PdbAstBuilderClang>(*
this);
9000 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9001 uint64_t &alignment,
9002 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9003 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9005 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9018 field_offsets, base_offsets, vbase_offsets);
9025 clang::NamedDecl *nd =
9026 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9036 if (!label_or_err) {
9037 llvm::consumeError(label_or_err.takeError());
9041 llvm::StringRef mangled = label_or_err->lookup_name;
9049 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9050 static_cast<clang::Decl *
>(opaque_decl));
9052 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9056 if (!mc || !mc->shouldMangleCXXName(nd))
9061 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9066 llvm::SmallVector<char, 1024> buf;
9067 llvm::raw_svector_ostream llvm_ostrm(buf);
9068 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9070 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9073 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9075 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9079 mc->mangleName(nd, llvm_ostrm);
9095 if (clang::FunctionDecl *func_decl =
9096 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9097 return GetType(func_decl->getReturnType());
9098 if (clang::ObjCMethodDecl *objc_method =
9099 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9100 return GetType(objc_method->getReturnType());
9106 if (clang::FunctionDecl *func_decl =
9107 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9108 return func_decl->param_size();
9109 if (clang::ObjCMethodDecl *objc_method =
9110 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9111 return objc_method->param_size();
9117 clang::DeclContext
const *decl_ctx) {
9118 switch (clang_kind) {
9119 case Decl::TranslationUnit:
9121 case Decl::Namespace:
9132 if (decl_ctx->isFunctionOrMethod())
9134 if (decl_ctx->isRecord())
9144 std::vector<lldb_private::CompilerContext> &context) {
9145 if (decl_ctx ==
nullptr)
9148 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9149 if (clang_kind == Decl::TranslationUnit)
9154 context.push_back({compiler_kind, decl_ctx_name});
9157std::vector<lldb_private::CompilerContext>
9159 std::vector<lldb_private::CompilerContext> context;
9162 clang::Decl *decl = (clang::Decl *)opaque_decl;
9164 clang::DeclContext *decl_ctx = decl->getDeclContext();
9167 auto compiler_kind =
9169 context.push_back({compiler_kind, decl_name});
9176 if (clang::FunctionDecl *func_decl =
9177 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9178 if (idx < func_decl->param_size()) {
9179 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9181 return GetType(var_decl->getOriginalType());
9183 }
else if (clang::ObjCMethodDecl *objc_method =
9184 llvm::dyn_cast<clang::ObjCMethodDecl>(
9185 (clang::Decl *)opaque_decl)) {
9186 if (idx < objc_method->param_size())
9187 return GetType(objc_method->parameters()[idx]->getOriginalType());
9193 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9194 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9197 clang::Expr *init_expr = var_decl->getInit();
9200 std::optional<llvm::APSInt> value =
9210 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9211 std::vector<CompilerDecl> found_decls;
9213 if (opaque_decl_ctx && symbol_file) {
9214 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9215 std::set<DeclContext *> searched;
9216 std::multimap<DeclContext *, DeclContext *> search_queue;
9218 for (clang::DeclContext *decl_context = root_decl_ctx;
9219 decl_context !=
nullptr && found_decls.empty();
9220 decl_context = decl_context->getParent()) {
9221 search_queue.insert(std::make_pair(decl_context, decl_context));
9223 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9225 if (!searched.insert(it->second).second)
9230 for (clang::Decl *child : it->second->decls()) {
9231 if (clang::UsingDirectiveDecl *ud =
9232 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9233 if (ignore_using_decls)
9235 clang::DeclContext *from = ud->getCommonAncestor();
9236 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9237 search_queue.insert(
9238 std::make_pair(from, ud->getNominatedNamespace()));
9239 }
else if (clang::UsingDecl *ud =
9240 llvm::dyn_cast<clang::UsingDecl>(child)) {
9241 if (ignore_using_decls)
9243 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9244 clang::Decl *target = usd->getTargetDecl();
9245 if (clang::NamedDecl *nd =
9246 llvm::dyn_cast<clang::NamedDecl>(target)) {
9247 IdentifierInfo *ii = nd->getIdentifier();
9248 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9252 }
else if (clang::NamedDecl *nd =
9253 llvm::dyn_cast<clang::NamedDecl>(child)) {
9254 IdentifierInfo *ii = nd->getIdentifier();
9255 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9306 clang::DeclContext *child_decl_ctx,
9310 if (frame_decl_ctx && symbol_file) {
9311 std::set<DeclContext *> searched;
9312 std::multimap<DeclContext *, DeclContext *> search_queue;
9315 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9319 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9320 decl_ctx = decl_ctx->getParent()) {
9321 if (!decl_ctx->isLookupContext())
9323 if (decl_ctx == parent_decl_ctx)
9326 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9327 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9329 if (searched.find(it->second) != searched.end())
9337 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9340 searched.insert(it->second);
9344 for (clang::Decl *child : it->second->decls()) {
9345 if (clang::UsingDirectiveDecl *ud =
9346 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9347 clang::DeclContext *ns = ud->getNominatedNamespace();
9348 if (ns == parent_decl_ctx)
9351 clang::DeclContext *from = ud->getCommonAncestor();
9352 if (searched.find(ns) == searched.end())
9353 search_queue.insert(std::make_pair(from, ns));
9354 }
else if (child_name) {
9355 if (clang::UsingDecl *ud =
9356 llvm::dyn_cast<clang::UsingDecl>(child)) {
9357 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9358 clang::Decl *target = usd->getTargetDecl();
9359 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9363 IdentifierInfo *ii = nd->getIdentifier();
9364 if (ii ==
nullptr ||
9365 ii->getName() != child_name->
AsCString(
nullptr))
9388 if (opaque_decl_ctx) {
9389 clang::NamedDecl *named_decl =
9390 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9393 llvm::raw_string_ostream stream{name};
9395 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9396 named_decl->getNameForDiagnostic(stream, policy,
false);
9405 if (opaque_decl_ctx) {
9406 clang::NamedDecl *named_decl =
9407 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9415 if (!opaque_decl_ctx)
9418 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9419 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9421 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9423 }
else if (clang::FunctionDecl *fun_decl =
9424 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9425 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9426 return metadata->HasObjectPtr();
9432std::vector<lldb_private::CompilerContext>
9434 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9435 std::vector<lldb_private::CompilerContext> context;
9441 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9442 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9443 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9447 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9448 if (DC->isInlineNamespace())
9451 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9452 return NS->isAnonymousNamespace();
9459 if (decl_ctx == other)
9461 }
while (is_transparent_lookup_allowed(other) &&
9462 (other = other->getParent()));
9469 if (!opaque_decl_ctx)
9472 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9473 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9475 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9477 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9478 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9479 return metadata->GetObjectPtrLanguage();
9499 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9507 return llvm::dyn_cast<clang::CXXMethodDecl>(
9512clang::FunctionDecl *
9515 return llvm::dyn_cast<clang::FunctionDecl>(
9520clang::NamespaceDecl *
9523 return llvm::dyn_cast<clang::NamespaceDecl>(
9528std::optional<ClangASTMetadata>
9530 const Decl *
object) {
9538 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9561 lldbassert(started &&
"Unable to start a class type definition.");
9566 ts->SetDeclIsForcefullyCompleted(td);
9580 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9581 std::unique_ptr<ClangASTSource> ast_source)
9583 m_scratch_ast_source_up(std::move(ast_source)) {
9585 m_scratch_ast_source_up->InstallASTContext(*
this);
9586 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9587 m_scratch_ast_source_up->CreateProxy();
9588 SetExternalSource(proxy_ast_source);
9592 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9600 llvm::Triple triple)
9607 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9619 std::optional<IsolatedASTKind> ast_kind,
9620 bool create_on_demand) {
9623 if (
auto err = type_system_or_err.takeError()) {
9625 "Couldn't get scratch TypeSystemClang: {0}");
9628 auto ts_sp = *type_system_or_err;
9630 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9635 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9637 return std::static_pointer_cast<TypeSystemClang>(
9642static llvm::StringRef
9646 return "C++ modules";
9648 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9652 llvm::StringRef filter,
bool show_color) {
9654 output <<
"State of scratch Clang type system:\n";
9658 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9659 std::vector<KeyAndTS> sorted_typesystems;
9661 sorted_typesystems.emplace_back(a.first, a.second.get());
9662 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9665 for (
const auto &a : sorted_typesystems) {
9668 output <<
"State of scratch Clang type subsystem "
9670 a.second->Dump(output, filter, show_color);
9675 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9683 desired_type, options, ctx_obj);
9688 const ValueList &arg_value_list,
const char *name) {
9693 Process *process = target_sp->GetProcessSP().get();
9698 arg_value_list, name);
9701std::unique_ptr<UtilityFunction>
9708 return std::make_unique<ClangUtilityFunction>(
9709 *target_sp.get(), std::move(text), std::move(name),
9710 target_sp->GetDebugUtilityExpression());
9724 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9728 return std::make_unique<ClangASTSource>(
9733static llvm::StringRef
9737 return "scratch ASTContext for C++ module types";
9739 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9746 return *found_ast->second;
9749 std::shared_ptr<TypeSystemClang> new_ast_sp =
9759 const clang::RecordType *record_type =
9760 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9762 const clang::RecordDecl *record_decl =
9763 record_type->getDecl()->getDefinitionOrSelf();
9764 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9765 return metadata->IsForcefullyCompleted();
9774 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9778 metadata->SetIsForcefullyCompleted();
9786 LLDB_LOG(log,
"Created new TypeSystem for (ASTContext*){0:x} '{1}'",
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
static bool DumpEnumValue(const clang::QualType &qual_type, Stream &s, const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_offset, uint32_t bitfield_bit_size)
static lldb::opaque_compiler_type_t GetObjCFieldAtIndex(clang::ASTContext *ast, clang::ObjCInterfaceDecl *class_interface_decl, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr)
static void ParseLangArgs(LangOptions &Opts, ArchSpec arch)
static const clang::EnumType * GetCompleteEnumType(const clang::ASTContext *ast, clang::QualType qual_type)
Returns the clang::EnumType of the specified qual_type.
static clang::QualType GetFullyUnqualifiedType_Impl(clang::ASTContext *ast, clang::QualType qual_type)
const TemplateArgument * GetNthTemplateArgument(const clang::ClassTemplateSpecializationDecl *decl, size_t idx, bool expand_pack)
static int64_t ReadVBaseOffsetFromVTable(Process &process, VTableContextBase &vtable_ctx, lldb::addr_t vtable_ptr, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl)
lldb_private::ThreadSafeDenseMap< clang::ASTContext *, TypeSystemClang * > ClangASTMap
static bool IsClangDeclContext(const CompilerDeclContext &dc)
static bool TemplateParameterAllowsValue(NamedDecl *param, const TemplateArgument &value)
Returns true if the given template parameter can represent the given value.
static CompilerContextKind GetCompilerKind(clang::Decl::Kind clang_kind, clang::DeclContext const *decl_ctx)
static QualType RemoveWrappingTypes(QualType type, ArrayRef< clang::Type::TypeClass > mask={})
Aggressively desugar the provided type, skipping past various kinds of syntactic sugar and other cons...
static TemplateParameterList * CreateTemplateParameterList(ASTContext &ast, const TypeSystemClang::TemplateParameterInfos &template_param_infos, llvm::SmallVector< NamedDecl *, 8 > &template_param_decls)
clang::DeclContext * FindLCABetweenDecls(clang::DeclContext *left, clang::DeclContext *right, clang::DeclContext *root)
static const clang::RecordType * GetCompleteRecordType(const clang::ASTContext *ast, clang::QualType qual_type)
Returns the clang::RecordType of the specified qual_type.
static bool check_op_param(bool is_method, clang::OverloadedOperatorKind op_kind, bool unary, bool binary, uint32_t num_params)
static llvm::StringRef GetSpecializedASTName(ScratchTypeSystemClang::IsolatedASTKind feature)
static bool ObjCDeclHasIVars(clang::ObjCInterfaceDecl *class_interface_decl)
static lldb::addr_t GetVTableAddress(Process &process, VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout)
static std::optional< SymbolFile::ArrayInfo > GetDynamicArrayInfo(TypeSystemClang &ast, SymbolFile *sym_file, clang::QualType qual_type, const ExecutionContext *exe_ctx)
static ConstString ExtractMangledNameFromFunctionCallLabel(llvm::StringRef label)
static bool GetCompleteQualType(const clang::ASTContext *ast, clang::QualType qual_type)
static llvm::StringRef GetNameForIsolatedASTKind(ScratchTypeSystemClang::IsolatedASTKind kind)
Returns a human-readable name that uniquely identifiers the sub-AST kind.
static void InsertCompilerContext(TypeSystemClang *ts, clang::DeclContext *decl_ctx, std::vector< lldb_private::CompilerContext > &context)
static bool GetVBaseBitOffset(VTableContextBase &vtable_ctx, ValueObject &valobj, const ASTRecordLayout &record_layout, const CXXRecordDecl *cxx_record_decl, const CXXRecordDecl *base_class_decl, int32_t &bit_offset)
static bool QualTypeMatchesBitSize(const uint64_t bit_size, ASTContext &ast, QualType qual_type)
static ClangASTMap & GetASTMap()
static void SetMemberOwningModule(clang::Decl *member, const clang::Decl *parent)
static bool ClassTemplateAllowsToInstantiationArgs(ClassTemplateDecl *class_template_decl, const TypeSystemClang::TemplateParameterInfos &instantiation_values)
Returns true if the given class template declaration could produce an instantiation with the specifie...
static const clang::ObjCObjectType * GetCompleteObjCObjectType(const clang::ASTContext *ast, QualType qual_type)
Returns the clang::ObjCObjectType of the specified qual_type.
#define LLDB_INVALID_DECL_LEVEL
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &info) override
DiagnosticConsumer * clone(DiagnosticsEngine &Diags) const
A section + offset based address class.
An architecture specification class.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool CharIsSignedByDefault() const
Returns true if 'char' is a signed type by default in the architecture false otherwise.
Manages and observes all Clang AST node importing in LLDB.
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &bit_size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets)
void ForgetSource(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx)
"lldb/Expression/ClangFunctionCaller.h" Encapsulates a function that can be called.
"lldb/Expression/ClangPersistentVariables.h" Manages persistent values that need to be preserved betw...
"lldb/Expression/ClangUserExpression.h" Encapsulates a single expression for use with Clang
Represents a generic declaration context in a program.
TypeSystem * GetTypeSystem() const
void * GetOpaqueDeclContext() const
Represents a generic declaration such as a function declaration.
lldb::TypeSystemSP GetSharedPointer() const
Generic representation of a type in a programming language.
lldb::LanguageType GetMinimumLanguage()
bool IsEnumerationType(bool &is_signed) const
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
void SetCompilerType(lldb::TypeSystemWP type_system, lldb::opaque_compiler_type_t type)
size_t GetIndexOfChildMemberWithName(llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) const
Lookup a child member given a name.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
lldb::Encoding GetEncoding() const
uint32_t GetNumDirectBaseClasses() const
ConstString GetTypeName(bool BaseOnly=false) const
bool IsEnumerationIntegerTypeSigned() const
bool DumpTypeValue(Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope)
bool IsAggregateType() const
lldb::Format GetFormat() const
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const
CompilerType GetDirectBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
bool GetCompleteType() const
Type Completion.
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
llvm::Expected< uint32_t > GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const
Lookup a child given a name.
llvm::Expected< uint32_t > GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
A class that describes the declaration location of a lldb object.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
Process * GetProcessPtr() const
Returns a pointer to the process object.
static FileSystem & Instance()
bool Test(ValueType bit) const
Test a single flag bit.
bool AnySet(ValueType mask) const
Test one or more flags.
Encapsulates a function that can be called.
static bool LanguageIsC(lldb::LanguageType language)
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
static bool LanguageIsPascal(lldb::LanguageType language)
static bool LanguageIsObjC(lldb::LanguageType language)
static bool IsMangledName(llvm::StringRef name)
A class that describes an executable image and its associated object and symbol files.
virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type, const char *ivar_name)
static ObjCLanguageRuntime * Get(Process &process)
unsigned GetValue() const
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Status &error)
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) const
The implementation of lldb::Type's m_payload field for TypeSystemClang.
void SetIsCompleteObjCClass(bool is_complete_objc_class)
bool IsCompleteObjCClass()
Type::Payload m_payload
The payload is used for typedefs and ptrauth types.
TypePayloadClang()=default
void SetOwningModule(OptionalClangModuleID id)
static constexpr unsigned ObjCClassBit
llvm::ArrayRef< clang::TemplateArgument > GetParameterPackArgs() const
void SetParameterPack(std::unique_ptr< TemplateParameterInfos > args)
clang::TemplateArgument const & Front() const
llvm::StringRef GetPackName() const
bool hasParameterPack() const
TemplateParameterInfos const & GetParameterPack() const
llvm::ArrayRef< const char * > GetNames() const
llvm::ArrayRef< clang::TemplateArgument > GetArgs() const
A TypeSystem implementation based on Clang.
bool IsMemberFunctionPointerType(lldb::opaque_compiler_type_t type) override
clang::ClassTemplateDecl * CreateClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef class_name, int kind, const TemplateParameterInfos &infos)
clang::ClassTemplateDecl * ParseClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *parent_name, int tag_decl_kind, const TypeSystemClang::TemplateParameterInfos &template_param_infos)
CompilerType GetTypeForIdentifier(const clang::ASTContext &Ctx, llvm::StringRef type_name, clang::DeclContext *decl_context=nullptr)
llvm::Expected< uint64_t > GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
CompilerType CreateFunctionType(const CompilerType &result_type, llvm::ArrayRef< CompilerType > args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
size_t GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes, std::vector< uint32_t > &child_indexes) override
static clang::TypedefNameDecl * GetAsTypedefDecl(const CompilerType &type)
std::string GetTypeNameForDecl(const clang::NamedDecl *named_decl, bool qualified=true)
Returns the internal type name for the given NamedDecl using the type printing policy.
static clang::ObjCInterfaceDecl * GetAsObjCInterfaceDecl(const CompilerType &type)
uint32_t m_pointer_byte_size
bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream &s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override
std::string m_display_name
A string describing what this TypeSystemClang represents (e.g., AST for debug information,...
ConstString GetTypeName(lldb::opaque_compiler_type_t type, bool base_only) override
static void SetOwningModule(clang::Decl *decl, OptionalClangModuleID owning_module)
Set the owning module for decl.
llvm::Expected< uint64_t > GetObjCBitSize(clang::QualType qual_type, ExecutionContextScope *exe_scope)
std::unique_ptr< clang::TargetInfo > m_target_info_up
std::unique_ptr< clang::LangOptions > m_language_options_up
Scalar DeclGetConstantValue(void *opaque_decl) override
llvm::Expected< CompilerType > GetDereferencedType(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, std::string &deref_name, uint32_t &deref_byte_size, int32_t &deref_byte_offset, ValueObject *valobj, uint64_t &language_flags) override
bool BaseSpecifierIsEmpty(const clang::CXXBaseSpecifier *b)
static uint32_t GetNumPointeeChildren(clang::QualType type)
ConstString DeclGetMangledName(void *opaque_decl) override
CompilerType GetBasicType(lldb::BasicType type)
std::unique_ptr< clang::HeaderSearchOptions > m_header_search_opts_up
clang::UsingDecl * CreateUsingDeclaration(clang::DeclContext *current_decl_ctx, OptionalClangModuleID owning_module, clang::NamedDecl *target)
static clang::AccessSpecifier ConvertAccessTypeToAccessSpecifier(lldb::AccessType access)
CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override
bool IsForcefullyCompleted(lldb::opaque_compiler_type_t type) override
bool SupportsLanguage(lldb::LanguageType language) override
uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override
OptionalClangModuleID GetOrCreateClangModule(llvm::StringRef name, OptionalClangModuleID parent, bool is_framework=false, bool is_explicit=false)
Synthesize a clang::Module and return its ID or a default-constructed ID.
void CompleteTagDecl(clang::TagDecl *)
std::shared_ptr< clang::TargetOptions > & getTargetOptions()
static TypeSystemClang * GetASTContext(clang::ASTContext *ast_ctx)
bool IsReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type, bool *is_rvalue) override
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
const char * GetTargetTriple()
TypeSystemClang(llvm::StringRef name, llvm::Triple triple)
Constructs a TypeSystemClang with an ASTContext using the given triple.
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, Module *module, Target *target)
clang::TargetInfo * getTargetInfo()
clang::FunctionTemplateDecl * CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::FunctionDecl *func_decl, const TemplateParameterInfos &infos)
CompilerType CreateArrayType(const CompilerType &element_type, std::optional< size_t > element_count, bool is_vector)
static bool AreTypesSame(CompilerType type1, CompilerType type2, bool ignore_qualifiers=false)
CompilerType GetArrayType(lldb::opaque_compiler_type_t type, uint64_t size) override
bool IsFunctionType(lldb::opaque_compiler_type_t type) override
CompilerType GetFunctionReturnType(lldb::opaque_compiler_type_t type) override
std::optional< ClangASTMetadata > GetMetadata(const clang::Decl *object)
CompilerType GetLValueReferenceType(lldb::opaque_compiler_type_t type) override
bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td)
lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override
bool CanPassInRegisters(const CompilerType &type) override
CompilerDecl GetStaticFieldWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
bool IsEnumerationType(lldb::opaque_compiler_type_t type, bool &is_signed) override
bool IsTemplateType(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
static bool IsCXXClassType(const CompilerType &type)
bool IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed) override
std::unique_ptr< npdb::PdbAstBuilderClang > m_native_pdb_ast_parser_up
uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override
static bool IsOperator(llvm::StringRef name, clang::OverloadedOperatorKind &op_kind)
bool IsCharType(lldb::opaque_compiler_type_t type) override
CompilerType CreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
static void SetFloatingInitializerForVariable(clang::VarDecl *var, const llvm::APFloat &init_value)
Initializes a variable with a floating point value.
uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type, CompilerType *pointee_or_element_compiler_type) override
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) override
CompilerType GetType(clang::QualType qt)
Creates a CompilerType from the given QualType with the current TypeSystemClang instance as the Compi...
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override
std::string m_target_triple
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > bases)
bool IsBeingDefined(lldb::opaque_compiler_type_t type) override
CompilerType GetPromotedIntegerType(lldb::opaque_compiler_type_t type) override
ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override
std::unique_ptr< clang::IdentifierTable > m_identifier_table_up
static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name)
static void SetIntegerInitializerForVariable(clang::VarDecl *var, const llvm::APInt &init_value)
Initializes a variable with an integer value.
bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override
CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets)
bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::SourceManager > m_source_manager_up
bool IsVoidType(lldb::opaque_compiler_type_t type) override
static void SetIsPacked(const CompilerType &type)
void ForEachEnumerator(lldb::opaque_compiler_type_t type, std::function< bool(const CompilerType &integer_type, ConstString name, const llvm::APSInt &value)> const &callback) override
CompilerType CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *class_template_specialization_decl)
bool IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
std::unique_ptr< clang::DiagnosticOptions > m_diagnostic_options_up
void CreateFunctionTemplateSpecializationInfo(clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template, const TemplateParameterInfos &infos)
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, uint64_t enum_value, uint32_t enum_value_bit_size)
llvm::StringRef getDisplayName() const
Returns the display name of this TypeSystemClang that indicates what purpose it serves in LLDB.
static clang::VarDecl * AddVariableToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &var_type)
bool IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length)
CompilerType GetRValueReferenceType(lldb::opaque_compiler_type_t type) override
CompilerDecl GetCompilerDecl(clang::Decl *decl)
Creates a CompilerDecl from the given Decl with the current TypeSystemClang instance as its typesyste...
unsigned GetPtrAuthDiscriminator(lldb::opaque_compiler_type_t type) override
CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override
bool GetCompleteType(lldb::opaque_compiler_type_t type) override
bool IsBlockPointerType(lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) override
bool IsConst(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::CXXBaseSpecifier > CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class)
CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override
std::vector< CompilerDecl > DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_using_decls) override
const llvm::fltSemantics & GetFloatTypeSemantics(size_t byte_size, lldb::Format format) override
bool IsFloatingPointType(lldb::opaque_compiler_type_t type) override
llvm::Expected< uint32_t > GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes) override
void setSema(clang::Sema *s)
uint32_t GetPointerByteSize() override
bool IsCompleteType(lldb::opaque_compiler_type_t type) override
CompilerType GetIntTypeFromBitSize(size_t bit_size, bool is_signed)
clang::MangleContext * getMangleContext()
void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *)
unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override
static void DumpDeclContextHiearchy(clang::DeclContext *decl_ctx)
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
CompilerType GetTypeForFormatters(void *type) override
void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id)
bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override
This is used by swift.
static LanguageSet GetSupportedLanguagesForExpressions()
clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, const CompilerType &function_Type, clang::StorageClass storage, bool is_inline, llvm::StringRef asm_label)
CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override
CompilerDeclContext GetCompilerDeclContextForType(const CompilerType &type) override
Returns the direct parent context of specified type.
std::unique_ptr< clang::SelectorTable > m_selector_table_up
PDBASTParser * GetPDBParser() override
std::optional< CompilerType::IntegralTemplateArgument > GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
bool DeclContextIsClassMethod(void *opaque_decl_ctx) override
bool IsMemberDataPointerType(lldb::opaque_compiler_type_t type) override
void SetTargetTriple(llvm::StringRef target_triple)
CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
static bool CheckOverloadedOperatorKindParameterCount(bool is_method, clang::OverloadedOperatorKind op_kind, uint32_t num_params)
clang::DeclarationName GetDeclarationName(llvm::StringRef name, const CompilerType &function_clang_type)
DeclMetadataMap m_decl_metadata
Maps Decls to their associated ClangASTMetadata.
static clang::CXXMethodDecl * DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc)
CompilerType GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override
uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx, clang::DeclContext *child_decl_ctx, ConstString *child_name=nullptr, CompilerType *child_type=nullptr)
bool HasPointerAuthQualifier(lldb::opaque_compiler_type_t type) override
static clang::QualType GetQualType(lldb::opaque_compiler_type_t type)
clang::PrintingPolicy GetTypePrintingPolicy()
Returns the PrintingPolicy used when generating the internal type names.
uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override
static clang::RecordDecl * GetAsRecordDecl(const CompilerType &type)
CompilerType GetPointerSizedIntType(bool is_signed)
uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl, bool omit_empty_base_classes)
lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) override
std::unique_ptr< DWARFASTParserClang > m_dwarf_ast_parser_up
CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size)
lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type) override
bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override
int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override
static void BuildIndirectFields(const CompilerType &type)
std::unique_ptr< clang::FileManager > m_file_manager_up
uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl, const clang::CXXBaseSpecifier *base_spec, bool omit_empty_base_classes)
bool IsAnonymousType(lldb::opaque_compiler_type_t type) override
bool Verify(lldb::opaque_compiler_type_t type) override
Verify the integrity of the type to catch CompilerTypes that mix and match invalid TypeSystem/Opaque ...
size_t GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override
void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type)
CompilerType CreateBlockPointerType(const CompilerType &function_type)
lldb::LanguageType GetMinimumLanguage(lldb::opaque_compiler_type_t type) override
bool FieldIsBitfield(clang::FieldDecl *field, uint32_t &bitfield_bit_size)
clang::ClassTemplateSpecializationDecl * CreateClassTemplateSpecializationDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::ClassTemplateDecl *class_template_decl, int kind, const TemplateParameterInfos &infos)
llvm::SmallVector< clang::ParmVarDecl * > CreateParameterDeclarations(clang::FunctionDecl *context, const clang::FunctionProtoType &prototype, const llvm::SmallVector< llvm::StringRef > ¶m_names)
For each parameter type of prototype, creates a clang::ParmVarDecl whose clang::DeclContext is contex...
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, int kind, lldb::LanguageType language, std::optional< ClangASTMetadata > metadata=std::nullopt, bool exports_symbols=false)
std::unique_ptr< clang::HeaderSearch > m_header_search_up
void Finalize() override
Free up any resources associated with this TypeSystem.
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, llvm::StringRef asm_label, const CompilerType &method_type, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
static clang::ASTContext * DeclContextGetTypeSystemClang(const CompilerDeclContext &dc)
uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, CompilerType *base_type_ptr) override
LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override
Convenience LLVM-style dump method for use in the debugger only.
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
std::unique_ptr< clang::ASTContext > m_ast_up
CompilerType CreateGenericFunctionPrototype() override
static clang::QualType GetCanonicalQualType(lldb::opaque_compiler_type_t type)
CompilerType DeclGetFunctionReturnType(void *opaque_decl) override
static bool IsEnumType(lldb::opaque_compiler_type_t type)
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
CompilerType GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static bool SetObjCSuperClass(const CompilerType &type, const CompilerType &superclass_compiler_type)
clang::UsingDirectiveDecl * CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::NamespaceDecl *ns_decl)
static lldb::opaque_compiler_type_t GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type)
bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override
void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name)
Dump clang AST types from the symbol file.
CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override
static void DumpDeclHiearchy(clang::Decl *decl)
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
static clang::FunctionDecl * DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc)
bool IsScalarType(lldb::opaque_compiler_type_t type) override
bool GetPtrAuthAddressDiversity(lldb::opaque_compiler_type_t type) override
std::shared_ptr< clang::TargetOptions > m_target_options_rp
lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override
static bool IsClassType(lldb::opaque_compiler_type_t type)
bool IsDefined(lldb::opaque_compiler_type_t type) override
static bool IsObjCClassType(const CompilerType &type)
TypeMetadataMap m_type_metadata
Maps Types to their associated ClangASTMetadata.
CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override
bool RecordHasFields(const clang::RecordDecl *record_decl)
CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index) override
static std::optional< ClangASTMetadata > DeclContextGetMetaData(const CompilerDeclContext &dc, const clang::Decl *object)
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerDiffType(bool is_signed) override
static clang::ObjCMethodDecl * AddMethodToObjCObjectType(const CompilerType &type, const char *name, const CompilerType &method_compiler_type, bool is_artificial, bool is_variadic, bool is_objc_direct_call)
~TypeSystemClang() override
CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override
bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, void *other_opaque_decl_ctx) override
CompilerType AddPtrAuthModifier(lldb::opaque_compiler_type_t type, uint32_t payload) override
static bool AddObjCClassProperty(const CompilerType &type, const char *property_name, const CompilerType &property_compiler_type, clang::ObjCIvarDecl *ivar_decl, const char *property_setter_name, const char *property_getter_name, uint32_t property_attributes, ClangASTMetadata metadata)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
void SetMetadata(const clang::Decl *object, ClangASTMetadata meta_data)
clang::ParmVarDecl * CreateParameterDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType ¶m_type, int storage, bool add_decl=false)
void DumpTypeDescription(lldb::opaque_compiler_type_t type, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) override
Dump the type to stdout.
CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
static clang::NamespaceDecl * DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped, std::optional< clang::EnumExtensibilityAttr::Kind > enum_kind=std::nullopt)
npdb::PdbAstBuilder * GetNativePDBParser() override
std::unique_ptr< clang::DiagnosticConsumer > m_diagnostic_consumer_up
CompilerType CreateObjCClass(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool isInternal, std::optional< ClangASTMetadata > metadata=std::nullopt)
CompilerType GetTypeForDecl(clang::NamedDecl *decl)
CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc)
bool IsTypedefType(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override
std::optional< size_t > GetTypeBitAlign(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< clang::Builtin::Context > m_builtins_up
CompilerType GetBuiltinTypeByName(ConstString name) override
bool GetCompleteDecl(clang::Decl *decl)
static bool StartTagDeclarationDefinition(const CompilerType &type)
uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl, bool omit_empty_base_classes)
bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, CompilerType *target_type, bool check_cplusplus, bool check_objc) override
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, uint32_t bitfield_bit_size)
CompilerType GetOrCreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
void LogCreation() const
Emits information about this TypeSystem into the expression log.
static llvm::StringRef GetPluginNameStatic()
clang::Sema * m_sema
The sema associated that is currently used to build this ASTContext.
size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override
const clang::ClassTemplateSpecializationDecl * GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type)
std::unique_ptr< clang::MangleContext > m_mangle_ctx_up
TypeMemberFunctionImpl GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
bool IsTypeImpl(lldb::opaque_compiler_type_t type, llvm::function_ref< bool(clang::QualType)> predicate) const
size_t DeclGetFunctionNumArguments(void *opaque_decl) override
CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< PDBASTParser > m_pdb_ast_parser_up
std::unique_ptr< clang::DiagnosticsEngine > m_diagnostics_engine_up
static std::optional< std::string > GetCXXClassName(const CompilerType &type)
static void DumpTypeName(const CompilerType &type)
plugin::dwarf::DWARFASTParser * GetDWARFParser() override
CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx) override
bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
static clang::EnumDecl * GetAsEnumDecl(const CompilerType &type)
CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::ModuleMap > m_module_map_up
static bool IsObjCObjectOrInterfaceType(const CompilerType &type)
static void RequireCompleteType(CompilerType type)
Complete a type from debug info, or mark it as forcefully completed if there is no definition of the ...
CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload) override
Using the current type, create a new typedef to that type using "typedef_name" as the name and "decl_...
llvm::Expected< uint32_t > GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes, const ExecutionContext *exe_ctx) override
CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override
clang::TemplateTemplateParmDecl * CreateTemplateTemplateParmDecl(const char *template_name)
lldb::TemplateArgumentKind GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
clang::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
std::vector< lldb_private::CompilerContext > DeclGetCompilerContext(void *opaque_decl) override
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
std::vector< lldb_private::CompilerContext > DeclContextGetCompilerContext(void *opaque_decl_ctx) override
void CreateASTContext()
Creates the internal ASTContext.
void SetExternalSource(llvm::IntrusiveRefCntPtr< clang::ExternalASTSource > ast_source_sp)
CompilerType GetCStringType(bool is_const)
bool IsAggregateType(lldb::opaque_compiler_type_t type) override
bool IsPromotableIntegerType(lldb::opaque_compiler_type_t type) override
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override
static LanguageSet GetSupportedLanguagesForTypes()
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
ConstString DeclContextGetName(void *opaque_decl_ctx) override
size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack) override
ConstString DeclGetName(void *opaque_decl) override
SymbolFile * GetSymbolFile() const
bool m_has_forcefully_completed_types
Used for reporting statistics.
Encapsulates a one-time expression for use in lldb.
virtual uint64_t GetData(DataExtractor &data, Status &error)
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
AddressType GetAddressTypeOfChildren()
CompilerType GetCompilerType()
ConstString GetName() const
const ExecutionContextRef & GetExecutionContextRef() const
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_IVAR_OFFSET
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, uint32_t item_bit_size, uint32_t item_bit_offset, ExecutionContextScope *exe_scope=nullptr, bool show_memory_tags=false)
Dumps item_count objects into the stream s.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
void * opaque_compiler_type_t
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eBasicTypeUnsignedShort
@ eBasicTypeUnsignedInt128
@ eBasicTypeUnsignedWChar
@ eBasicTypeLongDoubleComplex
@ eBasicTypeUnsignedLongLong
@ eBasicTypeDoubleComplex
Format
Display format definitions.
@ eFormatCString
NULL terminated C strings.
@ eFormatCharArray
Print characters with no single quotes, used for character arrays that can contain non printable char...
@ eFormatVoid
Do not print this.
@ eFormatComplex
Floating point complex type.
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
@ eFormatComplexInteger
Integer complex type.
@ eFormatFloat128
Disambiguate between 128-bit long double (which uses eFormatFloat) and __float128 (which uses eFormat...
LanguageType
Programming language type.
@ eLanguageTypeC_plus_plus_20
ISO C++:2020.
@ eLanguageTypeC_plus_plus_14
ISO C++:2014.
@ eLanguageTypeC11
ISO C:2011.
@ eLanguageTypeC99
ISO C:1999.
@ eLanguageTypeC_plus_plus_03
ISO C++:2003.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeC_plus_plus_17
ISO C++:2017.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
@ eLanguageTypeC_plus_plus_11
ISO C++:2011.
@ eLanguageTypeC89
ISO C:1989.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
@ eLanguageTypeDylan
Dylan.
std::shared_ptr< lldb_private::Type > TypeSP
@ eTemplateArgumentKindTemplate
@ eTemplateArgumentKindTemplateExpansion
@ eTemplateArgumentKindNull
@ eTemplateArgumentKindNullPtr
@ eTemplateArgumentKindDeclaration
@ eTemplateArgumentKindIntegral
@ eTemplateArgumentKindPack
@ eTemplateArgumentKindType
@ eTemplateArgumentKindStructuralValue
@ eTemplateArgumentKindExpression
Encoding
Register encoding definitions.
@ eEncodingVector
vector registers
@ eEncodingUint
unsigned integer
@ eEncodingSint
signed integer
MemberFunctionKind
Kind of member function.
@ eMemberFunctionKindInstanceMethod
A function that applies to a specific instance.
@ eMemberFunctionKindConstructor
A function used to create instances.
@ eMemberFunctionKindUnknown
Not sure what the type of this is.
@ eMemberFunctionKindDestructor
A function used to tear down existing instances.
@ eMemberFunctionKindStaticMethod
A function that applies to a type rather than any instance.
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Target > TargetSP
static clang::QualType GetQualType(const CompilerType &ct)
static clang::QualType GetCanonicalQualType(const CompilerType &ct)
static bool IsClangType(const CompilerType &ct)
static CompilerType RemoveFastQualifiers(const CompilerType &ct)
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
static llvm::Expected< FunctionCallLabel > fromString(llvm::StringRef label)
Decodes the specified function label into a FunctionCallLabel.
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
void Insert(lldb::LanguageType language)
A type-erased pair of llvm::dwarf::SourceLanguageName and version.