Skip to content

Commit 7d90b9a

Browse files
committed
Merge commit 'e424787a95f2' from llvm.org/main into next
2 parents f43b8cc + e424787 commit 7d90b9a

File tree

13 files changed

+36
-50
lines changed

13 files changed

+36
-50
lines changed

lldb/include/lldb/Symbol/CompilerType.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ class CompilerType {
287287
/// TypeSystem::TypeSystemSPWrapper can be compared for equality.
288288
TypeSystemSPWrapper GetTypeSystem() const;
289289

290+
template <typename TypeSystemType>
291+
std::shared_ptr<TypeSystemType> GetTypeSystem() const {
292+
return GetTypeSystem().dyn_cast_or_null<TypeSystemType>();
293+
}
294+
290295
ConstString GetTypeName(bool BaseOnly = false) const;
291296

292297
ConstString GetDisplayTypeName(const SymbolContext *sc = nullptr) const;

lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ CompilerType ClangASTImporter::CopyType(TypeSystemClang &dst_ast,
4040
const CompilerType &src_type) {
4141
clang::ASTContext &dst_clang_ast = dst_ast.getASTContext();
4242

43-
auto src_ast = src_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
43+
auto src_ast = src_type.GetTypeSystem<TypeSystemClang>();
4444
if (!src_ast)
4545
return CompilerType();
4646

@@ -317,7 +317,7 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang &dst,
317317
const CompilerType &src_type) {
318318
Log *log = GetLog(LLDBLog::Expressions);
319319

320-
auto src_ctxt = src_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
320+
auto src_ctxt = src_type.GetTypeSystem<TypeSystemClang>();
321321
if (!src_ctxt)
322322
return {};
323323

lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,8 +1529,7 @@ ClangASTImporter::DeclOrigin ClangASTSource::GetDeclOrigin(const clang::Decl *de
15291529
}
15301530

15311531
CompilerType ClangASTSource::GuardedCopyType(const CompilerType &src_type) {
1532-
auto ts = src_type.GetTypeSystem();
1533-
auto src_ast = ts.dyn_cast_or_null<TypeSystemClang>();
1532+
auto src_ast = src_type.GetTypeSystem<TypeSystemClang>();
15341533
if (!src_ast)
15351534
return {};
15361535

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
219219
bool is_result,
220220
bool is_lvalue) {
221221
assert(m_parser_vars.get());
222-
auto ast = parser_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
222+
auto ast = parser_type.GetTypeSystem<TypeSystemClang>();
223223
if (ast == nullptr)
224224
return false;
225225

@@ -1485,8 +1485,8 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
14851485
return false;
14861486
}
14871487

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

14911491
if (!clang_ast) {
14921492
LLDB_LOG(log, "Skipped a definition because it has no Clang AST");
@@ -1605,8 +1605,7 @@ void ClangExpressionDeclMap::AddOneVariable(
16051605

16061606
TypeFromUser user_type = valobj->GetCompilerType();
16071607

1608-
auto clang_ast =
1609-
user_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
1608+
auto clang_ast = user_type.GetTypeSystem<TypeSystemClang>();
16101609

16111610
if (!clang_ast) {
16121611
LLDB_LOG(log, "Skipped a definition because it has no Clang AST");

lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bool ClangUtil::IsClangType(const CompilerType &ct) {
2020
if (!ct)
2121
return false;
2222

23-
if (!ct.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>())
23+
if (!ct.GetTypeSystem<TypeSystemClang>())
2424
return false;
2525

2626
if (!ct.GetOpaqueQualType())

lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType &type) {
1919
if (!type.IsValid())
2020
return nullptr;
2121

22-
auto lldb_ast = type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
22+
auto lldb_ast = type.GetTypeSystem<TypeSystemClang>();
2323
if (!lldb_ast)
2424
return nullptr;
2525

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

48-
auto lldb_ast = type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
48+
auto lldb_ast = type.GetTypeSystem<TypeSystemClang>();
4949
if (!lldb_ast)
5050
return nullptr;
5151

lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
5050
return;
5151
}
5252

53-
auto ts = block_pointer_type.GetTypeSystem();
54-
auto clang_ast_context = ts.dyn_cast_or_null<TypeSystemClang>();
53+
auto clang_ast_context =
54+
block_pointer_type.GetTypeSystem<TypeSystemClang>();
5555
if (!clang_ast_context)
5656
return;
5757

lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() {
141141
if (frame_ptr_addr == 0 || frame_ptr_addr == LLDB_INVALID_ADDRESS)
142142
return lldb::ChildCacheState::eRefetch;
143143

144-
auto ts = valobj_sp->GetCompilerType().GetTypeSystem();
145-
auto ast_ctx = ts.dyn_cast_or_null<TypeSystemClang>();
144+
auto ast_ctx = valobj_sp->GetCompilerType().GetTypeSystem<TypeSystemClang>();
146145
if (!ast_ctx)
147146
return lldb::ChildCacheState::eRefetch;
148147

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,8 +1619,7 @@ void DWARFASTParserClang::ParseInheritance(
16191619
const lldb::ModuleSP &module_sp,
16201620
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
16211621
ClangASTImporter::LayoutInfo &layout_info) {
1622-
auto ast =
1623-
class_clang_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
1622+
auto ast = class_clang_type.GetTypeSystem<TypeSystemClang>();
16241623
if (ast == nullptr)
16251624
return;
16261625

@@ -2946,7 +2945,7 @@ llvm::Expected<llvm::APInt> DWARFASTParserClang::ExtractIntFromFormValue(
29462945
const CompilerType &int_type, const DWARFFormValue &form_value) const {
29472946
clang::QualType qt = ClangUtil::GetQualType(int_type);
29482947
assert(qt->isIntegralOrEnumerationType());
2949-
auto ts_ptr = int_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
2948+
auto ts_ptr = int_type.GetTypeSystem<TypeSystemClang>();
29502949
if (!ts_ptr)
29512950
return llvm::createStringError(llvm::inconvertibleErrorCode(),
29522951
"TypeSystem not clang");
@@ -3253,8 +3252,7 @@ bool DWARFASTParserClang::ParseChildMembers(
32533252
FieldInfo last_field_info;
32543253

32553254
ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
3256-
auto ts = class_clang_type.GetTypeSystem();
3257-
auto ast = ts.dyn_cast_or_null<TypeSystemClang>();
3255+
auto ast = class_clang_type.GetTypeSystem<TypeSystemClang>();
32583256
if (ast == nullptr)
32593257
return false;
32603258

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,8 +1551,7 @@ bool SymbolFileDWARF::HasForwardDeclForCompilerType(
15511551
compiler_type_no_qualifiers.GetOpaqueQualType())) {
15521552
return true;
15531553
}
1554-
auto type_system = compiler_type.GetTypeSystem();
1555-
auto clang_type_system = type_system.dyn_cast_or_null<TypeSystemClang>();
1554+
auto clang_type_system = compiler_type.GetTypeSystem<TypeSystemClang>();
15561555
if (!clang_type_system)
15571556
return false;
15581557
DWARFASTParserClang *ast_parser =
@@ -1562,8 +1561,7 @@ bool SymbolFileDWARF::HasForwardDeclForCompilerType(
15621561

15631562
bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
15641563
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1565-
auto clang_type_system =
1566-
compiler_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
1564+
auto clang_type_system = compiler_type.GetTypeSystem<TypeSystemClang>();
15671565
if (clang_type_system) {
15681566
DWARFASTParserClang *ast_parser =
15691567
static_cast<DWARFASTParserClang *>(clang_type_system->GetDWARFParser());

0 commit comments

Comments
 (0)