[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.
This commit is contained in:
Michael Buch 2024-08-13 20:04:18 +01:00 committed by GitHub
parent 5b40a05d8f
commit 28050e1b0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 18 deletions

View File

@ -45,7 +45,7 @@ public:
const AddressRange &range) = 0;
virtual bool CompleteTypeFromDWARF(const DWARFDIE &die, Type *type,
CompilerType &compiler_type) = 0;
const CompilerType &compiler_type) = 0;
virtual CompilerDecl GetDeclForUIDFromDWARF(const DWARFDIE &die) = 0;

View File

@ -2057,7 +2057,7 @@ bool DWARFASTParserClang::ParseTemplateParameterInfos(
bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
lldb_private::Type *type,
CompilerType &clang_type) {
const CompilerType &clang_type) {
const dw_tag_t tag = die.Tag();
SymbolFileDWARF *dwarf = die.GetDWARF();
@ -2152,7 +2152,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
lldb_private::Type *type,
CompilerType &clang_type) {
const CompilerType &clang_type) {
if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
if (die.HasChildren()) {
bool is_signed = false;
@ -2165,9 +2165,9 @@ bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
return (bool)clang_type;
}
bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
lldb_private::Type *type,
CompilerType &clang_type) {
bool DWARFASTParserClang::CompleteTypeFromDWARF(
const DWARFDIE &die, lldb_private::Type *type,
const CompilerType &clang_type) {
SymbolFileDWARF *dwarf = die.GetDWARF();
std::lock_guard<std::recursive_mutex> guard(
@ -2244,7 +2244,7 @@ DWARFASTParserClang::GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) {
}
size_t DWARFASTParserClang::ParseChildEnumerators(
lldb_private::CompilerType &clang_type, bool is_signed,
const lldb_private::CompilerType &clang_type, bool is_signed,
uint32_t enumerator_byte_size, const DWARFDIE &parent_die) {
if (!parent_die)
return 0;
@ -3032,7 +3032,7 @@ void DWARFASTParserClang::ParseSingleMember(
}
bool DWARFASTParserClang::ParseChildMembers(
const DWARFDIE &parent_die, CompilerType &class_clang_type,
const DWARFDIE &parent_die, const CompilerType &class_clang_type,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
std::vector<DWARFDIE> &member_function_dies,
std::vector<DWARFDIE> &contained_type_dies,
@ -3763,7 +3763,8 @@ bool DWARFASTParserClang::ShouldCreateUnnamedBitfield(
}
void DWARFASTParserClang::ParseRustVariantPart(
DWARFDIE &die, const DWARFDIE &parent_die, CompilerType &class_clang_type,
DWARFDIE &die, const DWARFDIE &parent_die,
const CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
ClangASTImporter::LayoutInfo &layout_info) {
assert(die.Tag() == llvm::dwarf::DW_TAG_variant_part);

View File

@ -61,10 +61,10 @@ public:
const lldb_private::plugin::dwarf::DWARFDIE &die,
const lldb_private::AddressRange &func_range) override;
bool
CompleteTypeFromDWARF(const lldb_private::plugin::dwarf::DWARFDIE &die,
lldb_private::Type *type,
lldb_private::CompilerType &compiler_type) override;
bool CompleteTypeFromDWARF(
const lldb_private::plugin::dwarf::DWARFDIE &die,
lldb_private::Type *type,
const lldb_private::CompilerType &compiler_type) override;
lldb_private::CompilerDecl GetDeclForUIDFromDWARF(
const lldb_private::plugin::dwarf::DWARFDIE &die) override;
@ -178,7 +178,7 @@ protected:
bool ParseChildMembers(
const lldb_private::plugin::dwarf::DWARFDIE &die,
lldb_private::CompilerType &class_compiler_type,
const lldb_private::CompilerType &class_compiler_type,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
std::vector<lldb_private::plugin::dwarf::DWARFDIE> &member_function_dies,
std::vector<lldb_private::plugin::dwarf::DWARFDIE> &contained_type_dies,
@ -196,7 +196,7 @@ protected:
unsigned &type_quals);
size_t ParseChildEnumerators(
lldb_private::CompilerType &compiler_type, bool is_signed,
const lldb_private::CompilerType &compiler_type, bool is_signed,
uint32_t enumerator_byte_size,
const lldb_private::plugin::dwarf::DWARFDIE &parent_die);
@ -362,10 +362,10 @@ private:
bool CompleteRecordType(const lldb_private::plugin::dwarf::DWARFDIE &die,
lldb_private::Type *type,
lldb_private::CompilerType &clang_type);
const lldb_private::CompilerType &clang_type);
bool CompleteEnumType(const lldb_private::plugin::dwarf::DWARFDIE &die,
lldb_private::Type *type,
lldb_private::CompilerType &clang_type);
const lldb_private::CompilerType &clang_type);
lldb::TypeSP
ParseTypeModifier(const lldb_private::SymbolContext &sc,
@ -467,7 +467,7 @@ private:
void
ParseRustVariantPart(lldb_private::plugin::dwarf::DWARFDIE &die,
const lldb_private::plugin::dwarf::DWARFDIE &parent_die,
lldb_private::CompilerType &class_clang_type,
const lldb_private::CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
lldb_private::ClangASTImporter::LayoutInfo &layout_info);
};