diff --git a/vndk/tools/header-checker/Android.bp b/vndk/tools/header-checker/Android.bp index 0cbc55910..8e0ba1132 100644 --- a/vndk/tools/header-checker/Android.bp +++ b/vndk/tools/header-checker/Android.bp @@ -59,8 +59,6 @@ cc_binary_host { "header-abi-dumper/src/frontend_action.cpp", "header-abi-dumper/src/frontend_action_factory.cpp", "header-abi-dumper/src/header_checker.cpp", - "header-abi-dumper/src/workaround_fortify.cpp", - "header-abi-dumper/src/workaround_openmp.cpp", ], static_libs: [ diff --git a/vndk/tools/header-checker/header-abi-diff/src/abi_diff.cpp b/vndk/tools/header-checker/header-abi-diff/src/abi_diff.cpp index 9d8acf5e4..a72636abf 100644 --- a/vndk/tools/header-checker/header-abi-diff/src/abi_diff.cpp +++ b/vndk/tools/header-checker/header-abi-diff/src/abi_diff.cpp @@ -14,7 +14,7 @@ #include "abi_diff.h" -#include +#include "header_abi_util.h" #include @@ -140,14 +140,14 @@ bool HeaderAbiDiff::CollectUserDefinedTypes( auto old_enums_and_records_extracted = ExtractUserDefinedTypes(old_tu); auto new_enums_and_records_extracted = ExtractUserDefinedTypes(new_tu); - return CollectUserDefinedTypesInternal( - old_enums_and_records_extracted.second, - new_enums_and_records_extracted.second, old_types_map, - new_types_map, ir_diff_dumper) && - CollectUserDefinedTypesInternal(old_enums_and_records_extracted.first, - new_enums_and_records_extracted.first, - old_types_map, new_types_map, - ir_diff_dumper); + return (CollectUserDefinedTypesInternal( + old_enums_and_records_extracted.second, + new_enums_and_records_extracted.second, old_types_map, + new_types_map, ir_diff_dumper) && + CollectUserDefinedTypesInternal( + old_enums_and_records_extracted.first, + new_enums_and_records_extracted.first, + old_types_map, new_types_map, ir_diff_dumper)); } template @@ -158,11 +158,11 @@ bool HeaderAbiDiff::CollectUserDefinedTypesInternal( const AbiElementMap &new_types_map, abi_util::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); + 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)); } template @@ -210,12 +210,12 @@ bool HeaderAbiDiff::CollectDynsymExportables( return true; } -// Collect added and removed Elements. The elf set is needed since some symbols -// might not have meta-data about them collected through the AST. For eg: if a -// function Foo is defined in an assembly file on target A, but in a c/c++ file -// on target B, foo does not have meta-data surrounding it when building target -// A, this does not mean it is not in the ABI + API of the library. - +// Collect the added and removed elements. The ELF maps are needed because the +// metadata for some symbols might be absent from AST. For example, if a +// function Foo() is defined in an assembly file on target A, but in a C/C++ +// file on target B. Even though Foo() does not have metadata surrounding it +// when building target A, it doesn't mean that Foo() is not a part of the ABI +// of the library. template bool HeaderAbiDiff::Collect( const AbiElementMap &old_elements_map, @@ -226,12 +226,11 @@ bool HeaderAbiDiff::Collect( const AbiElementMap &old_types_map, const AbiElementMap &new_types_map) { if (!PopulateRemovedElements( - old_elements_map, new_elements_map, new_elf_map, ir_diff_dumper, - abi_util::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)) { + old_elements_map, new_elements_map, new_elf_map, ir_diff_dumper, + abi_util::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)) { llvm::errs() << "Populating functions in report failed\n"; return false; } @@ -248,10 +247,10 @@ bool HeaderAbiDiff::CollectElfSymbols( std::vector added_elements = abi_util::FindRemovedElements(new_symbols, old_symbols); - return PopulateElfElements(removed_elements, ir_diff_dumper, - abi_util::IRDiffDumper::DiffKind::Removed) && - PopulateElfElements(added_elements, ir_diff_dumper, - abi_util::IRDiffDumper::DiffKind::Added); + return (PopulateElfElements(removed_elements, ir_diff_dumper, + abi_util::IRDiffDumper::DiffKind::Removed) && + PopulateElfElements(added_elements, ir_diff_dumper, + abi_util::IRDiffDumper::DiffKind::Added)); } bool HeaderAbiDiff::PopulateElfElements( @@ -358,11 +357,10 @@ bool HeaderAbiDiff::DumpDiffElements( [](const T *e) {return e->GetLinkerSetKey();})) { continue; } - abi_diff_wrappers::DiffWrapper diff_wrapper(old_element, new_element, - ir_diff_dumper, old_types, - new_types, - diff_policy_options_, - &type_cache_); + + abi_diff_wrappers::DiffWrapper diff_wrapper( + old_element, new_element, ir_diff_dumper, old_types, new_types, + diff_policy_options_, &type_cache_); if (!diff_wrapper.DumpDiff(diff_kind)) { llvm::errs() << "Failed to diff elements\n"; return false; diff --git a/vndk/tools/header-checker/header-abi-diff/src/abi_diff.h b/vndk/tools/header-checker/header-abi-diff/src/abi_diff.h index 9dcedc07e..4604b0fcc 100644 --- a/vndk/tools/header-checker/header-abi-diff/src/abi_diff.h +++ b/vndk/tools/header-checker/header-abi-diff/src/abi_diff.h @@ -12,9 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "abi_diff_wrappers.h" +#ifndef ABI_DIFF_H_ +#define ABI_DIFF_H_ -#include +#include "abi_diff_wrappers.h" +#include "ir_representation.h" #include #include @@ -38,7 +40,7 @@ class HeaderAbiDiff { diff_policy_options_(diff_policy_options), check_all_apis_(check_all_apis), text_format_old_(text_format_old), text_format_new_(text_format_new), - text_format_diff_(text_format_diff) { } + text_format_diff_(text_format_diff) {} abi_util::CompatibilityStatusIR GenerateCompatibilityReport(); @@ -50,13 +52,13 @@ class HeaderAbiDiff { template bool CollectDynsymExportables( - const AbiElementMap &old_exportables, - const AbiElementMap &new_exportables, - const AbiElementMap &old_elf_symbols, - const AbiElementMap &new_elf_symbols, - const AbiElementMap &old_types_map, - const AbiElementMap &new_types_map, - abi_util::IRDiffDumper *ir_diff_dumper); + const AbiElementMap &old_exportables, + const AbiElementMap &new_exportables, + const AbiElementMap &old_elf_symbols, + const AbiElementMap &new_elf_symbols, + const AbiElementMap &old_types_map, + const AbiElementMap &new_types_map, + abi_util::IRDiffDumper *ir_diff_dumper); template bool Collect( @@ -145,3 +147,5 @@ class HeaderAbiDiff { abi_util::TextFormatIR text_format_new_; abi_util::TextFormatIR text_format_diff_; }; + +#endif // ABI_DIFF_H_ diff --git a/vndk/tools/header-checker/header-abi-diff/src/abi_diff_wrappers.cpp b/vndk/tools/header-checker/header-abi-diff/src/abi_diff_wrappers.cpp index e9e4cd23f..4614bea6c 100644 --- a/vndk/tools/header-checker/header-abi-diff/src/abi_diff_wrappers.cpp +++ b/vndk/tools/header-checker/header-abi-diff/src/abi_diff_wrappers.cpp @@ -14,7 +14,7 @@ #include "abi_diff_wrappers.h" -#include +#include "header_abi_util.h" #include @@ -33,7 +33,7 @@ bool DiffWrapper::DumpDiff( return false; } if (!type_cache_->insert( - oldp_->GetSelfType() + newp_->GetSelfType()).second) { + oldp_->GetSelfType() + newp_->GetSelfType()).second) { return true; } CompareRecordTypes(oldp_, newp_, &type_queue, diff_kind); @@ -85,13 +85,13 @@ bool DiffWrapper::DumpDiff( abi_util::DiffMessageIR::DiffKind diff_kind) { std::deque type_queue; type_queue.push_back(oldp_->GetName()); - DiffStatus param_diffs = CompareFunctionParameters(oldp_->GetParameters(), - newp_->GetParameters(), - &type_queue, diff_kind); - DiffStatus return_type_diff = - CompareAndDumpTypeDiff(oldp_->GetReturnType(), - newp_->GetReturnType(), - &type_queue, diff_kind); + + DiffStatus param_diffs = CompareFunctionParameters( + oldp_->GetParameters(), newp_->GetParameters(), &type_queue, diff_kind); + + DiffStatus return_type_diff = CompareAndDumpTypeDiff( + oldp_->GetReturnType(), newp_->GetReturnType(), &type_queue, diff_kind); + CompareTemplateInfo(oldp_->GetTemplateElements(), newp_->GetTemplateElements(), &type_queue, diff_kind); @@ -111,4 +111,4 @@ bool DiffWrapper::DumpDiff( return true; } -} // abi_diff_wrappers +} // namespace abi_diff_wrappers diff --git a/vndk/tools/header-checker/header-abi-diff/src/abi_diff_wrappers.h b/vndk/tools/header-checker/header-abi-diff/src/abi_diff_wrappers.h index 92c04758e..8a4845254 100644 --- a/vndk/tools/header-checker/header-abi-diff/src/abi_diff_wrappers.h +++ b/vndk/tools/header-checker/header-abi-diff/src/abi_diff_wrappers.h @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef ABI_DIFF_WRAPPERS_H -#define ABI_DIFF_WRAPPERS_H +#ifndef ABI_DIFF_WRAPPERS_H_ +#define ABI_DIFF_WRAPPERS_H_ -#include -#include +#include "abi_diff_helpers.h" +#include "ir_representation.h" #include @@ -30,13 +30,11 @@ template static bool IgnoreSymbol(const T *element, const std::set &ignored_symbols, F func) { - return ignored_symbols.find(func(element)) != - ignored_symbols.end(); + return ignored_symbols.find(func(element)) != ignored_symbols.end(); } template class DiffWrapper : public AbiDiffHelper { - public: DiffWrapper(const T *oldp, const T *newp, abi_util::IRDiffDumper *ir_diff_dumper, @@ -45,7 +43,8 @@ class DiffWrapper : public AbiDiffHelper { const abi_util::DiffPolicyOptions &diff_policy_options, std::set *type_cache) : AbiDiffHelper(old_types, new_types, diff_policy_options, type_cache, - ir_diff_dumper), oldp_(oldp), newp_(newp) { } + ir_diff_dumper), + oldp_(oldp), newp_(newp) {} bool DumpDiff(abi_util::IRDiffDumper::DiffKind diff_kind); @@ -54,6 +53,6 @@ class DiffWrapper : public AbiDiffHelper { const T *newp_; }; -} // abi_diff_wrappers +} // namespace abi_diff_wrappers -#endif // ABI_DIFF_WRAPPERS_H +#endif // ABI_DIFF_WRAPPERS_H_ diff --git a/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp b/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp index b36e5ac98..cafb5e04b 100644 --- a/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp +++ b/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp @@ -14,12 +14,12 @@ #include "abi_diff.h" -#include - #include #include #include +#include + static llvm::cl::OptionCategory header_checker_category( "header-abi-diff options"); @@ -132,13 +132,13 @@ static const char kWarn[] = "\033[36;1mwarning: \033[0m"; static const char kError[] = "\033[31;1merror: \033[0m"; bool ShouldEmitWarningMessage(abi_util::CompatibilityStatusIR status) { - return (!allow_extensions && - (status & abi_util::CompatibilityStatusIR::Extension)) || - (!allow_unreferenced_changes && - (status & abi_util::CompatibilityStatusIR::UnreferencedChanges)) || - (!allow_unreferenced_elf_symbol_changes && - (status & abi_util::CompatibilityStatusIR::ElfIncompatible)) || - (status & abi_util::CompatibilityStatusIR::Incompatible); + return ((!allow_extensions && + (status & abi_util::CompatibilityStatusIR::Extension)) || + (!allow_unreferenced_changes && + (status & abi_util::CompatibilityStatusIR::UnreferencedChanges)) || + (!allow_unreferenced_elf_symbol_changes && + (status & abi_util::CompatibilityStatusIR::ElfIncompatible)) || + (status & abi_util::CompatibilityStatusIR::Incompatible)); } int main(int argc, const char **argv) { @@ -196,7 +196,7 @@ int main(int argc, const char **argv) { << "'s ABI has " << status_str << unreferenced_change_str - << " Please check compatiblity report at : " + << " Please check compatiblity report at: " << compatibility_report << "\n" << "******************************************************\n"; } diff --git a/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.cpp b/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.cpp index 918196503..8c3c045bf 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.cpp +++ b/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.cpp @@ -14,15 +14,17 @@ #include "abi_wrappers.h" -#include +#include "header_abi_util.h" -#include -#include #include #include #include +#include +#include +#include + using namespace abi_wrapper; ABIWrapper::ABIWrapper( @@ -31,11 +33,11 @@ ABIWrapper::ABIWrapper( const clang::CompilerInstance *cip, abi_util::IRDumper *ir_dumper, ast_util::ASTCaches *ast_caches) - : cip_(cip), - mangle_contextp_(mangle_contextp), - ast_contextp_(ast_contextp), - ir_dumper_(ir_dumper), - ast_caches_(ast_caches) { } + : cip_(cip), + mangle_contextp_(mangle_contextp), + ast_contextp_(ast_contextp), + ir_dumper_(ir_dumper), + ast_caches_(ast_caches) {} std::string ABIWrapper::GetCachedDeclSourceFile( const clang::Decl *decl, const clang::CompilerInstance *cip) { @@ -67,8 +69,9 @@ static const clang::RecordDecl *GetAnonymousRecord(clang::QualType type) { const clang::RecordDecl *record_decl = llvm::dyn_cast(tag_decl); - if (record_decl != nullptr && (!record_decl->hasNameForLinkage() || - record_decl->isAnonymousStructOrUnion())) { + if (record_decl != nullptr && + (!record_decl->hasNameForLinkage() || + record_decl->isAnonymousStructOrUnion())) { return record_decl; } return nullptr; @@ -95,8 +98,7 @@ static bool IsReferencingType(clang::QualType qual_type) { bool is_ptr = base_type->isPointerType(); bool is_reference = base_type->isReferenceType(); bool is_array = base_type->isArrayType(); - return is_array || is_ptr || is_reference || - qual_type.hasLocalQualifiers(); + return is_array || is_ptr || is_reference || qual_type.hasLocalQualifiers(); } static clang::QualType GetReferencedType(const clang::QualType qual_type); @@ -151,7 +153,7 @@ std::string ABIWrapper::GetDeclSourceFile(const clang::Decl *decl, } static abi_util::AccessSpecifierIR AccessClangToIR( - const clang::AccessSpecifier sp) { + const clang::AccessSpecifier sp) { switch (sp) { case clang::AS_private: { return abi_util::AccessSpecifierIR::PrivateAccess; @@ -194,18 +196,17 @@ static clang::QualType GetReferencedType(const clang::QualType qual_type) { return qual_type.getNonReferenceType(); } -bool ABIWrapper::CreateExtendedType( - clang::QualType qual_type, - abi_util::TypeIR *typep) { +bool ABIWrapper::CreateExtendedType(clang::QualType qual_type, + abi_util::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, ""); } -//This overload takes in a qualtype and adds its information to the abi-dump on -//its own. -bool ABIWrapper::CreateBasicNamedAndTypedDecl( - clang::QualType qual_type, const std::string &source_file) { +// This overload takes in a qualtype and adds its information to the abi-dump on +// its own. +bool ABIWrapper::CreateBasicNamedAndTypedDecl(clang::QualType qual_type, + const std::string &source_file) { const std::string &type_key = GetKeyForTypeId(qual_type); const clang::QualType canonical_type = qual_type.getCanonicalType(); const clang::Type *base_type = canonical_type.getTypePtr(); @@ -228,9 +229,12 @@ bool ABIWrapper::CreateBasicNamedAndTypedDecl( llvm::errs() << "nullptr with valid type while creating basic type\n"; return false; } - return type_and_status.should_create_type_ ? - CreateBasicNamedAndTypedDecl(canonical_type, typep.get(), source_file) && - ir_dumper_->AddLinkableMessageIR(typep.get()) : true; + if (!type_and_status.should_create_type_) { + return true; + } + return (CreateBasicNamedAndTypedDecl( + canonical_type, typep.get(), source_file) && + ir_dumper_->AddLinkableMessageIR(typep.get())); } std::string RecordDeclWrapper::GetMangledRTTI( @@ -258,19 +262,18 @@ std::string ABIWrapper::GetTypeUniqueId(const clang::TagDecl *tag_decl) { return QualTypeToString(qual_type); } -// CreateBasicNamedAndTypedDecl creates a BasicNamedAndTypedDecl : that'll -// include all the generic information a basic type will have: -// abi_dump::BasicNamedAndTypedDecl. Other methods fill in more specific -// information, eg: RecordDecl, EnumDecl. +// CreateBasicNamedAndTypedDecl creates a BasicNamedAndTypedDecl which will +// 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, const std::string &source_file) { + clang::QualType canonical_type, abi_util::TypeIR *typep, + const std::string &source_file) { // Cannot determine the size and alignment for template parameter dependent // types as well as incomplete types. const clang::Type *base_type = canonical_type.getTypePtr(); assert(base_type != nullptr); clang::Type::TypeClass type_class = base_type->getTypeClass(); - // Temporary Hack for auto type sizes. Not determinable. + // Temporary hack for auto type sizes. Not determinable. if ((type_class != clang::Type::Auto) && !base_type->isIncompleteType() && !(base_type->isDependentType())) { std::pair size_and_alignment = @@ -284,8 +287,8 @@ bool ABIWrapper::CreateBasicNamedAndTypedDecl( TypeNameWithFinalDestination(canonical_type); typep->SetName(type_name_with_destination); typep->SetLinkerSetKey(type_name_with_destination); - // default values are false, we don't set them since explicitly doing that - // makes the abi dumps more verbose. + // Default values are false, we don't set them since explicitly doing that + // makes the ABI dumps more verbose. // This type has a reference type if its a pointer / reference OR it has CVR // qualifiers. clang::QualType referenced_type = GetReferencedType(canonical_type); @@ -296,7 +299,7 @@ bool ABIWrapper::CreateBasicNamedAndTypedDecl( return CreateBasicNamedAndTypedDecl(referenced_type, source_file); } -std::string ABIWrapper::GetTypeLinkageName(const clang::Type *typep) { +std::string ABIWrapper::GetTypeLinkageName(const clang::Type *typep) { assert(typep != nullptr); clang::QualType qt = typep->getCanonicalTypeInternal(); return QualTypeToString(qt); @@ -329,10 +332,10 @@ TypeAndCreationStatus ABIWrapper::SetTypeKind( return TypeAndCreationStatus(std::move(lvalue_reference_type_ir)); } if (type_ptr->isRValueReferenceType()) { - auto rvalue_reference_type_ir = - std::make_unique(); - rvalue_reference_type_ir->SetSourceFile(source_file); - return TypeAndCreationStatus(std::move(rvalue_reference_type_ir)); + auto rvalue_reference_type_ir = + std::make_unique(); + 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(); @@ -349,7 +352,7 @@ TypeAndCreationStatus ABIWrapper::SetTypeKind( return TypeAndCreationStatus(std::move(builtin_type_ir)); } if (auto &&func_type_ptr = - llvm::dyn_cast(type_ptr)) { + llvm::dyn_cast(type_ptr)) { FunctionTypeWrapper function_type_wrapper(mangle_contextp_, ast_contextp_, cip_, func_type_ptr, ir_dumper_, ast_caches_, source_file); @@ -382,22 +385,20 @@ std::string ABIWrapper::GetMangledNameDecl( return mangled_name; } -std::string ABIWrapper::GetTagDeclQualifiedName( - const clang::TagDecl *decl) { +std::string ABIWrapper::GetTagDeclQualifiedName(const clang::TagDecl *decl) { if (decl->getTypedefNameForAnonDecl()) { return decl->getTypedefNameForAnonDecl()->getQualifiedNameAsString(); } return decl->getQualifiedNameAsString(); } -bool ABIWrapper::SetupTemplateArguments( - const clang::TemplateArgumentList *tl, - abi_util::TemplatedArtifactIR *ta, - const std::string &source_file) { +bool ABIWrapper::SetupTemplateArguments(const clang::TemplateArgumentList *tl, + abi_util::TemplatedArtifactIR *ta, + const std::string &source_file) { abi_util::TemplateInfoIR template_info; for (int i = 0; i < tl->size(); i++) { const clang::TemplateArgument &arg = (*tl)[i]; - //TODO: More comprehensive checking needed. + // TODO: More comprehensive checking needed. if (arg.getKind() != clang::TemplateArgument::Type) { continue; } @@ -414,8 +415,7 @@ bool ABIWrapper::SetupTemplateArguments( return true; } -std::string ABIWrapper::QualTypeToString( - const clang::QualType &sweet_qt) { +std::string ABIWrapper::QualTypeToString(const clang::QualType &sweet_qt) { const clang::QualType salty_qt = sweet_qt.getCanonicalType(); // clang::TypeName::getFullyQualifiedName removes the part of the type related // to it being a template parameter. Don't use it for dependent types. @@ -431,9 +431,10 @@ FunctionTypeWrapper::FunctionTypeWrapper( 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) - : ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper, - ast_caches), function_type_(function_type), - source_file_(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) { @@ -474,9 +475,9 @@ FunctionDeclWrapper::FunctionDeclWrapper( const clang::FunctionDecl *decl, abi_util::IRDumper *ir_dumper, ast_util::ASTCaches *ast_caches) - : ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper, - ast_caches), - function_decl_(decl) { } + : ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper, + ast_caches), + function_decl_(decl) {} bool FunctionDeclWrapper::SetupThisParameter(abi_util::FunctionIR *functionp, const std::string &source_file) { @@ -528,7 +529,7 @@ bool FunctionDeclWrapper::SetupFunctionParameters( } bool FunctionDeclWrapper::SetupFunction(abi_util::FunctionIR *functionp, - const std::string &source_file) { + 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. // TODO: Change this to get the complete function signature @@ -544,9 +545,8 @@ bool FunctionDeclWrapper::SetupFunction(abi_util::FunctionIR *functionp, SetupTemplateInfo(functionp, source_file); } -bool FunctionDeclWrapper::SetupTemplateInfo( - abi_util::FunctionIR *functionp, - const std::string &source_file) { +bool FunctionDeclWrapper::SetupTemplateInfo(abi_util::FunctionIR *functionp, + const std::string &source_file) { switch (function_decl_->getTemplatedKind()) { case clang::FunctionDecl::TK_FunctionTemplateSpecialization: { const clang::TemplateArgumentList *arg_list = @@ -579,9 +579,9 @@ RecordDeclWrapper::RecordDeclWrapper( const clang::CompilerInstance *compiler_instance_p, const clang::RecordDecl *decl, abi_util::IRDumper *ir_dumper, ast_util::ASTCaches *ast_caches) - : ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper, - ast_caches), - record_decl_(decl) { } + : ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper, + ast_caches), + record_decl_(decl) {} bool RecordDeclWrapper::SetupRecordFields(abi_util::RecordTypeIR *recordp, const std::string &source_file) { @@ -613,8 +613,7 @@ bool RecordDeclWrapper::SetupRecordFields(abi_util::RecordTypeIR *recordp, } bool RecordDeclWrapper::SetupCXXBases( - abi_util::RecordTypeIR *cxxp, - const clang::CXXRecordDecl *cxx_record_decl) { + abi_util::RecordTypeIR *cxxp, const clang::CXXRecordDecl *cxx_record_decl) { if (!cxx_record_decl || !cxxp) { return false; } @@ -823,8 +822,8 @@ bool RecordDeclWrapper::SetupRecordInfo(abi_util::RecordTypeIR *record_declp, SetupCXXRecordInfo(record_declp, source_file); } -bool RecordDeclWrapper::SetupCXXRecordInfo( - abi_util::RecordTypeIR *record_declp, const std::string &source_file) { +bool RecordDeclWrapper::SetupCXXRecordInfo(abi_util::RecordTypeIR *record_declp, + const std::string &source_file) { const clang::CXXRecordDecl *cxx_record_decl = clang::dyn_cast(record_decl_); if (!cxx_record_decl) { @@ -835,7 +834,7 @@ bool RecordDeclWrapper::SetupCXXRecordInfo( SetupRecordVTable(record_declp, cxx_record_decl); } -// TODO: Can we use clang's ODR hash to do faster ODR checking ? +// TODO: Can we use clang's ODR hash to do faster ODR checking? bool RecordDeclWrapper::GetRecordDecl() { auto abi_decl = std::make_unique(); std::string source_file = GetCachedDeclSourceFile(record_decl_, cip_); @@ -858,9 +857,9 @@ EnumDeclWrapper::EnumDeclWrapper( const clang::CompilerInstance *compiler_instance_p, const clang::EnumDecl *decl, abi_util::IRDumper *ir_dumper, ast_util::ASTCaches *ast_caches) - : ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper, - ast_caches), - enum_decl_(decl) { } + : ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper, + ast_caches), + enum_decl_(decl) {} bool EnumDeclWrapper::SetupEnumFields(abi_util::EnumTypeIR *enump) { if (!enump) { @@ -910,14 +909,13 @@ GlobalVarDeclWrapper::GlobalVarDeclWrapper( const clang::CompilerInstance *compiler_instance_p, const clang::VarDecl *decl, abi_util::IRDumper *ir_dumper, ast_util::ASTCaches *ast_caches) - : ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper, - ast_caches), - global_var_decl_(decl) { } + : ABIWrapper(mangle_contextp, ast_contextp, compiler_instance_p, ir_dumper, + ast_caches), + global_var_decl_(decl) {} -bool GlobalVarDeclWrapper::SetupGlobalVar( - abi_util::GlobalVarIR *global_varp, - const std::string &source_file) { - // Temporary fix : clang segfaults on trying to mangle global variable which +bool GlobalVarDeclWrapper::SetupGlobalVar(abi_util::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. std::string mangled_name = GetMangledNameDecl(global_var_decl_, mangle_contextp_); diff --git a/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.h b/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.h index cd068fb92..3505020b7 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.h +++ b/vndk/tools/header-checker/header-abi-dumper/src/abi_wrappers.h @@ -16,7 +16,7 @@ #define ABI_WRAPPERS_H_ #include "ast_util.h" -#include +#include "ir_representation.h" #include #include @@ -28,10 +28,10 @@ namespace abi_wrapper { struct TypeAndCreationStatus { std::unique_ptr typep_; - bool should_create_type_; // Whether the type is to be created. + bool should_create_type_; // Whether the type is to be created. TypeAndCreationStatus(std::unique_ptr &&typep, bool should_create_type = true) - : typep_(std::move(typep)), should_create_type_(should_create_type) { } + : typep_(std::move(typep)), should_create_type_(should_create_type) {} }; class ABIWrapper { @@ -162,7 +162,6 @@ class FunctionDeclWrapper : public ABIWrapper { bool SetupThisParameter(abi_util::FunctionIR *functionp, const std::string &source_file); - }; class FunctionTypeWrapper : public ABIWrapper { @@ -215,11 +214,12 @@ class GlobalVarDeclWrapper : public ABIWrapper { private: const clang::VarDecl *global_var_decl_; + private: bool SetupGlobalVar(abi_util::GlobalVarIR *global_varp, const std::string &source_file); }; -} //end namespace abi_wrapper +} // namespace abi_wrapper -#endif // ABI_WRAPPERS_H_ +#endif // ABI_WRAPPERS_H_ diff --git a/vndk/tools/header-checker/header-abi-dumper/src/ast_processing.cpp b/vndk/tools/header-checker/header-abi-dumper/src/ast_processing.cpp index 0d8086dd3..ec2aa1e38 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/ast_processing.cpp +++ b/vndk/tools/header-checker/header-abi-dumper/src/ast_processing.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include "ast_processing.h" + #include "abi_wrappers.h" #include @@ -37,13 +38,13 @@ HeaderASTVisitor::HeaderASTVisitor( const clang::Decl *tu_decl, abi_util::IRDumper *ir_dumper, ast_util::ASTCaches *ast_caches) - : mangle_contextp_(mangle_contextp), - ast_contextp_(ast_contextp), - cip_(compiler_instance_p), - exported_headers_(exported_headers), - tu_decl_(tu_decl), - ir_dumper_(ir_dumper), - ast_caches_(ast_caches) { } + : mangle_contextp_(mangle_contextp), + ast_contextp_(ast_contextp), + cip_(compiler_instance_p), + exported_headers_(exported_headers), + tu_decl_(tu_decl), + ir_dumper_(ir_dumper), + ast_caches_(ast_caches) {} bool HeaderASTVisitor::VisitRecordDecl(const clang::RecordDecl *decl) { // Skip forward declarations, dependent records. Also skip anonymous records @@ -69,7 +70,7 @@ bool HeaderASTVisitor::VisitEnumDecl(const clang::EnumDecl *decl) { EnumDeclWrapper enum_decl_wrapper( mangle_contextp_, ast_contextp_, cip_, decl, ir_dumper_, ast_caches_); return enum_decl_wrapper.GetEnumDecl(); - } +} static bool MutateFunctionWithLinkageName(const abi_util::FunctionIR *function, abi_util::IRDumper *ir_dumper, @@ -120,9 +121,8 @@ bool HeaderASTVisitor::VisitFunctionDecl(const clang::FunctionDecl *decl) { if (ShouldSkipFunctionDecl(decl)) { return true; } - FunctionDeclWrapper function_decl_wrapper(mangle_contextp_, ast_contextp_, - cip_, decl, ir_dumper_, - ast_caches_); + FunctionDeclWrapper function_decl_wrapper( + mangle_contextp_, ast_contextp_, cip_, decl, ir_dumper_, ast_caches_); auto function_wrapper = function_decl_wrapper.GetFunctionDecl(); // Destructors and Constructors can have more than 1 symbol generated from the // same Decl. @@ -138,15 +138,14 @@ bool HeaderASTVisitor::VisitFunctionDecl(const clang::FunctionDecl *decl) { } bool HeaderASTVisitor::VisitVarDecl(const clang::VarDecl *decl) { - if(!decl->hasGlobalStorage()|| - decl->getType().getTypePtr()->isDependentType()) { + if (!decl->hasGlobalStorage() || + decl->getType().getTypePtr()->isDependentType()) { // Non global / static variable declarations don't need to be dumped. return true; } - GlobalVarDeclWrapper global_var_decl_wrapper(mangle_contextp_, ast_contextp_, - cip_, decl, ir_dumper_, - ast_caches_); - return global_var_decl_wrapper.GetGlobalVarDecl(); + GlobalVarDeclWrapper global_var_decl_wrapper( + mangle_contextp_, ast_contextp_, cip_, decl, ir_dumper_, ast_caches_); + return global_var_decl_wrapper.GetGlobalVarDecl(); } static bool AreHeadersExported(const std::set &exported_headers) { @@ -181,10 +180,10 @@ HeaderASTConsumer::HeaderASTConsumer( const std::string &out_dump_name, std::set &exported_headers, abi_util::TextFormatIR text_format) - : cip_(compiler_instancep), - out_dump_name_(out_dump_name), - exported_headers_(exported_headers), - text_format_(text_format){ } + : cip_(compiler_instancep), + out_dump_name_(out_dump_name), + exported_headers_(exported_headers), + text_format_(text_format) {} void HeaderASTConsumer::HandleTranslationUnit(clang::ASTContext &ctx) { clang::PrintingPolicy policy(ctx.getPrintingPolicy()); diff --git a/vndk/tools/header-checker/header-abi-dumper/src/ast_processing.h b/vndk/tools/header-checker/header-abi-dumper/src/ast_processing.h index b798c9743..2fd14255f 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/ast_processing.h +++ b/vndk/tools/header-checker/header-abi-dumper/src/ast_processing.h @@ -16,7 +16,7 @@ #define AST_PROCESSING_H_ #include "ast_util.h" -#include +#include "ir_representation.h" #include #include @@ -82,4 +82,4 @@ class HeaderASTConsumer : public clang::ASTConsumer { abi_util::TextFormatIR text_format_; }; -#endif // AST_PROCESSING_H_ +#endif // AST_PROCESSING_H_ diff --git a/vndk/tools/header-checker/header-abi-dumper/src/ast_util.h b/vndk/tools/header-checker/header-abi-dumper/src/ast_util.h index 32b4654a3..74057c592 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/ast_util.h +++ b/vndk/tools/header-checker/header-abi-dumper/src/ast_util.h @@ -11,8 +11,9 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef AST_UTIL -#define AST_UTIL + +#ifndef AST_UTIL_H_ +#define AST_UTIL_H_ #include @@ -24,9 +25,8 @@ namespace ast_util { constexpr static char type_id_prefix[] = "type-"; struct ASTCaches { - ASTCaches(const std::string &translation_unit_source) - : translation_unit_source_(translation_unit_source) { }; + : translation_unit_source_(translation_unit_source) {} std::string GetTypeId(const std::string &qual_type) { auto type_id_it = qual_type_to_type_id_cache_.find(qual_type); @@ -45,5 +45,6 @@ struct ASTCaches { uint64_t max_type_id_ = 0; }; -} -#endif +} // namespace ast_util + +#endif // AST_UTIL_H_ diff --git a/vndk/tools/header-checker/header-abi-dumper/src/frontend_action.cpp b/vndk/tools/header-checker/header-abi-dumper/src/frontend_action.cpp index f4dd28268..01fc133a5 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/frontend_action.cpp +++ b/vndk/tools/header-checker/header-abi-dumper/src/frontend_action.cpp @@ -12,24 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "frontend_action.h" #include "ast_processing.h" -#include "frontend_action.h" -#include -#include +#include "header_abi_util.h" +#include "ir_representation.h" #include #include #include + #include -#include -#include HeaderCheckerFrontendAction::HeaderCheckerFrontendAction( const std::string &dump_name, std::set &exported_headers, abi_util::TextFormatIR text_format) - : dump_name_(dump_name), exported_headers_(exported_headers), - text_format_(text_format) { } + : dump_name_(dump_name), exported_headers_(exported_headers), + text_format_(text_format) {} std::unique_ptr HeaderCheckerFrontendAction::CreateASTConsumer(clang::CompilerInstance &ci, diff --git a/vndk/tools/header-checker/header-abi-dumper/src/frontend_action.h b/vndk/tools/header-checker/header-abi-dumper/src/frontend_action.h index 294c60838..82b6b648e 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/frontend_action.h +++ b/vndk/tools/header-checker/header-abi-dumper/src/frontend_action.h @@ -15,7 +15,7 @@ #ifndef FRONTEND_ACTION_H_ #define FRONTEND_ACTION_H_ -#include +#include "ir_representation.h" #include #include diff --git a/vndk/tools/header-checker/header-abi-dumper/src/frontend_action_factory.cpp b/vndk/tools/header-checker/header-abi-dumper/src/frontend_action_factory.cpp index 30372dc47..27822fe78 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/frontend_action_factory.cpp +++ b/vndk/tools/header-checker/header-abi-dumper/src/frontend_action_factory.cpp @@ -22,8 +22,8 @@ HeaderCheckerFrontendActionFactory::HeaderCheckerFrontendActionFactory( const std::string &dump_name, std::set &exported_headers, abi_util::TextFormatIR text_format) - : dump_name_(dump_name), exported_headers_(exported_headers), - text_format_(text_format) { } + : dump_name_(dump_name), exported_headers_(exported_headers), + text_format_(text_format) {} clang::FrontendAction *HeaderCheckerFrontendActionFactory::create() { return new HeaderCheckerFrontendAction(dump_name_, exported_headers_, diff --git a/vndk/tools/header-checker/header-abi-dumper/src/frontend_action_factory.h b/vndk/tools/header-checker/header-abi-dumper/src/frontend_action_factory.h index 0932372b7..1688f266c 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/frontend_action_factory.h +++ b/vndk/tools/header-checker/header-abi-dumper/src/frontend_action_factory.h @@ -15,7 +15,8 @@ #ifndef FRONTEND_ACTION_FACTORY_H_ #define FRONTEND_ACTION_FACTORY_H_ -#include +#include "ir_representation.h" + #include #include diff --git a/vndk/tools/header-checker/header-abi-dumper/src/header_checker.cpp b/vndk/tools/header-checker/header-abi-dumper/src/header_checker.cpp index c81ca5170..9b2959780 100644 --- a/vndk/tools/header-checker/header-abi-dumper/src/header_checker.cpp +++ b/vndk/tools/header-checker/header-abi-dumper/src/header_checker.cpp @@ -14,8 +14,7 @@ #include "fixed_argv.h" #include "frontend_action_factory.h" - -#include +#include "header_abi_util.h" #include #include diff --git a/vndk/tools/header-checker/header-abi-dumper/src/omp_header_data.h b/vndk/tools/header-checker/header-abi-dumper/src/omp_header_data.h deleted file mode 100644 index e95b1a531..000000000 --- a/vndk/tools/header-checker/header-abi-dumper/src/omp_header_data.h +++ /dev/null @@ -1,221 +0,0 @@ -#ifndef OMP_HEADER_DATA_H_ -#define OMP_HEADER_DATA_H_ - -const char OMP_HEADER_DATA[] = R"__SOURCE__( -/* - * include/50/omp.h.var - */ - - -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. -// -//===----------------------------------------------------------------------===// - - -#ifndef __OMP_H -# define __OMP_H - -# define KMP_VERSION_MAJOR 5 -# define KMP_VERSION_MINOR 0 -# define KMP_VERSION_BUILD 20140926 -# define KMP_BUILD_DATE "No_Timestamp" - -# ifdef __cplusplus - extern "C" { -# endif - -# if defined(_WIN32) -# define __KAI_KMPC_CONVENTION __cdecl -# else -# define __KAI_KMPC_CONVENTION -# endif - - /* schedule kind constants */ - typedef enum omp_sched_t { - omp_sched_static = 1, - omp_sched_dynamic = 2, - omp_sched_guided = 3, - omp_sched_auto = 4 - } omp_sched_t; - - /* set API functions */ - extern void __KAI_KMPC_CONVENTION omp_set_num_threads (int); - extern void __KAI_KMPC_CONVENTION omp_set_dynamic (int); - extern void __KAI_KMPC_CONVENTION omp_set_nested (int); - extern void __KAI_KMPC_CONVENTION omp_set_max_active_levels (int); - extern void __KAI_KMPC_CONVENTION omp_set_schedule (omp_sched_t, int); - - /* query API functions */ - extern int __KAI_KMPC_CONVENTION omp_get_num_threads (void); - extern int __KAI_KMPC_CONVENTION omp_get_dynamic (void); - extern int __KAI_KMPC_CONVENTION omp_get_nested (void); - extern int __KAI_KMPC_CONVENTION omp_get_max_threads (void); - extern int __KAI_KMPC_CONVENTION omp_get_thread_num (void); - extern int __KAI_KMPC_CONVENTION omp_get_num_procs (void); - extern int __KAI_KMPC_CONVENTION omp_in_parallel (void); - extern int __KAI_KMPC_CONVENTION omp_in_final (void); - extern int __KAI_KMPC_CONVENTION omp_get_active_level (void); - extern int __KAI_KMPC_CONVENTION omp_get_level (void); - extern int __KAI_KMPC_CONVENTION omp_get_ancestor_thread_num (int); - extern int __KAI_KMPC_CONVENTION omp_get_team_size (int); - extern int __KAI_KMPC_CONVENTION omp_get_thread_limit (void); - extern int __KAI_KMPC_CONVENTION omp_get_max_active_levels (void); - extern void __KAI_KMPC_CONVENTION omp_get_schedule (omp_sched_t *, int *); - extern int __KAI_KMPC_CONVENTION omp_get_max_task_priority (void); - - /* lock API functions */ - typedef struct omp_lock_t { - void * _lk; - } omp_lock_t; - - extern void __KAI_KMPC_CONVENTION omp_init_lock (omp_lock_t *); - extern void __KAI_KMPC_CONVENTION omp_set_lock (omp_lock_t *); - extern void __KAI_KMPC_CONVENTION omp_unset_lock (omp_lock_t *); - extern void __KAI_KMPC_CONVENTION omp_destroy_lock (omp_lock_t *); - extern int __KAI_KMPC_CONVENTION omp_test_lock (omp_lock_t *); - - /* nested lock API functions */ - typedef struct omp_nest_lock_t { - void * _lk; - } omp_nest_lock_t; - - extern void __KAI_KMPC_CONVENTION omp_init_nest_lock (omp_nest_lock_t *); - extern void __KAI_KMPC_CONVENTION omp_set_nest_lock (omp_nest_lock_t *); - extern void __KAI_KMPC_CONVENTION omp_unset_nest_lock (omp_nest_lock_t *); - extern void __KAI_KMPC_CONVENTION omp_destroy_nest_lock (omp_nest_lock_t *); - extern int __KAI_KMPC_CONVENTION omp_test_nest_lock (omp_nest_lock_t *); - - /* lock hint type for dynamic user lock */ - typedef enum omp_lock_hint_t { - omp_lock_hint_none = 0, - omp_lock_hint_uncontended = 1, - omp_lock_hint_contended = (1<<1 ), - omp_lock_hint_nonspeculative = (1<<2 ), - omp_lock_hint_speculative = (1<<3 ), - kmp_lock_hint_hle = (1<<16), - kmp_lock_hint_rtm = (1<<17), - kmp_lock_hint_adaptive = (1<<18) - } omp_lock_hint_t; - - /* hinted lock initializers */ - extern void __KAI_KMPC_CONVENTION omp_init_lock_with_hint(omp_lock_t *, omp_lock_hint_t); - extern void __KAI_KMPC_CONVENTION omp_init_nest_lock_with_hint(omp_nest_lock_t *, omp_lock_hint_t); - - /* time API functions */ - extern double __KAI_KMPC_CONVENTION omp_get_wtime (void); - extern double __KAI_KMPC_CONVENTION omp_get_wtick (void); - - /* OpenMP 4.0 */ - extern int __KAI_KMPC_CONVENTION omp_get_default_device (void); - extern void __KAI_KMPC_CONVENTION omp_set_default_device (int); - extern int __KAI_KMPC_CONVENTION omp_is_initial_device (void); - extern int __KAI_KMPC_CONVENTION omp_get_num_devices (void); - extern int __KAI_KMPC_CONVENTION omp_get_num_teams (void); - extern int __KAI_KMPC_CONVENTION omp_get_team_num (void); - extern int __KAI_KMPC_CONVENTION omp_get_cancellation (void); - -# include - /* OpenMP 4.5 */ - extern int __KAI_KMPC_CONVENTION omp_get_initial_device (void); - extern void* __KAI_KMPC_CONVENTION omp_target_alloc(size_t, int); - extern void __KAI_KMPC_CONVENTION omp_target_free(void *, int); - extern int __KAI_KMPC_CONVENTION omp_target_is_present(void *, int); - extern int __KAI_KMPC_CONVENTION omp_target_memcpy(void *, void *, size_t, size_t, size_t, int, int); - extern int __KAI_KMPC_CONVENTION omp_target_memcpy_rect(void *, void *, size_t, int, const size_t *, - const size_t *, const size_t *, const size_t *, const size_t *, int, int); - extern int __KAI_KMPC_CONVENTION omp_target_associate_ptr(void *, void *, size_t, size_t, int); - extern int __KAI_KMPC_CONVENTION omp_target_disassociate_ptr(void *, int); - - /* kmp API functions */ - extern int __KAI_KMPC_CONVENTION kmp_get_stacksize (void); - extern void __KAI_KMPC_CONVENTION kmp_set_stacksize (int); - extern size_t __KAI_KMPC_CONVENTION kmp_get_stacksize_s (void); - extern void __KAI_KMPC_CONVENTION kmp_set_stacksize_s (size_t); - extern int __KAI_KMPC_CONVENTION kmp_get_blocktime (void); - extern int __KAI_KMPC_CONVENTION kmp_get_library (void); - extern void __KAI_KMPC_CONVENTION kmp_set_blocktime (int); - extern void __KAI_KMPC_CONVENTION kmp_set_library (int); - extern void __KAI_KMPC_CONVENTION kmp_set_library_serial (void); - extern void __KAI_KMPC_CONVENTION kmp_set_library_turnaround (void); - extern void __KAI_KMPC_CONVENTION kmp_set_library_throughput (void); - extern void __KAI_KMPC_CONVENTION kmp_set_defaults (char const *); - extern void __KAI_KMPC_CONVENTION kmp_set_disp_num_buffers (int); - - /* Intel affinity API */ - typedef void * kmp_affinity_mask_t; - - extern int __KAI_KMPC_CONVENTION kmp_set_affinity (kmp_affinity_mask_t *); - extern int __KAI_KMPC_CONVENTION kmp_get_affinity (kmp_affinity_mask_t *); - extern int __KAI_KMPC_CONVENTION kmp_get_affinity_max_proc (void); - extern void __KAI_KMPC_CONVENTION kmp_create_affinity_mask (kmp_affinity_mask_t *); - extern void __KAI_KMPC_CONVENTION kmp_destroy_affinity_mask (kmp_affinity_mask_t *); - extern int __KAI_KMPC_CONVENTION kmp_set_affinity_mask_proc (int, kmp_affinity_mask_t *); - extern int __KAI_KMPC_CONVENTION kmp_unset_affinity_mask_proc (int, kmp_affinity_mask_t *); - extern int __KAI_KMPC_CONVENTION kmp_get_affinity_mask_proc (int, kmp_affinity_mask_t *); - - /* OpenMP 4.0 affinity API */ - typedef enum omp_proc_bind_t { - omp_proc_bind_false = 0, - omp_proc_bind_true = 1, - omp_proc_bind_master = 2, - omp_proc_bind_close = 3, - omp_proc_bind_spread = 4 - } omp_proc_bind_t; - - extern omp_proc_bind_t __KAI_KMPC_CONVENTION omp_get_proc_bind (void); - - /* OpenMP 4.5 affinity API */ - extern int __KAI_KMPC_CONVENTION omp_get_num_places (void); - extern int __KAI_KMPC_CONVENTION omp_get_place_num_procs (int); - extern void __KAI_KMPC_CONVENTION omp_get_place_proc_ids (int, int *); - extern int __KAI_KMPC_CONVENTION omp_get_place_num (void); - extern int __KAI_KMPC_CONVENTION omp_get_partition_num_places (void); - extern void __KAI_KMPC_CONVENTION omp_get_partition_place_nums (int *); - - extern void * __KAI_KMPC_CONVENTION kmp_malloc (size_t); - extern void * __KAI_KMPC_CONVENTION kmp_aligned_malloc (size_t, size_t); - extern void * __KAI_KMPC_CONVENTION kmp_calloc (size_t, size_t); - extern void * __KAI_KMPC_CONVENTION kmp_realloc (void *, size_t); - extern void __KAI_KMPC_CONVENTION kmp_free (void *); - - extern void __KAI_KMPC_CONVENTION kmp_set_warnings_on(void); - extern void __KAI_KMPC_CONVENTION kmp_set_warnings_off(void); - - /* OpenMP 5.0 Tool Control */ - typedef enum omp_control_tool_result_t { - omp_control_tool_notool = -2, - omp_control_tool_nocallback = -1, - omp_control_tool_success = 0, - omp_control_tool_ignored = 1 - } omp_control_tool_result_t; - - typedef enum omp_control_tool_t { - omp_control_tool_start = 1, - omp_control_tool_pause = 2, - omp_control_tool_flush = 3, - omp_control_tool_end = 4 - } omp_control_tool_t; - - extern int __KAI_KMPC_CONVENTION omp_control_tool(int, int, void*); - -# undef __KAI_KMPC_CONVENTION - - /* Warning: - The following typedefs are not standard, deprecated and will be removed in a future release. - */ - typedef int omp_int_t; - typedef double omp_wtime_t; - -# ifdef __cplusplus - } -# endif - -#endif /* __OMP_H */ -)__SOURCE__"; - -#endif // OMP_HEADER_DATA_H_ diff --git a/vndk/tools/header-checker/header-abi-dumper/src/workaround_fortify.cpp b/vndk/tools/header-checker/header-abi-dumper/src/workaround_fortify.cpp deleted file mode 100644 index 39495c941..000000000 --- a/vndk/tools/header-checker/header-abi-dumper/src/workaround_fortify.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2018 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "fixed_argv.h" - -static void DisableFortifySource(FixedArgv &fixed_argv) { - // FIXME: Clang FORTIFY requires a version of clang at least as new as - // clang-3688880 (r285906). Since external/clang is currently r275480, we need - // to disable FORTIFY for this tool to function correctly. - fixed_argv.PushForwardArgs("-U_FORTIFY_SOURCE"); -} - -static FixedArgvRegistry X(DisableFortifySource); diff --git a/vndk/tools/header-checker/header-abi-dumper/src/workaround_openmp.cpp b/vndk/tools/header-checker/header-abi-dumper/src/workaround_openmp.cpp deleted file mode 100644 index cf583ed49..000000000 --- a/vndk/tools/header-checker/header-abi-dumper/src/workaround_openmp.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2018 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "fixed_argv.h" -#include "omp_header_data.h" - -#include -#include -#include - -#include -#include -#include - -#include - -static std::string openmp_include_dir; - -static void RemoveOpenMPIncludeDir() { - if (openmp_include_dir.empty()) { - return; - } - - // Remove the header file. - llvm::SmallString<64> path; - llvm::sys::path::append(path, openmp_include_dir, "omp.h"); - llvm::sys::fs::remove(llvm::Twine(path)); - - // Remove the directory. - llvm::sys::fs::remove(llvm::Twine(openmp_include_dir)); -} - -static std::error_code WriteFile(const char *path, const char *data, - size_t size) { - std::fstream output(path, std::ios_base::out | std::ios_base::trunc); - if (!output) { - return std::make_error_code(std::io_errc::stream); - } - - output.write(data, size); - if (!output) { - return std::make_error_code(std::io_errc::stream); - } - - return std::error_code(); -} - -static std::error_code CreateOpenMPIncludeDir() { - llvm::SmallString<64> path; - - // Create a temporary directory for include fixes. - std::error_code error_code = - llvm::sys::fs::createUniqueDirectory("header-abi-dump-include", path); - if (error_code) { - return error_code; - } - - openmp_include_dir = path.str(); - - // Register a directory cleanup callback. - ::atexit(RemoveOpenMPIncludeDir); - - // Create and write the content. - llvm::sys::path::append(path, "omp.h"); - return WriteFile(path.c_str(), OMP_HEADER_DATA, sizeof(OMP_HEADER_DATA) - 1); -} - -static void SetupOpenMPIncludeDir(FixedArgv &fixed_argv) { - // FIXME: clang-3289846 does not have . This workaround copies omp.h - // from LLVM 5.0+ and adds `-isystem` to header search paths. - if (fixed_argv.IsLastArgEqualFirstOption("-fopenmp", "-fno-openmp")) { - std::error_code ec = CreateOpenMPIncludeDir(); - if (!ec) { - fixed_argv.PushForwardArgs("-isystem", openmp_include_dir.c_str()); - } - } -} - -static FixedArgvRegistry X(SetupOpenMPIncludeDir); diff --git a/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp b/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp index 53e7dfaf8..cb3fcb09e 100644 --- a/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp +++ b/vndk/tools/header-checker/header-abi-linker/src/header_abi_linker.cpp @@ -12,17 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include "header_abi_util.h" +#include "ir_representation.h" +#include "so_file_parser.h" +#include "version_script_parser.h" #include #include -#include -#include #include #include #include +#include +#include #include #include #include @@ -92,9 +94,9 @@ class HeaderAbiLinker { const std::string &linked_dump, const std::string &arch, const std::string &api) - : dump_files_(dump_files), exported_header_dirs_(exported_header_dirs), - version_script_(version_script), so_file_(so_file), - out_dump_name_(linked_dump), arch_(arch), api_(api) {}; + : dump_files_(dump_files), exported_header_dirs_(exported_header_dirs), + version_script_(version_script), so_file_(so_file), + out_dump_name_(linked_dump), arch_(arch), api_(api) {} bool LinkAndDump(); @@ -278,8 +280,7 @@ static std::regex CreateRegexMatchExprFromSet( template bool HeaderAbiLinker::LinkDecl( - abi_util::IRDumper *dst, - const abi_util::AbiElementMap &src, + abi_util::IRDumper *dst, const abi_util::AbiElementMap &src, const std::function &symbol_filter) { assert(dst != nullptr); for (auto &&element : src) { @@ -345,8 +346,8 @@ bool HeaderAbiLinker::LinkGlobalVars( } bool HeaderAbiLinker::ParseVersionScriptFiles() { - abi_util::VersionScriptParser version_script_parser(version_script_, arch_, - api_); + abi_util::VersionScriptParser version_script_parser( + version_script_, arch_, api_); if (!version_script_parser.Parse()) { llvm::errs() << "Failed to parse version script\n"; return false; diff --git a/vndk/tools/header-checker/header-abi-util/include/abi_diff_helpers.h b/vndk/tools/header-checker/header-abi-util/include/abi_diff_helpers.h index 839bac038..3fda32663 100644 --- a/vndk/tools/header-checker/header-abi-util/include/abi_diff_helpers.h +++ b/vndk/tools/header-checker/header-abi-util/include/abi_diff_helpers.h @@ -1,7 +1,21 @@ -#ifndef ABI_DIFF_HELPERS -#define ABI_DIFF_HELPERS +// Copyright (C) 2018 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. -#include +#ifndef ABI_DIFF_HELPERS_H_ +#define ABI_DIFF_HELPERS_H_ + +#include "ir_representation.h" #include @@ -23,13 +37,13 @@ enum DiffStatus { opaque_diff = 3, }; -static inline DiffStatus operator| (DiffStatus f,DiffStatus s) { +static inline DiffStatus operator|(DiffStatus f,DiffStatus s) { return static_cast( static_cast::type>(f) | static_cast::type>(s)); } -static inline DiffStatus operator& (DiffStatus f, DiffStatus s) { +static inline DiffStatus operator&(DiffStatus f, DiffStatus s) { return static_cast( static_cast::type>(f) & static_cast::type>(s)); @@ -49,9 +63,10 @@ struct GenericFieldDiffInfo { std::string Unwind(const std::deque *type_queue); struct DiffPolicyOptions { - DiffPolicyOptions(bool consider_opaque_types_different) : - consider_opaque_types_different_(consider_opaque_types_different) { } - bool consider_opaque_types_different_ = false; + DiffPolicyOptions(bool consider_opaque_types_different) + : consider_opaque_types_different_(consider_opaque_types_different) {} + + bool consider_opaque_types_different_; }; class AbiDiffHelper { @@ -66,7 +81,7 @@ class AbiDiffHelper { : old_types_(old_types), new_types_(new_types), diff_policy_options_(diff_policy_options), type_cache_(type_cache), ir_diff_dumper_(ir_diff_dumper), - local_to_global_type_id_map_(local_to_global_type_id_map) { } + local_to_global_type_id_map_(local_to_global_type_id_map) {} DiffStatus CompareAndDumpTypeDiff( const std::string &old_type_str, const std::string &new_type_str, @@ -110,10 +125,11 @@ class AbiDiffHelper { DiffStatus CompareBuiltinTypes(const abi_util::BuiltinTypeIR *old_type, const abi_util::BuiltinTypeIR *new_type); + static void CompareEnumFields( - const std::vector &old_fields, - const std::vector &new_fields, - abi_util::EnumTypeDiffIR *enum_type_diff_ir); + const std::vector &old_fields, + const std::vector &new_fields, + abi_util::EnumTypeDiffIR *enum_type_diff_ir); DiffStatus CompareEnumTypes(const abi_util::EnumTypeIR *old_type, const abi_util::EnumTypeIR *new_type, @@ -126,7 +142,7 @@ class AbiDiffHelper { abi_util::DiffMessageIR::DiffKind diff_kind); void ReplaceRemovedFieldTypeIdsWithTypeNames( - std::vector *removed_fields); + std::vector *removed_fields); void ReplaceDiffedFieldTypeIdsWithTypeNames( abi_util::RecordFieldDiffIR *diffed_field); @@ -137,10 +153,10 @@ class AbiDiffHelper { DiffStatusPair> CompareCommonRecordFields( - const abi_util::RecordFieldIR *old_field, - const abi_util::RecordFieldIR *new_field, - std::deque *type_queue, - abi_util::IRDiffDumper::DiffKind diff_kind); + const abi_util::RecordFieldIR *old_field, + const abi_util::RecordFieldIR *new_field, + std::deque *type_queue, + abi_util::IRDiffDumper::DiffKind diff_kind); GenericFieldDiffInfo CompareRecordFields( @@ -182,17 +198,19 @@ class AbiDiffHelper { bool AddToDiff(DiffType *mutable_diff, const DiffElement *oldp, const DiffElement *newp, std::deque *type_queue = nullptr); + protected: const AbiElementMap &old_types_; const AbiElementMap &new_types_; const DiffPolicyOptions &diff_policy_options_; - std::set *type_cache_ = nullptr; - abi_util::IRDiffDumper *ir_diff_dumper_ = nullptr; - AbiElementMap *local_to_global_type_id_map_ = nullptr; + std::set *type_cache_; + abi_util::IRDiffDumper *ir_diff_dumper_; + AbiElementMap *local_to_global_type_id_map_; }; void ReplaceTypeIdsWithTypeNames( const AbiElementMap &type_graph, LinkableMessageIR *lm); -} // namespace abi_util -#endif +} // namespace abi_util + +#endif // ABI_DIFF_HELPERS_H_ diff --git a/vndk/tools/header-checker/header-abi-util/include/header_abi_util.h b/vndk/tools/header-checker/header-abi-util/include/header_abi_util.h index 3c7d5eb40..aa55dad76 100644 --- a/vndk/tools/header-checker/header-abi-util/include/header_abi_util.h +++ b/vndk/tools/header-checker/header-abi-util/include/header_abi_util.h @@ -12,13 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#ifndef HEADER_ABI_UTIL_H_ +#define HEADER_ABI_UTIL_H_ -#include -#include -#include -#include -#include +#include "ir_representation.h" #include #include @@ -26,11 +23,6 @@ #include #include -using llvm::object::ObjectFile; -using llvm::object::ELFObjectFile; -using llvm::object::ELFFile; -using llvm::object::ELFType; - namespace abi_util { std::string RealPath(const std::string &path); @@ -38,58 +30,6 @@ std::string RealPath(const std::string &path); std::set CollectAllExportedHeaders( const std::vector &exported_header_dirs); -class VersionScriptParser { - public: - - enum LineScope { - global, - local, - }; - - VersionScriptParser(const std::string &version_script, - const std::string &arch, - const std::string &api); - bool Parse(); - - const std::map &GetFunctions(); - - const std::map &GetGlobVars(); - - const std::set &GetFunctionRegexs(); - - const std::set &GetGlobVarRegexs(); - - private: - - bool ParseInnerBlock(std::ifstream &symbol_ifstream); - - LineScope GetLineScope(std::string &line, LineScope scope); - - bool ParseSymbolLine(const std::string &line); - - bool SymbolInArchAndApiVersion(const std::string &line, - const std::string &arch, int api); - - bool SymbolExported(const std::string &line, const std::string &arch, - int api); - - int ApiStrToInt(const std::string &api); - - void AddToVars(std::string &symbol); - - void AddToFunctions(std::string &symbol); - - private: - const std::string &version_script_; - const std::string &arch_; - std::map functions_; - std::map globvars_; - // Added to speed up version script parsing and linking. - std::set function_regexs_; - std::set globvar_regexs_; - int api_; -}; - inline std::string FindAndReplace(const std::string &candidate_str, const std::string &find_str, const std::string &replace_str) { @@ -99,50 +39,17 @@ inline std::string FindAndReplace(const std::string &candidate_str, return std::regex_replace(candidate_str, match_expr, replace_str); } - -class SoFileParser { -public: - static std::unique_ptr Create(const ObjectFile *obj); - virtual const std::map &GetFunctions() const = 0; - virtual const std::map &GetGlobVars() const = 0; - virtual ~SoFileParser() {}; - virtual void GetSymbols() = 0; -}; - -template -class ELFSoFileParser : public SoFileParser { - public: - const std::map &GetFunctions() const override; - - const std::map &GetGlobVars() const override; - - LLVM_ELF_IMPORT_TYPES_ELFT(T) - typedef ELFFile ELFO; - typedef typename ELFO::Elf_Sym Elf_Sym; - - ELFSoFileParser(const ELFObjectFile *obj) : obj_(obj) {} - virtual ~ELFSoFileParser() override {}; - void GetSymbols() override; - private: - const ELFObjectFile *obj_; - std::map functions_; - std::map globvars_; - - private: - bool IsSymbolExported(const Elf_Sym *elf_sym) const; -}; - template std::vector FindRemovedElements( const std::map &old_elements_map, const std::map &new_elements_map) { std::vector removed_elements; for (auto &&map_element : old_elements_map) { - auto element_key = map_element.first; - auto new_element = new_elements_map.find(element_key); - if (new_element == new_elements_map.end()) { - removed_elements.emplace_back(map_element.second); - } + auto element_key = map_element.first; + auto new_element = new_elements_map.find(element_key); + if (new_element == new_elements_map.end()) { + removed_elements.emplace_back(map_element.second); + } } return removed_elements; } @@ -190,4 +97,6 @@ std::vector> FindCommonElements( return common_elements; } -} // namespace abi_util +} // namespace abi_util + +#endif // HEADER_ABI_UTIL_H_ diff --git a/vndk/tools/header-checker/header-abi-util/include/ir_representation.h b/vndk/tools/header-checker/header-abi-util/include/ir_representation.h index 2d6bd22df..7235248b8 100644 --- a/vndk/tools/header-checker/header-abi-util/include/ir_representation.h +++ b/vndk/tools/header-checker/header-abi-util/include/ir_representation.h @@ -11,17 +11,18 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef IR_ -#define IR_ + +#ifndef IR_REPRESENTATION_H_ +#define IR_REPRESENTATION_H_ #include -#include -#include -#include #include +#include +#include #include #include #include +#include #include // Classes which act as middle-men between clang AST parsing routines and @@ -57,8 +58,8 @@ static inline CompatibilityStatusIR operator|(CompatibilityStatusIR f, static_cast::type>(s)); } -static inline CompatibilityStatusIR operator&( - CompatibilityStatusIR f, CompatibilityStatusIR s) { +static inline CompatibilityStatusIR operator&(CompatibilityStatusIR f, + CompatibilityStatusIR s) { return static_cast( static_cast::type>(f) & static_cast::type>(s)); @@ -95,6 +96,8 @@ std::map CreateInverseMap(const std::map &m) { class LinkableMessageIR { public: + virtual ~LinkableMessageIR() {} + const std::string &GetLinkerSetKey() const { return linker_set_key_; } @@ -112,7 +115,7 @@ class LinkableMessageIR { } virtual LinkableMessageKind GetKind() const = 0; - virtual ~LinkableMessageIR() { }; + protected: // The source file where this message comes from. This will be an empty string // for built-in types. @@ -122,6 +125,14 @@ class LinkableMessageIR { class ReferencesOtherType { public: + ReferencesOtherType(const std::string &referenced_type) + : referenced_type_(referenced_type) {} + + ReferencesOtherType(std::string &&referenced_type) + : referenced_type_(std::move(referenced_type)) {} + + ReferencesOtherType() {} + void SetReferencedType(const std::string &referenced_type) { referenced_type_ = referenced_type; } @@ -130,21 +141,14 @@ class ReferencesOtherType { return referenced_type_; } - ReferencesOtherType(const std::string &referenced_type) - : referenced_type_(referenced_type) { } - - ReferencesOtherType(std::string &&referenced_type) - : referenced_type_(std::move(referenced_type)) { } - - ReferencesOtherType() { } - protected: std::string referenced_type_; }; -// TODO: Break this up into types with sizes and those without types ? -class TypeIR : public LinkableMessageIR , public ReferencesOtherType { +// TODO: Break this up into types with sizes and those without types? +class TypeIR : public LinkableMessageIR, public ReferencesOtherType { public: + virtual ~TypeIR() {} void SetSelfType(const std::string &self_type) { self_type_ = self_type; @@ -165,18 +169,19 @@ class TypeIR : public LinkableMessageIR , public ReferencesOtherType { void SetSize(uint64_t size) { size_ = size; } + uint64_t GetSize() const { - return size_; + return size_; } + void SetAlignment(uint32_t alignment) { alignment_ = alignment; } + uint32_t GetAlignment() const { return alignment_; } - virtual ~TypeIR() { } - protected: std::string name_; std::string self_type_; @@ -195,7 +200,7 @@ class TagTypeIR { } protected: - std::string unique_id_; + std::string unique_id_; }; class VTableComponentIR { @@ -213,9 +218,9 @@ class VTableComponentIR { VTableComponentIR(const std::string &name, Kind kind, int64_t value, bool is_pure) - : component_name_(name), kind_(kind), value_(value), is_pure_(is_pure) { } + : component_name_(name), kind_(kind), value_(value), is_pure_(is_pure) {} - VTableComponentIR() { } + VTableComponentIR() {} Kind GetKind() const { return kind_; @@ -261,10 +266,10 @@ class VTableLayoutIR { class CXXBaseSpecifierIR : public ReferencesOtherType { public: CXXBaseSpecifierIR(const std::string &type, bool is_virtual, - AccessSpecifierIR access) : - ReferencesOtherType(type), is_virtual_(is_virtual), access_(access) { } + AccessSpecifierIR access) + : ReferencesOtherType(type), is_virtual_(is_virtual), access_(access) {} - CXXBaseSpecifierIR() { } + CXXBaseSpecifierIR() {} bool IsVirtual() const { return is_virtual_; @@ -282,12 +287,12 @@ class CXXBaseSpecifierIR : public ReferencesOtherType { class TemplateElementIR : public ReferencesOtherType { public: TemplateElementIR(std::string &&type) - : ReferencesOtherType(std::move(type)) { } + : ReferencesOtherType(std::move(type)) {} TemplateElementIR(const std::string &type) - : ReferencesOtherType(type) { } + : ReferencesOtherType(type) {} - TemplateElementIR() { } + TemplateElementIR() {} }; class TemplateInfoIR { @@ -331,9 +336,9 @@ class RecordFieldIR : public ReferencesOtherType { RecordFieldIR(const std::string &name, const std::string &type, uint64_t offset, AccessSpecifierIR access) : ReferencesOtherType(type), name_(name), offset_(offset), - access_(access) { } + access_(access) {} - RecordFieldIR() { } + RecordFieldIR() {} const std::string &GetName() const { return name_; @@ -353,8 +358,8 @@ class RecordFieldIR : public ReferencesOtherType { AccessSpecifierIR access_ = AccessSpecifierIR::PublicAccess; }; -class RecordTypeIR: public TypeIR, public TemplatedArtifactIR, - public TagTypeIR { +class RecordTypeIR : public TypeIR, public TemplatedArtifactIR, + public TagTypeIR { public: enum RecordKind { struct_kind, @@ -408,7 +413,7 @@ class RecordTypeIR: public TypeIR, public TemplatedArtifactIR, return fields_; } - LinkableMessageKind GetKind() const override { + LinkableMessageKind GetKind() const override { return LinkableMessageKind::RecordTypeKind; } @@ -444,7 +449,8 @@ class RecordTypeIR: public TypeIR, public TemplatedArtifactIR, class EnumFieldIR { public: EnumFieldIR(const std::string &name, int value) - : name_(name), value_(value) { } + : name_(name), value_(value) {} + const std::string &GetName() const { return name_; } @@ -467,7 +473,7 @@ class EnumTypeIR : public TypeIR, public TagTypeIR { void SetAccess(AccessSpecifierIR access) { access_ = access;} - LinkableMessageKind GetKind() const override { + LinkableMessageKind GetKind() const override { return LinkableMessageKind::EnumTypeKind; } @@ -594,7 +600,7 @@ class QualifiedTypeIR : public TypeIR { bool is_volatile_; }; -class GlobalVarIR: public LinkableMessageIR , public ReferencesOtherType { +class GlobalVarIR : public LinkableMessageIR , public ReferencesOtherType { public: // Add Methods to get information from the IR. void SetName(std::string &&name) { @@ -628,9 +634,9 @@ class GlobalVarIR: public LinkableMessageIR , public ReferencesOtherType { class ParamIR : public ReferencesOtherType { public: - ParamIR(const std::string &type, bool is_default, bool is_this_ptr) : - ReferencesOtherType(type) , is_default_(is_default), - is_this_ptr_(is_this_ptr) {} + ParamIR(const std::string &type, bool is_default, bool is_this_ptr) + : ReferencesOtherType(type) , is_default_(is_default), + is_this_ptr_(is_this_ptr) {} bool GetIsDefault() const { return is_default_; @@ -666,6 +672,7 @@ class CFunctionLikeIR { std::vector &GetParameters() { return parameters_; } + protected: std::string return_type_; // return type reference std::vector parameters_; @@ -724,6 +731,12 @@ class ElfSymbolIR { Protected, }; + public: + ElfSymbolIR(const std::string &name, ElfSymbolBinding binding) + : name_(name), binding_(binding) {} + + virtual ~ElfSymbolIR() {} + const std::string GetName() const { return name_; } @@ -732,14 +745,8 @@ class ElfSymbolIR { return binding_; } - - ElfSymbolIR(const std::string &name, ElfSymbolBinding binding) - : name_(name), binding_(binding) { } - virtual ElfSymbolKind GetKind() const = 0; - virtual ~ElfSymbolIR() { } - protected: std::string name_; ElfSymbolBinding binding_; @@ -747,27 +754,29 @@ class ElfSymbolIR { class ElfFunctionIR : public ElfSymbolIR { public: + ElfFunctionIR(const std::string &name, ElfSymbolBinding binding) + : ElfSymbolIR(name, binding) {} + ElfSymbolKind GetKind() const override { return ElfFunctionKind; } - - ElfFunctionIR(const std::string &name, ElfSymbolBinding binding) - : ElfSymbolIR(name, binding) { } }; class ElfObjectIR : public ElfSymbolIR { public: + ElfObjectIR(const std::string &name, ElfSymbolBinding binding) + : ElfSymbolIR(name, binding) {} + ElfSymbolKind GetKind() const override { return ElfObjectKind; } - - ElfObjectIR(const std::string &name, ElfSymbolBinding binding) - : ElfSymbolIR(name, binding) { } }; class IRDumper { public: - IRDumper(const std::string &dump_path) : dump_path_(dump_path) { } + IRDumper(const std::string &dump_path) : dump_path_(dump_path) {} + + virtual ~IRDumper() {} static std::unique_ptr CreateIRDumper( TextFormatIR text_format, const std::string &dump_path); @@ -778,21 +787,17 @@ class IRDumper { virtual bool Dump() = 0; - virtual ~IRDumper() {} - protected: const std::string &dump_path_; }; template -inline std::string GetReferencedTypeMapKey( - T &element) { +inline std::string GetReferencedTypeMapKey(T &element) { return element.GetReferencedType(); } template <> -inline std::string GetReferencedTypeMapKey( - ArrayTypeIR &element) { +inline std::string GetReferencedTypeMapKey(ArrayTypeIR &element) { return element.GetReferencedType() + ":" + std::to_string(element.GetSize()); } @@ -842,8 +847,12 @@ typename AbiElementMap::iterator AddToMapAndTypeGraph( class TextFormatToIRReader { public: - struct MergeStatus { + MergeStatus(bool was_newly_added, const std::string &type_id) + : was_newly_added_(was_newly_added), type_id_(type_id) {} + + MergeStatus() {} + // type_id_ always has the global_type_id corresponding to the type this // MergeStatus corresponds to. For // generic reference types (pointers, qual types, l(r)value references etc), @@ -851,14 +860,15 @@ class TextFormatToIRReader { // parent type_graph if the we decide to add the referencing type to the // parent post ODR checking. bool was_newly_added_ = false; + std::string type_id_; - MergeStatus(bool was_newly_added, const std::string &type_id) - : was_newly_added_(was_newly_added), type_id_(type_id) { } - MergeStatus() { } }; + public: TextFormatToIRReader(const std::set *exported_headers) - : exported_headers_(exported_headers) { } + : exported_headers_(exported_headers) {} + + virtual ~TextFormatToIRReader() {} const AbiElementMap &GetFunctions() const { return functions_; @@ -880,13 +890,11 @@ class TextFormatToIRReader { return enum_types_; } - const AbiElementMap & - GetLvalueReferenceTypes() const { + const AbiElementMap &GetLvalueReferenceTypes() const { return lvalue_reference_types_; } - const AbiElementMap & - GetRvalueReferenceTypes() const { + const AbiElementMap &GetRvalueReferenceTypes() const { return rvalue_reference_types_; } @@ -919,8 +927,8 @@ class TextFormatToIRReader { } const AbiElementUnorderedMap> & - GetODRListMap() const { - return odr_list_map_; + GetODRListMap() const { + return odr_list_map_; } virtual bool ReadDump(const std::string &dump_file) = 0; @@ -928,7 +936,7 @@ class TextFormatToIRReader { template bool ReadDumps(Iterator begin, Iterator end) { Iterator it = begin; - while(it != end) { + while (it != end) { if (!ReadDump(*it)) { return false; } @@ -937,8 +945,6 @@ class TextFormatToIRReader { return true; } - virtual ~TextFormatToIRReader() { } - void Merge(TextFormatToIRReader &&addend) { MergeElements(&functions_, std::move(addend.functions_)); MergeElements(&global_variables_, std::move(addend.global_variables_)); @@ -963,9 +969,9 @@ class TextFormatToIRReader { AbiElementMap *parent_map, const std::string &updated_self_type_id); MergeStatus DoesUDTypeODRViolationExist( - const TypeIR *ud_type, const TextFormatToIRReader &addend, - const std::string ud_type_unique_id, - AbiElementMap *local_to_global_type_id_map_); + const TypeIR *ud_type, const TextFormatToIRReader &addend, + const std::string ud_type_unique_id, + AbiElementMap *local_to_global_type_id_map_); MergeStatus MergeReferencingTypeInternal( const TextFormatToIRReader &addend, ReferencesOtherType *references_type, @@ -977,39 +983,39 @@ class TextFormatToIRReader { const std::string &updated_self_type_id); MergeStatus MergeGenericReferringType( - const TextFormatToIRReader &addend, const TypeIR *addend_node, - AbiElementMap *local_to_global_type_id_map); + const TextFormatToIRReader &addend, const TypeIR *addend_node, + AbiElementMap *local_to_global_type_id_map); template std::pair::iterator> UpdateUDTypeAccounting( - const T *addend_node, const TextFormatToIRReader &addend, - AbiElementMap *local_to_global_type_id_map, - AbiElementMap *specific_type_map); + const T *addend_node, const TextFormatToIRReader &addend, + AbiElementMap *local_to_global_type_id_map, + AbiElementMap *specific_type_map); MergeStatus MergeTypeInternal( - const TypeIR *addend_node, const TextFormatToIRReader &addend, - AbiElementMap *local_to_global_type_id_map); + const TypeIR *addend_node, const TextFormatToIRReader &addend, + AbiElementMap *local_to_global_type_id_map); void MergeCFunctionLikeDeps( - const TextFormatToIRReader &addend, CFunctionLikeIR *cfunction_like_ir, - AbiElementMap *local_to_global_type_id_map); + const TextFormatToIRReader &addend, CFunctionLikeIR *cfunction_like_ir, + AbiElementMap *local_to_global_type_id_map); MergeStatus MergeFunctionType( - const FunctionTypeIR *addend_node, const TextFormatToIRReader &addend, - AbiElementMap *local_to_global_type_id_map); + const FunctionTypeIR *addend_node, const TextFormatToIRReader &addend, + AbiElementMap *local_to_global_type_id_map); MergeStatus MergeEnumType( - const EnumTypeIR *addend_node, const TextFormatToIRReader &addend, - AbiElementMap *local_to_global_type_id_map); + const EnumTypeIR *addend_node, const TextFormatToIRReader &addend, + AbiElementMap *local_to_global_type_id_map); void MergeEnumDependencies( const TextFormatToIRReader &addend, EnumTypeIR *added_node, AbiElementMap *local_to_global_type_id_map); MergeStatus MergeRecordAndDependencies( - const RecordTypeIR *addend_node, const TextFormatToIRReader &addend, - AbiElementMap *local_to_global_type_id_map); + const RecordTypeIR *addend_node, const TextFormatToIRReader &addend, + AbiElementMap *local_to_global_type_id_map); void MergeRecordDependencies( const TextFormatToIRReader &addend, RecordTypeIR *added_node, @@ -1040,12 +1046,12 @@ class TextFormatToIRReader { AbiElementMap *local_to_global_type_id_map); void MergeFunctionDeps( - FunctionIR *added_node, const TextFormatToIRReader &addend, - AbiElementMap *local_to_global_type_id_map); + FunctionIR *added_node, const TextFormatToIRReader &addend, + AbiElementMap *local_to_global_type_id_map); void MergeFunction( - const FunctionIR *addend_node, const TextFormatToIRReader &addend, - AbiElementMap *local_to_global_type_id_map); + const FunctionIR *addend_node, const TextFormatToIRReader &addend, + AbiElementMap *local_to_global_type_id_map); void MergeGraphs(const TextFormatToIRReader &addend); @@ -1057,9 +1063,9 @@ class TextFormatToIRReader { const TypeIR *addend_node, const TextFormatToIRReader &addend, AbiElementMap *local_to_global_type_id_map); - MergeStatus MergeType(const TypeIR *addend_type, - const TextFormatToIRReader &addend, - AbiElementMap *merged_types_cache); + MergeStatus MergeType( + const TypeIR *addend_type, const TextFormatToIRReader &addend, + AbiElementMap *merged_types_cache); std::string AllocateNewTypeId(); @@ -1068,7 +1074,6 @@ class TextFormatToIRReader { const std::set *exported_headers = nullptr); protected: - template inline void MergeElements(Augend *augend, Addend &&addend) { augend->insert(std::make_move_iterator(addend.begin()), @@ -1107,16 +1112,19 @@ class TextFormatToIRReader { class DiffMessageIR { public: - enum DiffKind { - Extension, // Applicable for enums. + Extension, // Applicable for enums. Added, Removed, Referenced, Unreferenced }; + public: + virtual ~DiffMessageIR() {} + virtual LinkableMessageKind Kind() const = 0; + void SetName(const std::string &name) { name_ = name; } @@ -1125,8 +1133,6 @@ class DiffMessageIR { return name_; } - virtual ~DiffMessageIR() { } - protected: std::string name_; }; @@ -1135,7 +1141,7 @@ class AccessSpecifierDiffIR { public: AccessSpecifierDiffIR(AccessSpecifierIR old_access, AccessSpecifierIR new_access) - : old_access_(old_access), new_access_(new_access) { } + : old_access_(old_access), new_access_(new_access) {} protected: AccessSpecifierIR old_access_; @@ -1146,7 +1152,7 @@ class TypeDiffIR { public: TypeDiffIR(std::pair &&sizes, std::pair &&alignment) - : sizes_(std::move(sizes)), alignments_(std::move(alignment)) { } + : sizes_(std::move(sizes)), alignments_(std::move(alignment)) {} const std::pair &GetSizes() const { return sizes_; @@ -1165,7 +1171,7 @@ class VTableLayoutDiffIR { public: VTableLayoutDiffIR(const VTableLayoutIR &old_layout, const VTableLayoutIR &new_layout) - : old_layout_(old_layout), new_layout_(new_layout) { } + : old_layout_(old_layout), new_layout_(new_layout) {} const VTableLayoutIR &GetOldVTable() const { return old_layout_; @@ -1184,7 +1190,8 @@ class RecordFieldDiffIR { public: RecordFieldDiffIR(const RecordFieldIR *old_field, const RecordFieldIR *new_field) - : old_field_(old_field), new_field_(new_field) { } + : old_field_(old_field), new_field_(new_field) {} + const RecordFieldIR *GetOldField() const { return old_field_; } @@ -1203,7 +1210,8 @@ class CXXBaseSpecifierDiffIR { const std::vector &old_base_specifiers, const std::vector &new_base_specifiers) : old_base_specifiers_(old_base_specifiers), - new_base_specifiers_(new_base_specifiers) { } + new_base_specifiers_(new_base_specifiers) {} + const std::vector &GetOldBases() const { return old_base_specifiers_; } @@ -1298,7 +1306,7 @@ class RecordTypeDiffIR : public DiffMessageIR { class EnumFieldDiffIR { public: EnumFieldDiffIR(const EnumFieldIR *old_field, const EnumFieldIR *new_field) - : old_field_(old_field), new_field_(new_field) { } + : old_field_(old_field), new_field_(new_field) {} const EnumFieldIR *GetOldField() const { return old_field_; @@ -1353,7 +1361,6 @@ class EnumTypeDiffIR : public DiffMessageIR { fields_added_.size() != 0) { return true; } - return false; } @@ -1361,7 +1368,6 @@ class EnumTypeDiffIR : public DiffMessageIR { if (fields_removed_.size() != 0 || fields_diff_.size() != 0) { return true; } - return false; } @@ -1386,17 +1392,17 @@ class GlobalVarDiffIR : public DiffMessageIR { return LinkableMessageKind::GlobalVarKind; } - GlobalVarDiffIR(const GlobalVarIR *old_global_var, - const GlobalVarIR *new_global_var) - : old_global_var_(old_global_var), new_global_var_(new_global_var) { } + GlobalVarDiffIR(const GlobalVarIR *old_global_var, + const GlobalVarIR *new_global_var) + : old_global_var_(old_global_var), new_global_var_(new_global_var) {} - const GlobalVarIR *GetOldGlobalVar() const { - return old_global_var_; - } + const GlobalVarIR *GetOldGlobalVar() const { + return old_global_var_; + } - const GlobalVarIR *GetNewGlobalVar() const { - return new_global_var_; - } + const GlobalVarIR *GetNewGlobalVar() const { + return new_global_var_; + } protected: const GlobalVarIR *old_global_var_; @@ -1405,14 +1411,14 @@ class GlobalVarDiffIR : public DiffMessageIR { class FunctionDiffIR : public DiffMessageIR { public: + FunctionDiffIR(const FunctionIR *old_function, + const FunctionIR *new_function) + : old_function_(old_function), new_function_(new_function) {} + LinkableMessageKind Kind() const override { return LinkableMessageKind::FunctionKind; } - FunctionDiffIR(const FunctionIR *old_function, - const FunctionIR *new_function) - : old_function_(old_function), new_function_(new_function) { } - const FunctionIR *GetOldFunction() const { return old_function_; } @@ -1430,7 +1436,10 @@ class IRDiffDumper { public: typedef DiffMessageIR::DiffKind DiffKind; - IRDiffDumper(const std::string &dump_path) : dump_path_(dump_path) { } + public: + IRDiffDumper(const std::string &dump_path) : dump_path_(dump_path) {} + + virtual ~IRDiffDumper() {} virtual bool AddDiffMessageIR(const DiffMessageIR *, const std::string &type_stack, @@ -1452,13 +1461,13 @@ class IRDiffDumper { virtual CompatibilityStatusIR GetCompatibilityStatusIR() = 0; - virtual ~IRDiffDumper() {} static std::unique_ptr CreateIRDiffDumper( TextFormatIR, const std::string &dump_path); + protected: const std::string &dump_path_; }; -} // namespace abi_util +} // namespace abi_util -#endif // IR_ +#endif // IR_REPRESENTATION_H_ diff --git a/vndk/tools/header-checker/header-abi-util/include/ir_representation_json.h b/vndk/tools/header-checker/header-abi-util/include/ir_representation_json.h index 45ebe550e..9b4c36f3b 100644 --- a/vndk/tools/header-checker/header-abi-util/include/ir_representation_json.h +++ b/vndk/tools/header-checker/header-abi-util/include/ir_representation_json.h @@ -11,10 +11,11 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef IR_JSON_ -#define IR_JSON_ -#include +#ifndef IR_REPRESENTATION_JSON_H_ +#define IR_REPRESENTATION_JSON_H_ + +#include "ir_representation.h" #include @@ -118,14 +119,14 @@ class JsonIRDumper : public IRDumper, public IRToJsonConverter { public: JsonIRDumper(const std::string &dump_path); + ~JsonIRDumper() override {} + bool AddLinkableMessageIR(const LinkableMessageIR *) override; bool AddElfSymbolMessageIR(const ElfSymbolIR *) override; bool Dump() override; - ~JsonIRDumper() override {} - private: JsonObject translation_unit_; }; @@ -281,6 +282,7 @@ class JsonToIRReader : public TextFormatToIRReader { static EnumTypeIR EnumTypeJsonToIR(const JsonObjectRef &enum_type); }; -} // namespace abi_util -#endif // IR_JSON_ +} // namespace abi_util + +#endif // IR_REPRESENTATION_JSON_H_ diff --git a/vndk/tools/header-checker/header-abi-util/include/ir_representation_protobuf.h b/vndk/tools/header-checker/header-abi-util/include/ir_representation_protobuf.h index db841c845..bacd1c965 100644 --- a/vndk/tools/header-checker/header-abi-util/include/ir_representation_protobuf.h +++ b/vndk/tools/header-checker/header-abi-util/include/ir_representation_protobuf.h @@ -11,10 +11,11 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef IR_PROTOBUF_ -#define IR_PROTOBUF_ -#include +#ifndef IR_REPRESENTATION_PROTOBUF_H_ +#define IR_REPRESENTATION_PROTOBUF_H_ + +#include "ir_representation.h" #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-parameter" @@ -33,7 +34,7 @@ namespace abi_util { inline abi_diff::CompatibilityStatus CompatibilityStatusIRToProtobuf( CompatibilityStatusIR status) { - switch(status) { + switch (status) { case CompatibilityStatusIR::Incompatible: return abi_diff::CompatibilityStatus::INCOMPATIBLE; case CompatibilityStatusIR::Extension: @@ -46,7 +47,7 @@ inline abi_diff::CompatibilityStatus CompatibilityStatusIRToProtobuf( inline abi_dump::ElfSymbolBinding ElfSymbolBindingIRToProtobuf( ElfSymbolIR::ElfSymbolBinding binding) { - switch(binding) { + switch (binding) { case ElfSymbolIR::ElfSymbolBinding::Global: return abi_dump::ElfSymbolBinding::Global; case ElfSymbolIR::ElfSymbolBinding::Weak: @@ -59,7 +60,7 @@ inline abi_dump::ElfSymbolBinding ElfSymbolBindingIRToProtobuf( inline ElfSymbolIR::ElfSymbolBinding ElfSymbolBindingProtobufToIR( abi_dump::ElfSymbolBinding binding) { - switch(binding) { + switch (binding) { case abi_dump::ElfSymbolBinding::Global: return ElfSymbolIR::ElfSymbolBinding::Global; case abi_dump::ElfSymbolBinding::Weak: @@ -197,7 +198,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 abi_util::TemplatedArtifactIR *ta); static bool AddTypeInfo( abi_dump::BasicNamedAndTypedDecl *type_info, const TypeIR *typep); @@ -216,6 +217,7 @@ class IRToProtobufConverter { static bool AddEnumFields(abi_dump::EnumType *enum_protobuf, const EnumTypeIR *enum_ir); + public: static abi_dump::EnumType ConvertEnumTypeIR(const EnumTypeIR *enump); @@ -265,29 +267,30 @@ class IRToProtobufConverter { class IRDiffToProtobufConverter { private: - static bool AddTypeInfoDiff(abi_diff::TypeInfoDiff *type_info_diff_protobuf, - const TypeDiffIR *type_diff_ir); + static bool AddTypeInfoDiff( + abi_diff::TypeInfoDiff *type_info_diff_protobuf, + const TypeDiffIR *type_diff_ir); static bool AddVTableLayoutDiff( - abi_diff::VTableLayoutDiff *vtable_layout_diff_protobuf, - const VTableLayoutDiffIR *vtable_layout_diff_ir); + abi_diff::VTableLayoutDiff *vtable_layout_diff_protobuf, + const VTableLayoutDiffIR *vtable_layout_diff_ir); static bool AddBaseSpecifierDiffs( - abi_diff::CXXBaseSpecifierDiff *base_specifier_diff_protobuf, - const CXXBaseSpecifierDiffIR *base_specifier_diff_ir); + abi_diff::CXXBaseSpecifierDiff *base_specifier_diff_protobuf, + const CXXBaseSpecifierDiffIR *base_specifier_diff_ir); static bool AddRecordFields( - abi_diff::RecordTypeDiff *record_diff_protobuf, - const std::vector &record_fields_removed_ir, - bool removed); + abi_diff::RecordTypeDiff *record_diff_protobuf, + const std::vector &record_fields_removed_ir, + bool removed); static bool AddRecordFieldDiffs( - abi_diff::RecordTypeDiff *record_diff_protobuf, - const std::vector &record_field_diff_ir); + abi_diff::RecordTypeDiff *record_diff_protobuf, + const std::vector &record_field_diff_ir); static bool AddEnumUnderlyingTypeDiff( - abi_diff::UnderlyingTypeDiff *underlying_type_diff_protobuf, - const std::pair *underlying_type_diff_ir); + abi_diff::UnderlyingTypeDiff *underlying_type_diff_protobuf, + const std::pair *underlying_type_diff_ir); public: static abi_diff::RecordTypeDiff ConvertRecordTypeDiffIR( @@ -335,7 +338,9 @@ class ProtobufIRDumper : public IRDumper, public IRToProtobufConverter { public: ProtobufIRDumper(const std::string &dump_path) - : IRDumper(dump_path), tu_ptr_(new abi_dump::TranslationUnit()) { } + : IRDumper(dump_path), tu_ptr_(new abi_dump::TranslationUnit()) {} + + ~ProtobufIRDumper() override {} bool AddLinkableMessageIR(const LinkableMessageIR *) override; @@ -343,18 +348,19 @@ class ProtobufIRDumper : public IRDumper, public IRToProtobufConverter { bool Dump() override; - ~ProtobufIRDumper() override { } - private: std::unique_ptr tu_ptr_; }; class ProtobufTextFormatToIRReader : public TextFormatToIRReader { - public: + private: + template + using RepeatedPtrField = google::protobuf::RepeatedPtrField; + public: ProtobufTextFormatToIRReader(const std::set *exported_headers) - : TextFormatToIRReader(exported_headers) { } + : TextFormatToIRReader(exported_headers) {} bool ReadDump(const std::string &dump_file) override; @@ -381,9 +387,9 @@ class ProtobufTextFormatToIRReader : public TextFormatToIRReader { void ReadRvalueReferenceTypes(const abi_dump::TranslationUnit &tu); - void ReadElfFunctions (const abi_dump::TranslationUnit &tu); + void ReadElfFunctions(const abi_dump::TranslationUnit &tu); - void ReadElfObjects (const abi_dump::TranslationUnit &tu); + void ReadElfObjects(const abi_dump::TranslationUnit &tu); void ReadTypeInfo(const abi_dump::BasicNamedAndTypedDecl &type_info, TypeIR *typep); @@ -394,32 +400,34 @@ class ProtobufTextFormatToIRReader : public TextFormatToIRReader { const abi_dump::FunctionType &function_type_protobuf); RecordTypeIR RecordTypeProtobufToIR( - const abi_dump::RecordType &record_type_protobuf); + const abi_dump::RecordType &record_type_protobuf); std::vector RecordFieldsProtobufToIR( - const google::protobuf::RepeatedPtrField &rfp); + const RepeatedPtrField &rfp); std::vector RecordCXXBaseSpecifiersProtobufToIR( - const google::protobuf::RepeatedPtrField &rbs); + const RepeatedPtrField &rbs); std::vector EnumFieldsProtobufToIR( - const google::protobuf::RepeatedPtrField &efp); + const RepeatedPtrField &efp); EnumTypeIR EnumTypeProtobufToIR( - const abi_dump::EnumType &enum_type_protobuf); + const abi_dump::EnumType &enum_type_protobuf); VTableLayoutIR VTableLayoutProtobufToIR( - const abi_dump::VTableLayout &vtable_layout_protobuf); + const abi_dump::VTableLayout &vtable_layout_protobuf); TemplateInfoIR TemplateInfoProtobufToIR( - const abi_dump::TemplateInfo &template_info_protobuf); + const abi_dump::TemplateInfo &template_info_protobuf); }; class ProtobufIRDiffDumper : public IRDiffDumper { public: ProtobufIRDiffDumper(const std::string &dump_path) : IRDiffDumper(dump_path), - diff_tu_(new abi_diff::TranslationUnitDiff()) { } + diff_tu_(new abi_diff::TranslationUnitDiff()) {} + + ~ProtobufIRDiffDumper() override {} bool AddDiffMessageIR(const DiffMessageIR *, const std::string &type_stack, DiffKind diff_kind) override; @@ -437,9 +445,7 @@ class ProtobufIRDiffDumper : public IRDiffDumper { bool Dump() override; - CompatibilityStatusIR GetCompatibilityStatusIR() override; - - ~ProtobufIRDiffDumper() override { } + CompatibilityStatusIR GetCompatibilityStatusIR() override; private: // User defined types. @@ -474,6 +480,6 @@ class ProtobufIRDiffDumper : public IRDiffDumper { std::unique_ptr diff_tu_; }; -} // abi_util +} // namespace abi_util -#endif // IR_PROTOBUF_ +#endif // IR_REPRESENTATION_PROTOBUF_H_ diff --git a/vndk/tools/header-checker/header-abi-util/include/so_file_parser.h b/vndk/tools/header-checker/header-abi-util/include/so_file_parser.h new file mode 100644 index 000000000..9c035bdfe --- /dev/null +++ b/vndk/tools/header-checker/header-abi-util/include/so_file_parser.h @@ -0,0 +1,67 @@ +// Copyright (C) 2018 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SO_FILE_PARSER_H_ +#define SO_FILE_PARSER_H_ + +#include "ir_representation.h" + +#include +#include + +#include +#include +#include + +namespace abi_util { + +class SoFileParser { + public: + virtual ~SoFileParser() {} + + static std::unique_ptr Create( + const llvm::object::ObjectFile *obj); + + virtual const std::map &GetFunctions() const = 0; + virtual const std::map &GetGlobVars() const = 0; + virtual void GetSymbols() = 0; +}; + +template +class ELFSoFileParser : public SoFileParser { + private: + LLVM_ELF_IMPORT_TYPES_ELFT(T) + typedef llvm::object::ELFFile ELFO; + typedef typename ELFO::Elf_Sym Elf_Sym; + + public: + ELFSoFileParser(const llvm::object::ELFObjectFile *obj) : obj_(obj) {} + ~ELFSoFileParser() override {} + + const std::map &GetFunctions() const override; + const std::map &GetGlobVars() const override; + void GetSymbols() override; + + private: + const llvm::object::ELFObjectFile *obj_; + std::map functions_; + std::map globvars_; + + private: + bool IsSymbolExported(const Elf_Sym *elf_sym) const; +}; + +} // namespace abi_util + +#endif // SO_FILE_PARSER_H_ diff --git a/vndk/tools/header-checker/header-abi-util/include/version_script_parser.h b/vndk/tools/header-checker/header-abi-util/include/version_script_parser.h new file mode 100644 index 000000000..dd86fbf0f --- /dev/null +++ b/vndk/tools/header-checker/header-abi-util/include/version_script_parser.h @@ -0,0 +1,78 @@ +// Copyright (C) 2018 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef VERSION_SCRIPT_PARSER_H_ +#define VERSION_SCRIPT_PARSER_H_ + +#include "ir_representation.h" + +#include +#include +#include + +namespace abi_util { + +class VersionScriptParser { + public: + enum LineScope { + global, + local, + }; + + VersionScriptParser(const std::string &version_script, + const std::string &arch, + const std::string &api); + bool Parse(); + + const std::map &GetFunctions(); + + const std::map &GetGlobVars(); + + const std::set &GetFunctionRegexs(); + + const std::set &GetGlobVarRegexs(); + + private: + bool ParseInnerBlock(std::ifstream &symbol_ifstream); + + LineScope GetLineScope(std::string &line, LineScope scope); + + bool ParseSymbolLine(const std::string &line); + + bool SymbolInArchAndApiVersion(const std::string &line, + const std::string &arch, int api); + + bool SymbolExported(const std::string &line, const std::string &arch, + int api); + + int ApiStrToInt(const std::string &api); + + void AddToVars(std::string &symbol); + + void AddToFunctions(std::string &symbol); + + private: + const std::string &version_script_; + const std::string &arch_; + std::map functions_; + std::map globvars_; + // Added to speed up version script parsing and linking. + std::set function_regexs_; + std::set globvar_regexs_; + int api_; +}; + +} // namespace abi_util + +#endif // VERSION_SCRIPT_PARSER_H_ diff --git a/vndk/tools/header-checker/header-abi-util/src/abi_diff_helpers.cpp b/vndk/tools/header-checker/header-abi-util/src/abi_diff_helpers.cpp index 05482b891..bf01ab315 100644 --- a/vndk/tools/header-checker/header-abi-util/src/abi_diff_helpers.cpp +++ b/vndk/tools/header-checker/header-abi-util/src/abi_diff_helpers.cpp @@ -1,5 +1,19 @@ -#include -#include +// Copyright (C) 2018 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "abi_diff_helpers.h" +#include "header_abi_util.h" #include @@ -26,9 +40,9 @@ static void TypeQueueCheckAndPushBack(std::deque *type_queue, } static void TypeQueueCheckAndPop(std::deque *type_queue) { - if (type_queue && !type_queue->empty()) { - type_queue->pop_back(); - } + if (type_queue && !type_queue->empty()) { + type_queue->pop_back(); + } } static bool IsAccessDownGraded(abi_util::AccessSpecifierIR old_access, @@ -72,8 +86,7 @@ static void ReplaceReferencesOtherTypeIdWithName( } static void ReplaceEnumTypeIRTypeIdsWithTypeNames( - const AbiElementMap &type_graph, - EnumTypeIR *enum_type_ir) { + const AbiElementMap &type_graph, EnumTypeIR *enum_type_ir) { // Replace underlying type. enum_type_ir->SetUnderlyingType( ConvertTypeIdToString(type_graph, enum_type_ir->GetUnderlyingType())); @@ -119,21 +132,20 @@ void ReplaceTypeIdsWithTypeNames( LinkableMessageIR *lm) { switch (lm->GetKind()) { case FunctionKind: - ReplaceFunctionTypeIdsWithTypeNames(type_graph, - static_cast(lm)); + ReplaceFunctionTypeIdsWithTypeNames( + type_graph, static_cast(lm)); break; case GlobalVarKind: - ReplaceGlobalVarTypeIdsWithTypeNames(type_graph, - static_cast(lm)); + ReplaceGlobalVarTypeIdsWithTypeNames( + type_graph, static_cast(lm)); break; case RecordTypeKind: - ReplaceRecordTypeIRTypeIdsWithTypeNames(type_graph, - static_cast(lm)); - + ReplaceRecordTypeIRTypeIdsWithTypeNames( + type_graph, static_cast(lm)); break; case EnumTypeKind: - ReplaceEnumTypeIRTypeIdsWithTypeNames(type_graph, - static_cast(lm)); + ReplaceEnumTypeIRTypeIdsWithTypeNames( + type_graph, static_cast(lm)); break; default: // This method should not be called on any other LinkableMessage @@ -165,8 +177,8 @@ void AbiDiffHelper::CompareEnumFields( enum_type_diff_ir->SetFieldsRemoved(std::move(removed_fields)); - std::vector> cf = + std::vector> cf = abi_util::FindCommonElements(old_fields_map, new_fields_map); std::vector enum_field_diffs; for (auto &&common_fields : cf) { @@ -181,8 +193,8 @@ void AbiDiffHelper::CompareEnumFields( DiffStatus AbiDiffHelper::CompareEnumTypes( const abi_util::EnumTypeIR *old_type, const abi_util::EnumTypeIR *new_type, - std::deque *type_queue, - abi_util::DiffMessageIR::DiffKind diff_kind) { + std::deque *type_queue, + abi_util::DiffMessageIR::DiffKind diff_kind) { if (old_type->GetUniqueId() != new_type->GetUniqueId()) { return DiffStatus::direct_diff; } @@ -372,9 +384,8 @@ AbiDiffHelper::CompareRecordFields( abi_util::FindCommonElements(old_fields_map, new_fields_map); bool common_field_diff_exists = false; for (auto &&common_fields : cf) { - auto diffed_field_ptr = CompareCommonRecordFields(common_fields.first, - common_fields.second, - type_queue, diff_kind); + auto diffed_field_ptr = CompareCommonRecordFields( + common_fields.first, common_fields.second, type_queue, diff_kind); if (!common_field_diff_exists && (diffed_field_ptr.first & (DiffStatus::direct_diff | DiffStatus::indirect_diff))) { @@ -522,7 +533,7 @@ DiffStatus AbiDiffHelper::CompareFunctionTypes( return DiffStatus::indirect_diff; } - return DiffStatus::no_diff; + return DiffStatus::no_diff; } DiffStatus AbiDiffHelper::CompareRecordTypes( @@ -563,10 +574,9 @@ DiffStatus AbiDiffHelper::CompareRecordTypes( } auto &old_fields_dup = old_type->GetFields(); auto &new_fields_dup = new_type->GetFields(); - auto field_status_and_diffs = - CompareRecordFields(old_fields_dup, new_fields_dup, - type_queue, diff_kind); - // TODO: combine this with base class diffs as well. + auto field_status_and_diffs = CompareRecordFields( + old_fields_dup, new_fields_dup, type_queue, diff_kind); + // TODO: Combine this with base class diffs as well. final_diff_status = final_diff_status | field_status_and_diffs.diff_status_; std::vector old_bases = old_type->GetBases(); @@ -611,17 +621,17 @@ DiffStatus AbiDiffHelper::CompareRecordTypes( llvm::errs() << "AddDiffMessage on record type failed\n"; ::exit(1); } - } // Records cannot be 'extended' compatibly, without a certain amount of - // risk. + } + final_diff_status = final_diff_status | CompareTemplateInfo(old_type->GetTemplateElements(), new_type->GetTemplateElements(), type_queue, diff_kind); - return - (final_diff_status & - (DiffStatus::direct_diff | DiffStatus::indirect_diff)) ? - DiffStatus::indirect_diff : DiffStatus::no_diff; + // Records cannot be 'extended' compatibly, without a certain amount of risk. + return ((final_diff_status & + (DiffStatus::direct_diff | DiffStatus::indirect_diff)) ? + DiffStatus::indirect_diff : DiffStatus::no_diff); } DiffStatus AbiDiffHelper::CompareLvalueReferenceTypes( @@ -681,11 +691,8 @@ DiffStatus AbiDiffHelper::CompareBuiltinTypes( const abi_util::BuiltinTypeIR *new_type) { // If the size, alignment and is_unsigned are the same, return no_diff // else return direct_diff. - uint64_t old_signedness = old_type->IsUnsigned(); - uint64_t new_signedness = new_type->IsUnsigned(); - if (!CompareSizeAndAlignment(old_type, new_type) || - old_signedness != new_signedness || + old_type->IsUnsigned() != new_type->IsUnsigned() || old_type->IsIntegralType() != new_type->IsIntegralType()) { return DiffStatus::direct_diff; } @@ -735,11 +742,10 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff( } if (kind == abi_util::LinkableMessageKind::EnumTypeKind) { - return CompareEnumTypes( - static_cast(old_type), - static_cast(new_type), - type_queue, diff_kind); - + return CompareEnumTypes( + static_cast(old_type), + static_cast(new_type), + type_queue, diff_kind); } if (kind == abi_util::LinkableMessageKind::LvalueReferenceTypeKind) { @@ -747,7 +753,6 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff( static_cast(old_type), static_cast(new_type), type_queue, diff_kind); - } if (kind == abi_util::LinkableMessageKind::RvalueReferenceTypeKind) { @@ -792,15 +797,15 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff( const std::string &old_type_id, const std::string &new_type_id, std::deque *type_queue, abi_util::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) { return DiffStatus::no_diff; - } else { - TypeQueueCheckAndPushBack(type_queue, - ConvertTypeIdToString(old_types_,old_type_id)); } + + TypeQueueCheckAndPushBack( + type_queue, ConvertTypeIdToString(old_types_,old_type_id)); + AbiElementMap::const_iterator old_it = old_types_.find(old_type_id); AbiElementMap::const_iterator new_it = @@ -813,10 +818,9 @@ 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(); + + abi_util::LinkableMessageKind old_kind = old_it->second->GetKind(); + abi_util::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); @@ -824,6 +828,7 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff( diff_status = CompareAndDumpTypeDiff(old_it->second , new_it->second , old_kind, type_queue, diff_kind); } + TypeQueueCheckAndPop(type_queue); if (diff_policy_options_.consider_opaque_types_different_ && diff_status == DiffStatus::opaque_diff && @@ -833,4 +838,4 @@ DiffStatus AbiDiffHelper::CompareAndDumpTypeDiff( return diff_status; } -} // namespace abi_util +} // namespace abi_util diff --git a/vndk/tools/header-checker/header-abi-util/src/collect_exported_headers.cpp b/vndk/tools/header-checker/header-abi-util/src/collect_exported_headers.cpp index 92a2348a4..39b3f6465 100644 --- a/vndk/tools/header-checker/header-abi-util/src/collect_exported_headers.cpp +++ b/vndk/tools/header-checker/header-abi-util/src/collect_exported_headers.cpp @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include "header_abi_util.h" -#include #include #include +#include #include #include @@ -25,16 +25,13 @@ namespace abi_util { static bool ShouldSkipFile(llvm::StringRef &file_name) { - // Ignore swap files and hidden files / dirs. Do not recurse into them too. - // We should also not look at source files. Many projects include source - // files in their exports. - if (file_name.empty() || file_name.startswith(".") || - file_name.endswith(".swp") || file_name.endswith(".swo") || - file_name.endswith("#") || file_name.endswith(".cpp") || - file_name.endswith(".cc") || file_name.endswith(".c")) { - return true; - } - return false; + // Ignore swap files, hidden files, and hidden directories. Do not recurse + // into hidden directories either. We should also not look at source files. + // Many projects include source files in their exports. + return (file_name.empty() || file_name.startswith(".") || + file_name.endswith(".swp") || file_name.endswith(".swo") || + file_name.endswith("#") || file_name.endswith(".cpp") || + file_name.endswith(".cc") || file_name.endswith(".c")); } std::string RealPath(const std::string &path) { @@ -67,7 +64,8 @@ bool CollectExportedHeaderSet(const std::string &dir_name, walker.no_push(); continue; } - llvm::ErrorOr status = walker->status(); + + llvm::ErrorOr status = walker->status(); if (!status) { llvm::errs() << "Failed to stat file : " << file_path << "\n"; return false; @@ -96,4 +94,4 @@ std::set CollectAllExportedHeaders( return exported_headers; } -} // namespace abi_util +} // namespace abi_util diff --git a/vndk/tools/header-checker/header-abi-util/src/ir_representation.cpp b/vndk/tools/header-checker/header-abi-util/src/ir_representation.cpp index b14010460..26dc22e31 100644 --- a/vndk/tools/header-checker/header-abi-util/src/ir_representation.cpp +++ b/vndk/tools/header-checker/header-abi-util/src/ir_representation.cpp @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include +#include "ir_representation.h" + +#include "abi_diff_helpers.h" +#include "ir_representation_json.h" +#include "ir_representation_protobuf.h" #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-parameter" @@ -31,7 +32,6 @@ #include #include - namespace abi_util { using MergeStatus = TextFormatToIRReader::MergeStatus; @@ -75,9 +75,8 @@ TextFormatToIRReader::CreateTextFormatToIRReader( } } -void TextFormatToIRReader::AddToODRListMap( - const std::string &key, - const TypeIR *value) { +void TextFormatToIRReader::AddToODRListMap(const std::string &key, + const TypeIR *value) { auto map_it = odr_list_map_.find(key); if (map_it == odr_list_map_.end()) { odr_list_map_.emplace(key, std::list({value})); @@ -113,9 +112,9 @@ MergeStatus TextFormatToIRReader::DoesUDTypeODRViolationExist( const TypeIR *ud_type, const TextFormatToIRReader &addend, const std::string ud_type_unique_id_and_source, AbiElementMap *local_to_global_type_id_map_) { - // Per entry in the map : + // Per entry in the map: // /-----------------------------------------------------------------------\ - // | UDType->UniqueTagId + UdType->source File => list(const UDTypeIR *)| + // | UDType->UniqueTagId + UdType->source File => list(const UDTypeIR *) | // \-----------------------------------------------------------------------/ auto it = odr_list_map_.find(ud_type_unique_id_and_source); if (it == odr_list_map_.end()) { @@ -132,17 +131,16 @@ MergeStatus TextFormatToIRReader::DoesUDTypeODRViolationExist( nullptr, local_to_global_type_id_map_); for (auto &contender_ud : it->second) { if (diff_helper.CompareAndDumpTypeDiff(contender_ud->GetSelfType(), - ud_type->GetSelfType()) - == DiffStatus::no_diff) { - local_to_global_type_id_map_->emplace(ud_type->GetSelfType(), - MergeStatus( - false, - contender_ud->GetSelfType())); + ud_type->GetSelfType()) == + DiffStatus::no_diff) { + local_to_global_type_id_map_->emplace( + ud_type->GetSelfType(), + MergeStatus(false, contender_ud->GetSelfType())); return MergeStatus(false, contender_ud->GetSelfType()); } } #ifdef DEBUG - llvm::errs() << "ODR violation detected for :" << ud_type->GetName() << "\n"; + llvm::errs() << "ODR violation detected for: " << ud_type->GetName() << "\n"; #endif return MergeStatus(true, (*(it->second.begin()))->GetSelfType()); } @@ -151,7 +149,7 @@ MergeStatus TextFormatToIRReader::IsTypeNodePresent( const TypeIR *addend_node, const TextFormatToIRReader &addend, AbiElementMap *local_to_global_type_id_map) { std::string unique_type_id; - switch(addend_node->GetKind()) { + switch (addend_node->GetKind()) { case RecordTypeKind: unique_type_id = GetODRListMapKey(static_cast(addend_node)); @@ -181,41 +179,42 @@ MergeStatus TextFormatToIRReader::MergeReferencingTypeInternal( const TextFormatToIRReader &addend, ReferencesOtherType *references_type, AbiElementMap *local_to_global_type_id_map) { - // First look in the local_to_global_type_id_map for the referenced type's - // id. - const std::string &referenced_type_id = - references_type->GetReferencedType(); - auto local_to_global_it = local_to_global_type_id_map->find( - referenced_type_id); - if (local_to_global_it != local_to_global_type_id_map->end()) { - // The type was already added to the parent graph. So change the - // referenced type to the global type id. - references_type->SetReferencedType(local_to_global_it->second.type_id_); - return local_to_global_it->second; - } - // If that did not go through, look at the addend's type_map_ and get the - // TypeIR* and call MergeType on it. - auto local_type_it = addend.type_graph_.find(referenced_type_id); - if (local_type_it != addend.type_graph_.end()) { - // We don't care about merge_status.was_newly_added since we wouldn't have - // gotten this far if we weren't adding this. - MergeStatus merge_status = - MergeType(local_type_it->second, addend, - local_to_global_type_id_map); - const std::string &global_type_id = merge_status.type_id_; - references_type->SetReferencedType(global_type_id); - return merge_status; - } - // The referenced type was hidden, so just set it to type-hidden. - const std::string &hidden_type_id = AllocateNewTypeId(); - references_type->SetReferencedType(hidden_type_id); - return MergeStatus(true, hidden_type_id); + // First look in the local_to_global_type_id_map for the referenced type's + // id. + const std::string &referenced_type_id = + references_type->GetReferencedType(); + auto local_to_global_it = local_to_global_type_id_map->find( + referenced_type_id); + if (local_to_global_it != local_to_global_type_id_map->end()) { + // The type was already added to the parent graph. So change the + // referenced type to the global type id. + references_type->SetReferencedType(local_to_global_it->second.type_id_); + return local_to_global_it->second; + } + + // If that did not go through, look at the addend's type_map_ and get the + // TypeIR* and call MergeType on it. + auto local_type_it = addend.type_graph_.find(referenced_type_id); + if (local_type_it != addend.type_graph_.end()) { + // We don't care about merge_status.was_newly_added since we wouldn't have + // gotten this far if we weren't adding this. + MergeStatus merge_status = + MergeType(local_type_it->second, addend, local_to_global_type_id_map); + const std::string &global_type_id = merge_status.type_id_; + references_type->SetReferencedType(global_type_id); + return merge_status; + } + + // The referenced type was hidden, so just set it to type-hidden. + const std::string &hidden_type_id = AllocateNewTypeId(); + references_type->SetReferencedType(hidden_type_id); + return MergeStatus(true, hidden_type_id); } void TextFormatToIRReader::MergeRecordFields( const TextFormatToIRReader &addend, RecordTypeIR *added_node, AbiElementMap *local_to_global_type_id_map) { - for(auto &field : added_node->GetFields()) { + for (auto &field : added_node->GetFields()) { MergeReferencingTypeInternal(addend, &field, local_to_global_type_id_map); } } @@ -223,7 +222,7 @@ void TextFormatToIRReader::MergeRecordFields( void TextFormatToIRReader::MergeRecordCXXBases( const TextFormatToIRReader &addend, RecordTypeIR *added_node, AbiElementMap *local_to_global_type_id_map) { - for(auto &base : added_node->GetBases()) { + for (auto &base : added_node->GetBases()) { MergeReferencingTypeInternal(addend, &base, local_to_global_type_id_map); } } @@ -231,9 +230,9 @@ void TextFormatToIRReader::MergeRecordCXXBases( void TextFormatToIRReader::MergeRecordTemplateElements( const TextFormatToIRReader &addend, RecordTypeIR *added_node, AbiElementMap *local_to_global_type_id_map) { - for(auto &template_element : added_node->GetTemplateElements()) { - MergeReferencingTypeInternal(addend, &template_element, - local_to_global_type_id_map); + for (auto &template_element : added_node->GetTemplateElements()) { + MergeReferencingTypeInternal( + addend, &template_element, local_to_global_type_id_map); } } @@ -331,60 +330,61 @@ template MergeStatus TextFormatToIRReader::MergeReferencingTypeInternalAndUpdateParent( const TextFormatToIRReader &addend, const T *addend_node, AbiElementMap *local_to_global_type_id_map, - AbiElementMap *parent_map, const std::string &updated_self_type_id) { - MergeStatus merge_status; - uint64_t old_max_type_id = max_type_id_; - // Create copy of addend_node - T added_node = - *(addend_node); - added_node.SetSelfType(updated_self_type_id); - // The merge status returned is the merge status of the referenced type. - merge_status = MergeReferencingTypeInternal(addend, &added_node, - local_to_global_type_id_map); - if (merge_status.was_newly_added_) { - // Emplace to map (type-referenced -> Referencing type) - AddToMapAndTypeGraph(std::move(added_node), parent_map, - &type_graph_); - return MergeStatus(true, updated_self_type_id); - } - // The type that the added_node references was not newly added to the parent - // graph. However, we still might need to add the added_node to the parent - // graph, since for the particular 'Kind' of the added_node, it may not be - // present in the parent graph. This will be determined by looking at the - // appropriate 'type-referenced' -> TypeElement map in the parent for the - // type-id returned by the MergeStatus. If the map doesn't have an entry for - // the type-id returned by the MergeStatus, the added_type is not present in - // the parent graph and needs to be 'newly' added. We also need to modify the - // global type id in the local_to_global_type_id map. The added_node should - // already have it's self_type and referenced_type fields fixed up. - // We maintain a rollback id to have contiguous type ids. - max_type_id_ = old_max_type_id; - // Try finding the referenced_type is referred to by any referencing type - // of the same kind in the parent graph. It is safe to call this on the - // added_node, since the referenced_type in the added_node would have been - // modified by the MergeReferencingTypeInternal call. - auto it = parent_map->find(GetReferencedTypeMapKey(added_node)); - if (it == parent_map->end()) { - // There was no counterpart found for the added_node's type Kind referencing - // the referenced type, so we added it to the parent and also updated the - // local_to_global_type_id_map's global_id value. - AddToMapAndTypeGraph(std::move(added_node), parent_map, - &type_graph_); + AbiElementMap *parent_map, const std::string &updated_self_type_id) { + MergeStatus merge_status; + uint64_t old_max_type_id = max_type_id_; + // Create copy of addend_node + T added_node = *(addend_node); + added_node.SetSelfType(updated_self_type_id); + // The merge status returned is the merge status of the referenced type. + merge_status = MergeReferencingTypeInternal(addend, &added_node, + local_to_global_type_id_map); + if (merge_status.was_newly_added_) { + // Emplace to map (type-referenced -> Referencing type) + AddToMapAndTypeGraph(std::move(added_node), parent_map, &type_graph_); + return MergeStatus(true, updated_self_type_id); + } - merge_status = MergeStatus(true, updated_self_type_id); - return merge_status; - } - // Update local_to_global_type_id map's MergeStatus.was_newly_added value for - // this key with false since this was node was not newly added. - // We never remove anything from the local_to_global_type_id_map, what's - // the point ? Since you store the decision of whether the type was newly - // added or not. It's global type id is the type-id of the element found - // in the parent map which refers to the added_node's modified - // referenced_type. - merge_status = MergeStatus(false, it->second.GetSelfType()); - (*local_to_global_type_id_map)[addend_node->GetSelfType()] = - merge_status; - return merge_status; + // The type that the added_node references was not newly added to the parent + // graph. However, we still might need to add the added_node to the parent + // graph, since for the particular 'Kind' of the added_node, it may not be + // present in the parent graph. This will be determined by looking at the + // appropriate 'type-referenced' -> TypeElement map in the parent for the + // type-id returned by the MergeStatus. If the map doesn't have an entry for + // the type-id returned by the MergeStatus, the added_type is not present in + // the parent graph and needs to be 'newly' added. We also need to modify the + // global type id in the local_to_global_type_id map. The added_node should + // already have it's self_type and referenced_type fields fixed up. + // We maintain a rollback id to have contiguous type ids. + max_type_id_ = old_max_type_id; + + // Try finding the referenced_type is referred to by any referencing type + // of the same kind in the parent graph. It is safe to call this on the + // added_node, since the referenced_type in the added_node would have been + // modified by the MergeReferencingTypeInternal call. + auto it = parent_map->find(GetReferencedTypeMapKey(added_node)); + if (it == parent_map->end()) { + // There was no counterpart found for the added_node's type Kind referencing + // the referenced type, so we added it to the parent and also updated the + // local_to_global_type_id_map's global_id value. + AddToMapAndTypeGraph(std::move(added_node), parent_map, + &type_graph_); + + merge_status = MergeStatus(true, updated_self_type_id); + return merge_status; + } + + // Update local_to_global_type_id map's MergeStatus.was_newly_added value for + // this key with false since this was node was not newly added. + // We never remove anything from the local_to_global_type_id_map, what's + // the point ? Since you store the decision of whether the type was newly + // added or not. It's global type id is the type-id of the element found + // in the parent map which refers to the added_node's modified + // referenced_type. + merge_status = MergeStatus(false, it->second.GetSelfType()); + (*local_to_global_type_id_map)[addend_node->GetSelfType()] = merge_status; + + return merge_status; } MergeStatus TextFormatToIRReader::MergeReferencingType( @@ -439,7 +439,7 @@ MergeStatus TextFormatToIRReader::MergeGenericReferringType( MergeStatus TextFormatToIRReader::MergeTypeInternal( const TypeIR *addend_node, const TextFormatToIRReader &addend, AbiElementMap *local_to_global_type_id_map) { - switch(addend_node->GetKind()) { + switch (addend_node->GetKind()) { case BuiltinTypeKind: return IsBuiltinTypeNodePresent( static_cast(addend_node), addend, @@ -466,29 +466,28 @@ MergeStatus TextFormatToIRReader::MergeType( const TypeIR *addend_node, const TextFormatToIRReader &addend, AbiElementMap *local_to_global_type_id_map) { - // Check if the addend type is already in the parent graph. Since we're - // going to traverse all the dependencies add whichever ones are not in the - // parent graph. This does not add the node itself though. - auto type_it = - local_to_global_type_id_map->find(addend_node->GetSelfType()); - if (type_it != local_to_global_type_id_map->end()) { - return type_it->second; - } + // Check if the addend type is already in the parent graph. Since we're + // going to traverse all the dependencies add whichever ones are not in the + // parent graph. This does not add the node itself though. + auto type_it = local_to_global_type_id_map->find(addend_node->GetSelfType()); + if (type_it != local_to_global_type_id_map->end()) { + return type_it->second; + } - MergeStatus merge_status = IsTypeNodePresent(addend_node, addend, - local_to_global_type_id_map); - if (!merge_status.was_newly_added_) { - return merge_status; - } - merge_status = MergeTypeInternal(addend_node, addend, - local_to_global_type_id_map); + MergeStatus merge_status = IsTypeNodePresent( + addend_node, addend, local_to_global_type_id_map); + if (!merge_status.was_newly_added_) { return merge_status; + } + merge_status = MergeTypeInternal( + addend_node, addend, local_to_global_type_id_map); + return merge_status; } void TextFormatToIRReader::MergeCFunctionLikeDeps( const TextFormatToIRReader &addend, CFunctionLikeIR *cfunction_like_ir, AbiElementMap *local_to_global_type_id_map) { - // Merge the return type first. + // Merge the return type first. auto ret_type_it = addend.type_graph_.find(cfunction_like_ir->GetReturnType()); if (ret_type_it == addend.type_graph_.end()) { @@ -585,5 +584,5 @@ bool TextFormatToIRReader::IsLinkableMessageInExportedHeaders( return exported_headers_->find(linkable_message->GetSourceFile()) != exported_headers_->end(); } -} // namespace abi_util +} // namespace abi_util diff --git a/vndk/tools/header-checker/header-abi-util/src/ir_representation_json.cpp b/vndk/tools/header-checker/header-abi-util/src/ir_representation_json.cpp index 39b0d07cb..c04b33e0b 100644 --- a/vndk/tools/header-checker/header-abi-util/src/ir_representation_json.cpp +++ b/vndk/tools/header-checker/header-abi-util/src/ir_representation_json.cpp @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include "ir_representation_json.h" #include #include + #include #include @@ -934,4 +935,5 @@ void JsonToIRReader::ReadElfObjects(const JsonObjectRef &tu) { elf_objects_.insert({elf_object_ir.GetName(), std::move(elf_object_ir)}); } } -} // namespace abi_util + +} // namespace abi_util diff --git a/vndk/tools/header-checker/header-abi-util/src/ir_representation_protobuf.cpp b/vndk/tools/header-checker/header-abi-util/src/ir_representation_protobuf.cpp index 6037fa4bb..5951555f8 100644 --- a/vndk/tools/header-checker/header-abi-util/src/ir_representation_protobuf.cpp +++ b/vndk/tools/header-checker/header-abi-util/src/ir_representation_protobuf.cpp @@ -12,20 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include "ir_representation_protobuf.h" #include #include #include -#include #include +#include namespace abi_util { void ProtobufTextFormatToIRReader::ReadTypeInfo( - const abi_dump::BasicNamedAndTypedDecl &type_info, - TypeIR *typep) { + const abi_dump::BasicNamedAndTypedDecl &type_info, TypeIR *typep) { typep->SetLinkerSetKey(type_info.linker_set_key()); typep->SetName(type_info.name()); typep->SetSourceFile(type_info.source_file()); @@ -72,7 +71,7 @@ TemplateInfoIR ProtobufTextFormatToIRReader::TemplateInfoProtobufToIR( return template_info_ir; } -template< typename T> +template static void SetupCFunctionLikeIR(const T &cfunction_like_protobuf, CFunctionLikeIR *cfunction_like_ir) { cfunction_like_ir->SetReturnType(cfunction_like_protobuf.return_type()); @@ -387,8 +386,7 @@ bool IRToProtobufConverter::AddTemplateInformation( } bool IRToProtobufConverter::AddTypeInfo( - abi_dump::BasicNamedAndTypedDecl *type_info, - const TypeIR *typep) { + abi_dump::BasicNamedAndTypedDecl *type_info, const TypeIR *typep) { if (!type_info || !typep) { llvm::errs() << "Typeinfo not valid\n"; return false; @@ -522,8 +520,8 @@ abi_dump::RecordType IRToProtobufConverter::ConvertRecordTypeIR( !AddVTableLayout(&added_record_type, recordp) || !AddTagTypeInfo(added_record_type.mutable_tag_info(), recordp) || !(recordp->GetTemplateElements().size() ? - AddTemplateInformation(added_record_type.mutable_template_info(), - recordp) : true)) { + AddTemplateInformation(added_record_type.mutable_template_info(), + recordp) : true)) { llvm::errs() << "Template information could not be added\n"; ::exit(1); } @@ -837,8 +835,8 @@ abi_diff::RecordTypeDiff IRDiffToProtobufConverter::ConvertRecordTypeDiffIR( abi_diff::TypeInfoDiff *type_info_diff = record_type_diff_protobuf.mutable_type_info_diff(); if (!AddTypeInfoDiff(type_info_diff, type_diff_ir)) { - llvm::errs() << "RecordType could not be converted\n"; - ::exit(1); + llvm::errs() << "RecordType could not be converted\n"; + ::exit(1); } } // If vtables differ. @@ -856,7 +854,7 @@ abi_diff::RecordTypeDiff IRDiffToProtobufConverter::ConvertRecordTypeDiffIR( // If base specifiers differ. const CXXBaseSpecifierDiffIR *base_specifier_diff_ir = record_type_diff_ir->GetBaseSpecifiers(); - if ( base_specifier_diff_ir != nullptr) { + if (base_specifier_diff_ir != nullptr) { abi_diff::CXXBaseSpecifierDiff *base_specifier_diff_protobuf = record_type_diff_protobuf.mutable_bases_diff(); if (!AddBaseSpecifierDiffs(base_specifier_diff_protobuf, @@ -926,9 +924,9 @@ abi_diff::EnumTypeDiff IRDiffToProtobufConverter::ConvertEnumTypeDiffIR( const std::pair *underlying_type_diff = enum_type_diff_ir->GetUnderlyingTypeDiff(); if ((underlying_type_diff != nullptr && - !AddEnumUnderlyingTypeDiff( - enum_type_diff_protobuf.mutable_underlying_type_diff(), - underlying_type_diff)) || + !AddEnumUnderlyingTypeDiff( + enum_type_diff_protobuf.mutable_underlying_type_diff(), + underlying_type_diff)) || !AddEnumFields(enum_type_diff_protobuf.mutable_fields_removed(), enum_type_diff_ir->GetFieldsRemoved()) || !AddEnumFields(enum_type_diff_protobuf.mutable_fields_added(), @@ -970,12 +968,10 @@ abi_diff::FunctionDeclDiff IRDiffToProtobufConverter::ConvertFunctionDiffIR( llvm::errs() << "Function diff could not be added\n"; ::exit(1); } - *old_function = - IRToProtobufConverter::ConvertFunctionIR( - function_diff_ir->GetOldFunction()); - *new_function = - IRToProtobufConverter::ConvertFunctionIR( - function_diff_ir->GetNewFunction()); + *old_function = IRToProtobufConverter::ConvertFunctionIR( + function_diff_ir->GetOldFunction()); + *new_function = IRToProtobufConverter::ConvertFunctionIR( + function_diff_ir->GetNewFunction()); return function_diff; } @@ -1195,8 +1191,8 @@ CompatibilityStatusIR ProtobufIRDiffDumper::GetCompatibilityStatusIR() { combined_status | CompatibilityStatusIR::UnreferencedChanges; } - if(diff_tu_->removed_elf_functions().size() != 0 || - diff_tu_->removed_elf_objects().size() != 0) { + if (diff_tu_->removed_elf_functions().size() != 0 || + diff_tu_->removed_elf_objects().size() != 0) { combined_status = combined_status | CompatibilityStatusIR::ElfIncompatible; } @@ -1208,38 +1204,33 @@ void ProtobufIRDiffDumper::AddCompatibilityStatusIR( diff_tu_->set_compatibility_status(CompatibilityStatusIRToProtobuf(status)); } -bool ProtobufIRDiffDumper::AddDiffMessageIR( - const DiffMessageIR *message, - const std::string &type_stack, - DiffKind diff_kind) { +bool ProtobufIRDiffDumper::AddDiffMessageIR(const DiffMessageIR *message, + const std::string &type_stack, + DiffKind diff_kind) { switch (message->Kind()) { case RecordTypeKind: return AddRecordTypeDiffIR( - static_cast(message), - type_stack, diff_kind); + static_cast(message), type_stack, + diff_kind); case EnumTypeKind: return AddEnumTypeDiffIR( - static_cast(message), - type_stack, diff_kind); + static_cast(message), type_stack, diff_kind); case GlobalVarKind: return AddGlobalVarDiffIR( - static_cast(message), - type_stack, diff_kind); + static_cast(message), type_stack, diff_kind); case FunctionKind: return AddFunctionDiffIR( - static_cast(message), - type_stack, diff_kind); + static_cast(message), type_stack, diff_kind); default: break; } - llvm::errs() << "Dump Diff attempted on something not a user defined type" << - "/ function / global variable\n"; + llvm::errs() << "Dump Diff attempted on something not a user defined type / " + << "function / global variable\n"; return false; } bool ProtobufIRDiffDumper::AddLinkableMessageIR( - const LinkableMessageIR *message, - DiffKind diff_kind) { + const LinkableMessageIR *message, DiffKind diff_kind) { switch (message->GetKind()) { case RecordTypeKind: return AddLoneRecordTypeDiffIR( @@ -1256,13 +1247,13 @@ bool ProtobufIRDiffDumper::AddLinkableMessageIR( default: break; } - llvm::errs() << "Dump Diff attempted on something not a user defined type" << - "/ function / global variable\n"; + llvm::errs() << "Dump Diff attempted on something not a user defined type / " + << "function / global variable\n"; return false; } -bool ProtobufIRDiffDumper::AddElfSymbolMessageIR (const ElfSymbolIR *elf_symbol, - DiffKind diff_kind) { +bool ProtobufIRDiffDumper::AddElfSymbolMessageIR(const ElfSymbolIR *elf_symbol, + DiffKind diff_kind) { switch (elf_symbol->GetKind()) { case ElfSymbolIR::ElfFunctionKind: return AddElfFunctionIR(static_cast(elf_symbol), @@ -1280,7 +1271,7 @@ bool ProtobufIRDiffDumper::AddElfSymbolMessageIR (const ElfSymbolIR *elf_symbol, bool ProtobufIRDiffDumper::AddElfFunctionIR( const ElfFunctionIR *elf_function_ir, DiffKind diff_kind) { abi_dump::ElfFunction *added_elf_function = nullptr; - switch(diff_kind) { + switch (diff_kind) { case DiffKind::Removed: added_elf_function = diff_tu_->add_removed_elf_functions(); break; @@ -1302,7 +1293,7 @@ bool ProtobufIRDiffDumper::AddElfFunctionIR( bool ProtobufIRDiffDumper::AddElfObjectIR( const ElfObjectIR *elf_object_ir, DiffKind diff_kind) { abi_dump::ElfObject *added_elf_object = nullptr; - switch(diff_kind) { + switch (diff_kind) { case DiffKind::Removed: added_elf_object = diff_tu_->add_removed_elf_objects(); break; @@ -1322,8 +1313,7 @@ bool ProtobufIRDiffDumper::AddElfObjectIR( } bool ProtobufIRDiffDumper::AddLoneRecordTypeDiffIR( - const RecordTypeIR *record_type_ir, - DiffKind diff_kind) { + const RecordTypeIR *record_type_ir, DiffKind diff_kind) { abi_dump::RecordType *added_record_type = nullptr; switch (diff_kind) { case DiffKind::Removed: @@ -1348,8 +1338,7 @@ bool ProtobufIRDiffDumper::AddLoneRecordTypeDiffIR( } bool ProtobufIRDiffDumper::AddLoneFunctionDiffIR( - const FunctionIR *function_ir, - DiffKind diff_kind) { + const FunctionIR *function_ir, DiffKind diff_kind) { abi_dump::FunctionDecl *added_function = nullptr; switch (diff_kind) { case DiffKind::Removed: @@ -1409,8 +1398,7 @@ bool ProtobufIRDiffDumper::AddLoneGlobalVarDiffIR( } bool ProtobufIRDiffDumper::AddRecordTypeDiffIR( - const RecordTypeDiffIR *record_diff_ir, - const std::string &type_stack, + const RecordTypeDiffIR *record_diff_ir, const std::string &type_stack, DiffKind diff_kind) { abi_diff::RecordTypeDiff *added_record_type_diff = nullptr; switch (diff_kind) { @@ -1482,8 +1470,7 @@ bool ProtobufIRDiffDumper::AddEnumTypeDiffIR(const EnumTypeDiffIR *enum_diff_ir, } bool ProtobufIRDiffDumper::AddGlobalVarDiffIR( - const GlobalVarDiffIR *global_var_diff_ir, - const std::string &type_stack, + const GlobalVarDiffIR *global_var_diff_ir, const std::string &type_stack, DiffKind diff_kind) { abi_diff::GlobalVarDeclDiff *added_global_var_diff = diff_tu_->add_global_var_diffs(); diff --git a/vndk/tools/header-checker/header-abi-util/src/so_file_parser.cpp b/vndk/tools/header-checker/header-abi-util/src/so_file_parser.cpp index 8f3df14de..5750c321e 100644 --- a/vndk/tools/header-checker/header-abi-util/src/so_file_parser.cpp +++ b/vndk/tools/header-checker/header-abi-util/src/so_file_parser.cpp @@ -12,36 +12,36 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include +#include "so_file_parser.h" + +#include "ir_representation.h" -#include #include +#include #include #include -using llvm::object::ELF32LEObjectFile; -using llvm::object::ELF32BEObjectFile; -using llvm::object::ELF64LEObjectFile; -using llvm::object::ELF64BEObjectFile; -using llvm::dyn_cast; +using llvm::ELF::STB_GLOBAL; +using llvm::ELF::STB_WEAK; using llvm::ELF::STV_DEFAULT; using llvm::ELF::STV_PROTECTED; -using llvm::ELF::STB_WEAK; -using llvm::ELF::STB_GLOBAL; +using llvm::dyn_cast; +using llvm::object::ELF32BEObjectFile; +using llvm::object::ELF32LEObjectFile; +using llvm::object::ELF64BEObjectFile; +using llvm::object::ELF64LEObjectFile; namespace abi_util { template static inline T UnWrap(llvm::Expected ValueOrError) { - if (!ValueOrError) { - llvm::errs() << "\nError: " - << llvm::toString(ValueOrError.takeError()) - << ".\n"; - llvm::errs().flush(); - exit(1); - } - return std::move(ValueOrError.get()); + if (!ValueOrError) { + llvm::errs() << "\nError: " << llvm::toString(ValueOrError.takeError()) + << ".\n"; + llvm::errs().flush(); + exit(1); + } + return std::move(ValueOrError.get()); } template @@ -79,8 +79,7 @@ template void ELFSoFileParser::GetSymbols() { assert(obj_ != nullptr); for (auto symbol_it : obj_->getDynamicSymbolIterators()) { - const Elf_Sym *elf_sym = - obj_->getSymbol(symbol_it.getRawDataRefImpl()); + const Elf_Sym *elf_sym = obj_->getSymbol(symbol_it.getRawDataRefImpl()); assert (elf_sym != nullptr); if (!IsSymbolExported(elf_sym) || elf_sym->isUndefined()) { continue; @@ -106,7 +105,7 @@ static std::unique_ptr CreateELFSoFileParser( std::unique_ptr SoFileParser::Create( const llvm::object::ObjectFile *objfile) { - // Little-endian 32-bit + // Little-endian 32-bit if (const ELF32LEObjectFile *ELFObj = dyn_cast(objfile)) { return CreateELFSoFileParser(ELFObj); } @@ -128,5 +127,4 @@ std::unique_ptr SoFileParser::Create( return nullptr; } -} // namespace abi_util - +} // namespace abi_util diff --git a/vndk/tools/header-checker/header-abi-util/src/version_script_parser.cpp b/vndk/tools/header-checker/header-abi-util/src/version_script_parser.cpp index f973cebb7..794b47799 100644 --- a/vndk/tools/header-checker/header-abi-util/src/version_script_parser.cpp +++ b/vndk/tools/header-checker/header-abi-util/src/version_script_parser.cpp @@ -12,27 +12,27 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include "version_script_parser.h" #include #include #include -#include #include #include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include namespace abi_util { #define FUTURE_API 10000 -std::unordered_set AllArches({"arm", "arm64", "x86", "x86_64", - "mips", "mips64"}); +std::unordered_set AllArches({ + "arm", "arm64", "x86", "x86_64", "mips", "mips64"}); static bool StringContains(const std::string &line, const std::string &substring) { @@ -53,8 +53,8 @@ static bool LineSatisfiesArch(const std::string &line, VersionScriptParser::VersionScriptParser(const std::string &version_script, const std::string &arch, - const std::string &api) : - version_script_(version_script), arch_(arch), api_(ApiStrToInt(api)) { } + const std::string &api) + : version_script_(version_script), arch_(arch), api_(ApiStrToInt(api)) {} int VersionScriptParser::ApiStrToInt(const std::string &api) { // Follow what build/soong/cc/gen_stub_libs.py does. @@ -90,7 +90,7 @@ bool VersionScriptParser::SymbolInArchAndApiVersion(const std::string &line, } // If the arch specific tag / version specific tag was found and the api level // required was greater than the api level offered. - return (matched_api <=0 || api >= matched_api); + return (matched_api <= 0 || api >= matched_api); } bool VersionScriptParser::SymbolExported(const std::string &line, @@ -121,7 +121,7 @@ void VersionScriptParser::AddToFunctions(std::string &symbol) { } bool VersionScriptParser::ParseSymbolLine(const std::string &line) { - //The symbol lies before the ; and the tags are after ; + // The symbol lies before the ';' and the tags are after ';' std::string::size_type pos = line.find(";"); if (pos == std::string::npos) { llvm::errs() << "Couldn't find end of symbol" << line <<"\n"; @@ -194,22 +194,22 @@ bool VersionScriptParser::Parse() { llvm::errs() << "Failed to open version script file\n"; return false; } - std::string line = ""; + std::string line; while (std::getline(symbol_ifstream, line)) { // Skip comment lines. if (line.c_str()[0] == '#') { continue; } if (StringContains(line, "{")) { - if ((StringContains(line, "PRIVATE"))) { continue; } ParseInnerBlock(symbol_ifstream); } } + return true; } -} // namespace abi_util +} // namespace abi_util diff --git a/vndk/tools/header-checker/merge-abi-diff/src/merge_abi_diff.cpp b/vndk/tools/header-checker/merge-abi-diff/src/merge_abi_diff.cpp index bab13b638..1808a1f18 100644 --- a/vndk/tools/header-checker/merge-abi-diff/src/merge_abi_diff.cpp +++ b/vndk/tools/header-checker/merge-abi-diff/src/merge_abi_diff.cpp @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "header_abi_util.h" + #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-parameter" #pragma clang diagnostic ignored "-Wnested-anon-types" @@ -19,17 +21,15 @@ #include "abi_diff.pb.h" #pragma clang diagnostic pop -#include +#include +#include #include #include -#include -#include - -#include #include #include +#include #include #include diff --git a/vndk/tools/header-checker/proto/abi_diff.proto b/vndk/tools/header-checker/proto/abi_diff.proto index 632b392fe..03f8ebe4b 100644 --- a/vndk/tools/header-checker/proto/abi_diff.proto +++ b/vndk/tools/header-checker/proto/abi_diff.proto @@ -71,8 +71,8 @@ message FunctionDeclDiff { message GlobalVarDeclDiff { optional string type_stack = 1; optional string name = 2; - optional abi_dump.GlobalVarDecl old = 3; // Old global var - optional abi_dump.GlobalVarDecl new = 4; // New global var + optional abi_dump.GlobalVarDecl old = 3; // Old global var + optional abi_dump.GlobalVarDecl new = 4; // New global var } message TranslationUnitDiff { diff --git a/vndk/tools/header-checker/proto/abi_dump.proto b/vndk/tools/header-checker/proto/abi_dump.proto index c9aa6e2de..68ec0cc70 100644 --- a/vndk/tools/header-checker/proto/abi_dump.proto +++ b/vndk/tools/header-checker/proto/abi_dump.proto @@ -86,7 +86,7 @@ message RecordFieldDecl { } message EnumFieldDecl { - optional int64 enum_field_value = 1; // assumption: fits int64 + optional int64 enum_field_value = 1; // assumption: fits int64 optional string name = 3; } diff --git a/vndk/tools/header-checker/tests/input/example1.h b/vndk/tools/header-checker/tests/input/example1.h index 08c386993..b93eccc70 100644 --- a/vndk/tools/header-checker/tests/input/example1.h +++ b/vndk/tools/header-checker/tests/input/example1.h @@ -36,7 +36,7 @@ struct CPPHello : private HelloAgain, public ByeAgain { const int cpp_foo; cfloat_type cpp_bar; virtual int again() { return 0; } - CPPHello() : cpp_foo(20), cpp_bar(1.234) { } + CPPHello() : cpp_foo(20), cpp_bar(1.234) {} enum Bla{BLA = 1}; int test_enum() {return CPPHello::BLA;} }; @@ -57,7 +57,7 @@ public: public: StackNode(T t, StackNode* next = nullptr) : value_(static_cast(t)), - next_(next) { } + next_(next) {} }; template @@ -66,7 +66,7 @@ private: StackNode* head_; public: - Stack() : head_(nullptr) { } + Stack() : head_(nullptr) {} void push(T t) { head_ = new StackNode(static_cast(t), head_); diff --git a/vndk/tools/header-checker/tests/input/example2.h b/vndk/tools/header-checker/tests/input/example2.h index bc225eb6b..67f92de85 100644 --- a/vndk/tools/header-checker/tests/input/example2.h +++ b/vndk/tools/header-checker/tests/input/example2.h @@ -25,7 +25,7 @@ struct HelloAgain { virtual ~HelloAgain() {} }; struct NowWeCrash; -} // namespace test2 +} // namespace test2 enum Foo_s { foosball = 10, @@ -77,6 +77,6 @@ class Outer { std::vector Dummy(int t); -} // namespace test3 +} // namespace test3 #endif // EXAMPLE2_H_ diff --git a/vndk/tools/header-checker/tests/input/example3.h b/vndk/tools/header-checker/tests/input/example3.h index d55d2d864..4a5fdd081 100644 --- a/vndk/tools/header-checker/tests/input/example3.h +++ b/vndk/tools/header-checker/tests/input/example3.h @@ -6,4 +6,4 @@ class HiddenBase { float seek; }; -#endif //EXAMPLE3_H +#endif // EXAMPLE3_H_ diff --git a/vndk/tools/header-checker/tests/integration/c_and_cpp/include/c_and_cpp.h b/vndk/tools/header-checker/tests/integration/c_and_cpp/include/c_and_cpp.h index c4a7fcdcf..87351a062 100644 --- a/vndk/tools/header-checker/tests/integration/c_and_cpp/include/c_and_cpp.h +++ b/vndk/tools/header-checker/tests/integration/c_and_cpp/include/c_and_cpp.h @@ -12,7 +12,7 @@ struct UnusedStruct { class Foo { public: - Foo(int *a, int *b) : a_(a), b_(b) { } + Foo(int *a, int *b) : a_(a), b_(b) {} private: int *a_; int *b_; diff --git a/vndk/tools/header-checker/tests/integration/c_and_cpp/source2.c b/vndk/tools/header-checker/tests/integration/c_and_cpp/source2.c index d3f089945..8cb7127d5 100644 --- a/vndk/tools/header-checker/tests/integration/c_and_cpp/source2.c +++ b/vndk/tools/header-checker/tests/integration/c_and_cpp/source2.c @@ -1,4 +1,4 @@ -#include +#include void CFunction(struct Cstruct **cstruct) { if (cstruct) { diff --git a/vndk/tools/header-checker/tests/integration/cpp/gold/golden_1.cpp b/vndk/tools/header-checker/tests/integration/cpp/gold/golden_1.cpp index 60a31130a..997b9f644 100644 --- a/vndk/tools/header-checker/tests/integration/cpp/gold/golden_1.cpp +++ b/vndk/tools/header-checker/tests/integration/cpp/gold/golden_1.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include SuperSpeaker *SuperSpeaker::CreateSuperSpeaker(int id) { // :) diff --git a/vndk/tools/header-checker/tests/integration/cpp/gold/high_volume_speaker.cpp b/vndk/tools/header-checker/tests/integration/cpp/gold/high_volume_speaker.cpp index 57a7e9bc1..e56f417b1 100644 --- a/vndk/tools/header-checker/tests/integration/cpp/gold/high_volume_speaker.cpp +++ b/vndk/tools/header-checker/tests/integration/cpp/gold/high_volume_speaker.cpp @@ -1,6 +1,6 @@ #include -void HighVolumeSpeaker::Speak() { } +void HighVolumeSpeaker::Speak() {} HighVolumeSpeaker *HighVolumeSpeaker::BadPractice(BP_PARAMETER_TYPE id) { return nullptr; diff --git a/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h b/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h index 7aec15150..3af13dd22 100644 --- a/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h +++ b/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h @@ -51,9 +51,8 @@ class SuperSpeaker { public: VIRTUAL_FUNCTIONS Volume SpeakLoud(); - void SpeakLoudest() { }; - - virtual ~SuperSpeaker() { } + void SpeakLoudest() {} + virtual ~SuperSpeaker() {} private: #if GOLDEN_CHANGE_MEMBER_NAME_SAME_OFFSET int mSpeakderId_; @@ -80,5 +79,5 @@ class SuperSpeaker { }; private: InternalStruct a; -#endif // GOLDEN_WITH_INTERNAL_STRUCT +#endif // GOLDEN_WITH_INTERNAL_STRUCT }; diff --git a/vndk/tools/header-checker/tests/integration/cpp/gold/low_volume_speaker.cpp b/vndk/tools/header-checker/tests/integration/cpp/gold/low_volume_speaker.cpp index 04d9693ef..3abb08875 100644 --- a/vndk/tools/header-checker/tests/integration/cpp/gold/low_volume_speaker.cpp +++ b/vndk/tools/header-checker/tests/integration/cpp/gold/low_volume_speaker.cpp @@ -1,6 +1,7 @@ #include -void LowVolumeSpeaker::Speak() { } +void LowVolumeSpeaker::Speak() {} + LISTEN_RETURN_TYPE LowVolumeSpeaker::Listen() { LISTEN_RETURN_STATEMENT } #ifdef ADD_UNEXPORTED_ELF_SYMBOL diff --git a/vndk/tools/header-checker/tests/module.py b/vndk/tools/header-checker/tests/module.py index e81330a40..df2cb1f3e 100755 --- a/vndk/tools/header-checker/tests/module.py +++ b/vndk/tools/header-checker/tests/module.py @@ -13,16 +13,19 @@ from utils import run_header_abi_linker from utils import TARGET_ARCHS from utils import SOURCE_ABI_DUMP_EXT + SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) INPUT_DIR = os.path.join(SCRIPT_DIR, 'input') EXPECTED_DIR = os.path.join(SCRIPT_DIR, 'expected') -REF_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps') -ARCH_TARGET_CFLAGS = {'arm': ['-target', 'arm-linux-androideabi'], - 'arm64': ['-target', 'aarch64-linux-android'], - 'x86' : ['-target', 'i386-linux-androideabi'], - 'x86_64' : ['-target', 'x86_64-linux-android'], - 'mips' : ['-target', 'mips-linux-androideabi'], - 'mips64' : ['-target', 'mips64-linux-android'],} +REF_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps') +ARCH_TARGET_CFLAGS = { + 'arm': ['-target', 'arm-linux-androideabi'], + 'arm64': ['-target', 'aarch64-linux-android'], + 'x86': ['-target', 'i386-linux-androideabi'], + 'x86_64': ['-target', 'x86_64-linux-android'], + 'mips': ['-target', 'mips-linux-androideabi'], + 'mips64': ['-target', 'mips64-linux-android'], +} def relative_to_abs_path(relative_path): return os.path.join(SCRIPT_DIR, relative_path) @@ -127,384 +130,412 @@ class Module(object): TEST_MODULES = [ Module( - name = 'libc_and_cpp', - srcs = ['integration/c_and_cpp/source1.cpp', - 'integration/c_and_cpp/source2.c', - ], - version_script = 'integration/c_and_cpp/map.txt', - export_include_dirs = ['integration/c_and_cpp/include'], - cflags = [], - arch = '', - api = 'current', + name='libc_and_cpp', + srcs=[ + 'integration/c_and_cpp/source1.cpp', + 'integration/c_and_cpp/source2.c', + ], + version_script='integration/c_and_cpp/map.txt', + export_include_dirs=['integration/c_and_cpp/include'], + cflags=[], + arch='', + api='current', ), Module( - name = 'libc_and_cpp_with_opaque_ptr_a', - srcs = ['integration/c_and_cpp/source1.cpp', - 'integration/c_and_cpp/source2.c', - ], - version_script = 'integration/c_and_cpp/map.txt', - export_include_dirs = ['integration/c_and_cpp/include'], - cflags = ['-DOPAQUE_STRUCT_A=1'], - arch = '', - api = 'current', + name='libc_and_cpp_with_opaque_ptr_a', + srcs=[ + 'integration/c_and_cpp/source1.cpp', + 'integration/c_and_cpp/source2.c', + ], + version_script='integration/c_and_cpp/map.txt', + export_include_dirs=['integration/c_and_cpp/include'], + cflags=['-DOPAQUE_STRUCT_A=1'], + arch='', + api='current', ), Module( - name = 'libc_and_cpp_with_opaque_ptr_b', - srcs = ['integration/c_and_cpp/source1.cpp', - 'integration/c_and_cpp/source2.c', - ], - version_script = 'integration/c_and_cpp/map.txt', - export_include_dirs = ['integration/c_and_cpp/include'], - cflags = ['-DOPAQUE_STRUCT_B=1'], - arch = '', - api = 'current', + name='libc_and_cpp_with_opaque_ptr_b', + srcs=[ + 'integration/c_and_cpp/source1.cpp', + 'integration/c_and_cpp/source2.c', + ], + version_script='integration/c_and_cpp/map.txt', + export_include_dirs=['integration/c_and_cpp/include'], + cflags=['-DOPAQUE_STRUCT_B=1'], + arch='', + api='current', ), Module( - name = 'libc_and_cpp_with_unused_struct', - srcs = ['integration/c_and_cpp/source1.cpp', - 'integration/c_and_cpp/source2.c', - ], - version_script = 'integration/c_and_cpp/map.txt', - export_include_dirs = ['integration/c_and_cpp/include'], - cflags = ['-DINCLUDE_UNUSED_STRUCTS=1'], - arch = '', - api = 'current', + name='libc_and_cpp_with_unused_struct', + srcs=[ + 'integration/c_and_cpp/source1.cpp', + 'integration/c_and_cpp/source2.c', + ], + version_script='integration/c_and_cpp/map.txt', + export_include_dirs=['integration/c_and_cpp/include'], + cflags=['-DINCLUDE_UNUSED_STRUCTS=1'], + arch='', + api='current', ), Module( - name = 'libc_and_cpp_with_unused_cstruct', - srcs = ['integration/c_and_cpp/source1.cpp', - 'integration/c_and_cpp/source2.c', - ], - version_script = 'integration/c_and_cpp/map.txt', - export_include_dirs = ['integration/c_and_cpp/include'], - cflags = ['-DINCLUDE_UNUSED_STRUCTS=1', '-DMAKE_UNUSED_STRUCT_C=1'], - arch = '', - api = 'current', + name='libc_and_cpp_with_unused_cstruct', + srcs=[ + 'integration/c_and_cpp/source1.cpp', + 'integration/c_and_cpp/source2.c', + ], + version_script='integration/c_and_cpp/map.txt', + export_include_dirs=['integration/c_and_cpp/include'], + cflags=['-DINCLUDE_UNUSED_STRUCTS=1', '-DMAKE_UNUSED_STRUCT_C=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = [], - arch = '', - api = 'current', + name='libgolden_cpp', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=[], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_odr', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DTEST_ODR'], - arch = '', - api = 'current', + name='libgolden_cpp_odr', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DTEST_ODR'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_add_function', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map_add_function.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_ADD_FUNCTION=1'], - arch = '', - api = 'current', + name='libgolden_cpp_add_function', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map_add_function.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_ADD_FUNCTION=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_add_function_and_unexported_elf', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = \ - 'integration/cpp/gold/map_add_function_elf_symbol.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_ADD_FUNCTION=1', '-DADD_UNEXPORTED_ELF_SYMBOL'], - arch = '', - api = 'current', + name='libgolden_cpp_add_function_and_unexported_elf', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map_add_function_elf_symbol.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_ADD_FUNCTION=1', '-DADD_UNEXPORTED_ELF_SYMBOL'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_change_function_access', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_CHANGE_FUNCTION_ACCESS=1'], - arch = '', - api = 'current', + name='libgolden_cpp_change_function_access', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_CHANGE_FUNCTION_ACCESS=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_add_global_variable', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map_added_globvar.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_ADD_GLOBVAR=1'], - arch = '', - api = 'current', + name='libgolden_cpp_add_global_variable', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map_added_globvar.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_ADD_GLOBVAR=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_add_global_variable_private', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map_added_globvar.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_ADD_GLOBVAR=1', '-DGOLDEN_ADD_GLOBVAR_PRIVATE'], - arch = '', - api = 'current', + name='libgolden_cpp_add_global_variable_private', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map_added_globvar.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_ADD_GLOBVAR=1', '-DGOLDEN_ADD_GLOBVAR_PRIVATE'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_return_type_diff', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_RETURN_TYPE_DIFF=1'], - arch = '', - api = 'current', + name='libgolden_cpp_return_type_diff', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_RETURN_TYPE_DIFF=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_parameter_type_diff', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map_parameter_type_diff.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_PARAMETER_TYPE_DIFF=1'], - arch = '', - api = 'current', + name='libgolden_cpp_parameter_type_diff', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map_parameter_type_diff.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_PARAMETER_TYPE_DIFF=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_vtable_diff', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_VTABLE_DIFF=1'], - arch = '', - api = 'current', + name='libgolden_cpp_vtable_diff', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_VTABLE_DIFF=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_member_diff', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_MEMBER_DIFF=1'], - arch = '', - api = 'current', + name='libgolden_cpp_member_diff', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_MEMBER_DIFF=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_member_fake_diff', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_MEMBER_FAKE_DIFF=1'], - arch = '', - api = 'current', + name='libgolden_cpp_member_fake_diff', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_MEMBER_FAKE_DIFF=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_member_cv_diff', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_MEMBER_CV_DIFF=1'], - arch = '', - api = 'current', + name='libgolden_cpp_member_cv_diff', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_MEMBER_CV_DIFF=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_change_member_access', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_CHANGE_MEMBER_ACCESS=1'], - arch = '', - api = 'current', + name='libgolden_cpp_change_member_access', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_CHANGE_MEMBER_ACCESS=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_member_integral_type_diff', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_MEMBER_INTEGRAL_TYPE_DIFF=1'], - arch = '', - api = 'current', + name='libgolden_cpp_member_integral_type_diff', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_MEMBER_INTEGRAL_TYPE_DIFF=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_enum_diff', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_ENUM_DIFF=1'], - arch = '', - api = 'current', + name='libgolden_cpp_enum_diff', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_ENUM_DIFF=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_enum_extended', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_ENUM_EXTENSION=1'], - arch = '', - api = 'current', + name='libgolden_cpp_enum_extended', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_ENUM_EXTENSION=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_unreferenced_elf_symbol_removed', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map_elf_symbol_removed.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = [], - arch = '', - api = 'current', + name='libgolden_cpp_unreferenced_elf_symbol_removed', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map_elf_symbol_removed.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=[], + arch='', + api='current', ), Module( - name = 'libreproducability', - srcs = ['integration/c_and_cpp/reproducability.c', - ], - version_script = 'integration/c_and_cpp/repro_map.txt', - export_include_dirs = ['integration/c_and_cpp/include'], - cflags = [], - arch = '', - api = 'current', + name='libreproducability', + srcs=['integration/c_and_cpp/reproducability.c'], + version_script='integration/c_and_cpp/repro_map.txt', + export_include_dirs=['integration/c_and_cpp/include'], + cflags=[], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_member_name_changed', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_CHANGE_MEMBER_NAME_SAME_OFFSET=1'], - arch = '', - api = 'current', + name='libgolden_cpp_member_name_changed', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_CHANGE_MEMBER_NAME_SAME_OFFSET=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_function_pointer', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_FUNCTION_POINTER=1'], - arch = '', - api = 'current', + name='libgolden_cpp_function_pointer', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_FUNCTION_POINTER=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_function_pointer_parameter_added', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_FUNCTION_POINTER_ADD_PARAM=1', - '-DGOLDEN_FUNCTION_POINTER=1'], - arch = '', - api = 'current', + name='libgolden_cpp_function_pointer_parameter_added', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_FUNCTION_POINTER_ADD_PARAM=1', + '-DGOLDEN_FUNCTION_POINTER=1'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_internal_public_struct', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_WITH_INTERNAL_STRUCT', - '-DGOLDEN_WITH_PUBLIC_INTERNAL_STRUCT'], - arch = '', - api = 'current', + name='libgolden_cpp_internal_public_struct', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_WITH_INTERNAL_STRUCT', + '-DGOLDEN_WITH_PUBLIC_INTERNAL_STRUCT'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_internal_private_struct', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_WITH_INTERNAL_STRUCT'], - arch = '', - api = 'current', + name='libgolden_cpp_internal_private_struct', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_WITH_INTERNAL_STRUCT'], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_inheritance_type_changed', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = ['-DGOLDEN_CHANGE_INHERITANCE_TYPE'], - arch = '', - api = 'current', + name='libgolden_cpp_inheritance_type_changed', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=['-DGOLDEN_CHANGE_INHERITANCE_TYPE'], + arch='', + api='current', ), Module( - name = 'libpure_virtual_function', - srcs = ['integration/cpp/pure_virtual/pure_virtual_function.cpp'], - export_include_dirs = ['integration/cpp/pure_virtual/include'], - version_script = '', - cflags = [], - arch = '', - api = 'current', + name='libpure_virtual_function', + srcs=['integration/cpp/pure_virtual/pure_virtual_function.cpp'], + export_include_dirs=['integration/cpp/pure_virtual/include'], + version_script='', + cflags=[], + arch='', + api='current', ), Module( - name = 'libgolden_cpp_json', - srcs = ['integration/cpp/gold/golden_1.cpp', - 'integration/cpp/gold/high_volume_speaker.cpp', - 'integration/cpp/gold/low_volume_speaker.cpp', - ], - version_script = 'integration/cpp/gold/map.txt', - export_include_dirs = ['integration/cpp/gold/include'], - cflags = [], - arch = '', - api = 'current', - dumper_flags = ['-output-format', 'Json'], - linker_flags = ['-input-format', 'Json', '-output-format', 'Json'] + name='libgolden_cpp_json', + srcs=[ + 'integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script='integration/cpp/gold/map.txt', + export_include_dirs=['integration/cpp/gold/include'], + cflags=[], + arch='', + api='current', + dumper_flags=['-output-format', 'Json'], + linker_flags=['-input-format', 'Json', '-output-format', 'Json'] ), ] -TEST_MODULES = { m.name: m for m in TEST_MODULES } +TEST_MODULES = {m.name: m for m in TEST_MODULES} diff --git a/vndk/tools/header-checker/tests/test.py b/vndk/tools/header-checker/tests/test.py index f96fe0aa6..eea3ff16d 100755 --- a/vndk/tools/header-checker/tests/test.py +++ b/vndk/tools/header-checker/tests/test.py @@ -10,15 +10,17 @@ import_path = os.path.abspath(os.path.join(import_path, 'utils')) sys.path.insert(1, import_path) from utils import ( - AOSP_DIR, SOURCE_ABI_DUMP_EXT, TARGET_ARCHS, read_output_content, - run_abi_diff, run_header_abi_dumper) + AOSP_DIR, SOURCE_ABI_DUMP_EXT, TARGET_ARCHS, read_output_content, + run_abi_diff, run_header_abi_dumper) from module import Module from gen_all import make_and_copy_reference_dumps + SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) INPUT_DIR = os.path.join(SCRIPT_DIR, 'input') EXPECTED_DIR = os.path.join(SCRIPT_DIR, 'expected') -REF_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps') +REF_DUMP_DIR = os.path.join(SCRIPT_DIR, 'reference_dumps') + class MyTest(unittest.TestCase): @classmethod @@ -50,7 +52,7 @@ class MyTest(unittest.TestCase): self.run_and_compare_name_cpp(name, cflags) def run_and_compare_abi_diff(self, old_dump, new_dump, lib, arch, - expected_return_code, flags=[]) : + expected_return_code, flags=[]): actual_output = run_abi_diff(old_dump, new_dump, arch, lib, flags) self.assertEqual(actual_output, expected_return_code) @@ -63,8 +65,7 @@ class MyTest(unittest.TestCase): def create_ref_dump(self, name, dir_name, target_arch): module_bare = Module.get_test_module_by_name(name) module = Module.mutate_module_for_arch(module_bare, target_arch) - return make_and_copy_reference_dumps(module, [], - dir_name) + return make_and_copy_reference_dumps(module, [], dir_name) def get_or_create_ref_dump(self, name, target_arch, dir_name, create): if create == True: @@ -76,26 +77,22 @@ class MyTest(unittest.TestCase): create_old=False, create_new=True): with tempfile.TemporaryDirectory() as tmp: for target_arch in TARGET_ARCHS: - old_ref_dump_path = self.get_or_create_ref_dump(old_lib, - target_arch, - tmp, create_old) - new_ref_dump_path = self.get_or_create_ref_dump(new_lib, - target_arch, - tmp, create_new) - self.prepare_and_run_abi_diff(old_ref_dump_path, - new_ref_dump_path, target_arch, - expected_return_code, flags) + old_ref_dump_path = self.get_or_create_ref_dump( + old_lib, target_arch, tmp, create_old) + new_ref_dump_path = self.get_or_create_ref_dump( + new_lib, target_arch, tmp, create_new) + self.prepare_and_run_abi_diff( + old_ref_dump_path, new_ref_dump_path, target_arch, + expected_return_code, flags) def prepare_and_absolute_diff_all_archs(self, old_lib, new_lib, flags=[], create=True): with tempfile.TemporaryDirectory() as tmp: for target_arch in TARGET_ARCHS: - old_ref_dump_path = self.get_or_create_ref_dump(old_lib, - target_arch, - tmp, False) - new_ref_dump_path = self.get_or_create_ref_dump(new_lib, - target_arch, - tmp, create) + old_ref_dump_path = self.get_or_create_ref_dump( + old_lib, target_arch, tmp, False) + new_ref_dump_path = self.get_or_create_ref_dump( + new_lib, target_arch, tmp, create) self.assertEqual( read_output_content(old_ref_dump_path, AOSP_DIR), read_output_content(new_ref_dump_path, AOSP_DIR)) @@ -117,8 +114,8 @@ class MyTest(unittest.TestCase): self.run_and_compare_name_cpp('example2.h') def test_libc_and_cpp(self): - self.prepare_and_run_abi_diff_all_archs("libc_and_cpp", "libc_and_cpp", - 0) + self.prepare_and_run_abi_diff_all_archs( + "libc_and_cpp", "libc_and_cpp", 0) def test_libc_and_cpp_and_libc_and_cpp_with_unused_struct(self): self.prepare_and_run_abi_diff_all_archs( @@ -134,14 +131,15 @@ class MyTest(unittest.TestCase): "libc_and_cpp", "libc_and_cpp_with_unused_struct", 1, ['-check-all-apis']) - def test_libc_and_cpp_with_unused_struct_and_libc_and_cpp_with_unused_cstruct(self): + def test_libc_and_cpp_with_unused_struct_and_libc_and_cpp_with_unused_cstruct( + self): self.prepare_and_run_abi_diff_all_archs( "libc_and_cpp_with_unused_struct", "libc_and_cpp_with_unused_cstruct", 0, ['-check-all-apis', '-allow-unreferenced-changes']) def test_libc_and_cpp_and_libc_and_cpp_with_unused_struct_check_all_advice( - self): + self): self.prepare_and_run_abi_diff_all_archs( "libc_and_cpp", "libc_and_cpp_with_unused_struct", 0, ['-check-all-apis', '-advice-only']) @@ -150,8 +148,7 @@ class MyTest(unittest.TestCase): self.prepare_and_run_abi_diff_all_archs( "libc_and_cpp_with_opaque_ptr_a", "libc_and_cpp_with_opaque_ptr_b", 8, - ['-consider-opaque-types-different'], True, - True) + ['-consider-opaque-types-different'], True, True) def test_libgolden_cpp_return_type_diff(self): self.prepare_and_run_abi_diff_all_archs( @@ -173,8 +170,7 @@ class MyTest(unittest.TestCase): def test_libgolden_cpp_add_function_and_elf_symbol(self): self.prepare_and_run_abi_diff_all_archs( - "libgolden_cpp", "libgolden_cpp_add_function_and_unexported_elf", - 4) + "libgolden_cpp", "libgolden_cpp_add_function_and_unexported_elf", 4) def test_libgolden_cpp_change_function_access(self): self.prepare_and_run_abi_diff_all_archs( @@ -194,29 +190,28 @@ class MyTest(unittest.TestCase): "libgolden_cpp", "libgolden_cpp_parameter_type_diff", 8) def test_libgolden_cpp_with_vtable_diff(self): - self.prepare_and_run_abi_diff_all_archs("libgolden_cpp", - "libgolden_cpp_vtable_diff", 8) + self.prepare_and_run_abi_diff_all_archs( + "libgolden_cpp", "libgolden_cpp_vtable_diff", 8) def test_libgolden_cpp_member_diff_advice_only(self): - self.prepare_and_run_abi_diff_all_archs("libgolden_cpp", - "libgolden_cpp_member_diff", - 0, ['-advice-only']) + self.prepare_and_run_abi_diff_all_archs( + "libgolden_cpp", "libgolden_cpp_member_diff", 0, ['-advice-only']) def test_libgolden_cpp_member_diff(self): - self.prepare_and_run_abi_diff_all_archs("libgolden_cpp", - "libgolden_cpp_member_diff", 8) + self.prepare_and_run_abi_diff_all_archs( + "libgolden_cpp", "libgolden_cpp_member_diff", 8) def test_libgolden_cpp_change_member_access(self): self.prepare_and_run_abi_diff_all_archs( "libgolden_cpp", "libgolden_cpp_change_member_access", 8) def test_libgolden_cpp_enum_extended(self): - self.prepare_and_run_abi_diff_all_archs("libgolden_cpp", - "libgolden_cpp_enum_extended", - 4) + self.prepare_and_run_abi_diff_all_archs( + "libgolden_cpp", "libgolden_cpp_enum_extended", 4) + def test_libgolden_cpp_enum_diff(self): - self.prepare_and_run_abi_diff_all_archs("libgolden_cpp", - "libgolden_cpp_enum_diff", 8) + self.prepare_and_run_abi_diff_all_archs( + "libgolden_cpp", "libgolden_cpp_enum_diff", 8) def test_libgolden_cpp_fabricated_function_ast_removed_diff(self): self.prepare_and_run_abi_diff_all_archs( @@ -237,35 +232,31 @@ class MyTest(unittest.TestCase): def test_libgolden_cpp_unreferenced_elf_symbol_removed(self): self.prepare_and_run_abi_diff_all_archs( - "libgolden_cpp", - "libgolden_cpp_unreferenced_elf_symbol_removed", 16) + "libgolden_cpp", "libgolden_cpp_unreferenced_elf_symbol_removed", + 16) def test_libreproducability(self): - self.prepare_and_absolute_diff_all_archs("libreproducability", - "libreproducability") + self.prepare_and_absolute_diff_all_archs( + "libreproducability", "libreproducability") def test_libgolden_cpp_member_name_changed(self): self.prepare_and_run_abi_diff_all_archs( - "libgolden_cpp", - "libgolden_cpp_member_name_changed", 0) + "libgolden_cpp", "libgolden_cpp_member_name_changed", 0) def test_libgolden_cpp_member_function_pointer_changed(self): self.prepare_and_run_abi_diff_all_archs( "libgolden_cpp_function_pointer", - "libgolden_cpp_function_pointer_parameter_added", 8, [], True, - True) + "libgolden_cpp_function_pointer_parameter_added", 8, [], True, True) def test_libgolden_cpp_internal_struct_access_upgraded(self): self.prepare_and_run_abi_diff_all_archs( "libgolden_cpp_internal_private_struct", - "libgolden_cpp_internal_public_struct", 0, [], True, - True) + "libgolden_cpp_internal_public_struct", 0, [], True, True) def test_libgolden_cpp_internal_struct_access_downgraded(self): self.prepare_and_run_abi_diff_all_archs( "libgolden_cpp_internal_public_struct", - "libgolden_cpp_internal_private_struct", 8, [], True, - True) + "libgolden_cpp_internal_private_struct", 8, [], True, True) def test_libgolden_cpp_inheritance_type_changed(self): self.prepare_and_run_abi_diff_all_archs( @@ -274,9 +265,7 @@ class MyTest(unittest.TestCase): def test_libpure_virtual_function(self): self.prepare_and_absolute_diff_all_archs( - "libpure_virtual_function", - "libpure_virtual_function", - ) + "libpure_virtual_function", "libpure_virtual_function") def test_libc_and_cpp_in_json(self): self.prepare_and_absolute_diff_all_archs( diff --git a/vndk/tools/header-checker/utils/utils.py b/vndk/tools/header-checker/utils/utils.py index 8f2205381..989af99b9 100644 --- a/vndk/tools/header-checker/utils/utils.py +++ b/vndk/tools/header-checker/utils/utils.py @@ -73,7 +73,7 @@ def copy_reference_dump(lib_path, reference_dump_dir, compress): else: with open(reference_dump_path, 'wb') as f: f.write(bytes(output_content, 'utf-8')) - print('Created abi dump at ', reference_dump_path) + print('Created abi dump at', reference_dump_path) return reference_dump_path @@ -89,7 +89,7 @@ def copy_reference_dump_content(lib_name, output_content, with open(reference_dump_path, 'w') as f: f.write(output_content) - print('Created abi dump at ', reference_dump_path) + print('Created abi dump at', reference_dump_path) return reference_dump_path @@ -129,7 +129,7 @@ def run_header_abi_dumper_on_file(input_path, output_path, for dir in BUILTIN_HEADERS_DIR: cmd += ['-isystem', dir] - # export includes imply local includes + # The export include dirs imply local include dirs. for dir in export_include_dirs: cmd += ['-I', dir] subprocess.check_call(cmd)