Skip to content

Commit b40b1db

Browse files
authored
Merge pull request #68118 from apple/egorzhdan/cxxstdlib-apinotes
[cxx-interop] Introduce APINotes file for C++ stdlib
2 parents a9a31c1 + 9b7dbf2 commit b40b1db

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,8 +3226,6 @@ namespace {
32263226
// instead of checking if they come from the `std` module.
32273227
if (!d->getDeclName().isIdentifier())
32283228
return false;
3229-
if (d->getName() == "abs" || d->getName() == "div")
3230-
return true;
32313229
if (Impl.SwiftContext.LangOpts.Target.isOSDarwin())
32323230
return d->getName() == "strstr" || d->getName() == "sin" ||
32333231
d->getName() == "cos" || d->getName() == "exit";

stdlib/public/Cxx/std/CMakeLists.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
#
2+
# API Notes for the C++ Standard Library
3+
#
4+
set(output_dir "${SWIFTLIB_DIR}/apinotes")
5+
add_custom_target(CxxStdlib-apinotes
6+
COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${output_dir}"
7+
COMMAND ${CMAKE_COMMAND} "-E" "copy_if_different" "${CMAKE_CURRENT_SOURCE_DIR}/std.apinotes" "${output_dir}"
8+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/std.apinotes
9+
COMMENT "Copying CxxStdlib API Notes to ${output_dir}")
10+
11+
swift_install_in_component(FILES std.apinotes
12+
DESTINATION "lib/swift/apinotes"
13+
COMPONENT compiler)
14+
15+
set_property(TARGET CxxStdlib-apinotes PROPERTY FOLDER "Miscellaneous")
16+
add_dependencies(sdk-overlay CxxStdlib-apinotes)
17+
add_dependencies(compiler CxxStdlib-apinotes)
18+
19+
120
# Swift compiler currently assumes that the Darwin overlay is a dependency of
221
# CxxStdlib, and fails to build CxxStdlib if Darwin.swiftmodule in build dir
322
# is built with a different (older) version of the compiler. To workaround this,
@@ -34,4 +53,4 @@ add_swift_target_library(swiftCxxStdlib STATIC NO_LINK_NAME IS_STDLIB IS_SWIFT_O
3453
TARGET_SDKS ALL_APPLE_PLATFORMS LINUX WINDOWS
3554
INSTALL_IN_COMPONENT compiler
3655
INSTALL_WITH_SHARED
37-
DEPENDS libstdcxx-modulemap libcxxshim_modulemap)
56+
DEPENDS libstdcxx-modulemap libcxxshim_modulemap CxxStdlib-apinotes)

stdlib/public/Cxx/std/std.apinotes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Name: std
2+
Functions:
3+
- Name: abs
4+
Availability: nonswift
5+
AvailabilityMsg: Use the C standard library function
6+
- Name: div
7+
Availability: nonswift
8+
AvailabilityMsg: Use the C standard library function

0 commit comments

Comments
 (0)