Skip to content

Commit 4fa5803

Browse files
committed
[cxx-interop] Mark *all* iterators as unsafe; update tests accordingly; fix a few remaining tests that use raw pointers.
1 parent 9f35bc5 commit 4fa5803

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6808,9 +6808,8 @@ bool IsSafeUseOfCxxDecl::evaluate(Evaluator &evaluator,
68086808
return true;
68096809

68106810
if (hasIteratorAPIAttr(cxxRecordReturnType) ||
6811-
isIterator(cxxRecordReturnType)) {
6812-
return !parentIsSelfContained;
6813-
}
6811+
isIterator(cxxRecordReturnType))
6812+
return false;
68146813

68156814
// Mark this as safe to help our diganostics down the road.
68166815
if (!cxxRecordReturnType->getDefinition()) {

test/Interop/Cxx/stdlib/overlay/Inputs/custom-sequence.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ struct SimpleCopyAwareSequence {
2424
SimpleCopyAwareSequence(const SimpleCopyAwareSequence &other) { copiesCount++; }
2525
};
2626

27-
struct SimpleArrayWrapper {
27+
struct
28+
__attribute__((swift_attr("import_owned")))
29+
SimpleArrayWrapper {
2830
private:
2931
int a[5] = {10, 20, 30, 40, 50};
3032

@@ -33,7 +35,9 @@ struct SimpleArrayWrapper {
3335
const int *end() const __attribute__((returns_nonnull)) { return &a[5]; }
3436
};
3537

36-
struct SimpleArrayWrapperNullableIterators {
38+
struct
39+
__attribute__((swift_attr("import_owned")))
40+
SimpleArrayWrapperNullableIterators {
3741
private:
3842
int a[5] = {10, 20, 30, 40, 50};
3943

@@ -42,7 +46,9 @@ struct SimpleArrayWrapperNullableIterators {
4246
const int *end() const { return &a[5]; }
4347
};
4448

45-
struct SimpleEmptySequence {
49+
struct
50+
__attribute__((swift_attr("import_owned")))
51+
SimpleEmptySequence {
4652
const int *begin() const { return nullptr; }
4753
const int *end() const { return nullptr; }
4854
};

0 commit comments

Comments
 (0)