Fix the bug that generates multiple definition of references

If a type ID is persent in local_to_global_type_id_map,
ModuleMerger functions should report that was_newly_added_ = false.

Test: ./test.py ; update prebuilts/clang-tools and build
Bug: 255702405
Change-Id: I0fbe68ebbc6b8df3ea4ae36a017d0bb61bc7d553
This commit is contained in:
Hsin-Yi Chen
2023-01-06 19:00:56 +08:00
parent 82b8191b50
commit 6e5894f6a2
3 changed files with 4 additions and 4 deletions

View File

@@ -131,7 +131,7 @@ MergeStatus ModuleMerger::MergeReferencingTypeInternal(
// The type was already added to the parent graph. So change the
// referenced type to the global type id.
references_type->SetReferencedType(local_to_global_it->second.type_id_);
return local_to_global_it->second;
return MergeStatus(false, local_to_global_it->second.type_id_);
}
// If that did not go through, look at the addend's type_map_ and get the
@@ -470,7 +470,7 @@ MergeStatus ModuleMerger::MergeType(
// parent graph. This does not add the node itself though.
auto type_it = local_to_global_type_id_map->find(addend_node->GetSelfType());
if (type_it != local_to_global_type_id_map->end()) {
return type_it->second;
return MergeStatus(false, type_it->second.type_id_);
}
MergeStatus merge_status = LookupType(

View File

@@ -69,7 +69,7 @@
"parameters" :
[
{
"referenced_type" : "_ZTIP18DefinedInOneHeader#ODR:/link_to_def2.h.sdump"
"referenced_type" : "_ZTIP18DefinedInOneHeader"
}
],
"return_type" : "_ZTIv",

View File

@@ -69,7 +69,7 @@
"parameters" :
[
{
"referenced_type" : "_ZTIP18DefinedInOneHeader#ODR:/def2.h.sdump"
"referenced_type" : "_ZTIP18DefinedInOneHeader"
}
],
"return_type" : "_ZTIv",