From 00d8159166e662c6776ecab8729d857a470f9b9e Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Mon, 19 Sep 2022 16:43:32 +0800 Subject: [PATCH] Add linker_set_key to RecordTypeDiff and EnumTypeDiff RecordTypeDiff and EnumTypeDiff in abi_diff.proto contain linker set keys. The developers can copy them to the ignore list. The other Diff messages do not need the field because it's in the messages imported from abi_dump.proto. Test: Update prebuilts/clang-tools; make libz Bug: 243903630 Change-Id: I1e90d3c6cbfd09d72b3fdb244a4079ae899630aa --- .../src/repr/abi_diff_helpers.cpp | 2 ++ .../src/repr/ir_diff_representation.h | 18 ++++++++++++++---- .../src/repr/protobuf/converter.cpp | 6 +++++- .../src/repr/protobuf/proto/abi_diff.proto | 3 +++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/vndk/tools/header-checker/src/repr/abi_diff_helpers.cpp b/vndk/tools/header-checker/src/repr/abi_diff_helpers.cpp index f50d5d559..9e4c578e6 100644 --- a/vndk/tools/header-checker/src/repr/abi_diff_helpers.cpp +++ b/vndk/tools/header-checker/src/repr/abi_diff_helpers.cpp @@ -204,6 +204,7 @@ DiffStatus AbiDiffHelper::CompareEnumTypes( } auto enum_type_diff_ir = std::make_unique(); enum_type_diff_ir->SetName(old_type->GetName()); + enum_type_diff_ir->SetLinkerSetKey(old_type->GetLinkerSetKey()); const std::string &old_underlying_type = ConvertTypeIdToString(old_types_, old_type->GetUnderlyingType()); const std::string &new_underlying_type = @@ -555,6 +556,7 @@ DiffStatus AbiDiffHelper::CompareRecordTypes( } DiffStatus final_diff_status = DiffStatus::no_diff; record_type_diff_ir->SetName(old_type->GetName()); + record_type_diff_ir->SetLinkerSetKey(old_type->GetLinkerSetKey()); if (IsAccessDownGraded(old_type->GetAccess(), new_type->GetAccess())) { final_diff_status = DiffStatus::indirect_diff; record_type_diff_ir->SetAccessDiff( diff --git a/vndk/tools/header-checker/src/repr/ir_diff_representation.h b/vndk/tools/header-checker/src/repr/ir_diff_representation.h index 2ec4c0def..85c903ec9 100644 --- a/vndk/tools/header-checker/src/repr/ir_diff_representation.h +++ b/vndk/tools/header-checker/src/repr/ir_diff_representation.h @@ -190,6 +190,10 @@ class RecordTypeDiffIR : public DiffMessageIR { base_specifier_diffs_ = std::move(base_diffs); } + void SetLinkerSetKey(std::string linker_set_key) { + linker_set_key_ = std::move(linker_set_key); + } + bool DiffExists() const { return (type_diff_ != nullptr) || (vtable_diffs_ != nullptr) || (fields_removed_.size() != 0) || (field_diffs_.size() != 0) || @@ -208,6 +212,8 @@ class RecordTypeDiffIR : public DiffMessageIR { return base_specifier_diffs_.get(); } + const std::string &GetLinkerSetKey() const { return linker_set_key_; } + protected: // optional implemented with vector / std::unique_ptr. std::unique_ptr type_diff_; @@ -217,8 +223,7 @@ class RecordTypeDiffIR : public DiffMessageIR { std::vector fields_added_; std::unique_ptr access_diff_; std::unique_ptr base_specifier_diffs_; - // Template Diffs are not needed since they will show up in the linker set - // key. + std::string linker_set_key_; }; class EnumFieldDiffIR { @@ -274,6 +279,12 @@ class EnumTypeDiffIR : public DiffMessageIR { return underlying_type_diff_.get(); } + void SetLinkerSetKey(std::string linker_set_key) { + linker_set_key_ = std::move(linker_set_key); + } + + const std::string &GetLinkerSetKey() const { return linker_set_key_; } + bool IsExtended() const { if (fields_removed_.size() == 0 && fields_diff_.size() == 0 && fields_added_.size() != 0) { @@ -300,8 +311,7 @@ class EnumTypeDiffIR : public DiffMessageIR { std::vector fields_removed_; std::vector fields_added_; std::vector fields_diff_; - // Modifiable to allow implicit construction. - std::string name_; + std::string linker_set_key_; }; class GlobalVarDiffIR : public DiffMessageIR { diff --git a/vndk/tools/header-checker/src/repr/protobuf/converter.cpp b/vndk/tools/header-checker/src/repr/protobuf/converter.cpp index 0ec9ab729..c418d80c1 100644 --- a/vndk/tools/header-checker/src/repr/protobuf/converter.cpp +++ b/vndk/tools/header-checker/src/repr/protobuf/converter.cpp @@ -138,8 +138,10 @@ abi_diff::RecordTypeDiff IRDiffToProtobufConverter::ConvertRecordTypeDiffIR( const RecordTypeDiffIR *record_type_diff_ir) { abi_diff::RecordTypeDiff record_type_diff_protobuf; record_type_diff_protobuf.set_name(record_type_diff_ir->GetName()); - const TypeDiffIR *type_diff_ir = record_type_diff_ir->GetTypeDiff(); + record_type_diff_protobuf.set_linker_set_key( + record_type_diff_ir->GetLinkerSetKey()); // If a type_info diff exists + const TypeDiffIR *type_diff_ir = record_type_diff_ir->GetTypeDiff(); if (type_diff_ir != nullptr) { abi_diff::TypeInfoDiff *type_info_diff = record_type_diff_protobuf.mutable_type_info_diff(); @@ -230,6 +232,8 @@ abi_diff::EnumTypeDiff IRDiffToProtobufConverter::ConvertEnumTypeDiffIR( const EnumTypeDiffIR *enum_type_diff_ir) { abi_diff::EnumTypeDiff enum_type_diff_protobuf; enum_type_diff_protobuf.set_name(enum_type_diff_ir->GetName()); + enum_type_diff_protobuf.set_linker_set_key( + enum_type_diff_ir->GetLinkerSetKey()); const std::pair *underlying_type_diff = enum_type_diff_ir->GetUnderlyingTypeDiff(); if ((underlying_type_diff != nullptr && diff --git a/vndk/tools/header-checker/src/repr/protobuf/proto/abi_diff.proto b/vndk/tools/header-checker/src/repr/protobuf/proto/abi_diff.proto index 03f8ebe4b..90a1096e4 100644 --- a/vndk/tools/header-checker/src/repr/protobuf/proto/abi_diff.proto +++ b/vndk/tools/header-checker/src/repr/protobuf/proto/abi_diff.proto @@ -30,6 +30,7 @@ message CXXBaseSpecifierDiff { } message RecordTypeDiff { + // Template diffs are not needed since they have different linker set keys. optional string name = 1; optional string type_stack = 2; optional TypeInfoDiff type_info_diff = 3; @@ -38,6 +39,7 @@ message RecordTypeDiff { repeated RecordFieldDeclDiff fields_diff = 6; optional CXXBaseSpecifierDiff bases_diff = 7; optional VTableLayoutDiff vtable_layout_diff = 8; + optional string linker_set_key = 9; } message UnderlyingTypeDiff { @@ -57,6 +59,7 @@ message EnumTypeDiff { optional UnderlyingTypeDiff underlying_type_diff = 4; repeated abi_dump.EnumFieldDecl fields_added = 5; repeated abi_dump.EnumFieldDecl fields_removed = 6; + optional string linker_set_key = 7; } message FunctionDeclDiff {