diff --git a/vndk/tools/header-checker/Android.bp b/vndk/tools/header-checker/Android.bp index 032e863a8..71cf17594 100644 --- a/vndk/tools/header-checker/Android.bp +++ b/vndk/tools/header-checker/Android.bp @@ -45,6 +45,7 @@ cc_defaults { "libclangFrontendTool", "libclangFrontend", "libclangDriver", + "libclangIndex", "libclangSerialization", "libclangCodeGen", "libclangRewriteFrontend", @@ -84,8 +85,13 @@ cc_defaults { name: "header-abi-linker-lib-defaults", static_libs: [ - "libLLVMSupport", "libheader-abi-util", + "libLLVMObject", + "libLLVMBitReader", + "libLLVMMC", + "libLLVMMCParser", + "libLLVMCore", + "libLLVMSupport", ], shared_libs: [ @@ -257,8 +263,14 @@ cc_library_static { "header-abi-util/src/*.cpp" ], static_libs: [ + "libLLVMObject", + "libLLVMBitReader", + "libLLVMMC", + "libLLVMMCParser", + "libLLVMCore", "libLLVMSupport", ], + cflags: [ "-Wcast-qual", "-Wno-long-long", 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 79ef08229..d4f535d1f 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 @@ -241,8 +241,8 @@ template <> std::unique_ptr DiffWrapper::Get() { std::unique_ptr record_diff(new RecordDeclDiff()); - assert(oldp_->mangled_record_name() == - newp_->mangled_record_name()); + assert(oldp_->basic_abi().linker_set_key() == + newp_->basic_abi().linker_set_key()); record_diff->set_name(oldp_->basic_abi().name()); google::protobuf::RepeatedPtrField *fdiffs = record_diff->mutable_field_diffs(); 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 d23d86ebb..850a9ca2e 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 @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -70,8 +71,12 @@ abi_dump::AccessSpecifier ABIWrapper::AccessClangToDump( } } +// Dumping the size and alignment is optional. This is since clang can lazily +// instantiate records as incomplete and therefore their sizes 'may' not be +// computable. b/62307940 bool ABIWrapper::SetupBasicTypeAbi(abi_dump::BasicTypeAbi *type_abi, - const clang::QualType type) const { + const clang::QualType type, + bool dump_size) const { if (!type_abi) { return false; } @@ -82,7 +87,7 @@ bool ABIWrapper::SetupBasicTypeAbi(abi_dump::BasicTypeAbi *type_abi, const clang::Type *base_type = canonical_type.getTypePtr(); clang::Type::TypeClass type_class = base_type->getTypeClass(); // Temporary Hack for auto type sizes. Not determinable. - if (base_type && !(base_type->isDependentType()) && + if (dump_size && base_type && !(base_type->isDependentType()) && !(base_type->isIncompleteType()) && (type_class != clang::Type::Auto)) { std::pair size_and_alignment = ast_contextp_->getTypeInfoInChars(canonical_type); @@ -97,7 +102,8 @@ bool ABIWrapper::SetupBasicTypeAbi(abi_dump::BasicTypeAbi *type_abi, bool ABIWrapper::SetupBasicNamedAndTypedDecl( abi_dump::BasicNamedAndTypedDecl *basic_named_and_typed_decl, const clang::QualType type, const std::string &name, - const clang::AccessSpecifier &access, std::string key) const { + const clang::AccessSpecifier &access, std::string key, + bool dump_size) const { if (!basic_named_and_typed_decl) { return false; } @@ -108,18 +114,33 @@ bool ABIWrapper::SetupBasicNamedAndTypedDecl( basic_named_and_typed_decl->set_linker_set_key(key); } return SetupBasicTypeAbi(basic_named_and_typed_decl->mutable_type_abi(), - type); + type, dump_size); } -std::string ABIWrapper::GetMangledNameDecl(const clang::NamedDecl *decl) const { - assert(&(mangle_contextp_->getASTContext()) == ast_contextp_); - if (!mangle_contextp_->shouldMangleDeclName(decl)) { +static bool ShouldDumpSize(clang::QualType qt) { + const clang::Type *type_ptr = qt.getTypePtr(); + assert(type_ptr != nullptr); + if (type_ptr->isBuiltinType() || type_ptr->isPointerType()) { + return true; + } + return false; +} + +std::string ABIWrapper::GetTypeLinkageName(const clang::Type *typep) const { + assert(typep != nullptr); + clang::QualType qt = typep->getCanonicalTypeInternal(); + return QualTypeToString(qt); +} + +std::string ABIWrapper::GetMangledNameDecl( + const clang::NamedDecl *decl, clang::MangleContext *mangle_contextp) { + if (!mangle_contextp->shouldMangleDeclName(decl)) { clang::IdentifierInfo *identifier = decl->getIdentifier(); return identifier ? identifier->getName() : ""; } std::string mangled_name; llvm::raw_string_ostream ostream(mangled_name); - mangle_contextp_->mangleName(decl, ostream); + mangle_contextp->mangleName(decl, ostream); ostream.flush(); return mangled_name; } @@ -177,7 +198,8 @@ bool ABIWrapper::SetupTemplateArguments( } abi_dump::TemplateElement::BasicTemplateElementAbi *basic_abi = template_parameterp->mutable_basic_abi(); - if (!basic_abi || !SetupBasicTypeAbi(basic_abi->mutable_type_abi(), type)) { + if (!basic_abi || !SetupBasicTypeAbi(basic_abi->mutable_type_abi(), type, + false)) { return false; } // TODO : default arg @@ -217,10 +239,13 @@ bool FunctionDeclWrapper::SetupFunctionParameters( } // The linker set key is blank since that shows up in the mangled name. bool has_default_arg = (*param_it)->hasDefaultArg(); + clang::QualType param_qt = (*param_it)->getType(); + bool should_dump_size = ShouldDumpSize(param_qt); if (!SetupBasicNamedAndTypedDecl( function_fieldp->mutable_basic_abi(), (*param_it)->getType(), (*param_it)->getName(), - (*param_it)->getAccess(), has_default_arg ? "true" : "false")) { + (*param_it)->getAccess(), has_default_arg ? "true" : "false", + should_dump_size)) { return false; } function_fieldp->set_default_arg(has_default_arg); @@ -232,16 +257,15 @@ bool FunctionDeclWrapper::SetupFunctionParameters( bool FunctionDeclWrapper::SetupFunction(abi_dump::FunctionDecl *functionp, const std::string &source_file) const { // Go through all the parameters in the method and add them to the fields. - // Also get the fully qualfied name and mangled name and store them. - std::string mangled_name = GetMangledNameDecl(function_decl_); - functionp->set_mangled_function_name(mangled_name); + // Also get the fully qualfied name. functionp->set_source_file(source_file); // Combine the function name and return type to form a NamedAndTypedDecl + clang::QualType return_type = function_decl_->getReturnType(); + bool should_dump_size = ShouldDumpSize(return_type); return SetupBasicNamedAndTypedDecl( functionp->mutable_basic_abi(), - function_decl_->getReturnType(), - function_decl_->getQualifiedNameAsString(), - function_decl_->getAccess(), mangled_name) && + return_type, function_decl_->getQualifiedNameAsString(), + function_decl_->getAccess(), "", should_dump_size) && SetupTemplateInfo(functionp) && SetupFunctionParameters(functionp); } @@ -309,7 +333,7 @@ bool RecordDeclWrapper::SetupRecordFields(abi_dump::RecordDecl *recordp) const { } if (!SetupBasicNamedAndTypedDecl(record_fieldp->mutable_basic_abi(), field->getType(), field->getName(), - field->getAccess(), "")) { + field->getAccess(), "", true)) { return false; } field++; @@ -334,7 +358,7 @@ bool RecordDeclWrapper::SetupCXXBases( if (!SetupBasicNamedAndTypedDecl(base_specifierp->mutable_basic_abi(), base_class->getType(), "", base_class->getAccessSpecifier(), - "")) { + "", false)) { return false; } base_specifierp->set_is_virtual(is_virtual); @@ -383,7 +407,8 @@ bool RecordDeclWrapper::SetupRecordVTableComponent( assert(added_vtable_component != nullptr); abi_dump::VTableComponent_Kind kind = abi_dump::VTableComponent_Kind_RTTI; std::string mangled_component_name = ""; - uint64_t value = 0; + llvm::raw_string_ostream ostream(mangled_component_name); + int64_t value = 0; clang::VTableComponent::Kind clang_component_kind = vtable_component.getKind(); switch (clang_component_kind) { @@ -405,7 +430,8 @@ bool RecordDeclWrapper::SetupRecordVTableComponent( const clang::CXXRecordDecl *rtti_decl = vtable_component.getRTTIDecl(); assert(rtti_decl != nullptr); - mangled_component_name = GetMangledNameDecl(rtti_decl); + mangled_component_name = + ABIWrapper::GetTypeLinkageName(rtti_decl->getTypeForDecl()); } break; case clang::VTableComponent::CK_FunctionPointer: @@ -416,16 +442,27 @@ bool RecordDeclWrapper::SetupRecordVTableComponent( const clang::CXXMethodDecl *method_decl = vtable_component.getFunctionDecl(); assert(method_decl != nullptr); - mangled_component_name = GetMangledNameDecl(method_decl); switch (clang_component_kind) { case clang::VTableComponent::CK_FunctionPointer: kind = abi_dump::VTableComponent_Kind_FunctionPointer; + mangled_component_name = GetMangledNameDecl(method_decl, + mangle_contextp_); break; case clang::VTableComponent::CK_CompleteDtorPointer: kind = abi_dump::VTableComponent_Kind_CompleteDtorPointer; + mangle_contextp_->mangleCXXDtor( + vtable_component.getDestructorDecl(), + clang::CXXDtorType::Dtor_Complete, ostream); + ostream.flush(); + break; case clang::VTableComponent::CK_DeletingDtorPointer: kind = abi_dump::VTableComponent_Kind_DeletingDtorPointer; + mangle_contextp_->mangleCXXDtor( + vtable_component.getDestructorDecl(), + clang::CXXDtorType::Dtor_Deleting, ostream); + ostream.flush(); + break; case clang::VTableComponent::CK_UnusedFunctionPointer: kind = abi_dump::VTableComponent_Kind_UnusedFunctionPointer; default: @@ -478,16 +515,17 @@ bool RecordDeclWrapper::SetupTemplateInfo( bool RecordDeclWrapper::SetupRecordInfo(abi_dump::RecordDecl *record_declp, const std::string &source_file) const { std::string qualified_name = GetTagDeclQualifiedName(record_decl_); - std::string mangled_name = GetMangledNameDecl(record_decl_); const clang::Type *basic_type = nullptr; if (!(basic_type = record_decl_->getTypeForDecl())) { return false; } + std::string mangled_name = ABIWrapper::GetTypeLinkageName(basic_type); clang::QualType type = basic_type->getCanonicalTypeInternal(); std::string linker_key = (mangled_name == "") ? qualified_name : mangled_name; if (!SetupBasicNamedAndTypedDecl(record_declp->mutable_basic_abi(), type, qualified_name, - record_decl_->getAccess(), linker_key)) { + record_decl_->getAccess(), linker_key, + true)) { return false; } record_declp->set_mangled_record_name(mangled_name); @@ -538,7 +576,7 @@ bool EnumDeclWrapper::SetupEnumFields(abi_dump::EnumDecl *enump) const { !SetupBasicNamedAndTypedDecl(enum_fieldp->mutable_basic_abi(), enum_it->getType(), name, enum_it->getAccess(), - std::to_string(field_value))) { + std::to_string(field_value), true)) { return false; } enum_fieldp->set_enum_field_value(field_value); @@ -550,11 +588,10 @@ bool EnumDeclWrapper::SetupEnumFields(abi_dump::EnumDecl *enump) const { bool EnumDeclWrapper::SetupEnum(abi_dump::EnumDecl *enump, const std::string &source_file) const { std::string enum_name = GetTagDeclQualifiedName(enum_decl_); - std::string enum_mangled_name = GetMangledNameDecl(enum_decl_); clang::QualType enum_type = enum_decl_->getIntegerType(); if (!SetupBasicNamedAndTypedDecl(enump->mutable_basic_abi(), enum_type, enum_name, enum_decl_->getAccess(), - enum_mangled_name) || + enum_name, true) || !SetupEnumFields(enump)) { return false; } @@ -587,13 +624,12 @@ bool GlobalVarDeclWrapper::SetupGlobalVar( // Temporary fix : clang segfaults on trying to mangle global variable which // is a dependent sized array type. std::string qualified_name = global_var_decl_->getQualifiedNameAsString(); - std::string mangled_or_qualified_name = - global_var_decl_->getType()->isDependentSizedArrayType() ? - qualified_name : GetMangledNameDecl(global_var_decl_); + std::string mangled_name = + GetMangledNameDecl(global_var_decl_, mangle_contextp_); if (!SetupBasicNamedAndTypedDecl( global_varp->mutable_basic_abi(),global_var_decl_->getType(), qualified_name, global_var_decl_->getAccess(), - mangled_or_qualified_name)) { + mangled_name, true)) { return false; } global_varp->set_source_file(source_file); 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 88ea4335d..262c9cfdc 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 @@ -37,12 +37,12 @@ class ABIWrapper { static std::string GetDeclSourceFile(const clang::Decl *decl, const clang::CompilerInstance *cip); + static std::string GetMangledNameDecl(const clang::NamedDecl *decl, + clang::MangleContext *mangle_context); protected: abi_dump::AccessSpecifier AccessClangToDump( const clang::AccessSpecifier sp) const; - std::string GetMangledNameDecl(const clang::NamedDecl *decl) const; - bool SetupTemplateParamNames(abi_dump::TemplateInfo *tinfo, clang::TemplateParameterList *pl) const; @@ -54,12 +54,15 @@ class ABIWrapper { std::string GetTagDeclQualifiedName(const clang::TagDecl *decl) const; bool SetupBasicTypeAbi(abi_dump::BasicTypeAbi *type_abi, - const clang::QualType type) const; + const clang::QualType type, bool dump_size) const; bool SetupBasicNamedAndTypedDecl( abi_dump::BasicNamedAndTypedDecl *basic_named_and_typed_decl, const clang::QualType type, const std::string &name, - const clang::AccessSpecifier &access, std::string key) const; + const clang::AccessSpecifier &access, std::string key, + bool dump_size) const; + + std::string GetTypeLinkageName(const clang::Type *typep) const; protected: const clang::CompilerInstance *cip_; 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 be370c425..66b3e9dec 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 @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -49,7 +50,8 @@ HeaderASTVisitor::HeaderASTVisitor( bool HeaderASTVisitor::VisitRecordDecl(const clang::RecordDecl *decl) { // Skip forward declaration. - if (!decl->isThisDeclarationADefinition()) { + if (!decl->isThisDeclarationADefinition() || + decl->getTypeForDecl()->isDependentType()) { return true; } RecordDeclWrapper record_decl_wrapper( @@ -69,7 +71,8 @@ bool HeaderASTVisitor::VisitRecordDecl(const clang::RecordDecl *decl) { } bool HeaderASTVisitor::VisitEnumDecl(const clang::EnumDecl *decl) { - if (!decl->isThisDeclarationADefinition()) { + if (!decl->isThisDeclarationADefinition() || + decl->getTypeForDecl()->isDependentType()) { return true; } EnumDeclWrapper enum_decl_wrapper( @@ -88,7 +91,53 @@ bool HeaderASTVisitor::VisitEnumDecl(const clang::EnumDecl *decl) { return true; } +static bool MutateFunctionWithLinkageName(abi_dump::TranslationUnit *tu_ptr, + const abi_dump::FunctionDecl *fd, + std::string &linkage_name) { + abi_dump::FunctionDecl *added_function_declp = tu_ptr->add_functions(); + if (!added_function_declp) { + return false; + } + *added_function_declp = *fd; + added_function_declp->set_mangled_function_name(linkage_name); + assert(added_function_declp->mutable_basic_abi() != nullptr); + added_function_declp->mutable_basic_abi()->set_linker_set_key(linkage_name); + return true; +} + +static bool AddMangledFunctions(abi_dump::TranslationUnit *tu_ptr, + const abi_dump::FunctionDecl *fd, + std::vector &manglings) { + for (auto &&mangling : manglings) { + if (!MutateFunctionWithLinkageName(tu_ptr, fd, mangling)) { + return false; + } + } + return true; +} + +static bool ShouldSkipFunctionDecl(const clang::FunctionDecl *decl) { + if (const clang::CXXMethodDecl *method_decl = + llvm::dyn_cast(decl)) { + if (method_decl->getParent()->getTypeForDecl()->isDependentType()) { + return true; + } + } + clang::FunctionDecl::TemplatedKind tkind = decl->getTemplatedKind(); + switch (tkind) { + case clang::FunctionDecl::TK_NonTemplate: + case clang::FunctionDecl::TK_FunctionTemplateSpecialization: + case clang::FunctionDecl::TK_MemberSpecialization: + return false; + default: + return true; + } +} + bool HeaderASTVisitor::VisitFunctionDecl(const clang::FunctionDecl *decl) { + if (ShouldSkipFunctionDecl(decl)) { + return true; + } FunctionDeclWrapper function_decl_wrapper(mangle_contextp_, ast_contextp_, cip_, decl); std::unique_ptr wrapped_function_decl = @@ -97,16 +146,22 @@ bool HeaderASTVisitor::VisitFunctionDecl(const clang::FunctionDecl *decl) { llvm::errs() << "Getting Function Decl failed\n"; return false; } - abi_dump::FunctionDecl *added_function_declp = tu_ptr_->add_functions(); - if (!added_function_declp) { - return false; + // Destructors and Constructors can have more than 1 symbol generated from the + // same Decl. + clang::index::CodegenNameGenerator cg(*ast_contextp_); + std::vector manglings = cg.getAllManglings(decl); + if (!manglings.empty()) { + return AddMangledFunctions(tu_ptr_, wrapped_function_decl.get(), manglings); } - *added_function_declp = *wrapped_function_decl; - return true; + std::string linkage_name = + ABIWrapper::GetMangledNameDecl(decl, mangle_contextp_); + return MutateFunctionWithLinkageName(tu_ptr_, wrapped_function_decl.get(), + linkage_name); } bool HeaderASTVisitor::VisitVarDecl(const clang::VarDecl *decl) { - if(!decl->hasGlobalStorage()) { + if(!decl->hasGlobalStorage()|| + decl->getType().getTypePtr()->isDependentType()) { // Non global / static variable declarations don't need to be dumped. return true; } 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 f050a5c23..96616d1ce 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 @@ -65,18 +65,23 @@ static llvm::cl::opt no_filter( "no-filter", llvm::cl::desc("Do not filter any abi"), llvm::cl::Optional, llvm::cl::cat(header_linker_category)); +static llvm::cl::opt so_file( + "so", llvm::cl::desc(""), llvm::cl::Optional, + llvm::cl::cat(header_linker_category)); + class HeaderAbiLinker { public: HeaderAbiLinker( const std::vector &dump_files, const std::vector &exported_header_dirs, const std::string &version_script, + const std::string &so_file, 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), out_dump_name_(linked_dump), arch_(arch), - api_(api) {}; + version_script_(version_script), so_file_(so_file), + out_dump_name_(linked_dump), arch_(arch), api_(api) {}; bool LinkAndDump(); @@ -103,10 +108,13 @@ class HeaderAbiLinker { bool ParseVersionScriptFiles(); + bool ParseSoFile(); + private: const std::vector &dump_files_; const std::vector &exported_header_dirs_; const std::string &version_script_; + const std::string &so_file_; const std::string &out_dump_name_; const std::string &arch_; const std::string &api_; @@ -132,6 +140,10 @@ bool HeaderAbiLinker::LinkAndDump() { if (version_script.empty()) { exported_headers_ = abi_util::CollectAllExportedHeaders(exported_header_dirs_); + if (!ParseSoFile()) { + llvm::errs() << "Couldn't parse so file\n"; + return false; + } } else if (!ParseVersionScriptFiles()) { llvm::errs() << "Failed to parse stub files for exported symbols\n"; return false; @@ -265,7 +277,8 @@ bool HeaderAbiLinker::LinkFunctions(const abi_dump::TranslationUnit &dump_tu, assert(linked_tu != nullptr); return LinkDecl(linked_tu->mutable_functions(), &function_decl_set_, &functions_regex_matched_set, &functions_vs_regex_, - dump_tu.functions(), (!version_script_.empty())); + dump_tu.functions(), + (!version_script_.empty() || !so_file_.empty())); } bool HeaderAbiLinker::LinkEnums(const abi_dump::TranslationUnit &dump_tu, @@ -282,7 +295,8 @@ bool HeaderAbiLinker::LinkGlobalVars(const abi_dump::TranslationUnit &dump_tu, assert(linked_tu != nullptr); return LinkDecl(linked_tu->mutable_global_vars(), &globvar_decl_set_, &globvars_regex_matched_set, &globvars_vs_regex_, - dump_tu.global_vars(), (!version_script.empty())); + dump_tu.global_vars(), + (!version_script.empty() || !so_file_.empty())); } bool HeaderAbiLinker::ParseVersionScriptFiles() { @@ -302,14 +316,41 @@ bool HeaderAbiLinker::ParseVersionScriptFiles() { return true; } +bool HeaderAbiLinker::ParseSoFile() { + auto Binary = llvm::object::createBinary(so_file_); + + if (!Binary) { + llvm::errs() << "Couldn't really create object File \n"; + return false; + } + llvm::object::ObjectFile *objfile = + llvm::dyn_cast(&(*Binary.get().getBinary())); + if (!objfile) { + llvm::errs() << "Not an object file\n"; + return false; + } + + std::unique_ptr so_parser = + abi_util::SoFileParser::Create(objfile); + if (so_parser == nullptr) { + llvm::errs() << "Couldn't create soFile Parser\n"; + return false; + } + so_parser->GetSymbols(); + function_decl_set_ = so_parser->GetFunctions(); + globvar_decl_set_ = so_parser->GetGlobVars(); + return true; +} + int main(int argc, const char **argv) { GOOGLE_PROTOBUF_VERIFY_VERSION; llvm::cl::ParseCommandLineOptions(argc, argv, "header-linker"); if (no_filter) { static_cast &>(exported_header_dirs).clear(); } - HeaderAbiLinker Linker(dump_files, exported_header_dirs, - version_script, linked_dump, arch, api); + HeaderAbiLinker Linker(dump_files, exported_header_dirs, version_script, + so_file, linked_dump, arch, api); + if (!Linker.LinkAndDump()) { return -1; } 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 9ce7af1c2..b335cdd6c 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,11 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include +#include +#include +#include + #include #include #include #include +using llvm::object::ObjectFile; +using llvm::object::ELFObjectFile; +using llvm::object::ELFFile; +using llvm::object::ELFType; +using llvm::object::ELFDataTypeTypedefHelper; + namespace abi_util { std::set CollectAllExportedHeaders( @@ -83,4 +95,37 @@ 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::set &GetFunctions() const = 0; + virtual const std::set &GetGlobVars() const = 0; + virtual ~SoFileParser() {}; + virtual void GetSymbols() = 0; +}; + +template +class ELFSoFileParser : public SoFileParser { + public: + const std::set &GetFunctions() const override; + + const std::set &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::set functions_; + std::set globvars_; + + private: + bool IsSymbolExported(const Elf_Sym *elf_sym) const; +}; + } // namespace abi_util 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 new file mode 100644 index 000000000..14a90a280 --- /dev/null +++ b/vndk/tools/header-checker/header-abi-util/src/so_file_parser.cpp @@ -0,0 +1,118 @@ +// Copyright (C) 2017 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 + +#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::STV_DEFAULT; +using llvm::ELF::STV_PROTECTED; +using llvm::ELF::STB_WEAK; +using llvm::ELF::STB_GLOBAL; + +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()); +} + +template +const std::set &ELFSoFileParser::GetFunctions() const { + return functions_; +} + +template +const std::set &ELFSoFileParser::GetGlobVars() const { + return globvars_; +} + +template +bool ELFSoFileParser::IsSymbolExported(const Elf_Sym *elf_sym) const { + + unsigned char visibility = elf_sym->getVisibility(); + unsigned char binding = elf_sym->getBinding(); + + return (binding == STB_GLOBAL || binding == STB_WEAK) && + (visibility == STV_DEFAULT || + visibility == STV_PROTECTED); +} + +template +void ELFSoFileParser::GetSymbols() { + assert(obj_ != nullptr); + for (auto symbol_it : obj_->symbols()) { + const Elf_Sym *elf_sym = + obj_->getSymbol(symbol_it.getRawDataRefImpl()); + assert (elf_sym != nullptr); + if (!IsSymbolExported(elf_sym) || elf_sym->isUndefined()) { + continue; + } + llvm::object::SymbolRef::Type type = UnWrap(symbol_it.getType()); + std::string symbol_name = UnWrap(symbol_it.getName()); + if (type == llvm::object::SymbolRef::Type::ST_Function) { + functions_.insert(symbol_name); + } else if (type == llvm::object::SymbolRef::Type::ST_Data) { + globvars_.insert(symbol_name); + } + } +} + +template +static std::unique_ptr CreateELFSoFileParser( + const llvm::object::ELFObjectFile *elfo) { + return llvm::make_unique>(elfo); +} + +std::unique_ptr SoFileParser::Create( + const llvm::object::ObjectFile *objfile) { + // Little-endian 32-bit + if (const ELF32LEObjectFile *ELFObj = dyn_cast(objfile)) { + return CreateELFSoFileParser(ELFObj); + } + + // Big-endian 32-bit + if (const ELF32BEObjectFile *ELFObj = dyn_cast(objfile)) { + return CreateELFSoFileParser(ELFObj); + } + + // Little-endian 64-bit + if (const ELF64LEObjectFile *ELFObj = dyn_cast(objfile)) { + return CreateELFSoFileParser(ELFObj); + } + + // Big-endian 64-bit + if (const ELF64BEObjectFile *ELFObj = dyn_cast(objfile)) { + return CreateELFSoFileParser(ELFObj); + } + return nullptr; +} + +} // namespace abi_util + diff --git a/vndk/tools/header-checker/proto/abi_dump.proto b/vndk/tools/header-checker/proto/abi_dump.proto index 77c610bce..0f43d9e6a 100644 --- a/vndk/tools/header-checker/proto/abi_dump.proto +++ b/vndk/tools/header-checker/proto/abi_dump.proto @@ -79,7 +79,7 @@ message VTableComponent { } optional Kind kind = 1; optional string mangled_component_name = 2 [default = ""]; - optional uint64 value = 3 [default = 0]; + optional int64 value = 3 [default = 0]; } message VTableLayout { diff --git a/vndk/tools/header-checker/tests/expected/example1.h b/vndk/tools/header-checker/tests/expected/example1.h index 971741d9e..6503af2b7 100644 --- a/vndk/tools/header-checker/tests/expected/example1.h +++ b/vndk/tools/header-checker/tests/expected/example1.h @@ -1,133 +1,795 @@ -classes { - fields { - field_name: "foo" - field_type: "int" - access: "public" +records { + basic_abi { + type_abi { + name: "HiddenBase" + size: 8 + alignment: 4 + } + name: "HiddenBase" + access: public_access + linker_set_key: "HiddenBase" } fields { - field_name: "bar" - field_type: "int" - access: "public" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "hide" + access: private_access + } } - fully_qualified_name: "Hello" - source_file: "./input/example1.h" - access: "public" + fields { + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "seek" + access: private_access + } + } + source_file: "./input/example3.h" + mangled_record_name: "HiddenBase" } -classes { - fields { - field_name: "cpp_foo" - field_type: "const int" - access: "public" +records { + basic_abi { + type_abi { + name: "test2::HelloAgain" + size: 40 + alignment: 8 + } + name: "test2::HelloAgain" + access: public_access + linker_set_key: "test2::HelloAgain" } fields { - field_name: "cpp_bar" - field_type: "const float" - access: "public" + basic_abi { + type_abi { + name: "std::vector >" + size: 24 + alignment: 8 + } + name: "foo_again" + access: public_access + } + } + fields { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "bar_again" + access: public_access + } + } + source_file: "./input/example2.h" + mangled_record_name: "test2::HelloAgain" + vtable_layout { + vtable_components { + kind: OffsetToTop + mangled_component_name: "" + value: 0 + } + vtable_components { + kind: RTTI + mangled_component_name: "test2::HelloAgain" + value: 0 + } + vtable_components { + kind: FunctionPointer + mangled_component_name: "_ZN5test210HelloAgain5againEv" + value: 0 + } + } +} +records { + basic_abi { + type_abi { + name: "test3::ByeAgain" + size: 16 + alignment: 8 + } + name: "test3::ByeAgain" + access: public_access + linker_set_key: "test3::ByeAgain" + } + fields { + basic_abi { + type_abi { + name: "double" + size: 8 + alignment: 8 + } + name: "foo_again" + access: public_access + } + } + fields { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "bar_again" + access: public_access + } + } + source_file: "./input/example2.h" + template_info { + elements { + basic_abi { + type_abi { + name: "double" + } + linker_set_key: "double" + } + } + } + mangled_record_name: "test3::ByeAgain" +} +records { + basic_abi { + type_abi { + name: "test3::ByeAgain" + size: 8 + alignment: 4 + } + name: "test3::ByeAgain" + access: public_access + linker_set_key: "test3::ByeAgain" + } + fields { + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "foo_again" + access: public_access + } + } + fields { + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "bar_Again" + access: public_access + } + } + source_file: "./input/example2.h" + template_info { + elements { + basic_abi { + type_abi { + name: "float" + } + linker_set_key: "float" + } + } + } + mangled_record_name: "test3::ByeAgain" +} +records { + basic_abi { + type_abi { + name: "test3::Outer" + size: 4 + alignment: 4 + } + name: "test3::Outer" + access: public_access + linker_set_key: "test3::Outer" + } + fields { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "a" + access: public_access + } + } + source_file: "./input/example2.h" + mangled_record_name: "test3::Outer" +} +records { + basic_abi { + type_abi { + name: "test3::Outer::Inner" + size: 4 + alignment: 4 + } + name: "test3::Outer::Inner" + access: private_access + linker_set_key: "test3::Outer::Inner" + } + fields { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "b" + access: private_access + } + } + source_file: "./input/example2.h" + mangled_record_name: "test3::Outer::Inner" +} +records { + basic_abi { + type_abi { + name: "Hello" + size: 8 + alignment: 4 + } + name: "Hello" + access: public_access + linker_set_key: "Hello" + } + fields { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "foo" + access: public_access + } + } + fields { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "bar" + access: public_access + } + } + source_file: "./input/example1.h" + mangled_record_name: "Hello" +} +records { + basic_abi { + type_abi { + name: "CPPHello" + size: 56 + alignment: 8 + } + name: "CPPHello" + access: public_access + linker_set_key: "CPPHello" + } + fields { + basic_abi { + type_abi { + name: "const int" + size: 4 + alignment: 4 + } + name: "cpp_foo" + access: public_access + } + } + fields { + basic_abi { + type_abi { + name: "const float" + size: 4 + alignment: 4 + } + name: "cpp_bar" + access: public_access + } } base_specifiers { - fully_qualified_name: "test2::HelloAgain" - access: "private" + basic_abi { + type_abi { + name: "test2::HelloAgain" + } + name: "" + access: private_access + } is_virtual: false } base_specifiers { - fully_qualified_name: "test3::ByeAgain" - access: "public" + basic_abi { + type_abi { + name: "test3::ByeAgain" + } + name: "" + access: public_access + } is_virtual: false } - fully_qualified_name: "CPPHello" source_file: "./input/example1.h" - access: "public" + mangled_record_name: "CPPHello" + vtable_layout { + vtable_components { + kind: OffsetToTop + mangled_component_name: "" + value: 0 + } + vtable_components { + kind: RTTI + mangled_component_name: "CPPHello" + value: 0 + } + vtable_components { + kind: FunctionPointer + mangled_component_name: "_ZN8CPPHello5againEv" + value: 0 + } + } } -classes { - fields { - field_name: "value_" - field_type: "T" - access: "public" +records { + basic_abi { + type_abi { + name: "List" + size: 8 + alignment: 8 + } + name: "List" + access: public_access + linker_set_key: "List" } fields { - field_name: "next_" - field_type: "StackNode *" - access: "public" + basic_abi { + type_abi { + name: "List::_Node *" + size: 8 + alignment: 8 + } + name: "middle" + access: protected_access + } } - fully_qualified_name: "StackNode" source_file: "./input/example1.h" - access: "public" + template_info { + elements { + basic_abi { + type_abi { + name: "float" + } + linker_set_key: "float" + } + } + } + mangled_record_name: "List" } -classes { - fields { - field_name: "head_" - field_type: "StackNode *" - access: "private" +records { + basic_abi { + type_abi { + name: "List" + size: 8 + alignment: 8 + } + name: "List" + access: public_access + linker_set_key: "List" + } + fields { + basic_abi { + type_abi { + name: "List::_Node *" + size: 8 + alignment: 8 + } + name: "middle" + access: protected_access + } } - fully_qualified_name: "Stack" source_file: "./input/example1.h" - access: "public" + template_info { + elements { + basic_abi { + type_abi { + name: "int" + } + linker_set_key: "int" + } + } + } + mangled_record_name: "List" } functions { - function_name: "CPPHello::CPPHello" - mangled_function_name: "_ZN8CPPHelloC1Ev" - source_file: "./input/example1.h" - return_type: "void" - access: "public" - template_kind: 0 + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "test2::HelloAgain::again" + access: public_access + linker_set_key: "_ZN5test210HelloAgain5againEv" + } + mangled_function_name: "_ZN5test210HelloAgain5againEv" + source_file: "./input/example2.h" } functions { - function_name: "StackNode::StackNode" - mangled_function_name: "_ZN9StackNodeC1ET_P9StackNodeIS0_E" - source_file: "./input/example1.h" + basic_abi { + type_abi { + name: "double" + size: 8 + alignment: 8 + } + name: "test3::ByeAgain::method_foo" + access: public_access + linker_set_key: "_ZN5test38ByeAgainIdE10method_fooEd" + } + mangled_function_name: "_ZN5test38ByeAgainIdE10method_fooEd" + source_file: "./input/example2.h" parameters { - field_name: "t" - field_type: "T" + basic_abi { + type_abi { + name: "double" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } + default_arg: false + } +} +functions { + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "test3::ByeAgain::method_foo" + access: public_access + linker_set_key: "_ZN5test38ByeAgainIfE10method_fooEi" + } + mangled_function_name: "_ZN5test38ByeAgainIfE10method_fooEi" + source_file: "./input/example2.h" + parameters { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } + default_arg: false + } +} +functions { + basic_abi { + type_abi { + name: "bool" + size: 1 + alignment: 1 + } + name: "test3::Begin" + access: public_access + linker_set_key: "_ZN5test35BeginIfiEEbT_T0_i" + } + mangled_function_name: "_ZN5test35BeginIfiEEbT_T0_i" + source_file: "./input/example2.h" + parameters { + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "arg1" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "next" - field_type: "StackNode *" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "arg2" + access: public_access + linker_set_key: "false" + } + default_arg: false + } + parameters { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "c" + access: public_access + linker_set_key: "false" + } + default_arg: false + } + template_info { + elements { + basic_abi { + type_abi { + name: "float" + } + linker_set_key: "float" + } + } + elements { + basic_abi { + type_abi { + name: "int" + } + linker_set_key: "int" + } + } + } +} +functions { + basic_abi { + type_abi { + name: "bool" + size: 1 + alignment: 1 + } + name: "test3::End" + access: public_access + linker_set_key: "_ZN5test33EndEf" + } + mangled_function_name: "_ZN5test33EndEf" + source_file: "./input/example2.h" + parameters { + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "arg" + access: public_access + linker_set_key: "true" + } default_arg: true } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "Stack::Stack" - mangled_function_name: "_ZN5StackC1Ev" - source_file: "./input/example1.h" - return_type: "void" - access: "public" - template_kind: 0 -} -functions { - function_name: "Stack::push" - mangled_function_name: "push_ZN5Stack4pushET_" - source_file: "./input/example1.h" + basic_abi { + type_abi { + name: "std::vector >" + } + name: "test3::Dummy" + access: public_access + linker_set_key: "_ZN5test35DummyEi" + } + mangled_function_name: "_ZN5test35DummyEi" + source_file: "./input/example2.h" parameters { - field_name: "t" - field_type: "T" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "t" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "Stack::pop" - mangled_function_name: "pop_ZN5Stack3popEv" - source_file: "./input/example1.h" - return_type: "T" - access: "public" - template_kind: 0 -} -functions { - function_name: "Global_Foo" - mangled_function_name: "Global_Foo_Z10Global_Fooi" - source_file: "./input/example1.h" - parameters { - field_name: "global_bar" - field_type: "int" - default_arg: false + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "CPPHello::again" + access: public_access + linker_set_key: "_ZN8CPPHello5againEv" } - return_type: "const volatile int" - access: "public" - template_kind: 0 + mangled_function_name: "_ZN8CPPHello5againEv" + source_file: "./input/example1.h" +} +functions { + basic_abi { + type_abi { + name: "void" + } + name: "CPPHello::CPPHello" + access: public_access + linker_set_key: "_ZN8CPPHelloC2Ev" + } + mangled_function_name: "_ZN8CPPHelloC2Ev" + source_file: "./input/example1.h" +} +functions { + basic_abi { + type_abi { + name: "void" + } + name: "CPPHello::CPPHello" + access: public_access + linker_set_key: "_ZN8CPPHelloC1Ev" + } + mangled_function_name: "_ZN8CPPHelloC1Ev" + source_file: "./input/example1.h" +} +enums { + basic_abi { + type_abi { + name: "unsigned int" + size: 4 + alignment: 4 + } + name: "Foo_s" + access: public_access + linker_set_key: "Foo_s" + } + enum_fields { + basic_abi { + type_abi { + name: "Foo_s" + size: 4 + alignment: 4 + } + name: "Foo_s::foosball" + access: public_access + linker_set_key: "10" + } + enum_field_value: 10 + } + enum_fields { + basic_abi { + type_abi { + name: "Foo_s" + size: 4 + alignment: 4 + } + name: "Foo_s::foosbat" + access: public_access + linker_set_key: "11" + } + enum_field_value: 11 + } + source_file: "./input/example2.h" +} +enums { + basic_abi { + type_abi { + name: "unsigned int" + size: 4 + alignment: 4 + } + name: "test3::Kind" + access: public_access + linker_set_key: "test3::Kind" + } + enum_fields { + basic_abi { + type_abi { + name: "test3::Kind" + size: 4 + alignment: 4 + } + name: "test3::Kind::kind1" + access: public_access + linker_set_key: "24" + } + enum_field_value: 24 + } + enum_fields { + basic_abi { + type_abi { + name: "test3::Kind" + size: 4 + alignment: 4 + } + name: "test3::Kind::kind2" + access: public_access + linker_set_key: "2312" + } + enum_field_value: 2312 + } + source_file: "./input/example2.h" +} +global_vars { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "test2::HelloAgain::hello_forever" + access: public_access + linker_set_key: "_ZN5test210HelloAgain13hello_foreverE" + } + source_file: "./input/example2.h" +} +global_vars { + basic_abi { + type_abi { + name: "bool const[2]" + size: 2 + alignment: 1 + } + name: "__test_var" + access: public_access + linker_set_key: "_ZL10__test_var" + } + source_file: "./input/example2.h" +} +global_vars { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "test3::ByeAgain::foo_forever" + access: public_access + linker_set_key: "_ZN5test38ByeAgainIfE11foo_foreverE" + } + source_file: "./input/example2.h" +} +global_vars { + basic_abi { + type_abi { + name: "test3::ByeAgain" + size: 16 + alignment: 8 + } + name: "test3::double_bye" + access: public_access + linker_set_key: "_ZN5test310double_byeE" + } + source_file: "./input/example2.h" +} +global_vars { + basic_abi { + type_abi { + name: "List" + size: 8 + alignment: 8 + } + name: "float_list_test" + access: public_access + linker_set_key: "float_list_test" + } + source_file: "./input/example1.h" +} +global_vars { + basic_abi { + type_abi { + name: "List" + size: 8 + alignment: 8 + } + name: "int_list_test" + access: public_access + linker_set_key: "int_list_test" + } + source_file: "./input/example1.h" } diff --git a/vndk/tools/header-checker/tests/expected/example2.h b/vndk/tools/header-checker/tests/expected/example2.h index 37a6380ba..2b1c9720e 100644 --- a/vndk/tools/header-checker/tests/expected/example2.h +++ b/vndk/tools/header-checker/tests/expected/example2.h @@ -1,244 +1,552 @@ -classes { - fields { - field_name: "foo_again" - field_type: "std::unique_ptr >" - access: "public" +records { + basic_abi { + type_abi { + name: "HiddenBase" + size: 8 + alignment: 4 + } + name: "HiddenBase" + access: public_access + linker_set_key: "HiddenBase" } fields { - field_name: "bar_again" - field_type: "int" - access: "public" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "hide" + access: private_access + } } - fully_qualified_name: "test2::HelloAgain" - source_file: "./input/example2.h" - access: "public" + fields { + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "seek" + access: private_access + } + } + source_file: "./input/example3.h" + mangled_record_name: "HiddenBase" } -classes { - fields { - field_name: "foo_again" - field_type: "T" - access: "public" +records { + basic_abi { + type_abi { + name: "test2::HelloAgain" + size: 40 + alignment: 8 + } + name: "test2::HelloAgain" + access: public_access + linker_set_key: "test2::HelloAgain" } fields { - field_name: "bar_again" - field_type: "int" - access: "public" + basic_abi { + type_abi { + name: "std::vector >" + size: 24 + alignment: 8 + } + name: "foo_again" + access: public_access + } + } + fields { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "bar_again" + access: public_access + } } - fully_qualified_name: "test3::ByeAgain" source_file: "./input/example2.h" - access: "public" + mangled_record_name: "test2::HelloAgain" + vtable_layout { + vtable_components { + kind: OffsetToTop + mangled_component_name: "" + value: 0 + } + vtable_components { + kind: RTTI + mangled_component_name: "test2::HelloAgain" + value: 0 + } + vtable_components { + kind: FunctionPointer + mangled_component_name: "_ZN5test210HelloAgain5againEv" + value: 0 + } + } } -classes { - fields { - field_name: "foo_again" - field_type: "double" - access: "public" +records { + basic_abi { + type_abi { + name: "test3::ByeAgain" + size: 16 + alignment: 8 + } + name: "test3::ByeAgain" + access: public_access + linker_set_key: "test3::ByeAgain" } fields { - field_name: "bar_again" - field_type: "int" - access: "public" + basic_abi { + type_abi { + name: "double" + size: 8 + alignment: 8 + } + name: "foo_again" + access: public_access + } + } + fields { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "bar_again" + access: public_access + } } - fully_qualified_name: "test3::ByeAgain" source_file: "./input/example2.h" template_info { - template_parameters { - field_type: "double" + elements { + basic_abi { + type_abi { + name: "double" + } + linker_set_key: "double" + } } } - access: "public" + mangled_record_name: "test3::ByeAgain" } -classes { - fields { - field_name: "foo_again" - field_type: "float" - access: "public" +records { + basic_abi { + type_abi { + name: "test3::ByeAgain" + size: 8 + alignment: 4 + } + name: "test3::ByeAgain" + access: public_access + linker_set_key: "test3::ByeAgain" } fields { - field_name: "bar_Again" - field_type: "float" - access: "public" - } - fully_qualified_name: "test3::ByeAgain" - source_file: "./input/example2.h" - template_info { - template_parameters { - field_type: "float" + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "foo_again" + access: public_access } } - access: "public" -} -classes { fields { - field_name: "a" - field_type: "int" - access: "public" + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "bar_Again" + access: public_access + } } - fully_qualified_name: "test3::Outer" source_file: "./input/example2.h" - access: "public" + template_info { + elements { + basic_abi { + type_abi { + name: "float" + } + linker_set_key: "float" + } + } + } + mangled_record_name: "test3::ByeAgain" } -classes { +records { + basic_abi { + type_abi { + name: "test3::Outer" + size: 4 + alignment: 4 + } + name: "test3::Outer" + access: public_access + linker_set_key: "test3::Outer" + } fields { - field_name: "b" - field_type: "int" - access: "private" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "a" + access: public_access + } } - fully_qualified_name: "test3::Outer::Inner" source_file: "./input/example2.h" - access: "private" + mangled_record_name: "test3::Outer" +} +records { + basic_abi { + type_abi { + name: "test3::Outer::Inner" + size: 4 + alignment: 4 + } + name: "test3::Outer::Inner" + access: private_access + linker_set_key: "test3::Outer::Inner" + } + fields { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "b" + access: private_access + } + } + source_file: "./input/example2.h" + mangled_record_name: "test3::Outer::Inner" } functions { - function_name: "test3::ByeAgain::method_foo" - mangled_function_name: "method_foo_ZN5test38ByeAgain10method_fooET_" - source_file: "./input/example2.h" - parameters { - field_name: "" - field_type: "T" - default_arg: false + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "test2::HelloAgain::again" + access: public_access + linker_set_key: "_ZN5test210HelloAgain5againEv" } - return_type: "T" - access: "public" - template_kind: 0 + mangled_function_name: "_ZN5test210HelloAgain5againEv" + source_file: "./input/example2.h" } functions { - function_name: "test3::ByeAgain::method_foo" - mangled_function_name: "method_foo_ZN5test38ByeAgainIdE10method_fooEd" + basic_abi { + type_abi { + name: "double" + size: 8 + alignment: 8 + } + name: "test3::ByeAgain::method_foo" + access: public_access + linker_set_key: "_ZN5test38ByeAgainIdE10method_fooEd" + } + mangled_function_name: "_ZN5test38ByeAgainIdE10method_fooEd" source_file: "./input/example2.h" parameters { - field_name: "" - field_type: "double" + basic_abi { + type_abi { + name: "double" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "double" - access: "public" - template_kind: 2 } functions { - function_name: "test3::ByeAgain::method_foo" - mangled_function_name: "method_foo_ZN5test38ByeAgainIfE10method_fooEi" + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "test3::ByeAgain::method_foo" + access: public_access + linker_set_key: "_ZN5test38ByeAgainIfE10method_fooEi" + } + mangled_function_name: "_ZN5test38ByeAgainIfE10method_fooEi" source_file: "./input/example2.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "float" - access: "public" - template_kind: 0 } functions { - function_name: "test3::Begin" - mangled_function_name: "Begin_ZN5test35BeginET_T0_" + basic_abi { + type_abi { + name: "bool" + size: 1 + alignment: 1 + } + name: "test3::Begin" + access: public_access + linker_set_key: "_ZN5test35BeginIfiEEbT_T0_i" + } + mangled_function_name: "_ZN5test35BeginIfiEEbT_T0_i" source_file: "./input/example2.h" parameters { - field_name: "arg1" - field_type: "T1" + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "arg1" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "arg2" - field_type: "T2" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "arg2" + access: public_access + linker_set_key: "false" + } + default_arg: false + } + parameters { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "c" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "bool" - access: "public" - template_kind: 1 template_info { - template_parameters { - field_name: "T1" + elements { + basic_abi { + type_abi { + name: "float" + } + linker_set_key: "float" + } } - template_parameters { - field_name: "T2" + elements { + basic_abi { + type_abi { + name: "int" + } + linker_set_key: "int" + } } } } functions { - function_name: "test3::Begin" - mangled_function_name: "Begin_ZN5test35BeginIfiEEbT_T0_" + basic_abi { + type_abi { + name: "bool" + size: 1 + alignment: 1 + } + name: "test3::End" + access: public_access + linker_set_key: "_ZN5test33EndEf" + } + mangled_function_name: "_ZN5test33EndEf" source_file: "./input/example2.h" parameters { - field_name: "arg1" - field_type: "float" - default_arg: false - } - parameters { - field_name: "arg2" - field_type: "int" - default_arg: false - } - return_type: "bool" - access: "public" - template_kind: 3 - template_info { - template_parameters { - field_type: "float" + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "arg" + access: public_access + linker_set_key: "true" } - template_parameters { - field_type: "int" - } - } -} -functions { - function_name: "test3::Begin" - mangled_function_name: "Begin_ZN5test35BeginIifEEbT_T0_" - source_file: "./input/example2.h" - parameters { - field_name: "a" - field_type: "int" - default_arg: false - } - parameters { - field_name: "b" - field_type: "float" - default_arg: false - } - return_type: "bool" - access: "public" - template_kind: 3 - template_info { - template_parameters { - field_type: "int" - } - template_parameters { - field_type: "float" - } - } -} -functions { - function_name: "test3::End" - mangled_function_name: "End_ZN5test33EndEf" - source_file: "./input/example2.h" - parameters { - field_name: "arg" - field_type: "float" default_arg: true } - return_type: "bool" - access: "public" - template_kind: 0 +} +functions { + basic_abi { + type_abi { + name: "std::vector >" + } + name: "test3::Dummy" + access: public_access + linker_set_key: "_ZN5test35DummyEi" + } + mangled_function_name: "_ZN5test35DummyEi" + source_file: "./input/example2.h" + parameters { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "t" + access: public_access + linker_set_key: "false" + } + default_arg: false + } } enums { - enum_name: "Foo_s" - enum_type: "unsigned int" + basic_abi { + type_abi { + name: "unsigned int" + size: 4 + alignment: 4 + } + name: "Foo_s" + access: public_access + linker_set_key: "Foo_s" + } enum_fields { - enum_field_name: "Foo_s::foosball" + basic_abi { + type_abi { + name: "Foo_s" + size: 4 + alignment: 4 + } + name: "Foo_s::foosball" + access: public_access + linker_set_key: "10" + } enum_field_value: 10 } enum_fields { - enum_field_name: "Foo_s::foosbat" + basic_abi { + type_abi { + name: "Foo_s" + size: 4 + alignment: 4 + } + name: "Foo_s::foosbat" + access: public_access + linker_set_key: "11" + } enum_field_value: 11 } + source_file: "./input/example2.h" } enums { - enum_name: "test3::Kind" - enum_type: "unsigned int" + basic_abi { + type_abi { + name: "unsigned int" + size: 4 + alignment: 4 + } + name: "test3::Kind" + access: public_access + linker_set_key: "test3::Kind" + } enum_fields { - enum_field_name: "test3::Kind::kind1" + basic_abi { + type_abi { + name: "test3::Kind" + size: 4 + alignment: 4 + } + name: "test3::Kind::kind1" + access: public_access + linker_set_key: "24" + } enum_field_value: 24 } enum_fields { - enum_field_name: "test3::Kind::kind2" + basic_abi { + type_abi { + name: "test3::Kind" + size: 4 + alignment: 4 + } + name: "test3::Kind::kind2" + access: public_access + linker_set_key: "2312" + } enum_field_value: 2312 } + source_file: "./input/example2.h" +} +global_vars { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "test2::HelloAgain::hello_forever" + access: public_access + linker_set_key: "_ZN5test210HelloAgain13hello_foreverE" + } + source_file: "./input/example2.h" +} +global_vars { + basic_abi { + type_abi { + name: "bool const[2]" + size: 2 + alignment: 1 + } + name: "__test_var" + access: public_access + linker_set_key: "_ZL10__test_var" + } + source_file: "./input/example2.h" +} +global_vars { + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "test3::ByeAgain::foo_forever" + access: public_access + linker_set_key: "_ZN5test38ByeAgainIfE11foo_foreverE" + } + source_file: "./input/example2.h" +} +global_vars { + basic_abi { + type_abi { + name: "test3::ByeAgain" + size: 16 + alignment: 8 + } + name: "test3::double_bye" + access: public_access + linker_set_key: "_ZN5test310double_byeE" + } + source_file: "./input/example2.h" } diff --git a/vndk/tools/header-checker/tests/expected/func_decl_no_args.h b/vndk/tools/header-checker/tests/expected/func_decl_no_args.h index 97b88c05c..b8c356f76 100644 --- a/vndk/tools/header-checker/tests/expected/func_decl_no_args.h +++ b/vndk/tools/header-checker/tests/expected/func_decl_no_args.h @@ -1,112 +1,194 @@ functions { - function_name: "test_void" + basic_abi { + type_abi { + name: "void" + } + name: "test_void" + access: public_access + linker_set_key: "test_void" + } mangled_function_name: "test_void" source_file: "./input/func_decl_no_args.h" - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_char" + basic_abi { + type_abi { + name: "char" + size: 1 + alignment: 1 + } + name: "test_char" + access: public_access + linker_set_key: "test_char" + } mangled_function_name: "test_char" source_file: "./input/func_decl_no_args.h" - return_type: "char" - access: "public" - template_kind: 0 } functions { - function_name: "test_short" + basic_abi { + type_abi { + name: "short" + size: 2 + alignment: 2 + } + name: "test_short" + access: public_access + linker_set_key: "test_short" + } mangled_function_name: "test_short" source_file: "./input/func_decl_no_args.h" - return_type: "short" - access: "public" - template_kind: 0 } functions { - function_name: "test_int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "test_int" + access: public_access + linker_set_key: "test_int" + } mangled_function_name: "test_int" source_file: "./input/func_decl_no_args.h" - return_type: "int" - access: "public" - template_kind: 0 } functions { - function_name: "test_long" + basic_abi { + type_abi { + name: "long" + size: 8 + alignment: 8 + } + name: "test_long" + access: public_access + linker_set_key: "test_long" + } mangled_function_name: "test_long" source_file: "./input/func_decl_no_args.h" - return_type: "long" - access: "public" - template_kind: 0 } functions { - function_name: "test_long_long" + basic_abi { + type_abi { + name: "long long" + size: 8 + alignment: 8 + } + name: "test_long_long" + access: public_access + linker_set_key: "test_long_long" + } mangled_function_name: "test_long_long" source_file: "./input/func_decl_no_args.h" - return_type: "long long" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_char" + basic_abi { + type_abi { + name: "unsigned char" + size: 1 + alignment: 1 + } + name: "test_unsigned_char" + access: public_access + linker_set_key: "test_unsigned_char" + } mangled_function_name: "test_unsigned_char" source_file: "./input/func_decl_no_args.h" - return_type: "unsigned char" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_short" + basic_abi { + type_abi { + name: "unsigned short" + size: 2 + alignment: 2 + } + name: "test_unsigned_short" + access: public_access + linker_set_key: "test_unsigned_short" + } mangled_function_name: "test_unsigned_short" source_file: "./input/func_decl_no_args.h" - return_type: "unsigned short" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_int" + basic_abi { + type_abi { + name: "unsigned int" + size: 4 + alignment: 4 + } + name: "test_unsigned_int" + access: public_access + linker_set_key: "test_unsigned_int" + } mangled_function_name: "test_unsigned_int" source_file: "./input/func_decl_no_args.h" - return_type: "unsigned int" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_long" + basic_abi { + type_abi { + name: "unsigned long" + size: 8 + alignment: 8 + } + name: "test_unsigned_long" + access: public_access + linker_set_key: "test_unsigned_long" + } mangled_function_name: "test_unsigned_long" source_file: "./input/func_decl_no_args.h" - return_type: "unsigned long" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_long_long" + basic_abi { + type_abi { + name: "unsigned long long" + size: 8 + alignment: 8 + } + name: "test_unsigned_long_long" + access: public_access + linker_set_key: "test_unsigned_long_long" + } mangled_function_name: "test_unsigned_long_long" source_file: "./input/func_decl_no_args.h" - return_type: "unsigned long long" - access: "public" - template_kind: 0 } functions { - function_name: "test_float" + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "test_float" + access: public_access + linker_set_key: "test_float" + } mangled_function_name: "test_float" source_file: "./input/func_decl_no_args.h" - return_type: "float" - access: "public" - template_kind: 0 } functions { - function_name: "test_double" + basic_abi { + type_abi { + name: "double" + size: 8 + alignment: 8 + } + name: "test_double" + access: public_access + linker_set_key: "test_double" + } mangled_function_name: "test_double" source_file: "./input/func_decl_no_args.h" - return_type: "double" - access: "public" - template_kind: 0 } functions { - function_name: "test_long_double" + basic_abi { + type_abi { + name: "long double" + size: 16 + alignment: 16 + } + name: "test_long_double" + access: public_access + linker_set_key: "test_long_double" + } mangled_function_name: "test_long_double" source_file: "./input/func_decl_no_args.h" - return_type: "long double" - access: "public" - template_kind: 0 } diff --git a/vndk/tools/header-checker/tests/expected/func_decl_one_arg.h b/vndk/tools/header-checker/tests/expected/func_decl_one_arg.h index a65210a79..400f6b56d 100644 --- a/vndk/tools/header-checker/tests/expected/func_decl_one_arg.h +++ b/vndk/tools/header-checker/tests/expected/func_decl_one_arg.h @@ -1,169 +1,325 @@ functions { - function_name: "test_char" + basic_abi { + type_abi { + name: "void" + } + name: "test_char" + access: public_access + linker_set_key: "test_char" + } mangled_function_name: "test_char" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "char" + basic_abi { + type_abi { + name: "char" + size: 1 + alignment: 1 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_short" + basic_abi { + type_abi { + name: "void" + } + name: "test_short" + access: public_access + linker_set_key: "test_short" + } mangled_function_name: "test_short" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "short" + basic_abi { + type_abi { + name: "short" + size: 2 + alignment: 2 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_int" + basic_abi { + type_abi { + name: "void" + } + name: "test_int" + access: public_access + linker_set_key: "test_int" + } mangled_function_name: "test_int" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_long" + basic_abi { + type_abi { + name: "void" + } + name: "test_long" + access: public_access + linker_set_key: "test_long" + } mangled_function_name: "test_long" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "long" + basic_abi { + type_abi { + name: "long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_long_long" + basic_abi { + type_abi { + name: "void" + } + name: "test_long_long" + access: public_access + linker_set_key: "test_long_long" + } mangled_function_name: "test_long_long" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "long long" + basic_abi { + type_abi { + name: "long long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_char" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_char" + access: public_access + linker_set_key: "test_unsigned_char" + } mangled_function_name: "test_unsigned_char" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "unsigned char" + basic_abi { + type_abi { + name: "unsigned char" + size: 1 + alignment: 1 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_short" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_short" + access: public_access + linker_set_key: "test_unsigned_short" + } mangled_function_name: "test_unsigned_short" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "unsigned short" + basic_abi { + type_abi { + name: "unsigned short" + size: 2 + alignment: 2 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_int" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_int" + access: public_access + linker_set_key: "test_unsigned_int" + } mangled_function_name: "test_unsigned_int" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "unsigned int" + basic_abi { + type_abi { + name: "unsigned int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_long" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_long" + access: public_access + linker_set_key: "test_unsigned_long" + } mangled_function_name: "test_unsigned_long" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "unsigned long" + basic_abi { + type_abi { + name: "unsigned long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_long_long" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_long_long" + access: public_access + linker_set_key: "test_unsigned_long_long" + } mangled_function_name: "test_unsigned_long_long" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "unsigned long long" + basic_abi { + type_abi { + name: "unsigned long long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_float" + basic_abi { + type_abi { + name: "void" + } + name: "test_float" + access: public_access + linker_set_key: "test_float" + } mangled_function_name: "test_float" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "float" + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_double" + basic_abi { + type_abi { + name: "void" + } + name: "test_double" + access: public_access + linker_set_key: "test_double" + } mangled_function_name: "test_double" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "double" + basic_abi { + type_abi { + name: "double" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_long_double" + basic_abi { + type_abi { + name: "void" + } + name: "test_long_double" + access: public_access + linker_set_key: "test_long_double" + } mangled_function_name: "test_long_double" source_file: "./input/func_decl_one_arg.h" parameters { - field_name: "" - field_type: "long double" + basic_abi { + type_abi { + name: "long double" + size: 16 + alignment: 16 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } diff --git a/vndk/tools/header-checker/tests/expected/func_decl_one_arg_ret.h b/vndk/tools/header-checker/tests/expected/func_decl_one_arg_ret.h index 70d0d6d77..f6e474f8f 100644 --- a/vndk/tools/header-checker/tests/expected/func_decl_one_arg_ret.h +++ b/vndk/tools/header-checker/tests/expected/func_decl_one_arg_ret.h @@ -1,169 +1,351 @@ functions { - function_name: "test_char" + basic_abi { + type_abi { + name: "char" + size: 1 + alignment: 1 + } + name: "test_char" + access: public_access + linker_set_key: "test_char" + } mangled_function_name: "test_char" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "char" + basic_abi { + type_abi { + name: "char" + size: 1 + alignment: 1 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "char" - access: "public" - template_kind: 0 } functions { - function_name: "test_short" + basic_abi { + type_abi { + name: "short" + size: 2 + alignment: 2 + } + name: "test_short" + access: public_access + linker_set_key: "test_short" + } mangled_function_name: "test_short" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "short" + basic_abi { + type_abi { + name: "short" + size: 2 + alignment: 2 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "short" - access: "public" - template_kind: 0 } functions { - function_name: "test_int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "test_int" + access: public_access + linker_set_key: "test_int" + } mangled_function_name: "test_int" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "int" - access: "public" - template_kind: 0 } functions { - function_name: "test_long" + basic_abi { + type_abi { + name: "long" + size: 8 + alignment: 8 + } + name: "test_long" + access: public_access + linker_set_key: "test_long" + } mangled_function_name: "test_long" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "long" + basic_abi { + type_abi { + name: "long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "long" - access: "public" - template_kind: 0 } functions { - function_name: "test_long_long" + basic_abi { + type_abi { + name: "long long" + size: 8 + alignment: 8 + } + name: "test_long_long" + access: public_access + linker_set_key: "test_long_long" + } mangled_function_name: "test_long_long" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "long long" + basic_abi { + type_abi { + name: "long long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "long long" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_char" + basic_abi { + type_abi { + name: "unsigned char" + size: 1 + alignment: 1 + } + name: "test_unsigned_char" + access: public_access + linker_set_key: "test_unsigned_char" + } mangled_function_name: "test_unsigned_char" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "unsigned char" + basic_abi { + type_abi { + name: "unsigned char" + size: 1 + alignment: 1 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "unsigned char" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_short" + basic_abi { + type_abi { + name: "unsigned short" + size: 2 + alignment: 2 + } + name: "test_unsigned_short" + access: public_access + linker_set_key: "test_unsigned_short" + } mangled_function_name: "test_unsigned_short" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "unsigned short" + basic_abi { + type_abi { + name: "unsigned short" + size: 2 + alignment: 2 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "unsigned short" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_int" + basic_abi { + type_abi { + name: "unsigned int" + size: 4 + alignment: 4 + } + name: "test_unsigned_int" + access: public_access + linker_set_key: "test_unsigned_int" + } mangled_function_name: "test_unsigned_int" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "unsigned int" + basic_abi { + type_abi { + name: "unsigned int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "unsigned int" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_long" + basic_abi { + type_abi { + name: "unsigned long" + size: 8 + alignment: 8 + } + name: "test_unsigned_long" + access: public_access + linker_set_key: "test_unsigned_long" + } mangled_function_name: "test_unsigned_long" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "unsigned long" + basic_abi { + type_abi { + name: "unsigned long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "unsigned long" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_long_long" + basic_abi { + type_abi { + name: "unsigned long long" + size: 8 + alignment: 8 + } + name: "test_unsigned_long_long" + access: public_access + linker_set_key: "test_unsigned_long_long" + } mangled_function_name: "test_unsigned_long_long" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "unsigned long long" + basic_abi { + type_abi { + name: "unsigned long long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "unsigned long long" - access: "public" - template_kind: 0 } functions { - function_name: "test_float" + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "test_float" + access: public_access + linker_set_key: "test_float" + } mangled_function_name: "test_float" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "float" + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "float" - access: "public" - template_kind: 0 } functions { - function_name: "test_double" + basic_abi { + type_abi { + name: "double" + size: 8 + alignment: 8 + } + name: "test_double" + access: public_access + linker_set_key: "test_double" + } mangled_function_name: "test_double" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "double" + basic_abi { + type_abi { + name: "double" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "double" - access: "public" - template_kind: 0 } functions { - function_name: "test_long_double" + basic_abi { + type_abi { + name: "long double" + size: 16 + alignment: 16 + } + name: "test_long_double" + access: public_access + linker_set_key: "test_long_double" + } mangled_function_name: "test_long_double" source_file: "./input/func_decl_one_arg_ret.h" parameters { - field_name: "" - field_type: "long double" + basic_abi { + type_abi { + name: "long double" + size: 16 + alignment: 16 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "long double" - access: "public" - template_kind: 0 } diff --git a/vndk/tools/header-checker/tests/expected/func_decl_two_args.h b/vndk/tools/header-checker/tests/expected/func_decl_two_args.h index b2d111ce2..6d0a21e9a 100644 --- a/vndk/tools/header-checker/tests/expected/func_decl_two_args.h +++ b/vndk/tools/header-checker/tests/expected/func_decl_two_args.h @@ -1,234 +1,494 @@ functions { - function_name: "test_char" + basic_abi { + type_abi { + name: "void" + } + name: "test_char" + access: public_access + linker_set_key: "test_char" + } mangled_function_name: "test_char" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "char" + basic_abi { + type_abi { + name: "char" + size: 1 + alignment: 1 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_short" + basic_abi { + type_abi { + name: "void" + } + name: "test_short" + access: public_access + linker_set_key: "test_short" + } mangled_function_name: "test_short" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "short" + basic_abi { + type_abi { + name: "short" + size: 2 + alignment: 2 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_int" + basic_abi { + type_abi { + name: "void" + } + name: "test_int" + access: public_access + linker_set_key: "test_int" + } mangled_function_name: "test_int" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_long" + basic_abi { + type_abi { + name: "void" + } + name: "test_long" + access: public_access + linker_set_key: "test_long" + } mangled_function_name: "test_long" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "long" + basic_abi { + type_abi { + name: "long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_long_long" + basic_abi { + type_abi { + name: "void" + } + name: "test_long_long" + access: public_access + linker_set_key: "test_long_long" + } mangled_function_name: "test_long_long" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "long long" + basic_abi { + type_abi { + name: "long long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_char" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_char" + access: public_access + linker_set_key: "test_unsigned_char" + } mangled_function_name: "test_unsigned_char" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "unsigned char" + basic_abi { + type_abi { + name: "unsigned char" + size: 1 + alignment: 1 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_short" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_short" + access: public_access + linker_set_key: "test_unsigned_short" + } mangled_function_name: "test_unsigned_short" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "unsigned short" + basic_abi { + type_abi { + name: "unsigned short" + size: 2 + alignment: 2 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_int" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_int" + access: public_access + linker_set_key: "test_unsigned_int" + } mangled_function_name: "test_unsigned_int" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "unsigned int" + basic_abi { + type_abi { + name: "unsigned int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_long" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_long" + access: public_access + linker_set_key: "test_unsigned_long" + } mangled_function_name: "test_unsigned_long" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "unsigned long" + basic_abi { + type_abi { + name: "unsigned long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_long_long" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_long_long" + access: public_access + linker_set_key: "test_unsigned_long_long" + } mangled_function_name: "test_unsigned_long_long" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "unsigned long long" + basic_abi { + type_abi { + name: "unsigned long long" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_float" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_float" + access: public_access + linker_set_key: "test_unsigned_float" + } mangled_function_name: "test_unsigned_float" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "float" + basic_abi { + type_abi { + name: "float" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_double" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_double" + access: public_access + linker_set_key: "test_unsigned_double" + } mangled_function_name: "test_unsigned_double" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "double" + basic_abi { + type_abi { + name: "double" + size: 8 + alignment: 8 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 } functions { - function_name: "test_unsigned_long_double" + basic_abi { + type_abi { + name: "void" + } + name: "test_unsigned_long_double" + access: public_access + linker_set_key: "test_unsigned_long_double" + } mangled_function_name: "test_unsigned_long_double" source_file: "./input/func_decl_two_args.h" parameters { - field_name: "" - field_type: "int" + basic_abi { + type_abi { + name: "int" + size: 4 + alignment: 4 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } parameters { - field_name: "" - field_type: "long double" + basic_abi { + type_abi { + name: "long double" + size: 16 + alignment: 16 + } + name: "" + access: public_access + linker_set_key: "false" + } default_arg: false } - return_type: "void" - access: "public" - template_kind: 0 }