File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -3026,8 +3026,17 @@ namespace {
3026
3026
decl->getIdentifier () &&
3027
3027
(decl->getName () == " tzdb" || decl->getName () == " time_zone_link" ||
3028
3028
decl->getName () == " __compressed_pair" ||
3029
+ decl->getName () == " __optional_copy_assign_base" || // libc++
3030
+ decl->getName () == " __optional_move_assign_base" || // libc++
3029
3031
decl->getName () == " time_zone" ))
3030
3032
return nullptr ;
3033
+ // Bail if this is one of the base types of std::optional. Those types are
3034
+ // mixins that are not designed to be used directly.
3035
+ if (decl->getDeclContext ()->isNamespace () && decl->isInStdNamespace () &&
3036
+ decl->getIdentifier () &&
3037
+ (decl->getName () == " _Optional_payload_base" ||
3038
+ decl->getName () == " _Optional_payload" ))
3039
+ return nullptr ;
3031
3040
3032
3041
auto &clangSema = Impl.getClangSema ();
3033
3042
// Make Clang define any implicit constructors it may need (copy,
Original file line number Diff line number Diff line change @@ -17,6 +17,14 @@ struct HasConstexprCtor {
17
17
};
18
18
using StdOptionalHasConstexprCtor = std::optional<HasConstexprCtor>;
19
19
20
+ struct HasDeletedCopyCtor {
21
+ int value;
22
+ HasDeletedCopyCtor (int value) : value(value) {}
23
+ HasDeletedCopyCtor (const HasDeletedCopyCtor &other) = delete ;
24
+ HasDeletedCopyCtor (HasDeletedCopyCtor &&other) = default ;
25
+ };
26
+ using StdOptionalHasDeletedCopyCtor = std::optional<HasDeletedCopyCtor>;
27
+
20
28
struct HasDeletedMoveCtor {
21
29
int value;
22
30
HasDeletedMoveCtor (int value) : value(value) {}
@@ -29,7 +37,12 @@ inline StdOptionalInt getNonNilOptional() { return {123}; }
29
37
30
38
inline StdOptionalInt getNilOptional () { return {std::nullopt }; }
31
39
40
+ inline StdOptionalHasDeletedCopyCtor getNonNilOptionalHasDeletedCopyCtor () {
41
+ return StdOptionalHasDeletedCopyCtor (HasDeletedCopyCtor (654 ));
42
+ }
43
+
32
44
inline bool takesOptionalInt (std::optional<int > arg) { return (bool )arg; }
33
45
inline bool takesOptionalString (std::optional<std::string> arg) { return (bool )arg; }
46
+ inline bool takesOptionalHasDeletedCopyCtor (std::optional<HasDeletedCopyCtor> arg) { return (bool )arg; }
34
47
35
48
#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_OPTIONAL_H
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ StdOptionalTestSuite.test("pointee") {
25
25
modifiedOpt. pointee = 777
26
26
expectEqual ( 777 , modifiedOpt. pointee)
27
27
#endif
28
+
29
+ let nonNilOptNonCopyable = getNonNilOptionalHasDeletedCopyCtor ( )
30
+ expectEqual ( 654 , nonNilOptNonCopyable. pointee. value)
28
31
}
29
32
30
33
StdOptionalTestSuite . test ( " std::optional => Swift.Optional " ) {
You can’t perform that action at this time.
0 commit comments