diff --git a/lib/ClangImporter/ClangIncludePaths.cpp b/lib/ClangImporter/ClangIncludePaths.cpp index 28be2a1643ae1..4d06e7bb2cb91 100644 --- a/lib/ClangImporter/ClangIncludePaths.cpp +++ b/lib/ClangImporter/ClangIncludePaths.cpp @@ -344,7 +344,47 @@ static void getLibStdCxxFileMapping( "codecvt", // C++17 and newer: "any", "charconv", "filesystem", "memory_resource", "optional", - "string_view", "variant"}; + "string_view", "variant", "bits/algorithmfwd.h", "bits/align.h", + "bits/alloc_traits.h", "bits/allocated_ptr.h", "bits/allocator.h", + "bits/atomic_base.h", "bits/atomic_futex.h", + "bits/atomic_lockfree_defines.h", "bits/basic_ios.h", + "bits/basic_string.h", "bits/c++0x_warning.h", "bits/char_traits.h", + "bits/charconv.h", "bits/codecvt.h", "bits/concept_check.h", + "bits/cpp_type_traits.h", "bits/cxxabi_forced.h", + "bits/cxxabi_init_exception.h", "bits/enable_special_members.h", + "bits/erase_if.h", "bits/exception.h", "bits/exception_defines.h", + "bits/exception_ptr.h", "bits/forward_list.h", "bits/fs_dir.h", + "bits/fs_fwd.h", "bits/fs_ops.h", "bits/fs_path.h", "bits/functexcept.h", + "bits/functional_hash.h", "bits/gslice.h", "bits/gslice_array.h", + "bits/hash_bytes.h", "bits/hashtable.h", "bits/hashtable_policy.h", + "bits/indirect_array.h", "bits/invoke.h", "bits/ios_base.h", + "bits/iterator_concepts.h", "bits/locale_classes.h", "bits/locale_conv.h", + "bits/locale_facets.h", "bits/locale_facets_nonio.h", "bits/localefwd.h", + "bits/mask_array.h", "bits/max_size_type.h", "bits/memoryfwd.h", + "bits/move.h", "bits/nested_exception.h", "bits/node_handle.h", + "bits/ostream_insert.h", "bits/parse_numbers.h", "bits/postypes.h", + "bits/predefined_ops.h", "bits/ptr_traits.h", "bits/quoted_string.h", + "bits/random.h", "bits/range_access.h", "bits/ranges_algo.h", + "bits/ranges_algobase.h", "bits/ranges_base.h", "bits/ranges_cmp.h", + "bits/ranges_uninitialized.h", "bits/ranges_util.h", "bits/refwrap.h", + "bits/shared_ptr.h", "bits/shared_ptr_atomic.h", "bits/shared_ptr_base.h", + "bits/slice_array.h", "bits/std_abs.h", "bits/std_function.h", + "bits/std_mutex.h", "bits/std_thread.h", "bits/stl_algo.h", + "bits/stl_algobase.h", "bits/stl_bvector.h", "bits/stl_construct.h", + "bits/stl_deque.h", "bits/stl_function.h", "bits/stl_heap.h", + "bits/stl_iterator.h", "bits/stl_iterator_base_funcs.h", + "bits/stl_iterator_base_types.h", "bits/stl_list.h", "bits/stl_map.h", + "bits/stl_multimap.h", "bits/stl_multiset.h", "bits/stl_numeric.h", + "bits/stl_pair.h", "bits/stl_queue.h", "bits/stl_raw_storage_iter.h", + "bits/stl_relops.h", "bits/stl_set.h", "bits/stl_stack.h", + "bits/stl_tempbuf.h", "bits/stl_tree.h", "bits/stl_uninitialized.h", + "bits/stl_vector.h", "bits/stream_iterator.h", + "bits/streambuf_iterator.h", "bits/stringfwd.h", + "bits/this_thread_sleep.h", "bits/uniform_int_dist.h", + "bits/unique_lock.h", "bits/unique_ptr.h", "bits/unordered_map.h", + "bits/unordered_set.h", "bits/uses_allocator.h", + "bits/uses_allocator_args.h", "bits/valarray_after.h", + "bits/valarray_array.h", "bits/valarray_before.h"}; std::string additionalHeaderDirectives; llvm::raw_string_ostream os(additionalHeaderDirectives); os << contents.substr(0, headerInjectionPoint); diff --git a/stdlib/public/Cxx/libstdcxx/libstdcxx.modulemap b/stdlib/public/Cxx/libstdcxx/libstdcxx.modulemap index a0d95f5946362..4627ffd22307b 100644 --- a/stdlib/public/Cxx/libstdcxx/libstdcxx.modulemap +++ b/stdlib/public/Cxx/libstdcxx/libstdcxx.modulemap @@ -82,5 +82,11 @@ module std { requires cplusplus export * } + + module cstdlib { + header "cstdlib" + requires cplusplus + export * + } } } diff --git a/test/Interop/Cxx/foreign-reference/Inputs/reference-counted.h b/test/Interop/Cxx/foreign-reference/Inputs/reference-counted.h index c66e58c03c045..fbf410236cc30 100644 --- a/test/Interop/Cxx/foreign-reference/Inputs/reference-counted.h +++ b/test/Interop/Cxx/foreign-reference/Inputs/reference-counted.h @@ -2,11 +2,10 @@ #define TEST_INTEROP_CXX_FOREIGN_REFERENCE_INPUTS_REFERENCE_COUNTED_H #include +#include #include "visibility.h" -inline void *operator new(size_t, void *p) { return p; } - SWIFT_BEGIN_NULLABILITY_ANNOTATIONS static int finalLocalRefCount = 100; diff --git a/test/Interop/Cxx/stdlib/foundation-and-std-module.swift b/test/Interop/Cxx/stdlib/foundation-and-std-module.swift new file mode 100644 index 0000000000000..8dcc93b45c710 --- /dev/null +++ b/test/Interop/Cxx/stdlib/foundation-and-std-module.swift @@ -0,0 +1,29 @@ +// RUN: %empty-directory(%t) +// RUN: %target-swift-frontend %s -c -enable-experimental-cxx-interop -Xcc -std=c++14 -Xcc -fmodules-cache-path=%t +// RUN: %target-swift-frontend %s -c -enable-experimental-cxx-interop -Xcc -std=c++17 -Xcc -fmodules-cache-path=%t +// RUN: %target-swift-frontend %s -c -enable-experimental-cxx-interop -Xcc -std=c++20 -Xcc -fmodules-cache-path=%t + +// RUN: find %t | %FileCheck %s + +// RUN: %empty-directory(%t) + +// RUN: %target-swift-frontend %s -c -enable-experimental-cxx-interop -Xcc -std=c++17 -Xcc -fmodules-cache-path=%t -DADD_CXXSTDLIB +// RUN: %target-swift-frontend %s -c -enable-experimental-cxx-interop -Xcc -std=c++20 -Xcc -fmodules-cache-path=%t -DADD_CXXSTDLIB + +// REQUIRES: OS=macosx || OS=linux-gnu + +#if canImport(Foundation) +import Foundation +#endif + +#if ADD_CXXSTDLIB +import CxxStdlib +#endif + +func test() { +#if ADD_CXXSTDLIB + let _ = std.string() +#endif +} + +// CHECK: std-{{.*}}.pcm