diff --git a/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp b/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp index 369b73a68..f5764707d 100644 --- a/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp +++ b/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp @@ -126,6 +126,16 @@ static std::set LoadIgnoredSymbols(std::string &symbol_list_path) { static const char kWarn[] = "\033[36;1mwarning: \033[0m"; static const char kError[] = "\033[31;1merror: \033[0m"; +bool ShouldEmitWarningMessage(abi_util::CompatibilityStatusIR status) { + return (!allow_extensions && + (status & abi_util::CompatibilityStatusIR::Extension)) || + (!allow_unreferenced_changes && + (status & abi_util::CompatibilityStatusIR::UnreferencedChanges)) || + (!allow_unreferenced_elf_symbol_changes && + (status & abi_util::CompatibilityStatusIR::ElfIncompatible)) || + (status & abi_util::CompatibilityStatusIR::Incompatible); +} + int main(int argc, const char **argv) { llvm::cl::ParseCommandLineOptions(argc, argv, "header-checker"); std::set ignored_symbols; @@ -168,15 +178,10 @@ int main(int argc, const char **argv) { unreferenced_change_str += " This MIGHT be an ABI breaking change due to"; unreferenced_change_str += " internal typecasts."; } - bool suppress_extending_warnings = - allow_extensions && (status & abi_util::CompatibilityStatusIR::Extension); - bool suppress_elf_warnings = - allow_unreferenced_elf_symbol_changes && - (status & abi_util::CompatibilityStatusIR::ElfIncompatible); + bool should_emit_warning_message = ShouldEmitWarningMessage(status); - if (!suppress_local_warnings && !suppress_extending_warnings && - !suppress_elf_warnings && status) { + if (should_emit_warning_message) { llvm::errs() << "******************************************************\n" << error_or_warning_str << "VNDK library: " @@ -189,13 +194,7 @@ int main(int argc, const char **argv) { << "******************************************************\n"; } - if (!advice_only && ((!allow_extensions && - (status & abi_util::CompatibilityStatusIR::Extension)) || - (!allow_unreferenced_changes && - (status & abi_util::CompatibilityStatusIR::UnreferencedChanges)) || - (!allow_unreferenced_elf_symbol_changes && - (status & abi_util::CompatibilityStatusIR::ElfIncompatible)) || - (status & abi_util::CompatibilityStatusIR::Incompatible))) { + if (!advice_only && should_emit_warning_message) { return status; } diff --git a/vndk/tools/header-checker/tests/module.py b/vndk/tools/header-checker/tests/module.py index e2b5e5249..0df8b2adf 100755 --- a/vndk/tools/header-checker/tests/module.py +++ b/vndk/tools/header-checker/tests/module.py @@ -189,7 +189,8 @@ TEST_MODULES = [ 'integration/cpp/gold/high_volume_speaker.cpp', 'integration/cpp/gold/low_volume_speaker.cpp', ], - version_script = 'integration/cpp/gold/map_add_function.txt', + version_script = \ + 'integration/cpp/gold/map_add_function_elf_symbol.txt', export_include_dirs = ['integration/cpp/gold/include'], cflags = ['-DGOLDEN_ADD_FUNCTION=1', '-DADD_UNEXPORTED_ELF_SYMBOL'], arch = '', diff --git a/vndk/tools/header-checker/tests/test.py b/vndk/tools/header-checker/tests/test.py index 4362201f7..ed186ad93 100755 --- a/vndk/tools/header-checker/tests/test.py +++ b/vndk/tools/header-checker/tests/test.py @@ -159,6 +159,11 @@ class MyTest(unittest.TestCase): self.prepare_and_run_abi_diff_all_archs( "libgolden_cpp", "libgolden_cpp_add_function", 4) + def test_libgolden_cpp_add_function_allow_extension(self): + self.prepare_and_run_abi_diff_all_archs( + "libgolden_cpp", "libgolden_cpp_add_function", 0, + ['-allow-extensions']) + def test_libgolden_cpp_add_function_and_elf_symbol(self): self.prepare_and_run_abi_diff_all_archs( "libgolden_cpp", "libgolden_cpp_add_function_and_unexported_elf",