Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lldb/include/lldb/Symbol/CompilerType.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ class CompilerType {
/// TypeSystem::TypeSystemSPWrapper can be compared for equality.
TypeSystemSPWrapper GetTypeSystem() const;

template <typename TypeSystemType>
std::shared_ptr<TypeSystemType> GetTypeSystem() const {
return GetTypeSystem().dyn_cast_or_null<TypeSystemType>();
}

ConstString GetTypeName(bool BaseOnly = false) const;

ConstString GetDisplayTypeName() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CompilerType ClangASTImporter::CopyType(TypeSystemClang &dst_ast,
const CompilerType &src_type) {
clang::ASTContext &dst_clang_ast = dst_ast.getASTContext();

auto src_ast = src_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
auto src_ast = src_type.GetTypeSystem<TypeSystemClang>();
if (!src_ast)
return CompilerType();

Expand Down Expand Up @@ -307,7 +307,7 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang &dst,
const CompilerType &src_type) {
Log *log = GetLog(LLDBLog::Expressions);

auto src_ctxt = src_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
auto src_ctxt = src_type.GetTypeSystem<TypeSystemClang>();
if (!src_ctxt)
return {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1477,8 +1477,7 @@ ClangASTImporter::DeclOrigin ClangASTSource::GetDeclOrigin(const clang::Decl *de
}

CompilerType ClangASTSource::GuardedCopyType(const CompilerType &src_type) {
auto ts = src_type.GetTypeSystem();
auto src_ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto src_ast = src_type.GetTypeSystem<TypeSystemClang>();
if (!src_ast)
return {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
bool is_result,
bool is_lvalue) {
assert(m_parser_vars.get());
auto ast = parser_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
auto ast = parser_type.GetTypeSystem<TypeSystemClang>();
if (ast == nullptr)
return false;

Expand Down Expand Up @@ -1486,8 +1486,8 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
return false;
}

auto ts = var_type->GetForwardCompilerType().GetTypeSystem();
auto clang_ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto clang_ast =
var_type->GetForwardCompilerType().GetTypeSystem<TypeSystemClang>();

if (!clang_ast) {
LLDB_LOG(log, "Skipped a definition because it has no Clang AST");
Expand Down Expand Up @@ -1606,8 +1606,7 @@ void ClangExpressionDeclMap::AddOneVariable(

TypeFromUser user_type = valobj->GetCompilerType();

auto clang_ast =
user_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
auto clang_ast = user_type.GetTypeSystem<TypeSystemClang>();

if (!clang_ast) {
LLDB_LOG(log, "Skipped a definition because it has no Clang AST");
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bool ClangUtil::IsClangType(const CompilerType &ct) {
if (!ct)
return false;

if (!ct.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>())
if (!ct.GetTypeSystem<TypeSystemClang>())
return false;

if (!ct.GetOpaqueQualType())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType &type) {
if (!type.IsValid())
return nullptr;

auto lldb_ast = type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
auto lldb_ast = type.GetTypeSystem<TypeSystemClang>();
if (!lldb_ast)
return nullptr;

Expand All @@ -45,7 +45,7 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
if (m_function_types.count(type))
return nullptr;

auto lldb_ast = type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
auto lldb_ast = type.GetTypeSystem<TypeSystemClang>();
if (!lldb_ast)
return nullptr;

Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
return;
}

auto ts = block_pointer_type.GetTypeSystem();
auto clang_ast_context = ts.dyn_cast_or_null<TypeSystemClang>();
auto clang_ast_context =
block_pointer_type.GetTypeSystem<TypeSystemClang>();
if (!clang_ast_context)
return;

Expand Down
3 changes: 1 addition & 2 deletions lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() {
if (frame_ptr_addr == 0 || frame_ptr_addr == LLDB_INVALID_ADDRESS)
return lldb::ChildCacheState::eRefetch;

auto ts = valobj_sp->GetCompilerType().GetTypeSystem();
auto ast_ctx = ts.dyn_cast_or_null<TypeSystemClang>();
auto ast_ctx = valobj_sp->GetCompilerType().GetTypeSystem<TypeSystemClang>();
if (!ast_ctx)
return lldb::ChildCacheState::eRefetch;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1531,8 +1531,7 @@ void DWARFASTParserClang::ParseInheritance(
const lldb::ModuleSP &module_sp,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
ClangASTImporter::LayoutInfo &layout_info) {
auto ast =
class_clang_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
auto ast = class_clang_type.GetTypeSystem<TypeSystemClang>();
if (ast == nullptr)
return;

Expand Down Expand Up @@ -2823,7 +2822,7 @@ llvm::Expected<llvm::APInt> DWARFASTParserClang::ExtractIntFromFormValue(
const CompilerType &int_type, const DWARFFormValue &form_value) const {
clang::QualType qt = ClangUtil::GetQualType(int_type);
assert(qt->isIntegralOrEnumerationType());
auto ts_ptr = int_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
auto ts_ptr = int_type.GetTypeSystem<TypeSystemClang>();
if (!ts_ptr)
return llvm::createStringError(llvm::inconvertibleErrorCode(),
"TypeSystem not clang");
Expand Down Expand Up @@ -3131,8 +3130,7 @@ bool DWARFASTParserClang::ParseChildMembers(
FieldInfo last_field_info;

ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
auto ts = class_clang_type.GetTypeSystem();
auto ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto ast = class_clang_type.GetTypeSystem<TypeSystemClang>();
if (ast == nullptr)
return false;

Expand Down
6 changes: 2 additions & 4 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,8 +1538,7 @@ bool SymbolFileDWARF::HasForwardDeclForCompilerType(
compiler_type_no_qualifiers.GetOpaqueQualType())) {
return true;
}
auto type_system = compiler_type.GetTypeSystem();
auto clang_type_system = type_system.dyn_cast_or_null<TypeSystemClang>();
auto clang_type_system = compiler_type.GetTypeSystem<TypeSystemClang>();
if (!clang_type_system)
return false;
DWARFASTParserClang *ast_parser =
Expand All @@ -1549,8 +1548,7 @@ bool SymbolFileDWARF::HasForwardDeclForCompilerType(

bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
auto clang_type_system =
compiler_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
auto clang_type_system = compiler_type.GetTypeSystem<TypeSystemClang>();
if (clang_type_system) {
DWARFASTParserClang *ast_parser =
static_cast<DWARFASTParserClang *>(clang_type_system->GetDWARFParser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2141,8 +2141,7 @@ SymbolFileNativePDB::GetDynamicArrayInfoForUID(

bool SymbolFileNativePDB::CompleteType(CompilerType &compiler_type) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
auto ts = compiler_type.GetTypeSystem();
auto clang_type_system = ts.dyn_cast_or_null<TypeSystemClang>();
auto clang_type_system = compiler_type.GetTypeSystem<TypeSystemClang>();
if (!clang_type_system)
return false;

Expand Down
31 changes: 11 additions & 20 deletions lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ CompilerType TypeSystemClang::GetCStringType(bool is_const) {

bool TypeSystemClang::AreTypesSame(CompilerType type1, CompilerType type2,
bool ignore_qualifiers) {
auto ast = type1.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
auto ast = type1.GetTypeSystem<TypeSystemClang>();
if (!ast || type1.GetTypeSystem() != type2.GetTypeSystem())
return false;

Expand Down Expand Up @@ -7333,8 +7333,7 @@ clang::FieldDecl *TypeSystemClang::AddFieldToRecordType(
uint32_t bitfield_bit_size) {
if (!type.IsValid() || !field_clang_type.IsValid())
return nullptr;
auto ts = type.GetTypeSystem();
auto ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto ast = type.GetTypeSystem<TypeSystemClang>();
if (!ast)
return nullptr;
clang::ASTContext &clang_ast = ast->getASTContext();
Expand Down Expand Up @@ -7437,8 +7436,7 @@ void TypeSystemClang::BuildIndirectFields(const CompilerType &type) {
if (!type)
return;

auto ts = type.GetTypeSystem();
auto ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto ast = type.GetTypeSystem<TypeSystemClang>();
if (!ast)
return;

Expand Down Expand Up @@ -7544,8 +7542,7 @@ void TypeSystemClang::BuildIndirectFields(const CompilerType &type) {

void TypeSystemClang::SetIsPacked(const CompilerType &type) {
if (type) {
auto ts = type.GetTypeSystem();
auto ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto ast = type.GetTypeSystem<TypeSystemClang>();
if (ast) {
clang::RecordDecl *record_decl = GetAsRecordDecl(type);

Expand All @@ -7564,8 +7561,7 @@ clang::VarDecl *TypeSystemClang::AddVariableToRecordType(
if (!type.IsValid() || !var_type.IsValid())
return nullptr;

auto ts = type.GetTypeSystem();
auto ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto ast = type.GetTypeSystem<TypeSystemClang>();
if (!ast)
return nullptr;

Expand Down Expand Up @@ -7890,8 +7886,7 @@ bool TypeSystemClang::TransferBaseClasses(

bool TypeSystemClang::SetObjCSuperClass(
const CompilerType &type, const CompilerType &superclass_clang_type) {
auto ts = type.GetTypeSystem();
auto ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto ast = type.GetTypeSystem<TypeSystemClang>();
if (!ast)
return false;
clang::ASTContext &clang_ast = ast->getASTContext();
Expand Down Expand Up @@ -7919,8 +7914,7 @@ bool TypeSystemClang::AddObjCClassProperty(
if (!type || !property_clang_type.IsValid() || property_name == nullptr ||
property_name[0] == '\0')
return false;
auto ts = type.GetTypeSystem();
auto ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto ast = type.GetTypeSystem<TypeSystemClang>();
if (!ast)
return false;
clang::ASTContext &clang_ast = ast->getASTContext();
Expand Down Expand Up @@ -8139,8 +8133,7 @@ clang::ObjCMethodDecl *TypeSystemClang::AddMethodToObjCObjectType(

if (class_interface_decl == nullptr)
return nullptr;
auto ts = type.GetTypeSystem();
auto lldb_ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto lldb_ast = type.GetTypeSystem<TypeSystemClang>();
if (lldb_ast == nullptr)
return nullptr;
clang::ASTContext &ast = lldb_ast->getASTContext();
Expand Down Expand Up @@ -8344,8 +8337,7 @@ bool TypeSystemClang::CompleteTagDeclarationDefinition(
if (qual_type.isNull())
return false;

auto ts = type.GetTypeSystem();
auto lldb_ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto lldb_ast = type.GetTypeSystem<TypeSystemClang>();
if (lldb_ast == nullptr)
return false;

Expand Down Expand Up @@ -8489,8 +8481,7 @@ TypeSystemClang::CreateMemberPointerType(const CompilerType &type,
const CompilerType &pointee_type) {
if (type && pointee_type.IsValid() &&
type.GetTypeSystem() == pointee_type.GetTypeSystem()) {
auto ts = type.GetTypeSystem();
auto ast = ts.dyn_cast_or_null<TypeSystemClang>();
auto ast = type.GetTypeSystem<TypeSystemClang>();
if (!ast)
return CompilerType();
return ast->GetType(ast->getASTContext().getMemberPointerType(
Expand Down Expand Up @@ -9554,7 +9545,7 @@ void TypeSystemClang::RequireCompleteType(CompilerType type) {
lldbassert(started && "Unable to start a class type definition.");
TypeSystemClang::CompleteTagDeclarationDefinition(type);
const clang::TagDecl *td = ClangUtil::GetAsTagDecl(type);
auto ts = type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
auto ts = type.GetTypeSystem<TypeSystemClang>();
if (ts)
ts->SetDeclIsForcefullyCompleted(td);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ struct MockLanguageRuntime : public LanguageRuntime {
TypeAndOrName &class_type_or_name, Address &address,
Value::ValueType &value_type,
llvm::ArrayRef<uint8_t> &local_buffer) override {
auto ast = in_value.GetCompilerType()
.GetTypeSystem()
.dyn_cast_or_null<TypeSystemClang>();
auto ast = in_value.GetCompilerType().GetTypeSystem<TypeSystemClang>();

auto int_type = createRecordWithField(
*ast, "TypeWitInt", ast->GetBasicType(lldb::BasicType::eBasicTypeInt),
Expand Down
Loading