Skip to content

Commit

Permalink
Library Forwarding: Don't map float/double to fixed-size integers
Browse files Browse the repository at this point in the history
Fixes #3455.
  • Loading branch information
neobrain committed Mar 14, 2024
1 parent caff3cb commit 552e76c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ThunkLibs/Generator/data_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions ThunkLibs/Generator/gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 552e76c

Please sign in to comment.