Commit 779da64
committed
Fix __split_buffer_pointer_layout compatibility with swift's C++ import
When the swift compiler generates a bridging module for importing C++
symbols, it instantiates all methods of the class template instances
used by the symbols imported from C++. This is because it cannot
determine which methods will be called from swift at that stage. This
means that it may attempt to generate invalid instantiations (due to
missing type traits) that would not be generated in a normal C++ build.
The default constructor of `__split_buffer_pointer_layout` has this
issue because it does not initialize `__alloc_` which may or may not be
a reference depending on the `allocator_type` tempalte parameter.
The initialization of class members that are references is mandatory.
`vector` uses a reference type for the allocator and `deque` does not.
Therefore, only `deque` is allowed to use the default constructor of
`__split_buffer_pointer_layout`.
When the swift compiler's C++ importer generates an instantiation of
`std::vector`, it will also attempt to instantiate the default
constructor of `__split_buffer_pointer_layout`, which fails to compile.
This change fixes the issue by adding a `requires` clause to suppress
the instantiation of the problematic constructor whenever its
instatiation would be invalid.
There are no tests included in this change because the `requires`
statement has no observable effect on pure C++ builds. Test coverage
will be automatically assured downstream in swift-project once it
updates its fork of libc++.1 parent 7afeea4 commit 779da64
2 files changed
+15
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
115 | 120 | | |
116 | 121 | | |
117 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
71 | | - | |
72 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
| |||
0 commit comments