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/Driver/CreateInvocationFromArgs.h"
45#include "clang/Driver/Driver.h"
46#include "clang/Frontend/CompilerInstance.h"
47#include "clang/Frontend/CompilerInvocation.h"
48#include "clang/Frontend/FrontendActions.h"
49#include "clang/Frontend/FrontendOptions.h"
50#include "clang/Lex/HeaderSearch.h"
51#include "clang/Lex/HeaderSearchOptions.h"
52#include "clang/Lex/ModuleMap.h"
53#include "clang/Sema/Sema.h"
54#include "clang/Serialization/ObjectFilePCHContainerReader.h"
56#include "llvm/Support/Signals.h"
57#include "llvm/Support/Threading.h"
106using namespace llvm::dwarf;
107using namespace clang;
108using llvm::StringSwitch;
113static void VerifyDecl(clang::Decl *decl) {
114 assert(decl &&
"VerifyDecl called with nullptr?");
140bool isOverload(clang::CXXMethodDecl *m1, clang::CXXMethodDecl *m2) {
142 lldbassert(&m1->getASTContext() == &m2->getASTContext() &&
143 "Methods should have the same AST context");
144 clang::ASTContext &context = m1->getASTContext();
146 const auto *m1Type = llvm::cast<clang::FunctionProtoType>(
147 context.getCanonicalType(m1->getType()));
149 const auto *m2Type = llvm::cast<clang::FunctionProtoType>(
150 context.getCanonicalType(m2->getType()));
152 auto compareArgTypes = [&context](
const clang::QualType &m1p,
153 const clang::QualType &m2p) {
154 return context.hasSameType(m1p.getUnqualifiedType(),
155 m2p.getUnqualifiedType());
160 return (m1->getNumParams() != m2->getNumParams()) ||
161 !std::equal(m1Type->param_type_begin(), m1Type->param_type_end(),
162 m2Type->param_type_begin(), compareArgTypes);
168void addOverridesForMethod(clang::CXXMethodDecl *decl) {
169 if (!decl->isVirtual())
172 clang::CXXBasePaths paths;
173 llvm::SmallVector<clang::NamedDecl *, 4> decls;
175 auto find_overridden_methods =
176 [&decls, decl](
const clang::CXXBaseSpecifier *specifier,
177 clang::CXXBasePath &path) {
178 if (
auto *base_record = specifier->getType()->getAsCXXRecordDecl()) {
180 clang::DeclarationName name = decl->getDeclName();
184 if (name.getNameKind() == clang::DeclarationName::CXXDestructorName)
185 if (
auto *baseDtorDecl = base_record->getDestructor()) {
186 if (baseDtorDecl->isVirtual()) {
187 decls.push_back(baseDtorDecl);
194 for (path.Decls = base_record->lookup(name).begin();
195 path.Decls != path.Decls.end(); ++path.Decls) {
196 if (
auto *method_decl =
197 llvm::dyn_cast<clang::CXXMethodDecl>(*path.Decls))
198 if (method_decl->isVirtual() && !isOverload(decl, method_decl)) {
199 decls.push_back(method_decl);
208 if (decl->getParent()->lookupInBases(find_overridden_methods, paths)) {
209 for (
auto *overridden_decl : decls)
210 decl->addOverriddenMethod(
211 llvm::cast<clang::CXXMethodDecl>(overridden_decl));
217 VTableContextBase &vtable_ctx,
219 const ASTRecordLayout &record_layout) {
223 uint32_t type_info = this_type.
GetTypeInfo(&pointee_type);
228 bool ptr_or_ref =
false;
229 if (type_info & (eTypeIsPointer | eTypeIsReference)) {
235 const uint32_t cpp_class = eTypeIsClass | eTypeIsCPlusPlus;
236 if ((type_info & cpp_class) != cpp_class)
241 vtable_ctx.isMicrosoft() ? record_layout.getVBPtrOffset().getQuantity()
255 vbtable_ptr_addr += vbtable_ptr_offset;
257 llvm::Expected<lldb::addr_t> vbtable_ptr_addr_or_err =
259 if (!vbtable_ptr_addr_or_err) {
260 llvm::consumeError(vbtable_ptr_addr_or_err.takeError());
263 return *vbtable_ptr_addr_or_err;
271 auto size = valobj.
GetData(data, err);
279 VTableContextBase &vtable_ctx,
281 const CXXRecordDecl *cxx_record_decl,
282 const CXXRecordDecl *base_class_decl) {
283 if (vtable_ctx.isMicrosoft()) {
284 clang::MicrosoftVTableContext &msoft_vtable_ctx =
285 static_cast<clang::MicrosoftVTableContext &
>(vtable_ctx);
289 const unsigned vbtable_index =
290 msoft_vtable_ctx.getVBTableIndex(cxx_record_decl, base_class_decl);
291 const lldb::addr_t base_offset_addr = vtable_ptr + vbtable_index * 4;
297 clang::ItaniumVTableContext &itanium_vtable_ctx =
298 static_cast<clang::ItaniumVTableContext &
>(vtable_ctx);
300 clang::CharUnits base_offset_offset =
301 itanium_vtable_ctx.getVirtualBaseOffsetOffset(cxx_record_decl,
304 vtable_ptr + base_offset_offset.getQuantity();
313 const ASTRecordLayout &record_layout,
314 const CXXRecordDecl *cxx_record_decl,
315 const CXXRecordDecl *base_class_decl,
316 int32_t &bit_offset) {
328 *process, vtable_ctx, vtable_ptr, cxx_record_decl, base_class_decl);
329 if (base_offset == INT64_MAX)
332 if (vtable_ctx.isMicrosoft())
333 base_offset += record_layout.getVBPtrOffset().getQuantity();
334 bit_offset = base_offset * 8;
344 static llvm::once_flag g_once_flag;
345 llvm::call_once(g_once_flag, []() {
352 bool is_complete_objc_class)
365 const clang::Decl *parent) {
366 if (!member || !parent)
373 member->setFromASTFile();
374 member->setOwningModuleID(
id.GetValue());
375 member->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
376 if (llvm::isa<clang::NamedDecl>(member))
377 if (
auto *dc = llvm::dyn_cast<clang::DeclContext>(parent)) {
378 dc->setHasExternalVisibleStorage(
true);
381 dc->setHasExternalLexicalStorage(
true);
388 clang::OverloadedOperatorKind &op_kind) {
390 if (!name.consume_front(
"operator"))
395 bool space_after_operator = name.consume_front(
" ");
397 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
398 .Case(
"+", clang::OO_Plus)
399 .Case(
"+=", clang::OO_PlusEqual)
400 .Case(
"++", clang::OO_PlusPlus)
401 .Case(
"-", clang::OO_Minus)
402 .Case(
"-=", clang::OO_MinusEqual)
403 .Case(
"--", clang::OO_MinusMinus)
404 .Case(
"->", clang::OO_Arrow)
405 .Case(
"->*", clang::OO_ArrowStar)
406 .Case(
"*", clang::OO_Star)
407 .Case(
"*=", clang::OO_StarEqual)
408 .Case(
"/", clang::OO_Slash)
409 .Case(
"/=", clang::OO_SlashEqual)
410 .Case(
"%", clang::OO_Percent)
411 .Case(
"%=", clang::OO_PercentEqual)
412 .Case(
"^", clang::OO_Caret)
413 .Case(
"^=", clang::OO_CaretEqual)
414 .Case(
"&", clang::OO_Amp)
415 .Case(
"&=", clang::OO_AmpEqual)
416 .Case(
"&&", clang::OO_AmpAmp)
417 .Case(
"|", clang::OO_Pipe)
418 .Case(
"|=", clang::OO_PipeEqual)
419 .Case(
"||", clang::OO_PipePipe)
420 .Case(
"~", clang::OO_Tilde)
421 .Case(
"!", clang::OO_Exclaim)
422 .Case(
"!=", clang::OO_ExclaimEqual)
423 .Case(
"=", clang::OO_Equal)
424 .Case(
"==", clang::OO_EqualEqual)
425 .Case(
"<", clang::OO_Less)
426 .Case(
"<=>", clang::OO_Spaceship)
427 .Case(
"<<", clang::OO_LessLess)
428 .Case(
"<<=", clang::OO_LessLessEqual)
429 .Case(
"<=", clang::OO_LessEqual)
430 .Case(
">", clang::OO_Greater)
431 .Case(
">>", clang::OO_GreaterGreater)
432 .Case(
">>=", clang::OO_GreaterGreaterEqual)
433 .Case(
">=", clang::OO_GreaterEqual)
434 .Case(
"()", clang::OO_Call)
435 .Case(
"[]", clang::OO_Subscript)
436 .Case(
",", clang::OO_Comma)
437 .Default(clang::NUM_OVERLOADED_OPERATORS);
440 if (op_kind != clang::NUM_OVERLOADED_OPERATORS)
452 if (!space_after_operator)
457 op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
458 .Case(
"new", clang::OO_New)
459 .Case(
"new[]", clang::OO_Array_New)
460 .Case(
"delete", clang::OO_Delete)
461 .Case(
"delete[]", clang::OO_Array_Delete)
463 .Default(clang::NUM_OVERLOADED_OPERATORS);
468clang::AccessSpecifier
488 std::vector<std::string> Includes;
489 LangOptions::setLangDefaults(Opts, clang::Language::ObjCXX, arch.
GetTriple(),
490 Includes, clang::LangStandard::lang_gnucxx98);
492 Opts.setValueVisibilityMode(DefaultVisibility);
496 Opts.Trigraphs = !Opts.GNUMode;
501 Opts.ModulesLocalVisibility = 1;
505 llvm::Triple target_triple) {
507 if (!target_triple.str().empty())
517 ASTContext &existing_ctxt) {
533 if (!TypeSystemClangSupportsLanguage(language))
537 arch =
module->GetArchitecture();
547 if (triple.getVendor() == llvm::Triple::Apple &&
548 triple.getOS() == llvm::Triple::UnknownOS) {
549 if (triple.getArch() == llvm::Triple::arm ||
550 triple.getArch() == llvm::Triple::aarch64 ||
551 triple.getArch() == llvm::Triple::aarch64_32 ||
552 triple.getArch() == llvm::Triple::thumb) {
553 triple.setOS(llvm::Triple::IOS);
555 triple.setOS(llvm::Triple::MacOSX);
560 std::string ast_name =
561 "ASTContext for '" +
module->GetFileSpec().GetPath() + "'";
562 return std::make_shared<TypeSystemClang>(ast_name, triple);
563 }
else if (target && target->
IsValid())
564 return std::make_shared<ScratchTypeSystemClang>(*target, triple);
603 interpreter,
"target modules dump pcm-info",
604 "Dump information about the given clang module (pcm).") {
609 ~CommandObjectTargetModulesDumpClangPCMInfo()
override =
default;
620 const FileSpec pcm_file{pcm_path};
623 result.
AppendError(
"file must have a .pcm extension");
632 const char *clang_args[] = {
"clang", pcm_path};
633 clang::CompilerInstance compiler(clang::createInvocation(clang_args));
634 compiler.setVirtualFileSystem(
636 compiler.createDiagnostics();
640 std::shared_ptr<llvm::raw_ostream> Out(
642 clang::DumpModuleInfoAction dump_module_info(Out);
644 compiler.getPCHContainerOperations()->registerReader(
645 std::make_unique<clang::ObjectFilePCHContainerReader>());
647 if (compiler.ExecuteAction(dump_module_info))
659 llvm::SmallString<128> path;
660 if (clang::driver::Driver::getDefaultModuleCachePath(path))
671 llvm::StringRef parent =
"target modules dump";
673 dump->LoadSubCommand(
675 std::make_shared<CommandObjectTargetModulesDumpClangPCMInfo>(
697 assert(s ==
nullptr || &s->getASTContext() ==
m_ast_up.get());
710 llvm::IntrusiveRefCntPtr<ExternalASTSource> ast_source_sp) {
712 ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(
true);
713 ast.setExternalSource(std::move(ast_source_sp));
726 const clang::Diagnostic &info)
override {
728 llvm::SmallVector<char, 32> diag_str(10);
729 info.FormatDiagnostic(diag_str);
730 diag_str.push_back(
'\0');
735 DiagnosticConsumer *
clone(DiagnosticsEngine &Diags)
const {
756 clang::FileSystemOptions file_system_options;
766 m_ast_up = std::make_unique<ASTContext>(
778 m_ast_up->InitBuiltinTypes(*target_info);
782 "Failed to initialize builtin ASTContext types for target '{0}'. "
783 "Printing variables may behave unexpectedly.",
789 static std::once_flag s_uninitialized_target_warning;
791 &s_uninitialized_target_warning);
797 llvm::makeIntrusiveRefCnt<ClangExternalASTSourceCallbacks>(*
this);
829#pragma mark Basic Types
832 ASTContext &ast, QualType qual_type) {
833 uint64_t qual_type_bit_size = ast.getTypeSize(qual_type);
834 return qual_type_bit_size == bit_size;
853 return GetType(ast.UnsignedCharTy);
855 return GetType(ast.UnsignedShortTy);
857 return GetType(ast.UnsignedIntTy);
859 return GetType(ast.UnsignedLongTy);
861 return GetType(ast.UnsignedLongLongTy);
863 return GetType(ast.UnsignedInt128Ty);
868 return GetType(ast.SignedCharTy);
876 return GetType(ast.LongLongTy);
887 return GetType(ast.LongDoubleTy);
891 return GetType(ast.Float128Ty);
896 if (bit_size && !(bit_size & 0x7u))
897 return GetType(ast.getExtVectorType(ast.UnsignedCharTy, bit_size / 8));
905 static const llvm::StringMap<lldb::BasicType> g_type_map = {
970 auto iter = g_type_map.find(name);
971 if (iter == g_type_map.end())
1002 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
1012 case DW_ATE_address:
1014 return GetType(ast.VoidPtrTy);
1017 case DW_ATE_boolean:
1021 return GetType(ast.UnsignedCharTy);
1023 return GetType(ast.UnsignedShortTy);
1025 return GetType(ast.UnsignedIntTy);
1028 case DW_ATE_lo_user:
1030 if (type_name.contains(
"complex")) {
1039 case DW_ATE_complex_float: {
1040 CanQualType FloatComplexTy = ast.getComplexType(ast.FloatTy);
1042 return GetType(FloatComplexTy);
1044 CanQualType DoubleComplexTy = ast.getComplexType(ast.DoubleTy);
1046 return GetType(DoubleComplexTy);
1048 CanQualType LongDoubleComplexTy = ast.getComplexType(ast.LongDoubleTy);
1050 return GetType(LongDoubleComplexTy);
1060 if (type_name ==
"float" &&
1063 if (type_name ==
"double" &&
1066 if (type_name ==
"long double" &&
1068 return GetType(ast.LongDoubleTy);
1069 if (type_name ==
"__bf16" &&
1071 return GetType(ast.BFloat16Ty);
1072 if (type_name ==
"_Float16" &&
1074 return GetType(ast.Float16Ty);
1078 if ((type_name ==
"__float128" || type_name ==
"_Float128" ||
1079 type_name ==
"f128") &&
1081 return GetType(ast.Float128Ty);
1088 return GetType(ast.LongDoubleTy);
1092 return GetType(ast.Float128Ty);
1096 if (!type_name.empty()) {
1097 if (type_name.starts_with(
"_BitInt"))
1098 return GetType(ast.getBitIntType(
false, bit_size));
1099 if (type_name ==
"wchar_t" &&
1104 if (type_name ==
"void" &&
1107 if (type_name.contains(
"long long") &&
1109 return GetType(ast.LongLongTy);
1110 if (type_name.contains(
"long") &&
1113 if (type_name.contains(
"short") &&
1116 if (type_name.contains(
"char")) {
1120 return GetType(ast.SignedCharTy);
1122 if (type_name.contains(
"int")) {
1139 return GetType(ast.LongLongTy);
1144 case DW_ATE_signed_char:
1145 if (type_name ==
"char") {
1150 return GetType(ast.SignedCharTy);
1153 case DW_ATE_unsigned:
1154 if (!type_name.empty()) {
1155 if (type_name.starts_with(
"unsigned _BitInt"))
1156 return GetType(ast.getBitIntType(
true, bit_size));
1157 if (type_name ==
"wchar_t") {
1164 if (type_name.contains(
"long long")) {
1166 return GetType(ast.UnsignedLongLongTy);
1167 }
else if (type_name.contains(
"long")) {
1169 return GetType(ast.UnsignedLongTy);
1170 }
else if (type_name.contains(
"short")) {
1172 return GetType(ast.UnsignedShortTy);
1173 }
else if (type_name.contains(
"char")) {
1175 return GetType(ast.UnsignedCharTy);
1176 }
else if (type_name.contains(
"int")) {
1178 return GetType(ast.UnsignedIntTy);
1180 return GetType(ast.UnsignedInt128Ty);
1185 return GetType(ast.UnsignedCharTy);
1187 return GetType(ast.UnsignedShortTy);
1189 return GetType(ast.UnsignedIntTy);
1191 return GetType(ast.UnsignedLongTy);
1193 return GetType(ast.UnsignedLongLongTy);
1195 return GetType(ast.UnsignedInt128Ty);
1198 case DW_ATE_unsigned_char:
1199 if (type_name ==
"char") {
1204 return GetType(ast.UnsignedCharTy);
1206 return GetType(ast.UnsignedShortTy);
1209 case DW_ATE_imaginary_float:
1221 if (!type_name.empty()) {
1222 if (type_name ==
"char16_t")
1224 if (type_name ==
"char32_t")
1226 if (type_name ==
"char8_t")
1235 "error: need to add support for DW_TAG_base_type '{0}' "
1236 "encoded with DW_ATE = {1:x}, bit_size = {2}",
1237 type_name, dw_ate, bit_size);
1243 QualType char_type(ast.CharTy);
1246 char_type.addConst();
1248 return GetType(ast.getPointerType(char_type));
1252 bool ignore_qualifiers) {
1263 if (ignore_qualifiers) {
1264 type1_qual = type1_qual.getUnqualifiedType();
1265 type2_qual = type2_qual.getUnqualifiedType();
1268 return ast->getASTContext().hasSameType(type1_qual, type2_qual);
1275 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
1276 if (
auto *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl))
1288 if (clang::ObjCInterfaceDecl *interface_decl =
1289 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
1291 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl))
1293 if (clang::ValueDecl *value_decl = llvm::dyn_cast<clang::ValueDecl>(decl))
1307 return GetType(value_decl->getType());
1310#pragma mark Structure, Unions, Classes
1314 if (!decl || !owning_module.
HasValue())
1317 decl->setFromASTFile();
1318 decl->setOwningModuleID(owning_module.
GetValue());
1319 decl->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
1325 bool is_framework,
bool is_explicit) {
1327 auto *ast_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
1329 assert(ast_source &&
"external ast source was lost");
1347 clang::Module *module;
1348 auto parent_desc = ast_source->getSourceDescriptor(parent.
GetValue());
1350 name, parent_desc ? parent_desc->getModuleOrNull() :
nullptr,
1351 is_framework, is_explicit);
1353 return ast_source->GetIDForModule(module);
1355 return ast_source->RegisterModule(module);
1361 std::optional<ClangASTMetadata> metadata,
bool exports_symbols) {
1364 if (decl_ctx ==
nullptr)
1365 decl_ctx = ast.getTranslationUnitDecl();
1369 bool isInternal =
false;
1370 return CreateObjCClass(name, decl_ctx, owning_module, isInternal, metadata);
1379 bool has_name = !name.empty();
1380 CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1381 decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1382 decl->setDeclContext(decl_ctx);
1384 decl->setDeclName(&ast.Idents.get(name));
1412 if (isa<CXXRecordDecl>(decl_ctx) && exports_symbols)
1413 decl->setAnonymousStructOrUnion(
true);
1425 decl->setAccess(AS_public);
1428 decl_ctx->addDecl(decl);
1430 return GetType(ast.getCanonicalTagType(decl));
1437QualType GetValueParamType(
const clang::TemplateArgument &argument) {
1438 switch (argument.getKind()) {
1439 case TemplateArgument::Integral:
1440 return argument.getIntegralType();
1441 case TemplateArgument::StructuralValue:
1442 return argument.getStructuralValueType();
1452 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1453 const bool parameter_pack =
false;
1454 const bool is_typename =
false;
1455 const unsigned depth = 0;
1456 const size_t num_template_params = template_param_infos.
Size();
1457 DeclContext *
const decl_context =
1458 ast.getTranslationUnitDecl();
1460 auto const &args = template_param_infos.
GetArgs();
1461 auto const &names = template_param_infos.
GetNames();
1462 for (
size_t i = 0; i < num_template_params; ++i) {
1463 const char *name = names[i];
1465 IdentifierInfo *identifier_info =
nullptr;
1466 if (name && name[0])
1467 identifier_info = &ast.Idents.get(name);
1468 TemplateArgument
const &targ = args[i];
1469 QualType template_param_type = GetValueParamType(targ);
1470 if (!template_param_type.isNull()) {
1471 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1472 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1473 identifier_info, template_param_type, parameter_pack,
1474 ast.getTrivialTypeSourceInfo(template_param_type)));
1476 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1477 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1478 identifier_info, is_typename, parameter_pack));
1483 IdentifierInfo *identifier_info =
nullptr;
1485 identifier_info = &ast.Idents.get(template_param_infos.
GetPackName());
1486 const bool parameter_pack_true =
true;
1488 QualType template_param_type =
1492 if (!template_param_type.isNull()) {
1493 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1494 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1495 num_template_params, identifier_info, template_param_type,
1496 parameter_pack_true,
1497 ast.getTrivialTypeSourceInfo(template_param_type)));
1499 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1500 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1501 num_template_params, identifier_info, is_typename,
1502 parameter_pack_true));
1505 clang::Expr *
const requires_clause =
nullptr;
1506 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1507 ast, SourceLocation(), SourceLocation(), template_param_decls,
1508 SourceLocation(), requires_clause);
1509 return template_param_list;
1514 clang::FunctionDecl *func_decl,
1519 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1521 ast, template_param_infos, template_param_decls);
1522 FunctionTemplateDecl *func_tmpl_decl =
1523 FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1524 func_tmpl_decl->setDeclContext(decl_ctx);
1525 func_tmpl_decl->setLocation(func_decl->getLocation());
1526 func_tmpl_decl->setDeclName(func_decl->getDeclName());
1527 func_tmpl_decl->setTemplateParameters(template_param_list);
1528 func_tmpl_decl->init(func_decl);
1531 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1532 i < template_param_decl_count; ++i) {
1534 template_param_decls[i]->setDeclContext(func_decl);
1536 func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
1538 return func_tmpl_decl;
1542 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1544 TemplateArgumentList *template_args_ptr = TemplateArgumentList::CreateCopy(
1545 func_decl->getASTContext(), infos.
GetArgs());
1547 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
1548 template_args_ptr, {});
1555 const TemplateArgument &value) {
1556 if (llvm::isa<TemplateTypeParmDecl>(param)) {
1558 if (value.getKind() != TemplateArgument::Type)
1560 }
else if (
auto *type_param =
1561 llvm::dyn_cast<NonTypeTemplateParmDecl>(param)) {
1563 QualType value_param_type = GetValueParamType(value);
1564 if (value_param_type.isNull())
1568 if (type_param->getType() != value_param_type)
1576 "Don't know how to compare template parameter to passed"
1577 " value. Decl kind of parameter is: {0}",
1578 param->getDeclKindName());
1579 lldbassert(
false &&
"Can't compare this TemplateParmDecl subclass");
1594 ClassTemplateDecl *class_template_decl,
1597 TemplateParameterList ¶ms = *class_template_decl->getTemplateParameters();
1603 std::optional<NamedDecl *> pack_parameter;
1605 size_t non_pack_params = params.size();
1606 for (
size_t i = 0; i < params.size(); ++i) {
1607 NamedDecl *param = params.getParam(i);
1608 if (param->isParameterPack()) {
1609 pack_parameter = param;
1610 non_pack_params = i;
1618 if (non_pack_params != instantiation_values.
Size())
1636 for (
const auto pair :
1637 llvm::zip_first(instantiation_values.
GetArgs(), params)) {
1638 const TemplateArgument &passed_arg = std::get<0>(pair);
1639 NamedDecl *found_param = std::get<1>(pair);
1644 return class_template_decl;
1649 llvm::StringRef class_name,
int kind,
1653 ClassTemplateDecl *class_template_decl =
nullptr;
1654 if (decl_ctx ==
nullptr)
1655 decl_ctx = ast.getTranslationUnitDecl();
1657 IdentifierInfo &identifier_info = ast.Idents.get(class_name);
1658 DeclarationName decl_name(&identifier_info);
1661 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1662 for (NamedDecl *decl : result) {
1663 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1664 if (!class_template_decl)
1673 template_param_infos))
1675 return class_template_decl;
1678 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1681 ast, template_param_infos, template_param_decls);
1683 CXXRecordDecl *template_cxx_decl =
1684 CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1685 template_cxx_decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1687 template_cxx_decl->setDeclContext(decl_ctx);
1688 template_cxx_decl->setDeclName(decl_name);
1691 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1692 i < template_param_decl_count; ++i) {
1693 template_param_decls[i]->setDeclContext(template_cxx_decl);
1701 class_template_decl =
1702 ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1704 class_template_decl->setDeclContext(decl_ctx);
1705 class_template_decl->setDeclName(decl_name);
1706 class_template_decl->setTemplateParameters(template_param_list);
1707 class_template_decl->init(template_cxx_decl);
1708 template_cxx_decl->setDescribedClassTemplate(class_template_decl);
1711 class_template_decl->setAccess(AS_public);
1713 decl_ctx->addDecl(class_template_decl);
1715 VerifyDecl(class_template_decl);
1717 return class_template_decl;
1720TemplateTemplateParmDecl *
1724 auto *decl_ctx = ast.getTranslationUnitDecl();
1726 IdentifierInfo &identifier_info = ast.Idents.get(template_name);
1727 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1731 std::make_unique<TemplateParameterInfos>());
1733 ast, template_param_infos, template_param_decls);
1739 return TemplateTemplateParmDecl::Create(
1740 ast, decl_ctx, SourceLocation(),
1742 false, &identifier_info,
1743 TemplateNameKind::TNK_Type_template,
true,
1744 template_param_list);
1747ClassTemplateSpecializationDecl *
1750 ClassTemplateDecl *class_template_decl,
int kind,
1753 llvm::SmallVector<clang::TemplateArgument, 2> args(
1754 template_param_infos.
Size() +
1757 auto const &orig_args = template_param_infos.
GetArgs();
1758 std::copy(orig_args.begin(), orig_args.end(), args.begin());
1760 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1763 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1764 ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
1765 class_template_specialization_decl->setTagKind(
1766 static_cast<TagDecl::TagKind
>(kind));
1767 class_template_specialization_decl->setDeclContext(decl_ctx);
1768 class_template_specialization_decl->setInstantiationOf(class_template_decl);
1769 class_template_specialization_decl->setTemplateArgs(
1770 TemplateArgumentList::CreateCopy(ast, args));
1771 llvm::FoldingSetInsertToken insert_token;
1772 if (class_template_decl->findSpecialization(args, insert_token))
1774 class_template_decl->AddSpecialization(class_template_specialization_decl,
1776 class_template_specialization_decl->setDeclName(
1777 class_template_decl->getDeclName());
1782 class_template_specialization_decl->setStrictPackMatch(
false);
1785 decl_ctx->addDecl(class_template_specialization_decl);
1787 class_template_specialization_decl->setSpecializationKind(
1788 TSK_ExplicitSpecialization);
1790 return class_template_specialization_decl;
1794 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1795 if (class_template_specialization_decl) {
1797 return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
1803 clang::OverloadedOperatorKind op_kind,
1804 bool unary,
bool binary,
1805 uint32_t num_params) {
1807 if (op_kind == OO_Call)
1813 if (num_params == 1)
1815 if (num_params == 2)
1822 bool is_method, clang::OverloadedOperatorKind op_kind,
1823 uint32_t num_params) {
1831 case OO_Array_Delete:
1835#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1837 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1839#include "clang/Basic/OperatorKinds.def"
1847 uint32_t &bitfield_bit_size) {
1849 if (field ==
nullptr)
1852 if (field->isBitField()) {
1853 Expr *bit_width_expr = field->getBitWidth();
1854 if (bit_width_expr) {
1855 if (std::optional<llvm::APSInt> bit_width_apsint =
1856 bit_width_expr->getIntegerConstantExpr(ast)) {
1857 bitfield_bit_size = bit_width_apsint->getLimitedValue(
UINT32_MAX);
1866 if (record_decl ==
nullptr)
1869 if (!record_decl->field_empty())
1873 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1874 if (cxx_record_decl) {
1875 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1876 for (base_class = cxx_record_decl->bases_begin(),
1877 base_class_end = cxx_record_decl->bases_end();
1878 base_class != base_class_end; ++base_class) {
1879 assert(record_decl != base_class->getType()->getAsCXXRecordDecl() &&
1880 "Base can't inherit from itself.");
1892 if (std::optional<ClangASTMetadata> meta_data =
GetMetadata(record_decl);
1893 meta_data && meta_data->IsForcefullyCompleted())
1899#pragma mark Objective-C Classes
1902 llvm::StringRef name, clang::DeclContext *decl_ctx,
1904 std::optional<ClangASTMetadata> metadata) {
1906 assert(!name.empty());
1908 decl_ctx = ast.getTranslationUnitDecl();
1910 ObjCInterfaceDecl *decl =
1911 ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
1912 decl->setDeclContext(decl_ctx);
1913 decl->setDeclName(&ast.Idents.get(name));
1914 decl->setImplicit(isInternal);
1920 return GetType(ast.getObjCInterfaceType(decl));
1929 bool omit_empty_base_classes) {
1930 uint32_t num_bases = 0;
1931 if (cxx_record_decl) {
1932 if (omit_empty_base_classes) {
1933 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1934 for (base_class = cxx_record_decl->bases_begin(),
1935 base_class_end = cxx_record_decl->bases_end();
1936 base_class != base_class_end; ++base_class) {
1943 num_bases = cxx_record_decl->getNumBases();
1948#pragma mark Namespace Declarations
1951 const char *name, clang::DeclContext *decl_ctx,
1953 NamespaceDecl *namespace_decl =
nullptr;
1955 TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
1957 decl_ctx = translation_unit_decl;
1960 IdentifierInfo &identifier_info = ast.Idents.get(name);
1961 DeclarationName decl_name(&identifier_info);
1962 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1963 for (NamedDecl *decl : result) {
1964 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1966 return namespace_decl;
1969 namespace_decl = NamespaceDecl::Create(ast, decl_ctx, is_inline,
1970 SourceLocation(), SourceLocation(),
1971 &identifier_info,
nullptr,
false);
1973 decl_ctx->addDecl(namespace_decl);
1975 if (decl_ctx == translation_unit_decl) {
1976 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1978 return namespace_decl;
1981 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1982 SourceLocation(),
nullptr,
nullptr,
false);
1983 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1984 translation_unit_decl->addDecl(namespace_decl);
1985 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace());
1987 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1988 if (parent_namespace_decl) {
1989 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1991 return namespace_decl;
1993 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1994 SourceLocation(),
nullptr,
nullptr,
false);
1995 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1996 parent_namespace_decl->addDecl(namespace_decl);
1997 assert(namespace_decl ==
1998 parent_namespace_decl->getAnonymousNamespace());
2000 assert(
false &&
"GetUniqueNamespaceDeclaration called with no name and "
2001 "no namespace as decl_ctx");
2009 VerifyDecl(namespace_decl);
2010 return namespace_decl;
2017 clang::BlockDecl *decl =
2018 clang::BlockDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
2019 decl->setDeclContext(ctx);
2028 clang::DeclContext *right,
2029 clang::DeclContext *root) {
2030 if (root ==
nullptr)
2033 std::set<clang::DeclContext *> path_left;
2034 for (clang::DeclContext *d = left; d !=
nullptr; d = d->getParent())
2035 path_left.insert(d);
2037 for (clang::DeclContext *d = right; d !=
nullptr; d = d->getParent())
2038 if (path_left.find(d) != path_left.end())
2046 clang::NamespaceDecl *ns_decl) {
2047 if (decl_ctx && ns_decl) {
2048 auto *translation_unit =
getASTContext().getTranslationUnitDecl();
2049 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
2051 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
2052 clang::SourceLocation(), ns_decl,
2055 decl_ctx->addDecl(using_decl);
2065 clang::NamedDecl *target) {
2066 if (current_decl_ctx && target) {
2067 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
2069 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(),
false);
2071 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
2073 target->getDeclName(), using_decl, target);
2075 using_decl->addShadowDecl(shadow_decl);
2076 current_decl_ctx->addDecl(using_decl);
2084 const char *name, clang::QualType type) {
2086 clang::VarDecl *var_decl =
2087 clang::VarDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
2088 var_decl->setDeclContext(decl_context);
2089 if (name && name[0])
2090 var_decl->setDeclName(&
getASTContext().Idents.getOwn(name));
2091 var_decl->setType(type);
2093 var_decl->setAccess(clang::AS_public);
2094 decl_context->addDecl(var_decl);
2103 switch (basic_type) {
2105 return ast->VoidTy.getAsOpaquePtr();
2107 return ast->CharTy.getAsOpaquePtr();
2109 return ast->SignedCharTy.getAsOpaquePtr();
2111 return ast->UnsignedCharTy.getAsOpaquePtr();
2113 return ast->getWCharType().getAsOpaquePtr();
2115 return ast->getSignedWCharType().getAsOpaquePtr();
2117 return ast->getUnsignedWCharType().getAsOpaquePtr();
2119 return ast->Char8Ty.getAsOpaquePtr();
2121 return ast->Char16Ty.getAsOpaquePtr();
2123 return ast->Char32Ty.getAsOpaquePtr();
2125 return ast->ShortTy.getAsOpaquePtr();
2127 return ast->UnsignedShortTy.getAsOpaquePtr();
2129 return ast->IntTy.getAsOpaquePtr();
2131 return ast->UnsignedIntTy.getAsOpaquePtr();
2133 return ast->LongTy.getAsOpaquePtr();
2135 return ast->UnsignedLongTy.getAsOpaquePtr();
2137 return ast->LongLongTy.getAsOpaquePtr();
2139 return ast->UnsignedLongLongTy.getAsOpaquePtr();
2141 return ast->Int128Ty.getAsOpaquePtr();
2143 return ast->UnsignedInt128Ty.getAsOpaquePtr();
2145 return ast->BoolTy.getAsOpaquePtr();
2147 return ast->HalfTy.getAsOpaquePtr();
2149 return ast->FloatTy.getAsOpaquePtr();
2151 return ast->DoubleTy.getAsOpaquePtr();
2153 return ast->LongDoubleTy.getAsOpaquePtr();
2155 return ast->Float128Ty.getAsOpaquePtr();
2157 return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
2159 return ast->getComplexType(ast->DoubleTy).getAsOpaquePtr();
2161 return ast->getComplexType(ast->LongDoubleTy).getAsOpaquePtr();
2163 return ast->getObjCIdType().getAsOpaquePtr();
2165 return ast->getObjCClassType().getAsOpaquePtr();
2167 return ast->getObjCSelType().getAsOpaquePtr();
2169 return ast->NullPtrTy.getAsOpaquePtr();
2175#pragma mark Function Types
2177clang::DeclarationName
2180 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2181 if (!
IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2190 const clang::FunctionProtoType *function_type =
2191 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2192 if (function_type ==
nullptr)
2193 return clang::DeclarationName();
2195 const bool is_method =
false;
2196 const unsigned int num_params = function_type->getNumParams();
2198 is_method, op_kind, num_params))
2199 return clang::DeclarationName();
2201 return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
2205 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
2206 printing_policy.SuppressTagKeyword =
true;
2209 printing_policy.SuppressInlineNamespace =
2210 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None);
2211 printing_policy.SuppressUnwrittenScope =
false;
2223 printing_policy.SuppressDefaultTemplateArgs =
false;
2224 return printing_policy;
2231 llvm::raw_string_ostream os(result);
2232 named_decl->getNameForDiagnostic(os, printing_policy, qualified);
2238 llvm::StringRef name,
const CompilerType &function_clang_type,
2239 clang::StorageClass storage,
bool is_inline, llvm::StringRef asm_label) {
2240 FunctionDecl *func_decl =
nullptr;
2243 decl_ctx = ast.getTranslationUnitDecl();
2245 const bool hasWrittenPrototype =
true;
2246 const bool isConstexprSpecified =
false;
2248 clang::DeclarationName declarationName =
2250 func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
2251 func_decl->setDeclContext(decl_ctx);
2252 func_decl->setDeclName(declarationName);
2254 func_decl->setStorageClass(storage);
2255 func_decl->setInlineSpecified(is_inline);
2256 func_decl->setHasWrittenPrototype(hasWrittenPrototype);
2257 func_decl->setConstexprKind(isConstexprSpecified
2258 ? ConstexprSpecKind::Constexpr
2259 : ConstexprSpecKind::Unspecified);
2271 if (!asm_label.empty())
2272 func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label));
2275 decl_ctx->addDecl(func_decl);
2277 VerifyDecl(func_decl);
2283 const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
2284 bool is_variadic,
unsigned type_quals, clang::CallingConv cc,
2285 clang::RefQualifierKind ref_qual) {
2289 std::vector<QualType> qual_type_args;
2291 for (
const auto &arg : args) {
2306 FunctionProtoType::ExtProtoInfo proto_info;
2307 proto_info.ExtInfo = cc;
2308 proto_info.Variadic = is_variadic;
2309 proto_info.ExceptionSpec = EST_None;
2310 proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
2311 proto_info.RefQualifier = ref_qual;
2319 const char *name,
const CompilerType ¶m_type,
int storage,
2322 auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
2323 decl->setDeclContext(decl_ctx);
2324 if (name && name[0])
2325 decl->setDeclName(&ast.Idents.get(name));
2327 decl->setStorageClass(
static_cast<clang::StorageClass
>(storage));
2330 decl_ctx->addDecl(decl);
2337 QualType block_type =
m_ast_up->getBlockPointerType(
2343#pragma mark Array Types
2347 std::optional<size_t> element_count,
2360 clang::ArraySizeModifier::Normal, 0));
2366 llvm::APInt ap_element_count(64, *element_count);
2368 ap_element_count,
nullptr,
2369 clang::ArraySizeModifier::Normal, 0));
2373 llvm::StringRef type_name,
2374 const std::initializer_list<std::pair<const char *, CompilerType>>
2381 lldbassert(0 &&
"Trying to create a type for an existing name");
2386 llvm::to_underlying(clang::TagTypeKind::Struct),
2389 for (
const auto &field : type_fields)
2398 llvm::StringRef type_name,
2399 const std::initializer_list<std::pair<const char *, CompilerType>>
2411#pragma mark Enumeration Types
2414 llvm::StringRef name, clang::DeclContext *decl_ctx,
2416 const CompilerType &integer_clang_type,
bool is_scoped,
2417 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind) {
2424 EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
2425 enum_decl->setDeclContext(decl_ctx);
2427 enum_decl->setDeclName(&ast.Idents.get(name));
2428 enum_decl->setScoped(is_scoped);
2429 enum_decl->setScopedUsingClassTag(is_scoped);
2430 enum_decl->setFixed(
false);
2433 decl_ctx->addDecl(enum_decl);
2437 clang::EnumExtensibilityAttr::CreateImplicit(ast, *enum_kind));
2442 enum_decl->setAccess(AS_public);
2444 return GetType(ast.getCanonicalTagType(enum_decl));
2455 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
2456 return GetType(ast.SignedCharTy);
2458 if (bit_size == ast.getTypeSize(ast.ShortTy))
2461 if (bit_size == ast.getTypeSize(ast.IntTy))
2464 if (bit_size == ast.getTypeSize(ast.LongTy))
2467 if (bit_size == ast.getTypeSize(ast.LongLongTy))
2468 return GetType(ast.LongLongTy);
2470 if (bit_size == ast.getTypeSize(ast.Int128Ty))
2473 if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
2474 return GetType(ast.UnsignedCharTy);
2476 if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
2477 return GetType(ast.UnsignedShortTy);
2479 if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
2480 return GetType(ast.UnsignedIntTy);
2482 if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
2483 return GetType(ast.UnsignedLongTy);
2485 if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
2486 return GetType(ast.UnsignedLongLongTy);
2488 if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
2489 return GetType(ast.UnsignedInt128Ty);
2524 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2526 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2527 named_decl->getDeclName().getAsString().c_str());
2529 printf(
"%20s\n", decl_ctx->getDeclKindName());
2535 if (decl ==
nullptr)
2539 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2541 bool is_injected_class_name =
2542 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2543 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2544 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2545 record_decl->getDeclName().getAsString().c_str(),
2546 is_injected_class_name ?
" (injected class name)" :
"");
2549 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2551 printf(
"%20s: %s\n", decl->getDeclKindName(),
2552 named_decl->getDeclName().getAsString().c_str());
2554 printf(
"%20s\n", decl->getDeclKindName());
2560 clang::Decl *decl) {
2564 ExternalASTSource *ast_source = ast->getExternalSource();
2569 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2570 if (tag_decl->isCompleteDefinition())
2573 if (!tag_decl->hasExternalLexicalStorage())
2576 ast_source->CompleteType(tag_decl);
2578 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2579 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2580 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2581 if (objc_interface_decl->getDefinition())
2584 if (!objc_interface_decl->hasExternalLexicalStorage())
2587 ast_source->CompleteType(objc_interface_decl);
2589 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2619std::optional<ClangASTMetadata>
2625 return std::nullopt;
2628std::optional<ClangASTMetadata>
2634 return std::nullopt;
2656 if (find(mask, type->getTypeClass()) != mask.end())
2658 switch (type->getTypeClass()) {
2661 case clang::Type::Atomic:
2662 type = cast<clang::AtomicType>(type)->getValueType();
2664 case clang::Type::Auto:
2665 case clang::Type::Decltype:
2666 case clang::Type::Paren:
2667 case clang::Type::SubstTemplateTypeParm:
2668 case clang::Type::TemplateSpecialization:
2669 case clang::Type::Typedef:
2670 case clang::Type::TypeOf:
2671 case clang::Type::TypeOfExpr:
2672 case clang::Type::Using:
2673 case clang::Type::PredefinedSugar:
2674 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2688 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2689 switch (type_class) {
2690 case clang::Type::ObjCInterface:
2691 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2693 case clang::Type::ObjCObjectPointer:
2695 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2696 ->getPointeeType());
2697 case clang::Type::Enum:
2698 case clang::Type::Record:
2699 return llvm::cast<clang::TagType>(qual_type)
2701 ->getDefinitionOrSelf();
2713static const clang::RecordType *
2715 assert(qual_type->isRecordType());
2717 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2719 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2723 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2726 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2727 const bool fields_loaded =
2728 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2731 if (is_complete && fields_loaded)
2739 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2740 if (external_ast_source) {
2741 external_ast_source->CompleteType(cxx_record_decl);
2742 if (cxx_record_decl->isCompleteDefinition()) {
2743 cxx_record_decl->field_begin();
2744 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
2756 clang::QualType qual_type) {
2757 assert(qual_type->isEnumeralType());
2760 const clang::EnumType *enum_type =
2761 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2763 auto *tag_decl = enum_type->getAsTagDecl();
2767 if (tag_decl->getDefinition())
2771 if (!tag_decl->hasExternalLexicalStorage())
2775 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2776 if (!external_ast_source)
2779 external_ast_source->CompleteType(tag_decl);
2787static const clang::ObjCObjectType *
2789 assert(qual_type->isObjCObjectType());
2792 const clang::ObjCObjectType *objc_class_type =
2793 llvm::cast<clang::ObjCObjectType>(qual_type);
2795 clang::ObjCInterfaceDecl *class_interface_decl =
2796 objc_class_type->getInterface();
2799 if (!class_interface_decl)
2800 return objc_class_type;
2803 if (class_interface_decl->getDefinition())
2804 return objc_class_type;
2807 if (!class_interface_decl->hasExternalLexicalStorage())
2811 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2812 if (!external_ast_source)
2815 external_ast_source->CompleteType(class_interface_decl);
2816 return objc_class_type;
2820 clang::QualType qual_type) {
2822 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2823 switch (type_class) {
2824 case clang::Type::ConstantArray:
2825 case clang::Type::IncompleteArray:
2826 case clang::Type::VariableArray: {
2827 const clang::ArrayType *array_type =
2828 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2833 case clang::Type::Record: {
2835 return !RT->isIncompleteType();
2840 case clang::Type::Enum: {
2842 return !ET->isIncompleteType();
2846 case clang::Type::ObjCObject:
2847 case clang::Type::ObjCInterface: {
2849 return !OT->isIncompleteType();
2854 case clang::Type::Attributed:
2856 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType());
2858 case clang::Type::MemberPointer:
2861 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2862 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2863 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2866 return !qual_type.getTypePtr()->isIncompleteType();
2881 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2888 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2889 switch (type_class) {
2890 case clang::Type::IncompleteArray:
2891 case clang::Type::VariableArray:
2892 case clang::Type::ConstantArray:
2893 case clang::Type::ExtVector:
2894 case clang::Type::Vector:
2895 case clang::Type::Record:
2896 case clang::Type::ObjCObject:
2897 case clang::Type::ObjCInterface:
2909 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2910 switch (type_class) {
2911 case clang::Type::Record: {
2912 if (
const clang::RecordType *record_type =
2913 llvm::dyn_cast_or_null<clang::RecordType>(
2914 qual_type.getTypePtrOrNull())) {
2915 if (
const clang::RecordDecl *record_decl = record_type->getDecl()) {
2916 return record_decl->isAnonymousStructOrUnion();
2930 uint64_t *size,
bool *is_incomplete) {
2933 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2934 switch (type_class) {
2938 case clang::Type::ConstantArray:
2939 if (element_type_ptr)
2941 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2945 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2947 .getLimitedValue(ULLONG_MAX);
2949 *is_incomplete =
false;
2952 case clang::Type::IncompleteArray:
2953 if (element_type_ptr)
2955 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2961 *is_incomplete =
true;
2964 case clang::Type::VariableArray:
2965 if (element_type_ptr)
2967 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2973 *is_incomplete =
false;
2976 case clang::Type::DependentSizedArray:
2977 if (element_type_ptr)
2980 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2986 *is_incomplete =
false;
2989 if (element_type_ptr)
2990 element_type_ptr->
Clear();
2994 *is_incomplete =
false;
3002 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3003 switch (type_class) {
3004 case clang::Type::Vector: {
3005 const clang::VectorType *vector_type =
3006 qual_type->getAs<clang::VectorType>();
3009 *size = vector_type->getNumElements();
3011 *element_type =
GetType(vector_type->getElementType());
3015 case clang::Type::ExtVector: {
3016 const clang::ExtVectorType *ext_vector_type =
3017 qual_type->getAs<clang::ExtVectorType>();
3018 if (ext_vector_type) {
3020 *size = ext_vector_type->getNumElements();
3024 ext_vector_type->getElementType().getAsOpaquePtr());
3040 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
3043 clang::ObjCInterfaceDecl *result_iface_decl =
3044 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
3046 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
3050 return (ast_metadata->GetISAPtr() != 0);
3054 return GetQualType(type).getUnqualifiedType()->isCharType();
3076 if (!pointee_or_element_clang_type.
IsValid())
3079 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
3080 if (pointee_or_element_clang_type.
IsCharType()) {
3081 if (type_flags.
Test(eTypeIsArray)) {
3084 length = llvm::cast<clang::ConstantArrayType>(
3098 if (
auto pointer_auth = qual_type.getPointerAuth())
3099 return pointer_auth.getKey();
3108 if (
auto pointer_auth = qual_type.getPointerAuth())
3109 return pointer_auth.getExtraDiscriminator();
3118 if (
auto pointer_auth = qual_type.getPointerAuth())
3119 return pointer_auth.isAddressDiscriminated();
3125 auto isFunctionType = [&](clang::QualType qual_type) {
3126 return qual_type->isFunctionType();
3140 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3141 switch (type_class) {
3142 case clang::Type::Record:
3144 const clang::CXXRecordDecl *cxx_record_decl =
3145 qual_type->getAsCXXRecordDecl();
3146 if (cxx_record_decl) {
3147 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3150 const clang::RecordType *record_type =
3151 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3153 if (
const clang::RecordDecl *record_decl =
3154 record_type->getDecl()->getDefinition()) {
3157 clang::RecordDecl::field_iterator field_pos,
3158 field_end = record_decl->field_end();
3159 uint32_t num_fields = 0;
3160 bool is_hva =
false;
3161 bool is_hfa =
false;
3162 clang::QualType base_qual_type;
3163 uint64_t base_bitwidth = 0;
3164 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3166 clang::QualType field_qual_type = field_pos->getType();
3167 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3168 if (field_qual_type->isFloatingType()) {
3169 if (field_qual_type->isComplexType())
3172 if (num_fields == 0)
3173 base_qual_type = field_qual_type;
3178 if (field_qual_type.getTypePtr() !=
3179 base_qual_type.getTypePtr())
3183 }
else if (field_qual_type->isVectorType() ||
3184 field_qual_type->isExtVectorType()) {
3185 if (num_fields == 0) {
3186 base_qual_type = field_qual_type;
3187 base_bitwidth = field_bitwidth;
3192 if (base_bitwidth != field_bitwidth)
3194 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3203 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3220 const clang::FunctionProtoType *func =
3221 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3223 return func->getNumParams();
3230 const size_t index) {
3233 const clang::FunctionProtoType *func =
3234 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3236 if (index < func->getNumParams())
3237 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3245 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3249 if (predicate(qual_type))
3252 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3253 switch (type_class) {
3257 case clang::Type::LValueReference:
3258 case clang::Type::RValueReference: {
3259 const clang::ReferenceType *reference_type =
3260 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3262 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3271 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3272 return qual_type->isMemberFunctionPointerType();
3275 return IsTypeImpl(type, isMemberFunctionPointerType);
3280 auto isMemberDataPointerType = [](clang::QualType qual_type) {
3281 return qual_type->isMemberDataPointerType();
3284 return IsTypeImpl(type, isMemberDataPointerType);
3288 auto isFunctionPointerType = [](clang::QualType qual_type) {
3289 return qual_type->isFunctionPointerType();
3292 return IsTypeImpl(type, isFunctionPointerType);
3298 auto isBlockPointerType = [&](clang::QualType qual_type) {
3299 if (qual_type->isBlockPointerType()) {
3300 if (function_pointer_type_ptr) {
3301 const clang::BlockPointerType *block_pointer_type =
3302 qual_type->castAs<clang::BlockPointerType>();
3303 QualType pointee_type = block_pointer_type->getPointeeType();
3304 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3306 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3323 if (qual_type.isNull())
3332 is_signed = qual_type->isSignedIntegerType();
3340 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3344 is_signed = enum_type->isSignedIntegerOrEnumerationType();
3355 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3359 return enum_type->isScopedEnumeralType();
3370 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3371 switch (type_class) {
3372 case clang::Type::Builtin:
3373 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3376 case clang::BuiltinType::ObjCId:
3377 case clang::BuiltinType::ObjCClass:
3381 case clang::Type::ObjCObjectPointer:
3385 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3389 case clang::Type::BlockPointer:
3392 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3396 case clang::Type::Pointer:
3399 llvm::cast<clang::PointerType>(qual_type)
3403 case clang::Type::MemberPointer:
3406 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3415 pointee_type->
Clear();
3423 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3424 switch (type_class) {
3425 case clang::Type::Builtin:
3426 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3429 case clang::BuiltinType::ObjCId:
3430 case clang::BuiltinType::ObjCClass:
3434 case clang::Type::ObjCObjectPointer:
3438 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3442 case clang::Type::BlockPointer:
3445 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3449 case clang::Type::Pointer:
3452 llvm::cast<clang::PointerType>(qual_type)
3456 case clang::Type::MemberPointer:
3459 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3463 case clang::Type::LValueReference:
3466 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3470 case clang::Type::RValueReference:
3473 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3482 pointee_type->
Clear();
3491 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3493 switch (type_class) {
3494 case clang::Type::LValueReference:
3497 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3503 case clang::Type::RValueReference:
3506 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3518 pointee_type->
Clear();
3527 if (qual_type.isNull())
3530 return qual_type->isFloatingType();
3538 const clang::TagType *tag_type =
3539 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3541 if (clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinition())
3542 return tag_decl->isCompleteDefinition();
3545 const clang::ObjCObjectType *objc_class_type =
3546 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3547 if (objc_class_type) {
3548 clang::ObjCInterfaceDecl *class_interface_decl =
3549 objc_class_type->getInterface();
3550 if (class_interface_decl)
3551 return class_interface_decl->getDefinition() !=
nullptr;
3562 const clang::ObjCObjectPointerType *obj_pointer_type =
3563 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3565 if (obj_pointer_type)
3566 return obj_pointer_type->isObjCClassType();
3581 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3582 return (type_class == clang::Type::Record);
3589 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3590 return (type_class == clang::Type::Enum);
3596 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3597 switch (type_class) {
3598 case clang::Type::Record:
3600 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3607 return cxx_record_decl->isDynamicClass();
3621 bool check_cplusplus,
3623 if (dynamic_pointee_type)
3624 dynamic_pointee_type->
Clear();
3628 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3629 if (dynamic_pointee_type)
3631 type.getAsOpaquePtr());
3634 clang::QualType pointee_qual_type;
3636 switch (qual_type->getTypeClass()) {
3637 case clang::Type::Builtin:
3638 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3639 clang::BuiltinType::ObjCId) {
3640 set_dynamic_pointee_type(qual_type);
3645 case clang::Type::ObjCObjectPointer:
3648 if (
const auto *objc_pointee_type =
3649 qual_type->getPointeeType().getTypePtrOrNull()) {
3650 if (
const auto *objc_object_type =
3651 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3652 objc_pointee_type)) {
3653 if (objc_object_type->isObjCClass())
3657 set_dynamic_pointee_type(
3658 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3661 case clang::Type::Pointer:
3663 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3666 case clang::Type::LValueReference:
3667 case clang::Type::RValueReference:
3669 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3679 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3680 case clang::Type::Builtin:
3681 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3682 case clang::BuiltinType::UnknownAny:
3683 case clang::BuiltinType::Void:
3684 set_dynamic_pointee_type(pointee_qual_type);
3690 case clang::Type::Record: {
3691 if (!check_cplusplus)
3693 clang::CXXRecordDecl *cxx_record_decl =
3694 pointee_qual_type->getAsCXXRecordDecl();
3695 if (!cxx_record_decl)
3699 if (cxx_record_decl->isCompleteDefinition())
3700 success = cxx_record_decl->isDynamicClass();
3702 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3703 std::optional<bool> is_dynamic =
3704 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3706 success = *is_dynamic;
3708 success = cxx_record_decl->isDynamicClass();
3714 set_dynamic_pointee_type(pointee_qual_type);
3718 case clang::Type::ObjCObject:
3719 case clang::Type::ObjCInterface:
3721 set_dynamic_pointee_type(pointee_qual_type);
3736 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3743 ->getTypeClass() == clang::Type::Typedef;
3762 return std::nullopt;
3764 if (!clang::isTargetAddressSpace(as))
3765 return std::nullopt;
3766 return clang::toTargetAddressSpace(as);
3770 if (
auto *record_decl =
3772 return record_decl->canPassInRegisters();
3778 return TypeSystemClangSupportsLanguage(language);
3781std::optional<std::string>
3784 return std::nullopt;
3787 if (qual_type.isNull())
3788 return std::nullopt;
3790 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3791 if (!cxx_record_decl)
3792 return std::nullopt;
3794 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3802 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3809 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3811 return tag_type->getDecl()->isEntityBeingDefined();
3822 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3823 if (class_type_ptr) {
3824 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3825 const clang::ObjCObjectPointerType *obj_pointer_type =
3826 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3827 if (obj_pointer_type ==
nullptr)
3828 class_type_ptr->
Clear();
3832 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3839 class_type_ptr->
Clear();
3866 {clang::Type::Typedef, clang::Type::Atomic});
3869 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3870 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3877 if (
auto *named_decl = qual_type->getAsTagDecl())
3889 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3890 printing_policy.SuppressTagKeyword =
true;
3891 printing_policy.SuppressScope =
false;
3892 printing_policy.SuppressUnwrittenScope =
true;
3893 printing_policy.SuppressInlineNamespace =
3894 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::All);
3895 return ConstString(qual_type.getAsString(printing_policy));
3904 if (pointee_or_element_clang_type)
3905 pointee_or_element_clang_type->
Clear();
3907 clang::QualType qual_type =
3910 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3911 switch (type_class) {
3912 case clang::Type::Attributed:
3913 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3916 pointee_or_element_clang_type);
3917 case clang::Type::BitInt: {
3918 uint32_t type_flags = eTypeIsScalar | eTypeIsInteger | eTypeHasValue;
3919 if (qual_type->isSignedIntegerType())
3920 type_flags |= eTypeIsSigned;
3924 case clang::Type::Builtin: {
3925 const clang::BuiltinType *builtin_type =
3926 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3928 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3929 switch (builtin_type->getKind()) {
3930 case clang::BuiltinType::ObjCId:
3931 case clang::BuiltinType::ObjCClass:
3932 if (pointee_or_element_clang_type)
3936 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3939 case clang::BuiltinType::ObjCSel:
3940 if (pointee_or_element_clang_type)
3943 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3946 case clang::BuiltinType::Bool:
3947 case clang::BuiltinType::Char_U:
3948 case clang::BuiltinType::UChar:
3949 case clang::BuiltinType::WChar_U:
3950 case clang::BuiltinType::Char16:
3951 case clang::BuiltinType::Char32:
3952 case clang::BuiltinType::UShort:
3953 case clang::BuiltinType::UInt:
3954 case clang::BuiltinType::ULong:
3955 case clang::BuiltinType::ULongLong:
3956 case clang::BuiltinType::UInt128:
3957 case clang::BuiltinType::Char_S:
3958 case clang::BuiltinType::SChar:
3959 case clang::BuiltinType::WChar_S:
3960 case clang::BuiltinType::Short:
3961 case clang::BuiltinType::Int:
3962 case clang::BuiltinType::Long:
3963 case clang::BuiltinType::LongLong:
3964 case clang::BuiltinType::Int128:
3965 case clang::BuiltinType::Float:
3966 case clang::BuiltinType::Double:
3967 case clang::BuiltinType::LongDouble:
3968 builtin_type_flags |= eTypeIsScalar;
3969 if (builtin_type->isInteger()) {
3970 builtin_type_flags |= eTypeIsInteger;
3971 if (builtin_type->isSignedInteger())
3972 builtin_type_flags |= eTypeIsSigned;
3973 }
else if (builtin_type->isFloatingPoint())
3974 builtin_type_flags |= eTypeIsFloat;
3979 return builtin_type_flags;
3982 case clang::Type::BlockPointer:
3983 if (pointee_or_element_clang_type)
3985 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3986 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3988 case clang::Type::Complex: {
3989 uint32_t complex_type_flags =
3990 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3991 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3992 qual_type->getCanonicalTypeInternal());
3994 clang::QualType complex_element_type(complex_type->getElementType());
3995 if (complex_element_type->isIntegerType())
3996 complex_type_flags |= eTypeIsInteger;
3997 else if (complex_element_type->isFloatingType())
3998 complex_type_flags |= eTypeIsFloat;
4000 return complex_type_flags;
4003 case clang::Type::ConstantArray:
4004 case clang::Type::DependentSizedArray:
4005 case clang::Type::IncompleteArray:
4006 case clang::Type::VariableArray:
4007 if (pointee_or_element_clang_type)
4009 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
4012 return eTypeHasChildren | eTypeIsArray;
4014 case clang::Type::DependentName:
4016 case clang::Type::DependentSizedExtVector:
4017 return eTypeHasChildren | eTypeIsVector;
4019 case clang::Type::Enum:
4020 if (pointee_or_element_clang_type)
4022 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
4024 ->getDefinitionOrSelf()
4027 return eTypeIsEnumeration | eTypeHasValue;
4029 case clang::Type::FunctionProto:
4030 return eTypeIsFuncPrototype | eTypeHasValue;
4031 case clang::Type::FunctionNoProto:
4032 return eTypeIsFuncPrototype | eTypeHasValue;
4033 case clang::Type::InjectedClassName:
4036 case clang::Type::LValueReference:
4037 case clang::Type::RValueReference:
4038 if (pointee_or_element_clang_type)
4041 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
4044 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
4046 case clang::Type::MemberPointer:
4047 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
4049 case clang::Type::ObjCObjectPointer:
4050 if (pointee_or_element_clang_type)
4052 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4053 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
4056 case clang::Type::ObjCObject:
4057 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4058 case clang::Type::ObjCInterface:
4059 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4061 case clang::Type::Pointer:
4062 if (pointee_or_element_clang_type)
4064 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4065 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
4067 case clang::Type::Record:
4068 if (qual_type->getAsCXXRecordDecl())
4069 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
4071 return eTypeHasChildren | eTypeIsStructUnion;
4073 case clang::Type::SubstTemplateTypeParm:
4074 return eTypeIsTemplate;
4075 case clang::Type::TemplateTypeParm:
4076 return eTypeIsTemplate;
4077 case clang::Type::TemplateSpecialization:
4078 return eTypeIsTemplate;
4080 case clang::Type::Typedef:
4081 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
4083 ->getUnderlyingType())
4085 case clang::Type::UnresolvedUsing:
4088 case clang::Type::ExtVector:
4089 case clang::Type::Vector: {
4090 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
4091 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
4092 qual_type->getCanonicalTypeInternal());
4096 QualType element_type = vector_type->getElementType();
4097 if (element_type.isNull())
4100 if (element_type->isIntegerType())
4101 vector_type_flags |= eTypeIsInteger;
4102 else if (element_type->isFloatingType())
4103 vector_type_flags |= eTypeIsFloat;
4104 return vector_type_flags;
4119 if (qual_type->isAnyPointerType()) {
4120 if (qual_type->isObjCObjectPointerType())
4122 if (qual_type->getPointeeCXXRecordDecl()) {
4123 if (std::optional<ClangASTMetadata> meta_data =
4124 GetMetadata(qual_type->getPointeeCXXRecordDecl());
4127 return meta_data->GetLanguageType();
4131 clang::QualType pointee_type(qual_type->getPointeeType());
4132 if (pointee_type->getPointeeCXXRecordDecl()) {
4133 if (std::optional<ClangASTMetadata> meta_data =
4134 GetMetadata(pointee_type->getPointeeCXXRecordDecl());
4137 return meta_data->GetLanguageType();
4140 if (pointee_type->isObjCObjectOrInterfaceType())
4142 if (pointee_type->isObjCClassType())
4144 if (pointee_type.getTypePtr() ==
4148 if (qual_type->isObjCObjectOrInterfaceType())
4150 if (qual_type->getAsCXXRecordDecl()) {
4151 if (std::optional<ClangASTMetadata> meta_data =
4155 return meta_data->GetLanguageType();
4158 switch (qual_type->getTypeClass()) {
4161 case clang::Type::Builtin:
4162 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4164 case clang::BuiltinType::Void:
4165 case clang::BuiltinType::Bool:
4166 case clang::BuiltinType::Char_U:
4167 case clang::BuiltinType::UChar:
4168 case clang::BuiltinType::WChar_U:
4169 case clang::BuiltinType::Char16:
4170 case clang::BuiltinType::Char32:
4171 case clang::BuiltinType::UShort:
4172 case clang::BuiltinType::UInt:
4173 case clang::BuiltinType::ULong:
4174 case clang::BuiltinType::ULongLong:
4175 case clang::BuiltinType::UInt128:
4176 case clang::BuiltinType::Char_S:
4177 case clang::BuiltinType::SChar:
4178 case clang::BuiltinType::WChar_S:
4179 case clang::BuiltinType::Short:
4180 case clang::BuiltinType::Int:
4181 case clang::BuiltinType::Long:
4182 case clang::BuiltinType::LongLong:
4183 case clang::BuiltinType::Int128:
4184 case clang::BuiltinType::Float:
4185 case clang::BuiltinType::Double:
4186 case clang::BuiltinType::LongDouble:
4189 case clang::BuiltinType::NullPtr:
4192 case clang::BuiltinType::ObjCId:
4193 case clang::BuiltinType::ObjCClass:
4194 case clang::BuiltinType::ObjCSel:
4197 case clang::BuiltinType::Dependent:
4198 case clang::BuiltinType::Overload:
4199 case clang::BuiltinType::BoundMember:
4200 case clang::BuiltinType::UnknownAny:
4204 case clang::Type::Typedef:
4205 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4207 ->getUnderlyingType())
4217 return lldb::eTypeClassInvalid;
4219 clang::QualType qual_type =
4222 switch (qual_type->getTypeClass()) {
4223 case clang::Type::Atomic:
4224 case clang::Type::Auto:
4225 case clang::Type::CountAttributed:
4226 case clang::Type::Decltype:
4227 case clang::Type::Paren:
4228 case clang::Type::TypeOf:
4229 case clang::Type::TypeOfExpr:
4230 case clang::Type::Using:
4231 case clang::Type::PredefinedSugar:
4232 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4233 case clang::Type::LateParsedAttr:
4234 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
4235 "that is resolved before the AST is finalized.");
4236 case clang::Type::UnaryTransform:
4238 case clang::Type::FunctionNoProto:
4239 return lldb::eTypeClassFunction;
4240 case clang::Type::FunctionProto:
4241 return lldb::eTypeClassFunction;
4242 case clang::Type::IncompleteArray:
4243 return lldb::eTypeClassArray;
4244 case clang::Type::VariableArray:
4245 return lldb::eTypeClassArray;
4246 case clang::Type::ConstantArray:
4247 return lldb::eTypeClassArray;
4248 case clang::Type::DependentSizedArray:
4249 return lldb::eTypeClassArray;
4250 case clang::Type::ArrayParameter:
4251 return lldb::eTypeClassArray;
4252 case clang::Type::DependentSizedExtVector:
4253 return lldb::eTypeClassVector;
4254 case clang::Type::DependentVector:
4255 return lldb::eTypeClassVector;
4256 case clang::Type::ExtVector:
4257 return lldb::eTypeClassVector;
4258 case clang::Type::Vector:
4259 return lldb::eTypeClassVector;
4260 case clang::Type::Builtin:
4262 case clang::Type::BitInt:
4263 case clang::Type::DependentBitInt:
4264 case clang::Type::OverflowBehavior:
4265 return lldb::eTypeClassBuiltin;
4266 case clang::Type::ObjCObjectPointer:
4267 return lldb::eTypeClassObjCObjectPointer;
4268 case clang::Type::BlockPointer:
4269 return lldb::eTypeClassBlockPointer;
4270 case clang::Type::Pointer:
4271 return lldb::eTypeClassPointer;
4272 case clang::Type::LValueReference:
4273 return lldb::eTypeClassReference;
4274 case clang::Type::RValueReference:
4275 return lldb::eTypeClassReference;
4276 case clang::Type::MemberPointer:
4277 return lldb::eTypeClassMemberPointer;
4278 case clang::Type::Complex:
4279 if (qual_type->isComplexType())
4280 return lldb::eTypeClassComplexFloat;
4282 return lldb::eTypeClassComplexInteger;
4283 case clang::Type::ObjCObject:
4284 return lldb::eTypeClassObjCObject;
4285 case clang::Type::ObjCInterface:
4286 return lldb::eTypeClassObjCInterface;
4287 case clang::Type::Record: {
4288 const clang::RecordType *record_type =
4289 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4290 const clang::RecordDecl *record_decl = record_type->getDecl();
4291 if (record_decl->isUnion())
4292 return lldb::eTypeClassUnion;
4293 else if (record_decl->isStruct())
4294 return lldb::eTypeClassStruct;
4296 return lldb::eTypeClassClass;
4298 case clang::Type::Enum:
4299 return lldb::eTypeClassEnumeration;
4300 case clang::Type::Typedef:
4301 return lldb::eTypeClassTypedef;
4302 case clang::Type::UnresolvedUsing:
4305 case clang::Type::Attributed:
4306 case clang::Type::BTFTagAttributed:
4308 case clang::Type::TemplateTypeParm:
4310 case clang::Type::SubstTemplateTypeParm:
4312 case clang::Type::SubstTemplateTypeParmPack:
4314 case clang::Type::InjectedClassName:
4316 case clang::Type::DependentName:
4318 case clang::Type::PackExpansion:
4321 case clang::Type::TemplateSpecialization:
4323 case clang::Type::DeducedTemplateSpecialization:
4325 case clang::Type::Pipe:
4329 case clang::Type::Decayed:
4331 case clang::Type::Adjusted:
4333 case clang::Type::ObjCTypeParam:
4336 case clang::Type::DependentAddressSpace:
4338 case clang::Type::MacroQualified:
4342 case clang::Type::ConstantMatrix:
4343 case clang::Type::CooperativeMatrix:
4344 case clang::Type::DependentSizedMatrix:
4348 case clang::Type::PackIndexing:
4351 case clang::Type::HLSLAttributedResource:
4353 case clang::Type::HLSLInlineSpirv:
4355 case clang::Type::SubstBuiltinTemplatePack:
4359 return lldb::eTypeClassOther;
4364 return GetQualType(type).getQualifiers().getCVRQualifiers();
4376 const clang::Type *array_eletype =
4377 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4382 return GetType(clang::QualType(array_eletype, 0));
4393 return GetType(ast_ctx.getConstantArrayType(
4394 qual_type, llvm::APInt(64, size),
nullptr,
4395 clang::ArraySizeModifier::Normal, 0));
4397 return GetType(ast_ctx.getIncompleteArrayType(
4398 qual_type, clang::ArraySizeModifier::Normal, 0));
4412 clang::QualType qual_type) {
4413 if (qual_type->isPointerType())
4414 qual_type = ast->getPointerType(
4416 else if (
const ConstantArrayType *arr =
4417 ast->getAsConstantArrayType(qual_type)) {
4418 qual_type = ast->getConstantArrayType(
4420 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4421 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4423 qual_type = qual_type.getUnqualifiedType();
4424 qual_type.removeLocalConst();
4425 qual_type.removeLocalRestrict();
4426 qual_type.removeLocalVolatile();
4448 const clang::FunctionProtoType *func =
4451 return func->getNumParams();
4459 const clang::FunctionProtoType *func =
4460 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4462 const uint32_t num_args = func->getNumParams();
4464 return GetType(func->getParamType(idx));
4474 const clang::FunctionProtoType *func =
4475 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4477 return GetType(func->getReturnType());
4484 size_t num_functions = 0;
4487 switch (qual_type->getTypeClass()) {
4488 case clang::Type::Record:
4490 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4491 num_functions = std::distance(cxx_record_decl->method_begin(),
4492 cxx_record_decl->method_end());
4495 case clang::Type::ObjCObjectPointer: {
4496 const clang::ObjCObjectPointerType *objc_class_type =
4497 qual_type->castAs<clang::ObjCObjectPointerType>();
4498 const clang::ObjCInterfaceType *objc_interface_type =
4499 objc_class_type->getInterfaceType();
4500 if (objc_interface_type &&
4502 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4503 clang::ObjCInterfaceDecl *class_interface_decl =
4504 objc_interface_type->getDecl();
4505 if (class_interface_decl) {
4506 num_functions = std::distance(class_interface_decl->meth_begin(),
4507 class_interface_decl->meth_end());
4513 case clang::Type::ObjCObject:
4514 case clang::Type::ObjCInterface:
4516 const clang::ObjCObjectType *objc_class_type =
4517 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4518 if (objc_class_type) {
4519 clang::ObjCInterfaceDecl *class_interface_decl =
4520 objc_class_type->getInterface();
4521 if (class_interface_decl)
4522 num_functions = std::distance(class_interface_decl->meth_begin(),
4523 class_interface_decl->meth_end());
4532 return num_functions;
4544 switch (qual_type->getTypeClass()) {
4545 case clang::Type::Record:
4547 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4548 auto method_iter = cxx_record_decl->method_begin();
4549 auto method_end = cxx_record_decl->method_end();
4551 static_cast<size_t>(std::distance(method_iter, method_end))) {
4552 std::advance(method_iter, idx);
4553 clang::CXXMethodDecl *cxx_method_decl =
4554 method_iter->getCanonicalDecl();
4555 if (cxx_method_decl) {
4556 name = cxx_method_decl->getDeclName().getAsString();
4557 if (cxx_method_decl->isStatic())
4559 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4561 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4565 clang_type =
GetType(cxx_method_decl->getType());
4573 case clang::Type::ObjCObjectPointer: {
4574 const clang::ObjCObjectPointerType *objc_class_type =
4575 qual_type->castAs<clang::ObjCObjectPointerType>();
4576 const clang::ObjCInterfaceType *objc_interface_type =
4577 objc_class_type->getInterfaceType();
4578 if (objc_interface_type &&
4580 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4581 clang::ObjCInterfaceDecl *class_interface_decl =
4582 objc_interface_type->getDecl();
4583 if (class_interface_decl) {
4584 auto method_iter = class_interface_decl->meth_begin();
4585 auto method_end = class_interface_decl->meth_end();
4587 static_cast<size_t>(std::distance(method_iter, method_end))) {
4588 std::advance(method_iter, idx);
4589 clang::ObjCMethodDecl *objc_method_decl =
4590 method_iter->getCanonicalDecl();
4591 if (objc_method_decl) {
4593 name = objc_method_decl->getSelector().getAsString();
4594 if (objc_method_decl->isClassMethod())
4605 case clang::Type::ObjCObject:
4606 case clang::Type::ObjCInterface:
4608 const clang::ObjCObjectType *objc_class_type =
4609 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4610 if (objc_class_type) {
4611 clang::ObjCInterfaceDecl *class_interface_decl =
4612 objc_class_type->getInterface();
4613 if (class_interface_decl) {
4614 auto method_iter = class_interface_decl->meth_begin();
4615 auto method_end = class_interface_decl->meth_end();
4617 static_cast<size_t>(std::distance(method_iter, method_end))) {
4618 std::advance(method_iter, idx);
4619 clang::ObjCMethodDecl *objc_method_decl =
4620 method_iter->getCanonicalDecl();
4621 if (objc_method_decl) {
4623 name = objc_method_decl->getSelector().getAsString();
4624 if (objc_method_decl->isClassMethod())
4657 return GetType(qual_type.getTypePtr()->getPointeeType());
4667 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4668 case clang::Type::ObjCObject:
4669 case clang::Type::ObjCInterface:
4716 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4717 clang::QualType result =
4718 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4726 uint32_t address_space) {
4728 assert(address_space <= clang::Qualifiers::MaxAddressSpace);
4730 auto lang_as =
static_cast<clang::LangAS
>(address_space);
4731 if (lang_as == clang::LangAS::Default || qual_type.hasAddressSpace())
4740 result.addVolatile();
4750 result.addRestrict();
4759 if (type && typedef_name && typedef_name[0]) {
4763 clang::DeclContext *decl_ctx =
4768 clang::TypedefDecl *decl =
4769 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4770 decl->setDeclContext(decl_ctx);
4771 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4772 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4773 decl_ctx->addDecl(decl);
4776 clang::TagDecl *tdecl =
nullptr;
4777 if (!qual_type.isNull()) {
4778 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4779 tdecl = rt->getDecl();
4780 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4781 tdecl = et->getDecl();
4787 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4788 tdecl->setTypedefNameForAnonDecl(decl);
4790 decl->setAccess(clang::AS_public);
4793 NestedNameSpecifier Qualifier =
4794 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4796 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4804 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4807 return GetType(typedef_type->getDecl()->getUnderlyingType());
4820 const FunctionType::ExtInfo generic_ext_info(
4829 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4834const llvm::fltSemantics &
4837 const size_t bit_size = byte_size * 8;
4838 if (bit_size == ast.getTypeSize(ast.FloatTy))
4839 return ast.getFloatTypeSemantics(ast.FloatTy);
4840 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4841 return ast.getFloatTypeSemantics(ast.DoubleTy);
4843 bit_size == ast.getTypeSize(ast.Float128Ty))
4844 return ast.getFloatTypeSemantics(ast.Float128Ty);
4845 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4846 bit_size == llvm::APFloat::semanticsSizeInBits(
4847 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4848 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4849 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4850 return ast.getFloatTypeSemantics(ast.HalfTy);
4851 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4852 return ast.getFloatTypeSemantics(ast.Float128Ty);
4853 return llvm::APFloatBase::Bogus();
4856llvm::Expected<uint64_t>
4859 assert(qual_type->isObjCObjectOrInterfaceType());
4864 if (std::optional<uint64_t> bit_size =
4865 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4869 static std::once_flag g_once_flag;
4870 std::call_once(g_once_flag, [&] {
4873 std::string backtrace;
4874 llvm::raw_string_ostream os(backtrace);
4875 llvm::sys::PrintStackTrace(os);
4877 llvm::formatv(
"determining the size of type {0} without a valid "
4878 "ExecutionContext is not reliable\n{1}",
4879 s.
GetString(), llvm::StringRef(backtrace).rtrim())
4888llvm::Expected<uint64_t>
4891 const bool base_name_only =
true;
4893 return llvm::createStringError(
4894 "could not complete type %s",
4898 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4899 switch (type_class) {
4900 case clang::Type::ConstantArray:
4901 case clang::Type::FunctionProto:
4902 case clang::Type::Record:
4904 case clang::Type::ObjCInterface:
4905 case clang::Type::ObjCObject:
4907 case clang::Type::IncompleteArray: {
4908 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4911 qual_type->getArrayElementTypeNoTypeQual()
4912 ->getCanonicalTypeUnqualified());
4917 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4921 return llvm::createStringError(
4922 "could not get size of type %s",
4926std::optional<uint64_t>
4930 return llvm::expectedToOptional(
GetByteSize(type,
nullptr));
4933std::optional<size_t>
4947 switch (qual_type->getTypeClass()) {
4948 case clang::Type::Atomic:
4949 case clang::Type::Auto:
4950 case clang::Type::CountAttributed:
4951 case clang::Type::Decltype:
4952 case clang::Type::Paren:
4953 case clang::Type::Typedef:
4954 case clang::Type::TypeOf:
4955 case clang::Type::TypeOfExpr:
4956 case clang::Type::Using:
4957 case clang::Type::PredefinedSugar:
4958 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4959 case clang::Type::LateParsedAttr:
4960 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
4961 "that is resolved before the AST is finalized.");
4963 case clang::Type::UnaryTransform:
4966 case clang::Type::FunctionNoProto:
4967 case clang::Type::FunctionProto:
4970 case clang::Type::IncompleteArray:
4971 case clang::Type::VariableArray:
4972 case clang::Type::ArrayParameter:
4975 case clang::Type::ConstantArray:
4978 case clang::Type::DependentVector:
4979 case clang::Type::ExtVector:
4980 case clang::Type::Vector:
4983 case clang::Type::BitInt:
4984 case clang::Type::DependentBitInt:
4985 case clang::Type::OverflowBehavior:
4989 case clang::Type::Builtin:
4990 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4991 case clang::BuiltinType::Void:
4994 case clang::BuiltinType::Char_S:
4995 case clang::BuiltinType::SChar:
4996 case clang::BuiltinType::WChar_S:
4997 case clang::BuiltinType::Short:
4998 case clang::BuiltinType::Int:
4999 case clang::BuiltinType::Long:
5000 case clang::BuiltinType::LongLong:
5001 case clang::BuiltinType::Int128:
5004 case clang::BuiltinType::Bool:
5005 case clang::BuiltinType::Char_U:
5006 case clang::BuiltinType::UChar:
5007 case clang::BuiltinType::WChar_U:
5008 case clang::BuiltinType::Char8:
5009 case clang::BuiltinType::Char16:
5010 case clang::BuiltinType::Char32:
5011 case clang::BuiltinType::UShort:
5012 case clang::BuiltinType::UInt:
5013 case clang::BuiltinType::ULong:
5014 case clang::BuiltinType::ULongLong:
5015 case clang::BuiltinType::UInt128:
5019 case clang::BuiltinType::ShortAccum:
5020 case clang::BuiltinType::Accum:
5021 case clang::BuiltinType::LongAccum:
5022 case clang::BuiltinType::UShortAccum:
5023 case clang::BuiltinType::UAccum:
5024 case clang::BuiltinType::ULongAccum:
5025 case clang::BuiltinType::ShortFract:
5026 case clang::BuiltinType::Fract:
5027 case clang::BuiltinType::LongFract:
5028 case clang::BuiltinType::UShortFract:
5029 case clang::BuiltinType::UFract:
5030 case clang::BuiltinType::ULongFract:
5031 case clang::BuiltinType::SatShortAccum:
5032 case clang::BuiltinType::SatAccum:
5033 case clang::BuiltinType::SatLongAccum:
5034 case clang::BuiltinType::SatUShortAccum:
5035 case clang::BuiltinType::SatUAccum:
5036 case clang::BuiltinType::SatULongAccum:
5037 case clang::BuiltinType::SatShortFract:
5038 case clang::BuiltinType::SatFract:
5039 case clang::BuiltinType::SatLongFract:
5040 case clang::BuiltinType::SatUShortFract:
5041 case clang::BuiltinType::SatUFract:
5042 case clang::BuiltinType::SatULongFract:
5045 case clang::BuiltinType::Half:
5046 case clang::BuiltinType::Float:
5047 case clang::BuiltinType::Float16:
5048 case clang::BuiltinType::Float128:
5049 case clang::BuiltinType::Double:
5050 case clang::BuiltinType::LongDouble:
5051 case clang::BuiltinType::BFloat16:
5052 case clang::BuiltinType::Ibm128:
5055 case clang::BuiltinType::ObjCClass:
5056 case clang::BuiltinType::ObjCId:
5057 case clang::BuiltinType::ObjCSel:
5060 case clang::BuiltinType::NullPtr:
5063 case clang::BuiltinType::MetaInfo:
5065#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5066#include "clang/Basic/HLSLPackedTypes.def"
5069 case clang::BuiltinType::Kind::ARCUnbridgedCast:
5070 case clang::BuiltinType::Kind::BoundMember:
5071 case clang::BuiltinType::Kind::BuiltinFn:
5072 case clang::BuiltinType::Kind::Dependent:
5073 case clang::BuiltinType::Kind::OCLClkEvent:
5074 case clang::BuiltinType::Kind::OCLEvent:
5075 case clang::BuiltinType::Kind::OCLImage1dRO:
5076 case clang::BuiltinType::Kind::OCLImage1dWO:
5077 case clang::BuiltinType::Kind::OCLImage1dRW:
5078 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
5079 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
5080 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
5081 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
5082 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
5083 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
5084 case clang::BuiltinType::Kind::OCLImage2dRO:
5085 case clang::BuiltinType::Kind::OCLImage2dWO:
5086 case clang::BuiltinType::Kind::OCLImage2dRW:
5087 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
5088 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
5089 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
5090 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
5091 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
5092 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
5093 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
5094 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
5095 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
5096 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
5097 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
5098 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
5099 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
5100 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
5101 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
5102 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
5103 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
5104 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
5105 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
5106 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
5107 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
5108 case clang::BuiltinType::Kind::OCLImage3dRO:
5109 case clang::BuiltinType::Kind::OCLImage3dWO:
5110 case clang::BuiltinType::Kind::OCLImage3dRW:
5111 case clang::BuiltinType::Kind::OCLQueue:
5112 case clang::BuiltinType::Kind::OCLReserveID:
5113 case clang::BuiltinType::Kind::OCLSampler:
5114 case clang::BuiltinType::Kind::HLSLResource:
5115 case clang::BuiltinType::Kind::ArraySection:
5116 case clang::BuiltinType::Kind::OMPArrayShaping:
5117 case clang::BuiltinType::Kind::OMPIterator:
5118 case clang::BuiltinType::Kind::Overload:
5119 case clang::BuiltinType::Kind::PseudoObject:
5120 case clang::BuiltinType::Kind::UnknownAny:
5123 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
5124 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
5125 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
5126 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
5127 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
5128 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
5129 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
5130 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
5131 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
5132 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
5133 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
5134 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
5138 case clang::BuiltinType::VectorPair:
5139 case clang::BuiltinType::VectorQuad:
5140 case clang::BuiltinType::DMR1024:
5141 case clang::BuiltinType::DMR2048:
5145#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5146#include "clang/Basic/AArch64ACLETypes.def"
5150#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5151#include "clang/Basic/RISCVVTypes.def"
5155 case clang::BuiltinType::WasmExternRef:
5158 case clang::BuiltinType::IncompleteMatrixIdx:
5161 case clang::BuiltinType::UnresolvedTemplate:
5165#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
5166 case clang::BuiltinType::Id:
5167#include "clang/Basic/AMDGPUTypes.def"
5171#define SPIRV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5172#include "clang/Basic/SPIRVTypes.def"
5178 case clang::Type::ObjCObjectPointer:
5179 case clang::Type::BlockPointer:
5180 case clang::Type::Pointer:
5181 case clang::Type::LValueReference:
5182 case clang::Type::RValueReference:
5183 case clang::Type::MemberPointer:
5185 case clang::Type::Complex: {
5187 if (qual_type->isComplexType())
5190 const clang::ComplexType *complex_type =
5191 qual_type->getAsComplexIntegerType();
5200 case clang::Type::ObjCInterface:
5202 case clang::Type::Record:
5204 case clang::Type::Enum:
5205 return qual_type->isUnsignedIntegerOrEnumerationType()
5208 case clang::Type::DependentSizedArray:
5209 case clang::Type::DependentSizedExtVector:
5210 case clang::Type::UnresolvedUsing:
5211 case clang::Type::Attributed:
5212 case clang::Type::BTFTagAttributed:
5213 case clang::Type::TemplateTypeParm:
5214 case clang::Type::SubstTemplateTypeParm:
5215 case clang::Type::SubstTemplateTypeParmPack:
5216 case clang::Type::InjectedClassName:
5217 case clang::Type::DependentName:
5218 case clang::Type::PackExpansion:
5219 case clang::Type::ObjCObject:
5221 case clang::Type::TemplateSpecialization:
5222 case clang::Type::DeducedTemplateSpecialization:
5223 case clang::Type::Adjusted:
5224 case clang::Type::Pipe:
5228 case clang::Type::Decayed:
5230 case clang::Type::ObjCTypeParam:
5233 case clang::Type::DependentAddressSpace:
5235 case clang::Type::MacroQualified:
5238 case clang::Type::ConstantMatrix:
5239 case clang::Type::CooperativeMatrix:
5240 case clang::Type::DependentSizedMatrix:
5244 case clang::Type::PackIndexing:
5247 case clang::Type::HLSLAttributedResource:
5249 case clang::Type::HLSLInlineSpirv:
5251 case clang::Type::SubstBuiltinTemplatePack:
5264 switch (qual_type->getTypeClass()) {
5265 case clang::Type::Atomic:
5266 case clang::Type::Auto:
5267 case clang::Type::CountAttributed:
5268 case clang::Type::Decltype:
5269 case clang::Type::Paren:
5270 case clang::Type::Typedef:
5271 case clang::Type::TypeOf:
5272 case clang::Type::TypeOfExpr:
5273 case clang::Type::Using:
5274 case clang::Type::PredefinedSugar:
5275 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5276 case clang::Type::LateParsedAttr:
5277 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
5278 "that is resolved before the AST is finalized.");
5279 case clang::Type::UnaryTransform:
5282 case clang::Type::FunctionNoProto:
5283 case clang::Type::FunctionProto:
5286 case clang::Type::IncompleteArray:
5287 case clang::Type::VariableArray:
5288 case clang::Type::ArrayParameter:
5291 case clang::Type::ConstantArray:
5294 case clang::Type::DependentVector:
5295 case clang::Type::ExtVector:
5296 case clang::Type::Vector:
5299 case clang::Type::BitInt:
5300 case clang::Type::DependentBitInt:
5301 case clang::Type::OverflowBehavior:
5305 case clang::Type::Builtin:
5306 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5307 case clang::BuiltinType::UnknownAny:
5308 case clang::BuiltinType::Void:
5309 case clang::BuiltinType::BoundMember:
5312 case clang::BuiltinType::Bool:
5314 case clang::BuiltinType::Char_S:
5315 case clang::BuiltinType::SChar:
5316 case clang::BuiltinType::WChar_S:
5317 case clang::BuiltinType::Char_U:
5318 case clang::BuiltinType::UChar:
5319 case clang::BuiltinType::WChar_U:
5321 case clang::BuiltinType::Char8:
5323 case clang::BuiltinType::Char16:
5325 case clang::BuiltinType::Char32:
5327 case clang::BuiltinType::UShort:
5329 case clang::BuiltinType::Short:
5331 case clang::BuiltinType::UInt:
5333 case clang::BuiltinType::Int:
5335 case clang::BuiltinType::ULong:
5337 case clang::BuiltinType::Long:
5339 case clang::BuiltinType::ULongLong:
5341 case clang::BuiltinType::LongLong:
5343 case clang::BuiltinType::UInt128:
5345 case clang::BuiltinType::Int128:
5347 case clang::BuiltinType::Half:
5348 case clang::BuiltinType::Float:
5349 case clang::BuiltinType::Double:
5350 case clang::BuiltinType::LongDouble:
5352 case clang::BuiltinType::Float128:
5358 case clang::Type::ObjCObjectPointer:
5360 case clang::Type::BlockPointer:
5362 case clang::Type::Pointer:
5364 case clang::Type::LValueReference:
5365 case clang::Type::RValueReference:
5367 case clang::Type::MemberPointer:
5369 case clang::Type::Complex: {
5370 if (qual_type->isComplexType())
5375 case clang::Type::ObjCInterface:
5377 case clang::Type::Record:
5379 case clang::Type::Enum:
5381 case clang::Type::DependentSizedArray:
5382 case clang::Type::DependentSizedExtVector:
5383 case clang::Type::UnresolvedUsing:
5384 case clang::Type::Attributed:
5385 case clang::Type::BTFTagAttributed:
5386 case clang::Type::TemplateTypeParm:
5387 case clang::Type::SubstTemplateTypeParm:
5388 case clang::Type::SubstTemplateTypeParmPack:
5389 case clang::Type::InjectedClassName:
5390 case clang::Type::DependentName:
5391 case clang::Type::PackExpansion:
5392 case clang::Type::ObjCObject:
5394 case clang::Type::TemplateSpecialization:
5395 case clang::Type::DeducedTemplateSpecialization:
5396 case clang::Type::Adjusted:
5397 case clang::Type::Pipe:
5401 case clang::Type::Decayed:
5403 case clang::Type::ObjCTypeParam:
5406 case clang::Type::DependentAddressSpace:
5408 case clang::Type::MacroQualified:
5412 case clang::Type::ConstantMatrix:
5413 case clang::Type::CooperativeMatrix:
5414 case clang::Type::DependentSizedMatrix:
5418 case clang::Type::PackIndexing:
5421 case clang::Type::HLSLAttributedResource:
5423 case clang::Type::HLSLInlineSpirv:
5425 case clang::Type::SubstBuiltinTemplatePack:
5433 while (class_interface_decl) {
5434 if (class_interface_decl->ivar_size() > 0)
5437 class_interface_decl = class_interface_decl->getSuperClass();
5442static std::optional<SymbolFile::ArrayInfo>
5444 clang::QualType qual_type,
5446 if (qual_type->isIncompleteArrayType())
5447 if (std::optional<ClangASTMetadata> metadata =
5451 return std::nullopt;
5454llvm::Expected<uint32_t>
5456 bool omit_empty_base_classes,
5459 return llvm::createStringError(
"invalid clang type");
5461 uint32_t num_children = 0;
5463 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5464 switch (type_class) {
5465 case clang::Type::Builtin:
5466 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5467 case clang::BuiltinType::ObjCId:
5468 case clang::BuiltinType::ObjCClass:
5477 case clang::Type::Complex:
5479 case clang::Type::Record:
5481 const clang::RecordType *record_type =
5482 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5483 const clang::RecordDecl *record_decl =
5484 record_type->getDecl()->getDefinitionOrSelf();
5485 const clang::CXXRecordDecl *cxx_record_decl =
5486 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5490 num_children += std::distance(record_decl->field_begin(),
5491 record_decl->field_end());
5493 return llvm::createStringError(
5496 case clang::Type::ObjCObject:
5497 case clang::Type::ObjCInterface:
5499 const clang::ObjCObjectType *objc_class_type =
5500 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5501 assert(objc_class_type);
5502 if (objc_class_type) {
5503 clang::ObjCInterfaceDecl *class_interface_decl =
5504 objc_class_type->getInterface();
5506 if (class_interface_decl) {
5508 clang::ObjCInterfaceDecl *superclass_interface_decl =
5509 class_interface_decl->getSuperClass();
5510 if (superclass_interface_decl) {
5511 if (omit_empty_base_classes) {
5518 num_children += class_interface_decl->ivar_size();
5524 case clang::Type::LValueReference:
5525 case clang::Type::RValueReference:
5526 case clang::Type::ObjCObjectPointer: {
5529 uint32_t num_pointee_children = 0;
5531 auto num_children_or_err =
5532 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5533 if (!num_children_or_err)
5534 return num_children_or_err;
5535 num_pointee_children = *num_children_or_err;
5538 if (num_pointee_children == 0)
5541 num_children = num_pointee_children;
5544 case clang::Type::Vector:
5545 case clang::Type::ExtVector:
5547 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5550 case clang::Type::ConstantArray:
5551 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5555 case clang::Type::IncompleteArray:
5556 if (
auto array_info =
5559 num_children = array_info->element_orders.size()
5560 ? array_info->element_orders.back().value_or(0)
5564 case clang::Type::Pointer: {
5565 const clang::PointerType *pointer_type =
5566 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5567 clang::QualType pointee_type(pointer_type->getPointeeType());
5569 uint32_t num_pointee_children = 0;
5571 auto num_children_or_err =
5572 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5573 if (!num_children_or_err)
5574 return num_children_or_err;
5575 num_pointee_children = *num_children_or_err;
5577 if (num_pointee_children == 0) {
5582 num_children = num_pointee_children;
5588 return num_children;
5595 if (name_ref.consume_front(
"unsigned _BitInt(") ||
5596 name_ref.consume_front(
"_BitInt(")) {
5598 if (name_ref.consumeInteger(10, bit_size))
5601 if (!name_ref.consume_front(
")"))
5605 name.
GetStringRef().starts_with(
"unsigned"), bit_size));
5614 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5615 if (type_class == clang::Type::Builtin) {
5616 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5617 case clang::BuiltinType::Void:
5619 case clang::BuiltinType::Bool:
5621 case clang::BuiltinType::Char_S:
5623 case clang::BuiltinType::Char_U:
5625 case clang::BuiltinType::Char8:
5627 case clang::BuiltinType::Char16:
5629 case clang::BuiltinType::Char32:
5631 case clang::BuiltinType::UChar:
5633 case clang::BuiltinType::SChar:
5635 case clang::BuiltinType::WChar_S:
5637 case clang::BuiltinType::WChar_U:
5639 case clang::BuiltinType::Short:
5641 case clang::BuiltinType::UShort:
5643 case clang::BuiltinType::Int:
5645 case clang::BuiltinType::UInt:
5647 case clang::BuiltinType::Long:
5649 case clang::BuiltinType::ULong:
5651 case clang::BuiltinType::LongLong:
5653 case clang::BuiltinType::ULongLong:
5655 case clang::BuiltinType::Int128:
5657 case clang::BuiltinType::UInt128:
5660 case clang::BuiltinType::Half:
5662 case clang::BuiltinType::Float:
5664 case clang::BuiltinType::Double:
5666 case clang::BuiltinType::LongDouble:
5668 case clang::BuiltinType::Float128:
5671 case clang::BuiltinType::NullPtr:
5673 case clang::BuiltinType::ObjCId:
5675 case clang::BuiltinType::ObjCClass:
5677 case clang::BuiltinType::ObjCSel:
5691 const llvm::APSInt &value)>
const &callback) {
5692 const clang::EnumType *enum_type =
5695 const clang::EnumDecl *enum_decl =
5696 enum_type->getDecl()->getDefinitionOrSelf();
5700 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5701 for (enum_pos = enum_decl->enumerator_begin(),
5702 enum_end_pos = enum_decl->enumerator_end();
5703 enum_pos != enum_end_pos; ++enum_pos) {
5705 if (!callback(integer_type, name, enum_pos->getInitVal()))
5712#pragma mark Aggregate Types
5720 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5721 switch (type_class) {
5722 case clang::Type::Record:
5724 const clang::RecordType *record_type =
5725 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5727 clang::RecordDecl *record_decl =
5728 record_type->getDecl()->getDefinition();
5730 count = std::distance(record_decl->field_begin(),
5731 record_decl->field_end());
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) {
5748 count = class_interface_decl->ivar_size();
5754 case clang::Type::ObjCObject:
5755 case clang::Type::ObjCInterface:
5757 const clang::ObjCObjectType *objc_class_type =
5758 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5759 if (objc_class_type) {
5760 clang::ObjCInterfaceDecl *class_interface_decl =
5761 objc_class_type->getInterface();
5763 if (class_interface_decl)
5764 count = class_interface_decl->ivar_size();
5777 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5778 std::string &name, uint64_t *bit_offset_ptr,
5779 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5780 if (class_interface_decl) {
5781 if (idx < (class_interface_decl->ivar_size())) {
5782 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5783 ivar_end = class_interface_decl->ivar_end();
5784 uint32_t ivar_idx = 0;
5786 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5787 ++ivar_pos, ++ivar_idx) {
5788 if (ivar_idx == idx) {
5789 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5791 clang::QualType ivar_qual_type(ivar_decl->getType());
5793 name.assign(ivar_decl->getNameAsString());
5795 if (bit_offset_ptr) {
5796 const clang::ASTRecordLayout &interface_layout =
5797 ast->getASTObjCInterfaceLayout(class_interface_decl);
5798 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5801 const bool is_bitfield = ivar_pos->isBitField();
5803 if (bitfield_bit_size_ptr) {
5804 *bitfield_bit_size_ptr = 0;
5806 if (is_bitfield && ast) {
5807 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5808 clang::Expr::EvalResult result;
5809 if (bitfield_bit_size_expr &&
5810 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5811 llvm::APSInt bitfield_apsint = result.Val.getInt();
5812 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5816 if (is_bitfield_ptr)
5817 *is_bitfield_ptr = is_bitfield;
5819 return ivar_qual_type.getAsOpaquePtr();
5828 size_t idx, std::string &name,
5829 uint64_t *bit_offset_ptr,
5830 uint32_t *bitfield_bit_size_ptr,
5831 bool *is_bitfield_ptr) {
5836 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5837 switch (type_class) {
5838 case clang::Type::Record:
5840 const clang::RecordType *record_type =
5841 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5842 const clang::RecordDecl *record_decl =
5843 record_type->getDecl()->getDefinitionOrSelf();
5844 uint32_t field_idx = 0;
5845 clang::RecordDecl::field_iterator field, field_end;
5846 for (field = record_decl->field_begin(),
5847 field_end = record_decl->field_end();
5848 field != field_end; ++field, ++field_idx) {
5849 if (idx == field_idx) {
5852 name.assign(field->getNameAsString());
5856 if (bit_offset_ptr) {
5857 const clang::ASTRecordLayout &record_layout =
5859 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5862 const bool is_bitfield = field->isBitField();
5864 if (bitfield_bit_size_ptr) {
5865 *bitfield_bit_size_ptr = 0;
5868 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5869 clang::Expr::EvalResult result;
5870 if (bitfield_bit_size_expr &&
5871 bitfield_bit_size_expr->EvaluateAsInt(result,
5873 llvm::APSInt bitfield_apsint = result.Val.getInt();
5874 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5878 if (is_bitfield_ptr)
5879 *is_bitfield_ptr = is_bitfield;
5881 return GetType(field->getType());
5887 case clang::Type::ObjCObjectPointer: {
5888 const clang::ObjCObjectPointerType *objc_class_type =
5889 qual_type->castAs<clang::ObjCObjectPointerType>();
5890 const clang::ObjCInterfaceType *objc_interface_type =
5891 objc_class_type->getInterfaceType();
5892 if (objc_interface_type &&
5894 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5895 clang::ObjCInterfaceDecl *class_interface_decl =
5896 objc_interface_type->getDecl();
5897 if (class_interface_decl) {
5901 name, bit_offset_ptr, bitfield_bit_size_ptr,
5908 case clang::Type::ObjCObject:
5909 case clang::Type::ObjCInterface:
5911 const clang::ObjCObjectType *objc_class_type =
5912 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5913 assert(objc_class_type);
5914 if (objc_class_type) {
5915 clang::ObjCInterfaceDecl *class_interface_decl =
5916 objc_class_type->getInterface();
5920 name, bit_offset_ptr, bitfield_bit_size_ptr,
5936 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5937 switch (type_class) {
5938 case clang::Type::Record:
5940 const clang::CXXRecordDecl *cxx_record_decl =
5941 qual_type->getAsCXXRecordDecl();
5942 if (cxx_record_decl)
5943 count = cxx_record_decl->getNumBases();
5947 case clang::Type::ObjCObjectPointer:
5951 case clang::Type::ObjCObject:
5953 const clang::ObjCObjectType *objc_class_type =
5954 qual_type->getAsObjCQualifiedInterfaceType();
5955 if (objc_class_type) {
5956 clang::ObjCInterfaceDecl *class_interface_decl =
5957 objc_class_type->getInterface();
5959 if (class_interface_decl && class_interface_decl->getSuperClass())
5964 case clang::Type::ObjCInterface:
5966 const clang::ObjCInterfaceType *objc_interface_type =
5967 qual_type->getAs<clang::ObjCInterfaceType>();
5968 if (objc_interface_type) {
5969 clang::ObjCInterfaceDecl *class_interface_decl =
5970 objc_interface_type->getInterface();
5972 if (class_interface_decl && class_interface_decl->getSuperClass())
5988 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5989 switch (type_class) {
5990 case clang::Type::Record:
5992 const clang::CXXRecordDecl *cxx_record_decl =
5993 qual_type->getAsCXXRecordDecl();
5994 if (cxx_record_decl)
5995 count = cxx_record_decl->getNumVBases();
6008 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6009 switch (type_class) {
6010 case clang::Type::Record:
6012 const clang::CXXRecordDecl *cxx_record_decl =
6013 qual_type->getAsCXXRecordDecl();
6014 if (cxx_record_decl) {
6015 uint32_t curr_idx = 0;
6016 clang::CXXRecordDecl::base_class_const_iterator base_class,
6018 for (base_class = cxx_record_decl->bases_begin(),
6019 base_class_end = cxx_record_decl->bases_end();
6020 base_class != base_class_end; ++base_class, ++curr_idx) {
6021 if (curr_idx == idx) {
6022 if (bit_offset_ptr) {
6023 const clang::ASTRecordLayout &record_layout =
6025 const clang::CXXRecordDecl *base_class_decl =
6026 llvm::cast<clang::CXXRecordDecl>(
6027 base_class->getType()
6028 ->castAs<clang::RecordType>()
6030 if (base_class->isVirtual())
6032 record_layout.getVBaseClassOffset(base_class_decl)
6037 record_layout.getBaseClassOffset(base_class_decl)
6041 return GetType(base_class->getType());
6048 case clang::Type::ObjCObjectPointer:
6051 case clang::Type::ObjCObject:
6053 const clang::ObjCObjectType *objc_class_type =
6054 qual_type->getAsObjCQualifiedInterfaceType();
6055 if (objc_class_type) {
6056 clang::ObjCInterfaceDecl *class_interface_decl =
6057 objc_class_type->getInterface();
6059 if (class_interface_decl) {
6060 clang::ObjCInterfaceDecl *superclass_interface_decl =
6061 class_interface_decl->getSuperClass();
6062 if (superclass_interface_decl) {
6064 *bit_offset_ptr = 0;
6066 superclass_interface_decl));
6072 case clang::Type::ObjCInterface:
6074 const clang::ObjCObjectType *objc_interface_type =
6075 qual_type->getAs<clang::ObjCInterfaceType>();
6076 if (objc_interface_type) {
6077 clang::ObjCInterfaceDecl *class_interface_decl =
6078 objc_interface_type->getInterface();
6080 if (class_interface_decl) {
6081 clang::ObjCInterfaceDecl *superclass_interface_decl =
6082 class_interface_decl->getSuperClass();
6083 if (superclass_interface_decl) {
6085 *bit_offset_ptr = 0;
6087 superclass_interface_decl));
6103 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6104 switch (type_class) {
6105 case clang::Type::Record:
6107 const clang::CXXRecordDecl *cxx_record_decl =
6108 qual_type->getAsCXXRecordDecl();
6109 if (cxx_record_decl) {
6110 uint32_t curr_idx = 0;
6111 clang::CXXRecordDecl::base_class_const_iterator base_class,
6113 for (base_class = cxx_record_decl->vbases_begin(),
6114 base_class_end = cxx_record_decl->vbases_end();
6115 base_class != base_class_end; ++base_class, ++curr_idx) {
6116 if (curr_idx == idx) {
6117 if (bit_offset_ptr) {
6118 const clang::ASTRecordLayout &record_layout =
6120 const clang::CXXRecordDecl *base_class_decl =
6121 llvm::cast<clang::CXXRecordDecl>(
6122 base_class->getType()
6123 ->castAs<clang::RecordType>()
6126 record_layout.getVBaseClassOffset(base_class_decl)
6130 return GetType(base_class->getType());
6145 llvm::StringRef name) {
6147 switch (qual_type->getTypeClass()) {
6148 case clang::Type::Record: {
6152 const clang::RecordType *record_type =
6153 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6154 const clang::RecordDecl *record_decl =
6155 record_type->getDecl()->getDefinitionOrSelf();
6157 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
6158 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
6159 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
6160 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
6184 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6185 switch (type_class) {
6186 case clang::Type::Builtin:
6187 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6188 case clang::BuiltinType::UnknownAny:
6189 case clang::BuiltinType::Void:
6190 case clang::BuiltinType::NullPtr:
6191 case clang::BuiltinType::OCLEvent:
6192 case clang::BuiltinType::OCLImage1dRO:
6193 case clang::BuiltinType::OCLImage1dWO:
6194 case clang::BuiltinType::OCLImage1dRW:
6195 case clang::BuiltinType::OCLImage1dArrayRO:
6196 case clang::BuiltinType::OCLImage1dArrayWO:
6197 case clang::BuiltinType::OCLImage1dArrayRW:
6198 case clang::BuiltinType::OCLImage1dBufferRO:
6199 case clang::BuiltinType::OCLImage1dBufferWO:
6200 case clang::BuiltinType::OCLImage1dBufferRW:
6201 case clang::BuiltinType::OCLImage2dRO:
6202 case clang::BuiltinType::OCLImage2dWO:
6203 case clang::BuiltinType::OCLImage2dRW:
6204 case clang::BuiltinType::OCLImage2dArrayRO:
6205 case clang::BuiltinType::OCLImage2dArrayWO:
6206 case clang::BuiltinType::OCLImage2dArrayRW:
6207 case clang::BuiltinType::OCLImage3dRO:
6208 case clang::BuiltinType::OCLImage3dWO:
6209 case clang::BuiltinType::OCLImage3dRW:
6210 case clang::BuiltinType::OCLSampler:
6211 case clang::BuiltinType::HLSLResource:
6213 case clang::BuiltinType::Bool:
6214 case clang::BuiltinType::Char_U:
6215 case clang::BuiltinType::UChar:
6216 case clang::BuiltinType::WChar_U:
6217 case clang::BuiltinType::Char16:
6218 case clang::BuiltinType::Char32:
6219 case clang::BuiltinType::UShort:
6220 case clang::BuiltinType::UInt:
6221 case clang::BuiltinType::ULong:
6222 case clang::BuiltinType::ULongLong:
6223 case clang::BuiltinType::UInt128:
6224 case clang::BuiltinType::Char_S:
6225 case clang::BuiltinType::SChar:
6226 case clang::BuiltinType::WChar_S:
6227 case clang::BuiltinType::Short:
6228 case clang::BuiltinType::Int:
6229 case clang::BuiltinType::Long:
6230 case clang::BuiltinType::LongLong:
6231 case clang::BuiltinType::Int128:
6232 case clang::BuiltinType::Float:
6233 case clang::BuiltinType::Double:
6234 case clang::BuiltinType::LongDouble:
6235 case clang::BuiltinType::Float128:
6236 case clang::BuiltinType::Dependent:
6237 case clang::BuiltinType::Overload:
6238 case clang::BuiltinType::ObjCId:
6239 case clang::BuiltinType::ObjCClass:
6240 case clang::BuiltinType::ObjCSel:
6241 case clang::BuiltinType::BoundMember:
6242 case clang::BuiltinType::Half:
6243 case clang::BuiltinType::ARCUnbridgedCast:
6244 case clang::BuiltinType::PseudoObject:
6245 case clang::BuiltinType::BuiltinFn:
6246 case clang::BuiltinType::ArraySection:
6253 case clang::Type::Complex:
6255 case clang::Type::Pointer:
6257 case clang::Type::BlockPointer:
6260 case clang::Type::LValueReference:
6262 case clang::Type::RValueReference:
6264 case clang::Type::MemberPointer:
6266 case clang::Type::ConstantArray:
6268 case clang::Type::IncompleteArray:
6270 case clang::Type::VariableArray:
6272 case clang::Type::DependentSizedArray:
6274 case clang::Type::DependentSizedExtVector:
6276 case clang::Type::Vector:
6278 case clang::Type::ExtVector:
6280 case clang::Type::FunctionProto:
6282 case clang::Type::FunctionNoProto:
6284 case clang::Type::UnresolvedUsing:
6286 case clang::Type::Record:
6288 case clang::Type::Enum:
6290 case clang::Type::TemplateTypeParm:
6292 case clang::Type::SubstTemplateTypeParm:
6294 case clang::Type::TemplateSpecialization:
6296 case clang::Type::InjectedClassName:
6298 case clang::Type::DependentName:
6300 case clang::Type::ObjCObject:
6302 case clang::Type::ObjCInterface:
6304 case clang::Type::ObjCObjectPointer:
6314 std::string &deref_name, uint32_t &deref_byte_size,
6315 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6319 return llvm::createStringError(
"not a pointer, reference or array type");
6320 llvm::Expected<ChildTypeInfo> child =
6325 return child.takeError();
6326 deref_name = child->name;
6327 deref_byte_size = child->byte_size;
6328 deref_byte_offset = child->byte_offset;
6329 language_flags = child->language_flags;
6335 bool transparent_pointers,
bool omit_empty_base_classes,
6338 return llvm::createStringError(
"invalid type");
6342 child.
type = child_type;
6343 return std::move(child);
6345 auto get_pointee_child =
6346 [&](
CompilerType pointee) -> llvm::Expected<ChildTypeInfo> {
6347 llvm::Expected<ChildTypeInfo> pointee_child = pointee.GetChildAtIndex(
6348 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6349 ignore_array_bounds, valobj);
6351 pointee_child->is_deref_of_parent =
false;
6352 return pointee_child;
6355 auto get_exe_scope = [&exe_ctx]() {
6359 clang::QualType parent_qual_type(
6361 const clang::Type::TypeClass parent_type_class =
6362 parent_qual_type->getTypeClass();
6364 auto num_children_or_err =
6366 if (!num_children_or_err)
6367 return num_children_or_err.takeError();
6369 const bool idx_is_valid = idx < *num_children_or_err;
6371 switch (parent_type_class) {
6372 case clang::Type::Builtin:
6374 return llvm::createStringError(
"invalid index");
6376 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6377 case clang::BuiltinType::ObjCId:
6378 case clang::BuiltinType::ObjCClass:
6389 case clang::Type::Record: {
6391 return llvm::createStringError(
"invalid index");
6393 return llvm::createStringError(
"cannot complete type");
6395 const clang::RecordType *record_type =
6396 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6397 const clang::RecordDecl *record_decl =
6398 record_type->getDecl()->getDefinitionOrSelf();
6399 const clang::ASTRecordLayout &record_layout =
6401 uint32_t child_idx = 0;
6403 const clang::CXXRecordDecl *cxx_record_decl =
6404 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6405 if (cxx_record_decl) {
6407 clang::CXXRecordDecl::base_class_const_iterator base_class,
6409 for (base_class = cxx_record_decl->bases_begin(),
6410 base_class_end = cxx_record_decl->bases_end();
6411 base_class != base_class_end; ++base_class) {
6412 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6415 if (omit_empty_base_classes) {
6417 llvm::cast<clang::CXXRecordDecl>(
6418 base_class->getType()->getAs<clang::RecordType>()->getDecl())
6419 ->getDefinitionOrSelf();
6424 if (idx == child_idx) {
6425 if (base_class_decl ==
nullptr)
6426 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6427 base_class->getType()
6428 ->getAs<clang::RecordType>()
6430 ->getDefinitionOrSelf();
6432 if (base_class->isVirtual()) {
6433 bool handled =
false;
6435 clang::VTableContextBase *vtable_ctx =
6439 cxx_record_decl, base_class_decl,
6443 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6447 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6455 auto size_or_err = base_class_clang_type.
GetBitSize(get_exe_scope());
6457 return llvm::joinErrors(
6458 llvm::createStringError(
"no size info for base class"),
6459 size_or_err.takeError());
6461 uint64_t base_class_clang_type_bit_size = *size_or_err;
6464 assert(base_class_clang_type_bit_size % 8 == 0);
6465 child.
byte_size = base_class_clang_type_bit_size / 8;
6467 return with_type(base_class_clang_type);
6475 uint32_t field_idx = 0;
6476 clang::RecordDecl::field_iterator field, field_end;
6477 for (field = record_decl->field_begin(),
6478 field_end = record_decl->field_end();
6479 field != field_end; ++field, ++field_idx, ++child_idx) {
6480 if (idx == child_idx) {
6483 child.
name.assign(field->getNameAsString());
6488 assert(field_idx < record_layout.getFieldCount());
6489 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6491 return llvm::joinErrors(
6492 llvm::createStringError(
"no size info for field"),
6493 size_or_err.takeError());
6496 const uint32_t child_bit_size = child.
byte_size * 8;
6500 bit_offset = record_layout.getFieldOffset(field_idx);
6503 const uint32_t child_bit_offset =
6510 return with_type(field_clang_type);
6514 case clang::Type::ObjCObject:
6515 case clang::Type::ObjCInterface: {
6517 return llvm::createStringError(
"invalid index");
6519 return llvm::createStringError(
"cannot complete type");
6521 const clang::ObjCObjectType *objc_class_type =
6522 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6523 assert(objc_class_type);
6524 if (!objc_class_type)
6525 return llvm::createStringError(
"unexpected object type");
6527 uint32_t child_idx = 0;
6528 clang::ObjCInterfaceDecl *class_interface_decl =
6529 objc_class_type->getInterface();
6531 if (!class_interface_decl)
6532 return llvm::createStringError(
"cannot get interface decl");
6534 const clang::ASTRecordLayout &interface_layout =
6535 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6536 clang::ObjCInterfaceDecl *superclass_interface_decl =
6537 class_interface_decl->getSuperClass();
6538 if (superclass_interface_decl) {
6539 if (omit_empty_base_classes) {
6541 getASTContext().getObjCInterfaceType(superclass_interface_decl));
6542 if (llvm::expectedToOptional(base_class_clang_type.
GetNumChildren(
6543 omit_empty_base_classes, exe_ctx))
6546 clang::QualType ivar_qual_type(
getASTContext().getObjCInterfaceType(
6547 superclass_interface_decl));
6549 child.
name.assign(superclass_interface_decl->getNameAsString());
6551 clang::TypeInfo ivar_type_info =
6554 child.
byte_size = ivar_type_info.Width / 8;
6557 return with_type(
GetType(ivar_qual_type));
6566 const uint32_t superclass_idx = child_idx;
6568 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6569 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6570 ivar_end = class_interface_decl->ivar_end();
6572 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
6574 if (child_idx == idx) {
6575 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6577 clang::QualType ivar_qual_type(ivar_decl->getType());
6579 child.
name.assign(ivar_decl->getNameAsString());
6581 clang::TypeInfo ivar_type_info =
6584 child.
byte_size = ivar_type_info.Width / 8;
6600 if (objc_runtime !=
nullptr) {
6603 parent_ast_type, ivar_decl->getNameAsString().c_str());
6614 interface_layout.getFieldOffset(child_idx - superclass_idx);
6627 interface_layout.getFieldOffset(child_idx - superclass_idx);
6631 return with_type(
GetType(ivar_qual_type));
6638 case clang::Type::ObjCObjectPointer: {
6640 return llvm::createStringError(
"invalid index");
6644 return get_pointee_child(pointee_clang_type);
6647 const char *parent_name =
6650 child.
name.assign(1,
'*');
6651 child.
name += parent_name;
6656 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6658 return size_or_err.takeError();
6660 return with_type(pointee_clang_type);
6665 case clang::Type::Vector:
6666 case clang::Type::ExtVector: {
6668 return llvm::createStringError(
"invalid index");
6669 const clang::VectorType *array =
6670 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6672 return llvm::createStringError(
"unexpected vector type");
6676 return llvm::createStringError(
"cannot complete type");
6678 char element_name[64];
6679 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6680 static_cast<uint64_t
>(idx));
6681 child.
name.assign(element_name);
6682 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6684 return size_or_err.takeError();
6687 return with_type(element_type);
6689 case clang::Type::ConstantArray:
6690 case clang::Type::IncompleteArray: {
6691 if (!ignore_array_bounds && !idx_is_valid)
6692 return llvm::createStringError(
"invalid index");
6693 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6695 return llvm::createStringError(
"unexpected array type");
6698 return llvm::createStringError(
"cannot complete type");
6700 child.
name = std::string(llvm::formatv(
"[{0}]", idx));
6701 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6703 return size_or_err.takeError();
6706 return with_type(element_type);
6708 case clang::Type::Pointer: {
6713 return llvm::createStringError(
"cannot dereference void *");
6716 return get_pointee_child(pointee_clang_type);
6722 child.
name.assign(1,
'*');
6723 child.
name += parent_name;
6728 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6730 return size_or_err.takeError();
6732 return with_type(pointee_clang_type);
6737 case clang::Type::LValueReference:
6738 case clang::Type::RValueReference: {
6740 return llvm::createStringError(
"invalid index");
6741 const clang::ReferenceType *reference_type =
6742 llvm::cast<clang::ReferenceType>(
6746 return get_pointee_child(pointee_clang_type);
6750 child.
name.assign(1,
'&');
6751 child.
name += parent_name;
6756 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6758 return size_or_err.takeError();
6760 return with_type(pointee_clang_type);
6767 return llvm::createStringError(
"cannot enumerate children");
6771 const clang::RecordDecl *record_decl,
6772 const clang::CXXBaseSpecifier *base_spec,
6773 bool omit_empty_base_classes) {
6774 uint32_t child_idx = 0;
6776 const clang::CXXRecordDecl *cxx_record_decl =
6777 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6779 if (cxx_record_decl) {
6780 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6781 for (base_class = cxx_record_decl->bases_begin(),
6782 base_class_end = cxx_record_decl->bases_end();
6783 base_class != base_class_end; ++base_class) {
6784 if (omit_empty_base_classes) {
6789 if (base_class == base_spec)
6799 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6800 bool omit_empty_base_classes) {
6802 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6803 omit_empty_base_classes);
6805 clang::RecordDecl::field_iterator field, field_end;
6806 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6807 field != field_end; ++field, ++child_idx) {
6808 if (field->getCanonicalDecl() == canonical_decl)
6850 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6851 if (type && !name.empty()) {
6853 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6854 switch (type_class) {
6855 case clang::Type::Record:
6857 const clang::RecordType *record_type =
6858 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6859 const clang::RecordDecl *record_decl =
6860 record_type->getDecl()->getDefinitionOrSelf();
6862 assert(record_decl);
6863 uint32_t child_idx = 0;
6865 const clang::CXXRecordDecl *cxx_record_decl =
6866 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6869 clang::RecordDecl::field_iterator field, field_end;
6870 for (field = record_decl->field_begin(),
6871 field_end = record_decl->field_end();
6872 field != field_end; ++field, ++child_idx) {
6873 llvm::StringRef field_name = field->getName();
6874 if (field_name.empty()) {
6876 std::vector<uint32_t> save_indices = child_indexes;
6877 child_indexes.push_back(
6879 cxx_record_decl, omit_empty_base_classes));
6881 name, omit_empty_base_classes, child_indexes))
6882 return child_indexes.size();
6883 child_indexes = std::move(save_indices);
6884 }
else if (field_name == name) {
6886 child_indexes.push_back(
6888 cxx_record_decl, omit_empty_base_classes));
6889 return child_indexes.size();
6893 if (cxx_record_decl) {
6894 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6897 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6898 clang::DeclarationName decl_name(&ident_ref);
6900 clang::CXXBasePaths paths;
6901 if (cxx_record_decl->lookupInBases(
6902 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6903 clang::CXXBasePath &path) {
6904 CXXRecordDecl *record =
6905 specifier->getType()->getAsCXXRecordDecl();
6906 auto r = record->lookup(decl_name);
6907 path.Decls = r.begin();
6911 clang::CXXBasePaths::const_paths_iterator path,
6912 path_end = paths.end();
6913 for (path = paths.begin(); path != path_end; ++path) {
6914 const size_t num_path_elements = path->size();
6915 for (
size_t e = 0; e < num_path_elements; ++e) {
6916 clang::CXXBasePathElement elem = (*path)[e];
6919 omit_empty_base_classes);
6921 child_indexes.clear();
6924 child_indexes.push_back(child_idx);
6925 parent_record_decl = elem.Base->getType()
6926 ->castAs<clang::RecordType>()
6928 ->getDefinitionOrSelf();
6931 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6934 parent_record_decl, *I, omit_empty_base_classes);
6936 child_indexes.clear();
6939 child_indexes.push_back(child_idx);
6943 return child_indexes.size();
6949 case clang::Type::ObjCObject:
6950 case clang::Type::ObjCInterface:
6952 llvm::StringRef name_sref(name);
6953 const clang::ObjCObjectType *objc_class_type =
6954 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6955 assert(objc_class_type);
6956 if (objc_class_type) {
6957 uint32_t child_idx = 0;
6958 clang::ObjCInterfaceDecl *class_interface_decl =
6959 objc_class_type->getInterface();
6961 if (class_interface_decl) {
6962 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6963 ivar_end = class_interface_decl->ivar_end();
6964 clang::ObjCInterfaceDecl *superclass_interface_decl =
6965 class_interface_decl->getSuperClass();
6967 for (ivar_pos = class_interface_decl->ivar_begin();
6968 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6969 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6971 if (ivar_decl->getName() == name_sref) {
6972 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6973 (omit_empty_base_classes &&
6977 child_indexes.push_back(child_idx);
6978 return child_indexes.size();
6982 if (superclass_interface_decl) {
6986 child_indexes.push_back(0);
6990 superclass_interface_decl));
6992 name, omit_empty_base_classes, child_indexes)) {
6995 return child_indexes.size();
7000 child_indexes.pop_back();
7007 case clang::Type::ObjCObjectPointer: {
7009 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7010 ->getPointeeType());
7012 name, omit_empty_base_classes, child_indexes);
7015 case clang::Type::LValueReference:
7016 case clang::Type::RValueReference: {
7017 const clang::ReferenceType *reference_type =
7018 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7019 clang::QualType pointee_type(reference_type->getPointeeType());
7024 name, omit_empty_base_classes, child_indexes);
7028 case clang::Type::Pointer: {
7033 name, omit_empty_base_classes, child_indexes);
7048llvm::Expected<uint32_t>
7050 llvm::StringRef name,
7051 bool omit_empty_base_classes) {
7052 if (type && !name.empty()) {
7055 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7057 switch (type_class) {
7058 case clang::Type::Record:
7060 const clang::RecordType *record_type =
7061 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7062 const clang::RecordDecl *record_decl =
7063 record_type->getDecl()->getDefinitionOrSelf();
7065 assert(record_decl);
7066 uint32_t child_idx = 0;
7068 const clang::CXXRecordDecl *cxx_record_decl =
7069 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
7071 if (cxx_record_decl) {
7072 clang::CXXRecordDecl::base_class_const_iterator base_class,
7074 for (base_class = cxx_record_decl->bases_begin(),
7075 base_class_end = cxx_record_decl->bases_end();
7076 base_class != base_class_end; ++base_class) {
7078 clang::CXXRecordDecl *base_class_decl =
7079 llvm::cast<clang::CXXRecordDecl>(
7080 base_class->getType()
7081 ->castAs<clang::RecordType>()
7083 ->getDefinitionOrSelf();
7084 if (omit_empty_base_classes &&
7089 std::string base_class_type_name(
7091 if (base_class_type_name == name)
7098 clang::RecordDecl::field_iterator field, field_end;
7099 for (field = record_decl->field_begin(),
7100 field_end = record_decl->field_end();
7101 field != field_end; ++field, ++child_idx) {
7102 if (field->getName() == name)
7108 case clang::Type::ObjCObject:
7109 case clang::Type::ObjCInterface:
7111 const clang::ObjCObjectType *objc_class_type =
7112 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
7113 assert(objc_class_type);
7114 if (objc_class_type) {
7115 uint32_t child_idx = 0;
7116 clang::ObjCInterfaceDecl *class_interface_decl =
7117 objc_class_type->getInterface();
7119 if (class_interface_decl) {
7120 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
7121 ivar_end = class_interface_decl->ivar_end();
7122 clang::ObjCInterfaceDecl *superclass_interface_decl =
7123 class_interface_decl->getSuperClass();
7125 for (ivar_pos = class_interface_decl->ivar_begin();
7126 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
7127 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
7129 if (ivar_decl->getName() == name) {
7130 if ((!omit_empty_base_classes && superclass_interface_decl) ||
7131 (omit_empty_base_classes &&
7139 if (superclass_interface_decl) {
7140 if (superclass_interface_decl->getName() == name)
7148 case clang::Type::ObjCObjectPointer: {
7150 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7151 ->getPointeeType());
7153 name, omit_empty_base_classes);
7156 case clang::Type::LValueReference:
7157 case clang::Type::RValueReference: {
7158 const clang::ReferenceType *reference_type =
7159 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7164 omit_empty_base_classes);
7168 case clang::Type::Pointer: {
7169 const clang::PointerType *pointer_type =
7170 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7175 omit_empty_base_classes);
7183 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
7188 llvm::StringRef name) {
7189 if (!type || name.empty())
7193 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7195 switch (type_class) {
7196 case clang::Type::Record: {
7199 const clang::RecordType *record_type =
7200 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7201 const clang::RecordDecl *record_decl =
7202 record_type->getDecl()->getDefinitionOrSelf();
7204 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7205 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7206 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7208 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7210 ElaboratedTypeKeyword::None, std::nullopt,
7226 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7227 return isa<clang::ClassTemplateSpecializationDecl>(
7228 cxx_record_decl->getDecl());
7239 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7240 switch (type_class) {
7241 case clang::Type::Record:
7243 const clang::CXXRecordDecl *cxx_record_decl =
7244 qual_type->getAsCXXRecordDecl();
7245 if (cxx_record_decl) {
7246 const clang::ClassTemplateSpecializationDecl *template_decl =
7247 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7249 if (template_decl) {
7250 const auto &template_arg_list = template_decl->getTemplateArgs();
7251 size_t num_args = template_arg_list.size();
7252 assert(num_args &&
"template specialization without any args");
7253 if (expand_pack && num_args) {
7254 const auto &pack = template_arg_list[num_args - 1];
7255 if (pack.getKind() == clang::TemplateArgument::Pack)
7256 num_args += pack.pack_size() - 1;
7271const clang::ClassTemplateSpecializationDecl *
7278 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7279 switch (type_class) {
7280 case clang::Type::Record: {
7283 const clang::CXXRecordDecl *cxx_record_decl =
7284 qual_type->getAsCXXRecordDecl();
7285 if (!cxx_record_decl)
7287 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7296const TemplateArgument *
7298 size_t idx,
bool expand_pack) {
7299 const auto &args = decl->getTemplateArgs();
7300 const size_t args_size = args.size();
7302 assert(args_size &&
"template specialization without any args");
7306 const size_t last_idx = args_size - 1;
7315 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7316 return idx >= args.size() ? nullptr : &args[idx];
7321 const auto &pack = args[last_idx];
7322 const size_t pack_idx = idx - last_idx;
7323 if (pack_idx >= pack.pack_size())
7325 return &pack.pack_elements()[pack_idx];
7330 size_t arg_idx,
bool expand_pack) {
7331 const clang::ClassTemplateSpecializationDecl *template_decl =
7340 switch (arg->getKind()) {
7341 case clang::TemplateArgument::Null:
7344 case clang::TemplateArgument::NullPtr:
7347 case clang::TemplateArgument::Type:
7350 case clang::TemplateArgument::Declaration:
7353 case clang::TemplateArgument::Integral:
7356 case clang::TemplateArgument::Template:
7359 case clang::TemplateArgument::TemplateExpansion:
7362 case clang::TemplateArgument::Expression:
7365 case clang::TemplateArgument::Pack:
7368 case clang::TemplateArgument::StructuralValue:
7371 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7376 size_t idx,
bool expand_pack) {
7377 const clang::ClassTemplateSpecializationDecl *template_decl =
7383 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7386 return GetType(arg->getAsType());
7389std::optional<CompilerType::IntegralTemplateArgument>
7391 size_t idx,
bool expand_pack) {
7392 const clang::ClassTemplateSpecializationDecl *template_decl =
7395 return std::nullopt;
7399 return std::nullopt;
7401 switch (arg->getKind()) {
7402 case clang::TemplateArgument::Integral:
7403 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7404 case clang::TemplateArgument::StructuralValue: {
7405 clang::APValue value = arg->getAsStructuralValue();
7408 if (value.isFloat())
7409 return {{value.getFloat(), type}};
7412 return {{value.getInt(), type}};
7414 return std::nullopt;
7417 return std::nullopt;
7442 const clang::EnumType *enutype =
7445 return enutype->getDecl()->getDefinitionOrSelf();
7450 const clang::RecordType *record_type =
7453 return record_type->getDecl()->getDefinitionOrSelf();
7461clang::TypedefNameDecl *
7463 const clang::TypedefType *typedef_type =
7466 return typedef_type->getDecl();
7470clang::CXXRecordDecl *
7475clang::ObjCInterfaceDecl *
7477 const clang::ObjCObjectType *objc_class_type =
7478 llvm::dyn_cast<clang::ObjCObjectType>(
7480 if (objc_class_type)
7481 return objc_class_type->getInterface();
7487 const CompilerType &field_clang_type, uint32_t bitfield_bit_size) {
7493 clang::ASTContext &clang_ast = ast->getASTContext();
7494 clang::IdentifierInfo *ident =
nullptr;
7496 ident = &clang_ast.Idents.get(name);
7498 clang::FieldDecl *field =
nullptr;
7500 clang::Expr *bit_width =
nullptr;
7501 if (bitfield_bit_size != 0) {
7502 if (clang_ast.IntTy.isNull()) {
7504 "builtin ASTContext types have not been initialized");
7508 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7510 bit_width =
new (clang_ast)
7511 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7512 clang_ast.IntTy, clang::SourceLocation());
7513 bit_width = clang::ConstantExpr::Create(
7514 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7517 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7519 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7520 field->setDeclContext(record_decl);
7521 field->setDeclName(ident);
7524 field->setBitWidth(bit_width);
7530 if (
const clang::TagType *TagT =
7531 field->getType()->getAs<clang::TagType>()) {
7532 if (clang::RecordDecl *Rec =
7533 llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
7534 if (!Rec->getDeclName()) {
7535 Rec->setAnonymousStructOrUnion(
true);
7536 field->setImplicit();
7542 field->setAccess(AS_public);
7544 record_decl->addDecl(field);
7549 clang::ObjCInterfaceDecl *class_interface_decl =
7550 ast->GetAsObjCInterfaceDecl(type);
7552 if (class_interface_decl) {
7553 const bool is_synthesized =
false;
7558 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7559 ivar->setDeclContext(class_interface_decl);
7560 ivar->setDeclName(ident);
7562 ivar->setAccessControl(ObjCIvarDecl::AccessControl::Public);
7564 ivar->setBitWidth(bit_width);
7565 ivar->setSynthesize(is_synthesized);
7570 class_interface_decl->addDecl(field);
7587 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7592 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7594 IndirectFieldVector indirect_fields;
7595 clang::RecordDecl::field_iterator field_pos;
7596 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7597 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7598 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7599 last_field_pos = field_pos++) {
7600 if (field_pos->isAnonymousStructOrUnion()) {
7601 clang::QualType field_qual_type = field_pos->getType();
7603 const clang::RecordType *field_record_type =
7604 field_qual_type->getAs<clang::RecordType>();
7606 if (!field_record_type)
7609 clang::RecordDecl *field_record_decl =
7610 field_record_type->getDecl()->getDefinition();
7612 if (!field_record_decl)
7615 for (clang::RecordDecl::decl_iterator
7616 di = field_record_decl->decls_begin(),
7617 de = field_record_decl->decls_end();
7619 if (clang::FieldDecl *nested_field_decl =
7620 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7621 clang::NamedDecl **chain =
7622 new (ast->getASTContext()) clang::NamedDecl *[2];
7623 chain[0] = *field_pos;
7624 chain[1] = nested_field_decl;
7625 clang::IndirectFieldDecl *indirect_field =
7626 clang::IndirectFieldDecl::Create(
7627 ast->getASTContext(), record_decl, clang::SourceLocation(),
7628 nested_field_decl->getIdentifier(),
7629 nested_field_decl->getType(), {chain, 2});
7632 indirect_field->setImplicit();
7634 indirect_field->setAccess(AS_public);
7636 indirect_fields.push_back(indirect_field);
7637 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7638 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7639 size_t nested_chain_size =
7640 nested_indirect_field_decl->getChainingSize();
7641 clang::NamedDecl **chain =
new (ast->getASTContext())
7642 clang::NamedDecl *[nested_chain_size + 1];
7643 chain[0] = *field_pos;
7645 int chain_index = 1;
7646 for (clang::IndirectFieldDecl::chain_iterator
7647 nci = nested_indirect_field_decl->chain_begin(),
7648 nce = nested_indirect_field_decl->chain_end();
7650 chain[chain_index] = *nci;
7654 clang::IndirectFieldDecl *indirect_field =
7655 clang::IndirectFieldDecl::Create(
7656 ast->getASTContext(), record_decl, clang::SourceLocation(),
7657 nested_indirect_field_decl->getIdentifier(),
7658 nested_indirect_field_decl->getType(),
7659 {chain, nested_chain_size + 1});
7662 indirect_field->setImplicit();
7664 indirect_field->setAccess(AS_public);
7666 indirect_fields.push_back(indirect_field);
7674 if (last_field_pos != field_end_pos) {
7675 if (last_field_pos->getType()->isIncompleteArrayType())
7676 record_decl->hasFlexibleArrayMember();
7679 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7680 ife = indirect_fields.end();
7682 record_decl->addDecl(*ifi);
7695 record_decl->addAttr(
7696 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7703 llvm::StringRef name,
7712 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7716 clang::VarDecl *var_decl =
nullptr;
7717 clang::IdentifierInfo *ident =
nullptr;
7719 ident = &ast->getASTContext().Idents.get(name);
7722 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7723 var_decl->setDeclContext(record_decl);
7724 var_decl->setDeclName(ident);
7726 var_decl->setStorageClass(clang::SC_Static);
7731 var_decl->setAccess(AS_public);
7732 record_decl->addDecl(var_decl);
7734 VerifyDecl(var_decl);
7740 VarDecl *var,
const llvm::APInt &init_value) {
7741 assert(!var->hasInit() &&
"variable already initialized");
7743 clang::ASTContext &ast = var->getASTContext();
7744 QualType qt = var->getType();
7745 assert(qt->isIntegralOrEnumerationType() &&
7746 "only integer or enum types supported");
7749 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7750 const EnumDecl *enum_decl = enum_type->getDecl()->getDefinitionOrSelf();
7751 qt = enum_decl->getIntegerType();
7755 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7756 var->setInit(CXXBoolLiteralExpr::Create(
7757 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7759 var->setInit(IntegerLiteral::Create(
7760 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7765 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7766 assert(!var->hasInit() &&
"variable already initialized");
7768 clang::ASTContext &ast = var->getASTContext();
7769 QualType qt = var->getType();
7770 assert(qt->isFloatingType() &&
"only floating point types supported");
7771 var->setInit(FloatingLiteral::Create(
7772 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7775llvm::SmallVector<clang::ParmVarDecl *>
7777 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7778 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7780 assert(parameter_names.empty() ||
7781 parameter_names.size() == prototype.getNumParams());
7783 llvm::SmallVector<clang::ParmVarDecl *> params;
7784 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7786 llvm::StringRef name =
7787 !parameter_names.empty() ? parameter_names[param_index] :
"";
7791 GetType(prototype.getParamType(param_index)),
7792 clang::SC_None,
false);
7795 params.push_back(param);
7803 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7804 bool is_virtual,
bool is_static,
bool is_inline,
bool is_explicit,
7805 bool is_attr_used,
bool is_artificial) {
7806 if (!type || !method_clang_type.
IsValid() || name.empty())
7811 clang::CXXRecordDecl *cxx_record_decl =
7812 record_qual_type->getAsCXXRecordDecl();
7814 if (cxx_record_decl ==
nullptr)
7819 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7821 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7823 const clang::FunctionType *function_type =
7824 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7826 if (function_type ==
nullptr)
7829 const clang::FunctionProtoType *method_function_prototype(
7830 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7832 if (!method_function_prototype)
7835 unsigned int num_params = method_function_prototype->getNumParams();
7837 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7838 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7843 const clang::ExplicitSpecifier explicit_spec(
7844 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7845 : clang::ExplicitSpecKind::ResolvedFalse);
7847 if (name.starts_with(
"~")) {
7848 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7850 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7851 cxx_dtor_decl->setDeclName(
7854 cxx_dtor_decl->setType(method_qual_type);
7855 cxx_dtor_decl->setImplicit(is_artificial);
7856 cxx_dtor_decl->setInlineSpecified(is_inline);
7857 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7858 cxx_method_decl = cxx_dtor_decl;
7859 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7860 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7862 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7863 cxx_ctor_decl->setDeclName(
7866 cxx_ctor_decl->setType(method_qual_type);
7867 cxx_ctor_decl->setImplicit(is_artificial);
7868 cxx_ctor_decl->setInlineSpecified(is_inline);
7869 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7870 cxx_ctor_decl->setNumCtorInitializers(0);
7871 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7872 cxx_method_decl = cxx_ctor_decl;
7874 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7875 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7878 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7883 const bool is_method =
true;
7885 is_method, op_kind, num_params))
7887 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7889 cxx_method_decl->setDeclContext(cxx_record_decl);
7890 cxx_method_decl->setDeclName(
7891 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7892 cxx_method_decl->setType(method_qual_type);
7893 cxx_method_decl->setStorageClass(SC);
7894 cxx_method_decl->setInlineSpecified(is_inline);
7895 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7896 }
else if (num_params == 0) {
7898 auto *cxx_conversion_decl =
7899 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7901 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7902 cxx_conversion_decl->setDeclName(
7903 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7905 function_type->getReturnType())));
7906 cxx_conversion_decl->setType(method_qual_type);
7907 cxx_conversion_decl->setInlineSpecified(is_inline);
7908 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7909 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7910 cxx_method_decl = cxx_conversion_decl;
7914 if (cxx_method_decl ==
nullptr) {
7915 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7917 cxx_method_decl->setDeclContext(cxx_record_decl);
7918 cxx_method_decl->setDeclName(decl_name);
7919 cxx_method_decl->setType(method_qual_type);
7920 cxx_method_decl->setInlineSpecified(is_inline);
7921 cxx_method_decl->setStorageClass(SC);
7922 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7927 cxx_method_decl->setAccess(AS_public);
7928 cxx_method_decl->setVirtualAsWritten(is_virtual);
7931 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7933 if (!asm_label.empty())
7934 cxx_method_decl->addAttr(
7935 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7940 cxx_method_decl, *method_function_prototype, {}));
7942 cxx_record_decl->addDecl(cxx_method_decl);
7951 if (is_artificial) {
7952 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7953 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7954 (cxx_ctor_decl->isCopyConstructor() &&
7955 cxx_record_decl->hasTrivialCopyConstructor()) ||
7956 (cxx_ctor_decl->isMoveConstructor() &&
7957 cxx_record_decl->hasTrivialMoveConstructor()))) {
7958 cxx_ctor_decl->setDefaulted();
7959 cxx_ctor_decl->setTrivial(
true);
7960 }
else if (cxx_dtor_decl) {
7961 if (cxx_record_decl->hasTrivialDestructor()) {
7962 cxx_dtor_decl->setDefaulted();
7963 cxx_dtor_decl->setTrivial(
true);
7965 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7966 cxx_record_decl->hasTrivialCopyAssignment()) ||
7967 (cxx_method_decl->isMoveAssignmentOperator() &&
7968 cxx_record_decl->hasTrivialMoveAssignment())) {
7969 cxx_method_decl->setDefaulted();
7970 cxx_method_decl->setTrivial(
true);
7974 VerifyDecl(cxx_method_decl);
7976 return cxx_method_decl;
7982 for (
auto *method : record->methods())
7983 addOverridesForMethod(method);
7986#pragma mark C++ Base Classes
7988std::unique_ptr<clang::CXXBaseSpecifier>
7991 bool base_of_class) {
7995 return std::make_unique<clang::CXXBaseSpecifier>(
7996 clang::SourceRange(), is_virtual, base_of_class,
7999 clang::SourceLocation());
8004 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
8008 if (!cxx_record_decl)
8010 std::vector<clang::CXXBaseSpecifier *> raw_bases;
8011 raw_bases.reserve(bases.size());
8015 for (
auto &b : bases)
8016 raw_bases.push_back(b.get());
8017 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
8026 clang::ASTContext &clang_ast = ast->getASTContext();
8028 if (type && superclass_clang_type.
IsValid() &&
8030 clang::ObjCInterfaceDecl *class_interface_decl =
8032 clang::ObjCInterfaceDecl *super_interface_decl =
8034 if (class_interface_decl && super_interface_decl) {
8035 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
8036 clang_ast.getObjCInterfaceType(super_interface_decl)));
8045 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
8046 const char *property_setter_name,
const char *property_getter_name,
8048 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
8049 property_name[0] ==
'\0')
8054 clang::ASTContext &clang_ast = ast->getASTContext();
8057 if (!class_interface_decl)
8062 if (property_clang_type.
IsValid())
8063 property_clang_type_to_access = property_clang_type;
8065 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
8067 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
8070 clang::TypeSourceInfo *prop_type_source;
8072 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
8074 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
8077 clang::ObjCPropertyDecl *property_decl =
8078 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8079 property_decl->setDeclContext(class_interface_decl);
8080 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
8081 property_decl->setType(ivar_decl
8082 ? ivar_decl->getType()
8090 ast->SetMetadata(property_decl, metadata);
8092 class_interface_decl->addDecl(property_decl);
8094 clang::Selector setter_sel, getter_sel;
8096 if (property_setter_name) {
8097 std::string property_setter_no_colon(property_setter_name,
8098 strlen(property_setter_name) - 1);
8099 const clang::IdentifierInfo *setter_ident =
8100 &clang_ast.Idents.get(property_setter_no_colon);
8101 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8102 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
8103 std::string setter_sel_string(
"set");
8104 setter_sel_string.push_back(::toupper(property_name[0]));
8105 setter_sel_string.append(&property_name[1]);
8106 const clang::IdentifierInfo *setter_ident =
8107 &clang_ast.Idents.get(setter_sel_string);
8108 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8110 property_decl->setSetterName(setter_sel);
8111 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
8113 if (property_getter_name !=
nullptr) {
8114 const clang::IdentifierInfo *getter_ident =
8115 &clang_ast.Idents.get(property_getter_name);
8116 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8118 const clang::IdentifierInfo *getter_ident =
8119 &clang_ast.Idents.get(property_name);
8120 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8122 property_decl->setGetterName(getter_sel);
8123 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
8126 property_decl->setPropertyIvarDecl(ivar_decl);
8128 if (property_attributes & DW_APPLE_PROPERTY_readonly)
8129 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
8130 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
8131 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
8132 if (property_attributes & DW_APPLE_PROPERTY_assign)
8133 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
8134 if (property_attributes & DW_APPLE_PROPERTY_retain)
8135 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
8136 if (property_attributes & DW_APPLE_PROPERTY_copy)
8137 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
8138 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8139 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
8140 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
8141 property_decl->setPropertyAttributes(
8142 ObjCPropertyAttribute::kind_nullability);
8143 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
8144 property_decl->setPropertyAttributes(
8145 ObjCPropertyAttribute::kind_null_resettable);
8146 if (property_attributes & ObjCPropertyAttribute::kind_class)
8147 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8149 const bool isInstance =
8150 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8152 clang::ObjCMethodDecl *getter =
nullptr;
8153 if (!getter_sel.isNull())
8154 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8155 : class_interface_decl->lookupClassMethod(getter_sel);
8156 if (!getter_sel.isNull() && !getter) {
8157 const bool isVariadic =
false;
8158 const bool isPropertyAccessor =
true;
8159 const bool isSynthesizedAccessorStub =
false;
8160 const bool isImplicitlyDeclared =
true;
8161 const bool isDefined =
false;
8162 const clang::ObjCImplementationControl impControl =
8163 clang::ObjCImplementationControl::None;
8164 const bool HasRelatedResultType =
false;
8167 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8168 getter->setDeclName(getter_sel);
8170 getter->setDeclContext(class_interface_decl);
8171 getter->setInstanceMethod(isInstance);
8172 getter->setVariadic(isVariadic);
8173 getter->setPropertyAccessor(isPropertyAccessor);
8174 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8175 getter->setImplicit(isImplicitlyDeclared);
8176 getter->setDefined(isDefined);
8177 getter->setDeclImplementation(impControl);
8178 getter->setRelatedResultType(HasRelatedResultType);
8182 ast->SetMetadata(getter, metadata);
8184 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8185 llvm::ArrayRef<clang::SourceLocation>());
8186 class_interface_decl->addDecl(getter);
8190 getter->setPropertyAccessor(
true);
8191 property_decl->setGetterMethodDecl(getter);
8194 clang::ObjCMethodDecl *setter =
nullptr;
8195 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8196 : class_interface_decl->lookupClassMethod(setter_sel);
8197 if (!setter_sel.isNull() && !setter) {
8198 clang::QualType result_type = clang_ast.VoidTy;
8199 const bool isVariadic =
false;
8200 const bool isPropertyAccessor =
true;
8201 const bool isSynthesizedAccessorStub =
false;
8202 const bool isImplicitlyDeclared =
true;
8203 const bool isDefined =
false;
8204 const clang::ObjCImplementationControl impControl =
8205 clang::ObjCImplementationControl::None;
8206 const bool HasRelatedResultType =
false;
8209 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8210 setter->setDeclName(setter_sel);
8211 setter->setReturnType(result_type);
8212 setter->setDeclContext(class_interface_decl);
8213 setter->setInstanceMethod(isInstance);
8214 setter->setVariadic(isVariadic);
8215 setter->setPropertyAccessor(isPropertyAccessor);
8216 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8217 setter->setImplicit(isImplicitlyDeclared);
8218 setter->setDefined(isDefined);
8219 setter->setDeclImplementation(impControl);
8220 setter->setRelatedResultType(HasRelatedResultType);
8224 ast->SetMetadata(setter, metadata);
8226 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8227 params.push_back(clang::ParmVarDecl::Create(
8228 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8231 clang::SC_Auto,
nullptr));
8233 setter->setMethodParams(clang_ast,
8234 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8235 llvm::ArrayRef<clang::SourceLocation>());
8237 class_interface_decl->addDecl(setter);
8241 setter->setPropertyAccessor(
true);
8242 property_decl->setSetterMethodDecl(setter);
8253 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8254 bool is_objc_direct_call) {
8255 if (!type || !method_clang_type.
IsValid())
8260 if (class_interface_decl ==
nullptr)
8263 if (lldb_ast ==
nullptr)
8265 clang::ASTContext &ast = lldb_ast->getASTContext();
8267 const char *selector_start = ::strchr(name,
' ');
8268 if (selector_start ==
nullptr)
8272 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8277 unsigned num_selectors_with_args = 0;
8278 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8280 len = ::strcspn(start,
":]");
8281 bool has_arg = (start[len] ==
':');
8283 ++num_selectors_with_args;
8284 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8289 if (selector_idents.size() == 0)
8292 clang::Selector method_selector = ast.Selectors.getSelector(
8293 num_selectors_with_args ? selector_idents.size() : 0,
8294 selector_idents.data());
8299 const clang::Type *method_type(method_qual_type.getTypePtr());
8301 if (method_type ==
nullptr)
8304 const clang::FunctionProtoType *method_function_prototype(
8305 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8307 if (!method_function_prototype)
8310 const bool isInstance = (name[0] ==
'-');
8311 const bool isVariadic = is_variadic;
8312 const bool isPropertyAccessor =
false;
8313 const bool isSynthesizedAccessorStub =
false;
8315 const bool isImplicitlyDeclared =
true;
8316 const bool isDefined =
false;
8317 const clang::ObjCImplementationControl impControl =
8318 clang::ObjCImplementationControl::None;
8319 const bool HasRelatedResultType =
false;
8321 const unsigned num_args = method_function_prototype->getNumParams();
8323 if (num_args != num_selectors_with_args)
8327 auto *objc_method_decl =
8328 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8329 objc_method_decl->setDeclName(method_selector);
8330 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8331 objc_method_decl->setDeclContext(
8333 objc_method_decl->setInstanceMethod(isInstance);
8334 objc_method_decl->setVariadic(isVariadic);
8335 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8336 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8337 objc_method_decl->setImplicit(isImplicitlyDeclared);
8338 objc_method_decl->setDefined(isDefined);
8339 objc_method_decl->setDeclImplementation(impControl);
8340 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8343 if (objc_method_decl ==
nullptr)
8347 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8349 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8350 params.push_back(clang::ParmVarDecl::Create(
8351 ast, objc_method_decl, clang::SourceLocation(),
8352 clang::SourceLocation(),
8354 method_function_prototype->getParamType(param_index),
nullptr,
8355 clang::SC_Auto,
nullptr));
8358 objc_method_decl->setMethodParams(
8359 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8360 llvm::ArrayRef<clang::SourceLocation>());
8363 if (is_objc_direct_call) {
8366 objc_method_decl->addAttr(
8367 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8372 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8375 class_interface_decl->addDecl(objc_method_decl);
8377 VerifyDecl(objc_method_decl);
8379 return objc_method_decl;
8389 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8390 switch (type_class) {
8391 case clang::Type::Record: {
8392 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8393 if (cxx_record_decl) {
8394 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8395 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8400 case clang::Type::Enum: {
8401 clang::EnumDecl *enum_decl =
8402 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8404 enum_decl->setHasExternalLexicalStorage(has_extern);
8405 enum_decl->setHasExternalVisibleStorage(has_extern);
8410 case clang::Type::ObjCObject:
8411 case clang::Type::ObjCInterface: {
8412 const clang::ObjCObjectType *objc_class_type =
8413 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8414 assert(objc_class_type);
8415 if (objc_class_type) {
8416 clang::ObjCInterfaceDecl *class_interface_decl =
8417 objc_class_type->getInterface();
8419 if (class_interface_decl) {
8420 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8421 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8437 if (!qual_type.isNull()) {
8438 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8440 clang::TagDecl *tag_decl = tag_type->getDecl();
8442 tag_decl->startDefinition();
8447 const clang::ObjCObjectType *object_type =
8448 qual_type->getAs<clang::ObjCObjectType>();
8450 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8451 if (interface_decl) {
8452 interface_decl->startDefinition();
8463 if (qual_type.isNull())
8467 if (lldb_ast ==
nullptr)
8473 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8475 clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinitionOrSelf();
8477 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8487 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8488 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8489 if (cxx_record_decl->needsImplicitCopyConstructor())
8490 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8491 if (cxx_record_decl->needsImplicitCopyAssignment())
8492 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8495 if (!cxx_record_decl->isCompleteDefinition())
8496 cxx_record_decl->completeDefinition();
8497 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8498 cxx_record_decl->setHasExternalLexicalStorage(
false);
8499 cxx_record_decl->setHasExternalVisibleStorage(
false);
8504 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8508 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8510 if (enum_decl->isCompleteDefinition())
8513 QualType integer_type(enum_decl->getIntegerType());
8514 if (!integer_type.isNull()) {
8515 clang::ASTContext &ast = lldb_ast->getASTContext();
8517 unsigned NumNegativeBits = 0;
8518 unsigned NumPositiveBits = 0;
8519 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8522 clang::QualType BestPromotionType;
8523 clang::QualType BestType;
8524 ast.computeBestEnumTypes(
false, NumNegativeBits,
8525 NumPositiveBits, BestType, BestPromotionType);
8527 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8528 BestPromotionType, NumPositiveBits,
8536 const llvm::APSInt &value) {
8547 if (!enum_opaque_compiler_type)
8550 clang::QualType enum_qual_type(
8553 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8558 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8563 clang::EnumConstantDecl *enumerator_decl =
8564 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8566 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8567 enumerator_decl->setDeclContext(enum_decl);
8568 if (name && name[0])
8569 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8570 enumerator_decl->setType(clang::QualType(enutype, 0));
8572 enumerator_decl->setAccess(AS_public);
8578 enum_decl->addDecl(enumerator_decl);
8580 VerifyDecl(enumerator_decl);
8581 return enumerator_decl;
8586 uint64_t enum_value, uint32_t enum_value_bit_size) {
8588 llvm::APSInt value(enum_value_bit_size,
8597 const clang::Type *clang_type = qt.getTypePtrOrNull();
8598 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8602 return GetType(enum_type->getDecl()->getDefinitionOrSelf()->getIntegerType());
8608 if (type && pointee_type.
IsValid() &&
8613 return ast->GetType(ast->getASTContext().getMemberPointerType(
8622#define DEPTH_INCREMENT 2
8625LLVM_DUMP_METHOD
void
8635struct ScopedASTColor {
8636 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8639 ast.getDiagnostics().getDiagnosticOptions().getShowColors()) {
8640 ast.getDiagnostics().getDiagnosticOptions().setShowColors(
8641 show_colors ? clang::ShowColorsKind::On : clang::ShowColorsKind::Off);
8645 ast.getDiagnostics().getDiagnosticOptions().setShowColors(old_show_colors);
8648 clang::ASTContext *
8649 const clang::ShowColorsKind old_show_colors;
8658 clang::CreateASTDumper(output, filter,
8663 false, clang::ADOF_Default);
8666 consumer->HandleTranslationUnit(*
m_ast_up);
8670 llvm::StringRef symbol_name) {
8677 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8678 size_t ntypes = type_list.
GetSize();
8680 for (
size_t i = 0; i < ntypes; ++i) {
8683 if (!symbol_name.empty())
8684 if (symbol_name != type->GetName().GetStringRef())
8687 s << type->GetName() <<
"\n";
8690 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8698 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8700 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8712 size_t byte_size, uint32_t bitfield_bit_offset,
8713 uint32_t bitfield_bit_size) {
8714 const clang::EnumType *enutype =
8715 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8716 const clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8718 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8719 const uint64_t enum_svalue =
8722 bitfield_bit_offset)
8724 bitfield_bit_offset);
8725 bool can_be_bitfield =
true;
8726 uint64_t covered_bits = 0;
8727 int num_enumerators = 0;
8735 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8736 if (enumerators.empty())
8737 can_be_bitfield =
false;
8739 for (
auto *enumerator : enumerators) {
8740 llvm::APSInt init_val = enumerator->getInitVal();
8741 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8742 : init_val.getZExtValue();
8743 if (qual_type_is_signed)
8744 val = llvm::SignExtend64(val, 8 * byte_size);
8745 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8746 can_be_bitfield =
false;
8747 covered_bits |= val;
8749 if (val == enum_svalue) {
8758 offset = byte_offset;
8760 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8764 if (!can_be_bitfield) {
8765 if (qual_type_is_signed)
8766 s.
Printf(
"%" PRIi64, enum_svalue);
8768 s.
Printf(
"%" PRIu64, enum_uvalue);
8775 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8779 uint64_t remaining_value = enum_uvalue;
8780 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8781 values.reserve(num_enumerators);
8782 for (
auto *enumerator : enum_decl->enumerators())
8783 if (
auto val = enumerator->getInitVal().getZExtValue())
8784 values.emplace_back(val, enumerator->getName());
8789 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8790 return llvm::popcount(a.first) > llvm::popcount(b.first);
8793 for (
const auto &val : values) {
8794 if ((remaining_value & val.first) != val.first)
8796 remaining_value &= ~val.first;
8798 if (remaining_value)
8804 if (remaining_value)
8805 s.
Printf(
"0x%" PRIx64, remaining_value);
8813 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8822 switch (qual_type->getTypeClass()) {
8823 case clang::Type::Typedef: {
8824 clang::QualType typedef_qual_type =
8825 llvm::cast<clang::TypedefType>(qual_type)
8827 ->getUnderlyingType();
8830 format = typedef_clang_type.
GetFormat();
8831 clang::TypeInfo typedef_type_info =
8833 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8843 bitfield_bit_offset,
8848 case clang::Type::Enum:
8853 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8854 bitfield_bit_offset, bitfield_bit_size);
8862 uint32_t item_count = 1;
8902 item_count = byte_size;
8907 item_count = byte_size / 2;
8912 item_count = byte_size / 4;
8918 bitfield_bit_size, bitfield_bit_offset,
8937 clang::QualType qual_type =
8940 llvm::SmallVector<char, 1024> buf;
8941 llvm::raw_svector_ostream llvm_ostrm(buf);
8943 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8944 switch (type_class) {
8945 case clang::Type::ObjCObject:
8946 case clang::Type::ObjCInterface: {
8949 auto *objc_class_type =
8950 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8951 assert(objc_class_type);
8952 if (!objc_class_type)
8954 clang::ObjCInterfaceDecl *class_interface_decl =
8955 objc_class_type->getInterface();
8956 if (!class_interface_decl)
8959 class_interface_decl->dump(llvm_ostrm);
8961 class_interface_decl->print(llvm_ostrm,
8966 case clang::Type::Typedef: {
8967 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8970 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
8972 typedef_decl->dump(llvm_ostrm);
8975 if (!clang_typedef_name.empty()) {
8982 case clang::Type::Record: {
8985 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
8986 const clang::RecordDecl *record_decl = record_type->getDecl();
8988 record_decl->dump(llvm_ostrm);
8990 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
8996 if (
auto *tag_type =
8997 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
8998 if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
9000 tag_decl->dump(llvm_ostrm);
9002 tag_decl->print(llvm_ostrm, 0);
9008 std::string clang_type_name(qual_type.getAsString());
9009 if (!clang_type_name.empty())
9016 if (buf.size() > 0) {
9017 s.
Write(buf.data(), buf.size());
9021 std::optional<ClangASTMetadata> metadata =
9024 s <<
"type-metadata = ";
9029 if (
const clang::TagDecl *tag = qual_type->getAsTagDecl())
9033 s <<
"decl-metadata = ";
9042 clang::QualType qual_type(
9045 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
9046 switch (type_class) {
9047 case clang::Type::Record: {
9048 const clang::CXXRecordDecl *cxx_record_decl =
9049 qual_type->getAsCXXRecordDecl();
9050 if (cxx_record_decl)
9051 printf(
"class %s", cxx_record_decl->getName().str().c_str());
9054 case clang::Type::Enum: {
9055 clang::EnumDecl *enum_decl =
9056 llvm::cast<clang::EnumType>(qual_type)->getDecl();
9058 printf(
"enum %s", enum_decl->getName().str().c_str());
9062 case clang::Type::ObjCObject:
9063 case clang::Type::ObjCInterface: {
9064 const clang::ObjCObjectType *objc_class_type =
9065 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
9066 if (objc_class_type) {
9067 clang::ObjCInterfaceDecl *class_interface_decl =
9068 objc_class_type->getInterface();
9072 if (class_interface_decl)
9073 printf(
"@class %s", class_interface_decl->getName().str().c_str());
9077 case clang::Type::Typedef:
9078 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
9085 case clang::Type::Auto:
9088 llvm::cast<clang::AutoType>(qual_type)
9090 .getAsOpaquePtr()));
9092 case clang::Type::Paren:
9096 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
9099 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
9107 const char *parent_name,
int tag_decl_kind,
9109 if (template_param_infos.
IsValid()) {
9110 std::string template_basename(parent_name);
9112 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
9113 template_basename.erase(i);
9116 template_basename.c_str(), tag_decl_kind,
9117 template_param_infos);
9132 clang::ObjCInterfaceDecl *decl) {
9156 std::make_unique<npdb::PdbAstBuilderClang>(*
this);
9161 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9162 uint64_t &alignment,
9163 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9164 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9166 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9179 field_offsets, base_offsets, vbase_offsets);
9186 clang::NamedDecl *nd =
9187 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9197 if (!label_or_err) {
9198 llvm::consumeError(label_or_err.takeError());
9202 llvm::StringRef mangled = label_or_err->lookup_name;
9210 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9211 static_cast<clang::Decl *
>(opaque_decl));
9213 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9217 if (!mc || !mc->shouldMangleCXXName(nd))
9222 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9227 llvm::SmallVector<char, 1024> buf;
9228 llvm::raw_svector_ostream llvm_ostrm(buf);
9229 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9231 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9234 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9236 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9240 mc->mangleName(nd, llvm_ostrm);
9256 if (clang::FunctionDecl *func_decl =
9257 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9258 return GetType(func_decl->getReturnType());
9259 if (clang::ObjCMethodDecl *objc_method =
9260 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9261 return GetType(objc_method->getReturnType());
9267 if (clang::FunctionDecl *func_decl =
9268 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9269 return func_decl->param_size();
9270 if (clang::ObjCMethodDecl *objc_method =
9271 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9272 return objc_method->param_size();
9278 clang::DeclContext
const *decl_ctx) {
9279 switch (clang_kind) {
9280 case Decl::TranslationUnit:
9282 case Decl::Namespace:
9293 if (decl_ctx->isFunctionOrMethod())
9295 if (decl_ctx->isRecord())
9305 std::vector<lldb_private::CompilerContext> &context) {
9306 if (decl_ctx ==
nullptr)
9309 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9310 if (clang_kind == Decl::TranslationUnit)
9315 context.push_back({compiler_kind, decl_ctx_name});
9318std::vector<lldb_private::CompilerContext>
9320 std::vector<lldb_private::CompilerContext> context;
9323 clang::Decl *decl = (clang::Decl *)opaque_decl;
9325 clang::DeclContext *decl_ctx = decl->getDeclContext();
9328 auto compiler_kind =
9330 context.push_back({compiler_kind, decl_name});
9337 if (clang::FunctionDecl *func_decl =
9338 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9339 if (idx < func_decl->param_size()) {
9340 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9342 return GetType(var_decl->getOriginalType());
9344 }
else if (clang::ObjCMethodDecl *objc_method =
9345 llvm::dyn_cast<clang::ObjCMethodDecl>(
9346 (clang::Decl *)opaque_decl)) {
9347 if (idx < objc_method->param_size())
9348 return GetType(objc_method->parameters()[idx]->getOriginalType());
9354 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9355 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9358 clang::Expr *init_expr = var_decl->getInit();
9361 std::optional<llvm::APSInt> value =
9371 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9372 std::vector<CompilerDecl> found_decls;
9374 if (opaque_decl_ctx && symbol_file) {
9375 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9376 std::set<DeclContext *> searched;
9377 std::multimap<DeclContext *, DeclContext *> search_queue;
9379 for (clang::DeclContext *decl_context = root_decl_ctx;
9380 decl_context !=
nullptr && found_decls.empty();
9381 decl_context = decl_context->getParent()) {
9382 search_queue.insert(std::make_pair(decl_context, decl_context));
9384 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9386 if (!searched.insert(it->second).second)
9391 for (clang::Decl *child : it->second->decls()) {
9392 if (clang::UsingDirectiveDecl *ud =
9393 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9394 if (ignore_using_decls)
9396 clang::DeclContext *from = ud->getCommonAncestor();
9397 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9398 search_queue.insert(
9399 std::make_pair(from, ud->getNominatedNamespace()));
9400 }
else if (clang::UsingDecl *ud =
9401 llvm::dyn_cast<clang::UsingDecl>(child)) {
9402 if (ignore_using_decls)
9404 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9405 clang::Decl *target = usd->getTargetDecl();
9406 if (clang::NamedDecl *nd =
9407 llvm::dyn_cast<clang::NamedDecl>(target)) {
9408 IdentifierInfo *ii = nd->getIdentifier();
9409 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9413 }
else if (clang::NamedDecl *nd =
9414 llvm::dyn_cast<clang::NamedDecl>(child)) {
9415 IdentifierInfo *ii = nd->getIdentifier();
9416 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9467 clang::DeclContext *child_decl_ctx,
9471 if (frame_decl_ctx && symbol_file) {
9472 std::set<DeclContext *> searched;
9473 std::multimap<DeclContext *, DeclContext *> search_queue;
9476 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9480 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9481 decl_ctx = decl_ctx->getParent()) {
9482 if (!decl_ctx->isLookupContext())
9484 if (decl_ctx == parent_decl_ctx)
9487 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9488 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9490 if (searched.find(it->second) != searched.end())
9498 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9501 searched.insert(it->second);
9505 for (clang::Decl *child : it->second->decls()) {
9506 if (clang::UsingDirectiveDecl *ud =
9507 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9508 clang::DeclContext *ns = ud->getNominatedNamespace();
9509 if (ns == parent_decl_ctx)
9512 clang::DeclContext *from = ud->getCommonAncestor();
9513 if (searched.find(ns) == searched.end())
9514 search_queue.insert(std::make_pair(from, ns));
9515 }
else if (child_name) {
9516 if (clang::UsingDecl *ud =
9517 llvm::dyn_cast<clang::UsingDecl>(child)) {
9518 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9519 clang::Decl *target = usd->getTargetDecl();
9520 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9524 IdentifierInfo *ii = nd->getIdentifier();
9525 if (ii ==
nullptr ||
9526 ii->getName() != child_name->
AsCString(
nullptr))
9549 if (opaque_decl_ctx) {
9550 clang::NamedDecl *named_decl =
9551 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9554 llvm::raw_string_ostream stream{name};
9556 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9557 named_decl->getNameForDiagnostic(stream, policy,
false);
9566 if (opaque_decl_ctx) {
9567 clang::NamedDecl *named_decl =
9568 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9576 if (!opaque_decl_ctx)
9579 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9580 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9582 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9584 }
else if (clang::FunctionDecl *fun_decl =
9585 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9586 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9587 return metadata->HasObjectPtr();
9593std::vector<lldb_private::CompilerContext>
9595 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9596 std::vector<lldb_private::CompilerContext> context;
9602 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9603 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9604 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9608 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9609 if (DC->isInlineNamespace())
9612 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9613 return NS->isAnonymousNamespace();
9620 if (decl_ctx == other)
9622 }
while (is_transparent_lookup_allowed(other) &&
9623 (other = other->getParent()));
9630 if (!opaque_decl_ctx)
9633 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9634 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9636 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9638 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9639 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9640 return metadata->GetObjectPtrLanguage();
9660 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9668 return llvm::dyn_cast<clang::CXXMethodDecl>(
9673clang::FunctionDecl *
9676 return llvm::dyn_cast<clang::FunctionDecl>(
9681clang::NamespaceDecl *
9684 return llvm::dyn_cast<clang::NamespaceDecl>(
9689std::optional<ClangASTMetadata>
9691 const Decl *
object) {
9699 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9722 lldbassert(started &&
"Unable to start a class type definition.");
9727 ts->SetDeclIsForcefullyCompleted(td);
9741 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9742 std::unique_ptr<ClangASTSource> ast_source)
9744 m_scratch_ast_source_up(std::move(ast_source)) {
9746 m_scratch_ast_source_up->InstallASTContext(*
this);
9747 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9748 m_scratch_ast_source_up->CreateProxy();
9749 SetExternalSource(proxy_ast_source);
9753 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9761 llvm::Triple triple)
9768 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9780 std::optional<IsolatedASTKind> ast_kind,
9781 bool create_on_demand) {
9784 if (
auto err = type_system_or_err.takeError()) {
9786 "Couldn't get scratch TypeSystemClang: {0}");
9789 auto ts_sp = *type_system_or_err;
9791 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9796 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9798 return std::static_pointer_cast<TypeSystemClang>(
9803static llvm::StringRef
9807 return "C++ modules";
9809 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9813 llvm::StringRef filter,
bool show_color) {
9815 output <<
"State of scratch Clang type system:\n";
9819 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9820 std::vector<KeyAndTS> sorted_typesystems;
9822 sorted_typesystems.emplace_back(a.first, a.second.get());
9823 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9826 for (
const auto &a : sorted_typesystems) {
9829 output <<
"State of scratch Clang type subsystem "
9831 a.second->Dump(output, filter, show_color);
9836 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9844 desired_type, options, ctx_obj);
9849 const ValueList &arg_value_list,
const char *name) {
9854 Process *process = target_sp->GetProcessSP().get();
9859 arg_value_list, name);
9862std::unique_ptr<UtilityFunction>
9869 return std::make_unique<ClangUtilityFunction>(
9870 *target_sp.get(), std::move(text), std::move(name),
9871 target_sp->GetDebugUtilityExpression());
9885 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9889 return std::make_unique<ClangASTSource>(
9894static llvm::StringRef
9898 return "scratch ASTContext for C++ module types";
9900 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9907 return *found_ast->second;
9910 std::shared_ptr<TypeSystemClang> new_ast_sp =
9920 const clang::RecordType *record_type =
9921 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9923 const clang::RecordDecl *record_decl =
9924 record_type->getDecl()->getDefinitionOrSelf();
9925 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9926 return metadata->IsForcefullyCompleted();
9935 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9939 metadata->SetIsForcefullyCompleted();
9947 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.
A command line argument class.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
const char * GetArgumentAtIndex(size_t idx) const
Gets the null-terminated C string argument pointer for the argument at index idx.
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
CommandObject * GetCommandObjectForCommand(llvm::StringRef &command_line)
void AppendError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
Stream & GetOutputStream()
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
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.
A class to manage flag bits.
static void ReportInternalError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report an error that may be a bug in LLDB.
CommandInterpreter & GetCommandInterpreter()
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.
llvm::StringRef GetFileNameExtension() const
Extract the extension of the file.
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 LanguageIsRust(lldb::LanguageType language)
static bool LanguageIsC(lldb::LanguageType language)
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
static lldb::LanguageType GetPrimaryLanguage(lldb::LanguageType language)
static bool LanguageIsPascal(lldb::LanguageType language)
static bool LanguageIsObjC(lldb::LanguageType language)
static bool IsMangledName(llvm::StringRef name)
bool SetClangModulesCachePath(const FileSpec &path)
static ModuleListProperties & GetGlobalModuleListProperties()
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)
llvm::Expected< lldb::addr_t > ReadPointerFromMemory(lldb::addr_t vm_addr)
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, ptrauth types, and pointer 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
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
CompilerType AddAddressSpaceModifier(lldb::opaque_compiler_type_t type, uint32_t address_space) 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)
llvm::Expected< ChildTypeInfo > GetChildAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, ValueObject *valobj) override
Get the child at idx, such as a field, a base class or a pointee.
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
static void DebuggerInitialize(Debugger &debugger)
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
std::optional< uint32_t > GetTargetAddressSpace(lldb::opaque_compiler_type_t type) const override
Returns the target address space of type, or std::nullopt if it lives in the default address space.
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)
std::optional< uint64_t > GetByteStride(lldb::opaque_compiler_type_t type) override
Return the distance in bytes between consecutive elements of this type when stored in contiguous stor...
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)
llvm::Expected< uint64_t > GetByteSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope)
ConstString DeclContextGetName(void *opaque_decl_ctx) override
size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack) override
ConstString DeclGetName(void *opaque_decl) override
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
@ eReturnStatusSuccessFinishResult
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
A child of a type, as returned by CompilerType::GetChildAtIndex.
uint32_t bitfield_bit_size
uint32_t bitfield_bit_offset
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.