Skip to content

Commit 28050e1

Browse files
authored
[lldb][DWARFASTParser] Don't pass CompilerType by non-const reference in the DWARFASTParserClang APIs (#103245)
The `CompilerType` is just a wrapper around two pointers, and there is no usage of the `CompilerType` where those are expected to change underneath the caller. To make the interface more straightforward to reason about, this patch changes all instances of `CompilerType&` to `const CompilerType&` around the `DWARFASTParserClang` APIs. We could probably pass these by-value, but all other APIs don't, and this patch just makes the parameter passing convention consistent with the rest of the file.
1 parent 5b40a05 commit 28050e1

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class DWARFASTParser {
4545
const AddressRange &range) = 0;
4646

4747
virtual bool CompleteTypeFromDWARF(const DWARFDIE &die, Type *type,
48-
CompilerType &compiler_type) = 0;
48+
const CompilerType &compiler_type) = 0;
4949

5050
virtual CompilerDecl GetDeclForUIDFromDWARF(const DWARFDIE &die) = 0;
5151

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,7 @@ bool DWARFASTParserClang::ParseTemplateParameterInfos(
20572057

20582058
bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
20592059
lldb_private::Type *type,
2060-
CompilerType &clang_type) {
2060+
const CompilerType &clang_type) {
20612061
const dw_tag_t tag = die.Tag();
20622062
SymbolFileDWARF *dwarf = die.GetDWARF();
20632063

@@ -2152,7 +2152,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
21522152

21532153
bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
21542154
lldb_private::Type *type,
2155-
CompilerType &clang_type) {
2155+
const CompilerType &clang_type) {
21562156
if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
21572157
if (die.HasChildren()) {
21582158
bool is_signed = false;
@@ -2165,9 +2165,9 @@ bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
21652165
return (bool)clang_type;
21662166
}
21672167

2168-
bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
2169-
lldb_private::Type *type,
2170-
CompilerType &clang_type) {
2168+
bool DWARFASTParserClang::CompleteTypeFromDWARF(
2169+
const DWARFDIE &die, lldb_private::Type *type,
2170+
const CompilerType &clang_type) {
21712171
SymbolFileDWARF *dwarf = die.GetDWARF();
21722172

21732173
std::lock_guard<std::recursive_mutex> guard(
@@ -2244,7 +2244,7 @@ DWARFASTParserClang::GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) {
22442244
}
22452245

22462246
size_t DWARFASTParserClang::ParseChildEnumerators(
2247-
lldb_private::CompilerType &clang_type, bool is_signed,
2247+
const lldb_private::CompilerType &clang_type, bool is_signed,
22482248
uint32_t enumerator_byte_size, const DWARFDIE &parent_die) {
22492249
if (!parent_die)
22502250
return 0;
@@ -3032,7 +3032,7 @@ void DWARFASTParserClang::ParseSingleMember(
30323032
}
30333033

30343034
bool DWARFASTParserClang::ParseChildMembers(
3035-
const DWARFDIE &parent_die, CompilerType &class_clang_type,
3035+
const DWARFDIE &parent_die, const CompilerType &class_clang_type,
30363036
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
30373037
std::vector<DWARFDIE> &member_function_dies,
30383038
std::vector<DWARFDIE> &contained_type_dies,
@@ -3763,7 +3763,8 @@ bool DWARFASTParserClang::ShouldCreateUnnamedBitfield(
37633763
}
37643764

37653765
void DWARFASTParserClang::ParseRustVariantPart(
3766-
DWARFDIE &die, const DWARFDIE &parent_die, CompilerType &class_clang_type,
3766+
DWARFDIE &die, const DWARFDIE &parent_die,
3767+
const CompilerType &class_clang_type,
37673768
const lldb::AccessType default_accesibility,
37683769
ClangASTImporter::LayoutInfo &layout_info) {
37693770
assert(die.Tag() == llvm::dwarf::DW_TAG_variant_part);

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
6161
const lldb_private::plugin::dwarf::DWARFDIE &die,
6262
const lldb_private::AddressRange &func_range) override;
6363

64-
bool
65-
CompleteTypeFromDWARF(const lldb_private::plugin::dwarf::DWARFDIE &die,
66-
lldb_private::Type *type,
67-
lldb_private::CompilerType &compiler_type) override;
64+
bool CompleteTypeFromDWARF(
65+
const lldb_private::plugin::dwarf::DWARFDIE &die,
66+
lldb_private::Type *type,
67+
const lldb_private::CompilerType &compiler_type) override;
6868

6969
lldb_private::CompilerDecl GetDeclForUIDFromDWARF(
7070
const lldb_private::plugin::dwarf::DWARFDIE &die) override;
@@ -178,7 +178,7 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
178178

179179
bool ParseChildMembers(
180180
const lldb_private::plugin::dwarf::DWARFDIE &die,
181-
lldb_private::CompilerType &class_compiler_type,
181+
const lldb_private::CompilerType &class_compiler_type,
182182
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
183183
std::vector<lldb_private::plugin::dwarf::DWARFDIE> &member_function_dies,
184184
std::vector<lldb_private::plugin::dwarf::DWARFDIE> &contained_type_dies,
@@ -196,7 +196,7 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
196196
unsigned &type_quals);
197197

198198
size_t ParseChildEnumerators(
199-
lldb_private::CompilerType &compiler_type, bool is_signed,
199+
const lldb_private::CompilerType &compiler_type, bool is_signed,
200200
uint32_t enumerator_byte_size,
201201
const lldb_private::plugin::dwarf::DWARFDIE &parent_die);
202202

@@ -362,10 +362,10 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
362362

363363
bool CompleteRecordType(const lldb_private::plugin::dwarf::DWARFDIE &die,
364364
lldb_private::Type *type,
365-
lldb_private::CompilerType &clang_type);
365+
const lldb_private::CompilerType &clang_type);
366366
bool CompleteEnumType(const lldb_private::plugin::dwarf::DWARFDIE &die,
367367
lldb_private::Type *type,
368-
lldb_private::CompilerType &clang_type);
368+
const lldb_private::CompilerType &clang_type);
369369

370370
lldb::TypeSP
371371
ParseTypeModifier(const lldb_private::SymbolContext &sc,
@@ -467,7 +467,7 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
467467
void
468468
ParseRustVariantPart(lldb_private::plugin::dwarf::DWARFDIE &die,
469469
const lldb_private::plugin::dwarf::DWARFDIE &parent_die,
470-
lldb_private::CompilerType &class_clang_type,
470+
const lldb_private::CompilerType &class_clang_type,
471471
const lldb::AccessType default_accesibility,
472472
lldb_private::ClangASTImporter::LayoutInfo &layout_info);
473473
};

0 commit comments

Comments
 (0)