[llvm-branch-commits] [lldb] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes (PR #149949)
Matheus Izvekov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 23 20:02:38 PDT 2025
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/149949
>From ea97cf5a5bf170c35c6fd838ce17a8c59ef5fdfe Mon Sep 17 00:00:00 2001
From: Matheus Izvekov <mizvekov at gmail.com>
Date: Mon, 21 Jul 2025 22:00:01 -0300
Subject: [PATCH] [PATCH 7/7] [clang] improve NestedNameSpecifier: LLDB changes
Patch series starting at https://github.com/llvm/llvm-project/pull/147835
---
.../Clang/ClangASTImporter.cpp | 31 +--
.../ExpressionParser/Clang/ClangASTSource.cpp | 5 +-
.../Clang/ClangExpressionDeclMap.cpp | 4 +-
.../Clang/ClangPersistentVariables.cpp | 6 +-
.../Clang/NameSearchContext.cpp | 2 +-
.../Plugins/Language/ObjC/NSDictionary.cpp | 3 +-
.../RegisterTypeBuilderClang.cpp | 4 +-
.../SymbolFile/NativePDB/PdbAstBuilder.cpp | 11 +-
.../Plugins/SymbolFile/PDB/PDBASTParser.cpp | 11 +-
.../TypeSystem/Clang/TypeSystemClang.cpp | 240 +++++++++---------
.../TypeSystem/Clang/TypeSystemClang.h | 9 +-
.../TestDataFormatterStdSharedPtr.py | 2 +-
.../string/TestDataFormatterStdString.py | 41 ++-
.../TestDataFormatterStdStringView.py | 64 +++--
.../TestDataFormatterStdUniquePtr.py | 2 +-
.../TestClassLoadingViaMemberTypedef.py | 4 +-
.../x86/DW_AT_declaration-with-children.s | 4 +-
.../DWARF/x86/dwp-foreign-type-units.cpp | 8 +-
.../DWARF/x86/typedef-in-incomplete-type.cpp | 2 +-
.../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp | 5 +-
20 files changed, 213 insertions(+), 245 deletions(-)
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 2529e78f78bca..7ba8b730c6e9b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -320,7 +320,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang &dst,
DeclContextOverride decl_context_override;
if (auto *t = ClangUtil::GetQualType(src_type)->getAs<TagType>())
- decl_context_override.OverrideAllDeclsFromContainingFunction(t->getDecl());
+ decl_context_override.OverrideAllDeclsFromContainingFunction(
+ t->getOriginalDecl());
CompleteTagDeclsScope complete_scope(*this, &dst.getASTContext(),
&src_ctxt->getASTContext());
@@ -377,8 +378,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
} break;
case clang::Type::Enum: {
- clang::EnumDecl *enum_decl =
- llvm::cast<clang::EnumType>(qual_type)->getDecl();
+ auto *enum_decl = llvm::cast<clang::EnumType>(qual_type)->getOriginalDecl();
if (enum_decl) {
if (GetDeclOrigin(enum_decl).Valid())
return true;
@@ -414,12 +414,6 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
->getDeducedType()
.getAsOpaquePtr()));
- case clang::Type::Elaborated:
- return CanImport(CompilerType(type.GetTypeSystem(),
- llvm::cast<clang::ElaboratedType>(qual_type)
- ->getNamedType()
- .getAsOpaquePtr()));
-
case clang::Type::Paren:
return CanImport(CompilerType(
type.GetTypeSystem(),
@@ -452,7 +446,7 @@ bool ClangASTImporter::Import(const CompilerType &type) {
case clang::Type::Enum: {
clang::EnumDecl *enum_decl =
- llvm::cast<clang::EnumType>(qual_type)->getDecl();
+ llvm::cast<clang::EnumType>(qual_type)->getOriginalDecl();
if (enum_decl) {
if (GetDeclOrigin(enum_decl).Valid())
return CompleteAndFetchChildren(qual_type);
@@ -488,12 +482,6 @@ bool ClangASTImporter::Import(const CompilerType &type) {
->getDeducedType()
.getAsOpaquePtr()));
- case clang::Type::Elaborated:
- return Import(CompilerType(type.GetTypeSystem(),
- llvm::cast<clang::ElaboratedType>(qual_type)
- ->getNamedType()
- .getAsOpaquePtr()));
-
case clang::Type::Paren:
return Import(CompilerType(
type.GetTypeSystem(),
@@ -597,7 +585,7 @@ bool ExtractBaseOffsets(const ASTRecordLayout &record_layout,
return false;
DeclFromUser<RecordDecl> origin_base_record(
- origin_base_record_type->getDecl());
+ origin_base_record_type->getOriginalDecl());
if (origin_base_record.IsInvalid())
return false;
@@ -728,7 +716,8 @@ bool ClangASTImporter::importRecordLayoutFromOrigin(
QualType base_type = bi->getType();
const RecordType *base_record_type = base_type->getAs<RecordType>();
- DeclFromParser<RecordDecl> base_record(base_record_type->getDecl());
+ DeclFromParser<RecordDecl> base_record(
+ base_record_type->getOriginalDecl());
DeclFromParser<CXXRecordDecl> base_cxx_record =
DynCast<CXXRecordDecl>(base_record);
@@ -860,7 +849,7 @@ bool ClangASTImporter::CompleteAndFetchChildren(clang::QualType type) {
Log *log = GetLog(LLDBLog::Expressions);
if (const TagType *tag_type = type->getAs<TagType>()) {
- TagDecl *tag_decl = tag_type->getDecl();
+ TagDecl *tag_decl = tag_type->getOriginalDecl();
DeclOrigin decl_origin = GetDeclOrigin(tag_decl);
@@ -928,9 +917,9 @@ bool ClangASTImporter::RequireCompleteType(clang::QualType type) {
return false;
if (const TagType *tag_type = type->getAs<TagType>()) {
- TagDecl *tag_decl = tag_type->getDecl();
+ TagDecl *tag_decl = tag_type->getOriginalDecl();
- if (tag_decl->getDefinition() || tag_decl->isBeingDefined())
+ if (tag_decl->getDefinition())
return true;
return CompleteTagDecl(tag_decl);
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 4b52f6aafcb75..21a930745893a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -223,7 +223,7 @@ TagDecl *ClangASTSource::FindCompleteType(const TagDecl *decl) {
continue;
TagDecl *candidate_tag_decl =
- const_cast<TagDecl *>(tag_type->getDecl());
+ tag_type->getOriginalDecl()->getDefinitionOrSelf();
if (TypeSystemClang::GetCompleteDecl(
&candidate_tag_decl->getASTContext(), candidate_tag_decl))
@@ -250,7 +250,8 @@ TagDecl *ClangASTSource::FindCompleteType(const TagDecl *decl) {
if (!tag_type)
continue;
- TagDecl *candidate_tag_decl = const_cast<TagDecl *>(tag_type->getDecl());
+ TagDecl *candidate_tag_decl =
+ tag_type->getOriginalDecl()->getDefinitionOrSelf();
if (TypeSystemClang::GetCompleteDecl(&candidate_tag_decl->getASTContext(),
candidate_tag_decl))
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 9f77fbc1d2434..69abb92604a45 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -839,7 +839,7 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
clang::CXXRecordDecl *class_decl = method_decl->getParent();
- QualType class_qual_type(class_decl->getTypeForDecl(), 0);
+ QualType class_qual_type = m_ast_context->getCanonicalTagType(class_decl);
TypeFromUser class_user_type(
class_qual_type.getAsOpaquePtr(),
@@ -1561,7 +1561,7 @@ ClangExpressionDeclMap::AddExpressionVariable(NameSearchContext &context,
if (const clang::Type *parser_type = parser_opaque_type.getTypePtr()) {
if (const TagType *tag_type = dyn_cast<TagType>(parser_type))
- CompleteType(tag_type->getDecl());
+ CompleteType(tag_type->getOriginalDecl()->getDefinitionOrSelf());
if (const ObjCObjectPointerType *objc_object_ptr_type =
dyn_cast<ObjCObjectPointerType>(parser_type))
CompleteType(objc_object_ptr_type->getInterfaceDecl());
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index aa0e6e37d63e0..319ff3fe8b447 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -79,9 +79,11 @@ ClangPersistentVariables::GetCompilerTypeFromPersistentDecl(
if (p.m_decl == nullptr)
return std::nullopt;
+ auto ctx = std::static_pointer_cast<TypeSystemClang>(p.m_context.lock());
if (clang::TypeDecl *tdecl = llvm::dyn_cast<clang::TypeDecl>(p.m_decl)) {
- opaque_compiler_type_t t = static_cast<opaque_compiler_type_t>(
- const_cast<clang::Type *>(tdecl->getTypeForDecl()));
+ opaque_compiler_type_t t =
+ static_cast<opaque_compiler_type_t>(const_cast<clang::Type *>(
+ ctx->getASTContext().getTypeDeclType(tdecl).getTypePtr()));
return CompilerType(p.m_context, t);
}
return std::nullopt;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
index 45ad4f1ad98b9..6f57c18063672 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
@@ -153,7 +153,7 @@ NameSearchContext::AddTypeDecl(const CompilerType &clang_type) {
return (NamedDecl *)typedef_name_decl;
} else if (const TagType *tag_type = qual_type->getAs<TagType>()) {
- TagDecl *tag_decl = tag_type->getDecl();
+ TagDecl *tag_decl = tag_type->getOriginalDecl()->getDefinitionOrSelf();
m_decls.push_back(tag_decl);
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index ef1c2c89fe125..24e84899e683c 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -73,7 +73,8 @@ static CompilerType GetLLDBNSPairType(TargetSP target_sp) {
static constexpr llvm::StringLiteral g_lldb_autogen_nspair("__lldb_autogen_nspair");
- compiler_type = scratch_ts_sp->GetTypeForIdentifier<clang::CXXRecordDecl>(g_lldb_autogen_nspair);
+ compiler_type = scratch_ts_sp->GetTypeForIdentifier<clang::CXXRecordDecl>(
+ scratch_ts_sp->getASTContext(), g_lldb_autogen_nspair);
if (!compiler_type) {
compiler_type = scratch_ts_sp->CreateRecordType(
diff --git a/lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp b/lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp
index f19dc8b1e6e58..eb9e013f4429a 100644
--- a/lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp
+++ b/lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp
@@ -47,7 +47,7 @@ CompilerType RegisterTypeBuilderClang::GetRegisterType(
// See if we have made this type before and can reuse it.
CompilerType fields_type =
type_system->GetTypeForIdentifier<clang::CXXRecordDecl>(
- register_type_name);
+ type_system->getASTContext(), register_type_name);
if (!fields_type) {
// In most ABI, a change of field type means a change in storage unit.
@@ -83,7 +83,7 @@ CompilerType RegisterTypeBuilderClang::GetRegisterType(
// may have built this one already.
CompilerType field_enum_type =
type_system->GetTypeForIdentifier<clang::EnumDecl>(
- enum_type_name);
+ type_system->getASTContext(), enum_type_name);
if (field_enum_type)
field_type = field_enum_type;
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index 702ec5e5c9ea9..df2fb519536a1 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -449,7 +449,7 @@ bool PdbAstBuilder::CompleteTagDecl(clang::TagDecl &tag) {
->GetIndex();
lldbassert(IsTagRecord(type_id, index.tpi()));
- clang::QualType tag_qt = m_clang.getASTContext().getTypeDeclType(&tag);
+ clang::QualType tag_qt = m_clang.getASTContext().getCanonicalTagType(&tag);
TypeSystemClang::SetHasExternalStorage(tag_qt.getAsOpaquePtr(), false);
TypeIndex tag_ti = type_id.index;
@@ -562,7 +562,8 @@ clang::QualType PdbAstBuilder::CreatePointerType(const PointerRecord &pointer) {
m_clang.getASTContext(), spelling));
}
return m_clang.getASTContext().getMemberPointerType(
- pointee_type, /*Qualifier=*/nullptr, class_type->getAsCXXRecordDecl());
+ pointee_type, /*Qualifier=*/std::nullopt,
+ class_type->getAsCXXRecordDecl());
}
clang::QualType pointer_type;
@@ -859,9 +860,9 @@ PdbAstBuilder::CreateFunctionDecl(PdbCompilandSymId func_id,
SymbolFileNativePDB *pdb = static_cast<SymbolFileNativePDB *>(
m_clang.GetSymbolFile()->GetBackingSymbolFile());
PdbIndex &index = pdb->GetIndex();
- clang::QualType parent_qt = llvm::cast<clang::TypeDecl>(parent)
- ->getTypeForDecl()
- ->getCanonicalTypeInternal();
+ clang::CanQualType parent_qt =
+ m_clang.getASTContext().getCanonicalTypeDeclType(
+ llvm::cast<clang::TypeDecl>(parent));
lldb::opaque_compiler_type_t parent_opaque_ty =
ToCompilerType(parent_qt).GetOpaqueQualType();
// FIXME: Remove this workaround.
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index 0090d8ff03ab6..c837315a51bcd 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -407,8 +407,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
// symbols in PDB for types with const or volatile modifiers, but we need
// to create only one declaration for them all.
Type::ResolveState type_resolve_state;
- CompilerType clang_type =
- m_ast.GetTypeForIdentifier<clang::CXXRecordDecl>(name, decl_context);
+ CompilerType clang_type = m_ast.GetTypeForIdentifier<clang::CXXRecordDecl>(
+ m_ast.getASTContext(), name, decl_context);
if (!clang_type.IsValid()) {
auto access = GetAccessibilityForUdt(*udt);
@@ -479,8 +479,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
uint64_t bytes = enum_type->getLength();
// Check if such an enum already exists in the current context
- CompilerType ast_enum =
- m_ast.GetTypeForIdentifier<clang::EnumDecl>(name, decl_context);
+ CompilerType ast_enum = m_ast.GetTypeForIdentifier<clang::EnumDecl>(
+ m_ast.getASTContext(), name, decl_context);
if (!ast_enum.IsValid()) {
auto underlying_type_up = enum_type->getUnderlyingType();
if (!underlying_type_up)
@@ -557,7 +557,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
// Check if such a typedef already exists in the current context
CompilerType ast_typedef =
- m_ast.GetTypeForIdentifier<clang::TypedefNameDecl>(name, decl_ctx);
+ m_ast.GetTypeForIdentifier<clang::TypedefNameDecl>(
+ m_ast.getASTContext(), name, decl_ctx);
if (!ast_typedef.IsValid()) {
CompilerType target_ast_type = target_type->GetFullCompilerType();
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 3226e0accc5ea..8d89ba9c96e1c 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -160,8 +160,7 @@ void addOverridesForMethod(clang::CXXMethodDecl *decl) {
auto find_overridden_methods =
[&decls, decl](const clang::CXXBaseSpecifier *specifier,
clang::CXXBasePath &path) {
- if (auto *base_record = llvm::dyn_cast<clang::CXXRecordDecl>(
- specifier->getType()->castAs<clang::RecordType>()->getDecl())) {
+ if (auto *base_record = specifier->getType()->getAsCXXRecordDecl()) {
clang::DeclarationName name = decl->getDeclName();
@@ -1168,7 +1167,7 @@ CompilerType TypeSystemClang::GetTypeForDecl(clang::NamedDecl *decl) {
}
CompilerType TypeSystemClang::GetTypeForDecl(TagDecl *decl) {
- return GetType(getASTContext().getTagDeclType(decl));
+ return GetType(getASTContext().getCanonicalTagType(decl));
}
CompilerType TypeSystemClang::GetTypeForDecl(ObjCInterfaceDecl *decl) {
@@ -1295,7 +1294,7 @@ CompilerType TypeSystemClang::CreateRecordType(
if (decl_ctx)
decl_ctx->addDecl(decl);
- return GetType(ast.getTagDeclType(decl));
+ return GetType(ast.getCanonicalTagType(decl));
}
namespace {
@@ -1662,7 +1661,6 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(
class_template_specialization_decl->setInstantiationOf(class_template_decl);
class_template_specialization_decl->setTemplateArgs(
TemplateArgumentList::CreateCopy(ast, args));
- ast.getTypeDeclType(class_template_specialization_decl, nullptr);
class_template_specialization_decl->setDeclName(
class_template_decl->getDeclName());
@@ -1684,7 +1682,7 @@ CompilerType TypeSystemClang::CreateClassTemplateSpecializationType(
ClassTemplateSpecializationDecl *class_template_specialization_decl) {
if (class_template_specialization_decl) {
ASTContext &ast = getASTContext();
- return GetType(ast.getTagDeclType(class_template_specialization_decl));
+ return GetType(ast.getCanonicalTagType(class_template_specialization_decl));
}
return CompilerType();
}
@@ -1780,9 +1778,7 @@ bool TypeSystemClang::RecordHasFields(const RecordDecl *record_decl) {
for (base_class = cxx_record_decl->bases_begin(),
base_class_end = cxx_record_decl->bases_end();
base_class != base_class_end; ++base_class) {
- const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(
- base_class->getType()->getAs<RecordType>()->getDecl());
- if (RecordHasFields(base_class_decl))
+ if (RecordHasFields(base_class->getType()->getAsCXXRecordDecl()))
return true;
}
}
@@ -2262,9 +2258,9 @@ CompilerType TypeSystemClang::CreateStructForIdentifier(
&type_fields,
bool packed) {
CompilerType type;
- if (!type_name.empty() &&
- (type = GetTypeForIdentifier<clang::CXXRecordDecl>(type_name))
- .IsValid()) {
+ if (!type_name.empty() && (type = GetTypeForIdentifier<clang::CXXRecordDecl>(
+ getASTContext(), type_name))
+ .IsValid()) {
lldbassert(0 && "Trying to create a type for an existing name");
return type;
}
@@ -2288,7 +2284,9 @@ CompilerType TypeSystemClang::GetOrCreateStructForIdentifier(
&type_fields,
bool packed) {
CompilerType type;
- if ((type = GetTypeForIdentifier<clang::CXXRecordDecl>(type_name)).IsValid())
+ if ((type = GetTypeForIdentifier<clang::CXXRecordDecl>(getASTContext(),
+ type_name))
+ .IsValid())
return type;
return CreateStructForIdentifier(type_name, type_fields, packed);
@@ -2327,7 +2325,7 @@ CompilerType TypeSystemClang::CreateEnumerationType(
enum_decl->setAccess(AS_public); // TODO respect what's in the debug info
- return GetType(ast.getTagDeclType(enum_decl));
+ return GetType(ast.getCanonicalTagType(enum_decl));
}
CompilerType TypeSystemClang::GetIntTypeFromBitSize(size_t bit_size,
@@ -2443,7 +2441,7 @@ bool TypeSystemClang::GetCompleteDecl(clang::ASTContext *ast,
ast_source->CompleteType(tag_decl);
- return !tag_decl->getTypeForDecl()->isIncompleteType();
+ return !ast->getCanonicalTagType(tag_decl)->isIncompleteType();
} else if (clang::ObjCInterfaceDecl *objc_interface_decl =
llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl)) {
if (objc_interface_decl->getDefinition())
@@ -2547,7 +2545,6 @@ RemoveWrappingTypes(QualType type, ArrayRef<clang::Type::TypeClass> mask = {}) {
break;
case clang::Type::Auto:
case clang::Type::Decltype:
- case clang::Type::Elaborated:
case clang::Type::Paren:
case clang::Type::SubstTemplateTypeParm:
case clang::Type::TemplateSpecialization:
@@ -2579,10 +2576,11 @@ TypeSystemClang::GetDeclContextForType(clang::QualType type) {
return GetDeclContextForType(
llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
->getPointeeType());
- case clang::Type::Record:
- return llvm::cast<clang::RecordType>(qual_type)->getDecl();
case clang::Type::Enum:
- return llvm::cast<clang::EnumType>(qual_type)->getDecl();
+ case clang::Type::Record:
+ return llvm::cast<clang::TagType>(qual_type)
+ ->getOriginalDecl()
+ ->getDefinitionOrSelf();
default:
break;
}
@@ -2762,7 +2760,7 @@ static bool GetCompleteQualType(clang::ASTContext *ast,
if (ast->getTargetInfo().getCXXABI().isMicrosoft()) {
auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>();
if (auto *RD = MPT->getMostRecentCXXRecordDecl())
- GetCompleteRecordType(ast, QualType(RD->getTypeForDecl(), 0),
+ GetCompleteRecordType(ast, ast->getCanonicalTagType(RD),
allow_completion);
return !qual_type.getTypePtr()->isIncompleteType();
@@ -2831,7 +2829,8 @@ bool TypeSystemClang::IsAnonymousType(lldb::opaque_compiler_type_t type) {
if (const clang::RecordType *record_type =
llvm::dyn_cast_or_null<clang::RecordType>(
qual_type.getTypePtrOrNull())) {
- if (const clang::RecordDecl *record_decl = record_type->getDecl()) {
+ if (const clang::RecordDecl *record_decl =
+ record_type->getOriginalDecl()) {
return record_decl->isAnonymousStructOrUnion();
}
}
@@ -3071,8 +3070,8 @@ TypeSystemClang::IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
const clang::RecordType *record_type =
llvm::cast<clang::RecordType>(qual_type.getTypePtr());
if (record_type) {
- const clang::RecordDecl *record_decl = record_type->getDecl();
- if (record_decl) {
+ if (const clang::RecordDecl *record_decl =
+ record_type->getOriginalDecl()->getDefinition()) {
// We are looking for a structure that contains only floating point
// types
clang::RecordDecl::field_iterator field_pos,
@@ -3252,7 +3251,10 @@ bool TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
GetCanonicalQualType(type)->getCanonicalTypeInternal());
if (enum_type) {
- IsIntegerType(enum_type->getDecl()->getIntegerType().getAsOpaquePtr(),
+ IsIntegerType(enum_type->getOriginalDecl()
+ ->getDefinitionOrSelf()
+ ->getIntegerType()
+ .getAsOpaquePtr(),
is_signed);
return true;
}
@@ -3477,8 +3479,7 @@ bool TypeSystemClang::IsDefined(lldb::opaque_compiler_type_t type) {
const clang::TagType *tag_type =
llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr());
if (tag_type) {
- clang::TagDecl *tag_decl = tag_type->getDecl();
- if (tag_decl)
+ if (clang::TagDecl *tag_decl = tag_type->getOriginalDecl()->getDefinition())
return tag_decl->isCompleteDefinition();
return false;
} else {
@@ -3537,21 +3538,14 @@ bool TypeSystemClang::IsPolymorphicClass(lldb::opaque_compiler_type_t type) {
switch (type_class) {
case clang::Type::Record:
if (GetCompleteType(type)) {
- const clang::RecordType *record_type =
- llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- if (record_decl) {
- const clang::CXXRecordDecl *cxx_record_decl =
- llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
- if (cxx_record_decl) {
- // We can't just call is isPolymorphic() here because that just
- // means the current class has virtual functions, it doesn't check
- // if any inherited classes have virtual functions. The doc string
- // in SBType::IsPolymorphicClass() says it is looking for both
- // if the class has virtual methods or if any bases do, so this
- // should be more correct.
- return cxx_record_decl->isDynamicClass();
- }
+ if (const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
+ // We can't just call is isPolymorphic() here because that just
+ // means the current class has virtual functions, it doesn't check
+ // if any inherited classes have virtual functions. The doc string
+ // in SBType::IsPolymorphicClass() says it is looking for both
+ // if the class has virtual methods or if any bases do, so this
+ // should be more correct.
+ return cxx_record_decl->isDynamicClass();
}
}
break;
@@ -3738,7 +3732,7 @@ bool TypeSystemClang::IsBeingDefined(lldb::opaque_compiler_type_t type) {
clang::QualType qual_type(GetCanonicalQualType(type));
const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type);
if (tag_type)
- return tag_type->isBeingDefined();
+ return tag_type->getOriginalDecl()->isEntityBeingDefined();
return false;
}
@@ -3946,7 +3940,8 @@ TypeSystemClang::GetTypeInfo(lldb::opaque_compiler_type_t type,
if (pointee_or_element_clang_type)
pointee_or_element_clang_type->SetCompilerType(
weak_from_this(), llvm::cast<clang::EnumType>(qual_type)
- ->getDecl()
+ ->getOriginalDecl()
+ ->getDefinitionOrSelf()
->getIntegerType()
.getAsOpaquePtr());
return eTypeIsEnumeration | eTypeHasValue;
@@ -4126,7 +4121,6 @@ TypeSystemClang::GetTypeClass(lldb::opaque_compiler_type_t type) {
case clang::Type::Auto:
case clang::Type::CountAttributed:
case clang::Type::Decltype:
- case clang::Type::Elaborated:
case clang::Type::Paren:
case clang::Type::TypeOf:
case clang::Type::TypeOfExpr:
@@ -4186,7 +4180,7 @@ TypeSystemClang::GetTypeClass(lldb::opaque_compiler_type_t type) {
case clang::Type::Record: {
const clang::RecordType *record_type =
llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
+ const clang::RecordDecl *record_decl = record_type->getOriginalDecl();
if (record_decl->isUnion())
return lldb::eTypeClassUnion;
else if (record_decl->isStruct())
@@ -4384,17 +4378,10 @@ TypeSystemClang::GetNumMemberFunctions(lldb::opaque_compiler_type_t type) {
clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
switch (qual_type->getTypeClass()) {
case clang::Type::Record:
- if (GetCompleteQualType(&getASTContext(), qual_type)) {
- const clang::RecordType *record_type =
- llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
- const clang::CXXRecordDecl *cxx_record_decl =
- llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
- if (cxx_record_decl)
+ if (GetCompleteQualType(&getASTContext(), qual_type))
+ if (const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl())
num_functions = std::distance(cxx_record_decl->method_begin(),
cxx_record_decl->method_end());
- }
break;
case clang::Type::ObjCObjectPointer: {
@@ -4449,13 +4436,7 @@ TypeSystemClang::GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
switch (qual_type->getTypeClass()) {
case clang::Type::Record:
if (GetCompleteQualType(&getASTContext(), qual_type)) {
- const clang::RecordType *record_type =
- llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
- const clang::CXXRecordDecl *cxx_record_decl =
- llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
- if (cxx_record_decl) {
+ if (const auto *cxx_record_decl = qual_type->getAsCXXRecordDecl()) {
auto method_iter = cxx_record_decl->method_begin();
auto method_end = cxx_record_decl->method_end();
if (idx <
@@ -4675,9 +4656,9 @@ CompilerType TypeSystemClang::CreateTypedef(
clang::TagDecl *tdecl = nullptr;
if (!qual_type.isNull()) {
if (const clang::RecordType *rt = qual_type->getAs<clang::RecordType>())
- tdecl = rt->getDecl();
+ tdecl = rt->getOriginalDecl();
if (const clang::EnumType *et = qual_type->getAs<clang::EnumType>())
- tdecl = et->getDecl();
+ tdecl = et->getOriginalDecl();
}
// Check whether this declaration is an anonymous struct, union, or enum,
@@ -4689,7 +4670,8 @@ CompilerType TypeSystemClang::CreateTypedef(
decl->setAccess(clang::AS_public); // TODO respect proper access specifier
// Get a uniqued clang::QualType for the typedef decl type
- return GetType(clang_ast.getTypedefType(decl));
+ return GetType(clang_ast.getTypedefType(ElaboratedTypeKeyword::None,
+ /*Qualifier=*/std::nullopt, decl));
}
return CompilerType();
}
@@ -4836,7 +4818,6 @@ lldb::Encoding TypeSystemClang::GetEncoding(lldb::opaque_compiler_type_t type,
case clang::Type::Auto:
case clang::Type::CountAttributed:
case clang::Type::Decltype:
- case clang::Type::Elaborated:
case clang::Type::Paren:
case clang::Type::Typedef:
case clang::Type::TypeOf:
@@ -5138,7 +5119,6 @@ lldb::Format TypeSystemClang::GetFormat(lldb::opaque_compiler_type_t type) {
case clang::Type::Auto:
case clang::Type::CountAttributed:
case clang::Type::Decltype:
- case clang::Type::Elaborated:
case clang::Type::Paren:
case clang::Type::Typedef:
case clang::Type::TypeOf:
@@ -5345,8 +5325,8 @@ TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
if (GetCompleteQualType(&getASTContext(), qual_type)) {
const clang::RecordType *record_type =
llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
+ const clang::RecordDecl *record_decl =
+ record_type->getOriginalDecl()->getDefinitionOrSelf();
const clang::CXXRecordDecl *cxx_record_decl =
llvm::dyn_cast<clang::CXXRecordDecl>(record_decl);
@@ -5540,7 +5520,8 @@ void TypeSystemClang::ForEachEnumerator(
const clang::EnumType *enum_type =
llvm::dyn_cast<clang::EnumType>(GetCanonicalQualType(type));
if (enum_type) {
- const clang::EnumDecl *enum_decl = enum_type->getDecl();
+ const clang::EnumDecl *enum_decl =
+ enum_type->getOriginalDecl()->getDefinitionOrSelf();
if (enum_decl) {
CompilerType integer_type = GetType(enum_decl->getIntegerType());
@@ -5571,7 +5552,8 @@ uint32_t TypeSystemClang::GetNumFields(lldb::opaque_compiler_type_t type) {
const clang::RecordType *record_type =
llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
if (record_type) {
- clang::RecordDecl *record_decl = record_type->getDecl();
+ clang::RecordDecl *record_decl =
+ record_type->getOriginalDecl()->getDefinition();
if (record_decl) {
count = std::distance(record_decl->field_begin(),
record_decl->field_end());
@@ -5685,7 +5667,8 @@ CompilerType TypeSystemClang::GetFieldAtIndex(lldb::opaque_compiler_type_t type,
if (GetCompleteType(type)) {
const clang::RecordType *record_type =
llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
+ const clang::RecordDecl *record_decl =
+ record_type->getOriginalDecl()->getDefinitionOrSelf();
uint32_t field_idx = 0;
clang::RecordDecl::field_iterator field, field_end;
for (field = record_decl->field_begin(),
@@ -5871,7 +5854,7 @@ CompilerType TypeSystemClang::GetDirectBaseClassAtIndex(
llvm::cast<clang::CXXRecordDecl>(
base_class->getType()
->castAs<clang::RecordType>()
- ->getDecl());
+ ->getOriginalDecl());
if (base_class->isVirtual())
*bit_offset_ptr =
record_layout.getVBaseClassOffset(base_class_decl)
@@ -5966,7 +5949,7 @@ CompilerType TypeSystemClang::GetVirtualBaseClassAtIndex(
llvm::cast<clang::CXXRecordDecl>(
base_class->getType()
->castAs<clang::RecordType>()
- ->getDecl());
+ ->getOriginalDecl());
*bit_offset_ptr =
record_layout.getVBaseClassOffset(base_class_decl)
.getQuantity() *
@@ -5996,7 +5979,8 @@ TypeSystemClang::GetStaticFieldWithName(lldb::opaque_compiler_type_t type,
const clang::RecordType *record_type =
llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
+ const clang::RecordDecl *record_decl =
+ record_type->getOriginalDecl()->getDefinitionOrSelf();
clang::DeclarationName decl_name(&getASTContext().Idents.get(name));
for (NamedDecl *decl : record_decl->lookup(decl_name)) {
@@ -6225,8 +6209,8 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
if (idx_is_valid && GetCompleteType(type)) {
const clang::RecordType *record_type =
llvm::cast<clang::RecordType>(parent_qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
+ const clang::RecordDecl *record_decl =
+ record_type->getOriginalDecl()->getDefinitionOrSelf();
const clang::ASTRecordLayout &record_layout =
getASTContext().getASTRecordLayout(record_decl);
uint32_t child_idx = 0;
@@ -6245,7 +6229,10 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
// Skip empty base classes
if (omit_empty_base_classes) {
base_class_decl = llvm::cast<clang::CXXRecordDecl>(
- base_class->getType()->getAs<clang::RecordType>()->getDecl());
+ base_class->getType()
+ ->getAs<clang::RecordType>()
+ ->getOriginalDecl())
+ ->getDefinitionOrSelf();
if (!TypeSystemClang::RecordHasFields(base_class_decl))
continue;
}
@@ -6253,7 +6240,10 @@ llvm::Expected<CompilerType> TypeSystemClang::GetChildCompilerTypeAtIndex(
if (idx == child_idx) {
if (base_class_decl == nullptr)
base_class_decl = llvm::cast<clang::CXXRecordDecl>(
- base_class->getType()->getAs<clang::RecordType>()->getDecl());
+ base_class->getType()
+ ->getAs<clang::RecordType>()
+ ->getOriginalDecl())
+ ->getDefinitionOrSelf();
if (base_class->isVirtual()) {
bool handled = false;
@@ -6714,7 +6704,8 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
if (GetCompleteType(type)) {
const clang::RecordType *record_type =
llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
+ const clang::RecordDecl *record_decl =
+ record_type->getOriginalDecl()->getDefinitionOrSelf();
assert(record_decl);
uint32_t child_idx = 0;
@@ -6779,10 +6770,10 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
return 0;
} else {
child_indexes.push_back(child_idx);
- parent_record_decl = llvm::cast<clang::RecordDecl>(
- elem.Base->getType()
- ->castAs<clang::RecordType>()
- ->getDecl());
+ parent_record_decl = elem.Base->getType()
+ ->castAs<clang::RecordType>()
+ ->getOriginalDecl()
+ ->getDefinitionOrSelf();
}
}
for (clang::DeclContext::lookup_iterator I = path->Decls, E;
@@ -6916,7 +6907,8 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
if (GetCompleteType(type)) {
const clang::RecordType *record_type =
llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
+ const clang::RecordDecl *record_decl =
+ record_type->getOriginalDecl()->getDefinitionOrSelf();
assert(record_decl);
uint32_t child_idx = 0;
@@ -6935,7 +6927,8 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
llvm::cast<clang::CXXRecordDecl>(
base_class->getType()
->castAs<clang::RecordType>()
- ->getDecl());
+ ->getOriginalDecl())
+ ->getDefinitionOrSelf();
if (omit_empty_base_classes &&
!TypeSystemClang::RecordHasFields(base_class_decl))
continue;
@@ -7054,14 +7047,17 @@ TypeSystemClang::GetDirectNestedTypeWithName(lldb::opaque_compiler_type_t type,
return CompilerType();
const clang::RecordType *record_type =
llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
+ const clang::RecordDecl *record_decl =
+ record_type->getOriginalDecl()->getDefinitionOrSelf();
clang::DeclarationName decl_name(&getASTContext().Idents.get(name));
for (NamedDecl *decl : record_decl->lookup(decl_name)) {
if (auto *tag_decl = dyn_cast<clang::TagDecl>(decl))
- return GetType(getASTContext().getTagDeclType(tag_decl));
+ return GetType(getASTContext().getCanonicalTagType(tag_decl));
if (auto *typedef_decl = dyn_cast<clang::TypedefNameDecl>(decl))
- return GetType(getASTContext().getTypedefType(typedef_decl));
+ return GetType(getASTContext().getTypedefType(
+ ElaboratedTypeKeyword::None, /*Qualifier=*/std::nullopt,
+ typedef_decl));
}
break;
}
@@ -7078,7 +7074,7 @@ bool TypeSystemClang::IsTemplateType(lldb::opaque_compiler_type_t type) {
const clang::Type *clang_type = ClangUtil::GetQualType(ct).getTypePtr();
if (auto *cxx_record_decl = dyn_cast<clang::TagType>(clang_type))
return isa<clang::ClassTemplateSpecializationDecl>(
- cxx_record_decl->getDecl());
+ cxx_record_decl->getOriginalDecl());
return false;
}
@@ -7281,7 +7277,7 @@ clang::EnumDecl *TypeSystemClang::GetAsEnumDecl(const CompilerType &type) {
const clang::EnumType *enutype =
llvm::dyn_cast<clang::EnumType>(ClangUtil::GetCanonicalQualType(type));
if (enutype)
- return enutype->getDecl();
+ return enutype->getOriginalDecl()->getDefinitionOrSelf();
return nullptr;
}
@@ -7289,7 +7285,7 @@ clang::RecordDecl *TypeSystemClang::GetAsRecordDecl(const CompilerType &type) {
const clang::RecordType *record_type =
llvm::dyn_cast<clang::RecordType>(ClangUtil::GetCanonicalQualType(type));
if (record_type)
- return record_type->getDecl();
+ return record_type->getOriginalDecl()->getDefinitionOrSelf();
return nullptr;
}
@@ -7371,7 +7367,7 @@ clang::FieldDecl *TypeSystemClang::AddFieldToRecordType(
if (const clang::TagType *TagT =
field->getType()->getAs<clang::TagType>()) {
if (clang::RecordDecl *Rec =
- llvm::dyn_cast<clang::RecordDecl>(TagT->getDecl()))
+ llvm::dyn_cast<clang::RecordDecl>(TagT->getOriginalDecl()))
if (!Rec->getDeclName()) {
Rec->setAnonymousStructOrUnion(true);
field->setImplicit();
@@ -7456,7 +7452,8 @@ void TypeSystemClang::BuildIndirectFields(const CompilerType &type) {
if (!field_record_type)
continue;
- clang::RecordDecl *field_record_decl = field_record_type->getDecl();
+ clang::RecordDecl *field_record_decl =
+ field_record_type->getOriginalDecl()->getDefinition();
if (!field_record_decl)
continue;
@@ -7598,7 +7595,8 @@ void TypeSystemClang::SetIntegerInitializerForVariable(
// If the variable is an enum type, take the underlying integer type as
// the type of the integer literal.
if (const EnumType *enum_type = qt->getAs<EnumType>()) {
- const EnumDecl *enum_decl = enum_type->getDecl();
+ const EnumDecl *enum_decl =
+ enum_type->getOriginalDecl()->getDefinitionOrSelf();
qt = enum_decl->getIntegerType();
}
// Bools are handled separately because the clang AST printer handles bools
@@ -8259,7 +8257,7 @@ bool TypeSystemClang::SetHasExternalStorage(lldb::opaque_compiler_type_t type,
case clang::Type::Enum: {
clang::EnumDecl *enum_decl =
- llvm::cast<clang::EnumType>(qual_type)->getDecl();
+ llvm::cast<clang::EnumType>(qual_type)->getOriginalDecl();
if (enum_decl) {
enum_decl->setHasExternalLexicalStorage(has_extern);
enum_decl->setHasExternalVisibleStorage(has_extern);
@@ -8297,7 +8295,7 @@ bool TypeSystemClang::StartTagDeclarationDefinition(const CompilerType &type) {
if (!qual_type.isNull()) {
const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
if (tag_type) {
- clang::TagDecl *tag_decl = tag_type->getDecl();
+ clang::TagDecl *tag_decl = tag_type->getOriginalDecl();
if (tag_decl) {
tag_decl->startDefinition();
return true;
@@ -8332,7 +8330,8 @@ bool TypeSystemClang::CompleteTagDeclarationDefinition(
// the definition.
const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
if (tag_type) {
- clang::TagDecl *tag_decl = tag_type->getDecl();
+ clang::TagDecl *tag_decl =
+ tag_type->getOriginalDecl()->getDefinitionOrSelf();
if (auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
// If we have a move constructor declared but no copy constructor we
@@ -8367,7 +8366,8 @@ bool TypeSystemClang::CompleteTagDeclarationDefinition(
if (!enutype)
return false;
- clang::EnumDecl *enum_decl = enutype->getDecl();
+ clang::EnumDecl *enum_decl =
+ enutype->getOriginalDecl()->getDefinitionOrSelf();
if (enum_decl->isCompleteDefinition())
return true;
@@ -8425,17 +8425,19 @@ clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType(
clang::EnumConstantDecl *enumerator_decl =
clang::EnumConstantDecl::CreateDeserialized(getASTContext(),
GlobalDeclID());
- enumerator_decl->setDeclContext(enutype->getDecl());
+ clang::EnumDecl *enum_decl =
+ enutype->getOriginalDecl()->getDefinitionOrSelf();
+ enumerator_decl->setDeclContext(enum_decl);
if (name && name[0])
enumerator_decl->setDeclName(&getASTContext().Idents.get(name));
enumerator_decl->setType(clang::QualType(enutype, 0));
enumerator_decl->setInitVal(getASTContext(), value);
- SetMemberOwningModule(enumerator_decl, enutype->getDecl());
+ SetMemberOwningModule(enumerator_decl, enum_decl);
if (!enumerator_decl)
return nullptr;
- enutype->getDecl()->addDecl(enumerator_decl);
+ enum_decl->addDecl(enumerator_decl);
VerifyDecl(enumerator_decl);
return enumerator_decl;
@@ -8459,7 +8461,8 @@ CompilerType TypeSystemClang::GetEnumerationIntegerType(CompilerType type) {
if (!enum_type)
return CompilerType();
- return GetType(enum_type->getDecl()->getIntegerType());
+ return GetType(
+ enum_type->getOriginalDecl()->getDefinitionOrSelf()->getIntegerType());
}
CompilerType
@@ -8472,7 +8475,7 @@ TypeSystemClang::CreateMemberPointerType(const CompilerType &type,
return CompilerType();
return ast->GetType(ast->getASTContext().getMemberPointerType(
ClangUtil::GetQualType(pointee_type),
- /*Qualifier=*/nullptr,
+ /*Qualifier=*/std::nullopt,
ClangUtil::GetQualType(type)->getAsCXXRecordDecl()));
}
return CompilerType();
@@ -8550,8 +8553,8 @@ static bool DumpEnumValue(const clang::QualType &qual_type, Stream &s,
uint32_t bitfield_bit_size) {
const clang::EnumType *enutype =
llvm::cast<clang::EnumType>(qual_type.getTypePtr());
- const clang::EnumDecl *enum_decl = enutype->getDecl();
- assert(enum_decl);
+ const clang::EnumDecl *enum_decl =
+ enutype->getOriginalDecl()->getDefinitionOrSelf();
lldb::offset_t offset = byte_offset;
bool qual_type_is_signed = qual_type->isSignedIntegerOrEnumerationType();
const uint64_t enum_svalue =
@@ -8657,15 +8660,7 @@ bool TypeSystemClang::DumpTypeValue(
} else {
clang::QualType qual_type(GetQualType(type));
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
-
- if (type_class == clang::Type::Elaborated) {
- qual_type = llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType();
- return DumpTypeValue(qual_type.getAsOpaquePtr(), s, format, data, byte_offset, byte_size,
- bitfield_bit_size, bitfield_bit_offset, exe_scope);
- }
-
- switch (type_class) {
+ switch (qual_type->getTypeClass()) {
case clang::Type::Typedef: {
clang::QualType typedef_qual_type =
llvm::cast<clang::TypedefType>(qual_type)
@@ -8834,7 +8829,7 @@ void TypeSystemClang::DumpTypeDescription(lldb::opaque_compiler_type_t type,
GetCompleteType(type);
auto *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
- const clang::RecordDecl *record_decl = record_type->getDecl();
+ const clang::RecordDecl *record_decl = record_type->getOriginalDecl();
if (level == eDescriptionLevelVerbose)
record_decl->dump(llvm_ostrm);
else {
@@ -8846,7 +8841,7 @@ void TypeSystemClang::DumpTypeDescription(lldb::opaque_compiler_type_t type,
default: {
if (auto *tag_type =
llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
- if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
+ if (clang::TagDecl *tag_decl = tag_type->getOriginalDecl()) {
if (level == eDescriptionLevelVerbose)
tag_decl->dump(llvm_ostrm);
else
@@ -8886,7 +8881,7 @@ void TypeSystemClang::DumpTypeName(const CompilerType &type) {
case clang::Type::Enum: {
clang::EnumDecl *enum_decl =
- llvm::cast<clang::EnumType>(qual_type)->getDecl();
+ llvm::cast<clang::EnumType>(qual_type)->getOriginalDecl();
if (enum_decl) {
printf("enum %s", enum_decl->getName().str().c_str());
}
@@ -8922,13 +8917,6 @@ void TypeSystemClang::DumpTypeName(const CompilerType &type) {
->getDeducedType()
.getAsOpaquePtr()));
- case clang::Type::Elaborated:
- printf("elaborated ");
- return DumpTypeName(CompilerType(
- type.GetTypeSystem(), llvm::cast<clang::ElaboratedType>(qual_type)
- ->getNamedType()
- .getAsOpaquePtr()));
-
case clang::Type::Paren:
printf("paren ");
return DumpTypeName(CompilerType(
@@ -9736,8 +9724,8 @@ bool TypeSystemClang::IsForcefullyCompleted(lldb::opaque_compiler_type_t type) {
const clang::RecordType *record_type =
llvm::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
if (record_type) {
- const clang::RecordDecl *record_decl = record_type->getDecl();
- assert(record_decl);
+ const clang::RecordDecl *record_decl =
+ record_type->getOriginalDecl()->getDefinitionOrSelf();
if (std::optional<ClangASTMetadata> metadata = GetMetadata(record_decl))
return metadata->IsForcefullyCompleted();
}
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 63dee9dceded3..b0cd04398bd22 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -260,7 +260,7 @@ class TypeSystemClang : public TypeSystem {
template <typename RecordDeclType>
CompilerType
- GetTypeForIdentifier(llvm::StringRef type_name,
+ GetTypeForIdentifier(const clang::ASTContext &Ctx, llvm::StringRef type_name,
clang::DeclContext *decl_context = nullptr) {
CompilerType compiler_type;
if (type_name.empty())
@@ -278,11 +278,10 @@ class TypeSystemClang : public TypeSystem {
return compiler_type;
clang::NamedDecl *named_decl = *result.begin();
- if (const RecordDeclType *record_decl =
- llvm::dyn_cast<RecordDeclType>(named_decl))
+ if (const auto *type_decl = llvm::dyn_cast<clang::TypeDecl>(named_decl);
+ llvm::isa_and_nonnull<RecordDeclType>(type_decl))
compiler_type = CompilerType(
- weak_from_this(),
- clang::QualType(record_decl->getTypeForDecl(), 0).getAsOpaquePtr());
+ weak_from_this(), Ctx.getTypeDeclType(type_decl).getAsOpaquePtr());
return compiler_type;
}
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py
index d71fbf8d5f81a..75ae731bc597b 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py
@@ -77,7 +77,7 @@ def do_test(self):
self.assertEqual(str(valobj), '(User) *pointer = (id = 30, name = "steph")')
self.expect_var_path("sp_user->id", type="int", value="30")
- self.expect_var_path("sp_user->name", type="std::string", summary='"steph"')
+ self.expect_var_path("sp_user->name", type="string", summary='"steph"')
valobj = self.expect_var_path(
"si", type="std::shared_ptr<int>", summary="47 strong=2 weak=0"
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
index 49c0c814f077a..948115de11e25 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
@@ -39,7 +39,7 @@ def cleanup():
ns = self.namespace
# Check 'S' pre-assignment.
- self.expect("frame variable S", substrs=['(%s::wstring) S = L"!!!!"' % ns])
+ self.expect("frame variable S", substrs=['(wstring) S = L"!!!!"'])
thread.StepOver()
@@ -54,32 +54,29 @@ def cleanup():
)
self.expect_expr(
- "s", result_type=ns + "::wstring", result_summary='L"hello world! מזל טוב!"'
+ "s", result_type="wstring", result_summary='L"hello world! מזל טוב!"'
)
- self.expect_expr(
- "q", result_type=ns + "::string", result_summary='"hello world"'
- )
+ self.expect_expr("q", result_type="string", result_summary='"hello world"')
self.expect_expr(
"Q",
- result_type=ns + "::string",
+ result_type="string",
result_summary='"quite a long std::strin with lots of info inside it"',
)
self.expect(
"frame variable",
substrs=[
- '(%s::wstring) wempty = L""' % ns,
- '(%s::wstring) s = L"hello world! מזל טוב!"' % ns,
- '(%s::wstring) S = L"!!!!!"' % ns,
+ '(wstring) wempty = L""',
+ '(wstring) s = L"hello world! מזל טוב!"',
+ '(wstring) S = L"!!!!!"',
"(const wchar_t *) mazeltov = 0x",
'L"מזל טוב"',
- '(%s::string) empty = ""' % ns,
- '(%s::string) q = "hello world"' % ns,
- '(%s::string) Q = "quite a long std::strin with lots of info inside it"'
- % ns,
- "(%s::string *) null_str = nullptr" % ns,
+ '(string) empty = ""',
+ '(string) q = "hello world"',
+ '(string) Q = "quite a long std::strin with lots of info inside it"',
+ "(string *) null_str = nullptr",
],
)
@@ -139,10 +136,10 @@ def do_test_multibyte(self):
self.expect(
"frame variable",
substrs=[
- '(%s::u16string) u16_string = u"ß水氶"' % ns,
- '(%s::u16string) u16_empty = u""' % ns,
- '(%s::u32string) u32_string = U"🍄🍅🍆🍌"' % ns,
- '(%s::u32string) u32_empty = U""' % ns,
+ '(u16string) u16_string = u"ß水氶"',
+ '(u16string) u16_empty = u""',
+ '(u32string) u32_string = U"🍄🍅🍆🍌"',
+ '(u32string) u32_empty = U""',
],
)
@@ -217,9 +214,6 @@ def test_unavailable_summary_libcxx(self):
self.build(dictionary={"USE_LIBCPP": 1})
self.do_test_summary_unavailable()
- @expectedFailureAll(
- bugnumber="libstdc++ std::string summary provider doesn't output a user-friendly message for invalid strings."
- )
@add_test_categories(["libstdcxx"])
def test_unavailable_summary_libstdcxx(self):
self.build(dictionary={"USE_LIBSTDCPP": 1})
@@ -268,9 +262,8 @@ def do_test_embedded_null(self):
self.expect(
"frame variable",
substrs=[
- '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"' % ns,
- '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'
- % ns,
+ '(string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"',
+ '(wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"',
],
)
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/TestDataFormatterStdStringView.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/TestDataFormatterStdStringView.py
index 8c053f0843f9b..d505f0f2acd79 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/TestDataFormatterStdStringView.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/TestDataFormatterStdStringView.py
@@ -51,42 +51,38 @@ def cleanup():
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
- self.expect_var_path("wempty", type="std::wstring_view", summary='L""')
+ self.expect_var_path("wempty", type="wstring_view", summary='L""')
self.expect_var_path(
- "s", type="std::wstring_view", summary='L"hello world! מזל טוב!"'
+ "s", type="wstring_view", summary='L"hello world! מזל טוב!"'
)
- self.expect_var_path("S", type="std::wstring_view", summary='L"!!!!"')
- self.expect_var_path("empty", type="std::string_view", summary='""')
- self.expect_var_path("q_source", type="std::string", summary='"hello world"')
- self.expect_var_path("q", type="std::string_view", summary='"hello world"')
+ self.expect_var_path("S", type="wstring_view", summary='L"!!!!"')
+ self.expect_var_path("empty", type="string_view", summary='""')
+ self.expect_var_path("q_source", type="string", summary='"hello world"')
+ self.expect_var_path("q", type="string_view", summary='"hello world"')
self.expect_var_path(
"Q",
- type="std::string_view",
+ type="string_view",
summary='"quite a long std::strin with lots of info inside it"',
)
self.expect_var_path(
- "IHaveEmbeddedZeros", type="std::string_view", summary='"a\\0b\\0c\\0d"'
+ "IHaveEmbeddedZeros", type="string_view", summary='"a\\0b\\0c\\0d"'
)
self.expect_var_path(
"IHaveEmbeddedZerosToo",
- type="std::wstring_view",
+ type="wstring_view",
summary='L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"',
)
- self.expect_var_path("u16_string", type="std::u16string_view", summary='u"ß水氶"')
- self.expect_var_path("u16_empty", type="std::u16string_view", summary='u""')
- self.expect_var_path(
- "u32_string", type="std::u32string_view", summary='U"🍄🍅🍆🍌"'
- )
- self.expect_var_path("u32_empty", type="std::u32string_view", summary='U""')
- self.expect_var_path(
- "oops", type="std::string_view", summary='"Hellooo World\\n"'
- )
+ self.expect_var_path("u16_string", type="u16string_view", summary='u"ß水氶"')
+ self.expect_var_path("u16_empty", type="u16string_view", summary='u""')
+ self.expect_var_path("u32_string", type="u32string_view", summary='U"🍄🍅🍆🍌"')
+ self.expect_var_path("u32_empty", type="u32string_view", summary='U""')
+ self.expect_var_path("oops", type="string_view", summary='"Hellooo World\\n"')
# GetSummary returns None so can't be checked by expect_var_path, so we
# use the str representation instead
null_obj = self.frame().GetValueForVariablePath("null_str")
self.assertEqual(null_obj.GetSummary(), "Summary Unavailable")
- self.assertEqual(str(null_obj), "(std::string_view *) null_str = nullptr")
+ self.assertEqual(str(null_obj), "(string_view *) null_str = nullptr")
self.runCmd("n")
@@ -111,37 +107,35 @@ def cleanup():
self.expect_expr(
"s",
- result_type="std::wstring_view",
+ result_type="wstring_view",
result_summary='L"hello world! מזל טוב!"',
)
- self.expect_var_path("wempty", type="std::wstring_view", summary='L""')
+ self.expect_var_path("wempty", type="wstring_view", summary='L""')
self.expect_var_path(
- "s", type="std::wstring_view", summary='L"hello world! מזל טוב!"'
+ "s", type="wstring_view", summary='L"hello world! מזל טוב!"'
)
- self.expect_var_path("S", type="std::wstring_view", summary='L"!!!!"')
- self.expect_var_path("empty", type="std::string_view", summary='""')
- self.expect_var_path("q_source", type="std::string", summary='"Hello world"')
- self.expect_var_path("q", type="std::string_view", summary='"Hello world"')
+ self.expect_var_path("S", type="wstring_view", summary='L"!!!!"')
+ self.expect_var_path("empty", type="string_view", summary='""')
+ self.expect_var_path("q_source", type="string", summary='"Hello world"')
+ self.expect_var_path("q", type="string_view", summary='"Hello world"')
self.expect_var_path(
"Q",
- type="std::string_view",
+ type="string_view",
summary='"quite a long std::strin with lots of info inside it"',
)
self.expect_var_path(
- "IHaveEmbeddedZeros", type="std::string_view", summary='"a\\0b\\0c\\0d"'
+ "IHaveEmbeddedZeros", type="string_view", summary='"a\\0b\\0c\\0d"'
)
self.expect_var_path(
"IHaveEmbeddedZerosToo",
- type="std::wstring_view",
+ type="wstring_view",
summary='L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"',
)
- self.expect_var_path("u16_string", type="std::u16string_view", summary='u"ß水氶"')
- self.expect_var_path("u16_empty", type="std::u16string_view", summary='u""')
- self.expect_var_path(
- "u32_string", type="std::u32string_view", summary='U"🍄🍅🍆🍌"'
- )
- self.expect_var_path("u32_empty", type="std::u32string_view", summary='U""')
+ self.expect_var_path("u16_string", type="u16string_view", summary='u"ß水氶"')
+ self.expect_var_path("u16_empty", type="u16string_view", summary='u""')
+ self.expect_var_path("u32_string", type="u32string_view", summary='U"🍄🍅🍆🍌"')
+ self.expect_var_path("u32_empty", type="u32string_view", summary='U""')
self.runCmd("cont")
self.expect(
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/TestDataFormatterStdUniquePtr.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/TestDataFormatterStdUniquePtr.py
index 0b68b1b532bb0..be2fc3d040cf9 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/TestDataFormatterStdUniquePtr.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/TestDataFormatterStdUniquePtr.py
@@ -84,7 +84,7 @@ def do_test(self):
self.assertNotEqual(valobj.child[0].unsigned, 0)
self.expect_var_path("up_user->id", type="int", value="30")
- self.expect_var_path("up_user->name", type="std::string", summary='"steph"')
+ self.expect_var_path("up_user->name", type="string", summary='"steph"')
self.runCmd("settings set target.experimental.use-DIL true")
self.expect_var_path("ptr_node->value", value="1")
diff --git a/lldb/test/API/lang/cpp/class-loading-via-member-typedef/TestClassLoadingViaMemberTypedef.py b/lldb/test/API/lang/cpp/class-loading-via-member-typedef/TestClassLoadingViaMemberTypedef.py
index e9aa47f4328f9..da1b2265695b5 100644
--- a/lldb/test/API/lang/cpp/class-loading-via-member-typedef/TestClassLoadingViaMemberTypedef.py
+++ b/lldb/test/API/lang/cpp/class-loading-via-member-typedef/TestClassLoadingViaMemberTypedef.py
@@ -20,7 +20,7 @@ def test(self):
# that the typedef is defined inside.
self.expect_expr(
"pull_in_classes",
- result_type="StructWithMember::MemberTypedef",
+ result_type="MemberTypedef",
result_value="0",
)
@@ -31,7 +31,7 @@ def test(self):
result_children=[
ValueCheck(
name="m",
- type="StructWithNested::Nested<int>::OtherTypedef",
+ type="OtherTypedef",
children=[ValueCheck(name="i", value="0", type="int")],
)
],
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_declaration-with-children.s b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_declaration-with-children.s
index 16bdbd3cfaad6..94042fa37d503 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_declaration-with-children.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_declaration-with-children.s
@@ -28,11 +28,11 @@ expr b1
target var c1
# CHECK-LABEL: target var c1
-# CHECK: (C::C1) c1 = 424742
+# CHECK: (C1) c1 = 424742
expr c1
# CHECK-LABEL: expr c1
-# CHECK: (C::C1) $1 = 424742
+# CHECK: (C1) $1 = 424742
#--- asm
.text
_ZN1AC2Ev:
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp
index 415b4850a244c..9251930d7d13c 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp
@@ -56,8 +56,8 @@
// DWPMAIN-NEXT: struct CustomType {
// DWPMAIN-NEXT: typedef int IntegerType;
// DWPMAIN-NEXT: typedef double FloatType;
-// DWPMAIN-NEXT: CustomType::IntegerType x;
-// DWPMAIN-NEXT: CustomType::FloatType y;
+// DWPMAIN-NEXT: IntegerType x;
+// DWPMAIN-NEXT: FloatType y;
// DWPMAIN-NEXT: }
// Next we check when we make the .dwp file with %t.foo.dwo first so it will
@@ -78,8 +78,8 @@
// DWPFOO-NEXT: struct CustomType {
// DWPFOO-NEXT: typedef unsigned int IntegerType;
// DWPFOO-NEXT: typedef float FloatType;
-// DWPFOO-NEXT: CustomType::IntegerType x;
-// DWPFOO-NEXT: CustomType::FloatType y;
+// DWPFOO-NEXT: IntegerType x;
+// DWPFOO-NEXT: FloatType y;
// DWPFOO-NEXT: }
struct CustomType {
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/typedef-in-incomplete-type.cpp b/lldb/test/Shell/SymbolFile/DWARF/x86/typedef-in-incomplete-type.cpp
index 591607784b0a9..a00e75dbfb591 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/typedef-in-incomplete-type.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/typedef-in-incomplete-type.cpp
@@ -10,7 +10,7 @@
// to the incomplete type. Make sure that succeeds. Use the expression command
// to make sure the resulting AST can be imported correctly.
// CHECK: expr -- var
-// CHECK: (A::X) $0 = 0
+// CHECK: (X) $0 = 0
struct A {
// Declare the constructor, but don't define it to avoid emitting the
diff --git a/lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp b/lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp
index e6b601ea13012..ad498055d4768 100644
--- a/lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp
+++ b/lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp
@@ -122,11 +122,10 @@ class SBVisitor : public RecursiveASTVisitor<SBVisitor> {
/// - Certain inconvenient classes
/// - Records without definitions (forward declarations)
bool ShouldSkipRecord(CXXRecordDecl *Decl) {
- const Type *DeclType = Decl->getTypeForDecl();
- QualType CanonicalType = DeclType->getCanonicalTypeInternal();
return !Manager.isInMainFile(Decl->getBeginLoc()) ||
!Decl->hasDefinition() || Decl->getDefinition() != Decl ||
- lldb_rpc_gen::TypeIsDisallowedClass(CanonicalType);
+ lldb_rpc_gen::TypeIsDisallowedClass(
+ Context.getCanonicalTagType(Decl));
}
/// Check the support level for a type
More information about the llvm-branch-commits
mailing list