Merge "header-checker: Fix opaque types comparison"

am: d199d5d3a0

Change-Id: Icacd0f84ca73692a002160b80f527d24f485ea56
This commit is contained in:
Logan Chien
2018-10-17 19:12:29 -07:00
committed by android-build-merger
3 changed files with 46 additions and 3 deletions

View File

@@ -810,6 +810,7 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
old_types_.find(old_type_id); old_types_.find(old_type_id);
AbiElementMap<const abi_util::TypeIR *>::const_iterator new_it = AbiElementMap<const abi_util::TypeIR *>::const_iterator new_it =
new_types_.find(new_type_id); new_types_.find(new_type_id);
if (old_it == old_types_.end() || new_it == new_types_.end()) { if (old_it == old_types_.end() || new_it == new_types_.end()) {
TypeQueueCheckAndPop(type_queue); TypeQueueCheckAndPop(type_queue);
// One of the types were hidden, we cannot compare further. // One of the types were hidden, we cannot compare further.
@@ -830,11 +831,16 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
} }
TypeQueueCheckAndPop(type_queue); TypeQueueCheckAndPop(type_queue);
if (diff_policy_options_.consider_opaque_types_different_ && if (diff_policy_options_.consider_opaque_types_different_ &&
diff_status == DiffStatus::opaque_diff && diff_status == DiffStatus::opaque_diff) {
(old_it->second->GetName() != new_it->second->GetName())) { // If `-considered-opaque-types-different` is specified and the comparison
return DiffStatus::direct_diff; // of `referenced_type` results in `opaque_diff`, then check the type name
// at this level.
return (old_it->second->GetName() == new_it->second->GetName() ?
DiffStatus::no_diff : DiffStatus::direct_diff);
} }
return diff_status; return diff_status;
} }

View File

@@ -0,0 +1,29 @@
{
"elf_objects" :
[
{
"name" : "test"
}
],
"global_vars" :
[
{
"linker_set_key" : "test",
"name" : "test",
"referenced_type" : "type-1",
"source_file" : "opaque_ptr_types.h"
}
],
"pointer_types" :
[
{
"alignment" : 8,
"linker_set_key" : "OpaqueType *",
"name" : "OpaqueType *",
"referenced_type" : "type-2",
"self_type" : "type-1",
"size" : 8,
"source_file" : "opaque_ptr_types.h"
}
]
}

View File

@@ -277,6 +277,14 @@ class MyTest(unittest.TestCase):
["-input-format-old", "ProtobufTextFormat", ["-input-format-old", "ProtobufTextFormat",
"-input-format-new", "Json"]) "-input-format-new", "Json"])
def test_opaque_type_self_diff(self):
lsdump = os.path.join(
SCRIPT_DIR, "abi_dumps", "opaque_ptr_types.lsdump")
self.run_and_compare_abi_diff(
lsdump, lsdump, "libexample", "arm64", 0,
["-input-format-old", "Json", "-input-format-new", "Json",
"-consider-opaque-types-different"])
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()