From 0ebf260ed04a7e6d5dc4af37c83d643f619b6c7c Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Tue, 30 Jan 2024 17:17:37 +0100 Subject: [PATCH] Library Forwarding: Consider struct metadata equal if it only differs in integer member type names --- ThunkLibs/Generator/data_layout.cpp | 1 + ThunkLibs/Generator/data_layout.h | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ThunkLibs/Generator/data_layout.cpp b/ThunkLibs/Generator/data_layout.cpp index 243ddfc28..6b5e760f4 100644 --- a/ThunkLibs/Generator/data_layout.cpp +++ b/ThunkLibs/Generator/data_layout.cpp @@ -86,6 +86,7 @@ std::unordered_map ComputeDataLayout(const clang:: .member_name = field->getNameAsString(), .array_size = array_size, .is_function_pointer = field_type->isFunctionPointerType(), + .is_integral = field->getType()->isIntegerType(), }; // TODO: Process types in dependency-order. Currently we skip this diff --git a/ThunkLibs/Generator/data_layout.h b/ThunkLibs/Generator/data_layout.h index 1bcf76d5e..07fd13330 100644 --- a/ThunkLibs/Generator/data_layout.h +++ b/ThunkLibs/Generator/data_layout.h @@ -29,14 +29,17 @@ struct StructInfo : SimpleTypeInfo { std::string member_name; std::optional array_size; bool is_function_pointer; + bool is_integral; bool operator==(const MemberInfo& other) const { return size_bits == other.size_bits && offset_bits == other.offset_bits && - type_name == other.type_name && + // The type name may differ for integral types if all other parameters are equal + (type_name == other.type_name || (is_integral && other.is_integral)) && member_name == other.member_name && array_size == other.array_size && - is_function_pointer == other.is_function_pointer; + is_function_pointer == other.is_function_pointer && + is_integral == other.is_integral; } };