summaryrefslogtreecommitdiffstats
path: root/vndk
diff options
context:
space:
mode:
authorLogan Chien <loganchien@google.com>2019-03-12 18:23:09 +0800
committerLogan Chien <loganchien@google.com>2019-03-20 14:13:21 +0800
commitef967f7325ac52b1628cc42ce6f393f4a6cef5d5 (patch)
tree813062ddac8066504ebd5b640923fa068159a8a9 /vndk
parentb229c4e38f960268c84dc75d194ed28e9b3fc965 (diff)
downloadandroid_development-ef967f7325ac52b1628cc42ce6f393f4a6cef5d5.tar.gz
android_development-ef967f7325ac52b1628cc42ce6f393f4a6cef5d5.tar.bz2
android_development-ef967f7325ac52b1628cc42ce6f393f4a6cef5d5.zip
header-checker: Cleanup namespaces
Test: ./tests/test.py Test: ${ANDROID_HOST_OUT}/nativetest64/\ header-checker-unittests/header-checker-unittests Change-Id: I65347228e31e63678c2642eaf19a60303cf33683
Diffstat (limited to 'vndk')
-rw-r--r--vndk/tools/header-checker/src/diff/abi_diff.cpp209
-rw-r--r--vndk/tools/header-checker/src/diff/abi_diff.h118
-rw-r--r--vndk/tools/header-checker/src/diff/abi_diff_wrappers.cpp43
-rw-r--r--vndk/tools/header-checker/src/diff/abi_diff_wrappers.h26
-rw-r--r--vndk/tools/header-checker/src/diff/header_abi_diff.cpp52
-rw-r--r--vndk/tools/header-checker/src/diff_merge/merge_abi_diff.cpp47
-rw-r--r--vndk/tools/header-checker/src/dumper/abi_wrappers.cpp154
-rw-r--r--vndk/tools/header-checker/src/dumper/abi_wrappers.h87
-rw-r--r--vndk/tools/header-checker/src/dumper/ast_processing.cpp34
-rw-r--r--vndk/tools/header-checker/src/dumper/ast_processing.h18
-rw-r--r--vndk/tools/header-checker/src/dumper/ast_util.h9
-rw-r--r--vndk/tools/header-checker/src/dumper/diagnostic_consumer.cpp8
-rw-r--r--vndk/tools/header-checker/src/dumper/diagnostic_consumer.h9
-rw-r--r--vndk/tools/header-checker/src/dumper/fake_decl_source.cpp8
-rw-r--r--vndk/tools/header-checker/src/dumper/fake_decl_source.h14
-rw-r--r--vndk/tools/header-checker/src/dumper/fixed_argv.cpp8
-rw-r--r--vndk/tools/header-checker/src/dumper/fixed_argv.h8
-rw-r--r--vndk/tools/header-checker/src/dumper/frontend_action.cpp8
-rw-r--r--vndk/tools/header-checker/src/dumper/frontend_action.h10
-rw-r--r--vndk/tools/header-checker/src/dumper/frontend_action_factory.cpp8
-rw-r--r--vndk/tools/header-checker/src/dumper/frontend_action_factory.h9
-rw-r--r--vndk/tools/header-checker/src/dumper/header_checker.cpp24
-rw-r--r--vndk/tools/header-checker/src/dumper/header_checker.h13
-rw-r--r--vndk/tools/header-checker/src/linker/header_abi_linker.cpp105
-rw-r--r--vndk/tools/header-checker/src/repr/abi_diff_helpers.cpp324
-rw-r--r--vndk/tools/header-checker/src/repr/abi_diff_helpers.h136
-rw-r--r--vndk/tools/header-checker/src/repr/ir_representation.cpp9
-rw-r--r--vndk/tools/header-checker/src/repr/ir_representation.h10
-rw-r--r--vndk/tools/header-checker/src/repr/json/ir_representation_json.cpp8
-rw-r--r--vndk/tools/header-checker/src/repr/json/ir_representation_json.h10
-rw-r--r--vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.cpp12
-rw-r--r--vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.h11
-rw-r--r--vndk/tools/header-checker/src/repr/symbol/exported_symbol_set.cpp10
-rw-r--r--vndk/tools/header-checker/src/repr/symbol/exported_symbol_set.h6
-rw-r--r--vndk/tools/header-checker/src/repr/symbol/exported_symbol_set_test.cpp6
-rw-r--r--vndk/tools/header-checker/src/repr/symbol/so_file_parser.cpp14
-rw-r--r--vndk/tools/header-checker/src/repr/symbol/so_file_parser.h6
-rw-r--r--vndk/tools/header-checker/src/repr/symbol/version_script_parser.cpp34
-rw-r--r--vndk/tools/header-checker/src/repr/symbol/version_script_parser.h12
-rw-r--r--vndk/tools/header-checker/src/repr/symbol/version_script_parser_test.cpp8
-rw-r--r--vndk/tools/header-checker/src/utils/api_level.cpp6
-rw-r--r--vndk/tools/header-checker/src/utils/api_level.h6
-rw-r--r--vndk/tools/header-checker/src/utils/api_level_test.cpp7
-rw-r--r--vndk/tools/header-checker/src/utils/collect_exported_headers.cpp9
-rw-r--r--vndk/tools/header-checker/src/utils/header_abi_util.h9
-rw-r--r--vndk/tools/header-checker/src/utils/stl_utils.h6
-rw-r--r--vndk/tools/header-checker/src/utils/string_utils.cpp6
-rw-r--r--vndk/tools/header-checker/src/utils/string_utils.h6
-rw-r--r--vndk/tools/header-checker/src/utils/string_utils_test.cpp6
49 files changed, 979 insertions, 727 deletions
diff --git a/vndk/tools/header-checker/src/diff/abi_diff.cpp b/vndk/tools/header-checker/src/diff/abi_diff.cpp
index 829b7415b..b67ca24a5 100644
--- a/vndk/tools/header-checker/src/diff/abi_diff.cpp
+++ b/vndk/tools/header-checker/src/diff/abi_diff.cpp
@@ -25,20 +25,24 @@
#include <stdlib.h>
-abi_util::CompatibilityStatusIR HeaderAbiDiff::GenerateCompatibilityReport() {
- using abi_util::TextFormatToIRReader;
- std::unique_ptr<abi_util::TextFormatToIRReader> old_reader =
+namespace header_checker {
+namespace diff {
+
+
+repr::CompatibilityStatusIR HeaderAbiDiff::GenerateCompatibilityReport() {
+ using repr::TextFormatToIRReader;
+ std::unique_ptr<repr::TextFormatToIRReader> old_reader =
TextFormatToIRReader::CreateTextFormatToIRReader(text_format_old_);
- std::unique_ptr<abi_util::TextFormatToIRReader> new_reader =
+ std::unique_ptr<repr::TextFormatToIRReader> new_reader =
TextFormatToIRReader::CreateTextFormatToIRReader(text_format_new_);
if (!old_reader || !new_reader || !old_reader->ReadDump(old_dump_) ||
!new_reader->ReadDump(new_dump_)) {
llvm::errs() << "Could not create Text Format readers\n";
::exit(1);
}
- std::unique_ptr<abi_util::IRDiffDumper> ir_diff_dumper =
- abi_util::IRDiffDumper::CreateIRDiffDumper(text_format_diff_, cr_);
- abi_util::CompatibilityStatusIR status =
+ std::unique_ptr<repr::IRDiffDumper> ir_diff_dumper =
+ repr::IRDiffDumper::CreateIRDiffDumper(text_format_diff_, cr_);
+ repr::CompatibilityStatusIR status =
CompareTUs(old_reader.get(), new_reader.get(), ir_diff_dumper.get());
if (!ir_diff_dumper->Dump()) {
llvm::errs() << "Could not dump diff report\n";
@@ -47,15 +51,15 @@ abi_util::CompatibilityStatusIR HeaderAbiDiff::GenerateCompatibilityReport() {
return status;
}
-abi_util::CompatibilityStatusIR HeaderAbiDiff::CompareTUs(
- const abi_util::TextFormatToIRReader *old_tu,
- const abi_util::TextFormatToIRReader *new_tu,
- abi_util::IRDiffDumper *ir_diff_dumper) {
+repr::CompatibilityStatusIR HeaderAbiDiff::CompareTUs(
+ const repr::TextFormatToIRReader *old_tu,
+ const repr::TextFormatToIRReader *new_tu,
+ repr::IRDiffDumper *ir_diff_dumper) {
// Collect all old and new types in maps, so that we can refer to them by
// type name / linker_set_key later.
- const AbiElementMap<const abi_util::TypeIR *> old_types =
+ const AbiElementMap<const repr::TypeIR *> old_types =
old_tu->GetTypeGraph();
- const AbiElementMap<const abi_util::TypeIR *> new_types =
+ const AbiElementMap<const repr::TypeIR *> new_types =
new_tu->GetTypeGraph();
// Collect fills in added, removed ,unsafe and safe function diffs.
@@ -82,7 +86,7 @@ abi_util::CompatibilityStatusIR HeaderAbiDiff::CompareTUs(
::exit(1);
}
- abi_util::CompatibilityStatusIR combined_status =
+ repr::CompatibilityStatusIR combined_status =
ir_diff_dumper->GetCompatibilityStatusIR();
ir_diff_dumper->AddLibNameIR(lib_name_);
@@ -91,12 +95,12 @@ abi_util::CompatibilityStatusIR HeaderAbiDiff::CompareTUs(
return combined_status;
}
-std::pair<AbiElementMap<const abi_util::EnumTypeIR *>,
- AbiElementMap<const abi_util::RecordTypeIR *>>
+std::pair<AbiElementMap<const repr::EnumTypeIR *>,
+ AbiElementMap<const repr::RecordTypeIR *>>
HeaderAbiDiff::ExtractUserDefinedTypes(
- const abi_util::TextFormatToIRReader *tu) {
- AbiElementMap<const abi_util::EnumTypeIR *> enum_types;
- AbiElementMap<const abi_util::RecordTypeIR *> record_types;
+ const repr::TextFormatToIRReader *tu) {
+ AbiElementMap<const repr::EnumTypeIR *> enum_types;
+ AbiElementMap<const repr::RecordTypeIR *> record_types;
// Iterate through the ODRListMap, if there is more than 1 element in the
// list, we cannot really unique the type by name, so skip it. If not, add a
// map entry UniqueId -> const Record(Enum)TypeIR *.
@@ -105,23 +109,23 @@ HeaderAbiDiff::ExtractUserDefinedTypes(
if (odr_list.size() != 1) {
continue;
}
- const abi_util::TypeIR *type = *(odr_list.begin());
- const abi_util::RecordTypeIR *record_type = nullptr;
+ const repr::TypeIR *type = *(odr_list.begin());
+ const repr::RecordTypeIR *record_type = nullptr;
switch (type->GetKind()) {
- case abi_util::RecordTypeKind:
- record_type = static_cast<const abi_util::RecordTypeIR *>(type);
+ case repr::RecordTypeKind:
+ record_type = static_cast<const repr::RecordTypeIR *>(type);
if (record_type->IsAnonymous()) {
continue;
}
record_types.emplace(
record_type->GetUniqueId(), record_type);
break;
- case abi_util::EnumTypeKind:
+ case repr::EnumTypeKind:
enum_types.emplace(
- static_cast<const abi_util::EnumTypeIR *>(type)->GetUniqueId(),
- static_cast<const abi_util::EnumTypeIR *>(type));
+ static_cast<const repr::EnumTypeIR *>(type)->GetUniqueId(),
+ static_cast<const repr::EnumTypeIR *>(type));
break;
- case abi_util::FunctionTypeKind:
+ case repr::FunctionTypeKind:
continue;
default:
// Only user defined types should have ODR list entries.
@@ -132,11 +136,11 @@ HeaderAbiDiff::ExtractUserDefinedTypes(
}
bool HeaderAbiDiff::CollectUserDefinedTypes(
- const abi_util::TextFormatToIRReader *old_tu,
- const abi_util::TextFormatToIRReader *new_tu,
- const AbiElementMap<const abi_util::TypeIR *> &old_types_map,
- const AbiElementMap<const abi_util::TypeIR *> &new_types_map,
- abi_util::IRDiffDumper *ir_diff_dumper) {
+ const repr::TextFormatToIRReader *old_tu,
+ const repr::TextFormatToIRReader *new_tu,
+ const AbiElementMap<const repr::TypeIR *> &old_types_map,
+ const AbiElementMap<const repr::TypeIR *> &new_types_map,
+ repr::IRDiffDumper *ir_diff_dumper) {
auto old_enums_and_records_extracted = ExtractUserDefinedTypes(old_tu);
auto new_enums_and_records_extracted = ExtractUserDefinedTypes(new_tu);
@@ -155,15 +159,15 @@ template <typename T>
bool HeaderAbiDiff::CollectUserDefinedTypesInternal(
const AbiElementMap<const T*> &old_ud_types_map,
const AbiElementMap<const T*> &new_ud_types_map,
- const AbiElementMap<const abi_util::TypeIR *> &old_types_map,
- const AbiElementMap<const abi_util::TypeIR *> &new_types_map,
- abi_util::IRDiffDumper *ir_diff_dumper) {
+ const AbiElementMap<const repr::TypeIR *> &old_types_map,
+ const AbiElementMap<const repr::TypeIR *> &new_types_map,
+ repr::IRDiffDumper *ir_diff_dumper) {
return (Collect(old_ud_types_map, new_ud_types_map, nullptr, nullptr,
ir_diff_dumper, old_types_map, new_types_map) &&
PopulateCommonElements(old_ud_types_map, new_ud_types_map,
old_types_map, new_types_map, ir_diff_dumper,
- abi_util::DiffMessageIR::Unreferenced));
+ repr::DiffMessageIR::Unreferenced));
}
template <typename T, typename ElfSymbolType>
@@ -172,30 +176,27 @@ bool HeaderAbiDiff::CollectDynsymExportables(
const AbiElementMap<T> &new_exportables,
const AbiElementMap<ElfSymbolType> &old_elf_symbols,
const AbiElementMap<ElfSymbolType> &new_elf_symbols,
- const AbiElementMap<const abi_util::TypeIR *> &old_types_map,
- const AbiElementMap<const abi_util::TypeIR *> &new_types_map,
- abi_util::IRDiffDumper *ir_diff_dumper) {
+ const AbiElementMap<const repr::TypeIR *> &old_types_map,
+ const AbiElementMap<const repr::TypeIR *> &new_types_map,
+ repr::IRDiffDumper *ir_diff_dumper) {
AbiElementMap<const T *> old_exportables_map;
AbiElementMap<const T *> new_exportables_map;
- AbiElementMap<const abi_util::ElfSymbolIR *> old_elf_symbol_map;
- AbiElementMap<const abi_util::ElfSymbolIR *> new_elf_symbol_map;
-
- abi_util::AddToMap(&old_exportables_map, old_exportables,
- [](auto e) { return e->first;},
- [](auto e) {return &(e->second);});
- abi_util::AddToMap(&new_exportables_map, new_exportables,
- [](auto e) { return e->first;},
- [](auto e) { return &(e->second);});
-
- abi_util::AddToMap(
- &old_elf_symbol_map, old_elf_symbols,
- [](auto e) { return e->first;},
- [](auto e) {return &(e->second);});
-
- abi_util::AddToMap(
- &new_elf_symbol_map, new_elf_symbols,
- [](auto e) { return e->first;},
- [](auto e) {return &(e->second);});
+ AbiElementMap<const repr::ElfSymbolIR *> old_elf_symbol_map;
+ AbiElementMap<const repr::ElfSymbolIR *> new_elf_symbol_map;
+
+ utils::AddToMap(&old_exportables_map, old_exportables,
+ [](auto e) { return e->first;},
+ [](auto e) {return &(e->second);});
+ utils::AddToMap(&new_exportables_map, new_exportables,
+ [](auto e) { return e->first;},
+ [](auto e) { return &(e->second);});
+
+ utils::AddToMap(&old_elf_symbol_map, old_elf_symbols,
+ [](auto e) { return e->first;},
+ [](auto e) {return &(e->second);});
+ utils::AddToMap(&new_elf_symbol_map, new_elf_symbols,
+ [](auto e) { return e->first;},
+ [](auto e) {return &(e->second);});
if (!Collect(old_exportables_map,
new_exportables_map, &old_elf_symbol_map, &new_elf_symbol_map,
@@ -204,7 +205,7 @@ bool HeaderAbiDiff::CollectDynsymExportables(
ir_diff_dumper) ||
!PopulateCommonElements(old_exportables_map, new_exportables_map,
old_types_map, new_types_map, ir_diff_dumper,
- abi_util::DiffMessageIR::Referenced)) {
+ repr::DiffMessageIR::Referenced)) {
llvm::errs() << "Diffing dynsym exportables failed\n";
return false;
}
@@ -221,17 +222,17 @@ template <typename T>
bool HeaderAbiDiff::Collect(
const AbiElementMap<const T*> &old_elements_map,
const AbiElementMap<const T*> &new_elements_map,
- const AbiElementMap<const abi_util::ElfSymbolIR *> *old_elf_map,
- const AbiElementMap<const abi_util::ElfSymbolIR *> *new_elf_map,
- abi_util::IRDiffDumper *ir_diff_dumper,
- const AbiElementMap<const abi_util::TypeIR *> &old_types_map,
- const AbiElementMap<const abi_util::TypeIR *> &new_types_map) {
+ const AbiElementMap<const repr::ElfSymbolIR *> *old_elf_map,
+ const AbiElementMap<const repr::ElfSymbolIR *> *new_elf_map,
+ repr::IRDiffDumper *ir_diff_dumper,
+ const AbiElementMap<const repr::TypeIR *> &old_types_map,
+ const AbiElementMap<const repr::TypeIR *> &new_types_map) {
if (!PopulateRemovedElements(
old_elements_map, new_elements_map, new_elf_map, ir_diff_dumper,
- abi_util::DiffMessageIR::Removed, old_types_map) ||
+ repr::DiffMessageIR::Removed, old_types_map) ||
!PopulateRemovedElements(
new_elements_map, old_elements_map, old_elf_map, ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind::Added, new_types_map)) {
+ repr::IRDiffDumper::DiffKind::Added, new_types_map)) {
llvm::errs() << "Populating functions in report failed\n";
return false;
}
@@ -239,25 +240,25 @@ bool HeaderAbiDiff::Collect(
}
bool HeaderAbiDiff::CollectElfSymbols(
- const AbiElementMap<const abi_util::ElfSymbolIR *> &old_symbols,
- const AbiElementMap<const abi_util::ElfSymbolIR *> &new_symbols,
- abi_util::IRDiffDumper *ir_diff_dumper) {
- std::vector<const abi_util::ElfSymbolIR *> removed_elements =
- abi_util::FindRemovedElements(old_symbols, new_symbols);
+ const AbiElementMap<const repr::ElfSymbolIR *> &old_symbols,
+ const AbiElementMap<const repr::ElfSymbolIR *> &new_symbols,
+ repr::IRDiffDumper *ir_diff_dumper) {
+ std::vector<const repr::ElfSymbolIR *> removed_elements =
+ utils::FindRemovedElements(old_symbols, new_symbols);
- std::vector<const abi_util::ElfSymbolIR *> added_elements =
- abi_util::FindRemovedElements(new_symbols, old_symbols);
+ std::vector<const repr::ElfSymbolIR *> added_elements =
+ utils::FindRemovedElements(new_symbols, old_symbols);
return (PopulateElfElements(removed_elements, ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind::Removed) &&
+ repr::IRDiffDumper::DiffKind::Removed) &&
PopulateElfElements(added_elements, ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind::Added));
+ repr::IRDiffDumper::DiffKind::Added));
}
bool HeaderAbiDiff::PopulateElfElements(
- std::vector<const abi_util::ElfSymbolIR *> &elf_elements,
- abi_util::IRDiffDumper *ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind diff_kind) {
+ std::vector<const repr::ElfSymbolIR *> &elf_elements,
+ repr::IRDiffDumper *ir_diff_dumper,
+ repr::IRDiffDumper::DiffKind diff_kind) {
for (auto &&elf_element : elf_elements) {
if (!ir_diff_dumper->AddElfSymbolMessageIR(elf_element, diff_kind)) {
return false;
@@ -270,12 +271,12 @@ template <typename T>
bool HeaderAbiDiff::PopulateRemovedElements(
const AbiElementMap<const T*> &old_elements_map,
const AbiElementMap<const T*> &new_elements_map,
- const AbiElementMap<const abi_util::ElfSymbolIR *> *elf_map,
- abi_util::IRDiffDumper *ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind diff_kind,
- const AbiElementMap<const abi_util::TypeIR *> &removed_types_map) {
+ const AbiElementMap<const repr::ElfSymbolIR *> *elf_map,
+ repr::IRDiffDumper *ir_diff_dumper,
+ repr::IRDiffDumper::DiffKind diff_kind,
+ const AbiElementMap<const repr::TypeIR *> &removed_types_map) {
std::vector<const T *> removed_elements =
- abi_util::FindRemovedElements(old_elements_map, new_elements_map);
+ utils::FindRemovedElements(old_elements_map, new_elements_map);
if (!DumpLoneElements(removed_elements, elf_map, ir_diff_dumper, diff_kind,
removed_types_map)) {
llvm::errs() << "Dumping added / removed element to report failed\n";
@@ -291,12 +292,12 @@ template <typename T>
bool HeaderAbiDiff::PopulateCommonElements(
const AbiElementMap<const T *> &old_elements_map,
const AbiElementMap<const T *> &new_elements_map,
- const AbiElementMap<const abi_util::TypeIR *> &old_types,
- const AbiElementMap<const abi_util::TypeIR *> &new_types,
- abi_util::IRDiffDumper *ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind diff_kind) {
+ const AbiElementMap<const repr::TypeIR *> &old_types,
+ const AbiElementMap<const repr::TypeIR *> &new_types,
+ repr::IRDiffDumper *ir_diff_dumper,
+ repr::IRDiffDumper::DiffKind diff_kind) {
std::vector<std::pair<const T *, const T *>> common_elements =
- abi_util::FindCommonElements(old_elements_map, new_elements_map);
+ utils::FindCommonElements(old_elements_map, new_elements_map);
if (!DumpDiffElements(common_elements, old_types, new_types,
ir_diff_dumper, diff_kind)) {
llvm::errs() << "Dumping difference in common element to report failed\n";
@@ -308,17 +309,16 @@ bool HeaderAbiDiff::PopulateCommonElements(
template <typename T>
bool HeaderAbiDiff::DumpLoneElements(
std::vector<const T *> &elements,
- const AbiElementMap<const abi_util::ElfSymbolIR *> *elf_map,
- abi_util::IRDiffDumper *ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind diff_kind,
- const AbiElementMap<const abi_util::TypeIR *> &types_map) {
+ const AbiElementMap<const repr::ElfSymbolIR *> *elf_map,
+ repr::IRDiffDumper *ir_diff_dumper,
+ repr::IRDiffDumper::DiffKind diff_kind,
+ const AbiElementMap<const repr::TypeIR *> &types_map) {
// If the record / enum has source file information, skip it.
std::smatch source_file_match;
std::regex source_file_regex(" at ");
for (auto &&element : elements) {
- if (abi_diff_wrappers::IgnoreSymbol<T>(
- element, ignored_symbols_,
- [](const T *e) {return e->GetLinkerSetKey();})) {
+ if (IgnoreSymbol<T>(element, ignored_symbols_,
+ [](const T *e) {return e->GetLinkerSetKey();})) {
continue;
}
// The element does exist in the .dynsym table, we do not have meta-data
@@ -345,21 +345,20 @@ bool HeaderAbiDiff::DumpLoneElements(
template <typename T>
bool HeaderAbiDiff::DumpDiffElements(
std::vector<std::pair<const T *,const T *>> &pairs,
- const AbiElementMap<const abi_util::TypeIR *> &old_types,
- const AbiElementMap<const abi_util::TypeIR *> &new_types,
- abi_util::IRDiffDumper *ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind diff_kind) {
+ const AbiElementMap<const repr::TypeIR *> &old_types,
+ const AbiElementMap<const repr::TypeIR *> &new_types,
+ repr::IRDiffDumper *ir_diff_dumper,
+ repr::IRDiffDumper::DiffKind diff_kind) {
for (auto &&pair : pairs) {
const T *old_element = pair.first;
const T *new_element = pair.second;
- if (abi_diff_wrappers::IgnoreSymbol<T>(
- old_element, ignored_symbols_,
- [](const T *e) {return e->GetLinkerSetKey();})) {
+ if (IgnoreSymbol<T>(old_element, ignored_symbols_,
+ [](const T *e) {return e->GetLinkerSetKey();})) {
continue;
}
- abi_diff_wrappers::DiffWrapper<T> diff_wrapper(
+ DiffWrapper<T> diff_wrapper(
old_element, new_element, ir_diff_dumper, old_types, new_types,
diff_policy_options_, &type_cache_);
if (!diff_wrapper.DumpDiff(diff_kind)) {
@@ -369,3 +368,7 @@ bool HeaderAbiDiff::DumpDiffElements(
}
return true;
}
+
+
+} // namespace diff
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/diff/abi_diff.h b/vndk/tools/header-checker/src/diff/abi_diff.h
index 8e288214e..83d691828 100644
--- a/vndk/tools/header-checker/src/diff/abi_diff.h
+++ b/vndk/tools/header-checker/src/diff/abi_diff.h
@@ -22,8 +22,13 @@
#include <vector>
-using abi_util::AbiElementMap;
-using abi_util::DiffPolicyOptions;
+namespace header_checker {
+namespace diff {
+
+
+using repr::AbiElementMap;
+using repr::DiffPolicyOptions;
+
class HeaderAbiDiff {
public:
@@ -32,9 +37,9 @@ class HeaderAbiDiff {
const std::string &compatibility_report,
const std::set<std::string> &ignored_symbols,
const DiffPolicyOptions &diff_policy_options,
- bool check_all_apis, abi_util::TextFormatIR text_format_old,
- abi_util::TextFormatIR text_format_new,
- abi_util::TextFormatIR text_format_diff)
+ bool check_all_apis, repr::TextFormatIR text_format_old,
+ repr::TextFormatIR text_format_new,
+ repr::TextFormatIR text_format_diff)
: lib_name_(lib_name), arch_(arch), old_dump_(old_dump),
new_dump_(new_dump), cr_(compatibility_report),
ignored_symbols_(ignored_symbols),
@@ -43,13 +48,13 @@ class HeaderAbiDiff {
text_format_old_(text_format_old), text_format_new_(text_format_new),
text_format_diff_(text_format_diff) {}
- abi_util::CompatibilityStatusIR GenerateCompatibilityReport();
+ repr::CompatibilityStatusIR GenerateCompatibilityReport();
private:
- abi_util::CompatibilityStatusIR CompareTUs(
- const abi_util::TextFormatToIRReader *old_tu,
- const abi_util::TextFormatToIRReader *new_tu,
- abi_util::IRDiffDumper *ir_diff_dumper);
+ repr::CompatibilityStatusIR CompareTUs(
+ const repr::TextFormatToIRReader *old_tu,
+ const repr::TextFormatToIRReader *new_tu,
+ repr::IRDiffDumper *ir_diff_dumper);
template <typename T, typename ElfSymbolType>
bool CollectDynsymExportables(
@@ -57,82 +62,82 @@ class HeaderAbiDiff {
const AbiElementMap<T> &new_exportables,
const AbiElementMap<ElfSymbolType> &old_elf_symbols,
const AbiElementMap<ElfSymbolType> &new_elf_symbols,
- const AbiElementMap<const abi_util::TypeIR *> &old_types_map,
- const AbiElementMap<const abi_util::TypeIR *> &new_types_map,
- abi_util::IRDiffDumper *ir_diff_dumper);
+ const AbiElementMap<const repr::TypeIR *> &old_types_map,
+ const AbiElementMap<const repr::TypeIR *> &new_types_map,
+ repr::IRDiffDumper *ir_diff_dumper);
template <typename T>
bool Collect(
const AbiElementMap<const T *> &old_elements_map,
const AbiElementMap<const T *> &new_elements_map,
- const AbiElementMap<const abi_util::ElfSymbolIR *> *old_elf_map,
- const AbiElementMap<const abi_util::ElfSymbolIR *> *new_elf_map,
- abi_util::IRDiffDumper *ir_diff_dumper,
- const AbiElementMap<const abi_util::TypeIR *> &old_types_map,
- const AbiElementMap<const abi_util::TypeIR *> &new_types_map);
+ const AbiElementMap<const repr::ElfSymbolIR *> *old_elf_map,
+ const AbiElementMap<const repr::ElfSymbolIR *> *new_elf_map,
+ repr::IRDiffDumper *ir_diff_dumper,
+ const AbiElementMap<const repr::TypeIR *> &old_types_map,
+ const AbiElementMap<const repr::TypeIR *> &new_types_map);
bool CollectElfSymbols(
- const AbiElementMap<const abi_util::ElfSymbolIR *> &old_symbols,
- const AbiElementMap<const abi_util::ElfSymbolIR *> &new_symbols,
- abi_util::IRDiffDumper *ir_diff_dumper);
+ const AbiElementMap<const repr::ElfSymbolIR *> &old_symbols,
+ const AbiElementMap<const repr::ElfSymbolIR *> &new_symbols,
+ repr::IRDiffDumper *ir_diff_dumper);
bool PopulateElfElements(
- std::vector<const abi_util::ElfSymbolIR *> &elf_elements,
- abi_util::IRDiffDumper *ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ std::vector<const repr::ElfSymbolIR *> &elf_elements,
+ repr::IRDiffDumper *ir_diff_dumper,
+ repr::IRDiffDumper::DiffKind diff_kind);
template <typename T>
bool PopulateRemovedElements(
const AbiElementMap<const T *> &old_elements_map,
const AbiElementMap<const T *> &new_elements_map,
- const AbiElementMap<const abi_util::ElfSymbolIR *> *elf_map,
- abi_util::IRDiffDumper *ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind diff_kind,
- const AbiElementMap<const abi_util::TypeIR *> &types_map);
+ const AbiElementMap<const repr::ElfSymbolIR *> *elf_map,
+ repr::IRDiffDumper *ir_diff_dumper,
+ repr::IRDiffDumper::DiffKind diff_kind,
+ const AbiElementMap<const repr::TypeIR *> &types_map);
template <typename T>
bool PopulateCommonElements(
const AbiElementMap<const T *> &old_elements_map,
const AbiElementMap<const T *> &new_elements_map,
- const AbiElementMap<const abi_util::TypeIR *> &old_types,
- const AbiElementMap<const abi_util::TypeIR *> &new_types,
- abi_util::IRDiffDumper *ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ const AbiElementMap<const repr::TypeIR *> &old_types,
+ const AbiElementMap<const repr::TypeIR *> &new_types,
+ repr::IRDiffDumper *ir_diff_dumper,
+ repr::IRDiffDumper::DiffKind diff_kind);
template <typename T>
bool DumpDiffElements(
std::vector<std::pair<const T *, const T *>> &pairs,
- const AbiElementMap<const abi_util::TypeIR *> &old_types,
- const AbiElementMap<const abi_util::TypeIR *> &new_types,
- abi_util::IRDiffDumper *ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ const AbiElementMap<const repr::TypeIR *> &old_types,
+ const AbiElementMap<const repr::TypeIR *> &new_types,
+ repr::IRDiffDumper *ir_diff_dumper,
+ repr::IRDiffDumper::DiffKind diff_kind);
template <typename T>
bool DumpLoneElements(
std::vector<const T *> &elements,
- const AbiElementMap<const abi_util::ElfSymbolIR *> *elf_map,
- abi_util::IRDiffDumper *ir_diff_dumper,
- abi_util::IRDiffDumper::DiffKind diff_kind,
- const AbiElementMap<const abi_util::TypeIR *> &old_types_map);
+ const AbiElementMap<const repr::ElfSymbolIR *> *elf_map,
+ repr::IRDiffDumper *ir_diff_dumper,
+ repr::IRDiffDumper::DiffKind diff_kind,
+ const AbiElementMap<const repr::TypeIR *> &old_types_map);
- std::pair<AbiElementMap<const abi_util::EnumTypeIR *>,
- AbiElementMap<const abi_util::RecordTypeIR *>>
- ExtractUserDefinedTypes(const abi_util::TextFormatToIRReader *tu);
+ std::pair<AbiElementMap<const repr::EnumTypeIR *>,
+ AbiElementMap<const repr::RecordTypeIR *>>
+ ExtractUserDefinedTypes(const repr::TextFormatToIRReader *tu);
bool CollectUserDefinedTypes(
- const abi_util::TextFormatToIRReader *old_tu,
- const abi_util::TextFormatToIRReader *new_tu,
- const AbiElementMap<const abi_util::TypeIR *> &old_types_map,
- const AbiElementMap<const abi_util::TypeIR *> &new_types_map,
- abi_util::IRDiffDumper *ir_diff_dumper);
+ const repr::TextFormatToIRReader *old_tu,
+ const repr::TextFormatToIRReader *new_tu,
+ const AbiElementMap<const repr::TypeIR *> &old_types_map,
+ const AbiElementMap<const repr::TypeIR *> &new_types_map,
+ repr::IRDiffDumper *ir_diff_dumper);
template <typename T>
bool CollectUserDefinedTypesInternal(
const AbiElementMap<const T*> &old_ud_types_map,
const AbiElementMap<const T*> &new_ud_types_map,
- const AbiElementMap<const abi_util::TypeIR *> &old_types_map,
- const AbiElementMap<const abi_util::TypeIR *> &new_types_map,
- abi_util::IRDiffDumper *ir_diff_dumper);
+ const AbiElementMap<const repr::TypeIR *> &old_types_map,
+ const AbiElementMap<const repr::TypeIR *> &new_types_map,
+ repr::IRDiffDumper *ir_diff_dumper);
private:
const std::string &lib_name_;
@@ -144,9 +149,14 @@ class HeaderAbiDiff {
const DiffPolicyOptions &diff_policy_options_;
bool check_all_apis_;
std::set<std::string> type_cache_;
- abi_util::TextFormatIR text_format_old_;
- abi_util::TextFormatIR text_format_new_;
- abi_util::TextFormatIR text_format_diff_;
+ repr::TextFormatIR text_format_old_;
+ repr::TextFormatIR text_format_new_;
+ repr::TextFormatIR text_format_diff_;
};
+
+} // namespace diff
+} // namespace header_checker
+
+
#endif // ABI_DIFF_H_
diff --git a/vndk/tools/header-checker/src/diff/abi_diff_wrappers.cpp b/vndk/tools/header-checker/src/diff/abi_diff_wrappers.cpp
index 3a2ab7fb1..3722c46bd 100644
--- a/vndk/tools/header-checker/src/diff/abi_diff_wrappers.cpp
+++ b/vndk/tools/header-checker/src/diff/abi_diff_wrappers.cpp
@@ -19,15 +19,18 @@
#include <llvm/Support/raw_ostream.h>
-namespace abi_diff_wrappers {
+namespace header_checker {
+namespace diff {
+
+
+using repr::AbiElementMap;
+using repr::DiffStatus;
+using repr::Unwind;
-using abi_util::AbiElementMap;
-using abi_util::DiffStatus;
-using abi_util::Unwind;
template <>
-bool DiffWrapper<abi_util::RecordTypeIR>::DumpDiff(
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+bool DiffWrapper<repr::RecordTypeIR>::DumpDiff(
+ repr::DiffMessageIR::DiffKind diff_kind) {
std::deque<std::string> type_queue;
if (oldp_->GetUniqueId() != newp_->GetUniqueId()) {
llvm::errs() << "Comparing two different unreferenced records\n";
@@ -42,8 +45,8 @@ bool DiffWrapper<abi_util::RecordTypeIR>::DumpDiff(
}
template <>
-bool DiffWrapper<abi_util::EnumTypeIR>::DumpDiff(
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+bool DiffWrapper<repr::EnumTypeIR>::DumpDiff(
+ repr::DiffMessageIR::DiffKind diff_kind) {
std::deque<std::string> type_queue;
if (oldp_->GetUniqueId() != newp_->GetUniqueId()) {
llvm::errs() << "Comparing two different unreferenced enums\n";
@@ -58,8 +61,8 @@ bool DiffWrapper<abi_util::EnumTypeIR>::DumpDiff(
}
template <>
-bool DiffWrapper<abi_util::GlobalVarIR>::DumpDiff(
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+bool DiffWrapper<repr::GlobalVarIR>::DumpDiff(
+ repr::DiffMessageIR::DiffKind diff_kind) {
std::deque<std::string> type_queue;
type_queue.push_back(oldp_->GetName());
DiffStatus type_diff = CompareAndDumpTypeDiff(oldp_->GetReferencedType(),
@@ -68,11 +71,11 @@ bool DiffWrapper<abi_util::GlobalVarIR>::DumpDiff(
DiffStatus access_diff = (oldp_->GetAccess() == newp_->GetAccess()) ?
DiffStatus::no_diff : DiffStatus::direct_diff;
if ((type_diff | access_diff) & DiffStatus::direct_diff) {
- abi_util::GlobalVarIR old_global_var = *oldp_;
- abi_util::GlobalVarIR new_global_var = *newp_;
+ repr::GlobalVarIR old_global_var = *oldp_;
+ repr::GlobalVarIR new_global_var = *newp_;
ReplaceTypeIdsWithTypeNames(old_types_, &old_global_var);
ReplaceTypeIdsWithTypeNames(new_types_, &new_global_var);
- abi_util::GlobalVarDiffIR global_var_diff_ir(&old_global_var,
+ repr::GlobalVarDiffIR global_var_diff_ir(&old_global_var,
&new_global_var);
global_var_diff_ir.SetName(oldp_->GetName());
return ir_diff_dumper_->AddDiffMessageIR(&global_var_diff_ir,
@@ -82,8 +85,8 @@ bool DiffWrapper<abi_util::GlobalVarIR>::DumpDiff(
}
template <>
-bool DiffWrapper<abi_util::FunctionIR>::DumpDiff(
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+bool DiffWrapper<repr::FunctionIR>::DumpDiff(
+ repr::DiffMessageIR::DiffKind diff_kind) {
std::deque<std::string> type_queue;
type_queue.push_back(oldp_->GetName());
@@ -100,11 +103,11 @@ bool DiffWrapper<abi_util::FunctionIR>::DumpDiff(
if ((param_diffs == DiffStatus::direct_diff ||
return_type_diff == DiffStatus::direct_diff) ||
(oldp_->GetAccess() != newp_->GetAccess())) {
- abi_util::FunctionIR old_function = *oldp_;
- abi_util::FunctionIR new_function = *newp_;
+ repr::FunctionIR old_function = *oldp_;
+ repr::FunctionIR new_function = *newp_;
ReplaceTypeIdsWithTypeNames(old_types_, &old_function);
ReplaceTypeIdsWithTypeNames(new_types_, &new_function);
- abi_util::FunctionDiffIR function_diff_ir(&old_function, &new_function);
+ repr::FunctionDiffIR function_diff_ir(&old_function, &new_function);
function_diff_ir.SetName(oldp_->GetName());
return ir_diff_dumper_->AddDiffMessageIR(&function_diff_ir,
Unwind(&type_queue), diff_kind);
@@ -112,4 +115,6 @@ bool DiffWrapper<abi_util::FunctionIR>::DumpDiff(
return true;
}
-} // namespace abi_diff_wrappers
+
+} // namespace diff
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/diff/abi_diff_wrappers.h b/vndk/tools/header-checker/src/diff/abi_diff_wrappers.h
index f4692b5d4..baa4a5f19 100644
--- a/vndk/tools/header-checker/src/diff/abi_diff_wrappers.h
+++ b/vndk/tools/header-checker/src/diff/abi_diff_wrappers.h
@@ -19,11 +19,14 @@
#include "repr/ir_representation.h"
-namespace abi_diff_wrappers {
+namespace header_checker {
+namespace diff {
+
+
+using repr::AbiDiffHelper;
+using repr::AbiElementMap;
+using repr::DiffStatus;
-using abi_util::AbiElementMap;
-using abi_util::AbiDiffHelper;
-using abi_util::DiffStatus;
template <typename T, typename F>
static bool IgnoreSymbol(const T *element,
@@ -36,22 +39,25 @@ template <typename T>
class DiffWrapper : public AbiDiffHelper {
public:
DiffWrapper(const T *oldp, const T *newp,
- abi_util::IRDiffDumper *ir_diff_dumper,
- const AbiElementMap<const abi_util::TypeIR *> &old_types,
- const AbiElementMap<const abi_util::TypeIR *> &new_types,
- const abi_util::DiffPolicyOptions &diff_policy_options,
+ repr::IRDiffDumper *ir_diff_dumper,
+ const AbiElementMap<const repr::TypeIR *> &old_types,
+ const AbiElementMap<const repr::TypeIR *> &new_types,
+ const repr::DiffPolicyOptions &diff_policy_options,
std::set<std::string> *type_cache)
: AbiDiffHelper(old_types, new_types, diff_policy_options, type_cache,
ir_diff_dumper),
oldp_(oldp), newp_(newp) {}
- bool DumpDiff(abi_util::IRDiffDumper::DiffKind diff_kind);
+ bool DumpDiff(repr::IRDiffDumper::DiffKind diff_kind);
private:
const T *oldp_;
const T *newp_;
};
-} // namespace abi_diff_wrappers
+
+} // namespace diff
+} // namespace header_checker
+
#endif // ABI_DIFF_WRAPPERS_H_
diff --git a/vndk/tools/header-checker/src/diff/header_abi_diff.cpp b/vndk/tools/header-checker/src/diff/header_abi_diff.cpp
index 5f2733c8d..ac13b535f 100644
--- a/vndk/tools/header-checker/src/diff/header_abi_diff.cpp
+++ b/vndk/tools/header-checker/src/diff/header_abi_diff.cpp
@@ -21,6 +21,12 @@
#include <fstream>
+using header_checker::diff::HeaderAbiDiff;
+using header_checker::repr::CompatibilityStatusIR;
+using header_checker::repr::DiffPolicyOptions;
+using header_checker::repr::TextFormatIR;
+
+
static llvm::cl::OptionCategory header_checker_category(
"header-abi-diff options");
@@ -92,27 +98,27 @@ static llvm::cl::opt<bool> consider_opaque_types_different(
"This should not be used while comparing C++ library ABIs"),
llvm::cl::Optional, llvm::cl::cat(header_checker_category));
-static llvm::cl::opt<abi_util::TextFormatIR> text_format_old(
+static llvm::cl::opt<TextFormatIR> text_format_old(
"input-format-old", llvm::cl::desc("Specify input format of old abi dump"),
- llvm::cl::values(clEnumValN(abi_util::TextFormatIR::ProtobufTextFormat,
+ llvm::cl::values(clEnumValN(TextFormatIR::ProtobufTextFormat,
"ProtobufTextFormat", "ProtobufTextFormat"),
- clEnumValN(abi_util::TextFormatIR::Json, "Json", "JSON")),
- llvm::cl::init(abi_util::TextFormatIR::Json),
+ clEnumValN(TextFormatIR::Json, "Json", "JSON")),
+ llvm::cl::init(TextFormatIR::Json),
llvm::cl::cat(header_checker_category));
-static llvm::cl::opt<abi_util::TextFormatIR> text_format_new(
+static llvm::cl::opt<TextFormatIR> text_format_new(
"input-format-new", llvm::cl::desc("Specify input format of new abi dump"),
- llvm::cl::values(clEnumValN(abi_util::TextFormatIR::ProtobufTextFormat,
+ llvm::cl::values(clEnumValN(TextFormatIR::ProtobufTextFormat,
"ProtobufTextFormat", "ProtobufTextFormat"),
- clEnumValN(abi_util::TextFormatIR::Json, "Json", "JSON")),
- llvm::cl::init(abi_util::TextFormatIR::Json),
+ clEnumValN(TextFormatIR::Json, "Json", "JSON")),
+ llvm::cl::init(TextFormatIR::Json),
llvm::cl::cat(header_checker_category));
-static llvm::cl::opt<abi_util::TextFormatIR> text_format_diff(
+static llvm::cl::opt<TextFormatIR> text_format_diff(
"text-format-diff", llvm::cl::desc("Specify text format of abi-diff"),
- llvm::cl::values(clEnumValN(abi_util::TextFormatIR::ProtobufTextFormat,
+ llvm::cl::values(clEnumValN(TextFormatIR::ProtobufTextFormat,
"ProtobufTextFormat", "ProtobufTextFormat")),
- llvm::cl::init(abi_util::TextFormatIR::ProtobufTextFormat),
+ llvm::cl::init(TextFormatIR::ProtobufTextFormat),
llvm::cl::cat(header_checker_category));
static std::set<std::string> LoadIgnoredSymbols(std::string &symbol_list_path) {
@@ -132,14 +138,14 @@ static std::set<std::string> 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) {
+bool ShouldEmitWarningMessage(CompatibilityStatusIR status) {
return ((!allow_extensions &&
- (status & abi_util::CompatibilityStatusIR::Extension)) ||
+ (status & CompatibilityStatusIR::Extension)) ||
(!allow_unreferenced_changes &&
- (status & abi_util::CompatibilityStatusIR::UnreferencedChanges)) ||
+ (status & CompatibilityStatusIR::UnreferencedChanges)) ||
(!allow_unreferenced_elf_symbol_changes &&
- (status & abi_util::CompatibilityStatusIR::ElfIncompatible)) ||
- (status & abi_util::CompatibilityStatusIR::Incompatible));
+ (status & CompatibilityStatusIR::ElfIncompatible)) ||
+ (status & CompatibilityStatusIR::Incompatible));
}
int main(int argc, const char **argv) {
@@ -148,24 +154,24 @@ int main(int argc, const char **argv) {
if (llvm::sys::fs::exists(ignore_symbol_list)) {
ignored_symbols = LoadIgnoredSymbols(ignore_symbol_list);
}
- abi_util::DiffPolicyOptions diff_policy_options(
+ DiffPolicyOptions diff_policy_options(
consider_opaque_types_different);
HeaderAbiDiff judge(lib_name, arch, old_dump, new_dump, compatibility_report,
ignored_symbols, diff_policy_options, check_all_apis,
text_format_old, text_format_new, text_format_diff);
- abi_util::CompatibilityStatusIR status = judge.GenerateCompatibilityReport();
+ CompatibilityStatusIR status = judge.GenerateCompatibilityReport();
std::string status_str = "";
std::string unreferenced_change_str = "";
std::string error_or_warning_str = kWarn;
switch (status) {
- case abi_util::CompatibilityStatusIR::Incompatible:
+ case CompatibilityStatusIR::Incompatible:
error_or_warning_str = kError;
status_str = "INCOMPATIBLE CHANGES";
break;
- case abi_util::CompatibilityStatusIR::ElfIncompatible:
+ case CompatibilityStatusIR::ElfIncompatible:
if (elf_unreferenced_symbol_errors) {
error_or_warning_str = kError;
}
@@ -174,13 +180,13 @@ int main(int argc, const char **argv) {
default:
break;
}
- if (status & abi_util::CompatibilityStatusIR::Extension) {
+ if (status & CompatibilityStatusIR::Extension) {
if (!allow_extensions) {
error_or_warning_str = kError;
}
status_str = "EXTENDING CHANGES";
}
- if (status & abi_util::CompatibilityStatusIR::UnreferencedChanges) {
+ if (status & CompatibilityStatusIR::UnreferencedChanges) {
unreferenced_change_str = ", changes in exported headers, which are";
unreferenced_change_str += " not directly referenced by exported symbols.";
unreferenced_change_str += " This MIGHT be an ABI breaking change due to";
@@ -206,5 +212,5 @@ int main(int argc, const char **argv) {
return status;
}
- return abi_util::CompatibilityStatusIR::Compatible;
+ return CompatibilityStatusIR::Compatible;
}
diff --git a/vndk/tools/header-checker/src/diff_merge/merge_abi_diff.cpp b/vndk/tools/header-checker/src/diff_merge/merge_abi_diff.cpp
index 8aa1a6056..52ab971fa 100644
--- a/vndk/tools/header-checker/src/diff_merge/merge_abi_diff.cpp
+++ b/vndk/tools/header-checker/src/diff_merge/merge_abi_diff.cpp
@@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "utils/header_abi_util.h"
-
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wnested-anon-types"
@@ -36,39 +34,38 @@
#include <stdlib.h>
-static llvm::cl::OptionCategory merge_abi_diff_category(
+static llvm::cl::OptionCategory merge_diff_category(
"merge-abi-diff options");
static llvm::cl::list<std::string> diff_report_list(
llvm::cl::Positional, llvm::cl::desc("<diff-reports>"), llvm::cl::Required,
- llvm::cl::cat(merge_abi_diff_category), llvm::cl::OneOrMore);
+ llvm::cl::cat(merge_diff_category), llvm::cl::OneOrMore);
static llvm::cl::opt<std::string> merged_diff_report(
"o", llvm::cl::desc("<merged-diff-report>"), llvm::cl::Required,
- llvm::cl::cat(merge_abi_diff_category));
+ llvm::cl::cat(merge_diff_category));
static llvm::cl::opt<bool> advice_only(
"advice-only", llvm::cl::desc("Advisory mode only"), llvm::cl::Optional,
- llvm::cl::cat(merge_abi_diff_category));
+ llvm::cl::cat(merge_diff_category));
static llvm::cl::opt<bool> do_not_break_on_extensions(
"allow-extensions",
llvm::cl::desc("Do not return a non zero status on extensions"),
- llvm::cl::Optional, llvm::cl::cat(merge_abi_diff_category));
-
-typedef abi_diff::CompatibilityStatus CompatibilityStatus;
+ llvm::cl::Optional, llvm::cl::cat(merge_diff_category));
-static bool IsStatusDowngraded(const CompatibilityStatus &old_status,
- const CompatibilityStatus &new_status) {
+static bool IsStatusDowngraded(
+ const abi_diff::CompatibilityStatus &old_status,
+ const abi_diff::CompatibilityStatus &new_status) {
bool status_downgraded = false;
switch (old_status) {
- case CompatibilityStatus::EXTENSION:
- if (new_status == CompatibilityStatus::INCOMPATIBLE) {
+ case abi_diff::CompatibilityStatus::EXTENSION:
+ if (new_status == abi_diff::CompatibilityStatus::INCOMPATIBLE) {
status_downgraded = true;
}
break;
- case CompatibilityStatus::COMPATIBLE:
- if (new_status != CompatibilityStatus::COMPATIBLE) {
+ case abi_diff::CompatibilityStatus::COMPATIBLE:
+ if (new_status != abi_diff::CompatibilityStatus::COMPATIBLE) {
status_downgraded = true;
}
break;
@@ -78,14 +75,14 @@ static bool IsStatusDowngraded(const CompatibilityStatus &old_status,
return status_downgraded;
}
-static CompatibilityStatus MergeDiffReports(
+static abi_diff::CompatibilityStatus MergeDiffReports(
const std::vector<std::string> &diff_reports,
const std::string &merged_diff_report) {
-
abi_diff::MergedTranslationUnitDiff merged_tu_diff;
std::ofstream text_output(merged_diff_report);
google::protobuf::io::OstreamOutputStream text_os(&text_output);
- CompatibilityStatus status = CompatibilityStatus::COMPATIBLE;
+ abi_diff::CompatibilityStatus status =
+ abi_diff::CompatibilityStatus::COMPATIBLE;
for (auto &&i : diff_reports) {
abi_diff::TranslationUnitDiff diff_tu;
@@ -101,7 +98,7 @@ static CompatibilityStatus MergeDiffReports(
llvm::errs() << "Failed to add diff report to merged report\n";
::exit(1);
}
- CompatibilityStatus new_status = diff_tu.compatibility_status();
+ abi_diff::CompatibilityStatus new_status = diff_tu.compatibility_status();
added_tu_diff->set_lib_name(diff_tu.lib_name());
added_tu_diff->set_arch(diff_tu.arch());
added_tu_diff->set_diff_report_path(i);
@@ -122,14 +119,14 @@ static CompatibilityStatus MergeDiffReports(
int main(int argc, const char **argv) {
GOOGLE_PROTOBUF_VERIFY_VERSION;
llvm::cl::ParseCommandLineOptions(argc, argv, "merge-abi-diff");
- CompatibilityStatus extension_or_incompatible =
+ abi_diff::CompatibilityStatus extension_or_incompatible =
MergeDiffReports(diff_report_list, merged_diff_report);
std::string status_str = "";
switch (extension_or_incompatible) {
- case CompatibilityStatus::INCOMPATIBLE:
+ case abi_diff::CompatibilityStatus::INCOMPATIBLE:
status_str = "broken";
break;
- case CompatibilityStatus::EXTENSION:
+ case abi_diff::CompatibilityStatus::EXTENSION:
status_str = "extended";
break;
default:
@@ -146,12 +143,12 @@ int main(int argc, const char **argv) {
}
if (do_not_break_on_extensions &&
- extension_or_incompatible == CompatibilityStatus::EXTENSION) {
- extension_or_incompatible = CompatibilityStatus::COMPATIBLE;
+ extension_or_incompatible == abi_diff::CompatibilityStatus::EXTENSION) {
+ extension_or_incompatible = abi_diff::CompatibilityStatus::COMPATIBLE;
}
if (!advice_only) {
return extension_or_incompatible;
}
- return CompatibilityStatus::COMPATIBLE;
+ return abi_diff::CompatibilityStatus::COMPATIBLE;
}
diff --git a/vndk/tools/header-checker/src/dumper/abi_wrappers.cpp b/vndk/tools/header-checker/src/dumper/abi_wrappers.cpp
index 005a957c2..efd835148 100644
--- a/vndk/tools/header-checker/src/dumper/abi_wrappers.cpp
+++ b/vndk/tools/header-checker/src/dumper/abi_wrappers.cpp
@@ -26,14 +26,16 @@
#include <stdlib.h>
-using namespace abi_wrapper;
+namespace header_checker {
+namespace dumper {
+
ABIWrapper::ABIWrapper(
clang::MangleContext *mangle_contextp,
clang::ASTContext *ast_contextp,
const clang::CompilerInstance *cip,
- abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches)
+ repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches)
: cip_(cip),
mangle_contextp_(mangle_contextp),
ast_contextp_(ast_contextp),
@@ -150,22 +152,22 @@ std::string ABIWrapper::GetDeclSourceFile(const clang::Decl *decl,
// belonging to the library.
clang::SourceLocation expansion_location = sm.getExpansionLoc(location);
llvm::StringRef file_name = sm.getFilename(expansion_location);
- return abi_util::RealPath(file_name.str());
+ return utils::RealPath(file_name.str());
}
-static abi_util::AccessSpecifierIR AccessClangToIR(
+static repr::AccessSpecifierIR AccessClangToIR(
const clang::AccessSpecifier sp) {
switch (sp) {
case clang::AS_private: {
- return abi_util::AccessSpecifierIR::PrivateAccess;
+ return repr::AccessSpecifierIR::PrivateAccess;
break;
}
case clang::AS_protected: {
- return abi_util::AccessSpecifierIR::ProtectedAccess;
+ return repr::AccessSpecifierIR::ProtectedAccess;
break;
}
default: {
- return abi_util::AccessSpecifierIR::PublicAccess;
+ return repr::AccessSpecifierIR::PublicAccess;
break;
}
}
@@ -198,7 +200,7 @@ static clang::QualType GetReferencedType(const clang::QualType qual_type) {
}
bool ABIWrapper::CreateExtendedType(clang::QualType qual_type,
- abi_util::TypeIR *typep) {
+ repr::TypeIR *typep) {
const clang::QualType canonical_type = qual_type.getCanonicalType();
// The source file is going to be set later anyway.
return CreateBasicNamedAndTypedDecl(canonical_type, typep, "");
@@ -224,7 +226,7 @@ bool ABIWrapper::CreateBasicNamedAndTypedDecl(clang::QualType qual_type,
// extending Type and return a pointer to that and pass it to CreateBasic...
// CreateBasic...(qualtype, Type *) fills in size, alignemnt etc.
auto type_and_status = SetTypeKind(canonical_type, source_file);
- std::unique_ptr<abi_util::TypeIR> typep = std::move(type_and_status.typep_);
+ std::unique_ptr<repr::TypeIR> typep = std::move(type_and_status.typep_);
if (!base_type->isVoidType() && type_and_status.should_create_type_ &&
!typep) {
llvm::errs() << "nullptr with valid type while creating basic type\n";
@@ -267,7 +269,7 @@ std::string ABIWrapper::GetTypeUniqueId(const clang::TagDecl *tag_decl) {
// include all the generic information of a basic type. Other methods will
// create more specific information, e.g. RecordDecl, EnumDecl.
bool ABIWrapper::CreateBasicNamedAndTypedDecl(
- clang::QualType canonical_type, abi_util::TypeIR *typep,
+ clang::QualType canonical_type, repr::TypeIR *typep,
const std::string &source_file) {
// Cannot determine the size and alignment for template parameter dependent
// types as well as incomplete types.
@@ -313,7 +315,7 @@ TypeAndCreationStatus ABIWrapper::SetTypeKind(
const clang::QualType canonical_type, const std::string &source_file) {
if (canonical_type.hasLocalQualifiers()) {
auto qual_type_ir =
- std::make_unique<abi_util::QualifiedTypeIR>();
+ std::make_unique<repr::QualifiedTypeIR>();
qual_type_ir->SetConstness(canonical_type.isConstQualified());
qual_type_ir->SetRestrictedness(canonical_type.isRestrictQualified());
qual_type_ir->SetVolatility(canonical_type.isVolatileQualified());
@@ -322,32 +324,32 @@ TypeAndCreationStatus ABIWrapper::SetTypeKind(
}
const clang::Type *type_ptr = canonical_type.getTypePtr();
if (type_ptr->isPointerType()) {
- auto pointer_type_ir = std::make_unique<abi_util::PointerTypeIR>();
+ auto pointer_type_ir = std::make_unique<repr::PointerTypeIR>();
pointer_type_ir->SetSourceFile(source_file);
return TypeAndCreationStatus(std::move(pointer_type_ir));
}
if (type_ptr->isLValueReferenceType()) {
auto lvalue_reference_type_ir =
- std::make_unique<abi_util::LvalueReferenceTypeIR>();
+ std::make_unique<repr::LvalueReferenceTypeIR>();
lvalue_reference_type_ir->SetSourceFile(source_file);
return TypeAndCreationStatus(std::move(lvalue_reference_type_ir));
}
if (type_ptr->isRValueReferenceType()) {
auto rvalue_reference_type_ir =
- std::make_unique<abi_util::RvalueReferenceTypeIR>();
+ std::make_unique<repr::RvalueReferenceTypeIR>();
rvalue_reference_type_ir->SetSourceFile(source_file);
return TypeAndCreationStatus(std::move(rvalue_reference_type_ir));
}
if (type_ptr->isArrayType()) {
- auto array_type_ir = std::make_unique<abi_util::ArrayTypeIR>();
+ auto array_type_ir = std::make_unique<repr::ArrayTypeIR>();
array_type_ir->SetSourceFile(source_file);
return TypeAndCreationStatus(std::move(array_type_ir));
}
if (type_ptr->isEnumeralType()) {
- return TypeAndCreationStatus(std::make_unique<abi_util::EnumTypeIR>());
+ return TypeAndCreationStatus(std::make_unique<repr::EnumTypeIR>());
}
if (type_ptr->isBuiltinType()) {
- auto builtin_type_ir = std::make_unique<abi_util::BuiltinTypeIR>();
+ auto builtin_type_ir = std::make_unique<repr::BuiltinTypeIR>();
builtin_type_ir->SetSignedness(type_ptr->isUnsignedIntegerType());
builtin_type_ir->SetIntegralType(type_ptr->isIntegralType(*ast_contextp_));
return TypeAndCreationStatus(std::move(builtin_type_ir));
@@ -397,9 +399,9 @@ std::string ABIWrapper::GetTagDeclQualifiedName(const clang::TagDecl *decl) {
}
bool ABIWrapper::SetupTemplateArguments(const clang::TemplateArgumentList *tl,
- abi_util::TemplatedArtifactIR *ta,
+ repr::TemplatedArtifactIR *ta,
const std::string &source_file) {
- abi_util::TemplateInfoIR template_info;
+ repr::TemplateInfoIR template_info;
for (int i = 0; i < tl->size(); i++) {
const clang::TemplateArgument &arg = (*tl)[i];
// TODO: More comprehensive checking needed.
@@ -408,7 +410,7 @@ bool ABIWrapper::SetupTemplateArguments(const clang::TemplateArgumentList *tl,
}
clang::QualType type = arg.getAsType();
template_info.AddTemplateElement(
- abi_util::TemplateElementIR(
+ repr::TemplateElementIR(
ast_caches_->GetTypeId(GetKeyForTypeId(type))));
if (!CreateBasicNamedAndTypedDecl(type, source_file)) {
llvm::errs() << "Setting up template arguments failed\n";
@@ -433,15 +435,15 @@ std::string ABIWrapper::QualTypeToString(const clang::QualType &sweet_qt) {
FunctionTypeWrapper::FunctionTypeWrapper(
clang::MangleContext *mangle_contextp, clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
- const clang::FunctionType *function_type, abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches, const std::string &source_file)
+ const clang::FunctionType *function_type, repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches, const std::string &source_file)
: ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper,
ast_caches),
function_type_(function_type),
source_file_(source_file) {}
bool FunctionTypeWrapper::SetupFunctionType(
- abi_util::FunctionTypeIR *function_type_ir) {
+ repr::FunctionTypeIR *function_type_ir) {
// Add ReturnType
function_type_ir->SetReturnType(
ast_caches_->GetTypeId(GetKeyForTypeId(function_type_->getReturnType())));
@@ -462,7 +464,7 @@ bool FunctionTypeWrapper::SetupFunctionType(
}
bool FunctionTypeWrapper::GetFunctionType() {
- auto abi_decl = std::make_unique<abi_util::FunctionTypeIR>();
+ auto abi_decl = std::make_unique<repr::FunctionTypeIR>();
clang::QualType canonical_type = function_type_->getCanonicalTypeInternal();
if (!CreateBasicNamedAndTypedDecl(canonical_type, abi_decl.get(), "")) {
llvm::errs() << "Couldn't create (function type) extended type\n";
@@ -477,13 +479,13 @@ FunctionDeclWrapper::FunctionDeclWrapper(
clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
const clang::FunctionDecl *decl,
- abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches)
+ repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches)
: ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper,
ast_caches),
function_decl_(decl) {}
-bool FunctionDeclWrapper::SetupThisParameter(abi_util::FunctionIR *functionp,
+bool FunctionDeclWrapper::SetupThisParameter(repr::FunctionIR *functionp,
const std::string &source_file) {
const clang::CXXMethodDecl *cxx_method_decl =
llvm::dyn_cast<clang::CXXMethodDecl>(function_decl_);
@@ -496,20 +498,20 @@ bool FunctionDeclWrapper::SetupThisParameter(abi_util::FunctionIR *functionp,
}
bool ABIWrapper::SetupFunctionParameter(
- abi_util::CFunctionLikeIR *functionp, const clang::QualType qual_type,
+ repr::CFunctionLikeIR *functionp, const clang::QualType qual_type,
bool has_default_arg, const std::string &source_file, bool is_this_ptr) {
if (!CreateBasicNamedAndTypedDecl(qual_type, source_file)) {
llvm::errs() << "Setting up function parameter failed\n";
return false;
}
- functionp->AddParameter(abi_util::ParamIR(
+ functionp->AddParameter(repr::ParamIR(
ast_caches_->GetTypeId(GetKeyForTypeId(qual_type)), has_default_arg,
is_this_ptr));
return true;
}
bool FunctionDeclWrapper::SetupFunctionParameters(
- abi_util::FunctionIR *functionp,
+ repr::FunctionIR *functionp,
const std::string &source_file) {
clang::FunctionDecl::param_const_iterator param_it =
function_decl_->param_begin();
@@ -532,7 +534,7 @@ bool FunctionDeclWrapper::SetupFunctionParameters(
return true;
}
-bool FunctionDeclWrapper::SetupFunction(abi_util::FunctionIR *functionp,
+bool FunctionDeclWrapper::SetupFunction(repr::FunctionIR *functionp,
const std::string &source_file) {
// Go through all the parameters in the method and add them to the fields.
// Also get the fully qualfied name.
@@ -549,7 +551,7 @@ bool FunctionDeclWrapper::SetupFunction(abi_util::FunctionIR *functionp,
SetupTemplateInfo(functionp, source_file);
}
-bool FunctionDeclWrapper::SetupTemplateInfo(abi_util::FunctionIR *functionp,
+bool FunctionDeclWrapper::SetupTemplateInfo(repr::FunctionIR *functionp,
const std::string &source_file) {
switch (function_decl_->getTemplatedKind()) {
case clang::FunctionDecl::TK_FunctionTemplateSpecialization: {
@@ -568,8 +570,8 @@ bool FunctionDeclWrapper::SetupTemplateInfo(abi_util::FunctionIR *functionp,
return true;
}
-std::unique_ptr<abi_util::FunctionIR> FunctionDeclWrapper::GetFunctionDecl() {
- auto abi_decl = std::make_unique<abi_util::FunctionIR>();
+std::unique_ptr<repr::FunctionIR> FunctionDeclWrapper::GetFunctionDecl() {
+ auto abi_decl = std::make_unique<repr::FunctionIR>();
std::string source_file = GetCachedDeclSourceFile(function_decl_, cip_);
if (!SetupFunction(abi_decl.get(), source_file)) {
return nullptr;
@@ -581,13 +583,13 @@ RecordDeclWrapper::RecordDeclWrapper(
clang::MangleContext *mangle_contextp,
clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
- const clang::RecordDecl *decl, abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches)
+ const clang::RecordDecl *decl, repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches)
: ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper,
ast_caches),
record_decl_(decl) {}
-bool RecordDeclWrapper::SetupRecordFields(abi_util::RecordTypeIR *recordp,
+bool RecordDeclWrapper::SetupRecordFields(repr::RecordTypeIR *recordp,
const std::string &source_file) {
clang::RecordDecl::field_iterator field = record_decl_->field_begin();
uint32_t field_index = 0;
@@ -607,7 +609,7 @@ bool RecordDeclWrapper::SetupRecordFields(abi_util::RecordTypeIR *recordp,
}
std::string field_name = field->getName();
uint64_t field_offset = record_layout.getFieldOffset(field_index);
- recordp->AddRecordField(abi_util::RecordFieldIR(
+ recordp->AddRecordField(repr::RecordFieldIR(
field_name, ast_caches_->GetTypeId(key_for_type_id), field_offset,
AccessClangToIR(field->getAccess())));
field++;
@@ -617,7 +619,7 @@ bool RecordDeclWrapper::SetupRecordFields(abi_util::RecordTypeIR *recordp,
}
bool RecordDeclWrapper::SetupCXXBases(
- abi_util::RecordTypeIR *cxxp, const clang::CXXRecordDecl *cxx_record_decl) {
+ repr::RecordTypeIR *cxxp, const clang::CXXRecordDecl *cxx_record_decl) {
if (!cxx_record_decl || !cxxp) {
return false;
}
@@ -626,10 +628,10 @@ bool RecordDeclWrapper::SetupCXXBases(
while (base_class != cxx_record_decl->bases_end()) {
std::string name = QualTypeToString(base_class->getType());
bool is_virtual = base_class->isVirtual();
- abi_util::AccessSpecifierIR access =
+ repr::AccessSpecifierIR access =
AccessClangToIR(base_class->getAccessSpecifier());
cxxp->AddCXXBaseSpecifier(
- abi_util::CXXBaseSpecifierIR(
+ repr::CXXBaseSpecifierIR(
ast_caches_->GetTypeId(GetKeyForTypeId(base_class->getType())),
is_virtual, access));
base_class++;
@@ -640,7 +642,7 @@ bool RecordDeclWrapper::SetupCXXBases(
typedef std::map<uint64_t, clang::ThunkInfo> ThunkMap;
bool RecordDeclWrapper::SetupRecordVTable(
- abi_util::RecordTypeIR *record_declp,
+ repr::RecordTypeIR *record_declp,
const clang::CXXRecordDecl *cxx_record_decl) {
if (!cxx_record_decl || !record_declp) {
return false;
@@ -663,7 +665,7 @@ bool RecordDeclWrapper::SetupRecordVTable(
llvm::ArrayRef<clang::VTableLayout::VTableThunkTy> thunks =
vtable_layout.vtable_thunks();
ThunkMap thunk_map(thunks.begin(), thunks.end());
- abi_util::VTableLayoutIR vtable_ir_layout;
+ repr::VTableLayoutIR vtable_ir_layout;
uint64_t index = 0;
for (auto vtable_component : vtable_layout.vtable_components()) {
@@ -672,7 +674,7 @@ bool RecordDeclWrapper::SetupRecordVTable(
if (it != thunk_map.end()) {
thunk_info = it->second;
}
- abi_util::VTableComponentIR added_component =
+ repr::VTableComponentIR added_component =
SetupRecordVTableComponent(vtable_component, thunk_info);
vtable_ir_layout.AddVTableComponent(std::move(added_component));
index++;
@@ -681,11 +683,11 @@ bool RecordDeclWrapper::SetupRecordVTable(
return true;
}
-abi_util::VTableComponentIR RecordDeclWrapper::SetupRecordVTableComponent(
+repr::VTableComponentIR RecordDeclWrapper::SetupRecordVTableComponent(
const clang::VTableComponent &vtable_component,
const clang::ThunkInfo &thunk_info) {
- abi_util::VTableComponentIR::Kind kind =
- abi_util::VTableComponentIR::Kind::RTTI;
+ repr::VTableComponentIR::Kind kind =
+ repr::VTableComponentIR::Kind::RTTI;
std::string mangled_component_name = "";
llvm::raw_string_ostream ostream(mangled_component_name);
int64_t value = 0;
@@ -695,20 +697,20 @@ abi_util::VTableComponentIR RecordDeclWrapper::SetupRecordVTableComponent(
switch (clang_component_kind) {
case clang::VTableComponent::CK_VCallOffset:
- kind = abi_util::VTableComponentIR::Kind::VCallOffset;
+ kind = repr::VTableComponentIR::Kind::VCallOffset;
value = vtable_component.getVCallOffset().getQuantity();
break;
case clang::VTableComponent::CK_VBaseOffset:
- kind = abi_util::VTableComponentIR::Kind::VBaseOffset;
+ kind = repr::VTableComponentIR::Kind::VBaseOffset;
value = vtable_component.getVBaseOffset().getQuantity();
break;
case clang::VTableComponent::CK_OffsetToTop:
- kind = abi_util::VTableComponentIR::Kind::OffsetToTop;
+ kind = repr::VTableComponentIR::Kind::OffsetToTop;
value = vtable_component.getOffsetToTop().getQuantity();
break;
case clang::VTableComponent::CK_RTTI:
{
- kind = abi_util::VTableComponentIR::Kind::RTTI;
+ kind = repr::VTableComponentIR::Kind::RTTI;
const clang::CXXRecordDecl *rtti_decl =
vtable_component.getRTTIDecl();
assert(rtti_decl != nullptr);
@@ -726,7 +728,7 @@ abi_util::VTableComponentIR RecordDeclWrapper::SetupRecordVTableComponent(
is_pure = method_decl->isPure();
switch (clang_component_kind) {
case clang::VTableComponent::CK_FunctionPointer:
- kind = abi_util::VTableComponentIR::Kind::FunctionPointer;
+ kind = repr::VTableComponentIR::Kind::FunctionPointer;
if (thunk_info.isEmpty()) {
mangle_contextp_->mangleName(method_decl, ostream);
} else {
@@ -741,10 +743,10 @@ abi_util::VTableComponentIR RecordDeclWrapper::SetupRecordVTableComponent(
if (clang_component_kind ==
clang::VTableComponent::CK_CompleteDtorPointer) {
dtor_type = clang::CXXDtorType::Dtor_Complete;
- kind = abi_util::VTableComponentIR::Kind::CompleteDtorPointer;
+ kind = repr::VTableComponentIR::Kind::CompleteDtorPointer;
} else {
dtor_type = clang::CXXDtorType::Dtor_Deleting;
- kind = abi_util::VTableComponentIR::Kind::DeletingDtorPointer;
+ kind = repr::VTableComponentIR::Kind::DeletingDtorPointer;
}
if (thunk_info.isEmpty()) {
@@ -759,7 +761,7 @@ abi_util::VTableComponentIR RecordDeclWrapper::SetupRecordVTableComponent(
}
break;
case clang::VTableComponent::CK_UnusedFunctionPointer:
- kind = abi_util::VTableComponentIR::Kind::UnusedFunctionPointer;
+ kind = repr::VTableComponentIR::Kind::UnusedFunctionPointer;
break;
default:
break;
@@ -769,12 +771,12 @@ abi_util::VTableComponentIR RecordDeclWrapper::SetupRecordVTableComponent(
default:
break;
}
- return abi_util::VTableComponentIR(mangled_component_name, kind, value,
+ return repr::VTableComponentIR(mangled_component_name, kind, value,
is_pure);
}
bool RecordDeclWrapper::SetupTemplateInfo(
- abi_util::RecordTypeIR *record_declp,
+ repr::RecordTypeIR *record_declp,
const clang::CXXRecordDecl *cxx_record_decl,
const std::string &source_file) {
assert(cxx_record_decl != nullptr);
@@ -791,20 +793,20 @@ bool RecordDeclWrapper::SetupTemplateInfo(
return true;
}
-bool RecordDeclWrapper::SetupRecordInfo(abi_util::RecordTypeIR *record_declp,
+bool RecordDeclWrapper::SetupRecordInfo(repr::RecordTypeIR *record_declp,
const std::string &source_file) {
if (!record_declp) {
return false;
}
if (record_decl_->isStruct()) {
record_declp->SetRecordKind(
- abi_util::RecordTypeIR::RecordKind::struct_kind);
+ repr::RecordTypeIR::RecordKind::struct_kind);
} else if (record_decl_->isClass()) {
record_declp->SetRecordKind(
- abi_util::RecordTypeIR::RecordKind::class_kind);
+ repr::RecordTypeIR::RecordKind::class_kind);
} else {
record_declp->SetRecordKind(
- abi_util::RecordTypeIR::RecordKind::union_kind);
+ repr::RecordTypeIR::RecordKind::union_kind);
}
const clang::Type *basic_type = nullptr;
@@ -826,7 +828,7 @@ bool RecordDeclWrapper::SetupRecordInfo(abi_util::RecordTypeIR *record_declp,
SetupCXXRecordInfo(record_declp, source_file);
}
-bool RecordDeclWrapper::SetupCXXRecordInfo(abi_util::RecordTypeIR *record_declp,
+bool RecordDeclWrapper::SetupCXXRecordInfo(repr::RecordTypeIR *record_declp,
const std::string &source_file) {
const clang::CXXRecordDecl *cxx_record_decl =
clang::dyn_cast<clang::CXXRecordDecl>(record_decl_);
@@ -840,7 +842,7 @@ bool RecordDeclWrapper::SetupCXXRecordInfo(abi_util::RecordTypeIR *record_declp,
// TODO: Can we use clang's ODR hash to do faster ODR checking?
bool RecordDeclWrapper::GetRecordDecl() {
- auto abi_decl = std::make_unique<abi_util::RecordTypeIR>();
+ auto abi_decl = std::make_unique<repr::RecordTypeIR>();
std::string source_file = GetCachedDeclSourceFile(record_decl_, cip_);
if (!SetupRecordInfo(abi_decl.get(), source_file)) {
llvm::errs() << "Setting up CXX Bases / Template Info failed\n";
@@ -859,13 +861,13 @@ EnumDeclWrapper::EnumDeclWrapper(
clang::MangleContext *mangle_contextp,
clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
- const clang::EnumDecl *decl, abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches)
+ const clang::EnumDecl *decl, repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches)
: ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper,
ast_caches),
enum_decl_(decl) {}
-bool EnumDeclWrapper::SetupEnumFields(abi_util::EnumTypeIR *enump) {
+bool EnumDeclWrapper::SetupEnumFields(repr::EnumTypeIR *enump) {
if (!enump) {
return false;
}
@@ -873,13 +875,13 @@ bool EnumDeclWrapper::SetupEnumFields(abi_util::EnumTypeIR *enump) {
while (enum_it != enum_decl_->enumerator_end()) {
std::string name = enum_it->getQualifiedNameAsString();
uint64_t field_value = enum_it->getInitVal().getExtValue();
- enump->AddEnumField(abi_util::EnumFieldIR(name, field_value));
+ enump->AddEnumField(repr::EnumFieldIR(name, field_value));
enum_it++;
}
return true;
}
-bool EnumDeclWrapper::SetupEnum(abi_util::EnumTypeIR *enum_type,
+bool EnumDeclWrapper::SetupEnum(repr::EnumTypeIR *enum_type,
const std::string &source_file) {
std::string enum_name = GetTagDeclQualifiedName(enum_decl_);
clang::QualType enum_qual_type =
@@ -897,7 +899,7 @@ bool EnumDeclWrapper::SetupEnum(abi_util::EnumTypeIR *enum_type,
}
bool EnumDeclWrapper::GetEnumDecl() {
- auto abi_decl = std::make_unique<abi_util::EnumTypeIR>();
+ auto abi_decl = std::make_unique<repr::EnumTypeIR>();
std::string source_file = GetCachedDeclSourceFile(enum_decl_, cip_);
if (!SetupEnum(abi_decl.get(), source_file)) {
@@ -911,13 +913,13 @@ GlobalVarDeclWrapper::GlobalVarDeclWrapper(
clang::MangleContext *mangle_contextp,
clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
- const clang::VarDecl *decl, abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches)
+ const clang::VarDecl *decl, repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches)
: ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper,
ast_caches),
global_var_decl_(decl) {}
-bool GlobalVarDeclWrapper::SetupGlobalVar(abi_util::GlobalVarIR *global_varp,
+bool GlobalVarDeclWrapper::SetupGlobalVar(repr::GlobalVarIR *global_varp,
const std::string &source_file) {
// Temporary fix: clang segfaults on trying to mangle global variable which
// is a dependent sized array type.
@@ -936,8 +938,12 @@ bool GlobalVarDeclWrapper::SetupGlobalVar(abi_util::GlobalVarIR *global_varp,
}
bool GlobalVarDeclWrapper::GetGlobalVarDecl() {
- auto abi_decl = std::make_unique<abi_util::GlobalVarIR>();
+ auto abi_decl = std::make_unique<repr::GlobalVarIR>();
std::string source_file = GetCachedDeclSourceFile(global_var_decl_, cip_);
return SetupGlobalVar(abi_decl.get(), source_file) &&
ir_dumper_->AddLinkableMessageIR(abi_decl.get());
}
+
+
+} // dumper
+} // header_checker
diff --git a/vndk/tools/header-checker/src/dumper/abi_wrappers.h b/vndk/tools/header-checker/src/dumper/abi_wrappers.h
index 3591477b9..624e0edfe 100644
--- a/vndk/tools/header-checker/src/dumper/abi_wrappers.h
+++ b/vndk/tools/header-checker/src/dumper/abi_wrappers.h
@@ -25,23 +25,26 @@
#include <clang/Frontend/CompilerInstance.h>
-namespace abi_wrapper {
+namespace header_checker {
+namespace dumper {
+
struct TypeAndCreationStatus {
- std::unique_ptr<abi_util::TypeIR> typep_;
+ std::unique_ptr<repr::TypeIR> typep_;
bool should_create_type_; // Whether the type is to be created.
- TypeAndCreationStatus(std::unique_ptr<abi_util::TypeIR> &&typep,
+ TypeAndCreationStatus(std::unique_ptr<repr::TypeIR> &&typep,
bool should_create_type = true)
: typep_(std::move(typep)), should_create_type_(should_create_type) {}
};
+
class ABIWrapper {
public:
ABIWrapper(clang::MangleContext *mangle_contextp,
clang::ASTContext *ast_contextp,
const clang::CompilerInstance *cip,
- abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches);
+ repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches);
static std::string GetDeclSourceFile(const clang::Decl *decl,
const clang::CompilerInstance *cip);
@@ -58,10 +61,10 @@ class ABIWrapper {
std::string TypeNameWithFinalDestination(clang::QualType qual_type);
bool SetupTemplateArguments(const clang::TemplateArgumentList *tl,
- abi_util::TemplatedArtifactIR *ta,
+ repr::TemplatedArtifactIR *ta,
const std::string &source_file);
- bool SetupFunctionParameter(abi_util::CFunctionLikeIR *functionp,
+ bool SetupFunctionParameter(repr::CFunctionLikeIR *functionp,
const clang::QualType qual_type,
bool has_default_arg,
const std::string &source_file,
@@ -75,11 +78,11 @@ class ABIWrapper {
const std::string &source_file);
bool CreateBasicNamedAndTypedDecl(clang::QualType canonical_type,
- abi_util::TypeIR *typep,
+ repr::TypeIR *typep,
const std::string &source_file);
bool CreateExtendedType(clang::QualType canonical_type,
- abi_util::TypeIR *typep);
+ repr::TypeIR *typep);
bool CreateAnonymousRecord(const clang::RecordDecl *decl);
@@ -94,17 +97,18 @@ class ABIWrapper {
const clang::CompilerInstance *cip_;
clang::MangleContext *mangle_contextp_;
clang::ASTContext *ast_contextp_;
- abi_util::IRDumper *ir_dumper_;
- ast_util::ASTCaches *ast_caches_;
+ repr::IRDumper *ir_dumper_;
+ ASTCaches *ast_caches_;
};
+
class RecordDeclWrapper : public ABIWrapper {
public:
RecordDeclWrapper(
clang::MangleContext *mangle_contextp, clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
- const clang::RecordDecl *record_decl, abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches);
+ const clang::RecordDecl *record_decl, repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches);
bool GetRecordDecl();
@@ -112,69 +116,71 @@ class RecordDeclWrapper : public ABIWrapper {
const clang::RecordDecl *record_decl_;
private:
- bool SetupRecordInfo(abi_util::RecordTypeIR *type,
+ bool SetupRecordInfo(repr::RecordTypeIR *type,
const std::string &source_file);
- bool SetupRecordFields(abi_util::RecordTypeIR *record_declp,
+ bool SetupRecordFields(repr::RecordTypeIR *record_declp,
const std::string &source_file);
- bool SetupCXXBases(abi_util::RecordTypeIR *cxxp,
+ bool SetupCXXBases(repr::RecordTypeIR *cxxp,
const clang::CXXRecordDecl *cxx_record_decl);
- bool SetupTemplateInfo(abi_util::RecordTypeIR *record_declp,
+ bool SetupTemplateInfo(repr::RecordTypeIR *record_declp,
const clang::CXXRecordDecl *cxx_record_decl,
const std::string &source_file);
- bool SetupRecordVTable(abi_util::RecordTypeIR *record_declp,
+ bool SetupRecordVTable(repr::RecordTypeIR *record_declp,
const clang::CXXRecordDecl *cxx_record_decl);
std::string GetMangledRTTI(const clang::CXXRecordDecl *cxx_record_decl);
- abi_util::VTableComponentIR
+ repr::VTableComponentIR
SetupRecordVTableComponent(const clang::VTableComponent &vtable_component,
const clang::ThunkInfo &thunk_info);
- bool SetupCXXRecordInfo(abi_util::RecordTypeIR *record_declp,
+ bool SetupCXXRecordInfo(repr::RecordTypeIR *record_declp,
const std::string &source_file);
};
+
class FunctionDeclWrapper : public ABIWrapper {
public:
FunctionDeclWrapper(
clang::MangleContext *mangle_contextp, clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
- const clang::FunctionDecl *decl, abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches);
+ const clang::FunctionDecl *decl, repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches);
- std::unique_ptr<abi_util::FunctionIR> GetFunctionDecl();
+ std::unique_ptr<repr::FunctionIR> GetFunctionDecl();
private:
const clang::FunctionDecl *function_decl_;
private:
- bool SetupFunction(abi_util::FunctionIR *methodp,
+ bool SetupFunction(repr::FunctionIR *methodp,
const std::string &source_file);
- bool SetupTemplateInfo(abi_util::FunctionIR *functionp,
+ bool SetupTemplateInfo(repr::FunctionIR *functionp,
const std::string &source_file);
- bool SetupFunctionParameters(abi_util::FunctionIR *functionp,
+ bool SetupFunctionParameters(repr::FunctionIR *functionp,
const std::string &source_file);
- bool SetupThisParameter(abi_util::FunctionIR *functionp,
+ bool SetupThisParameter(repr::FunctionIR *functionp,
const std::string &source_file);
};
+
class FunctionTypeWrapper : public ABIWrapper {
private:
- bool SetupFunctionType(abi_util::FunctionTypeIR *function_type_ir);
+ bool SetupFunctionType(repr::FunctionTypeIR *function_type_ir);
public:
FunctionTypeWrapper(
clang::MangleContext *mangle_contextp, clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
- const clang::FunctionType *function_type, abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches, const std::string &source_file);
+ const clang::FunctionType *function_type, repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches, const std::string &source_file);
bool GetFunctionType();
@@ -183,13 +189,14 @@ class FunctionTypeWrapper : public ABIWrapper {
const std::string &source_file_;
};
+
class EnumDeclWrapper : public ABIWrapper {
public:
EnumDeclWrapper(
clang::MangleContext *mangle_contextp, clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
- const clang::EnumDecl *decl, abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches);
+ const clang::EnumDecl *decl, repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches);
bool GetEnumDecl();
@@ -197,19 +204,20 @@ class EnumDeclWrapper : public ABIWrapper {
const clang::EnumDecl *enum_decl_;
private:
- bool SetupEnum(abi_util::EnumTypeIR *type,
+ bool SetupEnum(repr::EnumTypeIR *type,
const std::string &source_file);
- bool SetupEnumFields(abi_util::EnumTypeIR *enump);
+ bool SetupEnumFields(repr::EnumTypeIR *enump);
};
+
class GlobalVarDeclWrapper : public ABIWrapper {
public:
GlobalVarDeclWrapper(
clang::MangleContext *mangle_contextp, clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
- const clang::VarDecl *decl, abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches);
+ const clang::VarDecl *decl, repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches);
bool GetGlobalVarDecl();
@@ -217,10 +225,13 @@ class GlobalVarDeclWrapper : public ABIWrapper {
const clang::VarDecl *global_var_decl_;
private:
- bool SetupGlobalVar(abi_util::GlobalVarIR *global_varp,
+ bool SetupGlobalVar(repr::GlobalVarIR *global_varp,
const std::string &source_file);
};
-} // namespace abi_wrapper
+
+} // namespace dumper
+} // namespace header_checker
+
#endif // ABI_WRAPPERS_H_
diff --git a/vndk/tools/header-checker/src/dumper/ast_processing.cpp b/vndk/tools/header-checker/src/dumper/ast_processing.cpp
index 55308f0b9..3ce8e5fb5 100644
--- a/vndk/tools/header-checker/src/dumper/ast_processing.cpp
+++ b/vndk/tools/header-checker/src/dumper/ast_processing.cpp
@@ -25,18 +25,16 @@
#include <string>
-using abi_wrapper::ABIWrapper;
-using abi_wrapper::FunctionDeclWrapper;
-using abi_wrapper::RecordDeclWrapper;
-using abi_wrapper::EnumDeclWrapper;
-using abi_wrapper::GlobalVarDeclWrapper;
+namespace header_checker {
+namespace dumper {
+
HeaderASTVisitor::HeaderASTVisitor(
const HeaderCheckerOptions &options, clang::MangleContext *mangle_contextp,
clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
- const clang::Decl *tu_decl, abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches)
+ const clang::Decl *tu_decl, repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches)
: options_(options), mangle_contextp_(mangle_contextp),
ast_contextp_(ast_contextp), cip_(compiler_instance_p), tu_decl_(tu_decl),
ir_dumper_(ir_dumper), ast_caches_(ast_caches) {}
@@ -71,17 +69,17 @@ bool HeaderASTVisitor::VisitEnumDecl(const clang::EnumDecl *decl) {
return enum_decl_wrapper.GetEnumDecl();
}
-static bool MutateFunctionWithLinkageName(const abi_util::FunctionIR *function,
- abi_util::IRDumper *ir_dumper,
+static bool MutateFunctionWithLinkageName(const repr::FunctionIR *function,
+ repr::IRDumper *ir_dumper,
std::string &linkage_name) {
- auto added_function = std::make_unique<abi_util::FunctionIR>();
+ auto added_function = std::make_unique<repr::FunctionIR>();
*added_function = *function;
added_function->SetLinkerSetKey(linkage_name);
return ir_dumper->AddLinkableMessageIR(added_function.get());
}
-static bool AddMangledFunctions(const abi_util::FunctionIR *function,
- abi_util:: IRDumper *ir_dumper,
+static bool AddMangledFunctions(const repr::FunctionIR *function,
+ repr:: IRDumper *ir_dumper,
std::vector<std::string> &manglings) {
for (auto &&mangling : manglings) {
if (!MutateFunctionWithLinkageName(function, ir_dumper, mangling)) {
@@ -203,13 +201,13 @@ void HeaderASTConsumer::HandleTranslationUnit(clang::ASTContext &ctx) {
ctx.createMangleContext());
const std::string &translation_unit_source =
ABIWrapper::GetDeclSourceFile(translation_unit, cip_);
- ast_util::ASTCaches ast_caches(translation_unit_source);
+ ASTCaches ast_caches(translation_unit_source);
if (!options_.exported_headers_.empty()) {
options_.exported_headers_.insert(translation_unit_source);
}
- std::unique_ptr<abi_util::IRDumper> ir_dumper =
- abi_util::IRDumper::CreateIRDumper(options_.text_format_,
- options_.dump_name_);
+ std::unique_ptr<repr::IRDumper> ir_dumper =
+ repr::IRDumper::CreateIRDumper(options_.text_format_,
+ options_.dump_name_);
HeaderASTVisitor v(options_, mangle_contextp.get(), &ctx, cip_,
translation_unit, ir_dumper.get(), &ast_caches);
@@ -218,3 +216,7 @@ void HeaderASTConsumer::HandleTranslationUnit(clang::ASTContext &ctx) {
::exit(1);
}
}
+
+
+} // dumper
+} // header_checker
diff --git a/vndk/tools/header-checker/src/dumper/ast_processing.h b/vndk/tools/header-checker/src/dumper/ast_processing.h
index 5c1d50ffe..1fbad8e39 100644
--- a/vndk/tools/header-checker/src/dumper/ast_processing.h
+++ b/vndk/tools/header-checker/src/dumper/ast_processing.h
@@ -28,6 +28,10 @@
#include <set>
+namespace header_checker {
+namespace dumper {
+
+
class HeaderASTVisitor
: public clang::RecursiveASTVisitor<HeaderASTVisitor> {
public:
@@ -36,8 +40,8 @@ class HeaderASTVisitor
clang::ASTContext *ast_contextp,
const clang::CompilerInstance *compiler_instance_p,
const clang::Decl *tu_decl,
- abi_util::IRDumper *ir_dumper,
- ast_util::ASTCaches *ast_caches);
+ repr::IRDumper *ir_dumper,
+ ASTCaches *ast_caches);
bool VisitRecordDecl(const clang::RecordDecl *decl);
@@ -61,12 +65,13 @@ class HeaderASTVisitor
const clang::CompilerInstance *cip_;
// To optimize recursion into only exported abi.
const clang::Decl *tu_decl_;
- abi_util::IRDumper *ir_dumper_;
+ repr::IRDumper *ir_dumper_;
// We cache the source file an AST node corresponds to, to avoid repeated
// calls to "realpath".
- ast_util::ASTCaches *ast_caches_;
+ ASTCaches *ast_caches_;
};
+
class HeaderASTConsumer : public clang::ASTConsumer {
public:
HeaderASTConsumer(clang::CompilerInstance *compiler_instancep,
@@ -79,4 +84,9 @@ class HeaderASTConsumer : public clang::ASTConsumer {
HeaderCheckerOptions &options_;
};
+
+} // namespace dumper
+} // namespace header_checker
+
+
#endif // AST_PROCESSING_H_
diff --git a/vndk/tools/header-checker/src/dumper/ast_util.h b/vndk/tools/header-checker/src/dumper/ast_util.h
index f45b0909e..b68c4ba79 100644
--- a/vndk/tools/header-checker/src/dumper/ast_util.h
+++ b/vndk/tools/header-checker/src/dumper/ast_util.h
@@ -21,7 +21,9 @@
#include <string>
-namespace ast_util {
+namespace header_checker {
+namespace dumper {
+
constexpr static char type_id_prefix[] = "type-";
@@ -46,6 +48,9 @@ struct ASTCaches {
uint64_t max_type_id_ = 0;
};
-} // namespace ast_util
+
+} // namespace dumper
+} // namespace header_checker
+
#endif // AST_UTIL_H_
diff --git a/vndk/tools/header-checker/src/dumper/diagnostic_consumer.cpp b/vndk/tools/header-checker/src/dumper/diagnostic_consumer.cpp
index 4cdfc53ec..212609db7 100644
--- a/vndk/tools/header-checker/src/dumper/diagnostic_consumer.cpp
+++ b/vndk/tools/header-checker/src/dumper/diagnostic_consumer.cpp
@@ -19,6 +19,10 @@
#include <clang/Lex/LexDiagnostic.h>
+namespace header_checker {
+namespace dumper {
+
+
HeaderCheckerDiagnosticConsumer::HeaderCheckerDiagnosticConsumer(
std::unique_ptr<clang::DiagnosticConsumer> wrapped)
: wrapped_(std::move(wrapped)) {}
@@ -63,3 +67,7 @@ void HeaderCheckerDiagnosticConsumer::HandleDiagnostic(
DiagnosticConsumer::HandleDiagnostic(level, info);
wrapped_->HandleDiagnostic(level, info);
}
+
+
+} // dumper
+} // header_checker
diff --git a/vndk/tools/header-checker/src/dumper/diagnostic_consumer.h b/vndk/tools/header-checker/src/dumper/diagnostic_consumer.h
index 659dbab65..f4738ee8d 100644
--- a/vndk/tools/header-checker/src/dumper/diagnostic_consumer.h
+++ b/vndk/tools/header-checker/src/dumper/diagnostic_consumer.h
@@ -18,6 +18,10 @@
#include <clang/Basic/Diagnostic.h>
+namespace header_checker {
+namespace dumper {
+
+
class HeaderCheckerDiagnosticConsumer : public clang::DiagnosticConsumer {
private:
std::unique_ptr<clang::DiagnosticConsumer> wrapped_;
@@ -35,4 +39,9 @@ class HeaderCheckerDiagnosticConsumer : public clang::DiagnosticConsumer {
const clang::Diagnostic &info) override;
};
+
+} // namespace dumper
+} // namespace header_checker
+
+
#endif // DIAGNOSTIC_CONSUMER_H_
diff --git a/vndk/tools/header-checker/src/dumper/fake_decl_source.cpp b/vndk/tools/header-checker/src/dumper/fake_decl_source.cpp
index d00509f8f..4930a39c9 100644
--- a/vndk/tools/header-checker/src/dumper/fake_decl_source.cpp
+++ b/vndk/tools/header-checker/src/dumper/fake_decl_source.cpp
@@ -18,6 +18,10 @@
#include <clang/Sema/Lookup.h>
+namespace header_checker {
+namespace dumper {
+
+
FakeDeclSource::FakeDeclSource(const clang::CompilerInstance &ci) : ci_(ci) {}
clang::CXXRecordDecl *
@@ -199,3 +203,7 @@ bool FakeDeclSource::LookupUnqualified(clang::LookupResult &result,
result.resolveKind();
return true;
}
+
+
+} // dumper
+} // header_checker
diff --git a/vndk/tools/header-checker/src/dumper/fake_decl_source.h b/vndk/tools/header-checker/src/dumper/fake_decl_source.h
index 2a1efa099..42c855267 100644
--- a/vndk/tools/header-checker/src/dumper/fake_decl_source.h
+++ b/vndk/tools/header-checker/src/dumper/fake_decl_source.h
@@ -12,11 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#ifndef HEADER_CHECKER_ABI_DUMPER_FAKE_DECL_SOURCE_H_
+#define HEADER_CHECKER_ABI_DUMPER_FAKE_DECL_SOURCE_H_
+
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Sema/ExternalSemaSource.h>
#include <clang/Sema/Sema.h>
+namespace header_checker {
+namespace dumper {
+
+
// This class creates fake declarations when the compiler queries for unknown
// types.
class FakeDeclSource : public clang::ExternalSemaSource {
@@ -58,3 +65,10 @@ class FakeDeclSource : public clang::ExternalSemaSource {
bool LookupUnqualified(clang::LookupResult &result,
clang::Scope *scope) override;
};
+
+
+} // namespace dumper
+} // namespace header_checker
+
+
+#endif // HEADER_CHECKER_ABI_DUMPER_FAKE_DECL_SOURCE_H_
diff --git a/vndk/tools/header-checker/src/dumper/fixed_argv.cpp b/vndk/tools/header-checker/src/dumper/fixed_argv.cpp
index be947c81b..57f402b0d 100644
--- a/vndk/tools/header-checker/src/dumper/fixed_argv.cpp
+++ b/vndk/tools/header-checker/src/dumper/fixed_argv.cpp
@@ -15,4 +15,12 @@
#include "dumper/fixed_argv.h"
+namespace header_checker {
+namespace dumper {
+
+
FixedArgvRegistry *FixedArgvRegistry::head_ = nullptr;
+
+
+} // dumper
+} // header_checker
diff --git a/vndk/tools/header-checker/src/dumper/fixed_argv.h b/vndk/tools/header-checker/src/dumper/fixed_argv.h
index 61d590dcf..1ae947edd 100644
--- a/vndk/tools/header-checker/src/dumper/fixed_argv.h
+++ b/vndk/tools/header-checker/src/dumper/fixed_argv.h
@@ -24,6 +24,10 @@
#include <string.h>
+namespace header_checker {
+namespace dumper {
+
+
class FixedArgvAccess;
@@ -131,4 +135,8 @@ class FixedArgvRegistry {
};
+} // namespace dumper
+} // namespace header_checker
+
+
#endif // FIXED_ARGV_H_
diff --git a/vndk/tools/header-checker/src/dumper/frontend_action.cpp b/vndk/tools/header-checker/src/dumper/frontend_action.cpp
index 2ce4a7510..6b773267b 100644
--- a/vndk/tools/header-checker/src/dumper/frontend_action.cpp
+++ b/vndk/tools/header-checker/src/dumper/frontend_action.cpp
@@ -27,6 +27,10 @@
#include <llvm/ADT/STLExtras.h>
+namespace header_checker {
+namespace dumper {
+
+
HeaderCheckerFrontendAction::HeaderCheckerFrontendAction(
HeaderCheckerOptions &options)
: options_(options) {}
@@ -57,3 +61,7 @@ bool HeaderCheckerFrontendAction::BeginSourceFileAction(
}
return true;
}
+
+
+} // dumper
+} // header_checker
diff --git a/vndk/tools/header-checker/src/dumper/frontend_action.h b/vndk/tools/header-checker/src/dumper/frontend_action.h
index d2d34f5e9..ad82850eb 100644
--- a/vndk/tools/header-checker/src/dumper/frontend_action.h
+++ b/vndk/tools/header-checker/src/dumper/frontend_action.h
@@ -31,6 +31,11 @@ namespace clang {
class CompilerInstance;
} // namespace clang
+
+namespace header_checker {
+namespace dumper {
+
+
class HeaderCheckerFrontendAction : public clang::ASTFrontendAction {
private:
HeaderCheckerOptions &options_;
@@ -46,4 +51,9 @@ class HeaderCheckerFrontendAction : public clang::ASTFrontendAction {
bool BeginSourceFileAction(clang::CompilerInstance &ci) override;
};
+
+} // namespace dumper
+} // namespace header_checker
+
+
#endif // FRONTEND_ACTION_H_
diff --git a/vndk/tools/header-checker/src/dumper/frontend_action_factory.cpp b/vndk/tools/header-checker/src/dumper/frontend_action_factory.cpp
index e1a8ce531..307b9160d 100644
--- a/vndk/tools/header-checker/src/dumper/frontend_action_factory.cpp
+++ b/vndk/tools/header-checker/src/dumper/frontend_action_factory.cpp
@@ -19,6 +19,10 @@
#include <clang/Frontend/FrontendActions.h>
+namespace header_checker {
+namespace dumper {
+
+
HeaderCheckerFrontendActionFactory::HeaderCheckerFrontendActionFactory(
HeaderCheckerOptions &options)
: options_(options) {}
@@ -26,3 +30,7 @@ HeaderCheckerFrontendActionFactory::HeaderCheckerFrontendActionFactory(
clang::FrontendAction *HeaderCheckerFrontendActionFactory::create() {
return new HeaderCheckerFrontendAction(options_);
}
+
+
+} // dumper
+} // header_checker
diff --git a/vndk/tools/header-checker/src/dumper/frontend_action_factory.h b/vndk/tools/header-checker/src/dumper/frontend_action_factory.h
index 76df586d0..0a7d4094c 100644
--- a/vndk/tools/header-checker/src/dumper/frontend_action_factory.h
+++ b/vndk/tools/header-checker/src/dumper/frontend_action_factory.h
@@ -23,6 +23,10 @@
#include <vector>
+namespace header_checker {
+namespace dumper {
+
+
class HeaderCheckerFrontendActionFactory
: public clang::tooling::FrontendActionFactory {
private:
@@ -34,4 +38,9 @@ class HeaderCheckerFrontendActionFactory
clang::FrontendAction *create() override;
};
+
+} // namespace dumper
+} // namespace header_checker
+
+
#endif // FRONTEND_ACTION_FACTORY_H_
diff --git a/vndk/tools/header-checker/src/dumper/header_checker.cpp b/vndk/tools/header-checker/src/dumper/header_checker.cpp
index 810278c90..25d87fe8c 100644
--- a/vndk/tools/header-checker/src/dumper/header_checker.cpp
+++ b/vndk/tools/header-checker/src/dumper/header_checker.cpp
@@ -33,6 +33,17 @@
#include <stdlib.h>
+using header_checker::dumper::FixedArgv;
+using header_checker::dumper::FixedArgvAccess;
+using header_checker::dumper::FixedArgvRegistry;
+using header_checker::dumper::HeaderCheckerFrontendActionFactory;
+using header_checker::dumper::HeaderCheckerOptions;
+using header_checker::repr::TextFormatIR;
+using header_checker::utils::CollectAllExportedHeaders;
+using header_checker::utils::RealPath;
+
+
+
static llvm::cl::OptionCategory header_checker_category(
"header-checker options");
@@ -64,12 +75,12 @@ static llvm::cl::opt<bool> dump_function_declarations(
"file"),
llvm::cl::Optional, llvm::cl::cat(header_checker_category));
-static llvm::cl::opt<abi_util::TextFormatIR> output_format(
+static llvm::cl::opt<TextFormatIR> output_format(
"output-format", llvm::cl::desc("Specify format of output dump file"),
- llvm::cl::values(clEnumValN(abi_util::TextFormatIR::ProtobufTextFormat,
+ llvm::cl::values(clEnumValN(TextFormatIR::ProtobufTextFormat,
"ProtobufTextFormat", "ProtobufTextFormat"),
- clEnumValN(abi_util::TextFormatIR::Json, "Json", "JSON")),
- llvm::cl::init(abi_util::TextFormatIR::Json),
+ clEnumValN(TextFormatIR::Json, "Json", "JSON")),
+ llvm::cl::init(TextFormatIR::Json),
llvm::cl::cat(header_checker_category));
// Hide irrelevant command line options defined in LLVM libraries.
@@ -131,13 +142,12 @@ int main(int argc, const char **argv) {
std::set<std::string> exported_headers;
if (!no_filter) {
- exported_headers =
- abi_util::CollectAllExportedHeaders(exported_header_dirs);
+ exported_headers = CollectAllExportedHeaders(exported_header_dirs);
}
// Initialize clang tools and run front-end action.
std::vector<std::string> header_files{ header_file };
- HeaderCheckerOptions options(abi_util::RealPath(header_file), out_dump,
+ HeaderCheckerOptions options(RealPath(header_file), out_dump,
std::move(exported_headers), output_format,
dump_function_declarations, suppress_errors);
diff --git a/vndk/tools/header-checker/src/dumper/header_checker.h b/vndk/tools/header-checker/src/dumper/header_checker.h
index 7fcbda6c6..6acd59628 100644
--- a/vndk/tools/header-checker/src/dumper/header_checker.h
+++ b/vndk/tools/header-checker/src/dumper/header_checker.h
@@ -21,19 +21,23 @@
#include <string>
+namespace header_checker {
+namespace dumper {
+
+
class HeaderCheckerOptions {
public:
std::string source_file_;
std::string dump_name_;
std::set<std::string> exported_headers_;
- abi_util::TextFormatIR text_format_;
+ repr::TextFormatIR text_format_;
bool dump_function_declarations_;
bool suppress_errors_;
public:
HeaderCheckerOptions(std::string source_file, std::string dump_name,
std::set<std::string> exported_headers,
- abi_util::TextFormatIR text_format,
+ repr::TextFormatIR text_format,
bool dump_function_declarations, bool suppress_errors)
: source_file_(std::move(source_file)), dump_name_(std::move(dump_name)),
exported_headers_(std::move(exported_headers)),
@@ -42,4 +46,9 @@ class HeaderCheckerOptions {
suppress_errors_(suppress_errors) {}
};
+
+} // namespace dumper
+} // namespace header_checker
+
+
#endif // HEADER_CHECKER_H_
diff --git a/vndk/tools/header-checker/src/linker/header_abi_linker.cpp b/vndk/tools/header-checker/src/linker/header_abi_linker.cpp
index b92c38d11..4fcbbf50e 100644
--- a/vndk/tools/header-checker/src/linker/header_abi_linker.cpp
+++ b/vndk/tools/header-checker/src/linker/header_abi_linker.cpp
@@ -32,6 +32,11 @@
#include <stdlib.h>
+using namespace header_checker;
+using header_checker::repr::TextFormatIR;
+using header_checker::utils::CollectAllExportedHeaders;
+
+
static constexpr std::size_t kSourcesPerBatchThread = 7;
static llvm::cl::OptionCategory header_linker_category(
@@ -78,20 +83,20 @@ static llvm::cl::opt<std::string> so_file(
"so", llvm::cl::desc("<path to so file>"), llvm::cl::Optional,
llvm::cl::cat(header_linker_category));
-static llvm::cl::opt<abi_util::TextFormatIR> input_format(
+static llvm::cl::opt<TextFormatIR> input_format(
"input-format", llvm::cl::desc("Specify format of input dump files"),
- llvm::cl::values(clEnumValN(abi_util::TextFormatIR::ProtobufTextFormat,
+ llvm::cl::values(clEnumValN(TextFormatIR::ProtobufTextFormat,
"ProtobufTextFormat", "ProtobufTextFormat"),
- clEnumValN(abi_util::TextFormatIR::Json, "Json", "JSON")),
- llvm::cl::init(abi_util::TextFormatIR::Json),
+ clEnumValN(TextFormatIR::Json, "Json", "JSON")),
+ llvm::cl::init(TextFormatIR::Json),
llvm::cl::cat(header_linker_category));
-static llvm::cl::opt<abi_util::TextFormatIR> output_format(
+static llvm::cl::opt<TextFormatIR> output_format(
"output-format", llvm::cl::desc("Specify format of output dump file"),
- llvm::cl::values(clEnumValN(abi_util::TextFormatIR::ProtobufTextFormat,
+ llvm::cl::values(clEnumValN(TextFormatIR::ProtobufTextFormat,
"ProtobufTextFormat", "ProtobufTextFormat"),
- clEnumValN(abi_util::TextFormatIR::Json, "Json", "JSON")),
- llvm::cl::init(abi_util::TextFormatIR::Json),
+ clEnumValN(TextFormatIR::Json, "Json", "JSON")),
+ llvm::cl::init(TextFormatIR::Json),
llvm::cl::cat(header_linker_category));
class HeaderAbiLinker {
@@ -116,11 +121,11 @@ class HeaderAbiLinker {
private:
template <typename T>
- bool LinkDecl(abi_util::IRDumper *dst,
- const abi_util::AbiElementMap<T> &src,
+ bool LinkDecl(repr::IRDumper *dst,
+ const repr::AbiElementMap<T> &src,
const std::function<bool(const std::string &)> &symbol_filter);
- std::unique_ptr<abi_util::TextFormatToIRReader> ReadInputDumpFiles();
+ std::unique_ptr<repr::TextFormatToIRReader> ReadInputDumpFiles();
bool ReadExportedSymbols();
@@ -128,22 +133,22 @@ class HeaderAbiLinker {
bool ReadExportedSymbolsFromSharedObjectFile();
- bool LinkTypes(const abi_util::TextFormatToIRReader *ir_reader,
- abi_util::IRDumper *ir_dumper);
+ bool LinkTypes(const repr::TextFormatToIRReader *ir_reader,
+ repr::IRDumper *ir_dumper);
- bool LinkFunctions(const abi_util::TextFormatToIRReader *ir_reader,
- abi_util::IRDumper *ir_dumper);
+ bool LinkFunctions(const repr::TextFormatToIRReader *ir_reader,
+ repr::IRDumper *ir_dumper);
- bool LinkGlobalVars(const abi_util::TextFormatToIRReader *ir_reader,
- abi_util::IRDumper *ir_dumper);
+ bool LinkGlobalVars(const repr::TextFormatToIRReader *ir_reader,
+ repr::IRDumper *ir_dumper);
- bool LinkExportedSymbols(abi_util::IRDumper *ir_dumper);
+ bool LinkExportedSymbols(repr::IRDumper *ir_dumper);
- bool LinkExportedSymbols(abi_util::IRDumper *ir_dumper,
- const abi_util::ExportedSymbolSet &exported_symbols);
+ bool LinkExportedSymbols(repr::IRDumper *ir_dumper,
+ const repr::ExportedSymbolSet &exported_symbols);
template <typename SymbolMap>
- bool LinkExportedSymbols(abi_util::IRDumper *ir_dumper,
+ bool LinkExportedSymbols(repr::IRDumper *ir_dumper,
const SymbolMap &symbols);
// Check whether a symbol name is considered as exported. If both
@@ -165,17 +170,18 @@ class HeaderAbiLinker {
std::set<std::string> exported_headers_;
// Exported symbols
- std::unique_ptr<abi_util::ExportedSymbolSet> shared_object_symbols_;
- std::unique_ptr<abi_util::ExportedSymbolSet> version_script_symbols_;
+ std::unique_ptr<repr::ExportedSymbolSet> shared_object_symbols_;
+
+ std::unique_ptr<repr::ExportedSymbolSet> version_script_symbols_;
};
static void DeDuplicateAbiElementsThread(
const std::vector<std::string> &dump_files,
const std::set<std::string> *exported_headers,
- abi_util::TextFormatToIRReader *greader, std::mutex *greader_lock,
+ repr::TextFormatToIRReader *greader, std::mutex *greader_lock,
std::atomic<std::size_t> *cnt) {
- std::unique_ptr<abi_util::TextFormatToIRReader> local_reader =
- abi_util::TextFormatToIRReader::CreateTextFormatToIRReader(
+ std::unique_ptr<repr::TextFormatToIRReader> local_reader =
+ repr::TextFormatToIRReader::CreateTextFormatToIRReader(
input_format, exported_headers);
auto begin_it = dump_files.begin();
@@ -187,8 +193,8 @@ static void DeDuplicateAbiElementsThread(
}
std::size_t end = std::min(i + kSourcesPerBatchThread, num_sources);
for (auto it = begin_it; it != begin_it + end; it++) {
- std::unique_ptr<abi_util::TextFormatToIRReader> reader =
- abi_util::TextFormatToIRReader::CreateTextFormatToIRReader(
+ std::unique_ptr<repr::TextFormatToIRReader> reader =
+ repr::TextFormatToIRReader::CreateTextFormatToIRReader(
input_format, exported_headers);
assert(reader != nullptr);
if (!reader->ReadDump(*it)) {
@@ -204,10 +210,10 @@ static void DeDuplicateAbiElementsThread(
greader->MergeGraphs(*local_reader);
}
-std::unique_ptr<abi_util::TextFormatToIRReader>
+std::unique_ptr<repr::TextFormatToIRReader>
HeaderAbiLinker::ReadInputDumpFiles() {
- std::unique_ptr<abi_util::TextFormatToIRReader> greader =
- abi_util::TextFormatToIRReader::CreateTextFormatToIRReader(
+ std::unique_ptr<repr::TextFormatToIRReader> greader =
+ repr::TextFormatToIRReader::CreateTextFormatToIRReader(
input_format, &exported_headers_);
std::size_t max_threads = std::thread::hardware_concurrency();
@@ -238,15 +244,14 @@ bool HeaderAbiLinker::LinkAndDump() {
}
// Construct the list of exported headers for source location filtering.
- exported_headers_ =
- abi_util::CollectAllExportedHeaders(exported_header_dirs_);
+ exported_headers_ = CollectAllExportedHeaders(exported_header_dirs_);
// Read all input ABI dumps.
auto greader = ReadInputDumpFiles();
// Link input ABI dumps.
- std::unique_ptr<abi_util::IRDumper> ir_dumper =
- abi_util::IRDumper::CreateIRDumper(output_format, out_dump_name_);
+ std::unique_ptr<repr::IRDumper> ir_dumper =
+ repr::IRDumper::CreateIRDumper(output_format, out_dump_name_);
assert(ir_dumper != nullptr);
if (!LinkExportedSymbols(ir_dumper.get())) {
@@ -270,7 +275,7 @@ bool HeaderAbiLinker::LinkAndDump() {
template <typename T>
bool HeaderAbiLinker::LinkDecl(
- abi_util::IRDumper *dst, const abi_util::AbiElementMap<T> &src,
+ repr::IRDumper *dst, const repr::AbiElementMap<T> &src,
const std::function<bool(const std::string &)> &symbol_filter) {
assert(dst != nullptr);
for (auto &&element : src) {
@@ -294,8 +299,8 @@ bool HeaderAbiLinker::LinkDecl(
return true;
}
-bool HeaderAbiLinker::LinkTypes(const abi_util::TextFormatToIRReader *reader,
- abi_util::IRDumper *ir_dumper) {
+bool HeaderAbiLinker::LinkTypes(const repr::TextFormatToIRReader *reader,
+ repr::IRDumper *ir_dumper) {
assert(reader != nullptr);
auto no_filter = [](const std::string &symbol) { return true; };
return LinkDecl(ir_dumper, reader->GetRecordTypes(), no_filter) &&
@@ -320,8 +325,8 @@ bool HeaderAbiLinker::IsSymbolExported(const std::string &name) const {
}
bool HeaderAbiLinker::LinkFunctions(
- const abi_util::TextFormatToIRReader *reader,
- abi_util::IRDumper *ir_dumper) {
+ const repr::TextFormatToIRReader *reader,
+ repr::IRDumper *ir_dumper) {
assert(reader != nullptr);
auto symbol_filter = [this](const std::string &linker_set_key) {
return IsSymbolExported(linker_set_key);
@@ -330,8 +335,8 @@ bool HeaderAbiLinker::LinkFunctions(
}
bool HeaderAbiLinker::LinkGlobalVars(
- const abi_util::TextFormatToIRReader *reader,
- abi_util::IRDumper *ir_dumper) {
+ const repr::TextFormatToIRReader *reader,
+ repr::IRDumper *ir_dumper) {
assert(reader != nullptr);
auto symbol_filter = [this](const std::string &linker_set_key) {
return IsSymbolExported(linker_set_key);
@@ -340,7 +345,7 @@ bool HeaderAbiLinker::LinkGlobalVars(
}
template <typename SymbolMap>
-bool HeaderAbiLinker::LinkExportedSymbols(abi_util::IRDumper *dst,
+bool HeaderAbiLinker::LinkExportedSymbols(repr::IRDumper *dst,
const SymbolMap &symbols) {
for (auto &&symbol : symbols) {
if (!IsSymbolExported(symbol.first)) {
@@ -354,13 +359,13 @@ bool HeaderAbiLinker::LinkExportedSymbols(abi_util::IRDumper *dst,
}
bool HeaderAbiLinker::LinkExportedSymbols(
- abi_util::IRDumper *ir_dumper,
- const abi_util::ExportedSymbolSet &exported_symbols) {
+ repr::IRDumper *ir_dumper,
+ const repr::ExportedSymbolSet &exported_symbols) {
return (LinkExportedSymbols(ir_dumper, exported_symbols.GetFunctions()) &&
LinkExportedSymbols(ir_dumper, exported_symbols.GetVars()));
}
-bool HeaderAbiLinker::LinkExportedSymbols(abi_util::IRDumper *ir_dumper) {
+bool HeaderAbiLinker::LinkExportedSymbols(repr::IRDumper *ir_dumper) {
if (shared_object_symbols_) {
return LinkExportedSymbols(ir_dumper, *shared_object_symbols_);
}
@@ -398,7 +403,7 @@ bool HeaderAbiLinker::ReadExportedSymbols() {
}
bool HeaderAbiLinker::ReadExportedSymbolsFromVersionScript() {
- std::optional<abi_util::ApiLevel> api_level = abi_util::ParseApiLevel(api_);
+ std::optional<utils::ApiLevel> api_level = utils::ParseApiLevel(api_);
if (!api_level) {
llvm::errs() << "-api must be either \"current\" or an integer (e.g. 21)\n";
return false;
@@ -410,7 +415,7 @@ bool HeaderAbiLinker::ReadExportedSymbolsFromVersionScript() {
return false;
}
- abi_util::VersionScriptParser parser;
+ repr::VersionScriptParser parser;
parser.SetArch(arch_);
parser.SetApiLevel(api_level.value());
for (auto &&version : excluded_symbol_versions_) {
@@ -430,8 +435,8 @@ bool HeaderAbiLinker::ReadExportedSymbolsFromVersionScript() {
}
bool HeaderAbiLinker::ReadExportedSymbolsFromSharedObjectFile() {
- std::unique_ptr<abi_util::SoFileParser> so_parser =
- abi_util::SoFileParser::Create(so_file_);
+ std::unique_ptr<repr::SoFileParser> so_parser =
+ repr::SoFileParser::Create(so_file_);
if (!so_parser) {
return false;
}
diff --git a/vndk/tools/header-checker/src/repr/abi_diff_helpers.cpp b/vndk/tools/header-checker/src/repr/abi_diff_helpers.cpp
index c89430b7a..604186961 100644
--- a/vndk/tools/header-checker/src/repr/abi_diff_helpers.cpp
+++ b/vndk/tools/header-checker/src/repr/abi_diff_helpers.cpp
@@ -19,7 +19,9 @@
#include <llvm/Support/raw_ostream.h>
-namespace abi_util {
+namespace header_checker {
+namespace repr {
+
std::string Unwind(const std::deque<std::string> *type_queue) {
if (!type_queue) {
@@ -47,17 +49,17 @@ static void TypeQueueCheckAndPop(std::deque<std::string> *type_queue) {
}
}
-static bool IsAccessDownGraded(abi_util::AccessSpecifierIR old_access,
- abi_util::AccessSpecifierIR new_access) {
+static bool IsAccessDownGraded(AccessSpecifierIR old_access,
+ AccessSpecifierIR new_access) {
bool access_downgraded = false;
switch (old_access) {
- case abi_util::AccessSpecifierIR::ProtectedAccess:
- if (new_access == abi_util::AccessSpecifierIR::PrivateAccess) {
+ case AccessSpecifierIR::ProtectedAccess:
+ if (new_access == AccessSpecifierIR::PrivateAccess) {
access_downgraded = true;
}
break;
- case abi_util::AccessSpecifierIR::PublicAccess:
- if (new_access != abi_util::AccessSpecifierIR::PublicAccess) {
+ case AccessSpecifierIR::PublicAccess:
+ if (new_access != AccessSpecifierIR::PublicAccess) {
access_downgraded = true;
}
break;
@@ -156,36 +158,36 @@ void ReplaceTypeIdsWithTypeNames(
}
void AbiDiffHelper::CompareEnumFields(
- const std::vector<abi_util::EnumFieldIR> &old_fields,
- const std::vector<abi_util::EnumFieldIR> &new_fields,
- abi_util::EnumTypeDiffIR *enum_type_diff_ir) {
- AbiElementMap<const abi_util::EnumFieldIR *> old_fields_map;
- AbiElementMap<const abi_util::EnumFieldIR *> new_fields_map;
- abi_util::AddToMap(&old_fields_map, old_fields,
- [](const abi_util::EnumFieldIR *f) {return f->GetName();},
- [](const abi_util::EnumFieldIR *f) {return f;});
+ const std::vector<EnumFieldIR> &old_fields,
+ const std::vector<EnumFieldIR> &new_fields,
+ EnumTypeDiffIR *enum_type_diff_ir) {
+ AbiElementMap<const EnumFieldIR *> old_fields_map;
+ AbiElementMap<const EnumFieldIR *> new_fields_map;
+ utils::AddToMap(&old_fields_map, old_fields,
+ [](const EnumFieldIR *f) {return f->GetName();},
+ [](const EnumFieldIR *f) {return f;});
- abi_util::AddToMap(&new_fields_map, new_fields,
- [](const abi_util::EnumFieldIR *f) {return f->GetName();},
- [](const abi_util::EnumFieldIR *f) {return f;});
+ utils::AddToMap(&new_fields_map, new_fields,
+ [](const EnumFieldIR *f) {return f->GetName();},
+ [](const EnumFieldIR *f) {return f;});
- std::vector<const abi_util::EnumFieldIR *> removed_fields =
- abi_util::FindRemovedElements(old_fields_map, new_fields_map);
+ std::vector<const EnumFieldIR *> removed_fields =
+ utils::FindRemovedElements(old_fields_map, new_fields_map);
- std::vector<const abi_util::EnumFieldIR *> added_fields =
- abi_util::FindRemovedElements(new_fields_map, old_fields_map);
+ std::vector<const EnumFieldIR *> added_fields =
+ utils::FindRemovedElements(new_fields_map, old_fields_map);
enum_type_diff_ir->SetFieldsAdded(std::move(added_fields));
enum_type_diff_ir->SetFieldsRemoved(std::move(removed_fields));
- std::vector<std::pair<const abi_util::EnumFieldIR *,
- const abi_util::EnumFieldIR *>> cf =
- abi_util::FindCommonElements(old_fields_map, new_fields_map);
- std::vector<abi_util::EnumFieldDiffIR> enum_field_diffs;
+ std::vector<std::pair<const EnumFieldIR *,
+ const EnumFieldIR *>> cf =
+ utils::FindCommonElements(old_fields_map, new_fields_map);
+ std::vector<EnumFieldDiffIR> enum_field_diffs;
for (auto &&common_fields : cf) {
if (common_fields.first->GetValue() != common_fields.second->GetValue()) {
- abi_util::EnumFieldDiffIR enum_field_diff_ir(common_fields.first,
+ EnumFieldDiffIR enum_field_diff_ir(common_fields.first,
common_fields.second);
enum_field_diffs.emplace_back(std::move(enum_field_diff_ir));
}
@@ -194,13 +196,13 @@ void AbiDiffHelper::CompareEnumFields(
}
DiffStatus AbiDiffHelper::CompareEnumTypes(
- const abi_util::EnumTypeIR *old_type, const abi_util::EnumTypeIR *new_type,
+ const EnumTypeIR *old_type, const EnumTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
if (old_type->GetUniqueId() != new_type->GetUniqueId()) {
return DiffStatus::direct_diff;
}
- auto enum_type_diff_ir = std::make_unique<abi_util::EnumTypeDiffIR>();
+ auto enum_type_diff_ir = std::make_unique<EnumTypeDiffIR>();
enum_type_diff_ir->SetName(old_type->GetName());
const std::string &old_underlying_type =
ConvertTypeIdToString(old_types_, old_type->GetUnderlyingType());
@@ -236,8 +238,8 @@ static std::string RemoveThunkInfoFromMangledName(const std::string &name) {
}
bool AbiDiffHelper::CompareVTableComponents(
- const abi_util::VTableComponentIR &old_component,
- const abi_util::VTableComponentIR &new_component) {
+ const VTableComponentIR &old_component,
+ const VTableComponentIR &new_component) {
// Vtable components in prebuilts/abi-dumps/vndk/28 don't have thunk info.
if (old_component.GetName() != new_component.GetName()) {
if (RemoveThunkInfoFromMangledName(old_component.GetName()) ==
@@ -254,12 +256,12 @@ bool AbiDiffHelper::CompareVTableComponents(
}
bool AbiDiffHelper::CompareVTables(
- const abi_util::RecordTypeIR *old_record,
- const abi_util::RecordTypeIR *new_record) {
+ const RecordTypeIR *old_record,
+ const RecordTypeIR *new_record) {
- const std::vector<abi_util::VTableComponentIR> &old_components =
+ const std::vector<VTableComponentIR> &old_components =
old_record->GetVTableLayout().GetVTableComponents();
- const std::vector<abi_util::VTableComponentIR> &new_components =
+ const std::vector<VTableComponentIR> &new_components =
new_record->GetVTableLayout().GetVTableComponents();
if (old_components.size() > new_components.size()) {
// Something in the vtable got deleted.
@@ -278,18 +280,18 @@ bool AbiDiffHelper::CompareVTables(
}
bool AbiDiffHelper::CompareSizeAndAlignment(
- const abi_util::TypeIR *old_type,
- const abi_util::TypeIR *new_type) {
+ const TypeIR *old_type,
+ const TypeIR *new_type) {
return old_type->GetSize() == new_type->GetSize() &&
old_type->GetAlignment() == new_type->GetAlignment();
}
-DiffStatusPair<std::unique_ptr<abi_util::RecordFieldDiffIR>>
+DiffStatusPair<std::unique_ptr<RecordFieldDiffIR>>
AbiDiffHelper::CompareCommonRecordFields(
- const abi_util::RecordFieldIR *old_field,
- const abi_util::RecordFieldIR *new_field,
+ const RecordFieldIR *old_field,
+ const RecordFieldIR *new_field,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
DiffStatus field_diff_status =
CompareAndDumpTypeDiff(old_field->GetReferencedType(),
@@ -303,7 +305,7 @@ AbiDiffHelper::CompareCommonRecordFields(
(field_diff_status == DiffStatus::direct_diff)) {
return std::make_pair(
DiffStatus::direct_diff,
- std::make_unique<abi_util::RecordFieldDiffIR>(old_field, new_field)
+ std::make_unique<RecordFieldDiffIR>(old_field, new_field)
);
}
return std::make_pair(field_diff_status, nullptr);
@@ -312,46 +314,46 @@ AbiDiffHelper::CompareCommonRecordFields(
GenericFieldDiffInfo<RecordFieldIR, RecordFieldDiffIR>
AbiDiffHelper::CompareRecordFields(
- const std::vector<abi_util::RecordFieldIR> &old_fields,
- const std::vector<abi_util::RecordFieldIR> &new_fields,
+ const std::vector<RecordFieldIR> &old_fields,
+ const std::vector<RecordFieldIR> &new_fields,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
GenericFieldDiffInfo<RecordFieldIR, RecordFieldDiffIR>
diffed_removed_added_fields;
- AbiElementMap<const abi_util::RecordFieldIR *> old_fields_map;
- AbiElementMap<const abi_util::RecordFieldIR *> new_fields_map;
- std::map<uint64_t, const abi_util::RecordFieldIR *> old_fields_offset_map;
- std::map<uint64_t, const abi_util::RecordFieldIR *> new_fields_offset_map;
+ AbiElementMap<const RecordFieldIR *> old_fields_map;
+ AbiElementMap<const RecordFieldIR *> new_fields_map;
+ std::map<uint64_t, const RecordFieldIR *> old_fields_offset_map;
+ std::map<uint64_t, const RecordFieldIR *> new_fields_offset_map;
- abi_util::AddToMap(
+ utils::AddToMap(
&old_fields_map, old_fields,
- [](const abi_util::RecordFieldIR *f) {return f->GetName();},
- [](const abi_util::RecordFieldIR *f) {return f;});
- abi_util::AddToMap(
+ [](const RecordFieldIR *f) {return f->GetName();},
+ [](const RecordFieldIR *f) {return f;});
+ utils::AddToMap(
&new_fields_map, new_fields,
- [](const abi_util::RecordFieldIR *f) {return f->GetName();},
- [](const abi_util::RecordFieldIR *f) {return f;});
- abi_util::AddToMap(
+ [](const RecordFieldIR *f) {return f->GetName();},
+ [](const RecordFieldIR *f) {return f;});
+ utils::AddToMap(
&old_fields_offset_map, old_fields,
- [](const abi_util::RecordFieldIR *f) {return f->GetOffset();},
- [](const abi_util::RecordFieldIR *f) {return f;});
- abi_util::AddToMap(
+ [](const RecordFieldIR *f) {return f->GetOffset();},
+ [](const RecordFieldIR *f) {return f;});
+ utils::AddToMap(
&new_fields_offset_map, new_fields,
- [](const abi_util::RecordFieldIR *f) {return f->GetOffset();},
- [](const abi_util::RecordFieldIR *f) {return f;});
+ [](const RecordFieldIR *f) {return f->GetOffset();},
+ [](const RecordFieldIR *f) {return f;});
// If a field is removed from the map field_name -> offset see if another
// field is present at the same offset and compare the size and type etc,
// remove it from the removed fields if they're compatible.
DiffStatus final_diff_status = DiffStatus::no_diff;
- std::vector<const abi_util::RecordFieldIR *> removed_fields =
- abi_util::FindRemovedElements(old_fields_map, new_fields_map);
+ std::vector<const RecordFieldIR *> removed_fields =
+ utils::FindRemovedElements(old_fields_map, new_fields_map);
- std::vector<const abi_util::RecordFieldIR *> added_fields =
- abi_util::FindRemovedElements(new_fields_map, old_fields_map);
+ std::vector<const RecordFieldIR *> added_fields =
+ utils::FindRemovedElements(new_fields_map, old_fields_map);
auto predicate =
- [&](const abi_util::RecordFieldIR *removed_field,
- std::map<uint64_t, const abi_util::RecordFieldIR *> &field_off_map) {
+ [&](const RecordFieldIR *removed_field,
+ std::map<uint64_t, const RecordFieldIR *> &field_off_map) {
uint64_t old_field_offset = removed_field->GetOffset();
auto corresponding_field_at_same_offset =
field_off_map.find(old_field_offset);
@@ -382,8 +384,8 @@ AbiDiffHelper::CompareRecordFields(
diffed_removed_added_fields.added_fields_ = std::move(added_fields);
std::vector<std::pair<
- const abi_util::RecordFieldIR *, const abi_util::RecordFieldIR *>> cf =
- abi_util::FindCommonElements(old_fields_map, new_fields_map);
+ const RecordFieldIR *, const RecordFieldIR *>> cf =
+ utils::FindCommonElements(old_fields_map, new_fields_map);
bool common_field_diff_exists = false;
for (auto &&common_fields : cf) {
auto diffed_field_ptr = CompareCommonRecordFields(
@@ -409,10 +411,10 @@ AbiDiffHelper::CompareRecordFields(
}
bool AbiDiffHelper::CompareBaseSpecifiers(
- const std::vector<abi_util::CXXBaseSpecifierIR> &old_base_specifiers,
- const std::vector<abi_util::CXXBaseSpecifierIR> &new_base_specifiers,
+ const std::vector<CXXBaseSpecifierIR> &old_base_specifiers,
+ const std::vector<CXXBaseSpecifierIR> &new_base_specifiers,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
if (old_base_specifiers.size() != new_base_specifiers.size()) {
return false;
}
@@ -432,10 +434,10 @@ bool AbiDiffHelper::CompareBaseSpecifiers(
}
DiffStatus AbiDiffHelper::CompareTemplateInfo(
- const std::vector<abi_util::TemplateElementIR> &old_template_elements,
- const std::vector<abi_util::TemplateElementIR> &new_template_elements,
+ const std::vector<TemplateElementIR> &old_template_elements,
+ const std::vector<TemplateElementIR> &new_template_elements,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
uint32_t old_template_size = old_template_elements.size();
uint32_t i = 0;
if (old_template_size != new_template_elements.size()) {
@@ -443,9 +445,9 @@ DiffStatus AbiDiffHelper::CompareTemplateInfo(
}
DiffStatus final_diff_status = DiffStatus::no_diff;
while (i < old_template_size) {
- const abi_util::TemplateElementIR &old_template_element =
+ const TemplateElementIR &old_template_element =
old_template_elements[i];
- const abi_util::TemplateElementIR &new_template_element =
+ const TemplateElementIR &new_template_element =
new_template_elements[i];
auto template_element_diff =
CompareAndDumpTypeDiff(old_template_element.GetReferencedType(),
@@ -480,10 +482,10 @@ static std::vector<const T*> ConvertToConstPtrVector(
return cptr_vec;
}
-static std::vector<abi_util::RecordFieldIR> FixupRemovedFieldTypeIds(
- const std::vector<const abi_util::RecordFieldIR *> &removed_fields,
- const AbiElementMap<const abi_util::TypeIR *> &old_types) {
- std::vector<abi_util::RecordFieldIR> removed_fields_dup;
+static std::vector<RecordFieldIR> FixupRemovedFieldTypeIds(
+ const std::vector<const RecordFieldIR *> &removed_fields,
+ const AbiElementMap<const TypeIR *> &old_types) {
+ std::vector<RecordFieldIR> removed_fields_dup;
for (auto &removed_field : removed_fields) {
removed_fields_dup.emplace_back(*removed_field);
RecordFieldIR &it = removed_fields_dup[removed_fields_dup.size() -1];
@@ -493,17 +495,17 @@ static std::vector<abi_util::RecordFieldIR> FixupRemovedFieldTypeIds(
return removed_fields_dup;
}
-std::vector<std::pair<abi_util::RecordFieldIR, abi_util::RecordFieldIR>>
+std::vector<std::pair<RecordFieldIR, RecordFieldIR>>
AbiDiffHelper::FixupDiffedFieldTypeIds(
- const std::vector<abi_util::RecordFieldDiffIR> &field_diffs) {
- std::vector<std::pair<abi_util::RecordFieldIR, abi_util::RecordFieldIR>>
+ const std::vector<RecordFieldDiffIR> &field_diffs) {
+ std::vector<std::pair<RecordFieldIR, RecordFieldIR>>
diffed_fields_dup;
for (auto &field_diff : field_diffs) {
diffed_fields_dup.emplace_back(*(field_diff.old_field_),
*(field_diff.new_field_));
auto &it = diffed_fields_dup[diffed_fields_dup.size() - 1];
- abi_util::RecordFieldIR &old_field = it.first;
- abi_util::RecordFieldIR &new_field = it.second;
+ RecordFieldIR &old_field = it.first;
+ RecordFieldIR &new_field = it.second;
old_field.SetReferencedType(
ConvertTypeIdToString(old_types_, old_field.GetReferencedType()));
new_field.SetReferencedType(
@@ -513,10 +515,10 @@ AbiDiffHelper::FixupDiffedFieldTypeIds(
}
DiffStatus AbiDiffHelper::CompareFunctionTypes(
- const abi_util::FunctionTypeIR *old_type,
- const abi_util::FunctionTypeIR *new_type,
+ const FunctionTypeIR *old_type,
+ const FunctionTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
DiffStatus param_diffs = CompareFunctionParameters(old_type->GetParameters(),
new_type->GetParameters(),
type_queue, diff_kind);
@@ -539,11 +541,11 @@ DiffStatus AbiDiffHelper::CompareFunctionTypes(
}
DiffStatus AbiDiffHelper::CompareRecordTypes(
- const abi_util::RecordTypeIR *old_type,
- const abi_util::RecordTypeIR *new_type,
+ const RecordTypeIR *old_type,
+ const RecordTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
- auto record_type_diff_ir = std::make_unique<abi_util::RecordTypeDiffIR>();
+ DiffMessageIR::DiffKind diff_kind) {
+ auto record_type_diff_ir = std::make_unique<RecordTypeDiffIR>();
// Compare names.
if (!old_type->IsAnonymous() && !new_type->IsAnonymous() &&
old_type->GetUniqueId() != new_type->GetUniqueId()) {
@@ -556,14 +558,14 @@ DiffStatus AbiDiffHelper::CompareRecordTypes(
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>(
+ std::make_unique<AccessSpecifierDiffIR>(
old_type->GetAccess(), new_type->GetAccess()));
}
if (!CompareSizeAndAlignment(old_type, new_type)) {
final_diff_status = DiffStatus::indirect_diff;
record_type_diff_ir->SetTypeDiff(
- std::make_unique<abi_util::TypeDiffIR>(
+ std::make_unique<TypeDiffIR>(
std::make_pair(old_type->GetSize(), new_type->GetSize()),
std::make_pair(old_type->GetAlignment(),
new_type->GetAlignment())));
@@ -571,7 +573,7 @@ DiffStatus AbiDiffHelper::CompareRecordTypes(
if (!CompareVTables(old_type, new_type)) {
final_diff_status = DiffStatus::indirect_diff;
record_type_diff_ir->SetVTableLayoutDiff(
- std::make_unique<abi_util::VTableLayoutDiffIR>(
+ std::make_unique<VTableLayoutDiffIR>(
old_type->GetVTableLayout(), new_type->GetVTableLayout()));
}
auto &old_fields_dup = old_type->GetFields();
@@ -581,15 +583,15 @@ DiffStatus AbiDiffHelper::CompareRecordTypes(
// TODO: Combine this with base class diffs as well.
final_diff_status = final_diff_status | field_status_and_diffs.diff_status_;
- std::vector<abi_util::CXXBaseSpecifierIR> old_bases = old_type->GetBases();
- std::vector<abi_util::CXXBaseSpecifierIR> new_bases = new_type->GetBases();
+ std::vector<CXXBaseSpecifierIR> old_bases = old_type->GetBases();
+ std::vector<CXXBaseSpecifierIR> new_bases = new_type->GetBases();
if (!CompareBaseSpecifiers(old_bases, new_bases, type_queue, diff_kind) &&
ir_diff_dumper_) {
ReplaceReferencesOtherTypeIdWithName(old_types_, old_bases);
ReplaceReferencesOtherTypeIdWithName(new_types_, new_bases);
record_type_diff_ir->SetBaseSpecifierDiffs (
- std::make_unique<abi_util::CXXBaseSpecifierDiffIR>(old_bases,
+ std::make_unique<CXXBaseSpecifierDiffIR>(old_bases,
new_bases));
}
if (ir_diff_dumper_) {
@@ -597,20 +599,20 @@ DiffStatus AbiDiffHelper::CompareRecordTypes(
// type ids -> type strings.
std::vector<std::pair<RecordFieldIR, RecordFieldIR>> field_diff_dups =
FixupDiffedFieldTypeIds(field_status_and_diffs.diffed_fields_);
- std::vector<abi_util::RecordFieldDiffIR> field_diffs_fixed =
- ConvertToDiffContainerVector<abi_util::RecordFieldDiffIR,
- abi_util::RecordFieldIR>(field_diff_dups);
+ std::vector<RecordFieldDiffIR> field_diffs_fixed =
+ ConvertToDiffContainerVector<RecordFieldDiffIR,
+ RecordFieldIR>(field_diff_dups);
- std::vector<abi_util::RecordFieldIR> field_removed_dups =
+ std::vector<RecordFieldIR> field_removed_dups =
FixupRemovedFieldTypeIds(field_status_and_diffs.removed_fields_,
old_types_);
- std::vector<const abi_util::RecordFieldIR *> fields_removed_fixed =
+ std::vector<const RecordFieldIR *> fields_removed_fixed =
ConvertToConstPtrVector(field_removed_dups);
- std::vector<abi_util::RecordFieldIR> field_added_dups =
+ std::vector<RecordFieldIR> field_added_dups =
FixupRemovedFieldTypeIds(field_status_and_diffs.added_fields_,
new_types_);
- std::vector<const abi_util::RecordFieldIR *> fields_added_fixed =
+ std::vector<const RecordFieldIR *> fields_added_fixed =
ConvertToConstPtrVector(field_added_dups);
record_type_diff_ir->SetFieldDiffs(std::move(field_diffs_fixed));
@@ -637,30 +639,30 @@ DiffStatus AbiDiffHelper::CompareRecordTypes(
}
DiffStatus AbiDiffHelper::CompareLvalueReferenceTypes(
- const abi_util::LvalueReferenceTypeIR *old_type,
- const abi_util::LvalueReferenceTypeIR *new_type,
+ const LvalueReferenceTypeIR *old_type,
+ const LvalueReferenceTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
return CompareAndDumpTypeDiff(old_type->GetReferencedType(),
new_type->GetReferencedType(),
type_queue, diff_kind);
}
DiffStatus AbiDiffHelper::CompareRvalueReferenceTypes(
- const abi_util::RvalueReferenceTypeIR *old_type,
- const abi_util::RvalueReferenceTypeIR *new_type,
+ const RvalueReferenceTypeIR *old_type,
+ const RvalueReferenceTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
return CompareAndDumpTypeDiff(old_type->GetReferencedType(),
new_type->GetReferencedType(),
type_queue, diff_kind);
}
DiffStatus AbiDiffHelper::CompareQualifiedTypes(
- const abi_util::QualifiedTypeIR *old_type,
- const abi_util::QualifiedTypeIR *new_type,
+ const QualifiedTypeIR *old_type,
+ const QualifiedTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
// If all the qualifiers are not the same, return direct_diff, else
// recursively compare the unqualified types.
if (old_type->IsConst() != new_type->IsConst() ||
@@ -674,10 +676,10 @@ DiffStatus AbiDiffHelper::CompareQualifiedTypes(
}
DiffStatus AbiDiffHelper::ComparePointerTypes(
- const abi_util::PointerTypeIR *old_type,
- const abi_util::PointerTypeIR *new_type,
+ const PointerTypeIR *old_type,
+ const PointerTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
// The following need to be the same for two pointer types to be considered
// equivalent:
// 1) Number of pointer indirections are the same.
@@ -689,8 +691,8 @@ DiffStatus AbiDiffHelper::ComparePointerTypes(
}
DiffStatus AbiDiffHelper::CompareBuiltinTypes(
- const abi_util::BuiltinTypeIR *old_type,
- const abi_util::BuiltinTypeIR *new_type) {
+ const BuiltinTypeIR *old_type,
+ const BuiltinTypeIR *new_type) {
// If the size, alignment and is_unsigned are the same, return no_diff
// else return direct_diff.
if (!CompareSizeAndAlignment(old_type, new_type) ||
@@ -702,18 +704,18 @@ DiffStatus AbiDiffHelper::CompareBuiltinTypes(
}
DiffStatus AbiDiffHelper::CompareFunctionParameters(
- const std::vector<abi_util::ParamIR> &old_parameters,
- const std::vector<abi_util::ParamIR> &new_parameters,
+ const std::vector<ParamIR> &old_parameters,
+ const std::vector<ParamIR> &new_parameters,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
size_t old_parameters_size = old_parameters.size();
if (old_parameters_size != new_parameters.size()) {
return DiffStatus::direct_diff;
}
uint64_t i = 0;
while (i < old_parameters_size) {
- const abi_util::ParamIR &old_parameter = old_parameters.at(i);
- const abi_util::ParamIR &new_parameter = new_parameters.at(i);
+ const ParamIR &old_parameter = old_parameters.at(i);
+ const ParamIR &new_parameter = new_parameters.at(i);
if ((CompareAndDumpTypeDiff(old_parameter.GetReferencedType(),
new_parameter.GetReferencedType(),
type_queue, diff_kind) ==
@@ -727,68 +729,68 @@ DiffStatus AbiDiffHelper::CompareFunctionParameters(
}
DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
- const abi_util::TypeIR *old_type, const abi_util::TypeIR *new_type,
- abi_util::LinkableMessageKind kind, std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
- if (kind == abi_util::LinkableMessageKind::BuiltinTypeKind) {
+ const TypeIR *old_type, const TypeIR *new_type,
+ LinkableMessageKind kind, std::deque<std::string> *type_queue,
+ DiffMessageIR::DiffKind diff_kind) {
+ if (kind == LinkableMessageKind::BuiltinTypeKind) {
return CompareBuiltinTypes(
- static_cast<const abi_util::BuiltinTypeIR *>(old_type),
- static_cast<const abi_util::BuiltinTypeIR *>(new_type));
+ static_cast<const BuiltinTypeIR *>(old_type),
+ static_cast<const BuiltinTypeIR *>(new_type));
}
- if (kind == abi_util::LinkableMessageKind::QualifiedTypeKind) {
+ if (kind == LinkableMessageKind::QualifiedTypeKind) {
return CompareQualifiedTypes(
- static_cast<const abi_util::QualifiedTypeIR *>(old_type),
- static_cast<const abi_util::QualifiedTypeIR *>(new_type),
+ static_cast<const QualifiedTypeIR *>(old_type),
+ static_cast<const QualifiedTypeIR *>(new_type),
type_queue, diff_kind);
}
- if (kind == abi_util::LinkableMessageKind::EnumTypeKind) {
+ if (kind == LinkableMessageKind::EnumTypeKind) {
return CompareEnumTypes(
- static_cast<const abi_util::EnumTypeIR *>(old_type),
- static_cast<const abi_util::EnumTypeIR *>(new_type),
+ static_cast<const EnumTypeIR *>(old_type),
+ static_cast<const EnumTypeIR *>(new_type),
type_queue, diff_kind);
}
- if (kind == abi_util::LinkableMessageKind::LvalueReferenceTypeKind) {
+ if (kind == LinkableMessageKind::LvalueReferenceTypeKind) {
return CompareLvalueReferenceTypes(
- static_cast<const abi_util::LvalueReferenceTypeIR *>(old_type),
- static_cast<const abi_util::LvalueReferenceTypeIR *>(new_type),
+ static_cast<const LvalueReferenceTypeIR *>(old_type),
+ static_cast<const LvalueReferenceTypeIR *>(new_type),
type_queue, diff_kind);
}
- if (kind == abi_util::LinkableMessageKind::RvalueReferenceTypeKind) {
+ if (kind == LinkableMessageKind::RvalueReferenceTypeKind) {
return CompareRvalueReferenceTypes(
- static_cast<const abi_util::RvalueReferenceTypeIR *>(old_type),
- static_cast<const abi_util::RvalueReferenceTypeIR *>(new_type),
+ static_cast<const RvalueReferenceTypeIR *>(old_type),
+ static_cast<const RvalueReferenceTypeIR *>(new_type),
type_queue, diff_kind);
}
- if (kind == abi_util::LinkableMessageKind::PointerTypeKind) {
+ if (kind == LinkableMessageKind::PointerTypeKind) {
return ComparePointerTypes(
- static_cast<const abi_util::PointerTypeIR *>(old_type),
- static_cast<const abi_util::PointerTypeIR *>(new_type),
+ static_cast<const PointerTypeIR *>(old_type),
+ static_cast<const PointerTypeIR *>(new_type),
type_queue, diff_kind);
}
- if (kind == abi_util::LinkableMessageKind::RecordTypeKind) {
+ if (kind == LinkableMessageKind::RecordTypeKind) {
return CompareRecordTypes(
- static_cast<const abi_util::RecordTypeIR *>(old_type),
- static_cast<const abi_util::RecordTypeIR *>(new_type),
+ static_cast<const RecordTypeIR *>(old_type),
+ static_cast<const RecordTypeIR *>(new_type),
type_queue, diff_kind);
}
- if (kind == abi_util::LinkableMessageKind::FunctionTypeKind) {
+ if (kind == LinkableMessageKind::FunctionTypeKind) {
return CompareFunctionTypes(
- static_cast<const abi_util::FunctionTypeIR *>(old_type),
- static_cast<const abi_util::FunctionTypeIR *>(new_type),
+ static_cast<const FunctionTypeIR *>(old_type),
+ static_cast<const FunctionTypeIR *>(new_type),
type_queue, diff_kind);
}
return DiffStatus::no_diff;
}
static DiffStatus CompareDistinctKindMessages(
- const abi_util::TypeIR *old_type, const abi_util::TypeIR *new_type) {
+ const TypeIR *old_type, const TypeIR *new_type) {
// For these types to be considered ABI compatible, the very least requirement
// is that their sizes and alignments should be equal.
// TODO: Fill in
@@ -798,7 +800,7 @@ static DiffStatus CompareDistinctKindMessages(
DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
const std::string &old_type_id, const std::string &new_type_id,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind) {
+ DiffMessageIR::DiffKind diff_kind) {
// Check the map for type ids which have already been compared
// These types have already been diffed, return without further comparison.
if (!type_cache_->insert(old_type_id + new_type_id).second) {
@@ -808,9 +810,9 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
TypeQueueCheckAndPushBack(
type_queue, ConvertTypeIdToString(old_types_,old_type_id));
- AbiElementMap<const abi_util::TypeIR *>::const_iterator old_it =
+ AbiElementMap<const TypeIR *>::const_iterator old_it =
old_types_.find(old_type_id);
- AbiElementMap<const abi_util::TypeIR *>::const_iterator new_it =
+ AbiElementMap<const TypeIR *>::const_iterator new_it =
new_types_.find(new_type_id);
if (old_it == old_types_.end() || new_it == new_types_.end()) {
@@ -822,8 +824,8 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
return DiffStatus::no_diff;
}
- abi_util::LinkableMessageKind old_kind = old_it->second->GetKind();
- abi_util::LinkableMessageKind new_kind = new_it->second->GetKind();
+ LinkableMessageKind old_kind = old_it->second->GetKind();
+ LinkableMessageKind new_kind = new_it->second->GetKind();
DiffStatus diff_status = DiffStatus::no_diff;
if (old_kind != new_kind) {
diff_status = CompareDistinctKindMessages(old_it->second, new_it->second);
@@ -846,4 +848,6 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff(
return diff_status;
}
-} // namespace abi_util
+
+} // namespace repr
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/repr/abi_diff_helpers.h b/vndk/tools/header-checker/src/repr/abi_diff_helpers.h
index 2b4ab7029..0425709ac 100644
--- a/vndk/tools/header-checker/src/repr/abi_diff_helpers.h
+++ b/vndk/tools/header-checker/src/repr/abi_diff_helpers.h
@@ -20,9 +20,12 @@
#include <deque>
+namespace header_checker {
+namespace repr {
+
+
// Classes which act as middle-men between clang AST parsing routines and
// message format specific dumpers.
-namespace abi_util {
using MergeStatus = TextFormatToIRReader::MergeStatus;
@@ -73,11 +76,11 @@ struct DiffPolicyOptions {
class AbiDiffHelper {
public:
AbiDiffHelper(
- const AbiElementMap<const abi_util::TypeIR *> &old_types,
- const AbiElementMap<const abi_util::TypeIR *> &new_types,
+ const AbiElementMap<const TypeIR *> &old_types,
+ const AbiElementMap<const TypeIR *> &new_types,
const DiffPolicyOptions &diff_policy_options,
std::set<std::string> *type_cache,
- abi_util::IRDiffDumper *ir_diff_dumper = nullptr,
+ IRDiffDumper *ir_diff_dumper = nullptr,
AbiElementMap<MergeStatus> *local_to_global_type_id_map = nullptr)
: old_types_(old_types), new_types_(new_types),
diff_policy_options_(diff_policy_options), type_cache_(type_cache),
@@ -87,113 +90,113 @@ class AbiDiffHelper {
DiffStatus CompareAndDumpTypeDiff(
const std::string &old_type_str, const std::string &new_type_str,
std::deque<std::string> *type_queue = nullptr,
- abi_util::IRDiffDumper::DiffKind diff_kind = DiffMessageIR::Unreferenced);
+ IRDiffDumper::DiffKind diff_kind = DiffMessageIR::Unreferenced);
DiffStatus CompareAndDumpTypeDiff(
- const abi_util::TypeIR *old_type, const abi_util::TypeIR *new_type,
- abi_util::LinkableMessageKind kind,
+ const TypeIR *old_type, const TypeIR *new_type,
+ LinkableMessageKind kind,
std::deque<std::string> *type_queue = nullptr,
- abi_util::IRDiffDumper::DiffKind diff_kind = DiffMessageIR::Unreferenced);
+ IRDiffDumper::DiffKind diff_kind = DiffMessageIR::Unreferenced);
- DiffStatus CompareRecordTypes(const abi_util::RecordTypeIR *old_type,
- const abi_util::RecordTypeIR *new_type,
+ DiffStatus CompareRecordTypes(const RecordTypeIR *old_type,
+ const RecordTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ IRDiffDumper::DiffKind diff_kind);
- DiffStatus CompareQualifiedTypes(const abi_util::QualifiedTypeIR *old_type,
- const abi_util::QualifiedTypeIR *new_type,
+ DiffStatus CompareQualifiedTypes(const QualifiedTypeIR *old_type,
+ const QualifiedTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ IRDiffDumper::DiffKind diff_kind);
- DiffStatus ComparePointerTypes(const abi_util::PointerTypeIR *old_type,
- const abi_util::PointerTypeIR *new_type,
+ DiffStatus ComparePointerTypes(const PointerTypeIR *old_type,
+ const PointerTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ IRDiffDumper::DiffKind diff_kind);
DiffStatus CompareLvalueReferenceTypes(
- const abi_util::LvalueReferenceTypeIR *old_type,
- const abi_util::LvalueReferenceTypeIR *new_type,
+ const LvalueReferenceTypeIR *old_type,
+ const LvalueReferenceTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ IRDiffDumper::DiffKind diff_kind);
DiffStatus CompareRvalueReferenceTypes(
- const abi_util::RvalueReferenceTypeIR *old_type,
- const abi_util::RvalueReferenceTypeIR *new_type,
+ const RvalueReferenceTypeIR *old_type,
+ const RvalueReferenceTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ IRDiffDumper::DiffKind diff_kind);
- DiffStatus CompareBuiltinTypes(const abi_util::BuiltinTypeIR *old_type,
- const abi_util::BuiltinTypeIR *new_type);
+ DiffStatus CompareBuiltinTypes(const BuiltinTypeIR *old_type,
+ const BuiltinTypeIR *new_type);
static void CompareEnumFields(
- const std::vector<abi_util::EnumFieldIR> &old_fields,
- const std::vector<abi_util::EnumFieldIR> &new_fields,
- abi_util::EnumTypeDiffIR *enum_type_diff_ir);
+ const std::vector<EnumFieldIR> &old_fields,
+ const std::vector<EnumFieldIR> &new_fields,
+ EnumTypeDiffIR *enum_type_diff_ir);
- DiffStatus CompareEnumTypes(const abi_util::EnumTypeIR *old_type,
- const abi_util::EnumTypeIR *new_type,
+ DiffStatus CompareEnumTypes(const EnumTypeIR *old_type,
+ const EnumTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ IRDiffDumper::DiffKind diff_kind);
- DiffStatus CompareFunctionTypes(const abi_util::FunctionTypeIR *old_type,
- const abi_util::FunctionTypeIR *new_type,
+ DiffStatus CompareFunctionTypes(const FunctionTypeIR *old_type,
+ const FunctionTypeIR *new_type,
std::deque<std::string> *type_queue,
- abi_util::DiffMessageIR::DiffKind diff_kind);
+ DiffMessageIR::DiffKind diff_kind);
void ReplaceRemovedFieldTypeIdsWithTypeNames(
- std::vector<abi_util::RecordFieldIR *> *removed_fields);
+ std::vector<RecordFieldIR *> *removed_fields);
void ReplaceDiffedFieldTypeIdsWithTypeNames(
- abi_util::RecordFieldDiffIR *diffed_field);
+ RecordFieldDiffIR *diffed_field);
- std::vector<std::pair<abi_util::RecordFieldIR, abi_util::RecordFieldIR>>
+ std::vector<std::pair<RecordFieldIR, RecordFieldIR>>
FixupDiffedFieldTypeIds(
- const std::vector<abi_util::RecordFieldDiffIR> &field_diffs);
+ const std::vector<RecordFieldDiffIR> &field_diffs);
- DiffStatusPair<std::unique_ptr<abi_util::RecordFieldDiffIR>>
+ DiffStatusPair<std::unique_ptr<RecordFieldDiffIR>>
CompareCommonRecordFields(
- const abi_util::RecordFieldIR *old_field,
- const abi_util::RecordFieldIR *new_field,
+ const RecordFieldIR *old_field,
+ const RecordFieldIR *new_field,
std::deque<std::string> *type_queue,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ IRDiffDumper::DiffKind diff_kind);
- GenericFieldDiffInfo<abi_util::RecordFieldIR, abi_util::RecordFieldDiffIR>
+ GenericFieldDiffInfo<RecordFieldIR, RecordFieldDiffIR>
CompareRecordFields(
- const std::vector<abi_util::RecordFieldIR> &old_fields,
- const std::vector<abi_util::RecordFieldIR> &new_fields,
+ const std::vector<RecordFieldIR> &old_fields,
+ const std::vector<RecordFieldIR> &new_fields,
std::deque<std::string> *type_queue,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ IRDiffDumper::DiffKind diff_kind);
DiffStatus CompareFunctionParameters(
- const std::vector<abi_util::ParamIR> &old_parameters,
- const std::vector<abi_util::ParamIR> &new_parameters,
+ const std::vector<ParamIR> &old_parameters,
+ const std::vector<ParamIR> &new_parameters,
std::deque<std::string> *type_queue,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ IRDiffDumper::DiffKind diff_kind);
bool CompareBaseSpecifiers(
- const std::vector<abi_util::CXXBaseSpecifierIR> &old_base_specifiers,
- const std::vector<abi_util::CXXBaseSpecifierIR> &new_base_specifiers,
+ const std::vector<CXXBaseSpecifierIR> &old_base_specifiers,
+ const std::vector<CXXBaseSpecifierIR> &new_base_specifiers,
std::deque<std::string> *type_queue,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ IRDiffDumper::DiffKind diff_kind);
- bool CompareVTables(const abi_util::RecordTypeIR *old_record,
- const abi_util::RecordTypeIR *new_record);
+ bool CompareVTables(const RecordTypeIR *old_record,
+ const RecordTypeIR *new_record);
bool CompareVTableComponents(
- const abi_util::VTableComponentIR &old_component,
- const abi_util::VTableComponentIR &new_component);
+ const VTableComponentIR &old_component,
+ const VTableComponentIR &new_component);
DiffStatus CompareTemplateInfo(
- const std::vector<abi_util::TemplateElementIR> &old_template_elements,
- const std::vector<abi_util::TemplateElementIR> &new_template_elements,
+ const std::vector<TemplateElementIR> &old_template_elements,
+ const std::vector<TemplateElementIR> &new_template_elements,
std::deque<std::string> *type_queue,
- abi_util::IRDiffDumper::DiffKind diff_kind);
+ IRDiffDumper::DiffKind diff_kind);
- bool CompareSizeAndAlignment(const abi_util::TypeIR *old_ti,
- const abi_util::TypeIR *new_ti);
+ bool CompareSizeAndAlignment(const TypeIR *old_ti,
+ const TypeIR *new_ti);
template <typename DiffType, typename DiffElement>
bool AddToDiff(DiffType *mutable_diff, const DiffElement *oldp,
@@ -201,17 +204,20 @@ class AbiDiffHelper {
std::deque<std::string> *type_queue = nullptr);
protected:
- const AbiElementMap<const abi_util::TypeIR *> &old_types_;
- const AbiElementMap<const abi_util::TypeIR *> &new_types_;
+ const AbiElementMap<const TypeIR *> &old_types_;
+ const AbiElementMap<const TypeIR *> &new_types_;
const DiffPolicyOptions &diff_policy_options_;
std::set<std::string> *type_cache_;
- abi_util::IRDiffDumper *ir_diff_dumper_;
+ IRDiffDumper *ir_diff_dumper_;
AbiElementMap<MergeStatus> *local_to_global_type_id_map_;
};
void ReplaceTypeIdsWithTypeNames(
const AbiElementMap<const TypeIR *> &type_graph, LinkableMessageIR *lm);
-} // namespace abi_util
+
+} // namespace repr
+} // namespace header_checker
+
#endif // ABI_DIFF_HELPERS_H_
diff --git a/vndk/tools/header-checker/src/repr/ir_representation.cpp b/vndk/tools/header-checker/src/repr/ir_representation.cpp
index ab8a84b6f..a9c9e4341 100644
--- a/vndk/tools/header-checker/src/repr/ir_representation.cpp
+++ b/vndk/tools/header-checker/src/repr/ir_representation.cpp
@@ -33,7 +33,10 @@
#include <memory>
-namespace abi_util {
+
+namespace header_checker {
+namespace repr {
+
using MergeStatus = TextFormatToIRReader::MergeStatus;
@@ -586,4 +589,6 @@ bool TextFormatToIRReader::IsLinkableMessageInExportedHeaders(
exported_headers_->end();
}
-} // namespace abi_util
+
+} // namespace repr
+} // header_checker
diff --git a/vndk/tools/header-checker/src/repr/ir_representation.h b/vndk/tools/header-checker/src/repr/ir_representation.h
index 3f5a9bd55..b8e504acf 100644
--- a/vndk/tools/header-checker/src/repr/ir_representation.h
+++ b/vndk/tools/header-checker/src/repr/ir_representation.h
@@ -26,9 +26,12 @@
#include <vector>
+namespace header_checker {
+namespace repr {
+
+
// Classes which act as middle-men between clang AST parsing routines and
// message format specific dumpers.
-namespace abi_util {
template <typename T>
using AbiElementMap = std::map<std::string, T>;
@@ -1457,6 +1460,9 @@ class IRDiffDumper {
const std::string &dump_path_;
};
-} // namespace abi_util
+
+} // namespace repr
+} // namespace header_checker
+
#endif // IR_REPRESENTATION_H_
diff --git a/vndk/tools/header-checker/src/repr/json/ir_representation_json.cpp b/vndk/tools/header-checker/src/repr/json/ir_representation_json.cpp
index e7d02d783..3d679cf0e 100644
--- a/vndk/tools/header-checker/src/repr/json/ir_representation_json.cpp
+++ b/vndk/tools/header-checker/src/repr/json/ir_representation_json.cpp
@@ -25,7 +25,9 @@
#include <string>
-namespace abi_util {
+namespace header_checker {
+namespace repr {
+
// Conversion between IR enums and JSON strings.
static const std::map<AccessSpecifierIR, std::string> access_ir_to_json{
@@ -937,4 +939,6 @@ void JsonToIRReader::ReadElfObjects(const JsonObjectRef &tu) {
}
}
-} // namespace abi_util
+
+} // namespace repr
+} // header_checker
diff --git a/vndk/tools/header-checker/src/repr/json/ir_representation_json.h b/vndk/tools/header-checker/src/repr/json/ir_representation_json.h
index 6ef215f39..7099cabe6 100644
--- a/vndk/tools/header-checker/src/repr/json/ir_representation_json.h
+++ b/vndk/tools/header-checker/src/repr/json/ir_representation_json.h
@@ -20,9 +20,12 @@
#include <json/value.h>
+namespace header_checker {
+namespace repr {
+
+
// Classes which act as middle-men between clang AST parsing routines and
// message format specific dumpers.
-namespace abi_util {
// These classes wrap constructors of Json::Value.
class JsonArray : public Json::Value {
@@ -284,6 +287,9 @@ class JsonToIRReader : public TextFormatToIRReader {
static EnumTypeIR EnumTypeJsonToIR(const JsonObjectRef &enum_type);
};
-} // namespace abi_util
+
+} // namespace repr
+} // namespace header_checker
+
#endif // IR_REPRESENTATION_JSON_H_
diff --git a/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.cpp b/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.cpp
index 1a6f84f69..62dc75153 100644
--- a/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.cpp
+++ b/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.cpp
@@ -22,7 +22,9 @@
#include <string>
-namespace abi_util {
+namespace header_checker {
+namespace repr {
+
void ProtobufTextFormatToIRReader::ReadTypeInfo(
const abi_dump::BasicNamedAndTypedDecl &type_info, TypeIR *typep) {
@@ -374,7 +376,7 @@ void ProtobufTextFormatToIRReader::ReadElfObjects(
}
bool IRToProtobufConverter::AddTemplateInformation(
- abi_dump::TemplateInfo *ti, const abi_util::TemplatedArtifactIR *ta) {
+ abi_dump::TemplateInfo *ti, const TemplatedArtifactIR *ta) {
for (auto &&template_element : ta->GetTemplateElements()) {
abi_dump::TemplateElement *added_element = ti->add_elements();
if (!added_element) {
@@ -498,7 +500,7 @@ bool IRToProtobufConverter::AddVTableLayout(
bool IRToProtobufConverter::AddTagTypeInfo(
abi_dump::TagType *tag_type_protobuf,
- const abi_util::TagTypeIR *tag_type_ir) {
+ const TagTypeIR *tag_type_ir) {
if (!tag_type_protobuf || !tag_type_ir) {
return false;
}
@@ -1491,4 +1493,6 @@ bool ProtobufIRDiffDumper::Dump() {
return google::protobuf::TextFormat::Print(*diff_tu_.get(), &text_os);
}
-} // namespace abi_util
+
+} // namespace repr
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.h b/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.h
index 034fe79ee..8f55eb822 100644
--- a/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.h
+++ b/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.h
@@ -28,9 +28,12 @@
#include <google/protobuf/io/zero_copy_stream_impl.h>
+namespace header_checker {
+namespace repr {
+
+
// Classes which act as middle-men between clang AST parsing routines and
// message format specific dumpers.
-namespace abi_util {
inline abi_diff::CompatibilityStatus CompatibilityStatusIRToProtobuf(
CompatibilityStatusIR status) {
@@ -198,7 +201,7 @@ inline VTableComponentIR::Kind VTableComponentKindProtobufToIR(
class IRToProtobufConverter {
private:
static bool AddTemplateInformation(
- abi_dump::TemplateInfo *ti, const abi_util::TemplatedArtifactIR *ta);
+ abi_dump::TemplateInfo *ti, const TemplatedArtifactIR *ta);
static bool AddTypeInfo(
abi_dump::BasicNamedAndTypedDecl *type_info, const TypeIR *typep);
@@ -480,6 +483,8 @@ class ProtobufIRDiffDumper : public IRDiffDumper {
std::unique_ptr<abi_diff::TranslationUnitDiff> diff_tu_;
};
-} // namespace abi_util
+
+} // namespace repr
+} // namespace header_checker
#endif // IR_REPRESENTATION_PROTOBUF_H_
diff --git a/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set.cpp b/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set.cpp
index 94b239577..873be2dff 100644
--- a/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set.cpp
+++ b/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set.cpp
@@ -22,11 +22,12 @@
#include <cxxabi.h>
-namespace abi_util {
+namespace header_checker {
+namespace repr {
static inline bool IsCppSymbol(const std::string &name) {
- return StartsWith(name, "_Z");
+ return utils::StartsWith(name, "_Z");
}
@@ -74,7 +75,7 @@ bool ExportedSymbolSet::HasSymbol(const std::string &name) const {
}
if (IsCppSymbol(name) && HasDemangledCppSymbolsOrPatterns()) {
- std::unique_ptr<char, FreeDeleter> demangled_name_c_str(
+ std::unique_ptr<char, utils::FreeDeleter> demangled_name_c_str(
abi::__cxa_demangle(name.c_str(), nullptr, nullptr, nullptr));
if (demangled_name_c_str) {
@@ -96,4 +97,5 @@ bool ExportedSymbolSet::HasSymbol(const std::string &name) const {
}
-} // namespace abi_util
+} // namespace repr
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set.h b/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set.h
index e95920852..a5ca03def 100644
--- a/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set.h
+++ b/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set.h
@@ -23,7 +23,8 @@
#include <string>
-namespace abi_util {
+namespace header_checker {
+namespace repr {
class ExportedSymbolSet {
@@ -94,7 +95,8 @@ class ExportedSymbolSet {
};
-} // namespace abi_util
+} // namespace repr
+} // namespace header_checker
#endif // EXPORTED_SYMBOL_SET_
diff --git a/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set_test.cpp b/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set_test.cpp
index ede545d59..ad5cbd46f 100644
--- a/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set_test.cpp
+++ b/vndk/tools/header-checker/src/repr/symbol/exported_symbol_set_test.cpp
@@ -19,7 +19,8 @@
#include <gtest/gtest.h>
-namespace abi_util {
+namespace header_checker {
+namespace repr {
TEST(ExportedSymbolSetTest, AddFunction) {
@@ -129,4 +130,5 @@ TEST(ExportedSymbolSetTest, HasSymbol) {
}
-} // namespace abi_util
+} // namespace repr
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/repr/symbol/so_file_parser.cpp b/vndk/tools/header-checker/src/repr/symbol/so_file_parser.cpp
index 8e8b373c8..451c139f1 100644
--- a/vndk/tools/header-checker/src/repr/symbol/so_file_parser.cpp
+++ b/vndk/tools/header-checker/src/repr/symbol/so_file_parser.cpp
@@ -22,7 +22,8 @@
#include <llvm/Object/SymbolSize.h>
-namespace abi_util {
+namespace header_checker {
+namespace repr {
template <typename T>
@@ -37,13 +38,13 @@ static inline T UnWrap(llvm::Expected<T> value_or_error) {
}
-static abi_util::ElfSymbolIR::ElfSymbolBinding
+static ElfSymbolIR::ElfSymbolBinding
LLVMToIRSymbolBinding(unsigned char binding) {
switch (binding) {
case llvm::ELF::STB_GLOBAL:
- return abi_util::ElfSymbolIR::ElfSymbolBinding::Global;
+ return ElfSymbolIR::ElfSymbolBinding::Global;
case llvm::ELF::STB_WEAK:
- return abi_util::ElfSymbolIR::ElfSymbolBinding::Weak;
+ return ElfSymbolIR::ElfSymbolBinding::Weak;
}
assert(0);
}
@@ -94,7 +95,7 @@ ELFSoFileParser<T>::ELFSoFileParser(const llvm::object::ELFObjectFile<T> *obj) {
continue;
}
- abi_util::ElfSymbolIR::ElfSymbolBinding symbol_binding =
+ ElfSymbolIR::ElfSymbolBinding symbol_binding =
LLVMToIRSymbolBinding(elf_sym->getBinding());
std::string symbol_name = UnWrap(symbol_it.getName());
@@ -156,4 +157,5 @@ std::unique_ptr<SoFileParser> SoFileParser::Create(
}
-} // namespace abi_util
+} // namespace repr
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/repr/symbol/so_file_parser.h b/vndk/tools/header-checker/src/repr/symbol/so_file_parser.h
index 5a68dd6ad..89612c2c0 100644
--- a/vndk/tools/header-checker/src/repr/symbol/so_file_parser.h
+++ b/vndk/tools/header-checker/src/repr/symbol/so_file_parser.h
@@ -22,7 +22,8 @@
#include <string>
-namespace abi_util {
+namespace header_checker {
+namespace repr {
class SoFileParser {
@@ -35,7 +36,8 @@ class SoFileParser {
};
-} // namespace abi_util
+} // namespace repr
+} // namespace header_checker
#endif // SO_FILE_PARSER_H_
diff --git a/vndk/tools/header-checker/src/repr/symbol/version_script_parser.cpp b/vndk/tools/header-checker/src/repr/symbol/version_script_parser.cpp
index f8afed2b1..98ecea3f3 100644
--- a/vndk/tools/header-checker/src/repr/symbol/version_script_parser.cpp
+++ b/vndk/tools/header-checker/src/repr/symbol/version_script_parser.cpp
@@ -25,7 +25,8 @@
#include <vector>
-namespace abi_util {
+namespace header_checker {
+namespace repr {
static constexpr char DEFAULT_ARCH[] = "arm64";
@@ -38,7 +39,7 @@ inline std::string GetIntroducedArchTag(const std::string &arch) {
VersionScriptParser::VersionScriptParser()
: arch_(DEFAULT_ARCH), introduced_arch_tag_(GetIntroducedArchTag(arch_)),
- api_level_(FUTURE_API_LEVEL), stream_(nullptr), line_no_(0) {}
+ api_level_(utils::FUTURE_API_LEVEL), stream_(nullptr), line_no_(0) {}
void VersionScriptParser::SetArch(const std::string &arch) {
@@ -61,7 +62,7 @@ VersionScriptParser::ParsedTags VersionScriptParser::ParseSymbolTags(
}
std::string_view comment_line = line_view.substr(comment_pos + 1);
- std::vector<std::string_view> tags = Split(comment_line, " \t");
+ std::vector<std::string_view> tags = utils::Split(comment_line, " \t");
bool has_introduced_arch_tags = false;
@@ -92,8 +93,8 @@ VersionScriptParser::ParsedTags VersionScriptParser::ParseSymbolTags(
}
// Check introduced tags.
- if (StartsWith(tag, "introduced=")) {
- std::optional<ApiLevel> intro = ParseApiLevel(
+ if (utils::StartsWith(tag, "introduced=")) {
+ std::optional<utils::ApiLevel> intro = utils::ParseApiLevel(
std::string(tag.substr(sizeof("introduced=") - 1)));
if (!intro) {
ReportError("Bad introduced tag: " + std::string(tag));
@@ -106,8 +107,8 @@ VersionScriptParser::ParsedTags VersionScriptParser::ParseSymbolTags(
continue;
}
- if (StartsWith(tag, introduced_arch_tag_)) {
- std::optional<ApiLevel> intro = ParseApiLevel(
+ if (utils::StartsWith(tag, introduced_arch_tag_)) {
+ std::optional<utils::ApiLevel> intro = utils::ParseApiLevel(
std::string(tag.substr(introduced_arch_tag_.size())));
if (!intro) {
ReportError("Bad introduced tag " + std::string(tag));
@@ -141,7 +142,7 @@ bool VersionScriptParser::IsSymbolExported(
}
if (tags.has_future_tag_) {
- return api_level_ == FUTURE_API_LEVEL;
+ return api_level_ == utils::FUTURE_API_LEVEL;
}
if (tags.has_introduced_tags_) {
@@ -161,7 +162,7 @@ bool VersionScriptParser::ParseSymbolLine(const std::string &line,
return false;
}
- std::string symbol(Trim(line.substr(0, pos)));
+ std::string symbol(utils::Trim(line.substr(0, pos)));
ParsedTags tags = ParseSymbolTags(line);
if (!IsSymbolExported(tags)) {
@@ -169,7 +170,7 @@ bool VersionScriptParser::ParseSymbolLine(const std::string &line,
}
if (is_in_extern_cpp) {
- if (IsGlobPattern(symbol)) {
+ if (utils::IsGlobPattern(symbol)) {
exported_symbols_->AddDemangledCppGlobPattern(symbol);
} else {
exported_symbols_->AddDemangledCppSymbol(symbol);
@@ -177,7 +178,7 @@ bool VersionScriptParser::ParseSymbolLine(const std::string &line,
return true;
}
- if (IsGlobPattern(symbol)) {
+ if (utils::IsGlobPattern(symbol)) {
exported_symbols_->AddGlobPattern(symbol);
return true;
}
@@ -219,11 +220,11 @@ bool VersionScriptParser::ParseVersionBlock(bool ignore_symbols) {
}
// Check symbol visibility label
- if (StartsWith(line, "local:")) {
+ if (utils::StartsWith(line, "local:")) {
scope = LineScope::LOCAL;
continue;
}
- if (StartsWith(line, "global:")) {
+ if (utils::StartsWith(line, "global:")) {
scope = LineScope::GLOBAL;
continue;
}
@@ -264,7 +265,7 @@ std::unique_ptr<ExportedSymbolSet> VersionScriptParser::Parse(
return nullptr;
}
- std::string version(Trim(line.substr(0, lparen_pos - 1)));
+ std::string version(utils::Trim(line.substr(0, lparen_pos - 1)));
bool exclude_symbol_version = (excluded_symbol_versions_.find(version) !=
excluded_symbol_versions_.end());
@@ -280,7 +281,7 @@ std::unique_ptr<ExportedSymbolSet> VersionScriptParser::Parse(
bool VersionScriptParser::ReadLine(std::string &line) {
while (std::getline(*stream_, line)) {
++line_no_;
- line = std::string(Trim(line));
+ line = std::string(utils::Trim(line));
if (line.empty() || line[0] == '#') {
continue;
}
@@ -293,4 +294,5 @@ bool VersionScriptParser::ReadLine(std::string &line) {
VersionScriptParser::ErrorHandler::~ErrorHandler() {}
-} // namespace abi_util
+} // namespace repr
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/repr/symbol/version_script_parser.h b/vndk/tools/header-checker/src/repr/symbol/version_script_parser.h
index 225b655e4..7a047a299 100644
--- a/vndk/tools/header-checker/src/repr/symbol/version_script_parser.h
+++ b/vndk/tools/header-checker/src/repr/symbol/version_script_parser.h
@@ -24,7 +24,8 @@
#include <string>
-namespace abi_util {
+namespace header_checker {
+namespace repr {
class VersionScriptParser {
@@ -43,7 +44,7 @@ class VersionScriptParser {
unsigned has_excluded_tags_ : 1;
unsigned has_future_tag_ : 1;
unsigned has_var_tag_ : 1;
- ApiLevel introduced_;
+ utils::ApiLevel introduced_;
public:
@@ -68,7 +69,7 @@ class VersionScriptParser {
void SetArch(const std::string &arch);
- void SetApiLevel(ApiLevel api_level) {
+ void SetApiLevel(utils::ApiLevel api_level) {
api_level_ = api_level;
}
@@ -112,7 +113,7 @@ class VersionScriptParser {
std::string arch_;
std::string introduced_arch_tag_;
- ApiLevel api_level_;
+ utils::ApiLevel api_level_;
std::set<std::string, std::less<>> excluded_symbol_versions_;
std::set<std::string, std::less<>> excluded_symbol_tags_;
@@ -124,7 +125,8 @@ class VersionScriptParser {
};
-} // namespace abi_util
+} // namespace repr
+} // namespace header_checker
#endif // VERSION_SCRIPT_PARSER_H_
diff --git a/vndk/tools/header-checker/src/repr/symbol/version_script_parser_test.cpp b/vndk/tools/header-checker/src/repr/symbol/version_script_parser_test.cpp
index 7c1051fee..7984f580e 100644
--- a/vndk/tools/header-checker/src/repr/symbol/version_script_parser_test.cpp
+++ b/vndk/tools/header-checker/src/repr/symbol/version_script_parser_test.cpp
@@ -21,7 +21,8 @@
#include <string>
-namespace abi_util {
+namespace header_checker {
+namespace repr {
TEST(VersionScriptParserTest, SmokeTest) {
@@ -245,7 +246,7 @@ TEST(VersionScriptParserTest, ParseSymbolTagsIntroduced) {
{
VersionScriptParser parser;
parser.SetArch("arm64");
- parser.SetApiLevel(FUTURE_API_LEVEL);
+ parser.SetApiLevel(utils::FUTURE_API_LEVEL);
std::istringstream stream(testdata);
std::unique_ptr<ExportedSymbolSet> result(parser.Parse(stream));
@@ -427,4 +428,5 @@ TEST(VersionScriptParserTest, ParseGlobPattern) {
}
-} // namespace abi_util
+} // namespace repr
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/utils/api_level.cpp b/vndk/tools/header-checker/src/utils/api_level.cpp
index 450122fb5..a04b9b42b 100644
--- a/vndk/tools/header-checker/src/utils/api_level.cpp
+++ b/vndk/tools/header-checker/src/utils/api_level.cpp
@@ -20,7 +20,8 @@
#include <string>
-namespace abi_util {
+namespace header_checker {
+namespace utils {
std::optional<ApiLevel> ParseApiLevel(const std::string &api_level_str) {
@@ -31,4 +32,5 @@ std::optional<ApiLevel> ParseApiLevel(const std::string &api_level_str) {
}
-} // namespace abi_util
+} // namespace utils
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/utils/api_level.h b/vndk/tools/header-checker/src/utils/api_level.h
index 11bcb66dc..45e86e47c 100644
--- a/vndk/tools/header-checker/src/utils/api_level.h
+++ b/vndk/tools/header-checker/src/utils/api_level.h
@@ -19,7 +19,8 @@
#include <string>
-namespace abi_util {
+namespace header_checker {
+namespace utils {
using ApiLevel = int;
@@ -31,7 +32,8 @@ constexpr ApiLevel FUTURE_API_LEVEL = 10000;
std::optional<ApiLevel> ParseApiLevel(const std::string &api);
-} // namespace abi_util
+} // namespace utils
+} // namespace header_checker
#endif // API_LEVEL_H_
diff --git a/vndk/tools/header-checker/src/utils/api_level_test.cpp b/vndk/tools/header-checker/src/utils/api_level_test.cpp
index 138908dd7..74f06675b 100644
--- a/vndk/tools/header-checker/src/utils/api_level_test.cpp
+++ b/vndk/tools/header-checker/src/utils/api_level_test.cpp
@@ -17,7 +17,8 @@
#include <gtest/gtest.h>
-namespace abi_util {
+namespace header_checker {
+namespace utils {
TEST(ApiLevelTest, ParseApiLevel) {
@@ -32,5 +33,5 @@ TEST(ApiLevelTest, ParseApiLevel) {
}
-} // namespace abi_util
-
+} // namespace utils
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/utils/collect_exported_headers.cpp b/vndk/tools/header-checker/src/utils/collect_exported_headers.cpp
index 01e74d7e0..0729e60e1 100644
--- a/vndk/tools/header-checker/src/utils/collect_exported_headers.cpp
+++ b/vndk/tools/header-checker/src/utils/collect_exported_headers.cpp
@@ -23,7 +23,9 @@
#include <vector>
-namespace abi_util {
+namespace header_checker {
+namespace utils {
+
static bool ShouldSkipFile(llvm::StringRef &file_name) {
// Ignore swap files, hidden files, and hidden directories. Do not recurse
@@ -88,7 +90,7 @@ std::set<std::string> CollectAllExportedHeaders(
const std::vector<std::string> &exported_header_dirs) {
std::set<std::string> exported_headers;
for (auto &&dir : exported_header_dirs) {
- if (!abi_util::CollectExportedHeaderSet(dir, &exported_headers)) {
+ if (!CollectExportedHeaderSet(dir, &exported_headers)) {
llvm::errs() << "Couldn't collect exported headers\n";
::exit(1);
}
@@ -96,4 +98,5 @@ std::set<std::string> CollectAllExportedHeaders(
return exported_headers;
}
-} // namespace abi_util
+} // namespace utils
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/utils/header_abi_util.h b/vndk/tools/header-checker/src/utils/header_abi_util.h
index e76dbdadb..354c64d40 100644
--- a/vndk/tools/header-checker/src/utils/header_abi_util.h
+++ b/vndk/tools/header-checker/src/utils/header_abi_util.h
@@ -22,7 +22,9 @@
#include <vector>
-namespace abi_util {
+namespace header_checker {
+namespace utils {
+
std::string RealPath(const std::string &path);
@@ -96,6 +98,9 @@ std::vector<std::pair<T, T>> FindCommonElements(
return common_elements;
}
-} // namespace abi_util
+
+} // namespace utils
+} // namespace header_checker
+
#endif // HEADER_ABI_UTIL_H_
diff --git a/vndk/tools/header-checker/src/utils/stl_utils.h b/vndk/tools/header-checker/src/utils/stl_utils.h
index 3a520adb1..9ce8b142b 100644
--- a/vndk/tools/header-checker/src/utils/stl_utils.h
+++ b/vndk/tools/header-checker/src/utils/stl_utils.h
@@ -16,7 +16,8 @@
#define STL_UTILS_H_
-namespace abi_util {
+namespace header_checker {
+namespace utils {
class FreeDeleter {
@@ -27,7 +28,8 @@ class FreeDeleter {
};
-} // namespace abi_util
+} // namespace utils
+} // namespace header_checker
#endif // STL_UTILS_
diff --git a/vndk/tools/header-checker/src/utils/string_utils.cpp b/vndk/tools/header-checker/src/utils/string_utils.cpp
index a1055590e..ced07f754 100644
--- a/vndk/tools/header-checker/src/utils/string_utils.cpp
+++ b/vndk/tools/header-checker/src/utils/string_utils.cpp
@@ -19,7 +19,8 @@
#include <utility>
-namespace abi_util {
+namespace header_checker {
+namespace utils {
std::string_view Trim(std::string_view s) {
@@ -90,4 +91,5 @@ bool IsGlobPattern(std::string_view s) {
}
-} // namespace abi_util
+} // namespace utils
+} // namespace header_checker
diff --git a/vndk/tools/header-checker/src/utils/string_utils.h b/vndk/tools/header-checker/src/utils/string_utils.h
index d222a435f..8d546f400 100644
--- a/vndk/tools/header-checker/src/utils/string_utils.h
+++ b/vndk/tools/header-checker/src/utils/string_utils.h
@@ -20,7 +20,8 @@
#include <vector>
-namespace abi_util {
+namespace header_checker {
+namespace utils {
std::string_view Trim(std::string_view s);
@@ -37,7 +38,8 @@ std::optional<int> ParseInt(const std::string &s);
bool IsGlobPattern(std::string_view s);
-} // namespace abi_util
+} // namespace utils
+} // namespace header_checker
#endif // STRING_UTILS_H_
diff --git a/vndk/tools/header-checker/src/utils/string_utils_test.cpp b/vndk/tools/header-checker/src/utils/string_utils_test.cpp
index 3e5346fb6..6c5a874a8 100644
--- a/vndk/tools/header-checker/src/utils/string_utils_test.cpp
+++ b/vndk/tools/header-checker/src/utils/string_utils_test.cpp
@@ -17,7 +17,8 @@
#include <gtest/gtest.h>
-namespace abi_util {
+namespace header_checker {
+namespace utils {
TEST(StringUtilsTest, Trim) {
@@ -104,4 +105,5 @@ TEST(StringUtilsTest, IsGlobPattern) {
}
-} // namespace abi_util
+} // namespace utils
+} // namespace header_checker