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 @@ -2982,8 +2982,17 @@ namespace {
29822982 decl->getIdentifier () &&
29832983 (decl->getName () == " tzdb" || decl->getName () == " time_zone_link" ||
29842984 decl->getName () == " __compressed_pair" ||
2985+ decl->getName () == " __optional_copy_assign_base" || // libc++
2986+ decl->getName () == " __optional_move_assign_base" || // libc++
29852987 decl->getName () == " time_zone" ))
29862988 return nullptr ;
2989+ // Bail if this is one of the base types of std::optional. Those types are
2990+ // mixins that are not designed to be used directly.
2991+ if (decl->getDeclContext ()->isNamespace () && decl->isInStdNamespace () &&
2992+ decl->getIdentifier () &&
2993+ (decl->getName () == " _Optional_payload_base" ||
2994+ decl->getName () == " _Optional_payload" ))
2995+ return nullptr ;
29872996
29882997 auto &clangSema = Impl.getClangSema ();
29892998 // Make Clang define any implicit constructors it may need (copy,
Original file line number Diff line number Diff line change 77using StdOptionalInt = std::optional<int >;
88using StdOptionalString = std::optional<std::string>;
99
10+ struct HasDeletedCopyCtor {
11+ int value;
12+ HasDeletedCopyCtor (int value) : value(value) {}
13+ HasDeletedCopyCtor (const HasDeletedCopyCtor &other) = delete ;
14+ HasDeletedCopyCtor (HasDeletedCopyCtor &&other) = default ;
15+ };
16+ using StdOptionalHasDeletedCopyCtor = std::optional<HasDeletedCopyCtor>;
17+
1018inline StdOptionalInt getNonNilOptional () { return {123 }; }
1119
1220inline StdOptionalInt getNilOptional () { return {std::nullopt }; }
1321
22+ inline StdOptionalHasDeletedCopyCtor getNonNilOptionalHasDeletedCopyCtor () {
23+ return StdOptionalHasDeletedCopyCtor (HasDeletedCopyCtor (654 ));
24+ }
25+
1426inline bool takesOptionalInt (std::optional<int > arg) { return (bool )arg; }
1527inline bool takesOptionalString (std::optional<std::string> arg) { return (bool )arg; }
28+ inline bool takesOptionalHasDeletedCopyCtor (std::optional<HasDeletedCopyCtor> arg) { return (bool )arg; }
1629
1730#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_OPTIONAL_H
Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ StdOptionalTestSuite.test("pointee") {
2121 modifiedOpt. pointee = 777
2222 expectEqual ( 777 , modifiedOpt. pointee)
2323#endif
24+
25+ let nonNilOptNonCopyable = getNonNilOptionalHasDeletedCopyCtor ( )
26+ expectEqual ( 654 , nonNilOptNonCopyable. pointee. value)
2427}
2528
2629StdOptionalTestSuite . test ( " std::optional => Swift.Optional " ) {
You can’t perform that action at this time.
0 commit comments