Merge "Fix the comparison between opaque parameters"
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include <llvm/Support/raw_ostream.h>
|
#include <llvm/Support/raw_ostream.h>
|
||||||
|
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
|
|
||||||
namespace header_checker {
|
namespace header_checker {
|
||||||
namespace repr {
|
namespace repr {
|
||||||
@@ -260,6 +262,20 @@ bool AbiDiffHelper::CompareVTables(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AbiDiffHelper::AreOpaqueTypesEqual(const std::string &old_type_id,
|
||||||
|
const std::string &new_type_id) const {
|
||||||
|
if (!diff_policy_options_.consider_opaque_types_different_ ||
|
||||||
|
old_type_id == new_type_id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// __va_list is an opaque type defined by the compiler. ARM ABI requires
|
||||||
|
// __va_list to be in std namespace. Its mangled name is _ZTISt9__va_list, but
|
||||||
|
// some versions of clang produce _ZTI9__va_list. The names are equivalent.
|
||||||
|
static const std::unordered_set<std::string> va_list_names{
|
||||||
|
"_ZTI9__va_list", "_ZTISt9__va_list"};
|
||||||
|
return va_list_names.count(old_type_id) && va_list_names.count(new_type_id);
|
||||||
|
}
|
||||||
|
|
||||||
static bool CompareSizeAndAlignment(const TypeIR *old_type,
|
static bool CompareSizeAndAlignment(const TypeIR *old_type,
|
||||||
const TypeIR *new_type) {
|
const TypeIR *new_type) {
|
||||||
return old_type->GetSize() == new_type->GetSize() &&
|
return old_type->GetSize() == new_type->GetSize() &&
|
||||||
@@ -274,7 +290,7 @@ bool AbiDiffHelper::AreTypeSizeAndAlignmentEqual(
|
|||||||
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()) {
|
||||||
return !diff_policy_options_.consider_opaque_types_different_;
|
return AreOpaqueTypesEqual(old_type_id, new_type_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CompareSizeAndAlignment(old_it->second, new_it->second);
|
return CompareSizeAndAlignment(old_it->second, new_it->second);
|
||||||
@@ -825,10 +841,9 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
|
|||||||
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.
|
||||||
if (diff_policy_options_.consider_opaque_types_different_) {
|
return AreOpaqueTypesEqual(old_type_id, new_type_id)
|
||||||
return DiffStatus::opaque_diff;
|
? DiffStatus::no_diff
|
||||||
}
|
: DiffStatus::opaque_diff;
|
||||||
return DiffStatus::no_diff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkableMessageKind old_kind = old_it->second->GetKind();
|
LinkableMessageKind old_kind = old_it->second->GetKind();
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ class AbiDiffHelper {
|
|||||||
ignored_linker_set_keys_(ignored_linker_set_keys),
|
ignored_linker_set_keys_(ignored_linker_set_keys),
|
||||||
ir_diff_dumper_(ir_diff_dumper) {}
|
ir_diff_dumper_(ir_diff_dumper) {}
|
||||||
|
|
||||||
|
bool AreOpaqueTypesEqual(const std::string &old_type_str,
|
||||||
|
const std::string &new_type_str) const;
|
||||||
|
|
||||||
bool AreTypeSizeAndAlignmentEqual(const std::string &old_type_str,
|
bool AreTypeSizeAndAlignmentEqual(const std::string &old_type_str,
|
||||||
const std::string &new_type_str) const;
|
const std::string &new_type_str) const;
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
struct OpaqueType;
|
||||||
|
OpaqueType *function(va_list);
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
libopaque_type {
|
||||||
|
global:
|
||||||
|
function;
|
||||||
|
};
|
||||||
@@ -518,6 +518,15 @@ TEST_MODULES = [
|
|||||||
linker_flags=['-input-format', 'Json', '-output-format', 'Json'],
|
linker_flags=['-input-format', 'Json', '-output-format', 'Json'],
|
||||||
has_reference_dump=True,
|
has_reference_dump=True,
|
||||||
),
|
),
|
||||||
|
LsdumpModule(
|
||||||
|
name='libopaque_type',
|
||||||
|
arch='arm64',
|
||||||
|
srcs=['integration/opaque_type/include/opaque_type.h'],
|
||||||
|
version_script='integration/opaque_type/map.txt',
|
||||||
|
export_include_dirs=['integration/opaque_type/include'],
|
||||||
|
linker_flags=['-output-format', 'Json'],
|
||||||
|
has_reference_dump=True,
|
||||||
|
),
|
||||||
LsdumpModule(
|
LsdumpModule(
|
||||||
name='libversion_script_example',
|
name='libversion_script_example',
|
||||||
arch='arm64',
|
arch='arm64',
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"array_types" : [],
|
||||||
|
"builtin_types" : [],
|
||||||
|
"elf_functions" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name" : "function"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"elf_objects" : [],
|
||||||
|
"enum_types" : [],
|
||||||
|
"function_types" : [],
|
||||||
|
"functions" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"function_name" : "function",
|
||||||
|
"linker_set_key" : "function",
|
||||||
|
"parameters" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"referenced_type" : "_ZTISt9__va_list"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"return_type" : "_ZTIP10OpaqueType",
|
||||||
|
"source_file" : "development/vndk/tools/header-checker/tests/integration/opaque_type/include/opaque_type.h"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"global_vars" : [],
|
||||||
|
"lvalue_reference_types" : [],
|
||||||
|
"pointer_types" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"alignment" : 8,
|
||||||
|
"linker_set_key" : "_ZTIP10OpaqueType",
|
||||||
|
"name" : "OpaqueType *",
|
||||||
|
"referenced_type" : "_ZTI10OpaqueType",
|
||||||
|
"self_type" : "_ZTIP10OpaqueType",
|
||||||
|
"size" : 8,
|
||||||
|
"source_file" : "development/vndk/tools/header-checker/tests/integration/opaque_type/include/opaque_type.h"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"qualified_types" : [],
|
||||||
|
"record_types" : [],
|
||||||
|
"rvalue_reference_types" : []
|
||||||
|
}
|
||||||
@@ -311,12 +311,11 @@ class HeaderCheckerTest(unittest.TestCase):
|
|||||||
"-input-format-new", "Json"])
|
"-input-format-new", "Json"])
|
||||||
|
|
||||||
def test_opaque_type_self_diff(self):
|
def test_opaque_type_self_diff(self):
|
||||||
lsdump = os.path.join(
|
self.prepare_and_run_abi_diff_all_archs(
|
||||||
SCRIPT_DIR, "abi_dumps", "opaque_ptr_types.lsdump")
|
"libopaque_type", "libopaque_type", 0,
|
||||||
self.run_and_compare_abi_diff(
|
|
||||||
lsdump, lsdump, "libexample", "arm64", 0,
|
|
||||||
["-input-format-old", "Json", "-input-format-new", "Json",
|
["-input-format-old", "Json", "-input-format-new", "Json",
|
||||||
"-consider-opaque-types-different"])
|
"-consider-opaque-types-different"],
|
||||||
|
create_old=False, create_new=False)
|
||||||
|
|
||||||
def test_allow_adding_removing_weak_symbols(self):
|
def test_allow_adding_removing_weak_symbols(self):
|
||||||
module_old = Module.get_test_modules_by_name("libweak_symbols_old")[0]
|
module_old = Module.get_test_modules_by_name("libweak_symbols_old")[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user