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);
2429 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2431 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2432 named_decl->getDeclName().getAsString().c_str());
2434 printf(
"%20s\n", decl_ctx->getDeclKindName());
2440 if (decl ==
nullptr)
2444 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2446 bool is_injected_class_name =
2447 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2448 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2449 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2450 record_decl->getDeclName().getAsString().c_str(),
2451 is_injected_class_name ?
" (injected class name)" :
"");
2454 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2456 printf(
"%20s: %s\n", decl->getDeclKindName(),
2457 named_decl->getDeclName().getAsString().c_str());
2459 printf(
"%20s\n", decl->getDeclKindName());
2465 clang::Decl *decl) {
2469 ExternalASTSource *ast_source = ast->getExternalSource();
2474 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2475 if (tag_decl->isCompleteDefinition())
2478 if (!tag_decl->hasExternalLexicalStorage())
2481 ast_source->CompleteType(tag_decl);
2483 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2484 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2485 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2486 if (objc_interface_decl->getDefinition())
2489 if (!objc_interface_decl->hasExternalLexicalStorage())
2492 ast_source->CompleteType(objc_interface_decl);
2494 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2524std::optional<ClangASTMetadata>
2530 return std::nullopt;
2533std::optional<ClangASTMetadata>
2539 return std::nullopt;
2561 if (find(mask, type->getTypeClass()) != mask.end())
2563 switch (type->getTypeClass()) {
2566 case clang::Type::Atomic:
2567 type = cast<clang::AtomicType>(type)->getValueType();
2569 case clang::Type::Auto:
2570 case clang::Type::Decltype:
2571 case clang::Type::Paren:
2572 case clang::Type::SubstTemplateTypeParm:
2573 case clang::Type::TemplateSpecialization:
2574 case clang::Type::Typedef:
2575 case clang::Type::TypeOf:
2576 case clang::Type::TypeOfExpr:
2577 case clang::Type::Using:
2578 case clang::Type::PredefinedSugar:
2579 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2593 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2594 switch (type_class) {
2595 case clang::Type::ObjCInterface:
2596 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2598 case clang::Type::ObjCObjectPointer:
2600 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2601 ->getPointeeType());
2602 case clang::Type::Enum:
2603 case clang::Type::Record:
2604 return llvm::cast<clang::TagType>(qual_type)
2606 ->getDefinitionOrSelf();
2618static const clang::RecordType *
2620 assert(qual_type->isRecordType());
2622 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2624 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2628 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2631 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2632 const bool fields_loaded =
2633 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2636 if (is_complete && fields_loaded)
2644 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2645 if (external_ast_source) {
2646 external_ast_source->CompleteType(cxx_record_decl);
2647 if (cxx_record_decl->isCompleteDefinition()) {
2648 cxx_record_decl->field_begin();
2649 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
2661 clang::QualType qual_type) {
2662 assert(qual_type->isEnumeralType());
2665 const clang::EnumType *enum_type =
2666 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2668 auto *tag_decl = enum_type->getAsTagDecl();
2672 if (tag_decl->getDefinition())
2676 if (!tag_decl->hasExternalLexicalStorage())
2680 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2681 if (!external_ast_source)
2684 external_ast_source->CompleteType(tag_decl);
2692static const clang::ObjCObjectType *
2694 assert(qual_type->isObjCObjectType());
2697 const clang::ObjCObjectType *objc_class_type =
2698 llvm::cast<clang::ObjCObjectType>(qual_type);
2700 clang::ObjCInterfaceDecl *class_interface_decl =
2701 objc_class_type->getInterface();
2704 if (!class_interface_decl)
2705 return objc_class_type;
2708 if (class_interface_decl->getDefinition())
2709 return objc_class_type;
2712 if (!class_interface_decl->hasExternalLexicalStorage())
2716 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2717 if (!external_ast_source)
2720 external_ast_source->CompleteType(class_interface_decl);
2721 return objc_class_type;
2725 clang::QualType qual_type) {
2727 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2728 switch (type_class) {
2729 case clang::Type::ConstantArray:
2730 case clang::Type::IncompleteArray:
2731 case clang::Type::VariableArray: {
2732 const clang::ArrayType *array_type =
2733 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2738 case clang::Type::Record: {
2740 return !RT->isIncompleteType();
2745 case clang::Type::Enum: {
2747 return !ET->isIncompleteType();
2751 case clang::Type::ObjCObject:
2752 case clang::Type::ObjCInterface: {
2754 return !OT->isIncompleteType();
2759 case clang::Type::Attributed:
2761 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType());
2763 case clang::Type::MemberPointer:
2766 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2767 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2768 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2771 return !qual_type.getTypePtr()->isIncompleteType();
2786 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2793 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2794 switch (type_class) {
2795 case clang::Type::IncompleteArray:
2796 case clang::Type::VariableArray:
2797 case clang::Type::ConstantArray:
2798 case clang::Type::ExtVector:
2799 case clang::Type::Vector:
2800 case clang::Type::Record:
2801 case clang::Type::ObjCObject:
2802 case clang::Type::ObjCInterface:
2814 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2815 switch (type_class) {
2816 case clang::Type::Record: {
2817 if (
const clang::RecordType *record_type =
2818 llvm::dyn_cast_or_null<clang::RecordType>(
2819 qual_type.getTypePtrOrNull())) {
2820 if (
const clang::RecordDecl *record_decl = record_type->getDecl()) {
2821 return record_decl->isAnonymousStructOrUnion();
2835 uint64_t *size,
bool *is_incomplete) {
2838 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2839 switch (type_class) {
2843 case clang::Type::ConstantArray:
2844 if (element_type_ptr)
2846 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2850 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2852 .getLimitedValue(ULLONG_MAX);
2854 *is_incomplete =
false;
2857 case clang::Type::IncompleteArray:
2858 if (element_type_ptr)
2860 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2866 *is_incomplete =
true;
2869 case clang::Type::VariableArray:
2870 if (element_type_ptr)
2872 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2878 *is_incomplete =
false;
2881 case clang::Type::DependentSizedArray:
2882 if (element_type_ptr)
2885 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2891 *is_incomplete =
false;
2894 if (element_type_ptr)
2895 element_type_ptr->
Clear();
2899 *is_incomplete =
false;
2907 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2908 switch (type_class) {
2909 case clang::Type::Vector: {
2910 const clang::VectorType *vector_type =
2911 qual_type->getAs<clang::VectorType>();
2914 *size = vector_type->getNumElements();
2916 *element_type =
GetType(vector_type->getElementType());
2920 case clang::Type::ExtVector: {
2921 const clang::ExtVectorType *ext_vector_type =
2922 qual_type->getAs<clang::ExtVectorType>();
2923 if (ext_vector_type) {
2925 *size = ext_vector_type->getNumElements();
2929 ext_vector_type->getElementType().getAsOpaquePtr());
2945 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
2948 clang::ObjCInterfaceDecl *result_iface_decl =
2949 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
2951 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
2955 return (ast_metadata->GetISAPtr() != 0);
2959 return GetQualType(type).getUnqualifiedType()->isCharType();
2981 if (!pointee_or_element_clang_type.
IsValid())
2984 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
2985 if (pointee_or_element_clang_type.
IsCharType()) {
2986 if (type_flags.
Test(eTypeIsArray)) {
2989 length = llvm::cast<clang::ConstantArrayType>(
3003 if (
auto pointer_auth = qual_type.getPointerAuth())
3004 return pointer_auth.getKey();
3013 if (
auto pointer_auth = qual_type.getPointerAuth())
3014 return pointer_auth.getExtraDiscriminator();
3023 if (
auto pointer_auth = qual_type.getPointerAuth())
3024 return pointer_auth.isAddressDiscriminated();
3030 auto isFunctionType = [&](clang::QualType qual_type) {
3031 return qual_type->isFunctionType();
3045 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3046 switch (type_class) {
3047 case clang::Type::Record:
3049 const clang::CXXRecordDecl *cxx_record_decl =
3050 qual_type->getAsCXXRecordDecl();
3051 if (cxx_record_decl) {
3052 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3055 const clang::RecordType *record_type =
3056 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3058 if (
const clang::RecordDecl *record_decl =
3059 record_type->getDecl()->getDefinition()) {
3062 clang::RecordDecl::field_iterator field_pos,
3063 field_end = record_decl->field_end();
3064 uint32_t num_fields = 0;
3065 bool is_hva =
false;
3066 bool is_hfa =
false;
3067 clang::QualType base_qual_type;
3068 uint64_t base_bitwidth = 0;
3069 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3071 clang::QualType field_qual_type = field_pos->getType();
3072 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3073 if (field_qual_type->isFloatingType()) {
3074 if (field_qual_type->isComplexType())
3077 if (num_fields == 0)
3078 base_qual_type = field_qual_type;
3083 if (field_qual_type.getTypePtr() !=
3084 base_qual_type.getTypePtr())
3088 }
else if (field_qual_type->isVectorType() ||
3089 field_qual_type->isExtVectorType()) {
3090 if (num_fields == 0) {
3091 base_qual_type = field_qual_type;
3092 base_bitwidth = field_bitwidth;
3097 if (base_bitwidth != field_bitwidth)
3099 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3108 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3125 const clang::FunctionProtoType *func =
3126 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3128 return func->getNumParams();
3135 const size_t index) {
3138 const clang::FunctionProtoType *func =
3139 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3141 if (index < func->getNumParams())
3142 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3150 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3154 if (predicate(qual_type))
3157 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3158 switch (type_class) {
3162 case clang::Type::LValueReference:
3163 case clang::Type::RValueReference: {
3164 const clang::ReferenceType *reference_type =
3165 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3167 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3176 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3177 return qual_type->isMemberFunctionPointerType();
3180 return IsTypeImpl(type, isMemberFunctionPointerType);
3185 auto isMemberDataPointerType = [](clang::QualType qual_type) {
3186 return qual_type->isMemberDataPointerType();
3189 return IsTypeImpl(type, isMemberDataPointerType);
3193 auto isFunctionPointerType = [](clang::QualType qual_type) {
3194 return qual_type->isFunctionPointerType();
3197 return IsTypeImpl(type, isFunctionPointerType);
3203 auto isBlockPointerType = [&](clang::QualType qual_type) {
3204 if (qual_type->isBlockPointerType()) {
3205 if (function_pointer_type_ptr) {
3206 const clang::BlockPointerType *block_pointer_type =
3207 qual_type->castAs<clang::BlockPointerType>();
3208 QualType pointee_type = block_pointer_type->getPointeeType();
3209 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3211 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3228 if (qual_type.isNull())
3237 is_signed = qual_type->isSignedIntegerType();
3245 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3249 is_signed = enum_type->isSignedIntegerOrEnumerationType();
3260 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3264 return enum_type->isScopedEnumeralType();
3275 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3276 switch (type_class) {
3277 case clang::Type::Builtin:
3278 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3281 case clang::BuiltinType::ObjCId:
3282 case clang::BuiltinType::ObjCClass:
3286 case clang::Type::ObjCObjectPointer:
3290 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3294 case clang::Type::BlockPointer:
3297 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3301 case clang::Type::Pointer:
3304 llvm::cast<clang::PointerType>(qual_type)
3308 case clang::Type::MemberPointer:
3311 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3320 pointee_type->
Clear();
3328 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3329 switch (type_class) {
3330 case clang::Type::Builtin:
3331 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3334 case clang::BuiltinType::ObjCId:
3335 case clang::BuiltinType::ObjCClass:
3339 case clang::Type::ObjCObjectPointer:
3343 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3347 case clang::Type::BlockPointer:
3350 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3354 case clang::Type::Pointer:
3357 llvm::cast<clang::PointerType>(qual_type)
3361 case clang::Type::MemberPointer:
3364 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3368 case clang::Type::LValueReference:
3371 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3375 case clang::Type::RValueReference:
3378 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3387 pointee_type->
Clear();
3396 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3398 switch (type_class) {
3399 case clang::Type::LValueReference:
3402 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3408 case clang::Type::RValueReference:
3411 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3423 pointee_type->
Clear();
3432 if (qual_type.isNull())
3435 return qual_type->isFloatingType();
3443 const clang::TagType *tag_type =
3444 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3446 if (clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinition())
3447 return tag_decl->isCompleteDefinition();
3450 const clang::ObjCObjectType *objc_class_type =
3451 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3452 if (objc_class_type) {
3453 clang::ObjCInterfaceDecl *class_interface_decl =
3454 objc_class_type->getInterface();
3455 if (class_interface_decl)
3456 return class_interface_decl->getDefinition() !=
nullptr;
3467 const clang::ObjCObjectPointerType *obj_pointer_type =
3468 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3470 if (obj_pointer_type)
3471 return obj_pointer_type->isObjCClassType();
3486 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3487 return (type_class == clang::Type::Record);
3494 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3495 return (type_class == clang::Type::Enum);
3501 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3502 switch (type_class) {
3503 case clang::Type::Record:
3505 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3512 return cxx_record_decl->isDynamicClass();
3526 bool check_cplusplus,
3528 if (dynamic_pointee_type)
3529 dynamic_pointee_type->
Clear();
3533 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3534 if (dynamic_pointee_type)
3536 type.getAsOpaquePtr());
3539 clang::QualType pointee_qual_type;
3541 switch (qual_type->getTypeClass()) {
3542 case clang::Type::Builtin:
3543 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3544 clang::BuiltinType::ObjCId) {
3545 set_dynamic_pointee_type(qual_type);
3550 case clang::Type::ObjCObjectPointer:
3553 if (
const auto *objc_pointee_type =
3554 qual_type->getPointeeType().getTypePtrOrNull()) {
3555 if (
const auto *objc_object_type =
3556 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3557 objc_pointee_type)) {
3558 if (objc_object_type->isObjCClass())
3562 set_dynamic_pointee_type(
3563 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3566 case clang::Type::Pointer:
3568 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3571 case clang::Type::LValueReference:
3572 case clang::Type::RValueReference:
3574 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3584 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3585 case clang::Type::Builtin:
3586 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3587 case clang::BuiltinType::UnknownAny:
3588 case clang::BuiltinType::Void:
3589 set_dynamic_pointee_type(pointee_qual_type);
3595 case clang::Type::Record: {
3596 if (!check_cplusplus)
3598 clang::CXXRecordDecl *cxx_record_decl =
3599 pointee_qual_type->getAsCXXRecordDecl();
3600 if (!cxx_record_decl)
3604 if (cxx_record_decl->isCompleteDefinition())
3605 success = cxx_record_decl->isDynamicClass();
3607 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3608 std::optional<bool> is_dynamic =
3609 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3611 success = *is_dynamic;
3613 success = cxx_record_decl->isDynamicClass();
3619 set_dynamic_pointee_type(pointee_qual_type);
3623 case clang::Type::ObjCObject:
3624 case clang::Type::ObjCInterface:
3626 set_dynamic_pointee_type(pointee_qual_type);
3641 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3648 ->getTypeClass() == clang::Type::Typedef;
3665 if (
auto *record_decl =
3667 return record_decl->canPassInRegisters();
3673 return TypeSystemClangSupportsLanguage(language);
3676std::optional<std::string>
3679 return std::nullopt;
3682 if (qual_type.isNull())
3683 return std::nullopt;
3685 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3686 if (!cxx_record_decl)
3687 return std::nullopt;
3689 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3697 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3704 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3706 return tag_type->getDecl()->isEntityBeingDefined();
3717 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3718 if (class_type_ptr) {
3719 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3720 const clang::ObjCObjectPointerType *obj_pointer_type =
3721 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3722 if (obj_pointer_type ==
nullptr)
3723 class_type_ptr->
Clear();
3727 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3734 class_type_ptr->
Clear();
3761 {clang::Type::Typedef, clang::Type::Atomic});
3764 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3765 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3772 if (
auto *named_decl = qual_type->getAsTagDecl())
3784 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3785 printing_policy.SuppressTagKeyword =
true;
3786 printing_policy.SuppressScope =
false;
3787 printing_policy.SuppressUnwrittenScope =
true;
3788 printing_policy.SuppressInlineNamespace =
3789 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::All);
3790 return ConstString(qual_type.getAsString(printing_policy));
3799 if (pointee_or_element_clang_type)
3800 pointee_or_element_clang_type->
Clear();
3802 clang::QualType qual_type =
3805 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3806 switch (type_class) {
3807 case clang::Type::Attributed:
3808 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3811 pointee_or_element_clang_type);
3812 case clang::Type::BitInt: {
3813 uint32_t type_flags = eTypeIsScalar | eTypeIsInteger | eTypeHasValue;
3814 if (qual_type->isSignedIntegerType())
3815 type_flags |= eTypeIsSigned;
3819 case clang::Type::Builtin: {
3820 const clang::BuiltinType *builtin_type =
3821 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3823 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3824 switch (builtin_type->getKind()) {
3825 case clang::BuiltinType::ObjCId:
3826 case clang::BuiltinType::ObjCClass:
3827 if (pointee_or_element_clang_type)
3831 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3834 case clang::BuiltinType::ObjCSel:
3835 if (pointee_or_element_clang_type)
3838 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3841 case clang::BuiltinType::Bool:
3842 case clang::BuiltinType::Char_U:
3843 case clang::BuiltinType::UChar:
3844 case clang::BuiltinType::WChar_U:
3845 case clang::BuiltinType::Char16:
3846 case clang::BuiltinType::Char32:
3847 case clang::BuiltinType::UShort:
3848 case clang::BuiltinType::UInt:
3849 case clang::BuiltinType::ULong:
3850 case clang::BuiltinType::ULongLong:
3851 case clang::BuiltinType::UInt128:
3852 case clang::BuiltinType::Char_S:
3853 case clang::BuiltinType::SChar:
3854 case clang::BuiltinType::WChar_S:
3855 case clang::BuiltinType::Short:
3856 case clang::BuiltinType::Int:
3857 case clang::BuiltinType::Long:
3858 case clang::BuiltinType::LongLong:
3859 case clang::BuiltinType::Int128:
3860 case clang::BuiltinType::Float:
3861 case clang::BuiltinType::Double:
3862 case clang::BuiltinType::LongDouble:
3863 builtin_type_flags |= eTypeIsScalar;
3864 if (builtin_type->isInteger()) {
3865 builtin_type_flags |= eTypeIsInteger;
3866 if (builtin_type->isSignedInteger())
3867 builtin_type_flags |= eTypeIsSigned;
3868 }
else if (builtin_type->isFloatingPoint())
3869 builtin_type_flags |= eTypeIsFloat;
3874 return builtin_type_flags;
3877 case clang::Type::BlockPointer:
3878 if (pointee_or_element_clang_type)
3880 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3881 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3883 case clang::Type::Complex: {
3884 uint32_t complex_type_flags =
3885 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3886 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3887 qual_type->getCanonicalTypeInternal());
3889 clang::QualType complex_element_type(complex_type->getElementType());
3890 if (complex_element_type->isIntegerType())
3891 complex_type_flags |= eTypeIsInteger;
3892 else if (complex_element_type->isFloatingType())
3893 complex_type_flags |= eTypeIsFloat;
3895 return complex_type_flags;
3898 case clang::Type::ConstantArray:
3899 case clang::Type::DependentSizedArray:
3900 case clang::Type::IncompleteArray:
3901 case clang::Type::VariableArray:
3902 if (pointee_or_element_clang_type)
3904 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
3907 return eTypeHasChildren | eTypeIsArray;
3909 case clang::Type::DependentName:
3911 case clang::Type::DependentSizedExtVector:
3912 return eTypeHasChildren | eTypeIsVector;
3914 case clang::Type::Enum:
3915 if (pointee_or_element_clang_type)
3917 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
3919 ->getDefinitionOrSelf()
3922 return eTypeIsEnumeration | eTypeHasValue;
3924 case clang::Type::FunctionProto:
3925 return eTypeIsFuncPrototype | eTypeHasValue;
3926 case clang::Type::FunctionNoProto:
3927 return eTypeIsFuncPrototype | eTypeHasValue;
3928 case clang::Type::InjectedClassName:
3931 case clang::Type::LValueReference:
3932 case clang::Type::RValueReference:
3933 if (pointee_or_element_clang_type)
3936 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
3939 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
3941 case clang::Type::MemberPointer:
3942 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
3944 case clang::Type::ObjCObjectPointer:
3945 if (pointee_or_element_clang_type)
3947 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3948 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
3951 case clang::Type::ObjCObject:
3952 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
3953 case clang::Type::ObjCInterface:
3954 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
3956 case clang::Type::Pointer:
3957 if (pointee_or_element_clang_type)
3959 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3960 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
3962 case clang::Type::Record:
3963 if (qual_type->getAsCXXRecordDecl())
3964 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
3966 return eTypeHasChildren | eTypeIsStructUnion;
3968 case clang::Type::SubstTemplateTypeParm:
3969 return eTypeIsTemplate;
3970 case clang::Type::TemplateTypeParm:
3971 return eTypeIsTemplate;
3972 case clang::Type::TemplateSpecialization:
3973 return eTypeIsTemplate;
3975 case clang::Type::Typedef:
3976 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
3978 ->getUnderlyingType())
3980 case clang::Type::UnresolvedUsing:
3983 case clang::Type::ExtVector:
3984 case clang::Type::Vector: {
3985 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
3986 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
3987 qual_type->getCanonicalTypeInternal());
3991 QualType element_type = vector_type->getElementType();
3992 if (element_type.isNull())
3995 if (element_type->isIntegerType())
3996 vector_type_flags |= eTypeIsInteger;
3997 else if (element_type->isFloatingType())
3998 vector_type_flags |= eTypeIsFloat;
3999 return vector_type_flags;
4014 if (qual_type->isAnyPointerType()) {
4015 if (qual_type->isObjCObjectPointerType())
4017 if (qual_type->getPointeeCXXRecordDecl())
4020 clang::QualType pointee_type(qual_type->getPointeeType());
4021 if (pointee_type->getPointeeCXXRecordDecl())
4023 if (pointee_type->isObjCObjectOrInterfaceType())
4025 if (pointee_type->isObjCClassType())
4027 if (pointee_type.getTypePtr() ==
4031 if (qual_type->isObjCObjectOrInterfaceType())
4033 if (qual_type->getAsCXXRecordDecl())
4035 switch (qual_type->getTypeClass()) {
4038 case clang::Type::Builtin:
4039 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4041 case clang::BuiltinType::Void:
4042 case clang::BuiltinType::Bool:
4043 case clang::BuiltinType::Char_U:
4044 case clang::BuiltinType::UChar:
4045 case clang::BuiltinType::WChar_U:
4046 case clang::BuiltinType::Char16:
4047 case clang::BuiltinType::Char32:
4048 case clang::BuiltinType::UShort:
4049 case clang::BuiltinType::UInt:
4050 case clang::BuiltinType::ULong:
4051 case clang::BuiltinType::ULongLong:
4052 case clang::BuiltinType::UInt128:
4053 case clang::BuiltinType::Char_S:
4054 case clang::BuiltinType::SChar:
4055 case clang::BuiltinType::WChar_S:
4056 case clang::BuiltinType::Short:
4057 case clang::BuiltinType::Int:
4058 case clang::BuiltinType::Long:
4059 case clang::BuiltinType::LongLong:
4060 case clang::BuiltinType::Int128:
4061 case clang::BuiltinType::Float:
4062 case clang::BuiltinType::Double:
4063 case clang::BuiltinType::LongDouble:
4066 case clang::BuiltinType::NullPtr:
4069 case clang::BuiltinType::ObjCId:
4070 case clang::BuiltinType::ObjCClass:
4071 case clang::BuiltinType::ObjCSel:
4074 case clang::BuiltinType::Dependent:
4075 case clang::BuiltinType::Overload:
4076 case clang::BuiltinType::BoundMember:
4077 case clang::BuiltinType::UnknownAny:
4081 case clang::Type::Typedef:
4082 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4084 ->getUnderlyingType())
4094 return lldb::eTypeClassInvalid;
4096 clang::QualType qual_type =
4099 switch (qual_type->getTypeClass()) {
4100 case clang::Type::Atomic:
4101 case clang::Type::Auto:
4102 case clang::Type::CountAttributed:
4103 case clang::Type::Decltype:
4104 case clang::Type::Paren:
4105 case clang::Type::TypeOf:
4106 case clang::Type::TypeOfExpr:
4107 case clang::Type::Using:
4108 case clang::Type::PredefinedSugar:
4109 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4110 case clang::Type::LateParsedAttr:
4111 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
4112 "that is resolved before the AST is finalized.");
4113 case clang::Type::UnaryTransform:
4115 case clang::Type::FunctionNoProto:
4116 return lldb::eTypeClassFunction;
4117 case clang::Type::FunctionProto:
4118 return lldb::eTypeClassFunction;
4119 case clang::Type::IncompleteArray:
4120 return lldb::eTypeClassArray;
4121 case clang::Type::VariableArray:
4122 return lldb::eTypeClassArray;
4123 case clang::Type::ConstantArray:
4124 return lldb::eTypeClassArray;
4125 case clang::Type::DependentSizedArray:
4126 return lldb::eTypeClassArray;
4127 case clang::Type::ArrayParameter:
4128 return lldb::eTypeClassArray;
4129 case clang::Type::DependentSizedExtVector:
4130 return lldb::eTypeClassVector;
4131 case clang::Type::DependentVector:
4132 return lldb::eTypeClassVector;
4133 case clang::Type::ExtVector:
4134 return lldb::eTypeClassVector;
4135 case clang::Type::Vector:
4136 return lldb::eTypeClassVector;
4137 case clang::Type::Builtin:
4139 case clang::Type::BitInt:
4140 case clang::Type::DependentBitInt:
4141 case clang::Type::OverflowBehavior:
4142 return lldb::eTypeClassBuiltin;
4143 case clang::Type::ObjCObjectPointer:
4144 return lldb::eTypeClassObjCObjectPointer;
4145 case clang::Type::BlockPointer:
4146 return lldb::eTypeClassBlockPointer;
4147 case clang::Type::Pointer:
4148 return lldb::eTypeClassPointer;
4149 case clang::Type::LValueReference:
4150 return lldb::eTypeClassReference;
4151 case clang::Type::RValueReference:
4152 return lldb::eTypeClassReference;
4153 case clang::Type::MemberPointer:
4154 return lldb::eTypeClassMemberPointer;
4155 case clang::Type::Complex:
4156 if (qual_type->isComplexType())
4157 return lldb::eTypeClassComplexFloat;
4159 return lldb::eTypeClassComplexInteger;
4160 case clang::Type::ObjCObject:
4161 return lldb::eTypeClassObjCObject;
4162 case clang::Type::ObjCInterface:
4163 return lldb::eTypeClassObjCInterface;
4164 case clang::Type::Record: {
4165 const clang::RecordType *record_type =
4166 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4167 const clang::RecordDecl *record_decl = record_type->getDecl();
4168 if (record_decl->isUnion())
4169 return lldb::eTypeClassUnion;
4170 else if (record_decl->isStruct())
4171 return lldb::eTypeClassStruct;
4173 return lldb::eTypeClassClass;
4175 case clang::Type::Enum:
4176 return lldb::eTypeClassEnumeration;
4177 case clang::Type::Typedef:
4178 return lldb::eTypeClassTypedef;
4179 case clang::Type::UnresolvedUsing:
4182 case clang::Type::Attributed:
4183 case clang::Type::BTFTagAttributed:
4185 case clang::Type::TemplateTypeParm:
4187 case clang::Type::SubstTemplateTypeParm:
4189 case clang::Type::SubstTemplateTypeParmPack:
4191 case clang::Type::InjectedClassName:
4193 case clang::Type::DependentName:
4195 case clang::Type::PackExpansion:
4198 case clang::Type::TemplateSpecialization:
4200 case clang::Type::DeducedTemplateSpecialization:
4202 case clang::Type::Pipe:
4206 case clang::Type::Decayed:
4208 case clang::Type::Adjusted:
4210 case clang::Type::ObjCTypeParam:
4213 case clang::Type::DependentAddressSpace:
4215 case clang::Type::MacroQualified:
4219 case clang::Type::ConstantMatrix:
4220 case clang::Type::DependentSizedMatrix:
4224 case clang::Type::PackIndexing:
4227 case clang::Type::HLSLAttributedResource:
4229 case clang::Type::HLSLInlineSpirv:
4231 case clang::Type::SubstBuiltinTemplatePack:
4235 return lldb::eTypeClassOther;
4240 return GetQualType(type).getQualifiers().getCVRQualifiers();
4252 const clang::Type *array_eletype =
4253 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4258 return GetType(clang::QualType(array_eletype, 0));
4269 return GetType(ast_ctx.getConstantArrayType(
4270 qual_type, llvm::APInt(64, size),
nullptr,
4271 clang::ArraySizeModifier::Normal, 0));
4273 return GetType(ast_ctx.getIncompleteArrayType(
4274 qual_type, clang::ArraySizeModifier::Normal, 0));
4288 clang::QualType qual_type) {
4289 if (qual_type->isPointerType())
4290 qual_type = ast->getPointerType(
4292 else if (
const ConstantArrayType *arr =
4293 ast->getAsConstantArrayType(qual_type)) {
4294 qual_type = ast->getConstantArrayType(
4296 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4297 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4299 qual_type = qual_type.getUnqualifiedType();
4300 qual_type.removeLocalConst();
4301 qual_type.removeLocalRestrict();
4302 qual_type.removeLocalVolatile();
4324 const clang::FunctionProtoType *func =
4327 return func->getNumParams();
4335 const clang::FunctionProtoType *func =
4336 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4338 const uint32_t num_args = func->getNumParams();
4340 return GetType(func->getParamType(idx));
4350 const clang::FunctionProtoType *func =
4351 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4353 return GetType(func->getReturnType());
4360 size_t num_functions = 0;
4363 switch (qual_type->getTypeClass()) {
4364 case clang::Type::Record:
4366 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4367 num_functions = std::distance(cxx_record_decl->method_begin(),
4368 cxx_record_decl->method_end());
4371 case clang::Type::ObjCObjectPointer: {
4372 const clang::ObjCObjectPointerType *objc_class_type =
4373 qual_type->castAs<clang::ObjCObjectPointerType>();
4374 const clang::ObjCInterfaceType *objc_interface_type =
4375 objc_class_type->getInterfaceType();
4376 if (objc_interface_type &&
4378 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4379 clang::ObjCInterfaceDecl *class_interface_decl =
4380 objc_interface_type->getDecl();
4381 if (class_interface_decl) {
4382 num_functions = std::distance(class_interface_decl->meth_begin(),
4383 class_interface_decl->meth_end());
4389 case clang::Type::ObjCObject:
4390 case clang::Type::ObjCInterface:
4392 const clang::ObjCObjectType *objc_class_type =
4393 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4394 if (objc_class_type) {
4395 clang::ObjCInterfaceDecl *class_interface_decl =
4396 objc_class_type->getInterface();
4397 if (class_interface_decl)
4398 num_functions = std::distance(class_interface_decl->meth_begin(),
4399 class_interface_decl->meth_end());
4408 return num_functions;
4420 switch (qual_type->getTypeClass()) {
4421 case clang::Type::Record:
4423 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4424 auto method_iter = cxx_record_decl->method_begin();
4425 auto method_end = cxx_record_decl->method_end();
4427 static_cast<size_t>(std::distance(method_iter, method_end))) {
4428 std::advance(method_iter, idx);
4429 clang::CXXMethodDecl *cxx_method_decl =
4430 method_iter->getCanonicalDecl();
4431 if (cxx_method_decl) {
4432 name = cxx_method_decl->getDeclName().getAsString();
4433 if (cxx_method_decl->isStatic())
4435 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4437 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4441 clang_type =
GetType(cxx_method_decl->getType());
4449 case clang::Type::ObjCObjectPointer: {
4450 const clang::ObjCObjectPointerType *objc_class_type =
4451 qual_type->castAs<clang::ObjCObjectPointerType>();
4452 const clang::ObjCInterfaceType *objc_interface_type =
4453 objc_class_type->getInterfaceType();
4454 if (objc_interface_type &&
4456 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4457 clang::ObjCInterfaceDecl *class_interface_decl =
4458 objc_interface_type->getDecl();
4459 if (class_interface_decl) {
4460 auto method_iter = class_interface_decl->meth_begin();
4461 auto method_end = class_interface_decl->meth_end();
4463 static_cast<size_t>(std::distance(method_iter, method_end))) {
4464 std::advance(method_iter, idx);
4465 clang::ObjCMethodDecl *objc_method_decl =
4466 method_iter->getCanonicalDecl();
4467 if (objc_method_decl) {
4469 name = objc_method_decl->getSelector().getAsString();
4470 if (objc_method_decl->isClassMethod())
4481 case clang::Type::ObjCObject:
4482 case clang::Type::ObjCInterface:
4484 const clang::ObjCObjectType *objc_class_type =
4485 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4486 if (objc_class_type) {
4487 clang::ObjCInterfaceDecl *class_interface_decl =
4488 objc_class_type->getInterface();
4489 if (class_interface_decl) {
4490 auto method_iter = class_interface_decl->meth_begin();
4491 auto method_end = class_interface_decl->meth_end();
4493 static_cast<size_t>(std::distance(method_iter, method_end))) {
4494 std::advance(method_iter, idx);
4495 clang::ObjCMethodDecl *objc_method_decl =
4496 method_iter->getCanonicalDecl();
4497 if (objc_method_decl) {
4499 name = objc_method_decl->getSelector().getAsString();
4500 if (objc_method_decl->isClassMethod())
4533 return GetType(qual_type.getTypePtr()->getPointeeType());
4543 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4544 case clang::Type::ObjCObject:
4545 case clang::Type::ObjCInterface:
4592 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4593 clang::QualType result =
4594 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4604 result.addVolatile();
4614 result.addRestrict();
4623 if (type && typedef_name && typedef_name[0]) {
4627 clang::DeclContext *decl_ctx =
4632 clang::TypedefDecl *decl =
4633 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4634 decl->setDeclContext(decl_ctx);
4635 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4636 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4637 decl_ctx->addDecl(decl);
4640 clang::TagDecl *tdecl =
nullptr;
4641 if (!qual_type.isNull()) {
4642 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4643 tdecl = rt->getDecl();
4644 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4645 tdecl = et->getDecl();
4651 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4652 tdecl->setTypedefNameForAnonDecl(decl);
4654 decl->setAccess(clang::AS_public);
4657 NestedNameSpecifier Qualifier =
4658 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4660 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4668 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4671 return GetType(typedef_type->getDecl()->getUnderlyingType());
4684 const FunctionType::ExtInfo generic_ext_info(
4693 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4698const llvm::fltSemantics &
4701 const size_t bit_size = byte_size * 8;
4702 if (bit_size == ast.getTypeSize(ast.FloatTy))
4703 return ast.getFloatTypeSemantics(ast.FloatTy);
4704 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4705 return ast.getFloatTypeSemantics(ast.DoubleTy);
4707 bit_size == ast.getTypeSize(ast.Float128Ty))
4708 return ast.getFloatTypeSemantics(ast.Float128Ty);
4709 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4710 bit_size == llvm::APFloat::semanticsSizeInBits(
4711 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4712 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4713 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4714 return ast.getFloatTypeSemantics(ast.HalfTy);
4715 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4716 return ast.getFloatTypeSemantics(ast.Float128Ty);
4717 return llvm::APFloatBase::Bogus();
4720llvm::Expected<uint64_t>
4723 assert(qual_type->isObjCObjectOrInterfaceType());
4728 if (std::optional<uint64_t> bit_size =
4729 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4733 static bool g_printed =
false;
4738 llvm::outs() <<
"warning: trying to determine the size of type ";
4740 llvm::outs() <<
"without a valid ExecutionContext. this is not "
4741 "reliable. please file a bug against LLDB.\n";
4742 llvm::outs() <<
"backtrace:\n";
4743 llvm::sys::PrintStackTrace(llvm::outs());
4744 llvm::outs() <<
"\n";
4753llvm::Expected<uint64_t>
4756 const bool base_name_only =
true;
4758 return llvm::createStringError(
4759 "could not complete type %s",
4763 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4764 switch (type_class) {
4765 case clang::Type::ConstantArray:
4766 case clang::Type::FunctionProto:
4767 case clang::Type::Record:
4769 case clang::Type::ObjCInterface:
4770 case clang::Type::ObjCObject:
4772 case clang::Type::IncompleteArray: {
4773 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4776 qual_type->getArrayElementTypeNoTypeQual()
4777 ->getCanonicalTypeUnqualified());
4782 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4786 return llvm::createStringError(
4787 "could not get size of type %s",
4791std::optional<size_t>
4805 switch (qual_type->getTypeClass()) {
4806 case clang::Type::Atomic:
4807 case clang::Type::Auto:
4808 case clang::Type::CountAttributed:
4809 case clang::Type::Decltype:
4810 case clang::Type::Paren:
4811 case clang::Type::Typedef:
4812 case clang::Type::TypeOf:
4813 case clang::Type::TypeOfExpr:
4814 case clang::Type::Using:
4815 case clang::Type::PredefinedSugar:
4816 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4817 case clang::Type::LateParsedAttr:
4818 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
4819 "that is resolved before the AST is finalized.");
4821 case clang::Type::UnaryTransform:
4824 case clang::Type::FunctionNoProto:
4825 case clang::Type::FunctionProto:
4828 case clang::Type::IncompleteArray:
4829 case clang::Type::VariableArray:
4830 case clang::Type::ArrayParameter:
4833 case clang::Type::ConstantArray:
4836 case clang::Type::DependentVector:
4837 case clang::Type::ExtVector:
4838 case clang::Type::Vector:
4841 case clang::Type::BitInt:
4842 case clang::Type::DependentBitInt:
4843 case clang::Type::OverflowBehavior:
4847 case clang::Type::Builtin:
4848 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4849 case clang::BuiltinType::Void:
4852 case clang::BuiltinType::Char_S:
4853 case clang::BuiltinType::SChar:
4854 case clang::BuiltinType::WChar_S:
4855 case clang::BuiltinType::Short:
4856 case clang::BuiltinType::Int:
4857 case clang::BuiltinType::Long:
4858 case clang::BuiltinType::LongLong:
4859 case clang::BuiltinType::Int128:
4862 case clang::BuiltinType::Bool:
4863 case clang::BuiltinType::Char_U:
4864 case clang::BuiltinType::UChar:
4865 case clang::BuiltinType::WChar_U:
4866 case clang::BuiltinType::Char8:
4867 case clang::BuiltinType::Char16:
4868 case clang::BuiltinType::Char32:
4869 case clang::BuiltinType::UShort:
4870 case clang::BuiltinType::UInt:
4871 case clang::BuiltinType::ULong:
4872 case clang::BuiltinType::ULongLong:
4873 case clang::BuiltinType::UInt128:
4877 case clang::BuiltinType::ShortAccum:
4878 case clang::BuiltinType::Accum:
4879 case clang::BuiltinType::LongAccum:
4880 case clang::BuiltinType::UShortAccum:
4881 case clang::BuiltinType::UAccum:
4882 case clang::BuiltinType::ULongAccum:
4883 case clang::BuiltinType::ShortFract:
4884 case clang::BuiltinType::Fract:
4885 case clang::BuiltinType::LongFract:
4886 case clang::BuiltinType::UShortFract:
4887 case clang::BuiltinType::UFract:
4888 case clang::BuiltinType::ULongFract:
4889 case clang::BuiltinType::SatShortAccum:
4890 case clang::BuiltinType::SatAccum:
4891 case clang::BuiltinType::SatLongAccum:
4892 case clang::BuiltinType::SatUShortAccum:
4893 case clang::BuiltinType::SatUAccum:
4894 case clang::BuiltinType::SatULongAccum:
4895 case clang::BuiltinType::SatShortFract:
4896 case clang::BuiltinType::SatFract:
4897 case clang::BuiltinType::SatLongFract:
4898 case clang::BuiltinType::SatUShortFract:
4899 case clang::BuiltinType::SatUFract:
4900 case clang::BuiltinType::SatULongFract:
4903 case clang::BuiltinType::Half:
4904 case clang::BuiltinType::Float:
4905 case clang::BuiltinType::Float16:
4906 case clang::BuiltinType::Float128:
4907 case clang::BuiltinType::Double:
4908 case clang::BuiltinType::LongDouble:
4909 case clang::BuiltinType::BFloat16:
4910 case clang::BuiltinType::Ibm128:
4913 case clang::BuiltinType::ObjCClass:
4914 case clang::BuiltinType::ObjCId:
4915 case clang::BuiltinType::ObjCSel:
4918 case clang::BuiltinType::NullPtr:
4921 case clang::BuiltinType::Kind::ARCUnbridgedCast:
4922 case clang::BuiltinType::Kind::BoundMember:
4923 case clang::BuiltinType::Kind::BuiltinFn:
4924 case clang::BuiltinType::Kind::Dependent:
4925 case clang::BuiltinType::Kind::OCLClkEvent:
4926 case clang::BuiltinType::Kind::OCLEvent:
4927 case clang::BuiltinType::Kind::OCLImage1dRO:
4928 case clang::BuiltinType::Kind::OCLImage1dWO:
4929 case clang::BuiltinType::Kind::OCLImage1dRW:
4930 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
4931 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
4932 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
4933 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
4934 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
4935 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
4936 case clang::BuiltinType::Kind::OCLImage2dRO:
4937 case clang::BuiltinType::Kind::OCLImage2dWO:
4938 case clang::BuiltinType::Kind::OCLImage2dRW:
4939 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
4940 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
4941 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
4942 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
4943 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
4944 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
4945 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
4946 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
4947 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
4948 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
4949 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
4950 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
4951 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
4952 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
4953 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
4954 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
4955 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
4956 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
4957 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
4958 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
4959 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
4960 case clang::BuiltinType::Kind::OCLImage3dRO:
4961 case clang::BuiltinType::Kind::OCLImage3dWO:
4962 case clang::BuiltinType::Kind::OCLImage3dRW:
4963 case clang::BuiltinType::Kind::OCLQueue:
4964 case clang::BuiltinType::Kind::OCLReserveID:
4965 case clang::BuiltinType::Kind::OCLSampler:
4966 case clang::BuiltinType::Kind::HLSLResource:
4967 case clang::BuiltinType::Kind::ArraySection:
4968 case clang::BuiltinType::Kind::OMPArrayShaping:
4969 case clang::BuiltinType::Kind::OMPIterator:
4970 case clang::BuiltinType::Kind::Overload:
4971 case clang::BuiltinType::Kind::PseudoObject:
4972 case clang::BuiltinType::Kind::UnknownAny:
4975 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
4976 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
4977 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
4978 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
4979 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
4980 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
4981 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
4982 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
4983 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
4984 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
4985 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
4986 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
4990 case clang::BuiltinType::VectorPair:
4991 case clang::BuiltinType::VectorQuad:
4992 case clang::BuiltinType::DMR1024:
4993 case clang::BuiltinType::DMR2048:
4997#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
4998#include "clang/Basic/AArch64ACLETypes.def"
5002#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5003#include "clang/Basic/RISCVVTypes.def"
5007 case clang::BuiltinType::WasmExternRef:
5010 case clang::BuiltinType::IncompleteMatrixIdx:
5013 case clang::BuiltinType::UnresolvedTemplate:
5017#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
5018 case clang::BuiltinType::Id:
5019#include "clang/Basic/AMDGPUTypes.def"
5023#define SPIRV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5024#include "clang/Basic/SPIRVTypes.def"
5030 case clang::Type::ObjCObjectPointer:
5031 case clang::Type::BlockPointer:
5032 case clang::Type::Pointer:
5033 case clang::Type::LValueReference:
5034 case clang::Type::RValueReference:
5035 case clang::Type::MemberPointer:
5037 case clang::Type::Complex: {
5039 if (qual_type->isComplexType())
5042 const clang::ComplexType *complex_type =
5043 qual_type->getAsComplexIntegerType();
5052 case clang::Type::ObjCInterface:
5054 case clang::Type::Record:
5056 case clang::Type::Enum:
5057 return qual_type->isUnsignedIntegerOrEnumerationType()
5060 case clang::Type::DependentSizedArray:
5061 case clang::Type::DependentSizedExtVector:
5062 case clang::Type::UnresolvedUsing:
5063 case clang::Type::Attributed:
5064 case clang::Type::BTFTagAttributed:
5065 case clang::Type::TemplateTypeParm:
5066 case clang::Type::SubstTemplateTypeParm:
5067 case clang::Type::SubstTemplateTypeParmPack:
5068 case clang::Type::InjectedClassName:
5069 case clang::Type::DependentName:
5070 case clang::Type::PackExpansion:
5071 case clang::Type::ObjCObject:
5073 case clang::Type::TemplateSpecialization:
5074 case clang::Type::DeducedTemplateSpecialization:
5075 case clang::Type::Adjusted:
5076 case clang::Type::Pipe:
5080 case clang::Type::Decayed:
5082 case clang::Type::ObjCTypeParam:
5085 case clang::Type::DependentAddressSpace:
5087 case clang::Type::MacroQualified:
5090 case clang::Type::ConstantMatrix:
5091 case clang::Type::DependentSizedMatrix:
5095 case clang::Type::PackIndexing:
5098 case clang::Type::HLSLAttributedResource:
5100 case clang::Type::HLSLInlineSpirv:
5102 case clang::Type::SubstBuiltinTemplatePack:
5115 switch (qual_type->getTypeClass()) {
5116 case clang::Type::Atomic:
5117 case clang::Type::Auto:
5118 case clang::Type::CountAttributed:
5119 case clang::Type::Decltype:
5120 case clang::Type::Paren:
5121 case clang::Type::Typedef:
5122 case clang::Type::TypeOf:
5123 case clang::Type::TypeOfExpr:
5124 case clang::Type::Using:
5125 case clang::Type::PredefinedSugar:
5126 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5127 case clang::Type::LateParsedAttr:
5128 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
5129 "that is resolved before the AST is finalized.");
5130 case clang::Type::UnaryTransform:
5133 case clang::Type::FunctionNoProto:
5134 case clang::Type::FunctionProto:
5137 case clang::Type::IncompleteArray:
5138 case clang::Type::VariableArray:
5139 case clang::Type::ArrayParameter:
5142 case clang::Type::ConstantArray:
5145 case clang::Type::DependentVector:
5146 case clang::Type::ExtVector:
5147 case clang::Type::Vector:
5150 case clang::Type::BitInt:
5151 case clang::Type::DependentBitInt:
5152 case clang::Type::OverflowBehavior:
5156 case clang::Type::Builtin:
5157 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5158 case clang::BuiltinType::UnknownAny:
5159 case clang::BuiltinType::Void:
5160 case clang::BuiltinType::BoundMember:
5163 case clang::BuiltinType::Bool:
5165 case clang::BuiltinType::Char_S:
5166 case clang::BuiltinType::SChar:
5167 case clang::BuiltinType::WChar_S:
5168 case clang::BuiltinType::Char_U:
5169 case clang::BuiltinType::UChar:
5170 case clang::BuiltinType::WChar_U:
5172 case clang::BuiltinType::Char8:
5174 case clang::BuiltinType::Char16:
5176 case clang::BuiltinType::Char32:
5178 case clang::BuiltinType::UShort:
5180 case clang::BuiltinType::Short:
5182 case clang::BuiltinType::UInt:
5184 case clang::BuiltinType::Int:
5186 case clang::BuiltinType::ULong:
5188 case clang::BuiltinType::Long:
5190 case clang::BuiltinType::ULongLong:
5192 case clang::BuiltinType::LongLong:
5194 case clang::BuiltinType::UInt128:
5196 case clang::BuiltinType::Int128:
5198 case clang::BuiltinType::Half:
5199 case clang::BuiltinType::Float:
5200 case clang::BuiltinType::Double:
5201 case clang::BuiltinType::LongDouble:
5203 case clang::BuiltinType::Float128:
5209 case clang::Type::ObjCObjectPointer:
5211 case clang::Type::BlockPointer:
5213 case clang::Type::Pointer:
5215 case clang::Type::LValueReference:
5216 case clang::Type::RValueReference:
5218 case clang::Type::MemberPointer:
5220 case clang::Type::Complex: {
5221 if (qual_type->isComplexType())
5226 case clang::Type::ObjCInterface:
5228 case clang::Type::Record:
5230 case clang::Type::Enum:
5232 case clang::Type::DependentSizedArray:
5233 case clang::Type::DependentSizedExtVector:
5234 case clang::Type::UnresolvedUsing:
5235 case clang::Type::Attributed:
5236 case clang::Type::BTFTagAttributed:
5237 case clang::Type::TemplateTypeParm:
5238 case clang::Type::SubstTemplateTypeParm:
5239 case clang::Type::SubstTemplateTypeParmPack:
5240 case clang::Type::InjectedClassName:
5241 case clang::Type::DependentName:
5242 case clang::Type::PackExpansion:
5243 case clang::Type::ObjCObject:
5245 case clang::Type::TemplateSpecialization:
5246 case clang::Type::DeducedTemplateSpecialization:
5247 case clang::Type::Adjusted:
5248 case clang::Type::Pipe:
5252 case clang::Type::Decayed:
5254 case clang::Type::ObjCTypeParam:
5257 case clang::Type::DependentAddressSpace:
5259 case clang::Type::MacroQualified:
5263 case clang::Type::ConstantMatrix:
5264 case clang::Type::DependentSizedMatrix:
5268 case clang::Type::PackIndexing:
5271 case clang::Type::HLSLAttributedResource:
5273 case clang::Type::HLSLInlineSpirv:
5275 case clang::Type::SubstBuiltinTemplatePack:
5283 while (class_interface_decl) {
5284 if (class_interface_decl->ivar_size() > 0)
5287 class_interface_decl = class_interface_decl->getSuperClass();
5292static std::optional<SymbolFile::ArrayInfo>
5294 clang::QualType qual_type,
5296 if (qual_type->isIncompleteArrayType())
5297 if (std::optional<ClangASTMetadata> metadata =
5301 return std::nullopt;
5304llvm::Expected<uint32_t>
5306 bool omit_empty_base_classes,
5309 return llvm::createStringError(
"invalid clang type");
5311 uint32_t num_children = 0;
5313 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5314 switch (type_class) {
5315 case clang::Type::Builtin:
5316 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5317 case clang::BuiltinType::ObjCId:
5318 case clang::BuiltinType::ObjCClass:
5327 case clang::Type::Complex:
5329 case clang::Type::Record:
5331 const clang::RecordType *record_type =
5332 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5333 const clang::RecordDecl *record_decl =
5334 record_type->getDecl()->getDefinitionOrSelf();
5335 const clang::CXXRecordDecl *cxx_record_decl =
5336 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5340 num_children += std::distance(record_decl->field_begin(),
5341 record_decl->field_end());
5343 return llvm::createStringError(
5346 case clang::Type::ObjCObject:
5347 case clang::Type::ObjCInterface:
5349 const clang::ObjCObjectType *objc_class_type =
5350 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5351 assert(objc_class_type);
5352 if (objc_class_type) {
5353 clang::ObjCInterfaceDecl *class_interface_decl =
5354 objc_class_type->getInterface();
5356 if (class_interface_decl) {
5358 clang::ObjCInterfaceDecl *superclass_interface_decl =
5359 class_interface_decl->getSuperClass();
5360 if (superclass_interface_decl) {
5361 if (omit_empty_base_classes) {
5368 num_children += class_interface_decl->ivar_size();
5374 case clang::Type::LValueReference:
5375 case clang::Type::RValueReference:
5376 case clang::Type::ObjCObjectPointer: {
5379 uint32_t num_pointee_children = 0;
5381 auto num_children_or_err =
5382 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5383 if (!num_children_or_err)
5384 return num_children_or_err;
5385 num_pointee_children = *num_children_or_err;
5388 if (num_pointee_children == 0)
5391 num_children = num_pointee_children;
5394 case clang::Type::Vector:
5395 case clang::Type::ExtVector:
5397 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5400 case clang::Type::ConstantArray:
5401 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5405 case clang::Type::IncompleteArray:
5406 if (
auto array_info =
5409 num_children = array_info->element_orders.size()
5410 ? array_info->element_orders.back().value_or(0)
5414 case clang::Type::Pointer: {
5415 const clang::PointerType *pointer_type =
5416 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5417 clang::QualType pointee_type(pointer_type->getPointeeType());
5419 uint32_t num_pointee_children = 0;
5421 auto num_children_or_err =
5422 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5423 if (!num_children_or_err)
5424 return num_children_or_err;
5425 num_pointee_children = *num_children_or_err;
5427 if (num_pointee_children == 0) {
5432 num_children = num_pointee_children;
5438 return num_children;
5445 if (name_ref.consume_front(
"unsigned _BitInt(") ||
5446 name_ref.consume_front(
"_BitInt(")) {
5448 if (name_ref.consumeInteger(10, bit_size))
5451 if (!name_ref.consume_front(
")"))
5455 name.
GetStringRef().starts_with(
"unsigned"), bit_size));
5464 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5465 if (type_class == clang::Type::Builtin) {
5466 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5467 case clang::BuiltinType::Void:
5469 case clang::BuiltinType::Bool:
5471 case clang::BuiltinType::Char_S:
5473 case clang::BuiltinType::Char_U:
5475 case clang::BuiltinType::Char8:
5477 case clang::BuiltinType::Char16:
5479 case clang::BuiltinType::Char32:
5481 case clang::BuiltinType::UChar:
5483 case clang::BuiltinType::SChar:
5485 case clang::BuiltinType::WChar_S:
5487 case clang::BuiltinType::WChar_U:
5489 case clang::BuiltinType::Short:
5491 case clang::BuiltinType::UShort:
5493 case clang::BuiltinType::Int:
5495 case clang::BuiltinType::UInt:
5497 case clang::BuiltinType::Long:
5499 case clang::BuiltinType::ULong:
5501 case clang::BuiltinType::LongLong:
5503 case clang::BuiltinType::ULongLong:
5505 case clang::BuiltinType::Int128:
5507 case clang::BuiltinType::UInt128:
5510 case clang::BuiltinType::Half:
5512 case clang::BuiltinType::Float:
5514 case clang::BuiltinType::Double:
5516 case clang::BuiltinType::LongDouble:
5518 case clang::BuiltinType::Float128:
5521 case clang::BuiltinType::NullPtr:
5523 case clang::BuiltinType::ObjCId:
5525 case clang::BuiltinType::ObjCClass:
5527 case clang::BuiltinType::ObjCSel:
5541 const llvm::APSInt &value)>
const &callback) {
5542 const clang::EnumType *enum_type =
5545 const clang::EnumDecl *enum_decl =
5546 enum_type->getDecl()->getDefinitionOrSelf();
5550 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5551 for (enum_pos = enum_decl->enumerator_begin(),
5552 enum_end_pos = enum_decl->enumerator_end();
5553 enum_pos != enum_end_pos; ++enum_pos) {
5555 if (!callback(integer_type, name, enum_pos->getInitVal()))
5562#pragma mark Aggregate Types
5570 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5571 switch (type_class) {
5572 case clang::Type::Record:
5574 const clang::RecordType *record_type =
5575 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5577 clang::RecordDecl *record_decl =
5578 record_type->getDecl()->getDefinition();
5580 count = std::distance(record_decl->field_begin(),
5581 record_decl->field_end());
5587 case clang::Type::ObjCObjectPointer: {
5588 const clang::ObjCObjectPointerType *objc_class_type =
5589 qual_type->castAs<clang::ObjCObjectPointerType>();
5590 const clang::ObjCInterfaceType *objc_interface_type =
5591 objc_class_type->getInterfaceType();
5592 if (objc_interface_type &&
5594 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5595 clang::ObjCInterfaceDecl *class_interface_decl =
5596 objc_interface_type->getDecl();
5597 if (class_interface_decl) {
5598 count = class_interface_decl->ivar_size();
5604 case clang::Type::ObjCObject:
5605 case clang::Type::ObjCInterface:
5607 const clang::ObjCObjectType *objc_class_type =
5608 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5609 if (objc_class_type) {
5610 clang::ObjCInterfaceDecl *class_interface_decl =
5611 objc_class_type->getInterface();
5613 if (class_interface_decl)
5614 count = class_interface_decl->ivar_size();
5627 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5628 std::string &name, uint64_t *bit_offset_ptr,
5629 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5630 if (class_interface_decl) {
5631 if (idx < (class_interface_decl->ivar_size())) {
5632 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5633 ivar_end = class_interface_decl->ivar_end();
5634 uint32_t ivar_idx = 0;
5636 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5637 ++ivar_pos, ++ivar_idx) {
5638 if (ivar_idx == idx) {
5639 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5641 clang::QualType ivar_qual_type(ivar_decl->getType());
5643 name.assign(ivar_decl->getNameAsString());
5645 if (bit_offset_ptr) {
5646 const clang::ASTRecordLayout &interface_layout =
5647 ast->getASTObjCInterfaceLayout(class_interface_decl);
5648 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5651 const bool is_bitfield = ivar_pos->isBitField();
5653 if (bitfield_bit_size_ptr) {
5654 *bitfield_bit_size_ptr = 0;
5656 if (is_bitfield && ast) {
5657 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5658 clang::Expr::EvalResult result;
5659 if (bitfield_bit_size_expr &&
5660 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5661 llvm::APSInt bitfield_apsint = result.Val.getInt();
5662 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5666 if (is_bitfield_ptr)
5667 *is_bitfield_ptr = is_bitfield;
5669 return ivar_qual_type.getAsOpaquePtr();
5678 size_t idx, std::string &name,
5679 uint64_t *bit_offset_ptr,
5680 uint32_t *bitfield_bit_size_ptr,
5681 bool *is_bitfield_ptr) {
5686 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5687 switch (type_class) {
5688 case clang::Type::Record:
5690 const clang::RecordType *record_type =
5691 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5692 const clang::RecordDecl *record_decl =
5693 record_type->getDecl()->getDefinitionOrSelf();
5694 uint32_t field_idx = 0;
5695 clang::RecordDecl::field_iterator field, field_end;
5696 for (field = record_decl->field_begin(),
5697 field_end = record_decl->field_end();
5698 field != field_end; ++field, ++field_idx) {
5699 if (idx == field_idx) {
5702 name.assign(field->getNameAsString());
5706 if (bit_offset_ptr) {
5707 const clang::ASTRecordLayout &record_layout =
5709 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5712 const bool is_bitfield = field->isBitField();
5714 if (bitfield_bit_size_ptr) {
5715 *bitfield_bit_size_ptr = 0;
5718 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5719 clang::Expr::EvalResult result;
5720 if (bitfield_bit_size_expr &&
5721 bitfield_bit_size_expr->EvaluateAsInt(result,
5723 llvm::APSInt bitfield_apsint = result.Val.getInt();
5724 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5728 if (is_bitfield_ptr)
5729 *is_bitfield_ptr = is_bitfield;
5731 return GetType(field->getType());
5737 case clang::Type::ObjCObjectPointer: {
5738 const clang::ObjCObjectPointerType *objc_class_type =
5739 qual_type->castAs<clang::ObjCObjectPointerType>();
5740 const clang::ObjCInterfaceType *objc_interface_type =
5741 objc_class_type->getInterfaceType();
5742 if (objc_interface_type &&
5744 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5745 clang::ObjCInterfaceDecl *class_interface_decl =
5746 objc_interface_type->getDecl();
5747 if (class_interface_decl) {
5751 name, bit_offset_ptr, bitfield_bit_size_ptr,
5758 case clang::Type::ObjCObject:
5759 case clang::Type::ObjCInterface:
5761 const clang::ObjCObjectType *objc_class_type =
5762 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5763 assert(objc_class_type);
5764 if (objc_class_type) {
5765 clang::ObjCInterfaceDecl *class_interface_decl =
5766 objc_class_type->getInterface();
5770 name, bit_offset_ptr, bitfield_bit_size_ptr,
5786 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5787 switch (type_class) {
5788 case clang::Type::Record:
5790 const clang::CXXRecordDecl *cxx_record_decl =
5791 qual_type->getAsCXXRecordDecl();
5792 if (cxx_record_decl)
5793 count = cxx_record_decl->getNumBases();
5797 case clang::Type::ObjCObjectPointer:
5801 case clang::Type::ObjCObject:
5803 const clang::ObjCObjectType *objc_class_type =
5804 qual_type->getAsObjCQualifiedInterfaceType();
5805 if (objc_class_type) {
5806 clang::ObjCInterfaceDecl *class_interface_decl =
5807 objc_class_type->getInterface();
5809 if (class_interface_decl && class_interface_decl->getSuperClass())
5814 case clang::Type::ObjCInterface:
5816 const clang::ObjCInterfaceType *objc_interface_type =
5817 qual_type->getAs<clang::ObjCInterfaceType>();
5818 if (objc_interface_type) {
5819 clang::ObjCInterfaceDecl *class_interface_decl =
5820 objc_interface_type->getInterface();
5822 if (class_interface_decl && class_interface_decl->getSuperClass())
5838 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5839 switch (type_class) {
5840 case clang::Type::Record:
5842 const clang::CXXRecordDecl *cxx_record_decl =
5843 qual_type->getAsCXXRecordDecl();
5844 if (cxx_record_decl)
5845 count = cxx_record_decl->getNumVBases();
5858 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5859 switch (type_class) {
5860 case clang::Type::Record:
5862 const clang::CXXRecordDecl *cxx_record_decl =
5863 qual_type->getAsCXXRecordDecl();
5864 if (cxx_record_decl) {
5865 uint32_t curr_idx = 0;
5866 clang::CXXRecordDecl::base_class_const_iterator base_class,
5868 for (base_class = cxx_record_decl->bases_begin(),
5869 base_class_end = cxx_record_decl->bases_end();
5870 base_class != base_class_end; ++base_class, ++curr_idx) {
5871 if (curr_idx == idx) {
5872 if (bit_offset_ptr) {
5873 const clang::ASTRecordLayout &record_layout =
5875 const clang::CXXRecordDecl *base_class_decl =
5876 llvm::cast<clang::CXXRecordDecl>(
5877 base_class->getType()
5878 ->castAs<clang::RecordType>()
5880 if (base_class->isVirtual())
5882 record_layout.getVBaseClassOffset(base_class_decl)
5887 record_layout.getBaseClassOffset(base_class_decl)
5891 return GetType(base_class->getType());
5898 case clang::Type::ObjCObjectPointer:
5901 case clang::Type::ObjCObject:
5903 const clang::ObjCObjectType *objc_class_type =
5904 qual_type->getAsObjCQualifiedInterfaceType();
5905 if (objc_class_type) {
5906 clang::ObjCInterfaceDecl *class_interface_decl =
5907 objc_class_type->getInterface();
5909 if (class_interface_decl) {
5910 clang::ObjCInterfaceDecl *superclass_interface_decl =
5911 class_interface_decl->getSuperClass();
5912 if (superclass_interface_decl) {
5914 *bit_offset_ptr = 0;
5916 superclass_interface_decl));
5922 case clang::Type::ObjCInterface:
5924 const clang::ObjCObjectType *objc_interface_type =
5925 qual_type->getAs<clang::ObjCInterfaceType>();
5926 if (objc_interface_type) {
5927 clang::ObjCInterfaceDecl *class_interface_decl =
5928 objc_interface_type->getInterface();
5930 if (class_interface_decl) {
5931 clang::ObjCInterfaceDecl *superclass_interface_decl =
5932 class_interface_decl->getSuperClass();
5933 if (superclass_interface_decl) {
5935 *bit_offset_ptr = 0;
5937 superclass_interface_decl));
5953 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5954 switch (type_class) {
5955 case clang::Type::Record:
5957 const clang::CXXRecordDecl *cxx_record_decl =
5958 qual_type->getAsCXXRecordDecl();
5959 if (cxx_record_decl) {
5960 uint32_t curr_idx = 0;
5961 clang::CXXRecordDecl::base_class_const_iterator base_class,
5963 for (base_class = cxx_record_decl->vbases_begin(),
5964 base_class_end = cxx_record_decl->vbases_end();
5965 base_class != base_class_end; ++base_class, ++curr_idx) {
5966 if (curr_idx == idx) {
5967 if (bit_offset_ptr) {
5968 const clang::ASTRecordLayout &record_layout =
5970 const clang::CXXRecordDecl *base_class_decl =
5971 llvm::cast<clang::CXXRecordDecl>(
5972 base_class->getType()
5973 ->castAs<clang::RecordType>()
5976 record_layout.getVBaseClassOffset(base_class_decl)
5980 return GetType(base_class->getType());
5995 llvm::StringRef name) {
5997 switch (qual_type->getTypeClass()) {
5998 case clang::Type::Record: {
6002 const clang::RecordType *record_type =
6003 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6004 const clang::RecordDecl *record_decl =
6005 record_type->getDecl()->getDefinitionOrSelf();
6007 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
6008 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
6009 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
6010 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
6034 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6035 switch (type_class) {
6036 case clang::Type::Builtin:
6037 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6038 case clang::BuiltinType::UnknownAny:
6039 case clang::BuiltinType::Void:
6040 case clang::BuiltinType::NullPtr:
6041 case clang::BuiltinType::OCLEvent:
6042 case clang::BuiltinType::OCLImage1dRO:
6043 case clang::BuiltinType::OCLImage1dWO:
6044 case clang::BuiltinType::OCLImage1dRW:
6045 case clang::BuiltinType::OCLImage1dArrayRO:
6046 case clang::BuiltinType::OCLImage1dArrayWO:
6047 case clang::BuiltinType::OCLImage1dArrayRW:
6048 case clang::BuiltinType::OCLImage1dBufferRO:
6049 case clang::BuiltinType::OCLImage1dBufferWO:
6050 case clang::BuiltinType::OCLImage1dBufferRW:
6051 case clang::BuiltinType::OCLImage2dRO:
6052 case clang::BuiltinType::OCLImage2dWO:
6053 case clang::BuiltinType::OCLImage2dRW:
6054 case clang::BuiltinType::OCLImage2dArrayRO:
6055 case clang::BuiltinType::OCLImage2dArrayWO:
6056 case clang::BuiltinType::OCLImage2dArrayRW:
6057 case clang::BuiltinType::OCLImage3dRO:
6058 case clang::BuiltinType::OCLImage3dWO:
6059 case clang::BuiltinType::OCLImage3dRW:
6060 case clang::BuiltinType::OCLSampler:
6061 case clang::BuiltinType::HLSLResource:
6063 case clang::BuiltinType::Bool:
6064 case clang::BuiltinType::Char_U:
6065 case clang::BuiltinType::UChar:
6066 case clang::BuiltinType::WChar_U:
6067 case clang::BuiltinType::Char16:
6068 case clang::BuiltinType::Char32:
6069 case clang::BuiltinType::UShort:
6070 case clang::BuiltinType::UInt:
6071 case clang::BuiltinType::ULong:
6072 case clang::BuiltinType::ULongLong:
6073 case clang::BuiltinType::UInt128:
6074 case clang::BuiltinType::Char_S:
6075 case clang::BuiltinType::SChar:
6076 case clang::BuiltinType::WChar_S:
6077 case clang::BuiltinType::Short:
6078 case clang::BuiltinType::Int:
6079 case clang::BuiltinType::Long:
6080 case clang::BuiltinType::LongLong:
6081 case clang::BuiltinType::Int128:
6082 case clang::BuiltinType::Float:
6083 case clang::BuiltinType::Double:
6084 case clang::BuiltinType::LongDouble:
6085 case clang::BuiltinType::Float128:
6086 case clang::BuiltinType::Dependent:
6087 case clang::BuiltinType::Overload:
6088 case clang::BuiltinType::ObjCId:
6089 case clang::BuiltinType::ObjCClass:
6090 case clang::BuiltinType::ObjCSel:
6091 case clang::BuiltinType::BoundMember:
6092 case clang::BuiltinType::Half:
6093 case clang::BuiltinType::ARCUnbridgedCast:
6094 case clang::BuiltinType::PseudoObject:
6095 case clang::BuiltinType::BuiltinFn:
6096 case clang::BuiltinType::ArraySection:
6103 case clang::Type::Complex:
6105 case clang::Type::Pointer:
6107 case clang::Type::BlockPointer:
6110 case clang::Type::LValueReference:
6112 case clang::Type::RValueReference:
6114 case clang::Type::MemberPointer:
6116 case clang::Type::ConstantArray:
6118 case clang::Type::IncompleteArray:
6120 case clang::Type::VariableArray:
6122 case clang::Type::DependentSizedArray:
6124 case clang::Type::DependentSizedExtVector:
6126 case clang::Type::Vector:
6128 case clang::Type::ExtVector:
6130 case clang::Type::FunctionProto:
6132 case clang::Type::FunctionNoProto:
6134 case clang::Type::UnresolvedUsing:
6136 case clang::Type::Record:
6138 case clang::Type::Enum:
6140 case clang::Type::TemplateTypeParm:
6142 case clang::Type::SubstTemplateTypeParm:
6144 case clang::Type::TemplateSpecialization:
6146 case clang::Type::InjectedClassName:
6148 case clang::Type::DependentName:
6150 case clang::Type::ObjCObject:
6152 case clang::Type::ObjCInterface:
6154 case clang::Type::ObjCObjectPointer:
6164 std::string &deref_name, uint32_t &deref_byte_size,
6165 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6169 return llvm::createStringError(
"not a pointer, reference or array type");
6170 uint32_t child_bitfield_bit_size = 0;
6171 uint32_t child_bitfield_bit_offset = 0;
6172 bool child_is_base_class;
6173 bool child_is_deref_of_parent;
6175 type, exe_ctx, 0,
false,
true,
false, deref_name, deref_byte_size,
6176 deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6177 child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
6182 bool transparent_pointers,
bool omit_empty_base_classes,
6183 bool ignore_array_bounds, std::string &child_name,
6184 uint32_t &child_byte_size, int32_t &child_byte_offset,
6185 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6186 bool &child_is_base_class,
bool &child_is_deref_of_parent,
6189 return llvm::createStringError(
"invalid type");
6191 auto get_exe_scope = [&exe_ctx]() {
6195 clang::QualType parent_qual_type(
6197 const clang::Type::TypeClass parent_type_class =
6198 parent_qual_type->getTypeClass();
6199 child_bitfield_bit_size = 0;
6200 child_bitfield_bit_offset = 0;
6201 child_is_base_class =
false;
6204 auto num_children_or_err =
6206 if (!num_children_or_err)
6207 return num_children_or_err.takeError();
6209 const bool idx_is_valid = idx < *num_children_or_err;
6211 switch (parent_type_class) {
6212 case clang::Type::Builtin:
6214 return llvm::createStringError(
"invalid index");
6216 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6217 case clang::BuiltinType::ObjCId:
6218 case clang::BuiltinType::ObjCClass:
6229 case clang::Type::Record: {
6231 return llvm::createStringError(
"invalid index");
6233 return llvm::createStringError(
"cannot complete type");
6235 const clang::RecordType *record_type =
6236 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6237 const clang::RecordDecl *record_decl =
6238 record_type->getDecl()->getDefinitionOrSelf();
6239 const clang::ASTRecordLayout &record_layout =
6241 uint32_t child_idx = 0;
6243 const clang::CXXRecordDecl *cxx_record_decl =
6244 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6245 if (cxx_record_decl) {
6247 clang::CXXRecordDecl::base_class_const_iterator base_class,
6249 for (base_class = cxx_record_decl->bases_begin(),
6250 base_class_end = cxx_record_decl->bases_end();
6251 base_class != base_class_end; ++base_class) {
6252 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6255 if (omit_empty_base_classes) {
6257 llvm::cast<clang::CXXRecordDecl>(
6258 base_class->getType()->getAs<clang::RecordType>()->getDecl())
6259 ->getDefinitionOrSelf();
6264 if (idx == child_idx) {
6265 if (base_class_decl ==
nullptr)
6266 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6267 base_class->getType()
6268 ->getAs<clang::RecordType>()
6270 ->getDefinitionOrSelf();
6272 if (base_class->isVirtual()) {
6273 bool handled =
false;
6275 clang::VTableContextBase *vtable_ctx =
6279 cxx_record_decl, base_class_decl,
6283 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6287 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6292 child_byte_offset = bit_offset / 8;
6295 auto size_or_err = base_class_clang_type.
GetBitSize(get_exe_scope());
6297 return llvm::joinErrors(
6298 llvm::createStringError(
"no size info for base class"),
6299 size_or_err.takeError());
6301 uint64_t base_class_clang_type_bit_size = *size_or_err;
6304 assert(base_class_clang_type_bit_size % 8 == 0);
6305 child_byte_size = base_class_clang_type_bit_size / 8;
6306 child_is_base_class =
true;
6307 return base_class_clang_type;
6315 uint32_t field_idx = 0;
6316 clang::RecordDecl::field_iterator field, field_end;
6317 for (field = record_decl->field_begin(),
6318 field_end = record_decl->field_end();
6319 field != field_end; ++field, ++field_idx, ++child_idx) {
6320 if (idx == child_idx) {
6323 child_name.assign(field->getNameAsString());
6328 assert(field_idx < record_layout.getFieldCount());
6329 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6331 return llvm::joinErrors(
6332 llvm::createStringError(
"no size info for field"),
6333 size_or_err.takeError());
6335 child_byte_size = *size_or_err;
6336 const uint32_t child_bit_size = child_byte_size * 8;
6340 bit_offset = record_layout.getFieldOffset(field_idx);
6342 child_bitfield_bit_offset = bit_offset % child_bit_size;
6343 const uint32_t child_bit_offset =
6344 bit_offset - child_bitfield_bit_offset;
6345 child_byte_offset = child_bit_offset / 8;
6347 child_byte_offset = bit_offset / 8;
6350 return field_clang_type;
6354 case clang::Type::ObjCObject:
6355 case clang::Type::ObjCInterface: {
6357 return llvm::createStringError(
"invalid index");
6359 return llvm::createStringError(
"cannot complete type");
6361 const clang::ObjCObjectType *objc_class_type =
6362 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6363 assert(objc_class_type);
6364 if (!objc_class_type)
6365 return llvm::createStringError(
"unexpected object type");
6367 uint32_t child_idx = 0;
6368 clang::ObjCInterfaceDecl *class_interface_decl =
6369 objc_class_type->getInterface();
6371 if (!class_interface_decl)
6372 return llvm::createStringError(
"cannot get interface decl");
6374 const clang::ASTRecordLayout &interface_layout =
6375 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6376 clang::ObjCInterfaceDecl *superclass_interface_decl =
6377 class_interface_decl->getSuperClass();
6378 if (superclass_interface_decl) {
6379 if (omit_empty_base_classes) {
6381 getASTContext().getObjCInterfaceType(superclass_interface_decl));
6382 if (llvm::expectedToOptional(base_class_clang_type.
GetNumChildren(
6383 omit_empty_base_classes, exe_ctx))
6386 clang::QualType ivar_qual_type(
getASTContext().getObjCInterfaceType(
6387 superclass_interface_decl));
6389 child_name.assign(superclass_interface_decl->getNameAsString());
6391 clang::TypeInfo ivar_type_info =
6394 child_byte_size = ivar_type_info.Width / 8;
6395 child_byte_offset = 0;
6396 child_is_base_class =
true;
6398 return GetType(ivar_qual_type);
6407 const uint32_t superclass_idx = child_idx;
6409 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6410 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6411 ivar_end = class_interface_decl->ivar_end();
6413 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
6415 if (child_idx == idx) {
6416 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6418 clang::QualType ivar_qual_type(ivar_decl->getType());
6420 child_name.assign(ivar_decl->getNameAsString());
6422 clang::TypeInfo ivar_type_info =
6425 child_byte_size = ivar_type_info.Width / 8;
6441 if (objc_runtime !=
nullptr) {
6444 parent_ast_type, ivar_decl->getNameAsString().c_str());
6452 if (child_byte_offset ==
6455 interface_layout.getFieldOffset(child_idx - superclass_idx);
6456 child_byte_offset = bit_offset / 8;
6468 interface_layout.getFieldOffset(child_idx - superclass_idx);
6470 child_bitfield_bit_offset = bit_offset % 8;
6472 return GetType(ivar_qual_type);
6479 case clang::Type::ObjCObjectPointer: {
6481 return llvm::createStringError(
"invalid index");
6485 child_is_deref_of_parent =
false;
6486 bool tmp_child_is_deref_of_parent =
false;
6488 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6489 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6490 child_bitfield_bit_size, child_bitfield_bit_offset,
6491 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6494 child_is_deref_of_parent =
true;
6495 const char *parent_name =
6498 child_name.assign(1,
'*');
6499 child_name += parent_name;
6504 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6506 return size_or_err.takeError();
6507 child_byte_size = *size_or_err;
6508 child_byte_offset = 0;
6509 return pointee_clang_type;
6514 case clang::Type::Vector:
6515 case clang::Type::ExtVector: {
6517 return llvm::createStringError(
"invalid index");
6518 const clang::VectorType *array =
6519 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6521 return llvm::createStringError(
"unexpected vector type");
6525 return llvm::createStringError(
"cannot complete type");
6527 char element_name[64];
6528 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6529 static_cast<uint64_t
>(idx));
6530 child_name.assign(element_name);
6531 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6533 return size_or_err.takeError();
6534 child_byte_size = *size_or_err;
6535 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6536 return element_type;
6538 case clang::Type::ConstantArray:
6539 case clang::Type::IncompleteArray: {
6540 if (!ignore_array_bounds && !idx_is_valid)
6541 return llvm::createStringError(
"invalid index");
6542 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6544 return llvm::createStringError(
"unexpected array type");
6547 return llvm::createStringError(
"cannot complete type");
6549 child_name = std::string(llvm::formatv(
"[{0}]", idx));
6550 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6552 return size_or_err.takeError();
6553 child_byte_size = *size_or_err;
6554 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6555 return element_type;
6557 case clang::Type::Pointer: {
6562 return llvm::createStringError(
"cannot dereference void *");
6565 child_is_deref_of_parent =
false;
6566 bool tmp_child_is_deref_of_parent =
false;
6568 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6569 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6570 child_bitfield_bit_size, child_bitfield_bit_offset,
6571 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6574 child_is_deref_of_parent =
true;
6578 child_name.assign(1,
'*');
6579 child_name += parent_name;
6584 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6586 return size_or_err.takeError();
6587 child_byte_size = *size_or_err;
6588 child_byte_offset = 0;
6589 return pointee_clang_type;
6594 case clang::Type::LValueReference:
6595 case clang::Type::RValueReference: {
6597 return llvm::createStringError(
"invalid index");
6598 const clang::ReferenceType *reference_type =
6599 llvm::cast<clang::ReferenceType>(
6603 child_is_deref_of_parent =
false;
6604 bool tmp_child_is_deref_of_parent =
false;
6606 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6607 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6608 child_bitfield_bit_size, child_bitfield_bit_offset,
6609 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6614 child_name.assign(1,
'&');
6615 child_name += parent_name;
6620 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6622 return size_or_err.takeError();
6623 child_byte_size = *size_or_err;
6624 child_byte_offset = 0;
6625 return pointee_clang_type;
6632 return llvm::createStringError(
"cannot enumerate children");
6636 const clang::RecordDecl *record_decl,
6637 const clang::CXXBaseSpecifier *base_spec,
6638 bool omit_empty_base_classes) {
6639 uint32_t child_idx = 0;
6641 const clang::CXXRecordDecl *cxx_record_decl =
6642 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6644 if (cxx_record_decl) {
6645 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6646 for (base_class = cxx_record_decl->bases_begin(),
6647 base_class_end = cxx_record_decl->bases_end();
6648 base_class != base_class_end; ++base_class) {
6649 if (omit_empty_base_classes) {
6654 if (base_class == base_spec)
6664 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6665 bool omit_empty_base_classes) {
6667 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6668 omit_empty_base_classes);
6670 clang::RecordDecl::field_iterator field, field_end;
6671 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6672 field != field_end; ++field, ++child_idx) {
6673 if (field->getCanonicalDecl() == canonical_decl)
6715 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6716 if (type && !name.empty()) {
6718 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6719 switch (type_class) {
6720 case clang::Type::Record:
6722 const clang::RecordType *record_type =
6723 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6724 const clang::RecordDecl *record_decl =
6725 record_type->getDecl()->getDefinitionOrSelf();
6727 assert(record_decl);
6728 uint32_t child_idx = 0;
6730 const clang::CXXRecordDecl *cxx_record_decl =
6731 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6734 clang::RecordDecl::field_iterator field, field_end;
6735 for (field = record_decl->field_begin(),
6736 field_end = record_decl->field_end();
6737 field != field_end; ++field, ++child_idx) {
6738 llvm::StringRef field_name = field->getName();
6739 if (field_name.empty()) {
6741 std::vector<uint32_t> save_indices = child_indexes;
6742 child_indexes.push_back(
6744 cxx_record_decl, omit_empty_base_classes));
6746 name, omit_empty_base_classes, child_indexes))
6747 return child_indexes.size();
6748 child_indexes = std::move(save_indices);
6749 }
else if (field_name == name) {
6751 child_indexes.push_back(
6753 cxx_record_decl, omit_empty_base_classes));
6754 return child_indexes.size();
6758 if (cxx_record_decl) {
6759 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6762 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6763 clang::DeclarationName decl_name(&ident_ref);
6765 clang::CXXBasePaths paths;
6766 if (cxx_record_decl->lookupInBases(
6767 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6768 clang::CXXBasePath &path) {
6769 CXXRecordDecl *record =
6770 specifier->getType()->getAsCXXRecordDecl();
6771 auto r = record->lookup(decl_name);
6772 path.Decls = r.begin();
6776 clang::CXXBasePaths::const_paths_iterator path,
6777 path_end = paths.end();
6778 for (path = paths.begin(); path != path_end; ++path) {
6779 const size_t num_path_elements = path->size();
6780 for (
size_t e = 0; e < num_path_elements; ++e) {
6781 clang::CXXBasePathElement elem = (*path)[e];
6784 omit_empty_base_classes);
6786 child_indexes.clear();
6789 child_indexes.push_back(child_idx);
6790 parent_record_decl = elem.Base->getType()
6791 ->castAs<clang::RecordType>()
6793 ->getDefinitionOrSelf();
6796 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6799 parent_record_decl, *I, omit_empty_base_classes);
6801 child_indexes.clear();
6804 child_indexes.push_back(child_idx);
6808 return child_indexes.size();
6814 case clang::Type::ObjCObject:
6815 case clang::Type::ObjCInterface:
6817 llvm::StringRef name_sref(name);
6818 const clang::ObjCObjectType *objc_class_type =
6819 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6820 assert(objc_class_type);
6821 if (objc_class_type) {
6822 uint32_t child_idx = 0;
6823 clang::ObjCInterfaceDecl *class_interface_decl =
6824 objc_class_type->getInterface();
6826 if (class_interface_decl) {
6827 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6828 ivar_end = class_interface_decl->ivar_end();
6829 clang::ObjCInterfaceDecl *superclass_interface_decl =
6830 class_interface_decl->getSuperClass();
6832 for (ivar_pos = class_interface_decl->ivar_begin();
6833 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6834 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6836 if (ivar_decl->getName() == name_sref) {
6837 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6838 (omit_empty_base_classes &&
6842 child_indexes.push_back(child_idx);
6843 return child_indexes.size();
6847 if (superclass_interface_decl) {
6851 child_indexes.push_back(0);
6855 superclass_interface_decl));
6857 name, omit_empty_base_classes, child_indexes)) {
6860 return child_indexes.size();
6865 child_indexes.pop_back();
6872 case clang::Type::ObjCObjectPointer: {
6874 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6875 ->getPointeeType());
6877 name, omit_empty_base_classes, child_indexes);
6880 case clang::Type::LValueReference:
6881 case clang::Type::RValueReference: {
6882 const clang::ReferenceType *reference_type =
6883 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
6884 clang::QualType pointee_type(reference_type->getPointeeType());
6889 name, omit_empty_base_classes, child_indexes);
6893 case clang::Type::Pointer: {
6898 name, omit_empty_base_classes, child_indexes);
6913llvm::Expected<uint32_t>
6915 llvm::StringRef name,
6916 bool omit_empty_base_classes) {
6917 if (type && !name.empty()) {
6920 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6922 switch (type_class) {
6923 case clang::Type::Record:
6925 const clang::RecordType *record_type =
6926 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6927 const clang::RecordDecl *record_decl =
6928 record_type->getDecl()->getDefinitionOrSelf();
6930 assert(record_decl);
6931 uint32_t child_idx = 0;
6933 const clang::CXXRecordDecl *cxx_record_decl =
6934 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6936 if (cxx_record_decl) {
6937 clang::CXXRecordDecl::base_class_const_iterator base_class,
6939 for (base_class = cxx_record_decl->bases_begin(),
6940 base_class_end = cxx_record_decl->bases_end();
6941 base_class != base_class_end; ++base_class) {
6943 clang::CXXRecordDecl *base_class_decl =
6944 llvm::cast<clang::CXXRecordDecl>(
6945 base_class->getType()
6946 ->castAs<clang::RecordType>()
6948 ->getDefinitionOrSelf();
6949 if (omit_empty_base_classes &&
6954 std::string base_class_type_name(
6956 if (base_class_type_name == name)
6963 clang::RecordDecl::field_iterator field, field_end;
6964 for (field = record_decl->field_begin(),
6965 field_end = record_decl->field_end();
6966 field != field_end; ++field, ++child_idx) {
6967 if (field->getName() == name)
6973 case clang::Type::ObjCObject:
6974 case clang::Type::ObjCInterface:
6976 const clang::ObjCObjectType *objc_class_type =
6977 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6978 assert(objc_class_type);
6979 if (objc_class_type) {
6980 uint32_t child_idx = 0;
6981 clang::ObjCInterfaceDecl *class_interface_decl =
6982 objc_class_type->getInterface();
6984 if (class_interface_decl) {
6985 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6986 ivar_end = class_interface_decl->ivar_end();
6987 clang::ObjCInterfaceDecl *superclass_interface_decl =
6988 class_interface_decl->getSuperClass();
6990 for (ivar_pos = class_interface_decl->ivar_begin();
6991 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6992 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6994 if (ivar_decl->getName() == name) {
6995 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6996 (omit_empty_base_classes &&
7004 if (superclass_interface_decl) {
7005 if (superclass_interface_decl->getName() == name)
7013 case clang::Type::ObjCObjectPointer: {
7015 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7016 ->getPointeeType());
7018 name, omit_empty_base_classes);
7021 case clang::Type::LValueReference:
7022 case clang::Type::RValueReference: {
7023 const clang::ReferenceType *reference_type =
7024 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7029 omit_empty_base_classes);
7033 case clang::Type::Pointer: {
7034 const clang::PointerType *pointer_type =
7035 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7040 omit_empty_base_classes);
7048 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
7053 llvm::StringRef name) {
7054 if (!type || name.empty())
7058 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7060 switch (type_class) {
7061 case clang::Type::Record: {
7064 const clang::RecordType *record_type =
7065 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7066 const clang::RecordDecl *record_decl =
7067 record_type->getDecl()->getDefinitionOrSelf();
7069 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7070 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7071 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7073 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7075 ElaboratedTypeKeyword::None, std::nullopt,
7091 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7092 return isa<clang::ClassTemplateSpecializationDecl>(
7093 cxx_record_decl->getDecl());
7104 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7105 switch (type_class) {
7106 case clang::Type::Record:
7108 const clang::CXXRecordDecl *cxx_record_decl =
7109 qual_type->getAsCXXRecordDecl();
7110 if (cxx_record_decl) {
7111 const clang::ClassTemplateSpecializationDecl *template_decl =
7112 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7114 if (template_decl) {
7115 const auto &template_arg_list = template_decl->getTemplateArgs();
7116 size_t num_args = template_arg_list.size();
7117 assert(num_args &&
"template specialization without any args");
7118 if (expand_pack && num_args) {
7119 const auto &pack = template_arg_list[num_args - 1];
7120 if (pack.getKind() == clang::TemplateArgument::Pack)
7121 num_args += pack.pack_size() - 1;
7136const clang::ClassTemplateSpecializationDecl *
7143 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7144 switch (type_class) {
7145 case clang::Type::Record: {
7148 const clang::CXXRecordDecl *cxx_record_decl =
7149 qual_type->getAsCXXRecordDecl();
7150 if (!cxx_record_decl)
7152 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7161const TemplateArgument *
7163 size_t idx,
bool expand_pack) {
7164 const auto &args = decl->getTemplateArgs();
7165 const size_t args_size = args.size();
7167 assert(args_size &&
"template specialization without any args");
7171 const size_t last_idx = args_size - 1;
7180 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7181 return idx >= args.size() ? nullptr : &args[idx];
7186 const auto &pack = args[last_idx];
7187 const size_t pack_idx = idx - last_idx;
7188 if (pack_idx >= pack.pack_size())
7190 return &pack.pack_elements()[pack_idx];
7195 size_t arg_idx,
bool expand_pack) {
7196 const clang::ClassTemplateSpecializationDecl *template_decl =
7205 switch (arg->getKind()) {
7206 case clang::TemplateArgument::Null:
7209 case clang::TemplateArgument::NullPtr:
7212 case clang::TemplateArgument::Type:
7215 case clang::TemplateArgument::Declaration:
7218 case clang::TemplateArgument::Integral:
7221 case clang::TemplateArgument::Template:
7224 case clang::TemplateArgument::TemplateExpansion:
7227 case clang::TemplateArgument::Expression:
7230 case clang::TemplateArgument::Pack:
7233 case clang::TemplateArgument::StructuralValue:
7236 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7241 size_t idx,
bool expand_pack) {
7242 const clang::ClassTemplateSpecializationDecl *template_decl =
7248 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7251 return GetType(arg->getAsType());
7254std::optional<CompilerType::IntegralTemplateArgument>
7256 size_t idx,
bool expand_pack) {
7257 const clang::ClassTemplateSpecializationDecl *template_decl =
7260 return std::nullopt;
7264 return std::nullopt;
7266 switch (arg->getKind()) {
7267 case clang::TemplateArgument::Integral:
7268 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7269 case clang::TemplateArgument::StructuralValue: {
7270 clang::APValue value = arg->getAsStructuralValue();
7273 if (value.isFloat())
7274 return {{value.getFloat(), type}};
7277 return {{value.getInt(), type}};
7279 return std::nullopt;
7282 return std::nullopt;
7307 const clang::EnumType *enutype =
7310 return enutype->getDecl()->getDefinitionOrSelf();
7315 const clang::RecordType *record_type =
7318 return record_type->getDecl()->getDefinitionOrSelf();
7326clang::TypedefNameDecl *
7328 const clang::TypedefType *typedef_type =
7331 return typedef_type->getDecl();
7335clang::CXXRecordDecl *
7340clang::ObjCInterfaceDecl *
7342 const clang::ObjCObjectType *objc_class_type =
7343 llvm::dyn_cast<clang::ObjCObjectType>(
7345 if (objc_class_type)
7346 return objc_class_type->getInterface();
7352 const CompilerType &field_clang_type, uint32_t bitfield_bit_size) {
7358 clang::ASTContext &clang_ast = ast->getASTContext();
7359 clang::IdentifierInfo *ident =
nullptr;
7361 ident = &clang_ast.Idents.get(name);
7363 clang::FieldDecl *field =
nullptr;
7365 clang::Expr *bit_width =
nullptr;
7366 if (bitfield_bit_size != 0) {
7367 if (clang_ast.IntTy.isNull()) {
7369 "builtin ASTContext types have not been initialized");
7373 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7375 bit_width =
new (clang_ast)
7376 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7377 clang_ast.IntTy, clang::SourceLocation());
7378 bit_width = clang::ConstantExpr::Create(
7379 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7382 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7384 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7385 field->setDeclContext(record_decl);
7386 field->setDeclName(ident);
7389 field->setBitWidth(bit_width);
7395 if (
const clang::TagType *TagT =
7396 field->getType()->getAs<clang::TagType>()) {
7397 if (clang::RecordDecl *Rec =
7398 llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
7399 if (!Rec->getDeclName()) {
7400 Rec->setAnonymousStructOrUnion(
true);
7401 field->setImplicit();
7407 field->setAccess(AS_public);
7409 record_decl->addDecl(field);
7414 clang::ObjCInterfaceDecl *class_interface_decl =
7415 ast->GetAsObjCInterfaceDecl(type);
7417 if (class_interface_decl) {
7418 const bool is_synthesized =
false;
7423 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7424 ivar->setDeclContext(class_interface_decl);
7425 ivar->setDeclName(ident);
7427 ivar->setAccessControl(ObjCIvarDecl::AccessControl::Public);
7429 ivar->setBitWidth(bit_width);
7430 ivar->setSynthesize(is_synthesized);
7435 class_interface_decl->addDecl(field);
7452 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7457 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7459 IndirectFieldVector indirect_fields;
7460 clang::RecordDecl::field_iterator field_pos;
7461 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7462 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7463 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7464 last_field_pos = field_pos++) {
7465 if (field_pos->isAnonymousStructOrUnion()) {
7466 clang::QualType field_qual_type = field_pos->getType();
7468 const clang::RecordType *field_record_type =
7469 field_qual_type->getAs<clang::RecordType>();
7471 if (!field_record_type)
7474 clang::RecordDecl *field_record_decl =
7475 field_record_type->getDecl()->getDefinition();
7477 if (!field_record_decl)
7480 for (clang::RecordDecl::decl_iterator
7481 di = field_record_decl->decls_begin(),
7482 de = field_record_decl->decls_end();
7484 if (clang::FieldDecl *nested_field_decl =
7485 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7486 clang::NamedDecl **chain =
7487 new (ast->getASTContext()) clang::NamedDecl *[2];
7488 chain[0] = *field_pos;
7489 chain[1] = nested_field_decl;
7490 clang::IndirectFieldDecl *indirect_field =
7491 clang::IndirectFieldDecl::Create(
7492 ast->getASTContext(), record_decl, clang::SourceLocation(),
7493 nested_field_decl->getIdentifier(),
7494 nested_field_decl->getType(), {chain, 2});
7497 indirect_field->setImplicit();
7499 indirect_field->setAccess(AS_public);
7501 indirect_fields.push_back(indirect_field);
7502 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7503 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7504 size_t nested_chain_size =
7505 nested_indirect_field_decl->getChainingSize();
7506 clang::NamedDecl **chain =
new (ast->getASTContext())
7507 clang::NamedDecl *[nested_chain_size + 1];
7508 chain[0] = *field_pos;
7510 int chain_index = 1;
7511 for (clang::IndirectFieldDecl::chain_iterator
7512 nci = nested_indirect_field_decl->chain_begin(),
7513 nce = nested_indirect_field_decl->chain_end();
7515 chain[chain_index] = *nci;
7519 clang::IndirectFieldDecl *indirect_field =
7520 clang::IndirectFieldDecl::Create(
7521 ast->getASTContext(), record_decl, clang::SourceLocation(),
7522 nested_indirect_field_decl->getIdentifier(),
7523 nested_indirect_field_decl->getType(),
7524 {chain, nested_chain_size + 1});
7527 indirect_field->setImplicit();
7529 indirect_field->setAccess(AS_public);
7531 indirect_fields.push_back(indirect_field);
7539 if (last_field_pos != field_end_pos) {
7540 if (last_field_pos->getType()->isIncompleteArrayType())
7541 record_decl->hasFlexibleArrayMember();
7544 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7545 ife = indirect_fields.end();
7547 record_decl->addDecl(*ifi);
7560 record_decl->addAttr(
7561 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7568 llvm::StringRef name,
7577 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7581 clang::VarDecl *var_decl =
nullptr;
7582 clang::IdentifierInfo *ident =
nullptr;
7584 ident = &ast->getASTContext().Idents.get(name);
7587 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7588 var_decl->setDeclContext(record_decl);
7589 var_decl->setDeclName(ident);
7591 var_decl->setStorageClass(clang::SC_Static);
7596 var_decl->setAccess(AS_public);
7597 record_decl->addDecl(var_decl);
7599 VerifyDecl(var_decl);
7605 VarDecl *var,
const llvm::APInt &init_value) {
7606 assert(!var->hasInit() &&
"variable already initialized");
7608 clang::ASTContext &ast = var->getASTContext();
7609 QualType qt = var->getType();
7610 assert(qt->isIntegralOrEnumerationType() &&
7611 "only integer or enum types supported");
7614 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7615 const EnumDecl *enum_decl = enum_type->getDecl()->getDefinitionOrSelf();
7616 qt = enum_decl->getIntegerType();
7620 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7621 var->setInit(CXXBoolLiteralExpr::Create(
7622 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7624 var->setInit(IntegerLiteral::Create(
7625 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7630 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7631 assert(!var->hasInit() &&
"variable already initialized");
7633 clang::ASTContext &ast = var->getASTContext();
7634 QualType qt = var->getType();
7635 assert(qt->isFloatingType() &&
"only floating point types supported");
7636 var->setInit(FloatingLiteral::Create(
7637 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7640llvm::SmallVector<clang::ParmVarDecl *>
7642 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7643 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7645 assert(parameter_names.empty() ||
7646 parameter_names.size() == prototype.getNumParams());
7648 llvm::SmallVector<clang::ParmVarDecl *> params;
7649 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7651 llvm::StringRef name =
7652 !parameter_names.empty() ? parameter_names[param_index] :
"";
7656 GetType(prototype.getParamType(param_index)),
7657 clang::SC_None,
false);
7660 params.push_back(param);
7668 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7669 bool is_virtual,
bool is_static,
bool is_inline,
bool is_explicit,
7670 bool is_attr_used,
bool is_artificial) {
7671 if (!type || !method_clang_type.
IsValid() || name.empty())
7676 clang::CXXRecordDecl *cxx_record_decl =
7677 record_qual_type->getAsCXXRecordDecl();
7679 if (cxx_record_decl ==
nullptr)
7684 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7686 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7688 const clang::FunctionType *function_type =
7689 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7691 if (function_type ==
nullptr)
7694 const clang::FunctionProtoType *method_function_prototype(
7695 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7697 if (!method_function_prototype)
7700 unsigned int num_params = method_function_prototype->getNumParams();
7702 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7703 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7708 const clang::ExplicitSpecifier explicit_spec(
7709 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7710 : clang::ExplicitSpecKind::ResolvedFalse);
7712 if (name.starts_with(
"~")) {
7713 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7715 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7716 cxx_dtor_decl->setDeclName(
7719 cxx_dtor_decl->setType(method_qual_type);
7720 cxx_dtor_decl->setImplicit(is_artificial);
7721 cxx_dtor_decl->setInlineSpecified(is_inline);
7722 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7723 cxx_method_decl = cxx_dtor_decl;
7724 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7725 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7727 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7728 cxx_ctor_decl->setDeclName(
7731 cxx_ctor_decl->setType(method_qual_type);
7732 cxx_ctor_decl->setImplicit(is_artificial);
7733 cxx_ctor_decl->setInlineSpecified(is_inline);
7734 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7735 cxx_ctor_decl->setNumCtorInitializers(0);
7736 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7737 cxx_method_decl = cxx_ctor_decl;
7739 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7740 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7743 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7748 const bool is_method =
true;
7750 is_method, op_kind, num_params))
7752 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7754 cxx_method_decl->setDeclContext(cxx_record_decl);
7755 cxx_method_decl->setDeclName(
7756 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7757 cxx_method_decl->setType(method_qual_type);
7758 cxx_method_decl->setStorageClass(SC);
7759 cxx_method_decl->setInlineSpecified(is_inline);
7760 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7761 }
else if (num_params == 0) {
7763 auto *cxx_conversion_decl =
7764 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7766 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7767 cxx_conversion_decl->setDeclName(
7768 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7770 function_type->getReturnType())));
7771 cxx_conversion_decl->setType(method_qual_type);
7772 cxx_conversion_decl->setInlineSpecified(is_inline);
7773 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7774 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7775 cxx_method_decl = cxx_conversion_decl;
7779 if (cxx_method_decl ==
nullptr) {
7780 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7782 cxx_method_decl->setDeclContext(cxx_record_decl);
7783 cxx_method_decl->setDeclName(decl_name);
7784 cxx_method_decl->setType(method_qual_type);
7785 cxx_method_decl->setInlineSpecified(is_inline);
7786 cxx_method_decl->setStorageClass(SC);
7787 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7792 cxx_method_decl->setAccess(AS_public);
7793 cxx_method_decl->setVirtualAsWritten(is_virtual);
7796 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7798 if (!asm_label.empty())
7799 cxx_method_decl->addAttr(
7800 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7805 cxx_method_decl, *method_function_prototype, {}));
7807 cxx_record_decl->addDecl(cxx_method_decl);
7816 if (is_artificial) {
7817 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7818 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7819 (cxx_ctor_decl->isCopyConstructor() &&
7820 cxx_record_decl->hasTrivialCopyConstructor()) ||
7821 (cxx_ctor_decl->isMoveConstructor() &&
7822 cxx_record_decl->hasTrivialMoveConstructor()))) {
7823 cxx_ctor_decl->setDefaulted();
7824 cxx_ctor_decl->setTrivial(
true);
7825 }
else if (cxx_dtor_decl) {
7826 if (cxx_record_decl->hasTrivialDestructor()) {
7827 cxx_dtor_decl->setDefaulted();
7828 cxx_dtor_decl->setTrivial(
true);
7830 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7831 cxx_record_decl->hasTrivialCopyAssignment()) ||
7832 (cxx_method_decl->isMoveAssignmentOperator() &&
7833 cxx_record_decl->hasTrivialMoveAssignment())) {
7834 cxx_method_decl->setDefaulted();
7835 cxx_method_decl->setTrivial(
true);
7839 VerifyDecl(cxx_method_decl);
7841 return cxx_method_decl;
7847 for (
auto *method : record->methods())
7848 addOverridesForMethod(method);
7851#pragma mark C++ Base Classes
7853std::unique_ptr<clang::CXXBaseSpecifier>
7856 bool base_of_class) {
7860 return std::make_unique<clang::CXXBaseSpecifier>(
7861 clang::SourceRange(), is_virtual, base_of_class,
7864 clang::SourceLocation());
7869 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
7873 if (!cxx_record_decl)
7875 std::vector<clang::CXXBaseSpecifier *> raw_bases;
7876 raw_bases.reserve(bases.size());
7880 for (
auto &b : bases)
7881 raw_bases.push_back(b.get());
7882 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
7891 clang::ASTContext &clang_ast = ast->getASTContext();
7893 if (type && superclass_clang_type.
IsValid() &&
7895 clang::ObjCInterfaceDecl *class_interface_decl =
7897 clang::ObjCInterfaceDecl *super_interface_decl =
7899 if (class_interface_decl && super_interface_decl) {
7900 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
7901 clang_ast.getObjCInterfaceType(super_interface_decl)));
7910 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
7911 const char *property_setter_name,
const char *property_getter_name,
7913 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
7914 property_name[0] ==
'\0')
7919 clang::ASTContext &clang_ast = ast->getASTContext();
7922 if (!class_interface_decl)
7927 if (property_clang_type.
IsValid())
7928 property_clang_type_to_access = property_clang_type;
7930 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
7932 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
7935 clang::TypeSourceInfo *prop_type_source;
7937 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
7939 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
7942 clang::ObjCPropertyDecl *property_decl =
7943 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7944 property_decl->setDeclContext(class_interface_decl);
7945 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
7946 property_decl->setType(ivar_decl
7947 ? ivar_decl->getType()
7955 ast->SetMetadata(property_decl, metadata);
7957 class_interface_decl->addDecl(property_decl);
7959 clang::Selector setter_sel, getter_sel;
7961 if (property_setter_name) {
7962 std::string property_setter_no_colon(property_setter_name,
7963 strlen(property_setter_name) - 1);
7964 const clang::IdentifierInfo *setter_ident =
7965 &clang_ast.Idents.get(property_setter_no_colon);
7966 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
7967 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
7968 std::string setter_sel_string(
"set");
7969 setter_sel_string.push_back(::toupper(property_name[0]));
7970 setter_sel_string.append(&property_name[1]);
7971 const clang::IdentifierInfo *setter_ident =
7972 &clang_ast.Idents.get(setter_sel_string);
7973 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
7975 property_decl->setSetterName(setter_sel);
7976 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
7978 if (property_getter_name !=
nullptr) {
7979 const clang::IdentifierInfo *getter_ident =
7980 &clang_ast.Idents.get(property_getter_name);
7981 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
7983 const clang::IdentifierInfo *getter_ident =
7984 &clang_ast.Idents.get(property_name);
7985 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
7987 property_decl->setGetterName(getter_sel);
7988 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
7991 property_decl->setPropertyIvarDecl(ivar_decl);
7993 if (property_attributes & DW_APPLE_PROPERTY_readonly)
7994 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
7995 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
7996 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
7997 if (property_attributes & DW_APPLE_PROPERTY_assign)
7998 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
7999 if (property_attributes & DW_APPLE_PROPERTY_retain)
8000 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
8001 if (property_attributes & DW_APPLE_PROPERTY_copy)
8002 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
8003 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8004 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
8005 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
8006 property_decl->setPropertyAttributes(
8007 ObjCPropertyAttribute::kind_nullability);
8008 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
8009 property_decl->setPropertyAttributes(
8010 ObjCPropertyAttribute::kind_null_resettable);
8011 if (property_attributes & ObjCPropertyAttribute::kind_class)
8012 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8014 const bool isInstance =
8015 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8017 clang::ObjCMethodDecl *getter =
nullptr;
8018 if (!getter_sel.isNull())
8019 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8020 : class_interface_decl->lookupClassMethod(getter_sel);
8021 if (!getter_sel.isNull() && !getter) {
8022 const bool isVariadic =
false;
8023 const bool isPropertyAccessor =
true;
8024 const bool isSynthesizedAccessorStub =
false;
8025 const bool isImplicitlyDeclared =
true;
8026 const bool isDefined =
false;
8027 const clang::ObjCImplementationControl impControl =
8028 clang::ObjCImplementationControl::None;
8029 const bool HasRelatedResultType =
false;
8032 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8033 getter->setDeclName(getter_sel);
8035 getter->setDeclContext(class_interface_decl);
8036 getter->setInstanceMethod(isInstance);
8037 getter->setVariadic(isVariadic);
8038 getter->setPropertyAccessor(isPropertyAccessor);
8039 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8040 getter->setImplicit(isImplicitlyDeclared);
8041 getter->setDefined(isDefined);
8042 getter->setDeclImplementation(impControl);
8043 getter->setRelatedResultType(HasRelatedResultType);
8047 ast->SetMetadata(getter, metadata);
8049 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8050 llvm::ArrayRef<clang::SourceLocation>());
8051 class_interface_decl->addDecl(getter);
8055 getter->setPropertyAccessor(
true);
8056 property_decl->setGetterMethodDecl(getter);
8059 clang::ObjCMethodDecl *setter =
nullptr;
8060 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8061 : class_interface_decl->lookupClassMethod(setter_sel);
8062 if (!setter_sel.isNull() && !setter) {
8063 clang::QualType result_type = clang_ast.VoidTy;
8064 const bool isVariadic =
false;
8065 const bool isPropertyAccessor =
true;
8066 const bool isSynthesizedAccessorStub =
false;
8067 const bool isImplicitlyDeclared =
true;
8068 const bool isDefined =
false;
8069 const clang::ObjCImplementationControl impControl =
8070 clang::ObjCImplementationControl::None;
8071 const bool HasRelatedResultType =
false;
8074 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8075 setter->setDeclName(setter_sel);
8076 setter->setReturnType(result_type);
8077 setter->setDeclContext(class_interface_decl);
8078 setter->setInstanceMethod(isInstance);
8079 setter->setVariadic(isVariadic);
8080 setter->setPropertyAccessor(isPropertyAccessor);
8081 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8082 setter->setImplicit(isImplicitlyDeclared);
8083 setter->setDefined(isDefined);
8084 setter->setDeclImplementation(impControl);
8085 setter->setRelatedResultType(HasRelatedResultType);
8089 ast->SetMetadata(setter, metadata);
8091 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8092 params.push_back(clang::ParmVarDecl::Create(
8093 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8096 clang::SC_Auto,
nullptr));
8098 setter->setMethodParams(clang_ast,
8099 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8100 llvm::ArrayRef<clang::SourceLocation>());
8102 class_interface_decl->addDecl(setter);
8106 setter->setPropertyAccessor(
true);
8107 property_decl->setSetterMethodDecl(setter);
8118 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8119 bool is_objc_direct_call) {
8120 if (!type || !method_clang_type.
IsValid())
8125 if (class_interface_decl ==
nullptr)
8128 if (lldb_ast ==
nullptr)
8130 clang::ASTContext &ast = lldb_ast->getASTContext();
8132 const char *selector_start = ::strchr(name,
' ');
8133 if (selector_start ==
nullptr)
8137 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8142 unsigned num_selectors_with_args = 0;
8143 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8145 len = ::strcspn(start,
":]");
8146 bool has_arg = (start[len] ==
':');
8148 ++num_selectors_with_args;
8149 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8154 if (selector_idents.size() == 0)
8157 clang::Selector method_selector = ast.Selectors.getSelector(
8158 num_selectors_with_args ? selector_idents.size() : 0,
8159 selector_idents.data());
8164 const clang::Type *method_type(method_qual_type.getTypePtr());
8166 if (method_type ==
nullptr)
8169 const clang::FunctionProtoType *method_function_prototype(
8170 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8172 if (!method_function_prototype)
8175 const bool isInstance = (name[0] ==
'-');
8176 const bool isVariadic = is_variadic;
8177 const bool isPropertyAccessor =
false;
8178 const bool isSynthesizedAccessorStub =
false;
8180 const bool isImplicitlyDeclared =
true;
8181 const bool isDefined =
false;
8182 const clang::ObjCImplementationControl impControl =
8183 clang::ObjCImplementationControl::None;
8184 const bool HasRelatedResultType =
false;
8186 const unsigned num_args = method_function_prototype->getNumParams();
8188 if (num_args != num_selectors_with_args)
8192 auto *objc_method_decl =
8193 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8194 objc_method_decl->setDeclName(method_selector);
8195 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8196 objc_method_decl->setDeclContext(
8198 objc_method_decl->setInstanceMethod(isInstance);
8199 objc_method_decl->setVariadic(isVariadic);
8200 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8201 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8202 objc_method_decl->setImplicit(isImplicitlyDeclared);
8203 objc_method_decl->setDefined(isDefined);
8204 objc_method_decl->setDeclImplementation(impControl);
8205 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8208 if (objc_method_decl ==
nullptr)
8212 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8214 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8215 params.push_back(clang::ParmVarDecl::Create(
8216 ast, objc_method_decl, clang::SourceLocation(),
8217 clang::SourceLocation(),
8219 method_function_prototype->getParamType(param_index),
nullptr,
8220 clang::SC_Auto,
nullptr));
8223 objc_method_decl->setMethodParams(
8224 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8225 llvm::ArrayRef<clang::SourceLocation>());
8228 if (is_objc_direct_call) {
8231 objc_method_decl->addAttr(
8232 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8237 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8240 class_interface_decl->addDecl(objc_method_decl);
8242 VerifyDecl(objc_method_decl);
8244 return objc_method_decl;
8254 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8255 switch (type_class) {
8256 case clang::Type::Record: {
8257 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8258 if (cxx_record_decl) {
8259 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8260 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8265 case clang::Type::Enum: {
8266 clang::EnumDecl *enum_decl =
8267 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8269 enum_decl->setHasExternalLexicalStorage(has_extern);
8270 enum_decl->setHasExternalVisibleStorage(has_extern);
8275 case clang::Type::ObjCObject:
8276 case clang::Type::ObjCInterface: {
8277 const clang::ObjCObjectType *objc_class_type =
8278 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8279 assert(objc_class_type);
8280 if (objc_class_type) {
8281 clang::ObjCInterfaceDecl *class_interface_decl =
8282 objc_class_type->getInterface();
8284 if (class_interface_decl) {
8285 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8286 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8302 if (!qual_type.isNull()) {
8303 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8305 clang::TagDecl *tag_decl = tag_type->getDecl();
8307 tag_decl->startDefinition();
8312 const clang::ObjCObjectType *object_type =
8313 qual_type->getAs<clang::ObjCObjectType>();
8315 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8316 if (interface_decl) {
8317 interface_decl->startDefinition();
8328 if (qual_type.isNull())
8332 if (lldb_ast ==
nullptr)
8338 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8340 clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinitionOrSelf();
8342 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8352 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8353 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8354 if (cxx_record_decl->needsImplicitCopyConstructor())
8355 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8356 if (cxx_record_decl->needsImplicitCopyAssignment())
8357 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8360 if (!cxx_record_decl->isCompleteDefinition())
8361 cxx_record_decl->completeDefinition();
8362 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8363 cxx_record_decl->setHasExternalLexicalStorage(
false);
8364 cxx_record_decl->setHasExternalVisibleStorage(
false);
8369 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8373 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8375 if (enum_decl->isCompleteDefinition())
8378 QualType integer_type(enum_decl->getIntegerType());
8379 if (!integer_type.isNull()) {
8380 clang::ASTContext &ast = lldb_ast->getASTContext();
8382 unsigned NumNegativeBits = 0;
8383 unsigned NumPositiveBits = 0;
8384 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8387 clang::QualType BestPromotionType;
8388 clang::QualType BestType;
8389 ast.computeBestEnumTypes(
false, NumNegativeBits,
8390 NumPositiveBits, BestType, BestPromotionType);
8392 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8393 BestPromotionType, NumPositiveBits,
8401 const llvm::APSInt &value) {
8412 if (!enum_opaque_compiler_type)
8415 clang::QualType enum_qual_type(
8418 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8423 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8428 clang::EnumConstantDecl *enumerator_decl =
8429 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8431 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8432 enumerator_decl->setDeclContext(enum_decl);
8433 if (name && name[0])
8434 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8435 enumerator_decl->setType(clang::QualType(enutype, 0));
8437 enumerator_decl->setAccess(AS_public);
8443 enum_decl->addDecl(enumerator_decl);
8445 VerifyDecl(enumerator_decl);
8446 return enumerator_decl;
8451 uint64_t enum_value, uint32_t enum_value_bit_size) {
8453 llvm::APSInt value(enum_value_bit_size,
8462 const clang::Type *clang_type = qt.getTypePtrOrNull();
8463 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8467 return GetType(enum_type->getDecl()->getDefinitionOrSelf()->getIntegerType());
8473 if (type && pointee_type.
IsValid() &&
8478 return ast->GetType(ast->getASTContext().getMemberPointerType(
8487#define DEPTH_INCREMENT 2
8490LLVM_DUMP_METHOD
void
8500struct ScopedASTColor {
8501 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8504 ast.getDiagnostics().getDiagnosticOptions().getShowColors()) {
8505 ast.getDiagnostics().getDiagnosticOptions().setShowColors(
8506 show_colors ? clang::ShowColorsKind::On : clang::ShowColorsKind::Off);
8510 ast.getDiagnostics().getDiagnosticOptions().setShowColors(old_show_colors);
8513 clang::ASTContext *
8514 const clang::ShowColorsKind old_show_colors;
8523 clang::CreateASTDumper(output, filter,
8527 false, clang::ADOF_Default);
8530 consumer->HandleTranslationUnit(*
m_ast_up);
8534 llvm::StringRef symbol_name) {
8541 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8542 size_t ntypes = type_list.
GetSize();
8544 for (
size_t i = 0; i < ntypes; ++i) {
8547 if (!symbol_name.empty())
8548 if (symbol_name != type->GetName().GetStringRef())
8551 s << type->GetName() <<
"\n";
8554 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8562 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8564 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8576 size_t byte_size, uint32_t bitfield_bit_offset,
8577 uint32_t bitfield_bit_size) {
8578 const clang::EnumType *enutype =
8579 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8580 const clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8582 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8583 const uint64_t enum_svalue =
8586 bitfield_bit_offset)
8588 bitfield_bit_offset);
8589 bool can_be_bitfield =
true;
8590 uint64_t covered_bits = 0;
8591 int num_enumerators = 0;
8599 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8600 if (enumerators.empty())
8601 can_be_bitfield =
false;
8603 for (
auto *enumerator : enumerators) {
8604 llvm::APSInt init_val = enumerator->getInitVal();
8605 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8606 : init_val.getZExtValue();
8607 if (qual_type_is_signed)
8608 val = llvm::SignExtend64(val, 8 * byte_size);
8609 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8610 can_be_bitfield =
false;
8611 covered_bits |= val;
8613 if (val == enum_svalue) {
8622 offset = byte_offset;
8624 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8628 if (!can_be_bitfield) {
8629 if (qual_type_is_signed)
8630 s.
Printf(
"%" PRIi64, enum_svalue);
8632 s.
Printf(
"%" PRIu64, enum_uvalue);
8639 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8643 uint64_t remaining_value = enum_uvalue;
8644 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8645 values.reserve(num_enumerators);
8646 for (
auto *enumerator : enum_decl->enumerators())
8647 if (
auto val = enumerator->getInitVal().getZExtValue())
8648 values.emplace_back(val, enumerator->getName());
8653 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8654 return llvm::popcount(a.first) > llvm::popcount(b.first);
8657 for (
const auto &val : values) {
8658 if ((remaining_value & val.first) != val.first)
8660 remaining_value &= ~val.first;
8662 if (remaining_value)
8668 if (remaining_value)
8669 s.
Printf(
"0x%" PRIx64, remaining_value);
8677 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8686 switch (qual_type->getTypeClass()) {
8687 case clang::Type::Typedef: {
8688 clang::QualType typedef_qual_type =
8689 llvm::cast<clang::TypedefType>(qual_type)
8691 ->getUnderlyingType();
8694 format = typedef_clang_type.
GetFormat();
8695 clang::TypeInfo typedef_type_info =
8697 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8707 bitfield_bit_offset,
8712 case clang::Type::Enum:
8717 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8718 bitfield_bit_offset, bitfield_bit_size);
8726 uint32_t item_count = 1;
8766 item_count = byte_size;
8771 item_count = byte_size / 2;
8776 item_count = byte_size / 4;
8782 bitfield_bit_size, bitfield_bit_offset,
8798 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(clang_type)) {
8807 clang::QualType qual_type =
8810 llvm::SmallVector<char, 1024> buf;
8811 llvm::raw_svector_ostream llvm_ostrm(buf);
8813 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8814 switch (type_class) {
8815 case clang::Type::ObjCObject:
8816 case clang::Type::ObjCInterface: {
8819 auto *objc_class_type =
8820 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8821 assert(objc_class_type);
8822 if (!objc_class_type)
8824 clang::ObjCInterfaceDecl *class_interface_decl =
8825 objc_class_type->getInterface();
8826 if (!class_interface_decl)
8829 class_interface_decl->dump(llvm_ostrm);
8831 class_interface_decl->print(llvm_ostrm,
8836 case clang::Type::Typedef: {
8837 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8840 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
8842 typedef_decl->dump(llvm_ostrm);
8845 if (!clang_typedef_name.empty()) {
8852 case clang::Type::Record: {
8855 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
8856 const clang::RecordDecl *record_decl = record_type->getDecl();
8858 record_decl->dump(llvm_ostrm);
8860 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
8866 if (
auto *tag_type =
8867 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
8868 if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
8870 tag_decl->dump(llvm_ostrm);
8872 tag_decl->print(llvm_ostrm, 0);
8878 std::string clang_type_name(qual_type.getAsString());
8879 if (!clang_type_name.empty())
8886 if (buf.size() > 0) {
8887 s.
Write(buf.data(), buf.size());
8894 clang::QualType qual_type(
8897 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8898 switch (type_class) {
8899 case clang::Type::Record: {
8900 const clang::CXXRecordDecl *cxx_record_decl =
8901 qual_type->getAsCXXRecordDecl();
8902 if (cxx_record_decl)
8903 printf(
"class %s", cxx_record_decl->getName().str().c_str());
8906 case clang::Type::Enum: {
8907 clang::EnumDecl *enum_decl =
8908 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8910 printf(
"enum %s", enum_decl->getName().str().c_str());
8914 case clang::Type::ObjCObject:
8915 case clang::Type::ObjCInterface: {
8916 const clang::ObjCObjectType *objc_class_type =
8917 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
8918 if (objc_class_type) {
8919 clang::ObjCInterfaceDecl *class_interface_decl =
8920 objc_class_type->getInterface();
8924 if (class_interface_decl)
8925 printf(
"@class %s", class_interface_decl->getName().str().c_str());
8929 case clang::Type::Typedef:
8930 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
8937 case clang::Type::Auto:
8940 llvm::cast<clang::AutoType>(qual_type)
8942 .getAsOpaquePtr()));
8944 case clang::Type::Paren:
8948 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
8951 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
8959 const char *parent_name,
int tag_decl_kind,
8961 if (template_param_infos.
IsValid()) {
8962 std::string template_basename(parent_name);
8964 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
8965 template_basename.erase(i);
8968 template_basename.c_str(), tag_decl_kind,
8969 template_param_infos);
8984 clang::ObjCInterfaceDecl *decl) {
9008 std::make_unique<npdb::PdbAstBuilderClang>(*
this);
9013 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9014 uint64_t &alignment,
9015 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9016 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9018 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9031 field_offsets, base_offsets, vbase_offsets);
9038 clang::NamedDecl *nd =
9039 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9049 if (!label_or_err) {
9050 llvm::consumeError(label_or_err.takeError());
9054 llvm::StringRef mangled = label_or_err->lookup_name;
9062 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9063 static_cast<clang::Decl *
>(opaque_decl));
9065 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9069 if (!mc || !mc->shouldMangleCXXName(nd))
9074 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9079 llvm::SmallVector<char, 1024> buf;
9080 llvm::raw_svector_ostream llvm_ostrm(buf);
9081 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9083 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9086 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9088 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9092 mc->mangleName(nd, llvm_ostrm);
9108 if (clang::FunctionDecl *func_decl =
9109 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9110 return GetType(func_decl->getReturnType());
9111 if (clang::ObjCMethodDecl *objc_method =
9112 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9113 return GetType(objc_method->getReturnType());
9119 if (clang::FunctionDecl *func_decl =
9120 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9121 return func_decl->param_size();
9122 if (clang::ObjCMethodDecl *objc_method =
9123 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9124 return objc_method->param_size();
9130 clang::DeclContext
const *decl_ctx) {
9131 switch (clang_kind) {
9132 case Decl::TranslationUnit:
9134 case Decl::Namespace:
9145 if (decl_ctx->isFunctionOrMethod())
9147 if (decl_ctx->isRecord())
9157 std::vector<lldb_private::CompilerContext> &context) {
9158 if (decl_ctx ==
nullptr)
9161 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9162 if (clang_kind == Decl::TranslationUnit)
9167 context.push_back({compiler_kind, decl_ctx_name});
9170std::vector<lldb_private::CompilerContext>
9172 std::vector<lldb_private::CompilerContext> context;
9175 clang::Decl *decl = (clang::Decl *)opaque_decl;
9177 clang::DeclContext *decl_ctx = decl->getDeclContext();
9180 auto compiler_kind =
9182 context.push_back({compiler_kind, decl_name});
9189 if (clang::FunctionDecl *func_decl =
9190 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9191 if (idx < func_decl->param_size()) {
9192 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9194 return GetType(var_decl->getOriginalType());
9196 }
else if (clang::ObjCMethodDecl *objc_method =
9197 llvm::dyn_cast<clang::ObjCMethodDecl>(
9198 (clang::Decl *)opaque_decl)) {
9199 if (idx < objc_method->param_size())
9200 return GetType(objc_method->parameters()[idx]->getOriginalType());
9206 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9207 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9210 clang::Expr *init_expr = var_decl->getInit();
9213 std::optional<llvm::APSInt> value =
9223 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9224 std::vector<CompilerDecl> found_decls;
9226 if (opaque_decl_ctx && symbol_file) {
9227 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9228 std::set<DeclContext *> searched;
9229 std::multimap<DeclContext *, DeclContext *> search_queue;
9231 for (clang::DeclContext *decl_context = root_decl_ctx;
9232 decl_context !=
nullptr && found_decls.empty();
9233 decl_context = decl_context->getParent()) {
9234 search_queue.insert(std::make_pair(decl_context, decl_context));
9236 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9238 if (!searched.insert(it->second).second)
9243 for (clang::Decl *child : it->second->decls()) {
9244 if (clang::UsingDirectiveDecl *ud =
9245 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9246 if (ignore_using_decls)
9248 clang::DeclContext *from = ud->getCommonAncestor();
9249 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9250 search_queue.insert(
9251 std::make_pair(from, ud->getNominatedNamespace()));
9252 }
else if (clang::UsingDecl *ud =
9253 llvm::dyn_cast<clang::UsingDecl>(child)) {
9254 if (ignore_using_decls)
9256 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9257 clang::Decl *target = usd->getTargetDecl();
9258 if (clang::NamedDecl *nd =
9259 llvm::dyn_cast<clang::NamedDecl>(target)) {
9260 IdentifierInfo *ii = nd->getIdentifier();
9261 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9265 }
else if (clang::NamedDecl *nd =
9266 llvm::dyn_cast<clang::NamedDecl>(child)) {
9267 IdentifierInfo *ii = nd->getIdentifier();
9268 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9319 clang::DeclContext *child_decl_ctx,
9323 if (frame_decl_ctx && symbol_file) {
9324 std::set<DeclContext *> searched;
9325 std::multimap<DeclContext *, DeclContext *> search_queue;
9328 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9332 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9333 decl_ctx = decl_ctx->getParent()) {
9334 if (!decl_ctx->isLookupContext())
9336 if (decl_ctx == parent_decl_ctx)
9339 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9340 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9342 if (searched.find(it->second) != searched.end())
9350 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9353 searched.insert(it->second);
9357 for (clang::Decl *child : it->second->decls()) {
9358 if (clang::UsingDirectiveDecl *ud =
9359 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9360 clang::DeclContext *ns = ud->getNominatedNamespace();
9361 if (ns == parent_decl_ctx)
9364 clang::DeclContext *from = ud->getCommonAncestor();
9365 if (searched.find(ns) == searched.end())
9366 search_queue.insert(std::make_pair(from, ns));
9367 }
else if (child_name) {
9368 if (clang::UsingDecl *ud =
9369 llvm::dyn_cast<clang::UsingDecl>(child)) {
9370 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9371 clang::Decl *target = usd->getTargetDecl();
9372 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9376 IdentifierInfo *ii = nd->getIdentifier();
9377 if (ii ==
nullptr ||
9378 ii->getName() != child_name->
AsCString(
nullptr))
9401 if (opaque_decl_ctx) {
9402 clang::NamedDecl *named_decl =
9403 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9406 llvm::raw_string_ostream stream{name};
9408 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9409 named_decl->getNameForDiagnostic(stream, policy,
false);
9418 if (opaque_decl_ctx) {
9419 clang::NamedDecl *named_decl =
9420 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9428 if (!opaque_decl_ctx)
9431 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9432 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9434 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9436 }
else if (clang::FunctionDecl *fun_decl =
9437 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9438 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9439 return metadata->HasObjectPtr();
9445std::vector<lldb_private::CompilerContext>
9447 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9448 std::vector<lldb_private::CompilerContext> context;
9454 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9455 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9456 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9460 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9461 if (DC->isInlineNamespace())
9464 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9465 return NS->isAnonymousNamespace();
9472 if (decl_ctx == other)
9474 }
while (is_transparent_lookup_allowed(other) &&
9475 (other = other->getParent()));
9482 if (!opaque_decl_ctx)
9485 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9486 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9488 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9490 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9491 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9492 return metadata->GetObjectPtrLanguage();
9512 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9520 return llvm::dyn_cast<clang::CXXMethodDecl>(
9525clang::FunctionDecl *
9528 return llvm::dyn_cast<clang::FunctionDecl>(
9533clang::NamespaceDecl *
9536 return llvm::dyn_cast<clang::NamespaceDecl>(
9541std::optional<ClangASTMetadata>
9543 const Decl *
object) {
9551 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9574 lldbassert(started &&
"Unable to start a class type definition.");
9579 ts->SetDeclIsForcefullyCompleted(td);
9593 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9594 std::unique_ptr<ClangASTSource> ast_source)
9596 m_scratch_ast_source_up(std::move(ast_source)) {
9598 m_scratch_ast_source_up->InstallASTContext(*
this);
9599 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9600 m_scratch_ast_source_up->CreateProxy();
9601 SetExternalSource(proxy_ast_source);
9605 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9613 llvm::Triple triple)
9620 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9632 std::optional<IsolatedASTKind> ast_kind,
9633 bool create_on_demand) {
9636 if (
auto err = type_system_or_err.takeError()) {
9638 "Couldn't get scratch TypeSystemClang: {0}");
9641 auto ts_sp = *type_system_or_err;
9643 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9648 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9650 return std::static_pointer_cast<TypeSystemClang>(
9655static llvm::StringRef
9659 return "C++ modules";
9661 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9665 llvm::StringRef filter,
bool show_color) {
9667 output <<
"State of scratch Clang type system:\n";
9671 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9672 std::vector<KeyAndTS> sorted_typesystems;
9674 sorted_typesystems.emplace_back(a.first, a.second.get());
9675 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9678 for (
const auto &a : sorted_typesystems) {
9681 output <<
"State of scratch Clang type subsystem "
9683 a.second->Dump(output, filter, show_color);
9688 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9696 desired_type, options, ctx_obj);
9701 const ValueList &arg_value_list,
const char *name) {
9706 Process *process = target_sp->GetProcessSP().get();
9711 arg_value_list, name);
9714std::unique_ptr<UtilityFunction>
9721 return std::make_unique<ClangUtilityFunction>(
9722 *target_sp.get(), std::move(text), std::move(name),
9723 target_sp->GetDebugUtilityExpression());
9737 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9741 return std::make_unique<ClangASTSource>(
9746static llvm::StringRef
9750 return "scratch ASTContext for C++ module types";
9752 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9759 return *found_ast->second;
9762 std::shared_ptr<TypeSystemClang> new_ast_sp =
9772 const clang::RecordType *record_type =
9773 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9775 const clang::RecordDecl *record_decl =
9776 record_type->getDecl()->getDefinitionOrSelf();
9777 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9778 return metadata->IsForcefullyCompleted();
9787 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9791 metadata->SetIsForcefullyCompleted();
9799 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
CompilerType GetSizeType() override
static bool IsEnumType(lldb::opaque_compiler_type_t type)
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
CompilerType GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name) override
static bool SetObjCSuperClass(const CompilerType &type, const CompilerType &superclass_compiler_type)
clang::UsingDirectiveDecl * CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::NamespaceDecl *ns_decl)
static lldb::opaque_compiler_type_t GetOpaqueCompilerType(clang::ASTContext *ast, lldb::BasicType basic_type)
bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, bool *is_incomplete) override
void DumpFromSymbolFile(Stream &s, llvm::StringRef symbol_name)
Dump clang AST types from the symbol file.
CompilerType AddConstModifier(lldb::opaque_compiler_type_t type) override
static void DumpDeclHiearchy(clang::Decl *decl)
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
static clang::FunctionDecl * DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc)
bool IsScalarType(lldb::opaque_compiler_type_t type) override
bool GetPtrAuthAddressDiversity(lldb::opaque_compiler_type_t type) override
std::shared_ptr< clang::TargetOptions > m_target_options_rp
lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override
static bool IsClassType(lldb::opaque_compiler_type_t type)
bool IsDefined(lldb::opaque_compiler_type_t type) override
static bool IsObjCClassType(const CompilerType &type)
TypeMetadataMap m_type_metadata
Maps Types to their associated ClangASTMetadata.
CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override
bool RecordHasFields(const clang::RecordDecl *record_decl)
CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, const size_t index) override
static std::optional< ClangASTMetadata > DeclContextGetMetaData(const CompilerDeclContext &dc, const clang::Decl *object)
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerDiffType(bool is_signed) override
static clang::ObjCMethodDecl * AddMethodToObjCObjectType(const CompilerType &type, const char *name, const CompilerType &method_compiler_type, bool is_artificial, bool is_variadic, bool is_objc_direct_call)
~TypeSystemClang() override
CompilerDeclContext DeclGetDeclContext(void *opaque_decl) override
bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, void *other_opaque_decl_ctx) override
CompilerType AddPtrAuthModifier(lldb::opaque_compiler_type_t type, uint32_t payload) override
static bool AddObjCClassProperty(const CompilerType &type, const char *property_name, const CompilerType &property_compiler_type, clang::ObjCIvarDecl *ivar_decl, const char *property_setter_name, const char *property_getter_name, uint32_t property_attributes, ClangASTMetadata metadata)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
void SetMetadata(const clang::Decl *object, ClangASTMetadata meta_data)
clang::ParmVarDecl * CreateParameterDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType ¶m_type, int storage, bool add_decl=false)
void DumpTypeDescription(lldb::opaque_compiler_type_t type, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) override
Dump the type to stdout.
CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
static clang::NamespaceDecl * DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped, std::optional< clang::EnumExtensibilityAttr::Kind > enum_kind=std::nullopt)
npdb::PdbAstBuilder * GetNativePDBParser() override
std::unique_ptr< clang::DiagnosticConsumer > m_diagnostic_consumer_up
CompilerType CreateObjCClass(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool isInternal, std::optional< ClangASTMetadata > metadata=std::nullopt)
CompilerType GetTypeForDecl(clang::NamedDecl *decl)
CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc)
bool IsTypedefType(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override
std::optional< size_t > GetTypeBitAlign(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< clang::Builtin::Context > m_builtins_up
CompilerType GetBuiltinTypeByName(ConstString name) override
bool GetCompleteDecl(clang::Decl *decl)
static bool StartTagDeclarationDefinition(const CompilerType &type)
uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl, bool omit_empty_base_classes)
bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, CompilerType *target_type, bool check_cplusplus, bool check_objc) override
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, uint32_t bitfield_bit_size)
CompilerType GetOrCreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
void LogCreation() const
Emits information about this TypeSystem into the expression log.
static llvm::StringRef GetPluginNameStatic()
clang::Sema * m_sema
The sema associated that is currently used to build this ASTContext.
size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override
const clang::ClassTemplateSpecializationDecl * GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type)
std::unique_ptr< clang::MangleContext > m_mangle_ctx_up
TypeMemberFunctionImpl GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
bool IsTypeImpl(lldb::opaque_compiler_type_t type, llvm::function_ref< bool(clang::QualType)> predicate) const
size_t DeclGetFunctionNumArguments(void *opaque_decl) override
CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< PDBASTParser > m_pdb_ast_parser_up
std::unique_ptr< clang::DiagnosticsEngine > m_diagnostics_engine_up
static std::optional< std::string > GetCXXClassName(const CompilerType &type)
static void DumpTypeName(const CompilerType &type)
plugin::dwarf::DWARFASTParser * GetDWARFParser() override
CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx) override
bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
static clang::EnumDecl * GetAsEnumDecl(const CompilerType &type)
CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::ModuleMap > m_module_map_up
static bool IsObjCObjectOrInterfaceType(const CompilerType &type)
static void RequireCompleteType(CompilerType type)
Complete a type from debug info, or mark it as forcefully completed if there is no definition of the ...
CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload) override
Using the current type, create a new typedef to that type using "typedef_name" as the name and "decl_...
llvm::Expected< uint32_t > GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes, const ExecutionContext *exe_ctx) override
CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override
clang::TemplateTemplateParmDecl * CreateTemplateTemplateParmDecl(const char *template_name)
lldb::TemplateArgumentKind GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
clang::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
std::vector< lldb_private::CompilerContext > DeclGetCompilerContext(void *opaque_decl) override
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
std::vector< lldb_private::CompilerContext > DeclContextGetCompilerContext(void *opaque_decl_ctx) override
void CreateASTContext()
Creates the internal ASTContext.
void SetExternalSource(llvm::IntrusiveRefCntPtr< clang::ExternalASTSource > ast_source_sp)
CompilerType GetCStringType(bool is_const)
bool IsAggregateType(lldb::opaque_compiler_type_t type) override
bool IsPromotableIntegerType(lldb::opaque_compiler_type_t type) override
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override
static LanguageSet GetSupportedLanguagesForTypes()
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
ConstString DeclContextGetName(void *opaque_decl_ctx) override
size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack) override
ConstString DeclGetName(void *opaque_decl) override
SymbolFile * GetSymbolFile() const
bool m_has_forcefully_completed_types
Used for reporting statistics.
Encapsulates a one-time expression for use in lldb.
virtual uint64_t GetData(DataExtractor &data, Status &error)
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
AddressType GetAddressTypeOfChildren()
CompilerType GetCompilerType()
ConstString GetName() const
const ExecutionContextRef & GetExecutionContextRef() const
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_IVAR_OFFSET
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, uint32_t item_bit_size, uint32_t item_bit_offset, ExecutionContextScope *exe_scope=nullptr, bool show_memory_tags=false)
Dumps item_count objects into the stream s.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
void * opaque_compiler_type_t
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eBasicTypeUnsignedShort
@ eBasicTypeUnsignedInt128
@ eBasicTypeUnsignedWChar
@ eBasicTypeLongDoubleComplex
@ eBasicTypeUnsignedLongLong
@ eBasicTypeDoubleComplex
Format
Display format definitions.
@ eFormatCString
NULL terminated C strings.
@ eFormatCharArray
Print characters with no single quotes, used for character arrays that can contain non printable char...
@ eFormatVoid
Do not print this.
@ eFormatComplex
Floating point complex type.
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
@ eFormatComplexInteger
Integer complex type.
@ eFormatFloat128
Disambiguate between 128-bit long double (which uses eFormatFloat) and __float128 (which uses eFormat...
LanguageType
Programming language type.
@ eLanguageTypeC_plus_plus_20
ISO C++:2020.
@ eLanguageTypeC_plus_plus_14
ISO C++:2014.
@ eLanguageTypeC11
ISO C:2011.
@ eLanguageTypeC99
ISO C:1999.
@ eLanguageTypeC_plus_plus_03
ISO C++:2003.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeC_plus_plus_17
ISO C++:2017.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
@ eLanguageTypeC_plus_plus_11
ISO C++:2011.
@ eLanguageTypeC89
ISO C:1989.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
@ eLanguageTypeDylan
Dylan.
std::shared_ptr< lldb_private::Type > TypeSP
@ eTemplateArgumentKindTemplate
@ eTemplateArgumentKindTemplateExpansion
@ eTemplateArgumentKindNull
@ eTemplateArgumentKindNullPtr
@ eTemplateArgumentKindDeclaration
@ eTemplateArgumentKindIntegral
@ eTemplateArgumentKindPack
@ eTemplateArgumentKindType
@ eTemplateArgumentKindStructuralValue
@ eTemplateArgumentKindExpression
Encoding
Register encoding definitions.
@ eEncodingVector
vector registers
@ eEncodingUint
unsigned integer
@ eEncodingSint
signed integer
MemberFunctionKind
Kind of member function.
@ eMemberFunctionKindInstanceMethod
A function that applies to a specific instance.
@ eMemberFunctionKindConstructor
A function used to create instances.
@ eMemberFunctionKindUnknown
Not sure what the type of this is.
@ eMemberFunctionKindDestructor
A function used to tear down existing instances.
@ eMemberFunctionKindStaticMethod
A function that applies to a type rather than any instance.
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Target > TargetSP
static clang::QualType GetQualType(const CompilerType &ct)
static clang::QualType GetCanonicalQualType(const CompilerType &ct)
static bool IsClangType(const CompilerType &ct)
static CompilerType RemoveFastQualifiers(const CompilerType &ct)
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
static llvm::Expected< FunctionCallLabel > fromString(llvm::StringRef label)
Decodes the specified function label into a FunctionCallLabel.
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
void Insert(lldb::LanguageType language)
A type-erased pair of llvm::dwarf::SourceLanguageName and version.