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);
1419 decl->setAccess(AS_public);
1422 decl_ctx->addDecl(decl);
1424 return GetType(ast.getCanonicalTagType(decl));
1431QualType GetValueParamType(
const clang::TemplateArgument &argument) {
1432 switch (argument.getKind()) {
1433 case TemplateArgument::Integral:
1434 return argument.getIntegralType();
1435 case TemplateArgument::StructuralValue:
1436 return argument.getStructuralValueType();
1446 llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
1447 const bool parameter_pack =
false;
1448 const bool is_typename =
false;
1449 const unsigned depth = 0;
1450 const size_t num_template_params = template_param_infos.
Size();
1451 DeclContext *
const decl_context =
1452 ast.getTranslationUnitDecl();
1454 auto const &args = template_param_infos.
GetArgs();
1455 auto const &names = template_param_infos.
GetNames();
1456 for (
size_t i = 0; i < num_template_params; ++i) {
1457 const char *name = names[i];
1459 IdentifierInfo *identifier_info =
nullptr;
1460 if (name && name[0])
1461 identifier_info = &ast.Idents.get(name);
1462 TemplateArgument
const &targ = args[i];
1463 QualType template_param_type = GetValueParamType(targ);
1464 if (!template_param_type.isNull()) {
1465 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1466 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1467 identifier_info, template_param_type, parameter_pack,
1468 ast.getTrivialTypeSourceInfo(template_param_type)));
1470 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1471 ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
1472 identifier_info, is_typename, parameter_pack));
1477 IdentifierInfo *identifier_info =
nullptr;
1479 identifier_info = &ast.Idents.get(template_param_infos.
GetPackName());
1480 const bool parameter_pack_true =
true;
1482 QualType template_param_type =
1486 if (!template_param_type.isNull()) {
1487 template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
1488 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1489 num_template_params, identifier_info, template_param_type,
1490 parameter_pack_true,
1491 ast.getTrivialTypeSourceInfo(template_param_type)));
1493 template_param_decls.push_back(TemplateTypeParmDecl::Create(
1494 ast, decl_context, SourceLocation(), SourceLocation(), depth,
1495 num_template_params, identifier_info, is_typename,
1496 parameter_pack_true));
1499 clang::Expr *
const requires_clause =
nullptr;
1500 TemplateParameterList *template_param_list = TemplateParameterList::Create(
1501 ast, SourceLocation(), SourceLocation(), template_param_decls,
1502 SourceLocation(), requires_clause);
1503 return template_param_list;
1508 clang::FunctionDecl *func_decl,
1513 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1515 ast, template_param_infos, template_param_decls);
1516 FunctionTemplateDecl *func_tmpl_decl =
1517 FunctionTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1518 func_tmpl_decl->setDeclContext(decl_ctx);
1519 func_tmpl_decl->setLocation(func_decl->getLocation());
1520 func_tmpl_decl->setDeclName(func_decl->getDeclName());
1521 func_tmpl_decl->setTemplateParameters(template_param_list);
1522 func_tmpl_decl->init(func_decl);
1525 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1526 i < template_param_decl_count; ++i) {
1528 template_param_decls[i]->setDeclContext(func_decl);
1530 func_tmpl_decl->setAccess(clang::AccessSpecifier::AS_public);
1532 return func_tmpl_decl;
1536 FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
1538 TemplateArgumentList *template_args_ptr = TemplateArgumentList::CreateCopy(
1539 func_decl->getASTContext(), infos.
GetArgs());
1541 func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
1542 template_args_ptr, {});
1549 const TemplateArgument &value) {
1550 if (llvm::isa<TemplateTypeParmDecl>(param)) {
1552 if (value.getKind() != TemplateArgument::Type)
1554 }
else if (
auto *type_param =
1555 llvm::dyn_cast<NonTypeTemplateParmDecl>(param)) {
1557 QualType value_param_type = GetValueParamType(value);
1558 if (value_param_type.isNull())
1562 if (type_param->getType() != value_param_type)
1570 "Don't know how to compare template parameter to passed"
1571 " value. Decl kind of parameter is: {0}",
1572 param->getDeclKindName());
1573 lldbassert(
false &&
"Can't compare this TemplateParmDecl subclass");
1588 ClassTemplateDecl *class_template_decl,
1591 TemplateParameterList ¶ms = *class_template_decl->getTemplateParameters();
1597 std::optional<NamedDecl *> pack_parameter;
1599 size_t non_pack_params = params.size();
1600 for (
size_t i = 0; i < params.size(); ++i) {
1601 NamedDecl *param = params.getParam(i);
1602 if (param->isParameterPack()) {
1603 pack_parameter = param;
1604 non_pack_params = i;
1612 if (non_pack_params != instantiation_values.
Size())
1630 for (
const auto pair :
1631 llvm::zip_first(instantiation_values.
GetArgs(), params)) {
1632 const TemplateArgument &passed_arg = std::get<0>(pair);
1633 NamedDecl *found_param = std::get<1>(pair);
1638 return class_template_decl;
1643 llvm::StringRef class_name,
int kind,
1647 ClassTemplateDecl *class_template_decl =
nullptr;
1648 if (decl_ctx ==
nullptr)
1649 decl_ctx = ast.getTranslationUnitDecl();
1651 IdentifierInfo &identifier_info = ast.Idents.get(class_name);
1652 DeclarationName decl_name(&identifier_info);
1655 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1656 for (NamedDecl *decl : result) {
1657 class_template_decl = dyn_cast<clang::ClassTemplateDecl>(decl);
1658 if (!class_template_decl)
1667 template_param_infos))
1669 return class_template_decl;
1672 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1675 ast, template_param_infos, template_param_decls);
1677 CXXRecordDecl *template_cxx_decl =
1678 CXXRecordDecl::CreateDeserialized(ast, GlobalDeclID());
1679 template_cxx_decl->setTagKind(
static_cast<TagDecl::TagKind
>(kind));
1681 template_cxx_decl->setDeclContext(decl_ctx);
1682 template_cxx_decl->setDeclName(decl_name);
1685 for (
size_t i = 0, template_param_decl_count = template_param_decls.size();
1686 i < template_param_decl_count; ++i) {
1687 template_param_decls[i]->setDeclContext(template_cxx_decl);
1695 class_template_decl =
1696 ClassTemplateDecl::CreateDeserialized(ast, GlobalDeclID());
1698 class_template_decl->setDeclContext(decl_ctx);
1699 class_template_decl->setDeclName(decl_name);
1700 class_template_decl->setTemplateParameters(template_param_list);
1701 class_template_decl->init(template_cxx_decl);
1702 template_cxx_decl->setDescribedClassTemplate(class_template_decl);
1705 class_template_decl->setAccess(AS_public);
1707 decl_ctx->addDecl(class_template_decl);
1709 VerifyDecl(class_template_decl);
1711 return class_template_decl;
1714TemplateTemplateParmDecl *
1718 auto *decl_ctx = ast.getTranslationUnitDecl();
1720 IdentifierInfo &identifier_info = ast.Idents.get(template_name);
1721 llvm::SmallVector<NamedDecl *, 8> template_param_decls;
1725 std::make_unique<TemplateParameterInfos>());
1727 ast, template_param_infos, template_param_decls);
1733 return TemplateTemplateParmDecl::Create(
1734 ast, decl_ctx, SourceLocation(),
1736 false, &identifier_info,
1737 TemplateNameKind::TNK_Type_template,
true,
1738 template_param_list);
1741ClassTemplateSpecializationDecl *
1744 ClassTemplateDecl *class_template_decl,
int kind,
1747 llvm::SmallVector<clang::TemplateArgument, 2> args(
1748 template_param_infos.
Size() +
1751 auto const &orig_args = template_param_infos.
GetArgs();
1752 std::copy(orig_args.begin(), orig_args.end(), args.begin());
1754 args[args.size() - 1] = TemplateArgument::CreatePackCopy(
1757 ClassTemplateSpecializationDecl *class_template_specialization_decl =
1758 ClassTemplateSpecializationDecl::CreateDeserialized(ast, GlobalDeclID());
1759 class_template_specialization_decl->setTagKind(
1760 static_cast<TagDecl::TagKind
>(kind));
1761 class_template_specialization_decl->setDeclContext(decl_ctx);
1762 class_template_specialization_decl->setInstantiationOf(class_template_decl);
1763 class_template_specialization_decl->setTemplateArgs(
1764 TemplateArgumentList::CreateCopy(ast, args));
1765 llvm::FoldingSetInsertToken insert_token;
1766 if (class_template_decl->findSpecialization(args, insert_token))
1768 class_template_decl->AddSpecialization(class_template_specialization_decl,
1770 class_template_specialization_decl->setDeclName(
1771 class_template_decl->getDeclName());
1776 class_template_specialization_decl->setStrictPackMatch(
false);
1779 decl_ctx->addDecl(class_template_specialization_decl);
1781 class_template_specialization_decl->setSpecializationKind(
1782 TSK_ExplicitSpecialization);
1784 return class_template_specialization_decl;
1788 ClassTemplateSpecializationDecl *class_template_specialization_decl) {
1789 if (class_template_specialization_decl) {
1791 return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
1797 clang::OverloadedOperatorKind op_kind,
1798 bool unary,
bool binary,
1799 uint32_t num_params) {
1801 if (op_kind == OO_Call)
1807 if (num_params == 1)
1809 if (num_params == 2)
1816 bool is_method, clang::OverloadedOperatorKind op_kind,
1817 uint32_t num_params) {
1825 case OO_Array_Delete:
1829#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1831 return check_op_param(is_method, op_kind, Unary, Binary, num_params);
1833#include "clang/Basic/OperatorKinds.def"
1841 uint32_t &bitfield_bit_size) {
1843 if (field ==
nullptr)
1846 if (field->isBitField()) {
1847 Expr *bit_width_expr = field->getBitWidth();
1848 if (bit_width_expr) {
1849 if (std::optional<llvm::APSInt> bit_width_apsint =
1850 bit_width_expr->getIntegerConstantExpr(ast)) {
1851 bitfield_bit_size = bit_width_apsint->getLimitedValue(
UINT32_MAX);
1860 if (record_decl ==
nullptr)
1863 if (!record_decl->field_empty())
1867 const CXXRecordDecl *cxx_record_decl = dyn_cast<CXXRecordDecl>(record_decl);
1868 if (cxx_record_decl) {
1869 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1870 for (base_class = cxx_record_decl->bases_begin(),
1871 base_class_end = cxx_record_decl->bases_end();
1872 base_class != base_class_end; ++base_class) {
1873 assert(record_decl != base_class->getType()->getAsCXXRecordDecl() &&
1874 "Base can't inherit from itself.");
1886 if (std::optional<ClangASTMetadata> meta_data =
GetMetadata(record_decl);
1887 meta_data && meta_data->IsForcefullyCompleted())
1893#pragma mark Objective-C Classes
1896 llvm::StringRef name, clang::DeclContext *decl_ctx,
1898 std::optional<ClangASTMetadata> metadata) {
1900 assert(!name.empty());
1902 decl_ctx = ast.getTranslationUnitDecl();
1904 ObjCInterfaceDecl *decl =
1905 ObjCInterfaceDecl::CreateDeserialized(ast, GlobalDeclID());
1906 decl->setDeclContext(decl_ctx);
1907 decl->setDeclName(&ast.Idents.get(name));
1908 decl->setImplicit(isInternal);
1914 return GetType(ast.getObjCInterfaceType(decl));
1923 bool omit_empty_base_classes) {
1924 uint32_t num_bases = 0;
1925 if (cxx_record_decl) {
1926 if (omit_empty_base_classes) {
1927 CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
1928 for (base_class = cxx_record_decl->bases_begin(),
1929 base_class_end = cxx_record_decl->bases_end();
1930 base_class != base_class_end; ++base_class) {
1937 num_bases = cxx_record_decl->getNumBases();
1942#pragma mark Namespace Declarations
1945 const char *name, clang::DeclContext *decl_ctx,
1947 NamespaceDecl *namespace_decl =
nullptr;
1949 TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
1951 decl_ctx = translation_unit_decl;
1954 IdentifierInfo &identifier_info = ast.Idents.get(name);
1955 DeclarationName decl_name(&identifier_info);
1956 clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name);
1957 for (NamedDecl *decl : result) {
1958 namespace_decl = dyn_cast<clang::NamespaceDecl>(decl);
1960 return namespace_decl;
1963 namespace_decl = NamespaceDecl::Create(ast, decl_ctx, is_inline,
1964 SourceLocation(), SourceLocation(),
1965 &identifier_info,
nullptr,
false);
1967 decl_ctx->addDecl(namespace_decl);
1969 if (decl_ctx == translation_unit_decl) {
1970 namespace_decl = translation_unit_decl->getAnonymousNamespace();
1972 return namespace_decl;
1975 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1976 SourceLocation(),
nullptr,
nullptr,
false);
1977 translation_unit_decl->setAnonymousNamespace(namespace_decl);
1978 translation_unit_decl->addDecl(namespace_decl);
1979 assert(namespace_decl == translation_unit_decl->getAnonymousNamespace());
1981 NamespaceDecl *parent_namespace_decl = cast<NamespaceDecl>(decl_ctx);
1982 if (parent_namespace_decl) {
1983 namespace_decl = parent_namespace_decl->getAnonymousNamespace();
1985 return namespace_decl;
1987 NamespaceDecl::Create(ast, decl_ctx,
false, SourceLocation(),
1988 SourceLocation(),
nullptr,
nullptr,
false);
1989 parent_namespace_decl->setAnonymousNamespace(namespace_decl);
1990 parent_namespace_decl->addDecl(namespace_decl);
1991 assert(namespace_decl ==
1992 parent_namespace_decl->getAnonymousNamespace());
1994 assert(
false &&
"GetUniqueNamespaceDeclaration called with no name and "
1995 "no namespace as decl_ctx");
2003 VerifyDecl(namespace_decl);
2004 return namespace_decl;
2011 clang::BlockDecl *decl =
2012 clang::BlockDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
2013 decl->setDeclContext(ctx);
2022 clang::DeclContext *right,
2023 clang::DeclContext *root) {
2024 if (root ==
nullptr)
2027 std::set<clang::DeclContext *> path_left;
2028 for (clang::DeclContext *d = left; d !=
nullptr; d = d->getParent())
2029 path_left.insert(d);
2031 for (clang::DeclContext *d = right; d !=
nullptr; d = d->getParent())
2032 if (path_left.find(d) != path_left.end())
2040 clang::NamespaceDecl *ns_decl) {
2041 if (decl_ctx && ns_decl) {
2042 auto *translation_unit =
getASTContext().getTranslationUnitDecl();
2043 clang::UsingDirectiveDecl *using_decl = clang::UsingDirectiveDecl::Create(
2045 clang::SourceLocation(), clang::NestedNameSpecifierLoc(),
2046 clang::SourceLocation(), ns_decl,
2049 decl_ctx->addDecl(using_decl);
2059 clang::NamedDecl *target) {
2060 if (current_decl_ctx && target) {
2061 clang::UsingDecl *using_decl = clang::UsingDecl::Create(
2063 clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(),
false);
2065 clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
2067 target->getDeclName(), using_decl, target);
2069 using_decl->addShadowDecl(shadow_decl);
2070 current_decl_ctx->addDecl(using_decl);
2078 const char *name, clang::QualType type) {
2080 clang::VarDecl *var_decl =
2081 clang::VarDecl::CreateDeserialized(
getASTContext(), GlobalDeclID());
2082 var_decl->setDeclContext(decl_context);
2083 if (name && name[0])
2084 var_decl->setDeclName(&
getASTContext().Idents.getOwn(name));
2085 var_decl->setType(type);
2087 var_decl->setAccess(clang::AS_public);
2088 decl_context->addDecl(var_decl);
2097 switch (basic_type) {
2099 return ast->VoidTy.getAsOpaquePtr();
2101 return ast->CharTy.getAsOpaquePtr();
2103 return ast->SignedCharTy.getAsOpaquePtr();
2105 return ast->UnsignedCharTy.getAsOpaquePtr();
2107 return ast->getWCharType().getAsOpaquePtr();
2109 return ast->getSignedWCharType().getAsOpaquePtr();
2111 return ast->getUnsignedWCharType().getAsOpaquePtr();
2113 return ast->Char8Ty.getAsOpaquePtr();
2115 return ast->Char16Ty.getAsOpaquePtr();
2117 return ast->Char32Ty.getAsOpaquePtr();
2119 return ast->ShortTy.getAsOpaquePtr();
2121 return ast->UnsignedShortTy.getAsOpaquePtr();
2123 return ast->IntTy.getAsOpaquePtr();
2125 return ast->UnsignedIntTy.getAsOpaquePtr();
2127 return ast->LongTy.getAsOpaquePtr();
2129 return ast->UnsignedLongTy.getAsOpaquePtr();
2131 return ast->LongLongTy.getAsOpaquePtr();
2133 return ast->UnsignedLongLongTy.getAsOpaquePtr();
2135 return ast->Int128Ty.getAsOpaquePtr();
2137 return ast->UnsignedInt128Ty.getAsOpaquePtr();
2139 return ast->BoolTy.getAsOpaquePtr();
2141 return ast->HalfTy.getAsOpaquePtr();
2143 return ast->FloatTy.getAsOpaquePtr();
2145 return ast->DoubleTy.getAsOpaquePtr();
2147 return ast->LongDoubleTy.getAsOpaquePtr();
2149 return ast->Float128Ty.getAsOpaquePtr();
2151 return ast->getComplexType(ast->FloatTy).getAsOpaquePtr();
2153 return ast->getComplexType(ast->DoubleTy).getAsOpaquePtr();
2155 return ast->getComplexType(ast->LongDoubleTy).getAsOpaquePtr();
2157 return ast->getObjCIdType().getAsOpaquePtr();
2159 return ast->getObjCClassType().getAsOpaquePtr();
2161 return ast->getObjCSelType().getAsOpaquePtr();
2163 return ast->NullPtrTy.getAsOpaquePtr();
2169#pragma mark Function Types
2171clang::DeclarationName
2174 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
2175 if (!
IsOperator(name, op_kind) || op_kind == clang::NUM_OVERLOADED_OPERATORS)
2184 const clang::FunctionProtoType *function_type =
2185 llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr());
2186 if (function_type ==
nullptr)
2187 return clang::DeclarationName();
2189 const bool is_method =
false;
2190 const unsigned int num_params = function_type->getNumParams();
2192 is_method, op_kind, num_params))
2193 return clang::DeclarationName();
2195 return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
2199 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
2200 printing_policy.SuppressTagKeyword =
true;
2203 printing_policy.SuppressInlineNamespace =
2204 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::None);
2205 printing_policy.SuppressUnwrittenScope =
false;
2217 printing_policy.SuppressDefaultTemplateArgs =
false;
2218 return printing_policy;
2225 llvm::raw_string_ostream os(result);
2226 named_decl->getNameForDiagnostic(os, printing_policy, qualified);
2232 llvm::StringRef name,
const CompilerType &function_clang_type,
2233 clang::StorageClass storage,
bool is_inline, llvm::StringRef asm_label) {
2234 FunctionDecl *func_decl =
nullptr;
2237 decl_ctx = ast.getTranslationUnitDecl();
2239 const bool hasWrittenPrototype =
true;
2240 const bool isConstexprSpecified =
false;
2242 clang::DeclarationName declarationName =
2244 func_decl = FunctionDecl::CreateDeserialized(ast, GlobalDeclID());
2245 func_decl->setDeclContext(decl_ctx);
2246 func_decl->setDeclName(declarationName);
2248 func_decl->setStorageClass(storage);
2249 func_decl->setInlineSpecified(is_inline);
2250 func_decl->setHasWrittenPrototype(hasWrittenPrototype);
2251 func_decl->setConstexprKind(isConstexprSpecified
2252 ? ConstexprSpecKind::Constexpr
2253 : ConstexprSpecKind::Unspecified);
2265 if (!asm_label.empty())
2266 func_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(ast, asm_label));
2269 decl_ctx->addDecl(func_decl);
2271 VerifyDecl(func_decl);
2277 const CompilerType &result_type, llvm::ArrayRef<CompilerType> args,
2278 bool is_variadic,
unsigned type_quals, clang::CallingConv cc,
2279 clang::RefQualifierKind ref_qual) {
2283 std::vector<QualType> qual_type_args;
2285 for (
const auto &arg : args) {
2300 FunctionProtoType::ExtProtoInfo proto_info;
2301 proto_info.ExtInfo = cc;
2302 proto_info.Variadic = is_variadic;
2303 proto_info.ExceptionSpec = EST_None;
2304 proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
2305 proto_info.RefQualifier = ref_qual;
2313 const char *name,
const CompilerType ¶m_type,
int storage,
2316 auto *decl = ParmVarDecl::CreateDeserialized(ast, GlobalDeclID());
2317 decl->setDeclContext(decl_ctx);
2318 if (name && name[0])
2319 decl->setDeclName(&ast.Idents.get(name));
2321 decl->setStorageClass(
static_cast<clang::StorageClass
>(storage));
2324 decl_ctx->addDecl(decl);
2331 QualType block_type =
m_ast_up->getBlockPointerType(
2337#pragma mark Array Types
2341 std::optional<size_t> element_count,
2354 clang::ArraySizeModifier::Normal, 0));
2360 llvm::APInt ap_element_count(64, *element_count);
2362 ap_element_count,
nullptr,
2363 clang::ArraySizeModifier::Normal, 0));
2367 llvm::StringRef type_name,
2368 const std::initializer_list<std::pair<const char *, CompilerType>>
2375 lldbassert(0 &&
"Trying to create a type for an existing name");
2380 llvm::to_underlying(clang::TagTypeKind::Struct),
2383 for (
const auto &field : type_fields)
2392 llvm::StringRef type_name,
2393 const std::initializer_list<std::pair<const char *, CompilerType>>
2405#pragma mark Enumeration Types
2408 llvm::StringRef name, clang::DeclContext *decl_ctx,
2410 const CompilerType &integer_clang_type,
bool is_scoped,
2411 std::optional<clang::EnumExtensibilityAttr::Kind> enum_kind) {
2418 EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, GlobalDeclID());
2419 enum_decl->setDeclContext(decl_ctx);
2421 enum_decl->setDeclName(&ast.Idents.get(name));
2422 enum_decl->setScoped(is_scoped);
2423 enum_decl->setScopedUsingClassTag(is_scoped);
2424 enum_decl->setFixed(
false);
2427 decl_ctx->addDecl(enum_decl);
2431 clang::EnumExtensibilityAttr::CreateImplicit(ast, *enum_kind));
2436 enum_decl->setAccess(AS_public);
2438 return GetType(ast.getCanonicalTagType(enum_decl));
2449 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
2450 return GetType(ast.SignedCharTy);
2452 if (bit_size == ast.getTypeSize(ast.ShortTy))
2455 if (bit_size == ast.getTypeSize(ast.IntTy))
2458 if (bit_size == ast.getTypeSize(ast.LongTy))
2461 if (bit_size == ast.getTypeSize(ast.LongLongTy))
2462 return GetType(ast.LongLongTy);
2464 if (bit_size == ast.getTypeSize(ast.Int128Ty))
2467 if (bit_size == ast.getTypeSize(ast.UnsignedCharTy))
2468 return GetType(ast.UnsignedCharTy);
2470 if (bit_size == ast.getTypeSize(ast.UnsignedShortTy))
2471 return GetType(ast.UnsignedShortTy);
2473 if (bit_size == ast.getTypeSize(ast.UnsignedIntTy))
2474 return GetType(ast.UnsignedIntTy);
2476 if (bit_size == ast.getTypeSize(ast.UnsignedLongTy))
2477 return GetType(ast.UnsignedLongTy);
2479 if (bit_size == ast.getTypeSize(ast.UnsignedLongLongTy))
2480 return GetType(ast.UnsignedLongLongTy);
2482 if (bit_size == ast.getTypeSize(ast.UnsignedInt128Ty))
2483 return GetType(ast.UnsignedInt128Ty);
2518 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl_ctx);
2520 printf(
"%20s: %s\n", decl_ctx->getDeclKindName(),
2521 named_decl->getDeclName().getAsString().c_str());
2523 printf(
"%20s\n", decl_ctx->getDeclKindName());
2529 if (decl ==
nullptr)
2533 clang::RecordDecl *record_decl = llvm::dyn_cast<clang::RecordDecl>(decl);
2535 bool is_injected_class_name =
2536 llvm::isa<clang::CXXRecordDecl>(record_decl) &&
2537 llvm::cast<CXXRecordDecl>(record_decl)->isInjectedClassName();
2538 printf(
"%20s: %s%s\n", decl->getDeclKindName(),
2539 record_decl->getDeclName().getAsString().c_str(),
2540 is_injected_class_name ?
" (injected class name)" :
"");
2543 clang::NamedDecl *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl);
2545 printf(
"%20s: %s\n", decl->getDeclKindName(),
2546 named_decl->getDeclName().getAsString().c_str());
2548 printf(
"%20s\n", decl->getDeclKindName());
2554 clang::Decl *decl) {
2558 ExternalASTSource *ast_source = ast->getExternalSource();
2563 if (clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(decl)) {
2564 if (tag_decl->isCompleteDefinition())
2567 if (!tag_decl->hasExternalLexicalStorage())
2570 ast_source->CompleteType(tag_decl);
2572 return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
2573 }
else if (clang::ObjCInterfaceDecl *objc_interface_decl =
2574 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
2575 if (objc_interface_decl->getDefinition())
2578 if (!objc_interface_decl->hasExternalLexicalStorage())
2581 ast_source->CompleteType(objc_interface_decl);
2583 return !objc_interface_decl->getTypeForDecl()->isIncompleteType();
2613std::optional<ClangASTMetadata>
2619 return std::nullopt;
2622std::optional<ClangASTMetadata>
2628 return std::nullopt;
2650 if (find(mask, type->getTypeClass()) != mask.end())
2652 switch (type->getTypeClass()) {
2655 case clang::Type::Atomic:
2656 type = cast<clang::AtomicType>(type)->getValueType();
2658 case clang::Type::Auto:
2659 case clang::Type::Decltype:
2660 case clang::Type::Paren:
2661 case clang::Type::SubstTemplateTypeParm:
2662 case clang::Type::TemplateSpecialization:
2663 case clang::Type::Typedef:
2664 case clang::Type::TypeOf:
2665 case clang::Type::TypeOfExpr:
2666 case clang::Type::Using:
2667 case clang::Type::PredefinedSugar:
2668 type = type->getLocallyUnqualifiedSingleStepDesugaredType();
2682 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2683 switch (type_class) {
2684 case clang::Type::ObjCInterface:
2685 return llvm::cast<clang::ObjCObjectType>(qual_type.getTypePtr())
2687 case clang::Type::ObjCObjectPointer:
2689 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
2690 ->getPointeeType());
2691 case clang::Type::Enum:
2692 case clang::Type::Record:
2693 return llvm::cast<clang::TagType>(qual_type)
2695 ->getDefinitionOrSelf();
2707static const clang::RecordType *
2709 assert(qual_type->isRecordType());
2711 const auto *tag_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
2713 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
2717 if (!cxx_record_decl || !cxx_record_decl->hasExternalLexicalStorage())
2720 const bool is_complete = cxx_record_decl->isCompleteDefinition();
2721 const bool fields_loaded =
2722 cxx_record_decl->hasLoadedFieldsFromExternalStorage();
2725 if (is_complete && fields_loaded)
2733 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2734 if (external_ast_source) {
2735 external_ast_source->CompleteType(cxx_record_decl);
2736 if (cxx_record_decl->isCompleteDefinition()) {
2737 cxx_record_decl->field_begin();
2738 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
2750 clang::QualType qual_type) {
2751 assert(qual_type->isEnumeralType());
2754 const clang::EnumType *enum_type =
2755 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
2757 auto *tag_decl = enum_type->getAsTagDecl();
2761 if (tag_decl->getDefinition())
2765 if (!tag_decl->hasExternalLexicalStorage())
2769 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2770 if (!external_ast_source)
2773 external_ast_source->CompleteType(tag_decl);
2781static const clang::ObjCObjectType *
2783 assert(qual_type->isObjCObjectType());
2786 const clang::ObjCObjectType *objc_class_type =
2787 llvm::cast<clang::ObjCObjectType>(qual_type);
2789 clang::ObjCInterfaceDecl *class_interface_decl =
2790 objc_class_type->getInterface();
2793 if (!class_interface_decl)
2794 return objc_class_type;
2797 if (class_interface_decl->getDefinition())
2798 return objc_class_type;
2801 if (!class_interface_decl->hasExternalLexicalStorage())
2805 clang::ExternalASTSource *external_ast_source = ast->getExternalSource();
2806 if (!external_ast_source)
2809 external_ast_source->CompleteType(class_interface_decl);
2810 return objc_class_type;
2814 clang::QualType qual_type) {
2816 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2817 switch (type_class) {
2818 case clang::Type::ConstantArray:
2819 case clang::Type::IncompleteArray:
2820 case clang::Type::VariableArray: {
2821 const clang::ArrayType *array_type =
2822 llvm::dyn_cast<clang::ArrayType>(qual_type.getTypePtr());
2827 case clang::Type::Record: {
2829 return !RT->isIncompleteType();
2834 case clang::Type::Enum: {
2836 return !ET->isIncompleteType();
2840 case clang::Type::ObjCObject:
2841 case clang::Type::ObjCInterface: {
2843 return !OT->isIncompleteType();
2848 case clang::Type::Attributed:
2850 ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType());
2852 case clang::Type::MemberPointer:
2855 if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
2856 auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
2857 if (
auto *RD = MPT->getMostRecentCXXRecordDecl())
2860 return !qual_type.getTypePtr()->isIncompleteType();
2875 return !type || llvm::isa<clang::Type>(
GetQualType(type).getTypePtr());
2882 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2883 switch (type_class) {
2884 case clang::Type::IncompleteArray:
2885 case clang::Type::VariableArray:
2886 case clang::Type::ConstantArray:
2887 case clang::Type::ExtVector:
2888 case clang::Type::Vector:
2889 case clang::Type::Record:
2890 case clang::Type::ObjCObject:
2891 case clang::Type::ObjCInterface:
2903 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2904 switch (type_class) {
2905 case clang::Type::Record: {
2906 if (
const clang::RecordType *record_type =
2907 llvm::dyn_cast_or_null<clang::RecordType>(
2908 qual_type.getTypePtrOrNull())) {
2909 if (
const clang::RecordDecl *record_decl = record_type->getDecl()) {
2910 return record_decl->isAnonymousStructOrUnion();
2924 uint64_t *size,
bool *is_incomplete) {
2927 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2928 switch (type_class) {
2932 case clang::Type::ConstantArray:
2933 if (element_type_ptr)
2935 weak_from_this(), llvm::cast<clang::ConstantArrayType>(qual_type)
2939 *size = llvm::cast<clang::ConstantArrayType>(qual_type)
2941 .getLimitedValue(ULLONG_MAX);
2943 *is_incomplete =
false;
2946 case clang::Type::IncompleteArray:
2947 if (element_type_ptr)
2949 weak_from_this(), llvm::cast<clang::IncompleteArrayType>(qual_type)
2955 *is_incomplete =
true;
2958 case clang::Type::VariableArray:
2959 if (element_type_ptr)
2961 weak_from_this(), llvm::cast<clang::VariableArrayType>(qual_type)
2967 *is_incomplete =
false;
2970 case clang::Type::DependentSizedArray:
2971 if (element_type_ptr)
2974 llvm::cast<clang::DependentSizedArrayType>(qual_type)
2980 *is_incomplete =
false;
2983 if (element_type_ptr)
2984 element_type_ptr->
Clear();
2988 *is_incomplete =
false;
2996 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
2997 switch (type_class) {
2998 case clang::Type::Vector: {
2999 const clang::VectorType *vector_type =
3000 qual_type->getAs<clang::VectorType>();
3003 *size = vector_type->getNumElements();
3005 *element_type =
GetType(vector_type->getElementType());
3009 case clang::Type::ExtVector: {
3010 const clang::ExtVectorType *ext_vector_type =
3011 qual_type->getAs<clang::ExtVectorType>();
3012 if (ext_vector_type) {
3014 *size = ext_vector_type->getNumElements();
3018 ext_vector_type->getElementType().getAsOpaquePtr());
3034 if (!llvm::isa<clang::ObjCInterfaceDecl>(decl_ctx))
3037 clang::ObjCInterfaceDecl *result_iface_decl =
3038 llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
3040 std::optional<ClangASTMetadata> ast_metadata =
GetMetadata(result_iface_decl);
3044 return (ast_metadata->GetISAPtr() != 0);
3048 return GetQualType(type).getUnqualifiedType()->isCharType();
3070 if (!pointee_or_element_clang_type.
IsValid())
3073 if (type_flags.
AnySet(eTypeIsArray | eTypeIsPointer)) {
3074 if (pointee_or_element_clang_type.
IsCharType()) {
3075 if (type_flags.
Test(eTypeIsArray)) {
3078 length = llvm::cast<clang::ConstantArrayType>(
3092 if (
auto pointer_auth = qual_type.getPointerAuth())
3093 return pointer_auth.getKey();
3102 if (
auto pointer_auth = qual_type.getPointerAuth())
3103 return pointer_auth.getExtraDiscriminator();
3112 if (
auto pointer_auth = qual_type.getPointerAuth())
3113 return pointer_auth.isAddressDiscriminated();
3119 auto isFunctionType = [&](clang::QualType qual_type) {
3120 return qual_type->isFunctionType();
3134 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3135 switch (type_class) {
3136 case clang::Type::Record:
3138 const clang::CXXRecordDecl *cxx_record_decl =
3139 qual_type->getAsCXXRecordDecl();
3140 if (cxx_record_decl) {
3141 if (cxx_record_decl->getNumBases() || cxx_record_decl->isDynamicClass())
3144 const clang::RecordType *record_type =
3145 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
3147 if (
const clang::RecordDecl *record_decl =
3148 record_type->getDecl()->getDefinition()) {
3151 clang::RecordDecl::field_iterator field_pos,
3152 field_end = record_decl->field_end();
3153 uint32_t num_fields = 0;
3154 bool is_hva =
false;
3155 bool is_hfa =
false;
3156 clang::QualType base_qual_type;
3157 uint64_t base_bitwidth = 0;
3158 for (field_pos = record_decl->field_begin(); field_pos != field_end;
3160 clang::QualType field_qual_type = field_pos->getType();
3161 uint64_t field_bitwidth =
getASTContext().getTypeSize(qual_type);
3162 if (field_qual_type->isFloatingType()) {
3163 if (field_qual_type->isComplexType())
3166 if (num_fields == 0)
3167 base_qual_type = field_qual_type;
3172 if (field_qual_type.getTypePtr() !=
3173 base_qual_type.getTypePtr())
3177 }
else if (field_qual_type->isVectorType() ||
3178 field_qual_type->isExtVectorType()) {
3179 if (num_fields == 0) {
3180 base_qual_type = field_qual_type;
3181 base_bitwidth = field_bitwidth;
3186 if (base_bitwidth != field_bitwidth)
3188 if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr())
3197 CompilerType(weak_from_this(), base_qual_type.getAsOpaquePtr());
3214 const clang::FunctionProtoType *func =
3215 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3217 return func->getNumParams();
3224 const size_t index) {
3227 const clang::FunctionProtoType *func =
3228 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
3230 if (index < func->getNumParams())
3231 return CompilerType(weak_from_this(), func->getParamType(index).getAsOpaquePtr());
3239 llvm::function_ref<
bool(clang::QualType)> predicate)
const {
3243 if (predicate(qual_type))
3246 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3247 switch (type_class) {
3251 case clang::Type::LValueReference:
3252 case clang::Type::RValueReference: {
3253 const clang::ReferenceType *reference_type =
3254 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
3256 return IsTypeImpl(reference_type->getPointeeType().getAsOpaquePtr(), predicate);
3265 auto isMemberFunctionPointerType = [](clang::QualType qual_type) {
3266 return qual_type->isMemberFunctionPointerType();
3269 return IsTypeImpl(type, isMemberFunctionPointerType);
3274 auto isMemberDataPointerType = [](clang::QualType qual_type) {
3275 return qual_type->isMemberDataPointerType();
3278 return IsTypeImpl(type, isMemberDataPointerType);
3282 auto isFunctionPointerType = [](clang::QualType qual_type) {
3283 return qual_type->isFunctionPointerType();
3286 return IsTypeImpl(type, isFunctionPointerType);
3292 auto isBlockPointerType = [&](clang::QualType qual_type) {
3293 if (qual_type->isBlockPointerType()) {
3294 if (function_pointer_type_ptr) {
3295 const clang::BlockPointerType *block_pointer_type =
3296 qual_type->castAs<clang::BlockPointerType>();
3297 QualType pointee_type = block_pointer_type->getPointeeType();
3298 QualType function_pointer_type =
m_ast_up->getPointerType(pointee_type);
3300 weak_from_this(), function_pointer_type.getAsOpaquePtr());
3317 if (qual_type.isNull())
3326 is_signed = qual_type->isSignedIntegerType();
3334 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3338 is_signed = enum_type->isSignedIntegerOrEnumerationType();
3349 const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
3353 return enum_type->isScopedEnumeralType();
3364 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3365 switch (type_class) {
3366 case clang::Type::Builtin:
3367 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3370 case clang::BuiltinType::ObjCId:
3371 case clang::BuiltinType::ObjCClass:
3375 case clang::Type::ObjCObjectPointer:
3379 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3383 case clang::Type::BlockPointer:
3386 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3390 case clang::Type::Pointer:
3393 llvm::cast<clang::PointerType>(qual_type)
3397 case clang::Type::MemberPointer:
3400 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3409 pointee_type->
Clear();
3417 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3418 switch (type_class) {
3419 case clang::Type::Builtin:
3420 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
3423 case clang::BuiltinType::ObjCId:
3424 case clang::BuiltinType::ObjCClass:
3428 case clang::Type::ObjCObjectPointer:
3432 llvm::cast<clang::ObjCObjectPointerType>(qual_type)
3436 case clang::Type::BlockPointer:
3439 weak_from_this(), llvm::cast<clang::BlockPointerType>(qual_type)
3443 case clang::Type::Pointer:
3446 llvm::cast<clang::PointerType>(qual_type)
3450 case clang::Type::MemberPointer:
3453 weak_from_this(), llvm::cast<clang::MemberPointerType>(qual_type)
3457 case clang::Type::LValueReference:
3460 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3464 case clang::Type::RValueReference:
3467 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3476 pointee_type->
Clear();
3485 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3487 switch (type_class) {
3488 case clang::Type::LValueReference:
3491 weak_from_this(), llvm::cast<clang::LValueReferenceType>(qual_type)
3497 case clang::Type::RValueReference:
3500 weak_from_this(), llvm::cast<clang::RValueReferenceType>(qual_type)
3512 pointee_type->
Clear();
3521 if (qual_type.isNull())
3524 return qual_type->isFloatingType();
3532 const clang::TagType *tag_type =
3533 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
3535 if (clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinition())
3536 return tag_decl->isCompleteDefinition();
3539 const clang::ObjCObjectType *objc_class_type =
3540 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
3541 if (objc_class_type) {
3542 clang::ObjCInterfaceDecl *class_interface_decl =
3543 objc_class_type->getInterface();
3544 if (class_interface_decl)
3545 return class_interface_decl->getDefinition() !=
nullptr;
3556 const clang::ObjCObjectPointerType *obj_pointer_type =
3557 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3559 if (obj_pointer_type)
3560 return obj_pointer_type->isObjCClassType();
3575 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3576 return (type_class == clang::Type::Record);
3583 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3584 return (type_class == clang::Type::Enum);
3590 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3591 switch (type_class) {
3592 case clang::Type::Record:
3594 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
3601 return cxx_record_decl->isDynamicClass();
3615 bool check_cplusplus,
3617 if (dynamic_pointee_type)
3618 dynamic_pointee_type->
Clear();
3622 auto set_dynamic_pointee_type = [&](clang::QualType type) {
3623 if (dynamic_pointee_type)
3625 type.getAsOpaquePtr());
3628 clang::QualType pointee_qual_type;
3630 switch (qual_type->getTypeClass()) {
3631 case clang::Type::Builtin:
3632 if (check_objc && llvm::cast<clang::BuiltinType>(qual_type)->getKind() ==
3633 clang::BuiltinType::ObjCId) {
3634 set_dynamic_pointee_type(qual_type);
3639 case clang::Type::ObjCObjectPointer:
3642 if (
const auto *objc_pointee_type =
3643 qual_type->getPointeeType().getTypePtrOrNull()) {
3644 if (
const auto *objc_object_type =
3645 llvm::dyn_cast_or_null<clang::ObjCObjectType>(
3646 objc_pointee_type)) {
3647 if (objc_object_type->isObjCClass())
3651 set_dynamic_pointee_type(
3652 llvm::cast<clang::ObjCObjectPointerType>(qual_type)->getPointeeType());
3655 case clang::Type::Pointer:
3657 llvm::cast<clang::PointerType>(qual_type)->getPointeeType();
3660 case clang::Type::LValueReference:
3661 case clang::Type::RValueReference:
3663 llvm::cast<clang::ReferenceType>(qual_type)->getPointeeType();
3673 switch (pointee_qual_type.getCanonicalType()->getTypeClass()) {
3674 case clang::Type::Builtin:
3675 switch (llvm::cast<clang::BuiltinType>(pointee_qual_type)->getKind()) {
3676 case clang::BuiltinType::UnknownAny:
3677 case clang::BuiltinType::Void:
3678 set_dynamic_pointee_type(pointee_qual_type);
3684 case clang::Type::Record: {
3685 if (!check_cplusplus)
3687 clang::CXXRecordDecl *cxx_record_decl =
3688 pointee_qual_type->getAsCXXRecordDecl();
3689 if (!cxx_record_decl)
3693 if (cxx_record_decl->isCompleteDefinition())
3694 success = cxx_record_decl->isDynamicClass();
3696 std::optional<ClangASTMetadata> metadata =
GetMetadata(cxx_record_decl);
3697 std::optional<bool> is_dynamic =
3698 metadata ? metadata->GetIsDynamicCXXType() : std::nullopt;
3700 success = *is_dynamic;
3702 success = cxx_record_decl->isDynamicClass();
3708 set_dynamic_pointee_type(pointee_qual_type);
3712 case clang::Type::ObjCObject:
3713 case clang::Type::ObjCInterface:
3715 set_dynamic_pointee_type(pointee_qual_type);
3730 return (
GetTypeInfo(type,
nullptr) & eTypeIsScalar) != 0;
3737 ->getTypeClass() == clang::Type::Typedef;
3756 return std::nullopt;
3758 if (!clang::isTargetAddressSpace(as))
3759 return std::nullopt;
3760 return clang::toTargetAddressSpace(as);
3764 if (
auto *record_decl =
3766 return record_decl->canPassInRegisters();
3772 return TypeSystemClangSupportsLanguage(language);
3775std::optional<std::string>
3778 return std::nullopt;
3781 if (qual_type.isNull())
3782 return std::nullopt;
3784 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
3785 if (!cxx_record_decl)
3786 return std::nullopt;
3788 return std::string(cxx_record_decl->getIdentifier()->getNameStart());
3796 return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() !=
nullptr;
3803 const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
3805 return tag_type->getDecl()->isEntityBeingDefined();
3816 if (!qual_type.isNull() && qual_type->isObjCObjectPointerType()) {
3817 if (class_type_ptr) {
3818 if (!qual_type->isObjCClassType() && !qual_type->isObjCIdType()) {
3819 const clang::ObjCObjectPointerType *obj_pointer_type =
3820 llvm::dyn_cast<clang::ObjCObjectPointerType>(qual_type);
3821 if (obj_pointer_type ==
nullptr)
3822 class_type_ptr->
Clear();
3826 clang::QualType(obj_pointer_type->getInterfaceType(), 0)
3833 class_type_ptr->
Clear();
3860 {clang::Type::Typedef, clang::Type::Atomic});
3863 if (
const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
3864 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
3871 if (
auto *named_decl = qual_type->getAsTagDecl())
3883 clang::PrintingPolicy printing_policy(
getASTContext().getPrintingPolicy());
3884 printing_policy.SuppressTagKeyword =
true;
3885 printing_policy.SuppressScope =
false;
3886 printing_policy.SuppressUnwrittenScope =
true;
3887 printing_policy.SuppressInlineNamespace =
3888 llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::All);
3889 return ConstString(qual_type.getAsString(printing_policy));
3898 if (pointee_or_element_clang_type)
3899 pointee_or_element_clang_type->
Clear();
3901 clang::QualType qual_type =
3904 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
3905 switch (type_class) {
3906 case clang::Type::Attributed:
3907 return GetTypeInfo(qual_type->castAs<clang::AttributedType>()
3910 pointee_or_element_clang_type);
3911 case clang::Type::BitInt: {
3912 uint32_t type_flags = eTypeIsScalar | eTypeIsInteger | eTypeHasValue;
3913 if (qual_type->isSignedIntegerType())
3914 type_flags |= eTypeIsSigned;
3918 case clang::Type::Builtin: {
3919 const clang::BuiltinType *builtin_type =
3920 llvm::cast<clang::BuiltinType>(qual_type->getCanonicalTypeInternal());
3922 uint32_t builtin_type_flags = eTypeIsBuiltIn | eTypeHasValue;
3923 switch (builtin_type->getKind()) {
3924 case clang::BuiltinType::ObjCId:
3925 case clang::BuiltinType::ObjCClass:
3926 if (pointee_or_element_clang_type)
3930 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3933 case clang::BuiltinType::ObjCSel:
3934 if (pointee_or_element_clang_type)
3937 builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
3940 case clang::BuiltinType::Bool:
3941 case clang::BuiltinType::Char_U:
3942 case clang::BuiltinType::UChar:
3943 case clang::BuiltinType::WChar_U:
3944 case clang::BuiltinType::Char16:
3945 case clang::BuiltinType::Char32:
3946 case clang::BuiltinType::UShort:
3947 case clang::BuiltinType::UInt:
3948 case clang::BuiltinType::ULong:
3949 case clang::BuiltinType::ULongLong:
3950 case clang::BuiltinType::UInt128:
3951 case clang::BuiltinType::Char_S:
3952 case clang::BuiltinType::SChar:
3953 case clang::BuiltinType::WChar_S:
3954 case clang::BuiltinType::Short:
3955 case clang::BuiltinType::Int:
3956 case clang::BuiltinType::Long:
3957 case clang::BuiltinType::LongLong:
3958 case clang::BuiltinType::Int128:
3959 case clang::BuiltinType::Float:
3960 case clang::BuiltinType::Double:
3961 case clang::BuiltinType::LongDouble:
3962 builtin_type_flags |= eTypeIsScalar;
3963 if (builtin_type->isInteger()) {
3964 builtin_type_flags |= eTypeIsInteger;
3965 if (builtin_type->isSignedInteger())
3966 builtin_type_flags |= eTypeIsSigned;
3967 }
else if (builtin_type->isFloatingPoint())
3968 builtin_type_flags |= eTypeIsFloat;
3973 return builtin_type_flags;
3976 case clang::Type::BlockPointer:
3977 if (pointee_or_element_clang_type)
3979 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
3980 return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
3982 case clang::Type::Complex: {
3983 uint32_t complex_type_flags =
3984 eTypeIsBuiltIn | eTypeHasValue | eTypeIsComplex;
3985 const clang::ComplexType *complex_type = llvm::dyn_cast<clang::ComplexType>(
3986 qual_type->getCanonicalTypeInternal());
3988 clang::QualType complex_element_type(complex_type->getElementType());
3989 if (complex_element_type->isIntegerType())
3990 complex_type_flags |= eTypeIsInteger;
3991 else if (complex_element_type->isFloatingType())
3992 complex_type_flags |= eTypeIsFloat;
3994 return complex_type_flags;
3997 case clang::Type::ConstantArray:
3998 case clang::Type::DependentSizedArray:
3999 case clang::Type::IncompleteArray:
4000 case clang::Type::VariableArray:
4001 if (pointee_or_element_clang_type)
4003 weak_from_this(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
4006 return eTypeHasChildren | eTypeIsArray;
4008 case clang::Type::DependentName:
4010 case clang::Type::DependentSizedExtVector:
4011 return eTypeHasChildren | eTypeIsVector;
4013 case clang::Type::Enum:
4014 if (pointee_or_element_clang_type)
4016 weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
4018 ->getDefinitionOrSelf()
4021 return eTypeIsEnumeration | eTypeHasValue;
4023 case clang::Type::FunctionProto:
4024 return eTypeIsFuncPrototype | eTypeHasValue;
4025 case clang::Type::FunctionNoProto:
4026 return eTypeIsFuncPrototype | eTypeHasValue;
4027 case clang::Type::InjectedClassName:
4030 case clang::Type::LValueReference:
4031 case clang::Type::RValueReference:
4032 if (pointee_or_element_clang_type)
4035 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
4038 return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
4040 case clang::Type::MemberPointer:
4041 return eTypeIsPointer | eTypeIsMember | eTypeHasValue;
4043 case clang::Type::ObjCObjectPointer:
4044 if (pointee_or_element_clang_type)
4046 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4047 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
4050 case clang::Type::ObjCObject:
4051 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4052 case clang::Type::ObjCInterface:
4053 return eTypeHasChildren | eTypeIsObjC | eTypeIsClass;
4055 case clang::Type::Pointer:
4056 if (pointee_or_element_clang_type)
4058 weak_from_this(), qual_type->getPointeeType().getAsOpaquePtr());
4059 return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
4061 case clang::Type::Record:
4062 if (qual_type->getAsCXXRecordDecl())
4063 return eTypeHasChildren | eTypeIsClass | eTypeIsCPlusPlus;
4065 return eTypeHasChildren | eTypeIsStructUnion;
4067 case clang::Type::SubstTemplateTypeParm:
4068 return eTypeIsTemplate;
4069 case clang::Type::TemplateTypeParm:
4070 return eTypeIsTemplate;
4071 case clang::Type::TemplateSpecialization:
4072 return eTypeIsTemplate;
4074 case clang::Type::Typedef:
4075 return eTypeIsTypedef |
GetType(llvm::cast<clang::TypedefType>(qual_type)
4077 ->getUnderlyingType())
4079 case clang::Type::UnresolvedUsing:
4082 case clang::Type::ExtVector:
4083 case clang::Type::Vector: {
4084 uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector;
4085 const clang::VectorType *vector_type = llvm::dyn_cast<clang::VectorType>(
4086 qual_type->getCanonicalTypeInternal());
4090 QualType element_type = vector_type->getElementType();
4091 if (element_type.isNull())
4094 if (element_type->isIntegerType())
4095 vector_type_flags |= eTypeIsInteger;
4096 else if (element_type->isFloatingType())
4097 vector_type_flags |= eTypeIsFloat;
4098 return vector_type_flags;
4113 if (qual_type->isAnyPointerType()) {
4114 if (qual_type->isObjCObjectPointerType())
4116 if (qual_type->getPointeeCXXRecordDecl())
4119 clang::QualType pointee_type(qual_type->getPointeeType());
4120 if (pointee_type->getPointeeCXXRecordDecl())
4122 if (pointee_type->isObjCObjectOrInterfaceType())
4124 if (pointee_type->isObjCClassType())
4126 if (pointee_type.getTypePtr() ==
4130 if (qual_type->isObjCObjectOrInterfaceType())
4132 if (qual_type->getAsCXXRecordDecl())
4134 switch (qual_type->getTypeClass()) {
4137 case clang::Type::Builtin:
4138 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4140 case clang::BuiltinType::Void:
4141 case clang::BuiltinType::Bool:
4142 case clang::BuiltinType::Char_U:
4143 case clang::BuiltinType::UChar:
4144 case clang::BuiltinType::WChar_U:
4145 case clang::BuiltinType::Char16:
4146 case clang::BuiltinType::Char32:
4147 case clang::BuiltinType::UShort:
4148 case clang::BuiltinType::UInt:
4149 case clang::BuiltinType::ULong:
4150 case clang::BuiltinType::ULongLong:
4151 case clang::BuiltinType::UInt128:
4152 case clang::BuiltinType::Char_S:
4153 case clang::BuiltinType::SChar:
4154 case clang::BuiltinType::WChar_S:
4155 case clang::BuiltinType::Short:
4156 case clang::BuiltinType::Int:
4157 case clang::BuiltinType::Long:
4158 case clang::BuiltinType::LongLong:
4159 case clang::BuiltinType::Int128:
4160 case clang::BuiltinType::Float:
4161 case clang::BuiltinType::Double:
4162 case clang::BuiltinType::LongDouble:
4165 case clang::BuiltinType::NullPtr:
4168 case clang::BuiltinType::ObjCId:
4169 case clang::BuiltinType::ObjCClass:
4170 case clang::BuiltinType::ObjCSel:
4173 case clang::BuiltinType::Dependent:
4174 case clang::BuiltinType::Overload:
4175 case clang::BuiltinType::BoundMember:
4176 case clang::BuiltinType::UnknownAny:
4180 case clang::Type::Typedef:
4181 return GetType(llvm::cast<clang::TypedefType>(qual_type)
4183 ->getUnderlyingType())
4193 return lldb::eTypeClassInvalid;
4195 clang::QualType qual_type =
4198 switch (qual_type->getTypeClass()) {
4199 case clang::Type::Atomic:
4200 case clang::Type::Auto:
4201 case clang::Type::CountAttributed:
4202 case clang::Type::Decltype:
4203 case clang::Type::Paren:
4204 case clang::Type::TypeOf:
4205 case clang::Type::TypeOfExpr:
4206 case clang::Type::Using:
4207 case clang::Type::PredefinedSugar:
4208 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4209 case clang::Type::LateParsedAttr:
4210 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
4211 "that is resolved before the AST is finalized.");
4212 case clang::Type::UnaryTransform:
4214 case clang::Type::FunctionNoProto:
4215 return lldb::eTypeClassFunction;
4216 case clang::Type::FunctionProto:
4217 return lldb::eTypeClassFunction;
4218 case clang::Type::IncompleteArray:
4219 return lldb::eTypeClassArray;
4220 case clang::Type::VariableArray:
4221 return lldb::eTypeClassArray;
4222 case clang::Type::ConstantArray:
4223 return lldb::eTypeClassArray;
4224 case clang::Type::DependentSizedArray:
4225 return lldb::eTypeClassArray;
4226 case clang::Type::ArrayParameter:
4227 return lldb::eTypeClassArray;
4228 case clang::Type::DependentSizedExtVector:
4229 return lldb::eTypeClassVector;
4230 case clang::Type::DependentVector:
4231 return lldb::eTypeClassVector;
4232 case clang::Type::ExtVector:
4233 return lldb::eTypeClassVector;
4234 case clang::Type::Vector:
4235 return lldb::eTypeClassVector;
4236 case clang::Type::Builtin:
4238 case clang::Type::BitInt:
4239 case clang::Type::DependentBitInt:
4240 case clang::Type::OverflowBehavior:
4241 return lldb::eTypeClassBuiltin;
4242 case clang::Type::ObjCObjectPointer:
4243 return lldb::eTypeClassObjCObjectPointer;
4244 case clang::Type::BlockPointer:
4245 return lldb::eTypeClassBlockPointer;
4246 case clang::Type::Pointer:
4247 return lldb::eTypeClassPointer;
4248 case clang::Type::LValueReference:
4249 return lldb::eTypeClassReference;
4250 case clang::Type::RValueReference:
4251 return lldb::eTypeClassReference;
4252 case clang::Type::MemberPointer:
4253 return lldb::eTypeClassMemberPointer;
4254 case clang::Type::Complex:
4255 if (qual_type->isComplexType())
4256 return lldb::eTypeClassComplexFloat;
4258 return lldb::eTypeClassComplexInteger;
4259 case clang::Type::ObjCObject:
4260 return lldb::eTypeClassObjCObject;
4261 case clang::Type::ObjCInterface:
4262 return lldb::eTypeClassObjCInterface;
4263 case clang::Type::Record: {
4264 const clang::RecordType *record_type =
4265 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
4266 const clang::RecordDecl *record_decl = record_type->getDecl();
4267 if (record_decl->isUnion())
4268 return lldb::eTypeClassUnion;
4269 else if (record_decl->isStruct())
4270 return lldb::eTypeClassStruct;
4272 return lldb::eTypeClassClass;
4274 case clang::Type::Enum:
4275 return lldb::eTypeClassEnumeration;
4276 case clang::Type::Typedef:
4277 return lldb::eTypeClassTypedef;
4278 case clang::Type::UnresolvedUsing:
4281 case clang::Type::Attributed:
4282 case clang::Type::BTFTagAttributed:
4284 case clang::Type::TemplateTypeParm:
4286 case clang::Type::SubstTemplateTypeParm:
4288 case clang::Type::SubstTemplateTypeParmPack:
4290 case clang::Type::InjectedClassName:
4292 case clang::Type::DependentName:
4294 case clang::Type::PackExpansion:
4297 case clang::Type::TemplateSpecialization:
4299 case clang::Type::DeducedTemplateSpecialization:
4301 case clang::Type::Pipe:
4305 case clang::Type::Decayed:
4307 case clang::Type::Adjusted:
4309 case clang::Type::ObjCTypeParam:
4312 case clang::Type::DependentAddressSpace:
4314 case clang::Type::MacroQualified:
4318 case clang::Type::ConstantMatrix:
4319 case clang::Type::DependentSizedMatrix:
4323 case clang::Type::PackIndexing:
4326 case clang::Type::HLSLAttributedResource:
4328 case clang::Type::HLSLInlineSpirv:
4330 case clang::Type::SubstBuiltinTemplatePack:
4334 return lldb::eTypeClassOther;
4339 return GetQualType(type).getQualifiers().getCVRQualifiers();
4351 const clang::Type *array_eletype =
4352 qual_type.getTypePtr()->getArrayElementTypeNoTypeQual();
4357 return GetType(clang::QualType(array_eletype, 0));
4368 return GetType(ast_ctx.getConstantArrayType(
4369 qual_type, llvm::APInt(64, size),
nullptr,
4370 clang::ArraySizeModifier::Normal, 0));
4372 return GetType(ast_ctx.getIncompleteArrayType(
4373 qual_type, clang::ArraySizeModifier::Normal, 0));
4387 clang::QualType qual_type) {
4388 if (qual_type->isPointerType())
4389 qual_type = ast->getPointerType(
4391 else if (
const ConstantArrayType *arr =
4392 ast->getAsConstantArrayType(qual_type)) {
4393 qual_type = ast->getConstantArrayType(
4395 arr->getSize(), arr->getSizeExpr(), arr->getSizeModifier(),
4396 arr->getIndexTypeQualifiers().getAsOpaqueValue());
4398 qual_type = qual_type.getUnqualifiedType();
4399 qual_type.removeLocalConst();
4400 qual_type.removeLocalRestrict();
4401 qual_type.removeLocalVolatile();
4423 const clang::FunctionProtoType *func =
4426 return func->getNumParams();
4434 const clang::FunctionProtoType *func =
4435 llvm::dyn_cast<clang::FunctionProtoType>(
GetQualType(type));
4437 const uint32_t num_args = func->getNumParams();
4439 return GetType(func->getParamType(idx));
4449 const clang::FunctionProtoType *func =
4450 llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
4452 return GetType(func->getReturnType());
4459 size_t num_functions = 0;
4462 switch (qual_type->getTypeClass()) {
4463 case clang::Type::Record:
4465 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
4466 num_functions = std::distance(cxx_record_decl->method_begin(),
4467 cxx_record_decl->method_end());
4470 case clang::Type::ObjCObjectPointer: {
4471 const clang::ObjCObjectPointerType *objc_class_type =
4472 qual_type->castAs<clang::ObjCObjectPointerType>();
4473 const clang::ObjCInterfaceType *objc_interface_type =
4474 objc_class_type->getInterfaceType();
4475 if (objc_interface_type &&
4477 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4478 clang::ObjCInterfaceDecl *class_interface_decl =
4479 objc_interface_type->getDecl();
4480 if (class_interface_decl) {
4481 num_functions = std::distance(class_interface_decl->meth_begin(),
4482 class_interface_decl->meth_end());
4488 case clang::Type::ObjCObject:
4489 case clang::Type::ObjCInterface:
4491 const clang::ObjCObjectType *objc_class_type =
4492 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4493 if (objc_class_type) {
4494 clang::ObjCInterfaceDecl *class_interface_decl =
4495 objc_class_type->getInterface();
4496 if (class_interface_decl)
4497 num_functions = std::distance(class_interface_decl->meth_begin(),
4498 class_interface_decl->meth_end());
4507 return num_functions;
4519 switch (qual_type->getTypeClass()) {
4520 case clang::Type::Record:
4522 if (
const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
4523 auto method_iter = cxx_record_decl->method_begin();
4524 auto method_end = cxx_record_decl->method_end();
4526 static_cast<size_t>(std::distance(method_iter, method_end))) {
4527 std::advance(method_iter, idx);
4528 clang::CXXMethodDecl *cxx_method_decl =
4529 method_iter->getCanonicalDecl();
4530 if (cxx_method_decl) {
4531 name = cxx_method_decl->getDeclName().getAsString();
4532 if (cxx_method_decl->isStatic())
4534 else if (llvm::isa<clang::CXXConstructorDecl>(cxx_method_decl))
4536 else if (llvm::isa<clang::CXXDestructorDecl>(cxx_method_decl))
4540 clang_type =
GetType(cxx_method_decl->getType());
4548 case clang::Type::ObjCObjectPointer: {
4549 const clang::ObjCObjectPointerType *objc_class_type =
4550 qual_type->castAs<clang::ObjCObjectPointerType>();
4551 const clang::ObjCInterfaceType *objc_interface_type =
4552 objc_class_type->getInterfaceType();
4553 if (objc_interface_type &&
4555 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
4556 clang::ObjCInterfaceDecl *class_interface_decl =
4557 objc_interface_type->getDecl();
4558 if (class_interface_decl) {
4559 auto method_iter = class_interface_decl->meth_begin();
4560 auto method_end = class_interface_decl->meth_end();
4562 static_cast<size_t>(std::distance(method_iter, method_end))) {
4563 std::advance(method_iter, idx);
4564 clang::ObjCMethodDecl *objc_method_decl =
4565 method_iter->getCanonicalDecl();
4566 if (objc_method_decl) {
4568 name = objc_method_decl->getSelector().getAsString();
4569 if (objc_method_decl->isClassMethod())
4580 case clang::Type::ObjCObject:
4581 case clang::Type::ObjCInterface:
4583 const clang::ObjCObjectType *objc_class_type =
4584 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
4585 if (objc_class_type) {
4586 clang::ObjCInterfaceDecl *class_interface_decl =
4587 objc_class_type->getInterface();
4588 if (class_interface_decl) {
4589 auto method_iter = class_interface_decl->meth_begin();
4590 auto method_end = class_interface_decl->meth_end();
4592 static_cast<size_t>(std::distance(method_iter, method_end))) {
4593 std::advance(method_iter, idx);
4594 clang::ObjCMethodDecl *objc_method_decl =
4595 method_iter->getCanonicalDecl();
4596 if (objc_method_decl) {
4598 name = objc_method_decl->getSelector().getAsString();
4599 if (objc_method_decl->isClassMethod())
4632 return GetType(qual_type.getTypePtr()->getPointeeType());
4642 switch (qual_type.getDesugaredType(
getASTContext())->getTypeClass()) {
4643 case clang::Type::ObjCObject:
4644 case clang::Type::ObjCInterface:
4691 auto pauth = PointerAuthQualifier::fromOpaqueValue(payload);
4692 clang::QualType result =
4693 clang_ast.getPointerAuthType(
GetQualType(type), pauth);
4701 uint32_t address_space) {
4703 assert(address_space <= clang::Qualifiers::MaxAddressSpace);
4705 auto lang_as =
static_cast<clang::LangAS
>(address_space);
4706 if (lang_as == clang::LangAS::Default || qual_type.hasAddressSpace())
4715 result.addVolatile();
4725 result.addRestrict();
4734 if (type && typedef_name && typedef_name[0]) {
4738 clang::DeclContext *decl_ctx =
4743 clang::TypedefDecl *decl =
4744 clang::TypedefDecl::CreateDeserialized(clang_ast, GlobalDeclID());
4745 decl->setDeclContext(decl_ctx);
4746 decl->setDeclName(&clang_ast.Idents.get(typedef_name));
4747 decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
4748 decl_ctx->addDecl(decl);
4751 clang::TagDecl *tdecl =
nullptr;
4752 if (!qual_type.isNull()) {
4753 if (
const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
4754 tdecl = rt->getDecl();
4755 if (
const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
4756 tdecl = et->getDecl();
4762 if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl())
4763 tdecl->setTypedefNameForAnonDecl(decl);
4765 decl->setAccess(clang::AS_public);
4768 NestedNameSpecifier Qualifier =
4769 clang::TypeName::getFullyQualifiedDeclaredContext(clang_ast, decl);
4771 clang_ast.getTypedefType(ElaboratedTypeKeyword::None, Qualifier, decl));
4779 const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
4782 return GetType(typedef_type->getDecl()->getUnderlyingType());
4795 const FunctionType::ExtInfo generic_ext_info(
4804 QualType func_type = ast.getFunctionNoProtoType(ast.VoidTy, generic_ext_info);
4809const llvm::fltSemantics &
4812 const size_t bit_size = byte_size * 8;
4813 if (bit_size == ast.getTypeSize(ast.FloatTy))
4814 return ast.getFloatTypeSemantics(ast.FloatTy);
4815 else if (bit_size == ast.getTypeSize(ast.DoubleTy))
4816 return ast.getFloatTypeSemantics(ast.DoubleTy);
4818 bit_size == ast.getTypeSize(ast.Float128Ty))
4819 return ast.getFloatTypeSemantics(ast.Float128Ty);
4820 else if (bit_size == ast.getTypeSize(ast.LongDoubleTy) ||
4821 bit_size == llvm::APFloat::semanticsSizeInBits(
4822 ast.getFloatTypeSemantics(ast.LongDoubleTy)))
4823 return ast.getFloatTypeSemantics(ast.LongDoubleTy);
4824 else if (bit_size == ast.getTypeSize(ast.HalfTy))
4825 return ast.getFloatTypeSemantics(ast.HalfTy);
4826 else if (bit_size == ast.getTypeSize(ast.Float128Ty))
4827 return ast.getFloatTypeSemantics(ast.Float128Ty);
4828 return llvm::APFloatBase::Bogus();
4831llvm::Expected<uint64_t>
4834 assert(qual_type->isObjCObjectOrInterfaceType());
4839 if (std::optional<uint64_t> bit_size =
4840 objc_runtime->GetTypeBitSize(
GetType(qual_type)))
4844 static bool g_printed =
false;
4849 llvm::outs() <<
"warning: trying to determine the size of type ";
4851 llvm::outs() <<
"without a valid ExecutionContext. this is not "
4852 "reliable. please file a bug against LLDB.\n";
4853 llvm::outs() <<
"backtrace:\n";
4854 llvm::sys::PrintStackTrace(llvm::outs());
4855 llvm::outs() <<
"\n";
4864llvm::Expected<uint64_t>
4867 const bool base_name_only =
true;
4869 return llvm::createStringError(
4870 "could not complete type %s",
4874 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
4875 switch (type_class) {
4876 case clang::Type::ConstantArray:
4877 case clang::Type::FunctionProto:
4878 case clang::Type::Record:
4880 case clang::Type::ObjCInterface:
4881 case clang::Type::ObjCObject:
4883 case clang::Type::IncompleteArray: {
4884 const uint64_t bit_size =
getASTContext().getTypeSize(qual_type);
4887 qual_type->getArrayElementTypeNoTypeQual()
4888 ->getCanonicalTypeUnqualified());
4893 if (
const uint64_t bit_size =
getASTContext().getTypeSize(qual_type))
4897 return llvm::createStringError(
4898 "could not get size of type %s",
4902std::optional<size_t>
4916 switch (qual_type->getTypeClass()) {
4917 case clang::Type::Atomic:
4918 case clang::Type::Auto:
4919 case clang::Type::CountAttributed:
4920 case clang::Type::Decltype:
4921 case clang::Type::Paren:
4922 case clang::Type::Typedef:
4923 case clang::Type::TypeOf:
4924 case clang::Type::TypeOfExpr:
4925 case clang::Type::Using:
4926 case clang::Type::PredefinedSugar:
4927 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
4928 case clang::Type::LateParsedAttr:
4929 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
4930 "that is resolved before the AST is finalized.");
4932 case clang::Type::UnaryTransform:
4935 case clang::Type::FunctionNoProto:
4936 case clang::Type::FunctionProto:
4939 case clang::Type::IncompleteArray:
4940 case clang::Type::VariableArray:
4941 case clang::Type::ArrayParameter:
4944 case clang::Type::ConstantArray:
4947 case clang::Type::DependentVector:
4948 case clang::Type::ExtVector:
4949 case clang::Type::Vector:
4952 case clang::Type::BitInt:
4953 case clang::Type::DependentBitInt:
4954 case clang::Type::OverflowBehavior:
4958 case clang::Type::Builtin:
4959 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
4960 case clang::BuiltinType::Void:
4963 case clang::BuiltinType::Char_S:
4964 case clang::BuiltinType::SChar:
4965 case clang::BuiltinType::WChar_S:
4966 case clang::BuiltinType::Short:
4967 case clang::BuiltinType::Int:
4968 case clang::BuiltinType::Long:
4969 case clang::BuiltinType::LongLong:
4970 case clang::BuiltinType::Int128:
4973 case clang::BuiltinType::Bool:
4974 case clang::BuiltinType::Char_U:
4975 case clang::BuiltinType::UChar:
4976 case clang::BuiltinType::WChar_U:
4977 case clang::BuiltinType::Char8:
4978 case clang::BuiltinType::Char16:
4979 case clang::BuiltinType::Char32:
4980 case clang::BuiltinType::UShort:
4981 case clang::BuiltinType::UInt:
4982 case clang::BuiltinType::ULong:
4983 case clang::BuiltinType::ULongLong:
4984 case clang::BuiltinType::UInt128:
4988 case clang::BuiltinType::ShortAccum:
4989 case clang::BuiltinType::Accum:
4990 case clang::BuiltinType::LongAccum:
4991 case clang::BuiltinType::UShortAccum:
4992 case clang::BuiltinType::UAccum:
4993 case clang::BuiltinType::ULongAccum:
4994 case clang::BuiltinType::ShortFract:
4995 case clang::BuiltinType::Fract:
4996 case clang::BuiltinType::LongFract:
4997 case clang::BuiltinType::UShortFract:
4998 case clang::BuiltinType::UFract:
4999 case clang::BuiltinType::ULongFract:
5000 case clang::BuiltinType::SatShortAccum:
5001 case clang::BuiltinType::SatAccum:
5002 case clang::BuiltinType::SatLongAccum:
5003 case clang::BuiltinType::SatUShortAccum:
5004 case clang::BuiltinType::SatUAccum:
5005 case clang::BuiltinType::SatULongAccum:
5006 case clang::BuiltinType::SatShortFract:
5007 case clang::BuiltinType::SatFract:
5008 case clang::BuiltinType::SatLongFract:
5009 case clang::BuiltinType::SatUShortFract:
5010 case clang::BuiltinType::SatUFract:
5011 case clang::BuiltinType::SatULongFract:
5014 case clang::BuiltinType::Half:
5015 case clang::BuiltinType::Float:
5016 case clang::BuiltinType::Float16:
5017 case clang::BuiltinType::Float128:
5018 case clang::BuiltinType::Double:
5019 case clang::BuiltinType::LongDouble:
5020 case clang::BuiltinType::BFloat16:
5021 case clang::BuiltinType::Ibm128:
5024 case clang::BuiltinType::ObjCClass:
5025 case clang::BuiltinType::ObjCId:
5026 case clang::BuiltinType::ObjCSel:
5029 case clang::BuiltinType::NullPtr:
5032 case clang::BuiltinType::MetaInfo:
5034#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5035#include "clang/Basic/HLSLPackedTypes.def"
5038 case clang::BuiltinType::Kind::ARCUnbridgedCast:
5039 case clang::BuiltinType::Kind::BoundMember:
5040 case clang::BuiltinType::Kind::BuiltinFn:
5041 case clang::BuiltinType::Kind::Dependent:
5042 case clang::BuiltinType::Kind::OCLClkEvent:
5043 case clang::BuiltinType::Kind::OCLEvent:
5044 case clang::BuiltinType::Kind::OCLImage1dRO:
5045 case clang::BuiltinType::Kind::OCLImage1dWO:
5046 case clang::BuiltinType::Kind::OCLImage1dRW:
5047 case clang::BuiltinType::Kind::OCLImage1dArrayRO:
5048 case clang::BuiltinType::Kind::OCLImage1dArrayWO:
5049 case clang::BuiltinType::Kind::OCLImage1dArrayRW:
5050 case clang::BuiltinType::Kind::OCLImage1dBufferRO:
5051 case clang::BuiltinType::Kind::OCLImage1dBufferWO:
5052 case clang::BuiltinType::Kind::OCLImage1dBufferRW:
5053 case clang::BuiltinType::Kind::OCLImage2dRO:
5054 case clang::BuiltinType::Kind::OCLImage2dWO:
5055 case clang::BuiltinType::Kind::OCLImage2dRW:
5056 case clang::BuiltinType::Kind::OCLImage2dArrayRO:
5057 case clang::BuiltinType::Kind::OCLImage2dArrayWO:
5058 case clang::BuiltinType::Kind::OCLImage2dArrayRW:
5059 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRO:
5060 case clang::BuiltinType::Kind::OCLImage2dArrayDepthWO:
5061 case clang::BuiltinType::Kind::OCLImage2dArrayDepthRW:
5062 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARO:
5063 case clang::BuiltinType::Kind::OCLImage2dArrayMSAAWO:
5064 case clang::BuiltinType::Kind::OCLImage2dArrayMSAARW:
5065 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRO:
5066 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthWO:
5067 case clang::BuiltinType::Kind::OCLImage2dArrayMSAADepthRW:
5068 case clang::BuiltinType::Kind::OCLImage2dDepthRO:
5069 case clang::BuiltinType::Kind::OCLImage2dDepthWO:
5070 case clang::BuiltinType::Kind::OCLImage2dDepthRW:
5071 case clang::BuiltinType::Kind::OCLImage2dMSAARO:
5072 case clang::BuiltinType::Kind::OCLImage2dMSAAWO:
5073 case clang::BuiltinType::Kind::OCLImage2dMSAARW:
5074 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRO:
5075 case clang::BuiltinType::Kind::OCLImage2dMSAADepthWO:
5076 case clang::BuiltinType::Kind::OCLImage2dMSAADepthRW:
5077 case clang::BuiltinType::Kind::OCLImage3dRO:
5078 case clang::BuiltinType::Kind::OCLImage3dWO:
5079 case clang::BuiltinType::Kind::OCLImage3dRW:
5080 case clang::BuiltinType::Kind::OCLQueue:
5081 case clang::BuiltinType::Kind::OCLReserveID:
5082 case clang::BuiltinType::Kind::OCLSampler:
5083 case clang::BuiltinType::Kind::HLSLResource:
5084 case clang::BuiltinType::Kind::ArraySection:
5085 case clang::BuiltinType::Kind::OMPArrayShaping:
5086 case clang::BuiltinType::Kind::OMPIterator:
5087 case clang::BuiltinType::Kind::Overload:
5088 case clang::BuiltinType::Kind::PseudoObject:
5089 case clang::BuiltinType::Kind::UnknownAny:
5092 case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
5093 case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
5094 case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
5095 case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
5096 case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
5097 case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
5098 case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
5099 case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
5100 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
5101 case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
5102 case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
5103 case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
5107 case clang::BuiltinType::VectorPair:
5108 case clang::BuiltinType::VectorQuad:
5109 case clang::BuiltinType::DMR1024:
5110 case clang::BuiltinType::DMR2048:
5114#define SVE_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5115#include "clang/Basic/AArch64ACLETypes.def"
5119#define RVV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5120#include "clang/Basic/RISCVVTypes.def"
5124 case clang::BuiltinType::WasmExternRef:
5127 case clang::BuiltinType::IncompleteMatrixIdx:
5130 case clang::BuiltinType::UnresolvedTemplate:
5134#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
5135 case clang::BuiltinType::Id:
5136#include "clang/Basic/AMDGPUTypes.def"
5140#define SPIRV_TYPE(Name, Id, SingletonId) case clang::BuiltinType::Id:
5141#include "clang/Basic/SPIRVTypes.def"
5147 case clang::Type::ObjCObjectPointer:
5148 case clang::Type::BlockPointer:
5149 case clang::Type::Pointer:
5150 case clang::Type::LValueReference:
5151 case clang::Type::RValueReference:
5152 case clang::Type::MemberPointer:
5154 case clang::Type::Complex: {
5156 if (qual_type->isComplexType())
5159 const clang::ComplexType *complex_type =
5160 qual_type->getAsComplexIntegerType();
5169 case clang::Type::ObjCInterface:
5171 case clang::Type::Record:
5173 case clang::Type::Enum:
5174 return qual_type->isUnsignedIntegerOrEnumerationType()
5177 case clang::Type::DependentSizedArray:
5178 case clang::Type::DependentSizedExtVector:
5179 case clang::Type::UnresolvedUsing:
5180 case clang::Type::Attributed:
5181 case clang::Type::BTFTagAttributed:
5182 case clang::Type::TemplateTypeParm:
5183 case clang::Type::SubstTemplateTypeParm:
5184 case clang::Type::SubstTemplateTypeParmPack:
5185 case clang::Type::InjectedClassName:
5186 case clang::Type::DependentName:
5187 case clang::Type::PackExpansion:
5188 case clang::Type::ObjCObject:
5190 case clang::Type::TemplateSpecialization:
5191 case clang::Type::DeducedTemplateSpecialization:
5192 case clang::Type::Adjusted:
5193 case clang::Type::Pipe:
5197 case clang::Type::Decayed:
5199 case clang::Type::ObjCTypeParam:
5202 case clang::Type::DependentAddressSpace:
5204 case clang::Type::MacroQualified:
5207 case clang::Type::ConstantMatrix:
5208 case clang::Type::DependentSizedMatrix:
5212 case clang::Type::PackIndexing:
5215 case clang::Type::HLSLAttributedResource:
5217 case clang::Type::HLSLInlineSpirv:
5219 case clang::Type::SubstBuiltinTemplatePack:
5232 switch (qual_type->getTypeClass()) {
5233 case clang::Type::Atomic:
5234 case clang::Type::Auto:
5235 case clang::Type::CountAttributed:
5236 case clang::Type::Decltype:
5237 case clang::Type::Paren:
5238 case clang::Type::Typedef:
5239 case clang::Type::TypeOf:
5240 case clang::Type::TypeOfExpr:
5241 case clang::Type::Using:
5242 case clang::Type::PredefinedSugar:
5243 llvm_unreachable(
"Handled in RemoveWrappingTypes!");
5244 case clang::Type::LateParsedAttr:
5245 llvm_unreachable(
"LateParsedAttrType is a transient parsing placeholder "
5246 "that is resolved before the AST is finalized.");
5247 case clang::Type::UnaryTransform:
5250 case clang::Type::FunctionNoProto:
5251 case clang::Type::FunctionProto:
5254 case clang::Type::IncompleteArray:
5255 case clang::Type::VariableArray:
5256 case clang::Type::ArrayParameter:
5259 case clang::Type::ConstantArray:
5262 case clang::Type::DependentVector:
5263 case clang::Type::ExtVector:
5264 case clang::Type::Vector:
5267 case clang::Type::BitInt:
5268 case clang::Type::DependentBitInt:
5269 case clang::Type::OverflowBehavior:
5273 case clang::Type::Builtin:
5274 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5275 case clang::BuiltinType::UnknownAny:
5276 case clang::BuiltinType::Void:
5277 case clang::BuiltinType::BoundMember:
5280 case clang::BuiltinType::Bool:
5282 case clang::BuiltinType::Char_S:
5283 case clang::BuiltinType::SChar:
5284 case clang::BuiltinType::WChar_S:
5285 case clang::BuiltinType::Char_U:
5286 case clang::BuiltinType::UChar:
5287 case clang::BuiltinType::WChar_U:
5289 case clang::BuiltinType::Char8:
5291 case clang::BuiltinType::Char16:
5293 case clang::BuiltinType::Char32:
5295 case clang::BuiltinType::UShort:
5297 case clang::BuiltinType::Short:
5299 case clang::BuiltinType::UInt:
5301 case clang::BuiltinType::Int:
5303 case clang::BuiltinType::ULong:
5305 case clang::BuiltinType::Long:
5307 case clang::BuiltinType::ULongLong:
5309 case clang::BuiltinType::LongLong:
5311 case clang::BuiltinType::UInt128:
5313 case clang::BuiltinType::Int128:
5315 case clang::BuiltinType::Half:
5316 case clang::BuiltinType::Float:
5317 case clang::BuiltinType::Double:
5318 case clang::BuiltinType::LongDouble:
5320 case clang::BuiltinType::Float128:
5326 case clang::Type::ObjCObjectPointer:
5328 case clang::Type::BlockPointer:
5330 case clang::Type::Pointer:
5332 case clang::Type::LValueReference:
5333 case clang::Type::RValueReference:
5335 case clang::Type::MemberPointer:
5337 case clang::Type::Complex: {
5338 if (qual_type->isComplexType())
5343 case clang::Type::ObjCInterface:
5345 case clang::Type::Record:
5347 case clang::Type::Enum:
5349 case clang::Type::DependentSizedArray:
5350 case clang::Type::DependentSizedExtVector:
5351 case clang::Type::UnresolvedUsing:
5352 case clang::Type::Attributed:
5353 case clang::Type::BTFTagAttributed:
5354 case clang::Type::TemplateTypeParm:
5355 case clang::Type::SubstTemplateTypeParm:
5356 case clang::Type::SubstTemplateTypeParmPack:
5357 case clang::Type::InjectedClassName:
5358 case clang::Type::DependentName:
5359 case clang::Type::PackExpansion:
5360 case clang::Type::ObjCObject:
5362 case clang::Type::TemplateSpecialization:
5363 case clang::Type::DeducedTemplateSpecialization:
5364 case clang::Type::Adjusted:
5365 case clang::Type::Pipe:
5369 case clang::Type::Decayed:
5371 case clang::Type::ObjCTypeParam:
5374 case clang::Type::DependentAddressSpace:
5376 case clang::Type::MacroQualified:
5380 case clang::Type::ConstantMatrix:
5381 case clang::Type::DependentSizedMatrix:
5385 case clang::Type::PackIndexing:
5388 case clang::Type::HLSLAttributedResource:
5390 case clang::Type::HLSLInlineSpirv:
5392 case clang::Type::SubstBuiltinTemplatePack:
5400 while (class_interface_decl) {
5401 if (class_interface_decl->ivar_size() > 0)
5404 class_interface_decl = class_interface_decl->getSuperClass();
5409static std::optional<SymbolFile::ArrayInfo>
5411 clang::QualType qual_type,
5413 if (qual_type->isIncompleteArrayType())
5414 if (std::optional<ClangASTMetadata> metadata =
5418 return std::nullopt;
5421llvm::Expected<uint32_t>
5423 bool omit_empty_base_classes,
5426 return llvm::createStringError(
"invalid clang type");
5428 uint32_t num_children = 0;
5430 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5431 switch (type_class) {
5432 case clang::Type::Builtin:
5433 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5434 case clang::BuiltinType::ObjCId:
5435 case clang::BuiltinType::ObjCClass:
5444 case clang::Type::Complex:
5446 case clang::Type::Record:
5448 const clang::RecordType *record_type =
5449 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5450 const clang::RecordDecl *record_decl =
5451 record_type->getDecl()->getDefinitionOrSelf();
5452 const clang::CXXRecordDecl *cxx_record_decl =
5453 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
5457 num_children += std::distance(record_decl->field_begin(),
5458 record_decl->field_end());
5460 return llvm::createStringError(
5463 case clang::Type::ObjCObject:
5464 case clang::Type::ObjCInterface:
5466 const clang::ObjCObjectType *objc_class_type =
5467 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5468 assert(objc_class_type);
5469 if (objc_class_type) {
5470 clang::ObjCInterfaceDecl *class_interface_decl =
5471 objc_class_type->getInterface();
5473 if (class_interface_decl) {
5475 clang::ObjCInterfaceDecl *superclass_interface_decl =
5476 class_interface_decl->getSuperClass();
5477 if (superclass_interface_decl) {
5478 if (omit_empty_base_classes) {
5485 num_children += class_interface_decl->ivar_size();
5491 case clang::Type::LValueReference:
5492 case clang::Type::RValueReference:
5493 case clang::Type::ObjCObjectPointer: {
5496 uint32_t num_pointee_children = 0;
5498 auto num_children_or_err =
5499 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5500 if (!num_children_or_err)
5501 return num_children_or_err;
5502 num_pointee_children = *num_children_or_err;
5505 if (num_pointee_children == 0)
5508 num_children = num_pointee_children;
5511 case clang::Type::Vector:
5512 case clang::Type::ExtVector:
5514 llvm::cast<clang::VectorType>(qual_type.getTypePtr())->getNumElements();
5517 case clang::Type::ConstantArray:
5518 num_children = llvm::cast<clang::ConstantArrayType>(qual_type.getTypePtr())
5522 case clang::Type::IncompleteArray:
5523 if (
auto array_info =
5526 num_children = array_info->element_orders.size()
5527 ? array_info->element_orders.back().value_or(0)
5531 case clang::Type::Pointer: {
5532 const clang::PointerType *pointer_type =
5533 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
5534 clang::QualType pointee_type(pointer_type->getPointeeType());
5536 uint32_t num_pointee_children = 0;
5538 auto num_children_or_err =
5539 pointee_clang_type.
GetNumChildren(omit_empty_base_classes, exe_ctx);
5540 if (!num_children_or_err)
5541 return num_children_or_err;
5542 num_pointee_children = *num_children_or_err;
5544 if (num_pointee_children == 0) {
5549 num_children = num_pointee_children;
5555 return num_children;
5562 if (name_ref.consume_front(
"unsigned _BitInt(") ||
5563 name_ref.consume_front(
"_BitInt(")) {
5565 if (name_ref.consumeInteger(10, bit_size))
5568 if (!name_ref.consume_front(
")"))
5572 name.
GetStringRef().starts_with(
"unsigned"), bit_size));
5581 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5582 if (type_class == clang::Type::Builtin) {
5583 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
5584 case clang::BuiltinType::Void:
5586 case clang::BuiltinType::Bool:
5588 case clang::BuiltinType::Char_S:
5590 case clang::BuiltinType::Char_U:
5592 case clang::BuiltinType::Char8:
5594 case clang::BuiltinType::Char16:
5596 case clang::BuiltinType::Char32:
5598 case clang::BuiltinType::UChar:
5600 case clang::BuiltinType::SChar:
5602 case clang::BuiltinType::WChar_S:
5604 case clang::BuiltinType::WChar_U:
5606 case clang::BuiltinType::Short:
5608 case clang::BuiltinType::UShort:
5610 case clang::BuiltinType::Int:
5612 case clang::BuiltinType::UInt:
5614 case clang::BuiltinType::Long:
5616 case clang::BuiltinType::ULong:
5618 case clang::BuiltinType::LongLong:
5620 case clang::BuiltinType::ULongLong:
5622 case clang::BuiltinType::Int128:
5624 case clang::BuiltinType::UInt128:
5627 case clang::BuiltinType::Half:
5629 case clang::BuiltinType::Float:
5631 case clang::BuiltinType::Double:
5633 case clang::BuiltinType::LongDouble:
5635 case clang::BuiltinType::Float128:
5638 case clang::BuiltinType::NullPtr:
5640 case clang::BuiltinType::ObjCId:
5642 case clang::BuiltinType::ObjCClass:
5644 case clang::BuiltinType::ObjCSel:
5658 const llvm::APSInt &value)>
const &callback) {
5659 const clang::EnumType *enum_type =
5662 const clang::EnumDecl *enum_decl =
5663 enum_type->getDecl()->getDefinitionOrSelf();
5667 clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
5668 for (enum_pos = enum_decl->enumerator_begin(),
5669 enum_end_pos = enum_decl->enumerator_end();
5670 enum_pos != enum_end_pos; ++enum_pos) {
5672 if (!callback(integer_type, name, enum_pos->getInitVal()))
5679#pragma mark Aggregate Types
5687 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5688 switch (type_class) {
5689 case clang::Type::Record:
5691 const clang::RecordType *record_type =
5692 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
5694 clang::RecordDecl *record_decl =
5695 record_type->getDecl()->getDefinition();
5697 count = std::distance(record_decl->field_begin(),
5698 record_decl->field_end());
5704 case clang::Type::ObjCObjectPointer: {
5705 const clang::ObjCObjectPointerType *objc_class_type =
5706 qual_type->castAs<clang::ObjCObjectPointerType>();
5707 const clang::ObjCInterfaceType *objc_interface_type =
5708 objc_class_type->getInterfaceType();
5709 if (objc_interface_type &&
5711 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5712 clang::ObjCInterfaceDecl *class_interface_decl =
5713 objc_interface_type->getDecl();
5714 if (class_interface_decl) {
5715 count = class_interface_decl->ivar_size();
5721 case clang::Type::ObjCObject:
5722 case clang::Type::ObjCInterface:
5724 const clang::ObjCObjectType *objc_class_type =
5725 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5726 if (objc_class_type) {
5727 clang::ObjCInterfaceDecl *class_interface_decl =
5728 objc_class_type->getInterface();
5730 if (class_interface_decl)
5731 count = class_interface_decl->ivar_size();
5744 clang::ObjCInterfaceDecl *class_interface_decl,
size_t idx,
5745 std::string &name, uint64_t *bit_offset_ptr,
5746 uint32_t *bitfield_bit_size_ptr,
bool *is_bitfield_ptr) {
5747 if (class_interface_decl) {
5748 if (idx < (class_interface_decl->ivar_size())) {
5749 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
5750 ivar_end = class_interface_decl->ivar_end();
5751 uint32_t ivar_idx = 0;
5753 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
5754 ++ivar_pos, ++ivar_idx) {
5755 if (ivar_idx == idx) {
5756 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
5758 clang::QualType ivar_qual_type(ivar_decl->getType());
5760 name.assign(ivar_decl->getNameAsString());
5762 if (bit_offset_ptr) {
5763 const clang::ASTRecordLayout &interface_layout =
5764 ast->getASTObjCInterfaceLayout(class_interface_decl);
5765 *bit_offset_ptr = interface_layout.getFieldOffset(ivar_idx);
5768 const bool is_bitfield = ivar_pos->isBitField();
5770 if (bitfield_bit_size_ptr) {
5771 *bitfield_bit_size_ptr = 0;
5773 if (is_bitfield && ast) {
5774 clang::Expr *bitfield_bit_size_expr = ivar_pos->getBitWidth();
5775 clang::Expr::EvalResult result;
5776 if (bitfield_bit_size_expr &&
5777 bitfield_bit_size_expr->EvaluateAsInt(result, *ast)) {
5778 llvm::APSInt bitfield_apsint = result.Val.getInt();
5779 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5783 if (is_bitfield_ptr)
5784 *is_bitfield_ptr = is_bitfield;
5786 return ivar_qual_type.getAsOpaquePtr();
5795 size_t idx, std::string &name,
5796 uint64_t *bit_offset_ptr,
5797 uint32_t *bitfield_bit_size_ptr,
5798 bool *is_bitfield_ptr) {
5803 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5804 switch (type_class) {
5805 case clang::Type::Record:
5807 const clang::RecordType *record_type =
5808 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
5809 const clang::RecordDecl *record_decl =
5810 record_type->getDecl()->getDefinitionOrSelf();
5811 uint32_t field_idx = 0;
5812 clang::RecordDecl::field_iterator field, field_end;
5813 for (field = record_decl->field_begin(),
5814 field_end = record_decl->field_end();
5815 field != field_end; ++field, ++field_idx) {
5816 if (idx == field_idx) {
5819 name.assign(field->getNameAsString());
5823 if (bit_offset_ptr) {
5824 const clang::ASTRecordLayout &record_layout =
5826 *bit_offset_ptr = record_layout.getFieldOffset(field_idx);
5829 const bool is_bitfield = field->isBitField();
5831 if (bitfield_bit_size_ptr) {
5832 *bitfield_bit_size_ptr = 0;
5835 clang::Expr *bitfield_bit_size_expr = field->getBitWidth();
5836 clang::Expr::EvalResult result;
5837 if (bitfield_bit_size_expr &&
5838 bitfield_bit_size_expr->EvaluateAsInt(result,
5840 llvm::APSInt bitfield_apsint = result.Val.getInt();
5841 *bitfield_bit_size_ptr = bitfield_apsint.getLimitedValue();
5845 if (is_bitfield_ptr)
5846 *is_bitfield_ptr = is_bitfield;
5848 return GetType(field->getType());
5854 case clang::Type::ObjCObjectPointer: {
5855 const clang::ObjCObjectPointerType *objc_class_type =
5856 qual_type->castAs<clang::ObjCObjectPointerType>();
5857 const clang::ObjCInterfaceType *objc_interface_type =
5858 objc_class_type->getInterfaceType();
5859 if (objc_interface_type &&
5861 const_cast<clang::ObjCInterfaceType *
>(objc_interface_type)))) {
5862 clang::ObjCInterfaceDecl *class_interface_decl =
5863 objc_interface_type->getDecl();
5864 if (class_interface_decl) {
5868 name, bit_offset_ptr, bitfield_bit_size_ptr,
5875 case clang::Type::ObjCObject:
5876 case clang::Type::ObjCInterface:
5878 const clang::ObjCObjectType *objc_class_type =
5879 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
5880 assert(objc_class_type);
5881 if (objc_class_type) {
5882 clang::ObjCInterfaceDecl *class_interface_decl =
5883 objc_class_type->getInterface();
5887 name, bit_offset_ptr, bitfield_bit_size_ptr,
5903 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5904 switch (type_class) {
5905 case clang::Type::Record:
5907 const clang::CXXRecordDecl *cxx_record_decl =
5908 qual_type->getAsCXXRecordDecl();
5909 if (cxx_record_decl)
5910 count = cxx_record_decl->getNumBases();
5914 case clang::Type::ObjCObjectPointer:
5918 case clang::Type::ObjCObject:
5920 const clang::ObjCObjectType *objc_class_type =
5921 qual_type->getAsObjCQualifiedInterfaceType();
5922 if (objc_class_type) {
5923 clang::ObjCInterfaceDecl *class_interface_decl =
5924 objc_class_type->getInterface();
5926 if (class_interface_decl && class_interface_decl->getSuperClass())
5931 case clang::Type::ObjCInterface:
5933 const clang::ObjCInterfaceType *objc_interface_type =
5934 qual_type->getAs<clang::ObjCInterfaceType>();
5935 if (objc_interface_type) {
5936 clang::ObjCInterfaceDecl *class_interface_decl =
5937 objc_interface_type->getInterface();
5939 if (class_interface_decl && class_interface_decl->getSuperClass())
5955 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5956 switch (type_class) {
5957 case clang::Type::Record:
5959 const clang::CXXRecordDecl *cxx_record_decl =
5960 qual_type->getAsCXXRecordDecl();
5961 if (cxx_record_decl)
5962 count = cxx_record_decl->getNumVBases();
5975 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
5976 switch (type_class) {
5977 case clang::Type::Record:
5979 const clang::CXXRecordDecl *cxx_record_decl =
5980 qual_type->getAsCXXRecordDecl();
5981 if (cxx_record_decl) {
5982 uint32_t curr_idx = 0;
5983 clang::CXXRecordDecl::base_class_const_iterator base_class,
5985 for (base_class = cxx_record_decl->bases_begin(),
5986 base_class_end = cxx_record_decl->bases_end();
5987 base_class != base_class_end; ++base_class, ++curr_idx) {
5988 if (curr_idx == idx) {
5989 if (bit_offset_ptr) {
5990 const clang::ASTRecordLayout &record_layout =
5992 const clang::CXXRecordDecl *base_class_decl =
5993 llvm::cast<clang::CXXRecordDecl>(
5994 base_class->getType()
5995 ->castAs<clang::RecordType>()
5997 if (base_class->isVirtual())
5999 record_layout.getVBaseClassOffset(base_class_decl)
6004 record_layout.getBaseClassOffset(base_class_decl)
6008 return GetType(base_class->getType());
6015 case clang::Type::ObjCObjectPointer:
6018 case clang::Type::ObjCObject:
6020 const clang::ObjCObjectType *objc_class_type =
6021 qual_type->getAsObjCQualifiedInterfaceType();
6022 if (objc_class_type) {
6023 clang::ObjCInterfaceDecl *class_interface_decl =
6024 objc_class_type->getInterface();
6026 if (class_interface_decl) {
6027 clang::ObjCInterfaceDecl *superclass_interface_decl =
6028 class_interface_decl->getSuperClass();
6029 if (superclass_interface_decl) {
6031 *bit_offset_ptr = 0;
6033 superclass_interface_decl));
6039 case clang::Type::ObjCInterface:
6041 const clang::ObjCObjectType *objc_interface_type =
6042 qual_type->getAs<clang::ObjCInterfaceType>();
6043 if (objc_interface_type) {
6044 clang::ObjCInterfaceDecl *class_interface_decl =
6045 objc_interface_type->getInterface();
6047 if (class_interface_decl) {
6048 clang::ObjCInterfaceDecl *superclass_interface_decl =
6049 class_interface_decl->getSuperClass();
6050 if (superclass_interface_decl) {
6052 *bit_offset_ptr = 0;
6054 superclass_interface_decl));
6070 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6071 switch (type_class) {
6072 case clang::Type::Record:
6074 const clang::CXXRecordDecl *cxx_record_decl =
6075 qual_type->getAsCXXRecordDecl();
6076 if (cxx_record_decl) {
6077 uint32_t curr_idx = 0;
6078 clang::CXXRecordDecl::base_class_const_iterator base_class,
6080 for (base_class = cxx_record_decl->vbases_begin(),
6081 base_class_end = cxx_record_decl->vbases_end();
6082 base_class != base_class_end; ++base_class, ++curr_idx) {
6083 if (curr_idx == idx) {
6084 if (bit_offset_ptr) {
6085 const clang::ASTRecordLayout &record_layout =
6087 const clang::CXXRecordDecl *base_class_decl =
6088 llvm::cast<clang::CXXRecordDecl>(
6089 base_class->getType()
6090 ->castAs<clang::RecordType>()
6093 record_layout.getVBaseClassOffset(base_class_decl)
6097 return GetType(base_class->getType());
6112 llvm::StringRef name) {
6114 switch (qual_type->getTypeClass()) {
6115 case clang::Type::Record: {
6119 const clang::RecordType *record_type =
6120 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6121 const clang::RecordDecl *record_decl =
6122 record_type->getDecl()->getDefinitionOrSelf();
6124 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
6125 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
6126 auto *var_decl = dyn_cast<clang::VarDecl>(decl);
6127 if (!var_decl || var_decl->getStorageClass() != clang::SC_Static)
6151 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6152 switch (type_class) {
6153 case clang::Type::Builtin:
6154 switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
6155 case clang::BuiltinType::UnknownAny:
6156 case clang::BuiltinType::Void:
6157 case clang::BuiltinType::NullPtr:
6158 case clang::BuiltinType::OCLEvent:
6159 case clang::BuiltinType::OCLImage1dRO:
6160 case clang::BuiltinType::OCLImage1dWO:
6161 case clang::BuiltinType::OCLImage1dRW:
6162 case clang::BuiltinType::OCLImage1dArrayRO:
6163 case clang::BuiltinType::OCLImage1dArrayWO:
6164 case clang::BuiltinType::OCLImage1dArrayRW:
6165 case clang::BuiltinType::OCLImage1dBufferRO:
6166 case clang::BuiltinType::OCLImage1dBufferWO:
6167 case clang::BuiltinType::OCLImage1dBufferRW:
6168 case clang::BuiltinType::OCLImage2dRO:
6169 case clang::BuiltinType::OCLImage2dWO:
6170 case clang::BuiltinType::OCLImage2dRW:
6171 case clang::BuiltinType::OCLImage2dArrayRO:
6172 case clang::BuiltinType::OCLImage2dArrayWO:
6173 case clang::BuiltinType::OCLImage2dArrayRW:
6174 case clang::BuiltinType::OCLImage3dRO:
6175 case clang::BuiltinType::OCLImage3dWO:
6176 case clang::BuiltinType::OCLImage3dRW:
6177 case clang::BuiltinType::OCLSampler:
6178 case clang::BuiltinType::HLSLResource:
6180 case clang::BuiltinType::Bool:
6181 case clang::BuiltinType::Char_U:
6182 case clang::BuiltinType::UChar:
6183 case clang::BuiltinType::WChar_U:
6184 case clang::BuiltinType::Char16:
6185 case clang::BuiltinType::Char32:
6186 case clang::BuiltinType::UShort:
6187 case clang::BuiltinType::UInt:
6188 case clang::BuiltinType::ULong:
6189 case clang::BuiltinType::ULongLong:
6190 case clang::BuiltinType::UInt128:
6191 case clang::BuiltinType::Char_S:
6192 case clang::BuiltinType::SChar:
6193 case clang::BuiltinType::WChar_S:
6194 case clang::BuiltinType::Short:
6195 case clang::BuiltinType::Int:
6196 case clang::BuiltinType::Long:
6197 case clang::BuiltinType::LongLong:
6198 case clang::BuiltinType::Int128:
6199 case clang::BuiltinType::Float:
6200 case clang::BuiltinType::Double:
6201 case clang::BuiltinType::LongDouble:
6202 case clang::BuiltinType::Float128:
6203 case clang::BuiltinType::Dependent:
6204 case clang::BuiltinType::Overload:
6205 case clang::BuiltinType::ObjCId:
6206 case clang::BuiltinType::ObjCClass:
6207 case clang::BuiltinType::ObjCSel:
6208 case clang::BuiltinType::BoundMember:
6209 case clang::BuiltinType::Half:
6210 case clang::BuiltinType::ARCUnbridgedCast:
6211 case clang::BuiltinType::PseudoObject:
6212 case clang::BuiltinType::BuiltinFn:
6213 case clang::BuiltinType::ArraySection:
6220 case clang::Type::Complex:
6222 case clang::Type::Pointer:
6224 case clang::Type::BlockPointer:
6227 case clang::Type::LValueReference:
6229 case clang::Type::RValueReference:
6231 case clang::Type::MemberPointer:
6233 case clang::Type::ConstantArray:
6235 case clang::Type::IncompleteArray:
6237 case clang::Type::VariableArray:
6239 case clang::Type::DependentSizedArray:
6241 case clang::Type::DependentSizedExtVector:
6243 case clang::Type::Vector:
6245 case clang::Type::ExtVector:
6247 case clang::Type::FunctionProto:
6249 case clang::Type::FunctionNoProto:
6251 case clang::Type::UnresolvedUsing:
6253 case clang::Type::Record:
6255 case clang::Type::Enum:
6257 case clang::Type::TemplateTypeParm:
6259 case clang::Type::SubstTemplateTypeParm:
6261 case clang::Type::TemplateSpecialization:
6263 case clang::Type::InjectedClassName:
6265 case clang::Type::DependentName:
6267 case clang::Type::ObjCObject:
6269 case clang::Type::ObjCInterface:
6271 case clang::Type::ObjCObjectPointer:
6281 std::string &deref_name, uint32_t &deref_byte_size,
6282 int32_t &deref_byte_offset,
ValueObject *valobj, uint64_t &language_flags) {
6286 return llvm::createStringError(
"not a pointer, reference or array type");
6287 uint32_t child_bitfield_bit_size = 0;
6288 uint32_t child_bitfield_bit_offset = 0;
6289 bool child_is_base_class;
6290 bool child_is_deref_of_parent;
6292 type, exe_ctx, 0,
false,
true,
false, deref_name, deref_byte_size,
6293 deref_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
6294 child_is_base_class, child_is_deref_of_parent, valobj, language_flags);
6299 bool transparent_pointers,
bool omit_empty_base_classes,
6300 bool ignore_array_bounds, std::string &child_name,
6301 uint32_t &child_byte_size, int32_t &child_byte_offset,
6302 uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
6303 bool &child_is_base_class,
bool &child_is_deref_of_parent,
6306 return llvm::createStringError(
"invalid type");
6308 auto get_exe_scope = [&exe_ctx]() {
6312 clang::QualType parent_qual_type(
6314 const clang::Type::TypeClass parent_type_class =
6315 parent_qual_type->getTypeClass();
6316 child_bitfield_bit_size = 0;
6317 child_bitfield_bit_offset = 0;
6318 child_is_base_class =
false;
6321 auto num_children_or_err =
6323 if (!num_children_or_err)
6324 return num_children_or_err.takeError();
6326 const bool idx_is_valid = idx < *num_children_or_err;
6328 switch (parent_type_class) {
6329 case clang::Type::Builtin:
6331 return llvm::createStringError(
"invalid index");
6333 switch (llvm::cast<clang::BuiltinType>(parent_qual_type)->getKind()) {
6334 case clang::BuiltinType::ObjCId:
6335 case clang::BuiltinType::ObjCClass:
6346 case clang::Type::Record: {
6348 return llvm::createStringError(
"invalid index");
6350 return llvm::createStringError(
"cannot complete type");
6352 const clang::RecordType *record_type =
6353 llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
6354 const clang::RecordDecl *record_decl =
6355 record_type->getDecl()->getDefinitionOrSelf();
6356 const clang::ASTRecordLayout &record_layout =
6358 uint32_t child_idx = 0;
6360 const clang::CXXRecordDecl *cxx_record_decl =
6361 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6362 if (cxx_record_decl) {
6364 clang::CXXRecordDecl::base_class_const_iterator base_class,
6366 for (base_class = cxx_record_decl->bases_begin(),
6367 base_class_end = cxx_record_decl->bases_end();
6368 base_class != base_class_end; ++base_class) {
6369 const clang::CXXRecordDecl *base_class_decl =
nullptr;
6372 if (omit_empty_base_classes) {
6374 llvm::cast<clang::CXXRecordDecl>(
6375 base_class->getType()->getAs<clang::RecordType>()->getDecl())
6376 ->getDefinitionOrSelf();
6381 if (idx == child_idx) {
6382 if (base_class_decl ==
nullptr)
6383 base_class_decl = llvm::cast<clang::CXXRecordDecl>(
6384 base_class->getType()
6385 ->getAs<clang::RecordType>()
6387 ->getDefinitionOrSelf();
6389 if (base_class->isVirtual()) {
6390 bool handled =
false;
6392 clang::VTableContextBase *vtable_ctx =
6396 cxx_record_decl, base_class_decl,
6400 bit_offset = record_layout.getVBaseClassOffset(base_class_decl)
6404 bit_offset = record_layout.getBaseClassOffset(base_class_decl)
6409 child_byte_offset = bit_offset / 8;
6412 auto size_or_err = base_class_clang_type.
GetBitSize(get_exe_scope());
6414 return llvm::joinErrors(
6415 llvm::createStringError(
"no size info for base class"),
6416 size_or_err.takeError());
6418 uint64_t base_class_clang_type_bit_size = *size_or_err;
6421 assert(base_class_clang_type_bit_size % 8 == 0);
6422 child_byte_size = base_class_clang_type_bit_size / 8;
6423 child_is_base_class =
true;
6424 return base_class_clang_type;
6432 uint32_t field_idx = 0;
6433 clang::RecordDecl::field_iterator field, field_end;
6434 for (field = record_decl->field_begin(),
6435 field_end = record_decl->field_end();
6436 field != field_end; ++field, ++field_idx, ++child_idx) {
6437 if (idx == child_idx) {
6440 child_name.assign(field->getNameAsString());
6445 assert(field_idx < record_layout.getFieldCount());
6446 auto size_or_err = field_clang_type.
GetByteSize(get_exe_scope());
6448 return llvm::joinErrors(
6449 llvm::createStringError(
"no size info for field"),
6450 size_or_err.takeError());
6452 child_byte_size = *size_or_err;
6453 const uint32_t child_bit_size = child_byte_size * 8;
6457 bit_offset = record_layout.getFieldOffset(field_idx);
6459 child_bitfield_bit_offset = bit_offset % child_bit_size;
6460 const uint32_t child_bit_offset =
6461 bit_offset - child_bitfield_bit_offset;
6462 child_byte_offset = child_bit_offset / 8;
6464 child_byte_offset = bit_offset / 8;
6467 return field_clang_type;
6471 case clang::Type::ObjCObject:
6472 case clang::Type::ObjCInterface: {
6474 return llvm::createStringError(
"invalid index");
6476 return llvm::createStringError(
"cannot complete type");
6478 const clang::ObjCObjectType *objc_class_type =
6479 llvm::dyn_cast<clang::ObjCObjectType>(parent_qual_type.getTypePtr());
6480 assert(objc_class_type);
6481 if (!objc_class_type)
6482 return llvm::createStringError(
"unexpected object type");
6484 uint32_t child_idx = 0;
6485 clang::ObjCInterfaceDecl *class_interface_decl =
6486 objc_class_type->getInterface();
6488 if (!class_interface_decl)
6489 return llvm::createStringError(
"cannot get interface decl");
6491 const clang::ASTRecordLayout &interface_layout =
6492 getASTContext().getASTObjCInterfaceLayout(class_interface_decl);
6493 clang::ObjCInterfaceDecl *superclass_interface_decl =
6494 class_interface_decl->getSuperClass();
6495 if (superclass_interface_decl) {
6496 if (omit_empty_base_classes) {
6498 getASTContext().getObjCInterfaceType(superclass_interface_decl));
6499 if (llvm::expectedToOptional(base_class_clang_type.
GetNumChildren(
6500 omit_empty_base_classes, exe_ctx))
6503 clang::QualType ivar_qual_type(
getASTContext().getObjCInterfaceType(
6504 superclass_interface_decl));
6506 child_name.assign(superclass_interface_decl->getNameAsString());
6508 clang::TypeInfo ivar_type_info =
6511 child_byte_size = ivar_type_info.Width / 8;
6512 child_byte_offset = 0;
6513 child_is_base_class =
true;
6515 return GetType(ivar_qual_type);
6524 const uint32_t superclass_idx = child_idx;
6526 if (idx < (child_idx + class_interface_decl->ivar_size())) {
6527 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6528 ivar_end = class_interface_decl->ivar_end();
6530 for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end;
6532 if (child_idx == idx) {
6533 clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6535 clang::QualType ivar_qual_type(ivar_decl->getType());
6537 child_name.assign(ivar_decl->getNameAsString());
6539 clang::TypeInfo ivar_type_info =
6542 child_byte_size = ivar_type_info.Width / 8;
6558 if (objc_runtime !=
nullptr) {
6561 parent_ast_type, ivar_decl->getNameAsString().c_str());
6569 if (child_byte_offset ==
6572 interface_layout.getFieldOffset(child_idx - superclass_idx);
6573 child_byte_offset = bit_offset / 8;
6585 interface_layout.getFieldOffset(child_idx - superclass_idx);
6587 child_bitfield_bit_offset = bit_offset % 8;
6589 return GetType(ivar_qual_type);
6596 case clang::Type::ObjCObjectPointer: {
6598 return llvm::createStringError(
"invalid index");
6602 child_is_deref_of_parent =
false;
6603 bool tmp_child_is_deref_of_parent =
false;
6605 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6606 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6607 child_bitfield_bit_size, child_bitfield_bit_offset,
6608 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6611 child_is_deref_of_parent =
true;
6612 const char *parent_name =
6615 child_name.assign(1,
'*');
6616 child_name += parent_name;
6621 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6623 return size_or_err.takeError();
6624 child_byte_size = *size_or_err;
6625 child_byte_offset = 0;
6626 return pointee_clang_type;
6631 case clang::Type::Vector:
6632 case clang::Type::ExtVector: {
6634 return llvm::createStringError(
"invalid index");
6635 const clang::VectorType *array =
6636 llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
6638 return llvm::createStringError(
"unexpected vector type");
6642 return llvm::createStringError(
"cannot complete type");
6644 char element_name[64];
6645 ::snprintf(element_name,
sizeof(element_name),
"[%" PRIu64
"]",
6646 static_cast<uint64_t
>(idx));
6647 child_name.assign(element_name);
6648 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6650 return size_or_err.takeError();
6651 child_byte_size = *size_or_err;
6652 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6653 return element_type;
6655 case clang::Type::ConstantArray:
6656 case clang::Type::IncompleteArray: {
6657 if (!ignore_array_bounds && !idx_is_valid)
6658 return llvm::createStringError(
"invalid index");
6659 const clang::ArrayType *array =
GetQualType(type)->getAsArrayTypeUnsafe();
6661 return llvm::createStringError(
"unexpected array type");
6664 return llvm::createStringError(
"cannot complete type");
6666 child_name = std::string(llvm::formatv(
"[{0}]", idx));
6667 auto size_or_err = element_type.
GetByteSize(get_exe_scope());
6669 return size_or_err.takeError();
6670 child_byte_size = *size_or_err;
6671 child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
6672 return element_type;
6674 case clang::Type::Pointer: {
6679 return llvm::createStringError(
"cannot dereference void *");
6682 child_is_deref_of_parent =
false;
6683 bool tmp_child_is_deref_of_parent =
false;
6685 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6686 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6687 child_bitfield_bit_size, child_bitfield_bit_offset,
6688 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6691 child_is_deref_of_parent =
true;
6695 child_name.assign(1,
'*');
6696 child_name += parent_name;
6701 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6703 return size_or_err.takeError();
6704 child_byte_size = *size_or_err;
6705 child_byte_offset = 0;
6706 return pointee_clang_type;
6711 case clang::Type::LValueReference:
6712 case clang::Type::RValueReference: {
6714 return llvm::createStringError(
"invalid index");
6715 const clang::ReferenceType *reference_type =
6716 llvm::cast<clang::ReferenceType>(
6720 child_is_deref_of_parent =
false;
6721 bool tmp_child_is_deref_of_parent =
false;
6723 exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
6724 ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
6725 child_bitfield_bit_size, child_bitfield_bit_offset,
6726 child_is_base_class, tmp_child_is_deref_of_parent, valobj,
6731 child_name.assign(1,
'&');
6732 child_name += parent_name;
6737 auto size_or_err = pointee_clang_type.
GetByteSize(get_exe_scope());
6739 return size_or_err.takeError();
6740 child_byte_size = *size_or_err;
6741 child_byte_offset = 0;
6742 return pointee_clang_type;
6749 return llvm::createStringError(
"cannot enumerate children");
6753 const clang::RecordDecl *record_decl,
6754 const clang::CXXBaseSpecifier *base_spec,
6755 bool omit_empty_base_classes) {
6756 uint32_t child_idx = 0;
6758 const clang::CXXRecordDecl *cxx_record_decl =
6759 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6761 if (cxx_record_decl) {
6762 clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
6763 for (base_class = cxx_record_decl->bases_begin(),
6764 base_class_end = cxx_record_decl->bases_end();
6765 base_class != base_class_end; ++base_class) {
6766 if (omit_empty_base_classes) {
6771 if (base_class == base_spec)
6781 const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl,
6782 bool omit_empty_base_classes) {
6784 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
6785 omit_empty_base_classes);
6787 clang::RecordDecl::field_iterator field, field_end;
6788 for (field = record_decl->field_begin(), field_end = record_decl->field_end();
6789 field != field_end; ++field, ++child_idx) {
6790 if (field->getCanonicalDecl() == canonical_decl)
6832 bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
6833 if (type && !name.empty()) {
6835 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
6836 switch (type_class) {
6837 case clang::Type::Record:
6839 const clang::RecordType *record_type =
6840 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
6841 const clang::RecordDecl *record_decl =
6842 record_type->getDecl()->getDefinitionOrSelf();
6844 assert(record_decl);
6845 uint32_t child_idx = 0;
6847 const clang::CXXRecordDecl *cxx_record_decl =
6848 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
6851 clang::RecordDecl::field_iterator field, field_end;
6852 for (field = record_decl->field_begin(),
6853 field_end = record_decl->field_end();
6854 field != field_end; ++field, ++child_idx) {
6855 llvm::StringRef field_name = field->getName();
6856 if (field_name.empty()) {
6858 std::vector<uint32_t> save_indices = child_indexes;
6859 child_indexes.push_back(
6861 cxx_record_decl, omit_empty_base_classes));
6863 name, omit_empty_base_classes, child_indexes))
6864 return child_indexes.size();
6865 child_indexes = std::move(save_indices);
6866 }
else if (field_name == name) {
6868 child_indexes.push_back(
6870 cxx_record_decl, omit_empty_base_classes));
6871 return child_indexes.size();
6875 if (cxx_record_decl) {
6876 const clang::RecordDecl *parent_record_decl = cxx_record_decl;
6879 clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name);
6880 clang::DeclarationName decl_name(&ident_ref);
6882 clang::CXXBasePaths paths;
6883 if (cxx_record_decl->lookupInBases(
6884 [decl_name](
const clang::CXXBaseSpecifier *specifier,
6885 clang::CXXBasePath &path) {
6886 CXXRecordDecl *record =
6887 specifier->getType()->getAsCXXRecordDecl();
6888 auto r = record->lookup(decl_name);
6889 path.Decls = r.begin();
6893 clang::CXXBasePaths::const_paths_iterator path,
6894 path_end = paths.end();
6895 for (path = paths.begin(); path != path_end; ++path) {
6896 const size_t num_path_elements = path->size();
6897 for (
size_t e = 0; e < num_path_elements; ++e) {
6898 clang::CXXBasePathElement elem = (*path)[e];
6901 omit_empty_base_classes);
6903 child_indexes.clear();
6906 child_indexes.push_back(child_idx);
6907 parent_record_decl = elem.Base->getType()
6908 ->castAs<clang::RecordType>()
6910 ->getDefinitionOrSelf();
6913 for (clang::DeclContext::lookup_iterator I = path->Decls, E;
6916 parent_record_decl, *I, omit_empty_base_classes);
6918 child_indexes.clear();
6921 child_indexes.push_back(child_idx);
6925 return child_indexes.size();
6931 case clang::Type::ObjCObject:
6932 case clang::Type::ObjCInterface:
6934 llvm::StringRef name_sref(name);
6935 const clang::ObjCObjectType *objc_class_type =
6936 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
6937 assert(objc_class_type);
6938 if (objc_class_type) {
6939 uint32_t child_idx = 0;
6940 clang::ObjCInterfaceDecl *class_interface_decl =
6941 objc_class_type->getInterface();
6943 if (class_interface_decl) {
6944 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
6945 ivar_end = class_interface_decl->ivar_end();
6946 clang::ObjCInterfaceDecl *superclass_interface_decl =
6947 class_interface_decl->getSuperClass();
6949 for (ivar_pos = class_interface_decl->ivar_begin();
6950 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
6951 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
6953 if (ivar_decl->getName() == name_sref) {
6954 if ((!omit_empty_base_classes && superclass_interface_decl) ||
6955 (omit_empty_base_classes &&
6959 child_indexes.push_back(child_idx);
6960 return child_indexes.size();
6964 if (superclass_interface_decl) {
6968 child_indexes.push_back(0);
6972 superclass_interface_decl));
6974 name, omit_empty_base_classes, child_indexes)) {
6977 return child_indexes.size();
6982 child_indexes.pop_back();
6989 case clang::Type::ObjCObjectPointer: {
6991 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
6992 ->getPointeeType());
6994 name, omit_empty_base_classes, child_indexes);
6997 case clang::Type::LValueReference:
6998 case clang::Type::RValueReference: {
6999 const clang::ReferenceType *reference_type =
7000 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7001 clang::QualType pointee_type(reference_type->getPointeeType());
7006 name, omit_empty_base_classes, child_indexes);
7010 case clang::Type::Pointer: {
7015 name, omit_empty_base_classes, child_indexes);
7030llvm::Expected<uint32_t>
7032 llvm::StringRef name,
7033 bool omit_empty_base_classes) {
7034 if (type && !name.empty()) {
7037 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7039 switch (type_class) {
7040 case clang::Type::Record:
7042 const clang::RecordType *record_type =
7043 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7044 const clang::RecordDecl *record_decl =
7045 record_type->getDecl()->getDefinitionOrSelf();
7047 assert(record_decl);
7048 uint32_t child_idx = 0;
7050 const clang::CXXRecordDecl *cxx_record_decl =
7051 llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
7053 if (cxx_record_decl) {
7054 clang::CXXRecordDecl::base_class_const_iterator base_class,
7056 for (base_class = cxx_record_decl->bases_begin(),
7057 base_class_end = cxx_record_decl->bases_end();
7058 base_class != base_class_end; ++base_class) {
7060 clang::CXXRecordDecl *base_class_decl =
7061 llvm::cast<clang::CXXRecordDecl>(
7062 base_class->getType()
7063 ->castAs<clang::RecordType>()
7065 ->getDefinitionOrSelf();
7066 if (omit_empty_base_classes &&
7071 std::string base_class_type_name(
7073 if (base_class_type_name == name)
7080 clang::RecordDecl::field_iterator field, field_end;
7081 for (field = record_decl->field_begin(),
7082 field_end = record_decl->field_end();
7083 field != field_end; ++field, ++child_idx) {
7084 if (field->getName() == name)
7090 case clang::Type::ObjCObject:
7091 case clang::Type::ObjCInterface:
7093 const clang::ObjCObjectType *objc_class_type =
7094 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
7095 assert(objc_class_type);
7096 if (objc_class_type) {
7097 uint32_t child_idx = 0;
7098 clang::ObjCInterfaceDecl *class_interface_decl =
7099 objc_class_type->getInterface();
7101 if (class_interface_decl) {
7102 clang::ObjCInterfaceDecl::ivar_iterator ivar_pos,
7103 ivar_end = class_interface_decl->ivar_end();
7104 clang::ObjCInterfaceDecl *superclass_interface_decl =
7105 class_interface_decl->getSuperClass();
7107 for (ivar_pos = class_interface_decl->ivar_begin();
7108 ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
7109 const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
7111 if (ivar_decl->getName() == name) {
7112 if ((!omit_empty_base_classes && superclass_interface_decl) ||
7113 (omit_empty_base_classes &&
7121 if (superclass_interface_decl) {
7122 if (superclass_interface_decl->getName() == name)
7130 case clang::Type::ObjCObjectPointer: {
7132 llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
7133 ->getPointeeType());
7135 name, omit_empty_base_classes);
7138 case clang::Type::LValueReference:
7139 case clang::Type::RValueReference: {
7140 const clang::ReferenceType *reference_type =
7141 llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
7146 omit_empty_base_classes);
7150 case clang::Type::Pointer: {
7151 const clang::PointerType *pointer_type =
7152 llvm::cast<clang::PointerType>(qual_type.getTypePtr());
7157 omit_empty_base_classes);
7165 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
7170 llvm::StringRef name) {
7171 if (!type || name.empty())
7175 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7177 switch (type_class) {
7178 case clang::Type::Record: {
7181 const clang::RecordType *record_type =
7182 llvm::cast<clang::RecordType>(qual_type.getTypePtr());
7183 const clang::RecordDecl *record_decl =
7184 record_type->getDecl()->getDefinitionOrSelf();
7186 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7187 for (NamedDecl *decl : record_decl->lookup(decl_name)) {
7188 if (
auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
7190 if (
auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
7192 ElaboratedTypeKeyword::None, std::nullopt,
7208 if (
auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
7209 return isa<clang::ClassTemplateSpecializationDecl>(
7210 cxx_record_decl->getDecl());
7221 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7222 switch (type_class) {
7223 case clang::Type::Record:
7225 const clang::CXXRecordDecl *cxx_record_decl =
7226 qual_type->getAsCXXRecordDecl();
7227 if (cxx_record_decl) {
7228 const clang::ClassTemplateSpecializationDecl *template_decl =
7229 llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7231 if (template_decl) {
7232 const auto &template_arg_list = template_decl->getTemplateArgs();
7233 size_t num_args = template_arg_list.size();
7234 assert(num_args &&
"template specialization without any args");
7235 if (expand_pack && num_args) {
7236 const auto &pack = template_arg_list[num_args - 1];
7237 if (pack.getKind() == clang::TemplateArgument::Pack)
7238 num_args += pack.pack_size() - 1;
7253const clang::ClassTemplateSpecializationDecl *
7260 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
7261 switch (type_class) {
7262 case clang::Type::Record: {
7265 const clang::CXXRecordDecl *cxx_record_decl =
7266 qual_type->getAsCXXRecordDecl();
7267 if (!cxx_record_decl)
7269 return llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
7278const TemplateArgument *
7280 size_t idx,
bool expand_pack) {
7281 const auto &args = decl->getTemplateArgs();
7282 const size_t args_size = args.size();
7284 assert(args_size &&
"template specialization without any args");
7288 const size_t last_idx = args_size - 1;
7297 if (!expand_pack || args[last_idx].getKind() != clang::TemplateArgument::Pack)
7298 return idx >= args.size() ? nullptr : &args[idx];
7303 const auto &pack = args[last_idx];
7304 const size_t pack_idx = idx - last_idx;
7305 if (pack_idx >= pack.pack_size())
7307 return &pack.pack_elements()[pack_idx];
7312 size_t arg_idx,
bool expand_pack) {
7313 const clang::ClassTemplateSpecializationDecl *template_decl =
7322 switch (arg->getKind()) {
7323 case clang::TemplateArgument::Null:
7326 case clang::TemplateArgument::NullPtr:
7329 case clang::TemplateArgument::Type:
7332 case clang::TemplateArgument::Declaration:
7335 case clang::TemplateArgument::Integral:
7338 case clang::TemplateArgument::Template:
7341 case clang::TemplateArgument::TemplateExpansion:
7344 case clang::TemplateArgument::Expression:
7347 case clang::TemplateArgument::Pack:
7350 case clang::TemplateArgument::StructuralValue:
7353 llvm_unreachable(
"Unhandled clang::TemplateArgument::ArgKind");
7358 size_t idx,
bool expand_pack) {
7359 const clang::ClassTemplateSpecializationDecl *template_decl =
7365 if (!arg || arg->getKind() != clang::TemplateArgument::Type)
7368 return GetType(arg->getAsType());
7371std::optional<CompilerType::IntegralTemplateArgument>
7373 size_t idx,
bool expand_pack) {
7374 const clang::ClassTemplateSpecializationDecl *template_decl =
7377 return std::nullopt;
7381 return std::nullopt;
7383 switch (arg->getKind()) {
7384 case clang::TemplateArgument::Integral:
7385 return {{arg->getAsIntegral(),
GetType(arg->getIntegralType())}};
7386 case clang::TemplateArgument::StructuralValue: {
7387 clang::APValue value = arg->getAsStructuralValue();
7390 if (value.isFloat())
7391 return {{value.getFloat(), type}};
7394 return {{value.getInt(), type}};
7396 return std::nullopt;
7399 return std::nullopt;
7424 const clang::EnumType *enutype =
7427 return enutype->getDecl()->getDefinitionOrSelf();
7432 const clang::RecordType *record_type =
7435 return record_type->getDecl()->getDefinitionOrSelf();
7443clang::TypedefNameDecl *
7445 const clang::TypedefType *typedef_type =
7448 return typedef_type->getDecl();
7452clang::CXXRecordDecl *
7457clang::ObjCInterfaceDecl *
7459 const clang::ObjCObjectType *objc_class_type =
7460 llvm::dyn_cast<clang::ObjCObjectType>(
7462 if (objc_class_type)
7463 return objc_class_type->getInterface();
7469 const CompilerType &field_clang_type, uint32_t bitfield_bit_size) {
7475 clang::ASTContext &clang_ast = ast->getASTContext();
7476 clang::IdentifierInfo *ident =
nullptr;
7478 ident = &clang_ast.Idents.get(name);
7480 clang::FieldDecl *field =
nullptr;
7482 clang::Expr *bit_width =
nullptr;
7483 if (bitfield_bit_size != 0) {
7484 if (clang_ast.IntTy.isNull()) {
7486 "builtin ASTContext types have not been initialized");
7490 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
7492 bit_width =
new (clang_ast)
7493 clang::IntegerLiteral(clang_ast, bitfield_bit_size_apint,
7494 clang_ast.IntTy, clang::SourceLocation());
7495 bit_width = clang::ConstantExpr::Create(
7496 clang_ast, bit_width, APValue(llvm::APSInt(bitfield_bit_size_apint)));
7499 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7501 field = clang::FieldDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7502 field->setDeclContext(record_decl);
7503 field->setDeclName(ident);
7506 field->setBitWidth(bit_width);
7512 if (
const clang::TagType *TagT =
7513 field->getType()->getAs<clang::TagType>()) {
7514 if (clang::RecordDecl *Rec =
7515 llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
7516 if (!Rec->getDeclName()) {
7517 Rec->setAnonymousStructOrUnion(
true);
7518 field->setImplicit();
7524 field->setAccess(AS_public);
7526 record_decl->addDecl(field);
7531 clang::ObjCInterfaceDecl *class_interface_decl =
7532 ast->GetAsObjCInterfaceDecl(type);
7534 if (class_interface_decl) {
7535 const bool is_synthesized =
false;
7540 clang::ObjCIvarDecl::CreateDeserialized(clang_ast, GlobalDeclID());
7541 ivar->setDeclContext(class_interface_decl);
7542 ivar->setDeclName(ident);
7544 ivar->setAccessControl(ObjCIvarDecl::AccessControl::Public);
7546 ivar->setBitWidth(bit_width);
7547 ivar->setSynthesize(is_synthesized);
7552 class_interface_decl->addDecl(field);
7569 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7574 typedef llvm::SmallVector<clang::IndirectFieldDecl *, 1> IndirectFieldVector;
7576 IndirectFieldVector indirect_fields;
7577 clang::RecordDecl::field_iterator field_pos;
7578 clang::RecordDecl::field_iterator field_end_pos = record_decl->field_end();
7579 clang::RecordDecl::field_iterator last_field_pos = field_end_pos;
7580 for (field_pos = record_decl->field_begin(); field_pos != field_end_pos;
7581 last_field_pos = field_pos++) {
7582 if (field_pos->isAnonymousStructOrUnion()) {
7583 clang::QualType field_qual_type = field_pos->getType();
7585 const clang::RecordType *field_record_type =
7586 field_qual_type->getAs<clang::RecordType>();
7588 if (!field_record_type)
7591 clang::RecordDecl *field_record_decl =
7592 field_record_type->getDecl()->getDefinition();
7594 if (!field_record_decl)
7597 for (clang::RecordDecl::decl_iterator
7598 di = field_record_decl->decls_begin(),
7599 de = field_record_decl->decls_end();
7601 if (clang::FieldDecl *nested_field_decl =
7602 llvm::dyn_cast<clang::FieldDecl>(*di)) {
7603 clang::NamedDecl **chain =
7604 new (ast->getASTContext()) clang::NamedDecl *[2];
7605 chain[0] = *field_pos;
7606 chain[1] = nested_field_decl;
7607 clang::IndirectFieldDecl *indirect_field =
7608 clang::IndirectFieldDecl::Create(
7609 ast->getASTContext(), record_decl, clang::SourceLocation(),
7610 nested_field_decl->getIdentifier(),
7611 nested_field_decl->getType(), {chain, 2});
7614 indirect_field->setImplicit();
7616 indirect_field->setAccess(AS_public);
7618 indirect_fields.push_back(indirect_field);
7619 }
else if (clang::IndirectFieldDecl *nested_indirect_field_decl =
7620 llvm::dyn_cast<clang::IndirectFieldDecl>(*di)) {
7621 size_t nested_chain_size =
7622 nested_indirect_field_decl->getChainingSize();
7623 clang::NamedDecl **chain =
new (ast->getASTContext())
7624 clang::NamedDecl *[nested_chain_size + 1];
7625 chain[0] = *field_pos;
7627 int chain_index = 1;
7628 for (clang::IndirectFieldDecl::chain_iterator
7629 nci = nested_indirect_field_decl->chain_begin(),
7630 nce = nested_indirect_field_decl->chain_end();
7632 chain[chain_index] = *nci;
7636 clang::IndirectFieldDecl *indirect_field =
7637 clang::IndirectFieldDecl::Create(
7638 ast->getASTContext(), record_decl, clang::SourceLocation(),
7639 nested_indirect_field_decl->getIdentifier(),
7640 nested_indirect_field_decl->getType(),
7641 {chain, nested_chain_size + 1});
7644 indirect_field->setImplicit();
7646 indirect_field->setAccess(AS_public);
7648 indirect_fields.push_back(indirect_field);
7656 if (last_field_pos != field_end_pos) {
7657 if (last_field_pos->getType()->isIncompleteArrayType())
7658 record_decl->hasFlexibleArrayMember();
7661 for (IndirectFieldVector::iterator ifi = indirect_fields.begin(),
7662 ife = indirect_fields.end();
7664 record_decl->addDecl(*ifi);
7677 record_decl->addAttr(
7678 clang::PackedAttr::CreateImplicit(ast->getASTContext()));
7685 llvm::StringRef name,
7694 clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
7698 clang::VarDecl *var_decl =
nullptr;
7699 clang::IdentifierInfo *ident =
nullptr;
7701 ident = &ast->getASTContext().Idents.get(name);
7704 clang::VarDecl::CreateDeserialized(ast->getASTContext(), GlobalDeclID());
7705 var_decl->setDeclContext(record_decl);
7706 var_decl->setDeclName(ident);
7708 var_decl->setStorageClass(clang::SC_Static);
7713 var_decl->setAccess(AS_public);
7714 record_decl->addDecl(var_decl);
7716 VerifyDecl(var_decl);
7722 VarDecl *var,
const llvm::APInt &init_value) {
7723 assert(!var->hasInit() &&
"variable already initialized");
7725 clang::ASTContext &ast = var->getASTContext();
7726 QualType qt = var->getType();
7727 assert(qt->isIntegralOrEnumerationType() &&
7728 "only integer or enum types supported");
7731 if (
const EnumType *enum_type = qt->getAs<EnumType>()) {
7732 const EnumDecl *enum_decl = enum_type->getDecl()->getDefinitionOrSelf();
7733 qt = enum_decl->getIntegerType();
7737 if (qt->isSpecificBuiltinType(BuiltinType::Bool)) {
7738 var->setInit(CXXBoolLiteralExpr::Create(
7739 ast, !init_value.isZero(), qt.getUnqualifiedType(), SourceLocation()));
7741 var->setInit(IntegerLiteral::Create(
7742 ast, init_value, qt.getUnqualifiedType(), SourceLocation()));
7747 clang::VarDecl *var,
const llvm::APFloat &init_value) {
7748 assert(!var->hasInit() &&
"variable already initialized");
7750 clang::ASTContext &ast = var->getASTContext();
7751 QualType qt = var->getType();
7752 assert(qt->isFloatingType() &&
"only floating point types supported");
7753 var->setInit(FloatingLiteral::Create(
7754 ast, init_value,
true, qt.getUnqualifiedType(), SourceLocation()));
7757llvm::SmallVector<clang::ParmVarDecl *>
7759 clang::FunctionDecl *func,
const clang::FunctionProtoType &prototype,
7760 const llvm::SmallVector<llvm::StringRef> ¶meter_names) {
7762 assert(parameter_names.empty() ||
7763 parameter_names.size() == prototype.getNumParams());
7765 llvm::SmallVector<clang::ParmVarDecl *> params;
7766 for (
unsigned param_index = 0; param_index < prototype.getNumParams();
7768 llvm::StringRef name =
7769 !parameter_names.empty() ? parameter_names[param_index] :
"";
7773 GetType(prototype.getParamType(param_index)),
7774 clang::SC_None,
false);
7777 params.push_back(param);
7785 llvm::StringRef asm_label,
const CompilerType &method_clang_type,
7786 bool is_virtual,
bool is_static,
bool is_inline,
bool is_explicit,
7787 bool is_attr_used,
bool is_artificial) {
7788 if (!type || !method_clang_type.
IsValid() || name.empty())
7793 clang::CXXRecordDecl *cxx_record_decl =
7794 record_qual_type->getAsCXXRecordDecl();
7796 if (cxx_record_decl ==
nullptr)
7801 clang::CXXMethodDecl *cxx_method_decl =
nullptr;
7803 clang::DeclarationName decl_name(&
getASTContext().Idents.get(name));
7805 const clang::FunctionType *function_type =
7806 llvm::dyn_cast<clang::FunctionType>(method_qual_type.getTypePtr());
7808 if (function_type ==
nullptr)
7811 const clang::FunctionProtoType *method_function_prototype(
7812 llvm::dyn_cast<clang::FunctionProtoType>(function_type));
7814 if (!method_function_prototype)
7817 unsigned int num_params = method_function_prototype->getNumParams();
7819 clang::CXXDestructorDecl *cxx_dtor_decl(
nullptr);
7820 clang::CXXConstructorDecl *cxx_ctor_decl(
nullptr);
7825 const clang::ExplicitSpecifier explicit_spec(
7826 nullptr , is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
7827 : clang::ExplicitSpecKind::ResolvedFalse);
7829 if (name.starts_with(
"~")) {
7830 cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(
7832 cxx_dtor_decl->setDeclContext(cxx_record_decl);
7833 cxx_dtor_decl->setDeclName(
7836 cxx_dtor_decl->setType(method_qual_type);
7837 cxx_dtor_decl->setImplicit(is_artificial);
7838 cxx_dtor_decl->setInlineSpecified(is_inline);
7839 cxx_dtor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7840 cxx_method_decl = cxx_dtor_decl;
7841 }
else if (decl_name == cxx_record_decl->getDeclName()) {
7842 cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
7844 cxx_ctor_decl->setDeclContext(cxx_record_decl);
7845 cxx_ctor_decl->setDeclName(
7848 cxx_ctor_decl->setType(method_qual_type);
7849 cxx_ctor_decl->setImplicit(is_artificial);
7850 cxx_ctor_decl->setInlineSpecified(is_inline);
7851 cxx_ctor_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7852 cxx_ctor_decl->setNumCtorInitializers(0);
7853 cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
7854 cxx_method_decl = cxx_ctor_decl;
7856 clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
7857 clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
7860 if (op_kind != clang::NUM_OVERLOADED_OPERATORS) {
7865 const bool is_method =
true;
7867 is_method, op_kind, num_params))
7869 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7871 cxx_method_decl->setDeclContext(cxx_record_decl);
7872 cxx_method_decl->setDeclName(
7873 getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
7874 cxx_method_decl->setType(method_qual_type);
7875 cxx_method_decl->setStorageClass(SC);
7876 cxx_method_decl->setInlineSpecified(is_inline);
7877 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7878 }
else if (num_params == 0) {
7880 auto *cxx_conversion_decl =
7881 clang::CXXConversionDecl::CreateDeserialized(
getASTContext(),
7883 cxx_conversion_decl->setDeclContext(cxx_record_decl);
7884 cxx_conversion_decl->setDeclName(
7885 getASTContext().DeclarationNames.getCXXConversionFunctionName(
7887 function_type->getReturnType())));
7888 cxx_conversion_decl->setType(method_qual_type);
7889 cxx_conversion_decl->setInlineSpecified(is_inline);
7890 cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
7891 cxx_conversion_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7892 cxx_method_decl = cxx_conversion_decl;
7896 if (cxx_method_decl ==
nullptr) {
7897 cxx_method_decl = clang::CXXMethodDecl::CreateDeserialized(
7899 cxx_method_decl->setDeclContext(cxx_record_decl);
7900 cxx_method_decl->setDeclName(decl_name);
7901 cxx_method_decl->setType(method_qual_type);
7902 cxx_method_decl->setInlineSpecified(is_inline);
7903 cxx_method_decl->setStorageClass(SC);
7904 cxx_method_decl->setConstexprKind(ConstexprSpecKind::Unspecified);
7909 cxx_method_decl->setAccess(AS_public);
7910 cxx_method_decl->setVirtualAsWritten(is_virtual);
7913 cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(
getASTContext()));
7915 if (!asm_label.empty())
7916 cxx_method_decl->addAttr(
7917 clang::AsmLabelAttr::CreateImplicit(
getASTContext(), asm_label));
7922 cxx_method_decl, *method_function_prototype, {}));
7924 cxx_record_decl->addDecl(cxx_method_decl);
7933 if (is_artificial) {
7934 if (cxx_ctor_decl && ((cxx_ctor_decl->isDefaultConstructor() &&
7935 cxx_record_decl->hasTrivialDefaultConstructor()) ||
7936 (cxx_ctor_decl->isCopyConstructor() &&
7937 cxx_record_decl->hasTrivialCopyConstructor()) ||
7938 (cxx_ctor_decl->isMoveConstructor() &&
7939 cxx_record_decl->hasTrivialMoveConstructor()))) {
7940 cxx_ctor_decl->setDefaulted();
7941 cxx_ctor_decl->setTrivial(
true);
7942 }
else if (cxx_dtor_decl) {
7943 if (cxx_record_decl->hasTrivialDestructor()) {
7944 cxx_dtor_decl->setDefaulted();
7945 cxx_dtor_decl->setTrivial(
true);
7947 }
else if ((cxx_method_decl->isCopyAssignmentOperator() &&
7948 cxx_record_decl->hasTrivialCopyAssignment()) ||
7949 (cxx_method_decl->isMoveAssignmentOperator() &&
7950 cxx_record_decl->hasTrivialMoveAssignment())) {
7951 cxx_method_decl->setDefaulted();
7952 cxx_method_decl->setTrivial(
true);
7956 VerifyDecl(cxx_method_decl);
7958 return cxx_method_decl;
7964 for (
auto *method : record->methods())
7965 addOverridesForMethod(method);
7968#pragma mark C++ Base Classes
7970std::unique_ptr<clang::CXXBaseSpecifier>
7973 bool base_of_class) {
7977 return std::make_unique<clang::CXXBaseSpecifier>(
7978 clang::SourceRange(), is_virtual, base_of_class,
7981 clang::SourceLocation());
7986 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
7990 if (!cxx_record_decl)
7992 std::vector<clang::CXXBaseSpecifier *> raw_bases;
7993 raw_bases.reserve(bases.size());
7997 for (
auto &b : bases)
7998 raw_bases.push_back(b.get());
7999 cxx_record_decl->setBases(raw_bases.data(), raw_bases.size());
8008 clang::ASTContext &clang_ast = ast->getASTContext();
8010 if (type && superclass_clang_type.
IsValid() &&
8012 clang::ObjCInterfaceDecl *class_interface_decl =
8014 clang::ObjCInterfaceDecl *super_interface_decl =
8016 if (class_interface_decl && super_interface_decl) {
8017 class_interface_decl->setSuperClass(clang_ast.getTrivialTypeSourceInfo(
8018 clang_ast.getObjCInterfaceType(super_interface_decl)));
8027 const CompilerType &property_clang_type, clang::ObjCIvarDecl *ivar_decl,
8028 const char *property_setter_name,
const char *property_getter_name,
8030 if (!type || !property_clang_type.
IsValid() || property_name ==
nullptr ||
8031 property_name[0] ==
'\0')
8036 clang::ASTContext &clang_ast = ast->getASTContext();
8039 if (!class_interface_decl)
8044 if (property_clang_type.
IsValid())
8045 property_clang_type_to_access = property_clang_type;
8047 property_clang_type_to_access = ast->GetType(ivar_decl->getType());
8049 if (!class_interface_decl || !property_clang_type_to_access.
IsValid())
8052 clang::TypeSourceInfo *prop_type_source;
8054 prop_type_source = clang_ast.getTrivialTypeSourceInfo(ivar_decl->getType());
8056 prop_type_source = clang_ast.getTrivialTypeSourceInfo(
8059 clang::ObjCPropertyDecl *property_decl =
8060 clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8061 property_decl->setDeclContext(class_interface_decl);
8062 property_decl->setDeclName(&clang_ast.Idents.get(property_name));
8063 property_decl->setType(ivar_decl
8064 ? ivar_decl->getType()
8072 ast->SetMetadata(property_decl, metadata);
8074 class_interface_decl->addDecl(property_decl);
8076 clang::Selector setter_sel, getter_sel;
8078 if (property_setter_name) {
8079 std::string property_setter_no_colon(property_setter_name,
8080 strlen(property_setter_name) - 1);
8081 const clang::IdentifierInfo *setter_ident =
8082 &clang_ast.Idents.get(property_setter_no_colon);
8083 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8084 }
else if (!(property_attributes & DW_APPLE_PROPERTY_readonly)) {
8085 std::string setter_sel_string(
"set");
8086 setter_sel_string.push_back(::toupper(property_name[0]));
8087 setter_sel_string.append(&property_name[1]);
8088 const clang::IdentifierInfo *setter_ident =
8089 &clang_ast.Idents.get(setter_sel_string);
8090 setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
8092 property_decl->setSetterName(setter_sel);
8093 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
8095 if (property_getter_name !=
nullptr) {
8096 const clang::IdentifierInfo *getter_ident =
8097 &clang_ast.Idents.get(property_getter_name);
8098 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8100 const clang::IdentifierInfo *getter_ident =
8101 &clang_ast.Idents.get(property_name);
8102 getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
8104 property_decl->setGetterName(getter_sel);
8105 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
8108 property_decl->setPropertyIvarDecl(ivar_decl);
8110 if (property_attributes & DW_APPLE_PROPERTY_readonly)
8111 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
8112 if (property_attributes & DW_APPLE_PROPERTY_readwrite)
8113 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
8114 if (property_attributes & DW_APPLE_PROPERTY_assign)
8115 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
8116 if (property_attributes & DW_APPLE_PROPERTY_retain)
8117 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
8118 if (property_attributes & DW_APPLE_PROPERTY_copy)
8119 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
8120 if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
8121 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
8122 if (property_attributes & ObjCPropertyAttribute::kind_nullability)
8123 property_decl->setPropertyAttributes(
8124 ObjCPropertyAttribute::kind_nullability);
8125 if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
8126 property_decl->setPropertyAttributes(
8127 ObjCPropertyAttribute::kind_null_resettable);
8128 if (property_attributes & ObjCPropertyAttribute::kind_class)
8129 property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
8131 const bool isInstance =
8132 (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
8134 clang::ObjCMethodDecl *getter =
nullptr;
8135 if (!getter_sel.isNull())
8136 getter = isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
8137 : class_interface_decl->lookupClassMethod(getter_sel);
8138 if (!getter_sel.isNull() && !getter) {
8139 const bool isVariadic =
false;
8140 const bool isPropertyAccessor =
true;
8141 const bool isSynthesizedAccessorStub =
false;
8142 const bool isImplicitlyDeclared =
true;
8143 const bool isDefined =
false;
8144 const clang::ObjCImplementationControl impControl =
8145 clang::ObjCImplementationControl::None;
8146 const bool HasRelatedResultType =
false;
8149 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8150 getter->setDeclName(getter_sel);
8152 getter->setDeclContext(class_interface_decl);
8153 getter->setInstanceMethod(isInstance);
8154 getter->setVariadic(isVariadic);
8155 getter->setPropertyAccessor(isPropertyAccessor);
8156 getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8157 getter->setImplicit(isImplicitlyDeclared);
8158 getter->setDefined(isDefined);
8159 getter->setDeclImplementation(impControl);
8160 getter->setRelatedResultType(HasRelatedResultType);
8164 ast->SetMetadata(getter, metadata);
8166 getter->setMethodParams(clang_ast, llvm::ArrayRef<clang::ParmVarDecl *>(),
8167 llvm::ArrayRef<clang::SourceLocation>());
8168 class_interface_decl->addDecl(getter);
8172 getter->setPropertyAccessor(
true);
8173 property_decl->setGetterMethodDecl(getter);
8176 clang::ObjCMethodDecl *setter =
nullptr;
8177 setter = isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
8178 : class_interface_decl->lookupClassMethod(setter_sel);
8179 if (!setter_sel.isNull() && !setter) {
8180 clang::QualType result_type = clang_ast.VoidTy;
8181 const bool isVariadic =
false;
8182 const bool isPropertyAccessor =
true;
8183 const bool isSynthesizedAccessorStub =
false;
8184 const bool isImplicitlyDeclared =
true;
8185 const bool isDefined =
false;
8186 const clang::ObjCImplementationControl impControl =
8187 clang::ObjCImplementationControl::None;
8188 const bool HasRelatedResultType =
false;
8191 clang::ObjCMethodDecl::CreateDeserialized(clang_ast, GlobalDeclID());
8192 setter->setDeclName(setter_sel);
8193 setter->setReturnType(result_type);
8194 setter->setDeclContext(class_interface_decl);
8195 setter->setInstanceMethod(isInstance);
8196 setter->setVariadic(isVariadic);
8197 setter->setPropertyAccessor(isPropertyAccessor);
8198 setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8199 setter->setImplicit(isImplicitlyDeclared);
8200 setter->setDefined(isDefined);
8201 setter->setDeclImplementation(impControl);
8202 setter->setRelatedResultType(HasRelatedResultType);
8206 ast->SetMetadata(setter, metadata);
8208 llvm::SmallVector<clang::ParmVarDecl *, 1> params;
8209 params.push_back(clang::ParmVarDecl::Create(
8210 clang_ast, setter, clang::SourceLocation(), clang::SourceLocation(),
8213 clang::SC_Auto,
nullptr));
8215 setter->setMethodParams(clang_ast,
8216 llvm::ArrayRef<clang::ParmVarDecl *>(params),
8217 llvm::ArrayRef<clang::SourceLocation>());
8219 class_interface_decl->addDecl(setter);
8223 setter->setPropertyAccessor(
true);
8224 property_decl->setSetterMethodDecl(setter);
8235 const CompilerType &method_clang_type,
bool is_artificial,
bool is_variadic,
8236 bool is_objc_direct_call) {
8237 if (!type || !method_clang_type.
IsValid())
8242 if (class_interface_decl ==
nullptr)
8245 if (lldb_ast ==
nullptr)
8247 clang::ASTContext &ast = lldb_ast->getASTContext();
8249 const char *selector_start = ::strchr(name,
' ');
8250 if (selector_start ==
nullptr)
8254 llvm::SmallVector<const clang::IdentifierInfo *, 12> selector_idents;
8259 unsigned num_selectors_with_args = 0;
8260 for (start = selector_start; start && *start !=
'\0' && *start !=
']';
8262 len = ::strcspn(start,
":]");
8263 bool has_arg = (start[len] ==
':');
8265 ++num_selectors_with_args;
8266 selector_idents.push_back(&ast.Idents.get(llvm::StringRef(start, len)));
8271 if (selector_idents.size() == 0)
8274 clang::Selector method_selector = ast.Selectors.getSelector(
8275 num_selectors_with_args ? selector_idents.size() : 0,
8276 selector_idents.data());
8281 const clang::Type *method_type(method_qual_type.getTypePtr());
8283 if (method_type ==
nullptr)
8286 const clang::FunctionProtoType *method_function_prototype(
8287 llvm::dyn_cast<clang::FunctionProtoType>(method_type));
8289 if (!method_function_prototype)
8292 const bool isInstance = (name[0] ==
'-');
8293 const bool isVariadic = is_variadic;
8294 const bool isPropertyAccessor =
false;
8295 const bool isSynthesizedAccessorStub =
false;
8297 const bool isImplicitlyDeclared =
true;
8298 const bool isDefined =
false;
8299 const clang::ObjCImplementationControl impControl =
8300 clang::ObjCImplementationControl::None;
8301 const bool HasRelatedResultType =
false;
8303 const unsigned num_args = method_function_prototype->getNumParams();
8305 if (num_args != num_selectors_with_args)
8309 auto *objc_method_decl =
8310 clang::ObjCMethodDecl::CreateDeserialized(ast, GlobalDeclID());
8311 objc_method_decl->setDeclName(method_selector);
8312 objc_method_decl->setReturnType(method_function_prototype->getReturnType());
8313 objc_method_decl->setDeclContext(
8315 objc_method_decl->setInstanceMethod(isInstance);
8316 objc_method_decl->setVariadic(isVariadic);
8317 objc_method_decl->setPropertyAccessor(isPropertyAccessor);
8318 objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
8319 objc_method_decl->setImplicit(isImplicitlyDeclared);
8320 objc_method_decl->setDefined(isDefined);
8321 objc_method_decl->setDeclImplementation(impControl);
8322 objc_method_decl->setRelatedResultType(HasRelatedResultType);
8325 if (objc_method_decl ==
nullptr)
8329 llvm::SmallVector<clang::ParmVarDecl *, 12> params;
8331 for (
unsigned param_index = 0; param_index < num_args; ++param_index) {
8332 params.push_back(clang::ParmVarDecl::Create(
8333 ast, objc_method_decl, clang::SourceLocation(),
8334 clang::SourceLocation(),
8336 method_function_prototype->getParamType(param_index),
nullptr,
8337 clang::SC_Auto,
nullptr));
8340 objc_method_decl->setMethodParams(
8341 ast, llvm::ArrayRef<clang::ParmVarDecl *>(params),
8342 llvm::ArrayRef<clang::SourceLocation>());
8345 if (is_objc_direct_call) {
8348 objc_method_decl->addAttr(
8349 clang::ObjCDirectAttr::CreateImplicit(ast, SourceLocation()));
8354 objc_method_decl->createImplicitParams(ast, class_interface_decl);
8357 class_interface_decl->addDecl(objc_method_decl);
8359 VerifyDecl(objc_method_decl);
8361 return objc_method_decl;
8371 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8372 switch (type_class) {
8373 case clang::Type::Record: {
8374 clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
8375 if (cxx_record_decl) {
8376 cxx_record_decl->setHasExternalLexicalStorage(has_extern);
8377 cxx_record_decl->setHasExternalVisibleStorage(has_extern);
8382 case clang::Type::Enum: {
8383 clang::EnumDecl *enum_decl =
8384 llvm::cast<clang::EnumType>(qual_type)->getDecl();
8386 enum_decl->setHasExternalLexicalStorage(has_extern);
8387 enum_decl->setHasExternalVisibleStorage(has_extern);
8392 case clang::Type::ObjCObject:
8393 case clang::Type::ObjCInterface: {
8394 const clang::ObjCObjectType *objc_class_type =
8395 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8396 assert(objc_class_type);
8397 if (objc_class_type) {
8398 clang::ObjCInterfaceDecl *class_interface_decl =
8399 objc_class_type->getInterface();
8401 if (class_interface_decl) {
8402 class_interface_decl->setHasExternalLexicalStorage(has_extern);
8403 class_interface_decl->setHasExternalVisibleStorage(has_extern);
8419 if (!qual_type.isNull()) {
8420 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8422 clang::TagDecl *tag_decl = tag_type->getDecl();
8424 tag_decl->startDefinition();
8429 const clang::ObjCObjectType *object_type =
8430 qual_type->getAs<clang::ObjCObjectType>();
8432 clang::ObjCInterfaceDecl *interface_decl = object_type->getInterface();
8433 if (interface_decl) {
8434 interface_decl->startDefinition();
8445 if (qual_type.isNull())
8449 if (lldb_ast ==
nullptr)
8455 const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
8457 clang::TagDecl *tag_decl = tag_type->getDecl()->getDefinitionOrSelf();
8459 if (
auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
8469 if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
8470 cxx_record_decl->hasUserDeclaredMoveAssignment()) {
8471 if (cxx_record_decl->needsImplicitCopyConstructor())
8472 cxx_record_decl->setImplicitCopyConstructorIsDeleted();
8473 if (cxx_record_decl->needsImplicitCopyAssignment())
8474 cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
8477 if (!cxx_record_decl->isCompleteDefinition())
8478 cxx_record_decl->completeDefinition();
8479 cxx_record_decl->setHasLoadedFieldsFromExternalStorage(
true);
8480 cxx_record_decl->setHasExternalLexicalStorage(
false);
8481 cxx_record_decl->setHasExternalVisibleStorage(
false);
8486 const clang::EnumType *enutype = qual_type->getAs<clang::EnumType>();
8490 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8492 if (enum_decl->isCompleteDefinition())
8495 QualType integer_type(enum_decl->getIntegerType());
8496 if (!integer_type.isNull()) {
8497 clang::ASTContext &ast = lldb_ast->getASTContext();
8499 unsigned NumNegativeBits = 0;
8500 unsigned NumPositiveBits = 0;
8501 ast.computeEnumBits(enum_decl->enumerators(), NumNegativeBits,
8504 clang::QualType BestPromotionType;
8505 clang::QualType BestType;
8506 ast.computeBestEnumTypes(
false, NumNegativeBits,
8507 NumPositiveBits, BestType, BestPromotionType);
8509 enum_decl->completeDefinition(enum_decl->getIntegerType(),
8510 BestPromotionType, NumPositiveBits,
8518 const llvm::APSInt &value) {
8529 if (!enum_opaque_compiler_type)
8532 clang::QualType enum_qual_type(
8535 const clang::Type *clang_type = enum_qual_type.getTypePtr();
8540 const clang::EnumType *enutype = llvm::dyn_cast<clang::EnumType>(clang_type);
8545 clang::EnumConstantDecl *enumerator_decl =
8546 clang::EnumConstantDecl::CreateDeserialized(
getASTContext(),
8548 clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8549 enumerator_decl->setDeclContext(enum_decl);
8550 if (name && name[0])
8551 enumerator_decl->setDeclName(&
getASTContext().Idents.get(name));
8552 enumerator_decl->setType(clang::QualType(enutype, 0));
8554 enumerator_decl->setAccess(AS_public);
8560 enum_decl->addDecl(enumerator_decl);
8562 VerifyDecl(enumerator_decl);
8563 return enumerator_decl;
8568 uint64_t enum_value, uint32_t enum_value_bit_size) {
8570 llvm::APSInt value(enum_value_bit_size,
8579 const clang::Type *clang_type = qt.getTypePtrOrNull();
8580 const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
8584 return GetType(enum_type->getDecl()->getDefinitionOrSelf()->getIntegerType());
8590 if (type && pointee_type.
IsValid() &&
8595 return ast->GetType(ast->getASTContext().getMemberPointerType(
8604#define DEPTH_INCREMENT 2
8607LLVM_DUMP_METHOD
void
8617struct ScopedASTColor {
8618 ScopedASTColor(clang::ASTContext &ast,
bool show_colors)
8621 ast.getDiagnostics().getDiagnosticOptions().getShowColors()) {
8622 ast.getDiagnostics().getDiagnosticOptions().setShowColors(
8623 show_colors ? clang::ShowColorsKind::On : clang::ShowColorsKind::Off);
8627 ast.getDiagnostics().getDiagnosticOptions().setShowColors(old_show_colors);
8630 clang::ASTContext *
8631 const clang::ShowColorsKind old_show_colors;
8640 clang::CreateASTDumper(output, filter,
8645 false, clang::ADOF_Default);
8648 consumer->HandleTranslationUnit(*
m_ast_up);
8652 llvm::StringRef symbol_name) {
8659 symfile->
GetTypes(
nullptr, eTypeClassAny, type_list);
8660 size_t ntypes = type_list.
GetSize();
8662 for (
size_t i = 0; i < ntypes; ++i) {
8665 if (!symbol_name.empty())
8666 if (symbol_name != type->GetName().GetStringRef())
8669 s << type->GetName() <<
"\n";
8672 if (clang::TagDecl *tag_decl =
GetAsTagDecl(full_type)) {
8680 if (
auto *objc_obj = llvm::dyn_cast<clang::ObjCObjectType>(
8682 if (clang::ObjCInterfaceDecl *interface_decl = objc_obj->getInterface()) {
8694 size_t byte_size, uint32_t bitfield_bit_offset,
8695 uint32_t bitfield_bit_size) {
8696 const clang::EnumType *enutype =
8697 llvm::cast<clang::EnumType>(qual_type.getTypePtr());
8698 const clang::EnumDecl *enum_decl = enutype->getDecl()->getDefinitionOrSelf();
8700 bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
8701 const uint64_t enum_svalue =
8704 bitfield_bit_offset)
8706 bitfield_bit_offset);
8707 bool can_be_bitfield =
true;
8708 uint64_t covered_bits = 0;
8709 int num_enumerators = 0;
8717 clang::EnumDecl::enumerator_range enumerators = enum_decl->enumerators();
8718 if (enumerators.empty())
8719 can_be_bitfield =
false;
8721 for (
auto *enumerator : enumerators) {
8722 llvm::APSInt init_val = enumerator->getInitVal();
8723 uint64_t val = qual_type_is_signed ? init_val.getSExtValue()
8724 : init_val.getZExtValue();
8725 if (qual_type_is_signed)
8726 val = llvm::SignExtend64(val, 8 * byte_size);
8727 if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
8728 can_be_bitfield =
false;
8729 covered_bits |= val;
8731 if (val == enum_svalue) {
8740 offset = byte_offset;
8742 &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
8746 if (!can_be_bitfield) {
8747 if (qual_type_is_signed)
8748 s.
Printf(
"%" PRIi64, enum_svalue);
8750 s.
Printf(
"%" PRIu64, enum_uvalue);
8757 s.
Printf(
"0x%" PRIx64, enum_uvalue);
8761 uint64_t remaining_value = enum_uvalue;
8762 std::vector<std::pair<uint64_t, llvm::StringRef>> values;
8763 values.reserve(num_enumerators);
8764 for (
auto *enumerator : enum_decl->enumerators())
8765 if (
auto val = enumerator->getInitVal().getZExtValue())
8766 values.emplace_back(val, enumerator->getName());
8771 llvm::stable_sort(values, [](
const auto &a,
const auto &b) {
8772 return llvm::popcount(a.first) > llvm::popcount(b.first);
8775 for (
const auto &val : values) {
8776 if ((remaining_value & val.first) != val.first)
8778 remaining_value &= ~val.first;
8780 if (remaining_value)
8786 if (remaining_value)
8787 s.
Printf(
"0x%" PRIx64, remaining_value);
8795 size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset,
8804 switch (qual_type->getTypeClass()) {
8805 case clang::Type::Typedef: {
8806 clang::QualType typedef_qual_type =
8807 llvm::cast<clang::TypedefType>(qual_type)
8809 ->getUnderlyingType();
8812 format = typedef_clang_type.
GetFormat();
8813 clang::TypeInfo typedef_type_info =
8815 uint64_t typedef_byte_size = typedef_type_info.Width / 8;
8825 bitfield_bit_offset,
8830 case clang::Type::Enum:
8835 return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
8836 bitfield_bit_offset, bitfield_bit_size);
8844 uint32_t item_count = 1;
8884 item_count = byte_size;
8889 item_count = byte_size / 2;
8894 item_count = byte_size / 4;
8900 bitfield_bit_size, bitfield_bit_offset,
8919 clang::QualType qual_type =
8922 llvm::SmallVector<char, 1024> buf;
8923 llvm::raw_svector_ostream llvm_ostrm(buf);
8925 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
8926 switch (type_class) {
8927 case clang::Type::ObjCObject:
8928 case clang::Type::ObjCInterface: {
8931 auto *objc_class_type =
8932 llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
8933 assert(objc_class_type);
8934 if (!objc_class_type)
8936 clang::ObjCInterfaceDecl *class_interface_decl =
8937 objc_class_type->getInterface();
8938 if (!class_interface_decl)
8941 class_interface_decl->dump(llvm_ostrm);
8943 class_interface_decl->print(llvm_ostrm,
8948 case clang::Type::Typedef: {
8949 auto *typedef_type = qual_type->getAs<clang::TypedefType>();
8952 const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
8954 typedef_decl->dump(llvm_ostrm);
8957 if (!clang_typedef_name.empty()) {
8964 case clang::Type::Record: {
8967 auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
8968 const clang::RecordDecl *record_decl = record_type->getDecl();
8970 record_decl->dump(llvm_ostrm);
8972 record_decl->print(llvm_ostrm,
getASTContext().getPrintingPolicy(),
8978 if (
auto *tag_type =
8979 llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
8980 if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
8982 tag_decl->dump(llvm_ostrm);
8984 tag_decl->print(llvm_ostrm, 0);
8990 std::string clang_type_name(qual_type.getAsString());
8991 if (!clang_type_name.empty())
8998 if (buf.size() > 0) {
8999 s.
Write(buf.data(), buf.size());
9003 std::optional<ClangASTMetadata> metadata =
9006 s <<
"type-metadata = ";
9011 if (
const clang::TagDecl *tag = qual_type->getAsTagDecl())
9015 s <<
"decl-metadata = ";
9024 clang::QualType qual_type(
9027 const clang::Type::TypeClass type_class = qual_type->getTypeClass();
9028 switch (type_class) {
9029 case clang::Type::Record: {
9030 const clang::CXXRecordDecl *cxx_record_decl =
9031 qual_type->getAsCXXRecordDecl();
9032 if (cxx_record_decl)
9033 printf(
"class %s", cxx_record_decl->getName().str().c_str());
9036 case clang::Type::Enum: {
9037 clang::EnumDecl *enum_decl =
9038 llvm::cast<clang::EnumType>(qual_type)->getDecl();
9040 printf(
"enum %s", enum_decl->getName().str().c_str());
9044 case clang::Type::ObjCObject:
9045 case clang::Type::ObjCInterface: {
9046 const clang::ObjCObjectType *objc_class_type =
9047 llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
9048 if (objc_class_type) {
9049 clang::ObjCInterfaceDecl *class_interface_decl =
9050 objc_class_type->getInterface();
9054 if (class_interface_decl)
9055 printf(
"@class %s", class_interface_decl->getName().str().c_str());
9059 case clang::Type::Typedef:
9060 printf(
"typedef %s", llvm::cast<clang::TypedefType>(qual_type)
9067 case clang::Type::Auto:
9070 llvm::cast<clang::AutoType>(qual_type)
9072 .getAsOpaquePtr()));
9074 case clang::Type::Paren:
9078 llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
9081 printf(
"TypeSystemClang::DumpTypeName() type_class = %u", type_class);
9089 const char *parent_name,
int tag_decl_kind,
9091 if (template_param_infos.
IsValid()) {
9092 std::string template_basename(parent_name);
9094 if (
auto i = template_basename.find(
'<'); i != std::string::npos)
9095 template_basename.erase(i);
9098 template_basename.c_str(), tag_decl_kind,
9099 template_param_infos);
9114 clang::ObjCInterfaceDecl *decl) {
9138 std::make_unique<npdb::PdbAstBuilderClang>(*
this);
9143 const clang::RecordDecl *record_decl, uint64_t &bit_size,
9144 uint64_t &alignment,
9145 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
9146 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9148 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
9161 field_offsets, base_offsets, vbase_offsets);
9168 clang::NamedDecl *nd =
9169 llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
9179 if (!label_or_err) {
9180 llvm::consumeError(label_or_err.takeError());
9184 llvm::StringRef mangled = label_or_err->lookup_name;
9192 clang::NamedDecl *nd = llvm::dyn_cast_or_null<clang::NamedDecl>(
9193 static_cast<clang::Decl *
>(opaque_decl));
9195 if (!nd || llvm::isa<clang::ObjCMethodDecl>(nd))
9199 if (!mc || !mc->shouldMangleCXXName(nd))
9204 if (
const auto *label = nd->getAttr<AsmLabelAttr>())
9209 llvm::SmallVector<char, 1024> buf;
9210 llvm::raw_svector_ostream llvm_ostrm(buf);
9211 if (llvm::isa<clang::CXXConstructorDecl>(nd)) {
9213 clang::GlobalDecl(llvm::dyn_cast<clang::CXXConstructorDecl>(nd),
9216 }
else if (llvm::isa<clang::CXXDestructorDecl>(nd)) {
9218 clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
9222 mc->mangleName(nd, llvm_ostrm);
9238 if (clang::FunctionDecl *func_decl =
9239 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9240 return GetType(func_decl->getReturnType());
9241 if (clang::ObjCMethodDecl *objc_method =
9242 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9243 return GetType(objc_method->getReturnType());
9249 if (clang::FunctionDecl *func_decl =
9250 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
9251 return func_decl->param_size();
9252 if (clang::ObjCMethodDecl *objc_method =
9253 llvm::dyn_cast<clang::ObjCMethodDecl>((clang::Decl *)opaque_decl))
9254 return objc_method->param_size();
9260 clang::DeclContext
const *decl_ctx) {
9261 switch (clang_kind) {
9262 case Decl::TranslationUnit:
9264 case Decl::Namespace:
9275 if (decl_ctx->isFunctionOrMethod())
9277 if (decl_ctx->isRecord())
9287 std::vector<lldb_private::CompilerContext> &context) {
9288 if (decl_ctx ==
nullptr)
9291 clang::Decl::Kind clang_kind = decl_ctx->getDeclKind();
9292 if (clang_kind == Decl::TranslationUnit)
9297 context.push_back({compiler_kind, decl_ctx_name});
9300std::vector<lldb_private::CompilerContext>
9302 std::vector<lldb_private::CompilerContext> context;
9305 clang::Decl *decl = (clang::Decl *)opaque_decl;
9307 clang::DeclContext *decl_ctx = decl->getDeclContext();
9310 auto compiler_kind =
9312 context.push_back({compiler_kind, decl_name});
9319 if (clang::FunctionDecl *func_decl =
9320 llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
9321 if (idx < func_decl->param_size()) {
9322 ParmVarDecl *var_decl = func_decl->getParamDecl(idx);
9324 return GetType(var_decl->getOriginalType());
9326 }
else if (clang::ObjCMethodDecl *objc_method =
9327 llvm::dyn_cast<clang::ObjCMethodDecl>(
9328 (clang::Decl *)opaque_decl)) {
9329 if (idx < objc_method->param_size())
9330 return GetType(objc_method->parameters()[idx]->getOriginalType());
9336 clang::Decl *decl =
static_cast<clang::Decl *
>(opaque_decl);
9337 clang::VarDecl *var_decl = llvm::dyn_cast<clang::VarDecl>(decl);
9340 clang::Expr *init_expr = var_decl->getInit();
9343 std::optional<llvm::APSInt> value =
9353 void *opaque_decl_ctx,
ConstString name,
const bool ignore_using_decls) {
9354 std::vector<CompilerDecl> found_decls;
9356 if (opaque_decl_ctx && symbol_file) {
9357 DeclContext *root_decl_ctx = (DeclContext *)opaque_decl_ctx;
9358 std::set<DeclContext *> searched;
9359 std::multimap<DeclContext *, DeclContext *> search_queue;
9361 for (clang::DeclContext *decl_context = root_decl_ctx;
9362 decl_context !=
nullptr && found_decls.empty();
9363 decl_context = decl_context->getParent()) {
9364 search_queue.insert(std::make_pair(decl_context, decl_context));
9366 for (
auto it = search_queue.find(decl_context); it != search_queue.end();
9368 if (!searched.insert(it->second).second)
9373 for (clang::Decl *child : it->second->decls()) {
9374 if (clang::UsingDirectiveDecl *ud =
9375 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9376 if (ignore_using_decls)
9378 clang::DeclContext *from = ud->getCommonAncestor();
9379 if (searched.find(ud->getNominatedNamespace()) == searched.end())
9380 search_queue.insert(
9381 std::make_pair(from, ud->getNominatedNamespace()));
9382 }
else if (clang::UsingDecl *ud =
9383 llvm::dyn_cast<clang::UsingDecl>(child)) {
9384 if (ignore_using_decls)
9386 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9387 clang::Decl *target = usd->getTargetDecl();
9388 if (clang::NamedDecl *nd =
9389 llvm::dyn_cast<clang::NamedDecl>(target)) {
9390 IdentifierInfo *ii = nd->getIdentifier();
9391 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9395 }
else if (clang::NamedDecl *nd =
9396 llvm::dyn_cast<clang::NamedDecl>(child)) {
9397 IdentifierInfo *ii = nd->getIdentifier();
9398 if (ii !=
nullptr && ii->getName() == name.
AsCString(
nullptr))
9449 clang::DeclContext *child_decl_ctx,
9453 if (frame_decl_ctx && symbol_file) {
9454 std::set<DeclContext *> searched;
9455 std::multimap<DeclContext *, DeclContext *> search_queue;
9458 clang::DeclContext *parent_decl_ctx = child_decl_ctx->getParent();
9462 for (clang::DeclContext *decl_ctx = frame_decl_ctx; decl_ctx !=
nullptr;
9463 decl_ctx = decl_ctx->getParent()) {
9464 if (!decl_ctx->isLookupContext())
9466 if (decl_ctx == parent_decl_ctx)
9469 search_queue.insert(std::make_pair(decl_ctx, decl_ctx));
9470 for (
auto it = search_queue.find(decl_ctx); it != search_queue.end();
9472 if (searched.find(it->second) != searched.end())
9480 if (llvm::isa<clang::TranslationUnitDecl>(it->second))
9483 searched.insert(it->second);
9487 for (clang::Decl *child : it->second->decls()) {
9488 if (clang::UsingDirectiveDecl *ud =
9489 llvm::dyn_cast<clang::UsingDirectiveDecl>(child)) {
9490 clang::DeclContext *ns = ud->getNominatedNamespace();
9491 if (ns == parent_decl_ctx)
9494 clang::DeclContext *from = ud->getCommonAncestor();
9495 if (searched.find(ns) == searched.end())
9496 search_queue.insert(std::make_pair(from, ns));
9497 }
else if (child_name) {
9498 if (clang::UsingDecl *ud =
9499 llvm::dyn_cast<clang::UsingDecl>(child)) {
9500 for (clang::UsingShadowDecl *usd : ud->shadows()) {
9501 clang::Decl *target = usd->getTargetDecl();
9502 clang::NamedDecl *nd = llvm::dyn_cast<clang::NamedDecl>(target);
9506 IdentifierInfo *ii = nd->getIdentifier();
9507 if (ii ==
nullptr ||
9508 ii->getName() != child_name->
AsCString(
nullptr))
9531 if (opaque_decl_ctx) {
9532 clang::NamedDecl *named_decl =
9533 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9536 llvm::raw_string_ostream stream{name};
9538 policy.AlwaysIncludeTypeForTemplateArgument =
true;
9539 named_decl->getNameForDiagnostic(stream, policy,
false);
9548 if (opaque_decl_ctx) {
9549 clang::NamedDecl *named_decl =
9550 llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
9558 if (!opaque_decl_ctx)
9561 clang::DeclContext *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9562 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9564 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9566 }
else if (clang::FunctionDecl *fun_decl =
9567 llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9568 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9569 return metadata->HasObjectPtr();
9575std::vector<lldb_private::CompilerContext>
9577 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9578 std::vector<lldb_private::CompilerContext> context;
9584 void *opaque_decl_ctx,
void *other_opaque_decl_ctx) {
9585 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9586 auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
9590 auto is_transparent_lookup_allowed = [](clang::DeclContext *DC) {
9591 if (DC->isInlineNamespace())
9594 if (
auto const *NS = dyn_cast<NamespaceDecl>(DC))
9595 return NS->isAnonymousNamespace();
9602 if (decl_ctx == other)
9604 }
while (is_transparent_lookup_allowed(other) &&
9605 (other = other->getParent()));
9612 if (!opaque_decl_ctx)
9615 auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
9616 if (llvm::isa<clang::ObjCMethodDecl>(decl_ctx)) {
9618 }
else if (llvm::isa<clang::CXXMethodDecl>(decl_ctx)) {
9620 }
else if (
auto *fun_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
9621 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(fun_decl))
9622 return metadata->GetObjectPtrLanguage();
9642 return llvm::dyn_cast<clang::ObjCMethodDecl>(
9650 return llvm::dyn_cast<clang::CXXMethodDecl>(
9655clang::FunctionDecl *
9658 return llvm::dyn_cast<clang::FunctionDecl>(
9663clang::NamespaceDecl *
9666 return llvm::dyn_cast<clang::NamespaceDecl>(
9671std::optional<ClangASTMetadata>
9673 const Decl *
object) {
9681 llvm::dyn_cast_or_null<TypeSystemClang>(dc.
GetTypeSystem());
9704 lldbassert(started &&
"Unable to start a class type definition.");
9709 ts->SetDeclIsForcefullyCompleted(td);
9723 SpecializedScratchAST(llvm::StringRef name, llvm::Triple triple,
9724 std::unique_ptr<ClangASTSource> ast_source)
9726 m_scratch_ast_source_up(std::move(ast_source)) {
9728 m_scratch_ast_source_up->InstallASTContext(*
this);
9729 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9730 m_scratch_ast_source_up->CreateProxy();
9731 SetExternalSource(proxy_ast_source);
9735 std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
9743 llvm::Triple triple)
9750 llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source =
9762 std::optional<IsolatedASTKind> ast_kind,
9763 bool create_on_demand) {
9766 if (
auto err = type_system_or_err.takeError()) {
9768 "Couldn't get scratch TypeSystemClang: {0}");
9771 auto ts_sp = *type_system_or_err;
9773 llvm::dyn_cast_or_null<ScratchTypeSystemClang>(ts_sp.get());
9778 return std::static_pointer_cast<TypeSystemClang>(ts_sp);
9780 return std::static_pointer_cast<TypeSystemClang>(
9785static llvm::StringRef
9789 return "C++ modules";
9791 llvm_unreachable(
"Unimplemented IsolatedASTKind?");
9795 llvm::StringRef filter,
bool show_color) {
9797 output <<
"State of scratch Clang type system:\n";
9801 typedef std::pair<IsolatedASTKey, TypeSystem *> KeyAndTS;
9802 std::vector<KeyAndTS> sorted_typesystems;
9804 sorted_typesystems.emplace_back(a.first, a.second.get());
9805 llvm::stable_sort(sorted_typesystems, llvm::less_first());
9808 for (
const auto &a : sorted_typesystems) {
9811 output <<
"State of scratch Clang type subsystem "
9813 a.second->Dump(output, filter, show_color);
9818 llvm::StringRef expr, llvm::StringRef prefix,
SourceLanguage language,
9826 desired_type, options, ctx_obj);
9831 const ValueList &arg_value_list,
const char *name) {
9836 Process *process = target_sp->GetProcessSP().get();
9841 arg_value_list, name);
9844std::unique_ptr<UtilityFunction>
9851 return std::make_unique<ClangUtilityFunction>(
9852 *target_sp.get(), std::move(text), std::move(name),
9853 target_sp->GetDebugUtilityExpression());
9867 importer.
ForgetSource(&a.second->getASTContext(), src_ctx);
9871 return std::make_unique<ClangASTSource>(
9876static llvm::StringRef
9880 return "scratch ASTContext for C++ module types";
9882 llvm_unreachable(
"Unimplemented ASTFeature kind?");
9889 return *found_ast->second;
9892 std::shared_ptr<TypeSystemClang> new_ast_sp =
9902 const clang::RecordType *record_type =
9903 llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
9905 const clang::RecordDecl *record_decl =
9906 record_type->getDecl()->getDefinitionOrSelf();
9907 if (std::optional<ClangASTMetadata> metadata =
GetMetadata(record_decl))
9908 return metadata->IsForcefullyCompleted();
9917 std::optional<ClangASTMetadata> metadata =
GetMetadata(td);
9921 metadata->SetIsForcefullyCompleted();
9929 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
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const
CompilerType GetDirectBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
bool GetCompleteType() const
Type Completion.
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
llvm::Expected< uint32_t > GetIndexOfChildWithName(llvm::StringRef name, bool omit_empty_base_classes) const
Lookup a child given a name.
llvm::Expected< uint32_t > GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
A class to manage flag bits.
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 LanguageIsC(lldb::LanguageType language)
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
static bool LanguageIsPascal(lldb::LanguageType language)
static bool LanguageIsObjC(lldb::LanguageType language)
static bool IsMangledName(llvm::StringRef name)
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
llvm::Expected< CompilerType > GetChildCompilerTypeAtIndex(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) override
CompilerType GetType(clang::QualType qt)
Creates a CompilerType from the given QualType with the current TypeSystemClang instance as the Compi...
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override
std::string m_target_triple
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > bases)
bool IsBeingDefined(lldb::opaque_compiler_type_t type) override
CompilerType GetPromotedIntegerType(lldb::opaque_compiler_type_t type) override
ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override
std::unique_ptr< clang::IdentifierTable > m_identifier_table_up
static lldb::BasicType GetBasicTypeEnumeration(llvm::StringRef name)
static void SetIntegerInitializerForVariable(clang::VarDecl *var, const llvm::APInt &init_value)
Initializes a variable with an integer value.
bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override
CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override
bool LayoutRecordType(const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &field_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &base_offsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &vbase_offsets)
bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::SourceManager > m_source_manager_up
bool IsVoidType(lldb::opaque_compiler_type_t type) override
static void SetIsPacked(const CompilerType &type)
void ForEachEnumerator(lldb::opaque_compiler_type_t type, std::function< bool(const CompilerType &integer_type, ConstString name, const llvm::APSInt &value)> const &callback) override
CompilerType CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *class_template_specialization_decl)
bool IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
std::unique_ptr< clang::DiagnosticOptions > m_diagnostic_options_up
void CreateFunctionTemplateSpecializationInfo(clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template, const TemplateParameterInfos &infos)
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, uint64_t enum_value, uint32_t enum_value_bit_size)
llvm::StringRef getDisplayName() const
Returns the display name of this TypeSystemClang that indicates what purpose it serves in LLDB.
static clang::VarDecl * AddVariableToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &var_type)
bool IsCStringType(lldb::opaque_compiler_type_t type, uint32_t &length)
CompilerType GetRValueReferenceType(lldb::opaque_compiler_type_t type) override
CompilerDecl GetCompilerDecl(clang::Decl *decl)
Creates a CompilerDecl from the given Decl with the current TypeSystemClang instance as its typesyste...
unsigned GetPtrAuthDiscriminator(lldb::opaque_compiler_type_t type) override
CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override
bool GetCompleteType(lldb::opaque_compiler_type_t type) override
bool IsBlockPointerType(lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) override
bool IsConst(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::CXXBaseSpecifier > CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class)
CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override
std::vector< CompilerDecl > DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_using_decls) override
const llvm::fltSemantics & GetFloatTypeSemantics(size_t byte_size, lldb::Format format) override
bool IsFloatingPointType(lldb::opaque_compiler_type_t type) override
llvm::Expected< uint32_t > GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, llvm::StringRef name, bool omit_empty_base_classes) override
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)
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)
void DumpTypeDescription(lldb::opaque_compiler_type_t type, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) override
Dump the type to stdout.
CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
static clang::NamespaceDecl * DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped, std::optional< clang::EnumExtensibilityAttr::Kind > enum_kind=std::nullopt)
npdb::PdbAstBuilder * GetNativePDBParser() override
std::unique_ptr< clang::DiagnosticConsumer > m_diagnostic_consumer_up
CompilerType CreateObjCClass(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool isInternal, std::optional< ClangASTMetadata > metadata=std::nullopt)
CompilerType GetTypeForDecl(clang::NamedDecl *decl)
CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) override
CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc)
bool IsTypedefType(lldb::opaque_compiler_type_t type) override
CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override
std::optional< size_t > GetTypeBitAlign(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) override
void Dump(llvm::raw_ostream &output, llvm::StringRef filter, bool show_color) override
std::unique_ptr< clang::Builtin::Context > m_builtins_up
CompilerType GetBuiltinTypeByName(ConstString name) override
bool GetCompleteDecl(clang::Decl *decl)
static bool StartTagDeclarationDefinition(const CompilerType &type)
uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl, clang::NamedDecl *canonical_decl, bool omit_empty_base_classes)
bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, CompilerType *target_type, bool check_cplusplus, bool check_objc) override
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, uint32_t bitfield_bit_size)
CompilerType GetOrCreateStructForIdentifier(llvm::StringRef type_name, const std::initializer_list< std::pair< const char *, CompilerType > > &type_fields, bool packed=false)
void LogCreation() const
Emits information about this TypeSystem into the expression log.
static llvm::StringRef GetPluginNameStatic()
clang::Sema * m_sema
The sema associated that is currently used to build this ASTContext.
size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override
const clang::ClassTemplateSpecializationDecl * GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type)
std::unique_ptr< clang::MangleContext > m_mangle_ctx_up
TypeMemberFunctionImpl GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, size_t idx) override
bool IsTypeImpl(lldb::opaque_compiler_type_t type, llvm::function_ref< bool(clang::QualType)> predicate) const
size_t DeclGetFunctionNumArguments(void *opaque_decl) override
CompilerType GetAtomicType(lldb::opaque_compiler_type_t type) override
std::unique_ptr< PDBASTParser > m_pdb_ast_parser_up
std::unique_ptr< clang::DiagnosticsEngine > m_diagnostics_engine_up
static std::optional< std::string > GetCXXClassName(const CompilerType &type)
static void DumpTypeName(const CompilerType &type)
plugin::dwarf::DWARFASTParser * GetDWARFParser() override
CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx) override
bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) override
static clang::EnumDecl * GetAsEnumDecl(const CompilerType &type)
CompilerType AddVolatileModifier(lldb::opaque_compiler_type_t type) override
std::unique_ptr< clang::ModuleMap > m_module_map_up
static bool IsObjCObjectOrInterfaceType(const CompilerType &type)
static void RequireCompleteType(CompilerType type)
Complete a type from debug info, or mark it as forcefully completed if there is no definition of the ...
CompilerType CreateTypedef(lldb::opaque_compiler_type_t type, const char *name, const CompilerDeclContext &decl_ctx, uint32_t opaque_payload) override
Using the current type, create a new typedef to that type using "typedef_name" as the name and "decl_...
llvm::Expected< uint32_t > GetNumChildren(lldb::opaque_compiler_type_t type, bool omit_empty_base_classes, const ExecutionContext *exe_ctx) override
CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type) override
clang::TemplateTemplateParmDecl * CreateTemplateTemplateParmDecl(const char *template_name)
lldb::TemplateArgumentKind GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx, bool expand_pack) override
clang::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
std::vector< lldb_private::CompilerContext > DeclGetCompilerContext(void *opaque_decl) override
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
std::vector< lldb_private::CompilerContext > DeclContextGetCompilerContext(void *opaque_decl_ctx) override
void CreateASTContext()
Creates the internal ASTContext.
void SetExternalSource(llvm::IntrusiveRefCntPtr< clang::ExternalASTSource > ast_source_sp)
CompilerType GetCStringType(bool is_const)
bool IsAggregateType(lldb::opaque_compiler_type_t type) override
bool IsPromotableIntegerType(lldb::opaque_compiler_type_t type) override
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
bool IsVectorType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size) override
static LanguageSet GetSupportedLanguagesForTypes()
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
ConstString DeclContextGetName(void *opaque_decl_ctx) override
size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type, bool expand_pack) override
ConstString DeclGetName(void *opaque_decl) override
SymbolFile * GetSymbolFile() const
bool m_has_forcefully_completed_types
Used for reporting statistics.
Encapsulates a one-time expression for use in lldb.
virtual uint64_t GetData(DataExtractor &data, Status &error)
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
AddressType GetAddressTypeOfChildren()
CompilerType GetCompilerType()
ConstString GetName() const
const ExecutionContextRef & GetExecutionContextRef() const
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_IVAR_OFFSET
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, uint32_t item_bit_size, uint32_t item_bit_offset, ExecutionContextScope *exe_scope=nullptr, bool show_memory_tags=false)
Dumps item_count objects into the stream s.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
void * opaque_compiler_type_t
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eBasicTypeUnsignedShort
@ eBasicTypeUnsignedInt128
@ eBasicTypeUnsignedWChar
@ eBasicTypeLongDoubleComplex
@ eBasicTypeUnsignedLongLong
@ eBasicTypeDoubleComplex
Format
Display format definitions.
@ eFormatCString
Null-terminated C strings.
@ eFormatCharArray
Print characters with no single quotes, used for character arrays that can contain non printable char...
@ eFormatVoid
Do not print this.
@ eFormatComplex
Floating point complex type.
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
@ eFormatComplexInteger
Integer complex type.
@ eFormatFloat128
Disambiguate between 128-bit long double (which uses eFormatFloat) and __float128 (which uses eFormat...
LanguageType
Programming language type.
@ eLanguageTypeC_plus_plus_20
ISO C++:2020.
@ eLanguageTypeC_plus_plus_14
ISO C++:2014.
@ eLanguageTypeC11
ISO C:2011.
@ eLanguageTypeC99
ISO C:1999.
@ eLanguageTypeC_plus_plus_03
ISO C++:2003.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeC_plus_plus_17
ISO C++:2017.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
@ eLanguageTypeC_plus_plus_11
ISO C++:2011.
@ eLanguageTypeC89
ISO C:1989.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
@ eLanguageTypeDylan
Dylan.
std::shared_ptr< lldb_private::Type > TypeSP
@ eTemplateArgumentKindTemplate
@ eTemplateArgumentKindTemplateExpansion
@ eTemplateArgumentKindNull
@ eTemplateArgumentKindNullPtr
@ eTemplateArgumentKindDeclaration
@ eTemplateArgumentKindIntegral
@ eTemplateArgumentKindPack
@ eTemplateArgumentKindType
@ eTemplateArgumentKindStructuralValue
@ eTemplateArgumentKindExpression
Encoding
Register encoding definitions.
@ eEncodingVector
vector registers
@ eEncodingUint
unsigned integer
@ eEncodingSint
signed integer
@ 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
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.