Merge pull request #3494 from neobrain/fix_libfwd_float_as_int

Library Forwarding: Don't map float/double to fixed-size integers
This commit is contained in:
Ryan Houdek 2024-03-14 03:11:11 -07:00 committed by GitHub
commit 4e269d8b80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -191,10 +191,10 @@ static std::array<uint8_t, 32> GetSha256(const std::string& function_name) {
};
std::string GetTypeNameWithFixedSizeIntegers(clang::ASTContext& context, clang::QualType type) {
if (type->isBuiltinType()) {
if (type->isBuiltinType() && type->isIntegerType()) {
auto size = context.getTypeSize(type);
return fmt::format("uint{}_t", size);
} else if (type->isPointerType() && type->getPointeeType()->isBuiltinType() && context.getTypeSize(type->getPointeeType()) > 8) {
} else if (type->isPointerType() && type->getPointeeType()->isBuiltinType() && type->getPointeeType()->isIntegerType() && context.getTypeSize(type->getPointeeType()) > 8) {
// TODO: Also apply this path to char-like types
auto size = context.getTypeSize(type->getPointeeType());
return fmt::format("uint{}_t*", size);

View File

@ -551,10 +551,10 @@ void GenerateThunkLibsAction::OnAnalysisComplete(clang::ASTContext& context) {
}
auto get_guest_type_name = [this](clang::QualType type) {
if (type->isBuiltinType() && !type->isFloatingType()) {
if (type->isBuiltinType() && type->isIntegerType()) {
auto size = guest_abi.at(type.getUnqualifiedType().getAsString()).get_if_simple_or_struct()->size_bits;
return get_fixed_size_int_name(type.getTypePtr(), size);
} else if (type->isPointerType() && type->getPointeeType()->isIntegerType() && !type->getPointeeType()->isEnumeralType() && !type->getPointeeType()->isVoidType()) {
} else if (type->isPointerType() && type->getPointeeType()->isBuiltinType() && type->getPointeeType()->isIntegerType() && !type->getPointeeType()->isVoidType()) {
auto size = guest_abi.at(type->getPointeeType().getUnqualifiedType().getAsString()).get_if_simple_or_struct()->size_bits;
return fmt::format("{}{}*", type->getPointeeType().isConstQualified() ? "const " : "", get_fixed_size_int_name(type->getPointeeType().getTypePtr(), size));
} else {