diff options
| author | Logan Chien <loganchien@google.com> | 2019-03-13 11:32:42 +0800 |
|---|---|---|
| committer | Logan Chien <loganchien@google.com> | 2019-03-20 16:16:27 +0800 |
| commit | a58b9d9f6a09d413967c29358fdad54dd04a9574 (patch) | |
| tree | f5bef5ca4eb651a06b341694e93e5bfa309b80ff /vndk | |
| parent | ef967f7325ac52b1628cc42ce6f393f4a6cef5d5 (diff) | |
| download | android_development-a58b9d9f6a09d413967c29358fdad54dd04a9574.tar.gz android_development-a58b9d9f6a09d413967c29358fdad54dd04a9574.tar.bz2 android_development-a58b9d9f6a09d413967c29358fdad54dd04a9574.zip | |
header-checker: Extract ModuleIR
Test: ./tests/test.py
Test: ${ANDROID_HOST_OUT}/nativetest64/\
header-checker-unittests/header-checker-unittests
Change-Id: I3ae005ddee723213f524881c30ecf5a4a8d45cd9
Diffstat (limited to 'vndk')
4 files changed, 226 insertions, 128 deletions
diff --git a/vndk/tools/header-checker/src/repr/ir_representation.cpp b/vndk/tools/header-checker/src/repr/ir_representation.cpp index a9c9e4341..af70a5e67 100644 --- a/vndk/tools/header-checker/src/repr/ir_representation.cpp +++ b/vndk/tools/header-checker/src/repr/ir_representation.cpp @@ -81,12 +81,12 @@ TextFormatToIRReader::CreateTextFormatToIRReader( 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<const TypeIR *>({value})); + auto map_it = module_->odr_list_map_.find(key); + if (map_it == module_->odr_list_map_.end()) { + module_->odr_list_map_.emplace(key, std::list<const TypeIR *>({value})); return; } - odr_list_map_[key].emplace_back(value); + module_->odr_list_map_[key].emplace_back(value); } MergeStatus TextFormatToIRReader::IsBuiltinTypeNodePresent( @@ -94,18 +94,19 @@ MergeStatus TextFormatToIRReader::IsBuiltinTypeNodePresent( AbiElementMap<MergeStatus> *local_to_global_type_id_map) { std::string builtin_linker_set_key = builtin_type->GetLinkerSetKey(); - auto builtin_it = builtin_types_.find(builtin_linker_set_key); - if (builtin_it != builtin_types_.end()) { + auto builtin_it = module_->builtin_types_.find(builtin_linker_set_key); + if (builtin_it != module_->builtin_types_.end()) { return MergeStatus(false, builtin_it->second.GetSelfType()); } // Add this builtin type to the parent graph's builtin_types_ map. // Before that, correct the type id of the builtin-type. const std::string &local_type_id = builtin_type->GetSelfType(); std::string builtin_global_type_id = AllocateNewTypeId(); - auto it = builtin_types_.emplace(builtin_linker_set_key, *builtin_type); + auto it = module_->builtin_types_.emplace( + builtin_linker_set_key, *builtin_type); it.first->second.SetSelfType(builtin_global_type_id); it.first->second.SetReferencedType(builtin_global_type_id); - type_graph_.emplace(builtin_global_type_id, &((it.first)->second)); + module_->type_graph_.emplace(builtin_global_type_id, &((it.first)->second)); MergeStatus merge_status(true, builtin_global_type_id); local_to_global_type_id_map->emplace(local_type_id, merge_status); @@ -120,8 +121,8 @@ MergeStatus TextFormatToIRReader::DoesUDTypeODRViolationExist( // /-----------------------------------------------------------------------\ // | 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()) { + auto it = module_->odr_list_map_.find(ud_type_unique_id_and_source); + if (it == module_->odr_list_map_.end()) { // Calling this an ODR violation even though it means no UD with the same // name + source combination was seen in the parent graph. The type-id // passed does not matter since was_newly_added_ is true, the type will get @@ -130,7 +131,7 @@ MergeStatus TextFormatToIRReader::DoesUDTypeODRViolationExist( } std::set<std::string> type_cache; DiffPolicyOptions diff_policy_options(false) ; - AbiDiffHelper diff_helper(type_graph_, addend.type_graph_, + AbiDiffHelper diff_helper(module_->type_graph_, addend.module_->type_graph_, diff_policy_options, &type_cache, nullptr, local_to_global_type_id_map_); for (auto &contender_ud : it->second) { @@ -198,8 +199,8 @@ MergeStatus TextFormatToIRReader::MergeReferencingTypeInternal( // 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()) { + auto local_type_it = addend.module_->type_graph_.find(referenced_type_id); + if (local_type_it != addend.module_->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 = @@ -267,7 +268,7 @@ TextFormatToIRReader::UpdateUDTypeAccounting( added_type_ir.SetSelfType(added_type_id); added_type_ir.SetReferencedType(added_type_id); auto it = AddToMapAndTypeGraph(std::move(added_type_ir), specific_type_map, - &type_graph_); + &module_->type_graph_); // Add to faciliate ODR checking. const std::string &key = GetODRListMapKey(&(it->second)); MergeStatus type_merge_status = MergeStatus(true, added_type_id); @@ -283,7 +284,7 @@ MergeStatus TextFormatToIRReader::MergeRecordAndDependencies( AbiElementMap<MergeStatus> *local_to_global_type_id_map) { auto merge_status_and_it = UpdateUDTypeAccounting(addend_node, addend, local_to_global_type_id_map, - &record_types_); + &module_->record_types_); auto it = merge_status_and_it.second; MergeRecordDependencies(addend, &(it->second), local_to_global_type_id_map); return merge_status_and_it.first; @@ -296,8 +297,8 @@ void TextFormatToIRReader::MergeEnumDependencies( // Get the underlying type, it nessarily has to be present in the addend's // type graph since builtin types can't be hidden. Call MergeType on it and // change the underlying type to that. - auto it = addend.type_graph_.find(underlying_type_id); - if (it == addend.type_graph_.end()) { + auto it = addend.module_->type_graph_.find(underlying_type_id); + if (it == addend.module_->type_graph_.end()) { llvm::errs() << "Enum underlying types should not be hidden\n"; ::exit(1); } @@ -313,7 +314,7 @@ MergeStatus TextFormatToIRReader::MergeEnumType( AbiElementMap<MergeStatus> *local_to_global_type_id_map) { auto merge_status_and_it = UpdateUDTypeAccounting(addend_node, addend, local_to_global_type_id_map, - &enum_types_); + &module_->enum_types_); auto it = merge_status_and_it.second; MergeEnumDependencies(addend, &(it->second), local_to_global_type_id_map); return merge_status_and_it.first; @@ -324,7 +325,7 @@ MergeStatus TextFormatToIRReader::MergeFunctionType( AbiElementMap<MergeStatus> *local_to_global_type_id_map) { auto merge_status_and_it = UpdateUDTypeAccounting(addend_node, addend, local_to_global_type_id_map, - &function_types_); + &module_->function_types_); auto it = merge_status_and_it.second; MergeCFunctionLikeDeps(addend, &(it->second), local_to_global_type_id_map); return merge_status_and_it.first; @@ -345,7 +346,8 @@ MergeStatus TextFormatToIRReader::MergeReferencingTypeInternalAndUpdateParent( 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_); + AddToMapAndTypeGraph(std::move(added_node), parent_map, + &module_->type_graph_); return MergeStatus(true, updated_self_type_id); } @@ -372,7 +374,7 @@ MergeStatus TextFormatToIRReader::MergeReferencingTypeInternalAndUpdateParent( // 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_); + &module_->type_graph_); merge_status = MergeStatus(true, updated_self_type_id); return merge_status; @@ -399,24 +401,27 @@ MergeStatus TextFormatToIRReader::MergeReferencingType( case PointerTypeKind: return MergeReferencingTypeInternalAndUpdateParent( addend, static_cast<const PointerTypeIR *>(addend_node), - local_to_global_type_id_map, &pointer_types_, updated_self_type_id); + local_to_global_type_id_map, &module_->pointer_types_, + updated_self_type_id); case QualifiedTypeKind: return MergeReferencingTypeInternalAndUpdateParent( addend, static_cast<const QualifiedTypeIR *>(addend_node), - local_to_global_type_id_map, &qualified_types_, updated_self_type_id); + local_to_global_type_id_map, &module_->qualified_types_, + updated_self_type_id); case ArrayTypeKind: return MergeReferencingTypeInternalAndUpdateParent( addend, static_cast<const ArrayTypeIR *>(addend_node), - local_to_global_type_id_map, &array_types_, updated_self_type_id); + local_to_global_type_id_map, &module_->array_types_, + updated_self_type_id); case LvalueReferenceTypeKind: return MergeReferencingTypeInternalAndUpdateParent( addend, static_cast<const LvalueReferenceTypeIR *>(addend_node), - local_to_global_type_id_map, &lvalue_reference_types_, + local_to_global_type_id_map, &module_->lvalue_reference_types_, updated_self_type_id); case RvalueReferenceTypeKind: return MergeReferencingTypeInternalAndUpdateParent( addend, static_cast<const RvalueReferenceTypeIR *>(addend_node), - local_to_global_type_id_map, &rvalue_reference_types_, + local_to_global_type_id_map, &module_->rvalue_reference_types_, updated_self_type_id); default: // Only referencing types @@ -493,8 +498,8 @@ void TextFormatToIRReader::MergeCFunctionLikeDeps( AbiElementMap<MergeStatus> *local_to_global_type_id_map) { // 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()) { + addend.module_->type_graph_.find(cfunction_like_ir->GetReturnType()); + if (ret_type_it == addend.module_->type_graph_.end()) { // Hidden types aren't officially added to the parent since there is // nothing actually backing it. We assign a type-id. cfunction_like_ir->SetReturnType(AllocateNewTypeId()); @@ -530,7 +535,7 @@ void TextFormatToIRReader::MergeFunction( const FunctionIR *addend_node, const TextFormatToIRReader &addend, AbiElementMap<MergeStatus> *local_to_global_type_id_map) { const std::string &function_linkage_name = addend_node->GetLinkerSetKey(); - if (IsLinkableMessagePresent(addend_node, functions_)) { + if (IsLinkableMessagePresent(addend_node, module_->functions_)) { // The functions and all of its dependencies have already been added. // No two globally visible functions can have the same symbol name. return; @@ -538,7 +543,7 @@ void TextFormatToIRReader::MergeFunction( FunctionIR function_ir = *addend_node; MergeFunctionDeps(&function_ir, addend, local_to_global_type_id_map); // Add it to the parent's function map. - functions_.emplace(function_linkage_name, std::move(function_ir)); + module_->functions_.emplace(function_linkage_name, std::move(function_ir)); } std::string TextFormatToIRReader::AllocateNewTypeId() { @@ -550,15 +555,15 @@ void TextFormatToIRReader::MergeGlobalVariable( AbiElementMap<MergeStatus> *local_to_global_type_id_map) { const std::string &global_variable_linkage_name = addend_node->GetLinkerSetKey(); - if (IsLinkableMessagePresent(addend_node, global_variables_)) { + if (IsLinkableMessagePresent(addend_node, module_->global_variables_)) { // The global variable and all of its dependencies have already been added. return; } GlobalVarIR global_variable_ir = *addend_node; MergeReferencingTypeInternal(addend, &global_variable_ir, local_to_global_type_id_map); - global_variables_.emplace(global_variable_linkage_name, - std::move(global_variable_ir)); + module_->global_variables_.emplace( + global_variable_linkage_name, std::move(global_variable_ir)); } void TextFormatToIRReader::MergeGraphs(const TextFormatToIRReader &addend) { @@ -567,26 +572,27 @@ void TextFormatToIRReader::MergeGraphs(const TextFormatToIRReader &addend) { // dependencies which weren't already merged. AbiElementMap<MergeStatus> merged_types_cache; - for (auto &&type_ir : addend.type_graph_) { + for (auto &&type_ir : addend.module_->type_graph_) { MergeType(type_ir.second, addend, &merged_types_cache); } - for (auto &&function_ir : addend.functions_) { + for (auto &&function_ir : addend.module_->functions_) { MergeFunction(&function_ir.second, addend, &merged_types_cache); } - for (auto &&global_var_ir : addend.global_variables_) { + for (auto &&global_var_ir : addend.module_->global_variables_) { MergeGlobalVariable(&global_var_ir.second, addend, &merged_types_cache); } } bool TextFormatToIRReader::IsLinkableMessageInExportedHeaders( const LinkableMessageIR *linkable_message) const { - if (exported_headers_ == nullptr || exported_headers_->empty()) { + if (module_->exported_headers_ == nullptr || + module_->exported_headers_->empty()) { return true; } - return exported_headers_->find(linkable_message->GetSourceFile()) != - exported_headers_->end(); + return module_->exported_headers_->find(linkable_message->GetSourceFile()) != + module_->exported_headers_->end(); } diff --git a/vndk/tools/header-checker/src/repr/ir_representation.h b/vndk/tools/header-checker/src/repr/ir_representation.h index b8e504acf..f14755c96 100644 --- a/vndk/tools/header-checker/src/repr/ir_representation.h +++ b/vndk/tools/header-checker/src/repr/ir_representation.h @@ -776,6 +776,99 @@ class ElfObjectIR : public ElfSymbolIR { } }; +class ModuleIR { + public: + ModuleIR(const std::set<std::string> *exported_headers) + : exported_headers_(exported_headers) {} + + const AbiElementMap<FunctionIR> &GetFunctions() const { + return functions_; + } + + const AbiElementMap<GlobalVarIR> &GetGlobalVariables() const { + return global_variables_; + } + + const AbiElementMap<RecordTypeIR> &GetRecordTypes() const { + return record_types_; + } + + const AbiElementMap<FunctionTypeIR> &GetFunctionTypes() const { + return function_types_; + } + + const AbiElementMap<EnumTypeIR> &GetEnumTypes() const { + return enum_types_; + } + + const AbiElementMap<LvalueReferenceTypeIR> &GetLvalueReferenceTypes() const { + return lvalue_reference_types_; + } + + const AbiElementMap<RvalueReferenceTypeIR> &GetRvalueReferenceTypes() const { + return rvalue_reference_types_; + } + + const AbiElementMap<QualifiedTypeIR> &GetQualifiedTypes() const { + return qualified_types_; + } + + const AbiElementMap<ArrayTypeIR> &GetArrayTypes() const { + return array_types_; + } + + const AbiElementMap<PointerTypeIR> &GetPointerTypes() const { + return pointer_types_; + } + + const AbiElementMap<BuiltinTypeIR> &GetBuiltinTypes() const { + return builtin_types_; + } + + const AbiElementMap<ElfFunctionIR> &GetElfFunctions() const { + return elf_functions_; + } + + const AbiElementMap<ElfObjectIR> &GetElfObjects() const { + return elf_objects_; + } + + const AbiElementMap<const TypeIR *> &GetTypeGraph() const { + return type_graph_; + } + + const AbiElementUnorderedMap<std::list<const TypeIR *>> & + GetODRListMap() const { + return odr_list_map_; + } + + public: + AbiElementList<RecordTypeIR> record_types_list_; + AbiElementMap<FunctionIR> functions_; + AbiElementMap<GlobalVarIR> global_variables_; + AbiElementMap<RecordTypeIR> record_types_; + AbiElementMap<FunctionTypeIR> function_types_; + AbiElementMap<EnumTypeIR> enum_types_; + // These maps which contain generic referring types as values are used while + // looking up whether in the parent graph, a particular referring type refers + // to a certain type id. The mechanism is useful while trying to determine + // whether a generic referring type needs to be newly added to the parent + // graph or not. + AbiElementMap<PointerTypeIR> pointer_types_; + AbiElementMap<LvalueReferenceTypeIR> lvalue_reference_types_; + AbiElementMap<RvalueReferenceTypeIR> rvalue_reference_types_; + AbiElementMap<ArrayTypeIR> array_types_; + AbiElementMap<BuiltinTypeIR> builtin_types_; + AbiElementMap<QualifiedTypeIR> qualified_types_; + AbiElementMap<ElfFunctionIR> elf_functions_; + AbiElementMap<ElfObjectIR> elf_objects_; + // type-id -> LinkableMessageIR * map + AbiElementMap<const TypeIR *> type_graph_; + // maps unique_id + source_file -> const TypeIR * + AbiElementUnorderedMap<std::list<const TypeIR *>> odr_list_map_; + const std::set<std::string> *exported_headers_; +}; + class IRDumper { public: IRDumper(const std::string &dump_path) : dump_path_(dump_path) {} @@ -870,86 +963,93 @@ class TextFormatToIRReader { public: TextFormatToIRReader(const std::set<std::string> *exported_headers) - : exported_headers_(exported_headers) {} + : module_(new ModuleIR(exported_headers)) {} virtual ~TextFormatToIRReader() {} const AbiElementMap<FunctionIR> &GetFunctions() const { - return functions_; + return module_->functions_; } const AbiElementMap<GlobalVarIR> &GetGlobalVariables() const { - return global_variables_; + return module_->global_variables_; } const AbiElementMap<RecordTypeIR> &GetRecordTypes() const { - return record_types_; + return module_->record_types_; } const AbiElementMap<FunctionTypeIR> &GetFunctionTypes() const { - return function_types_; + return module_->function_types_; } const AbiElementMap<EnumTypeIR> &GetEnumTypes() const { - return enum_types_; + return module_->enum_types_; } const AbiElementMap<LvalueReferenceTypeIR> &GetLvalueReferenceTypes() const { - return lvalue_reference_types_; + return module_->lvalue_reference_types_; } const AbiElementMap<RvalueReferenceTypeIR> &GetRvalueReferenceTypes() const { - return rvalue_reference_types_; + return module_->rvalue_reference_types_; } const AbiElementMap<QualifiedTypeIR> &GetQualifiedTypes() const { - return qualified_types_; + return module_->qualified_types_; } const AbiElementMap<ArrayTypeIR> &GetArrayTypes() const { - return array_types_; + return module_->array_types_; } const AbiElementMap<PointerTypeIR> &GetPointerTypes() const { - return pointer_types_; + return module_->pointer_types_; } const AbiElementMap<BuiltinTypeIR> &GetBuiltinTypes() const { - return builtin_types_; + return module_->builtin_types_; } const AbiElementMap<ElfFunctionIR> &GetElfFunctions() const { - return elf_functions_; + return module_->elf_functions_; } const AbiElementMap<ElfObjectIR> &GetElfObjects() const { - return elf_objects_; + return module_->elf_objects_; } const AbiElementMap<const TypeIR *> &GetTypeGraph() const { - return type_graph_; + return module_->type_graph_; } const AbiElementUnorderedMap<std::list<const TypeIR *>> & GetODRListMap() const { - return odr_list_map_; + return module_->odr_list_map_; } virtual bool ReadDump(const std::string &dump_file) = 0; void Merge(TextFormatToIRReader &&addend) { - MergeElements(&functions_, std::move(addend.functions_)); - MergeElements(&global_variables_, std::move(addend.global_variables_)); - MergeElements(&record_types_, std::move(addend.record_types_)); - MergeElements(&enum_types_, std::move(addend.enum_types_)); - MergeElements(&pointer_types_, std::move(addend.pointer_types_)); - MergeElements(&lvalue_reference_types_, - std::move(addend.lvalue_reference_types_)); - MergeElements(&rvalue_reference_types_, - std::move(addend.rvalue_reference_types_)); - MergeElements(&array_types_, std::move(addend.array_types_)); - MergeElements(&builtin_types_, std::move(addend.builtin_types_)); - MergeElements(&qualified_types_, std::move(addend.qualified_types_)); + MergeElements(&module_->functions_, std::move(addend.module_->functions_)); + MergeElements(&module_->global_variables_, + std::move(addend.module_->global_variables_)); + MergeElements(&module_->record_types_, + std::move(addend.module_->record_types_)); + MergeElements(&module_->enum_types_, + std::move(addend.module_->enum_types_)); + MergeElements(&module_->pointer_types_, + std::move(addend.module_->pointer_types_)); + MergeElements(&module_->lvalue_reference_types_, + std::move(addend.module_->lvalue_reference_types_)); + MergeElements(&module_->rvalue_reference_types_, + std::move(addend.module_->rvalue_reference_types_)); + MergeElements(&module_->array_types_, + std::move(addend.module_->array_types_)); + MergeElements(&module_->builtin_types_, + std::move(addend.module_->builtin_types_)); + MergeElements(&module_->qualified_types_, + std::move(addend.module_->qualified_types_)); } void AddToODRListMap(const std::string &key, const TypeIR *value); @@ -1075,30 +1175,8 @@ class TextFormatToIRReader { bool IsLinkableMessageInExportedHeaders( const LinkableMessageIR *linkable_message) const; - AbiElementList<RecordTypeIR> record_types_list_; - AbiElementMap<FunctionIR> functions_; - AbiElementMap<GlobalVarIR> global_variables_; - AbiElementMap<RecordTypeIR> record_types_; - AbiElementMap<FunctionTypeIR> function_types_; - AbiElementMap<EnumTypeIR> enum_types_; - // These maps which contain generic referring types as values are used while - // looking up whether in the parent graph, a particular reffering type refers - // to a certain type id. The mechanism is useful while trying to determine - // whether a generic referring type needs to be newly added to the parent - // graph or not. - AbiElementMap<PointerTypeIR> pointer_types_; - AbiElementMap<LvalueReferenceTypeIR> lvalue_reference_types_; - AbiElementMap<RvalueReferenceTypeIR> rvalue_reference_types_; - AbiElementMap<ArrayTypeIR> array_types_; - AbiElementMap<BuiltinTypeIR> builtin_types_; - AbiElementMap<QualifiedTypeIR> qualified_types_; - AbiElementMap<ElfFunctionIR> elf_functions_; - AbiElementMap<ElfObjectIR> elf_objects_; - // type-id -> LinkableMessageIR * map - AbiElementMap<const TypeIR *> type_graph_; - // maps unique_id + source_file -> const TypeIR * - AbiElementUnorderedMap<std::list<const TypeIR *>> odr_list_map_; - const std::set<std::string> *exported_headers_; + std::unique_ptr<ModuleIR> module_; + uint64_t max_type_id_ = 0; }; diff --git a/vndk/tools/header-checker/src/repr/json/ir_representation_json.cpp b/vndk/tools/header-checker/src/repr/json/ir_representation_json.cpp index 3d679cf0e..32e25127c 100644 --- a/vndk/tools/header-checker/src/repr/json/ir_representation_json.cpp +++ b/vndk/tools/header-checker/src/repr/json/ir_representation_json.cpp @@ -794,7 +794,7 @@ void JsonToIRReader::ReadGlobalVariables(const JsonObjectRef &tu) { if (!IsLinkableMessageInExportedHeaders(&global_variable_ir)) { continue; } - global_variables_.insert( + module_->global_variables_.insert( {global_variable_ir.GetLinkerSetKey(), std::move(global_variable_ir)}); } } @@ -806,8 +806,8 @@ void JsonToIRReader::ReadPointerTypes(const JsonObjectRef &tu) { if (!IsLinkableMessageInExportedHeaders(&pointer_type_ir)) { continue; } - AddToMapAndTypeGraph(std::move(pointer_type_ir), &pointer_types_, - &type_graph_); + AddToMapAndTypeGraph(std::move(pointer_type_ir), &module_->pointer_types_, + &module_->type_graph_); } } @@ -817,8 +817,8 @@ void JsonToIRReader::ReadBuiltinTypes(const JsonObjectRef &tu) { ReadTypeInfo(builtin_type, &builtin_type_ir); builtin_type_ir.SetSignedness(builtin_type.GetBool("is_unsigned")); builtin_type_ir.SetIntegralType(builtin_type.GetBool("is_integral")); - AddToMapAndTypeGraph(std::move(builtin_type_ir), &builtin_types_, - &type_graph_); + AddToMapAndTypeGraph(std::move(builtin_type_ir), &module_->builtin_types_, + &module_->type_graph_); } } @@ -833,8 +833,8 @@ void JsonToIRReader::ReadQualifiedTypes(const JsonObjectRef &tu) { if (!IsLinkableMessageInExportedHeaders(&qualified_type_ir)) { continue; } - AddToMapAndTypeGraph(std::move(qualified_type_ir), &qualified_types_, - &type_graph_); + AddToMapAndTypeGraph(std::move(qualified_type_ir), + &module_->qualified_types_, &module_->type_graph_); } } @@ -845,7 +845,8 @@ void JsonToIRReader::ReadArrayTypes(const JsonObjectRef &tu) { if (!IsLinkableMessageInExportedHeaders(&array_type_ir)) { continue; } - AddToMapAndTypeGraph(std::move(array_type_ir), &array_types_, &type_graph_); + AddToMapAndTypeGraph(std::move(array_type_ir), &module_->array_types_, + &module_->type_graph_); } } @@ -857,7 +858,8 @@ void JsonToIRReader::ReadLvalueReferenceTypes(const JsonObjectRef &tu) { continue; } AddToMapAndTypeGraph(std::move(lvalue_reference_type_ir), - &lvalue_reference_types_, &type_graph_); + &module_->lvalue_reference_types_, + &module_->type_graph_); } } @@ -869,7 +871,8 @@ void JsonToIRReader::ReadRvalueReferenceTypes(const JsonObjectRef &tu) { continue; } AddToMapAndTypeGraph(std::move(rvalue_reference_type_ir), - &rvalue_reference_types_, &type_graph_); + &module_->rvalue_reference_types_, + &module_->type_graph_); } } @@ -879,7 +882,8 @@ void JsonToIRReader::ReadFunctions(const JsonObjectRef &tu) { if (!IsLinkableMessageInExportedHeaders(&function_ir)) { continue; } - functions_.insert({function_ir.GetLinkerSetKey(), std::move(function_ir)}); + module_->functions_.insert( + {function_ir.GetLinkerSetKey(), std::move(function_ir)}); } } @@ -889,8 +893,9 @@ void JsonToIRReader::ReadRecordTypes(const JsonObjectRef &tu) { if (!IsLinkableMessageInExportedHeaders(&record_type_ir)) { continue; } - auto it = AddToMapAndTypeGraph(std::move(record_type_ir), &record_types_, - &type_graph_); + auto it = AddToMapAndTypeGraph(std::move(record_type_ir), + &module_->record_types_, + &module_->type_graph_); const std::string &key = GetODRListMapKey(&(it->second)); AddToODRListMap(key, &(it->second)); } @@ -903,7 +908,8 @@ void JsonToIRReader::ReadFunctionTypes(const JsonObjectRef &tu) { continue; } auto it = AddToMapAndTypeGraph(std::move(function_type_ir), - &function_types_, &type_graph_); + &module_->function_types_, + &module_->type_graph_); const std::string &key = GetODRListMapKey(&(it->second)); AddToODRListMap(key, &(it->second)); } @@ -915,8 +921,9 @@ void JsonToIRReader::ReadEnumTypes(const JsonObjectRef &tu) { if (!IsLinkableMessageInExportedHeaders(&enum_type_ir)) { continue; } - auto it = AddToMapAndTypeGraph(std::move(enum_type_ir), &enum_types_, - &type_graph_); + auto it = AddToMapAndTypeGraph(std::move(enum_type_ir), + &module_->enum_types_, + &module_->type_graph_); AddToODRListMap(it->second.GetUniqueId() + it->second.GetSourceFile(), (&it->second)); } @@ -926,7 +933,7 @@ void JsonToIRReader::ReadElfFunctions(const JsonObjectRef &tu) { for (auto &&elf_function : tu.GetObjects("elf_functions")) { ElfFunctionIR elf_function_ir(elf_function.GetString("name"), GetElfSymbolBinding(elf_function)); - elf_functions_.insert( + module_->elf_functions_.insert( {elf_function_ir.GetName(), std::move(elf_function_ir)}); } } @@ -935,7 +942,8 @@ void JsonToIRReader::ReadElfObjects(const JsonObjectRef &tu) { for (auto &&elf_object : tu.GetObjects("elf_objects")) { ElfObjectIR elf_object_ir(elf_object.GetString("name"), GetElfSymbolBinding(elf_object)); - elf_objects_.insert({elf_object_ir.GetName(), std::move(elf_object_ir)}); + module_->elf_objects_.insert( + {elf_object_ir.GetName(), std::move(elf_object_ir)}); } } diff --git a/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.cpp b/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.cpp index 62dc75153..ede10fcca 100644 --- a/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.cpp +++ b/vndk/tools/header-checker/src/repr/protobuf/ir_representation_protobuf.cpp @@ -212,7 +212,7 @@ void ProtobufTextFormatToIRReader::ReadGlobalVariables( if (!IsLinkableMessageInExportedHeaders(&global_variable_ir)) { continue; } - global_variables_.insert( + module_->global_variables_.insert( {global_variable_ir.GetLinkerSetKey(), std::move(global_variable_ir)}); } } @@ -225,8 +225,8 @@ void ProtobufTextFormatToIRReader::ReadPointerTypes( if (!IsLinkableMessageInExportedHeaders(&pointer_type_ir)) { continue; } - AddToMapAndTypeGraph(std::move(pointer_type_ir), &pointer_types_, - &type_graph_); + AddToMapAndTypeGraph(std::move(pointer_type_ir), &module_->pointer_types_, + &module_->type_graph_); } } @@ -237,8 +237,8 @@ void ProtobufTextFormatToIRReader::ReadBuiltinTypes( ReadTypeInfo(builtin_type_protobuf.type_info(), &builtin_type_ir); builtin_type_ir.SetSignedness(builtin_type_protobuf.is_unsigned()); builtin_type_ir.SetIntegralType(builtin_type_protobuf.is_integral()); - AddToMapAndTypeGraph(std::move(builtin_type_ir), &builtin_types_, - &type_graph_); + AddToMapAndTypeGraph(std::move(builtin_type_ir), &module_->builtin_types_, + &module_->type_graph_); } } @@ -254,8 +254,8 @@ void ProtobufTextFormatToIRReader::ReadQualifiedTypes( if (!IsLinkableMessageInExportedHeaders(&qualified_type_ir)) { continue; } - AddToMapAndTypeGraph(std::move(qualified_type_ir), &qualified_types_, - &type_graph_); + AddToMapAndTypeGraph(std::move(qualified_type_ir), + &module_->qualified_types_, &module_->type_graph_); } } @@ -267,8 +267,8 @@ void ProtobufTextFormatToIRReader::ReadArrayTypes( if (!IsLinkableMessageInExportedHeaders(&array_type_ir)) { continue; } - AddToMapAndTypeGraph(std::move(array_type_ir), &array_types_, - &type_graph_); + AddToMapAndTypeGraph(std::move(array_type_ir), &module_->array_types_, + &module_->type_graph_); } } @@ -282,7 +282,8 @@ void ProtobufTextFormatToIRReader::ReadLvalueReferenceTypes( continue; } AddToMapAndTypeGraph(std::move(lvalue_reference_type_ir), - &lvalue_reference_types_, &type_graph_); + &module_->lvalue_reference_types_, + &module_->type_graph_); } } @@ -296,7 +297,8 @@ void ProtobufTextFormatToIRReader::ReadRvalueReferenceTypes( continue; } AddToMapAndTypeGraph(std::move(rvalue_reference_type_ir), - &rvalue_reference_types_, &type_graph_); + &module_->rvalue_reference_types_, + &module_->type_graph_); } } @@ -307,7 +309,8 @@ void ProtobufTextFormatToIRReader::ReadFunctions( if (!IsLinkableMessageInExportedHeaders(&function_ir)) { continue; } - functions_.insert({function_ir.GetLinkerSetKey(), std::move(function_ir)}); + module_->functions_.insert( + {function_ir.GetLinkerSetKey(), std::move(function_ir)}); } } @@ -318,8 +321,9 @@ void ProtobufTextFormatToIRReader::ReadRecordTypes( if (!IsLinkableMessageInExportedHeaders(&record_type_ir)) { continue; } - auto it = AddToMapAndTypeGraph(std::move(record_type_ir), &record_types_, - &type_graph_); + auto it = AddToMapAndTypeGraph(std::move(record_type_ir), + &module_->record_types_, + &module_->type_graph_); const std::string &key = GetODRListMapKey(&(it->second)); AddToODRListMap(key, &(it->second)); } @@ -334,7 +338,8 @@ void ProtobufTextFormatToIRReader::ReadFunctionTypes( continue; } auto it = AddToMapAndTypeGraph(std::move(function_type_ir), - &function_types_, &type_graph_); + &module_->function_types_, + &module_->type_graph_); const std::string &key = GetODRListMapKey(&(it->second)); AddToODRListMap(key, &(it->second)); } @@ -347,8 +352,9 @@ void ProtobufTextFormatToIRReader::ReadEnumTypes( if (!IsLinkableMessageInExportedHeaders(&enum_type_ir)) { continue; } - auto it = AddToMapAndTypeGraph(std::move(enum_type_ir), &enum_types_, - &type_graph_); + auto it = AddToMapAndTypeGraph(std::move(enum_type_ir), + &module_->enum_types_, + &module_->type_graph_); AddToODRListMap(it->second.GetUniqueId() + it->second.GetSourceFile(), (&it->second)); } @@ -360,7 +366,7 @@ void ProtobufTextFormatToIRReader::ReadElfFunctions( ElfFunctionIR elf_function_ir( elf_function.name(), ElfSymbolBindingProtobufToIR(elf_function.binding())); - elf_functions_.insert( + module_->elf_functions_.insert( {elf_function_ir.GetName(), std::move(elf_function_ir)}); } } @@ -370,7 +376,7 @@ void ProtobufTextFormatToIRReader::ReadElfObjects( for (auto &&elf_object : tu.elf_objects()) { ElfObjectIR elf_object_ir( elf_object.name(), ElfSymbolBindingProtobufToIR(elf_object.binding())); - elf_objects_.insert( + module_->elf_objects_.insert( {elf_object_ir.GetName(), std::move(elf_object_ir)}); } } |
