Merge "header-abi-diff: Fix omission of warning message for extensions."

am: dd511b6bd0

Change-Id: I1f7bbeaaee9fb5f6f391222a4fa608310705a7e3
This commit is contained in:
Jayant Chowdhary
2018-05-29 12:16:44 -07:00
committed by android-build-merger
3 changed files with 20 additions and 15 deletions

View File

@@ -126,6 +126,16 @@ static std::set<std::string> LoadIgnoredSymbols(std::string &symbol_list_path) {
static const char kWarn[] = "\033[36;1mwarning: \033[0m"; static const char kWarn[] = "\033[36;1mwarning: \033[0m";
static const char kError[] = "\033[31;1merror: \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) { int main(int argc, const char **argv) {
llvm::cl::ParseCommandLineOptions(argc, argv, "header-checker"); llvm::cl::ParseCommandLineOptions(argc, argv, "header-checker");
std::set<std::string> ignored_symbols; std::set<std::string> 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 += " This MIGHT be an ABI breaking change due to";
unreferenced_change_str += " internal typecasts."; unreferenced_change_str += " internal typecasts.";
} }
bool suppress_extending_warnings =
allow_extensions && (status & abi_util::CompatibilityStatusIR::Extension);
bool suppress_elf_warnings = bool should_emit_warning_message = ShouldEmitWarningMessage(status);
allow_unreferenced_elf_symbol_changes &&
(status & abi_util::CompatibilityStatusIR::ElfIncompatible);
if (!suppress_local_warnings && !suppress_extending_warnings && if (should_emit_warning_message) {
!suppress_elf_warnings && status) {
llvm::errs() << "******************************************************\n" llvm::errs() << "******************************************************\n"
<< error_or_warning_str << error_or_warning_str
<< "VNDK library: " << "VNDK library: "
@@ -189,13 +194,7 @@ int main(int argc, const char **argv) {
<< "******************************************************\n"; << "******************************************************\n";
} }
if (!advice_only && ((!allow_extensions && if (!advice_only && should_emit_warning_message) {
(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))) {
return status; return status;
} }

View File

@@ -189,7 +189,8 @@ TEST_MODULES = [
'integration/cpp/gold/high_volume_speaker.cpp', 'integration/cpp/gold/high_volume_speaker.cpp',
'integration/cpp/gold/low_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'], export_include_dirs = ['integration/cpp/gold/include'],
cflags = ['-DGOLDEN_ADD_FUNCTION=1', '-DADD_UNEXPORTED_ELF_SYMBOL'], cflags = ['-DGOLDEN_ADD_FUNCTION=1', '-DADD_UNEXPORTED_ELF_SYMBOL'],
arch = '', arch = '',

View File

@@ -159,6 +159,11 @@ class MyTest(unittest.TestCase):
self.prepare_and_run_abi_diff_all_archs( self.prepare_and_run_abi_diff_all_archs(
"libgolden_cpp", "libgolden_cpp_add_function", 4) "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): def test_libgolden_cpp_add_function_and_elf_symbol(self):
self.prepare_and_run_abi_diff_all_archs( self.prepare_and_run_abi_diff_all_archs(
"libgolden_cpp", "libgolden_cpp_add_function_and_unexported_elf", "libgolden_cpp", "libgolden_cpp_add_function_and_unexported_elf",