Merge "Mark two records as different if the access specifier is downgraded."

This commit is contained in:
Jayant Chowdhary
2018-05-17 17:07:02 +00:00
committed by Gerrit Code Review
4 changed files with 52 additions and 1 deletions

View File

@@ -518,7 +518,7 @@ DiffStatus AbiDiffHelper::CompareRecordTypes(
}
DiffStatus final_diff_status = DiffStatus::no_diff;
record_type_diff_ir->SetName(old_type->GetName());
if (old_type->GetAccess() != new_type->GetAccess()) {
if (IsAccessDownGraded(old_type->GetAccess(), new_type->GetAccess())) {
final_diff_status = DiffStatus::indirect_diff;
record_type_diff_ir->SetAccessDiff(
std::make_unique<abi_util::AccessSpecifierDiffIR>(

View File

@@ -60,6 +60,7 @@ class SuperSpeaker {
#else
int mSpeakderId;
#endif
#if GOLDEN_FUNCTION_POINTER
#if GOLDEN_FUNCTION_POINTER_ADD_PARAM
SuperSpeaker * (*speaker_fp)(int, char, int);
@@ -67,4 +68,17 @@ class SuperSpeaker {
SuperSpeaker * (*speaker_fp)(int, char);
#endif
#endif
#if GOLDEN_WITH_INTERNAL_STRUCT
#ifdef GOLDEN_WITH_PUBLIC_INTERNAL_STRUCT
public:
#else
private:
#endif
struct InternalStruct {
int internal;
};
private:
InternalStruct a;
#endif // GOLDEN_WITH_INTERNAL_STRUCT
};

View File

@@ -398,6 +398,32 @@ TEST_MODULES = [
arch = '',
api = 'current',
),
Module(
name = 'libgolden_cpp_internal_public_struct',
srcs = ['integration/cpp/gold/golden_1.cpp',
'integration/cpp/gold/high_volume_speaker.cpp',
'integration/cpp/gold/low_volume_speaker.cpp',
],
version_script = 'integration/cpp/gold/map.txt',
export_include_dirs = ['integration/cpp/gold/include'],
cflags = ['-DGOLDEN_WITH_INTERNAL_STRUCT',
'-DGOLDEN_WITH_PUBLIC_INTERNAL_STRUCT'],
arch = '',
api = 'current',
),
Module(
name = 'libgolden_cpp_internal_private_struct',
srcs = ['integration/cpp/gold/golden_1.cpp',
'integration/cpp/gold/high_volume_speaker.cpp',
'integration/cpp/gold/low_volume_speaker.cpp',
],
version_script = 'integration/cpp/gold/map.txt',
export_include_dirs = ['integration/cpp/gold/include'],
cflags = ['-DGOLDEN_WITH_INTERNAL_STRUCT'],
arch = '',
api = 'current',
),
]
TEST_MODULES = { m.name: m for m in TEST_MODULES }

View File

@@ -238,6 +238,17 @@ class MyTest(unittest.TestCase):
"libgolden_cpp_function_pointer_parameter_added", 8, [], True,
True)
def test_libgolden_cpp_internal_struct_access_upgraded(self):
self.prepare_and_run_abi_diff_all_archs(
"libgolden_cpp_internal_private_struct",
"libgolden_cpp_internal_public_struct", 0, [], True,
True)
def test_libgolden_cpp_internal_struct_access_downgraded(self):
self.prepare_and_run_abi_diff_all_archs(
"libgolden_cpp_internal_public_struct",
"libgolden_cpp_internal_private_struct", 8, [], True,
True)
if __name__ == '__main__':