-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Import size_t
as Int instead of UInt on Linux
#42003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please smoke test |
@swift-ci please smoke test Linux platform |
@@ -7,4 +7,8 @@ void foo(int x) {} | |||
|
|||
}; // namespace FakeNamespace | |||
|
|||
namespace std { | |||
typedef unsigned long size_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this get tested on windows? size_t
needs unsigned long long for the windows target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't be tested on Windows, since Clang on Windows doesn't support -stdlib=libc++
which is used for fake toolchain tests.
There was an effort to support it in Clang, however, the patch got reverted: https://reviews.llvm.org/D101479
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
When using libc++, Swift imports `size_t` as Int despite `size_t` being an unsigned type. This is intentional & is specified in `lib/ClangImporter/MappedTypes.def`. Previously, MappedTypes were only honored for C/C++ types declared on the file level. In libstdc++, `size_t` is declared within `namespace std` and not on the file level, so the mapping to Int was not applied. This change ensures that MappedTypes are also applied to types declared in `namespace std`.
4948769
to
626eadc
Compare
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
When using libc++, Swift imports
size_t
as Int despitesize_t
being an unsigned type. This is intentional & is specified inlib/ClangImporter/MappedTypes.def
. Previously, MappedTypes were only honored for C/C++ types declared on the file level.In libstdc++,
size_t
is declared withinnamespace std
and not on the file level, so the mapping to Int was not applied.This change ensures that MappedTypes are also applied to types declared in
namespace std
.