Skip to content

Commit 3a90828

Browse files
authored
Merge pull request #70210 from apple/egorzhdan/apinotes-std-owned
[cxx-interop] Use APINotes to apply `import_owned` attr to `std::string` and `std::vector`
2 parents a7a0b32 + c39c8da commit 3a90828

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6956,12 +6956,6 @@ static bool isForeignReferenceType(const clang::QualType type) {
69566956
}
69576957

69586958
static bool hasOwnedValueAttr(const clang::RecordDecl *decl) {
6959-
// Hard-coded special cases from the standard library (this will go away once
6960-
// API notes support namespaces).
6961-
if (decl->getNameAsString() == "basic_string" ||
6962-
decl->getNameAsString() == "vector")
6963-
return true;
6964-
69656959
return decl->hasAttrs() && llvm::any_of(decl->getAttrs(), [](auto *attr) {
69666960
if (auto swiftAttr = dyn_cast<clang::SwiftAttrAttr>(attr))
69676961
return swiftAttr->getAttribute() == "import_owned";

stdlib/public/Cxx/std/std.apinotes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ Functions:
66
- Name: div
77
Availability: nonswift
88
AvailabilityMsg: Use the C standard library function
9+
Namespaces:
10+
- Name: std
11+
Tags:
12+
- Name: basic_string
13+
SwiftImportAs: owned
14+
- Name: vector
15+
SwiftImportAs: owned

0 commit comments

Comments
 (0)