Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 15be175

Browse files
committed
[API Notes] Look for framework API notes in Headers/PrivateHeaders.
Rather than relying on the addition of a new "top-level" directory within a framework, have frameworks put API notes alongside the headers. (cherry picked from commit 1237d45)
1 parent 37a2480 commit 15be175

File tree

5 files changed

+81
-5
lines changed

5 files changed

+81
-5
lines changed

lib/APINotes/APINotesManager.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,14 +396,20 @@ bool APINotesManager::loadCurrentModuleAPINotes(
396396
};
397397

398398
if (module->IsFramework) {
399-
// For frameworks, we search in the "APINotes" subdirectory.
399+
// For frameworks, we search in the "Headers" or "PrivateHeaders"
400+
// subdirectory.
400401
llvm::SmallString<128> path;
401402
path += module->Directory->getName();
402-
llvm::sys::path::append(path, "APINotes");
403-
if (auto apinotesDir = fileMgr.getDirectory(path)) {
403+
unsigned pathLen = path.size();
404+
405+
llvm::sys::path::append(path, "Headers");
406+
if (auto apinotesDir = fileMgr.getDirectory(path))
404407
tryAPINotes(apinotesDir, /*wantPublic=*/true);
405-
tryAPINotes(apinotesDir, /*wantPublic=*/false);
406-
}
408+
409+
path.resize(pathLen);
410+
llvm::sys::path::append(path, "PrivateHeaders");
411+
if (auto privateAPINotesDir = fileMgr.getDirectory(path))
412+
tryAPINotes(privateAPINotesDir, /*wantPublic=*/false);
407413
} else {
408414
tryAPINotes(module->Directory, /*wantPublic=*/true);
409415
tryAPINotes(module->Directory, /*wantPublic=*/false);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Name: SomeKit
2+
Classes:
3+
- Name: A
4+
Methods:
5+
- Selector: "transform:"
6+
MethodKind: Instance
7+
Availability: none
8+
AvailabilityMsg: "anything but this"
9+
- Selector: "transform:integer:"
10+
MethodKind: Instance
11+
NullabilityOfRet: N
12+
Nullability: [ N, S ]
13+
Properties:
14+
- Name: intValue
15+
PropertyKind: Instance
16+
Availability: none
17+
AvailabilityMsg: "wouldn't work anyway"
18+
- Name: nonnullAInstance
19+
PropertyKind: Instance
20+
Nullability: N
21+
- Name: nonnullAClass
22+
PropertyKind: Class
23+
Nullability: N
24+
- Name: nonnullABoth
25+
Nullability: N
26+
- Name: B
27+
Availability: none
28+
AvailabilityMsg: "just don't"
29+
- Name: C
30+
Methods:
31+
- Selector: "initWithA:"
32+
MethodKind: Instance
33+
DesignatedInit: true
34+
SwiftVersions:
35+
- Version: 3.0
36+
Classes:
37+
- Name: A
38+
Methods:
39+
- Selector: "transform:integer:"
40+
MethodKind: Instance
41+
NullabilityOfRet: O
42+
Nullability: [ O, S ]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@interface A(ExplicitNullabilityProperties)
2+
@property (nonatomic, readwrite, retain, nonnull) A *explicitNonnullInstance;
3+
@property (nonatomic, readwrite, retain, nullable) A *explicitNullableInstance;
4+
@end
5+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Name: SomeKit
2+
Classes:
3+
- Name: A
4+
Methods:
5+
- Selector: "privateTransform:input:"
6+
MethodKind: Instance
7+
NullabilityOfRet: N
8+
Nullability: [ N, S ]
9+
Properties:
10+
- Name: internalProperty
11+
Nullability: N
12+
Protocols:
13+
- Name: InternalProtocol
14+
Availability: none
15+
AvailabilityMsg: "not for you"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Name: SomeOtherKit
2+
Classes:
3+
- Name: A
4+
Methods:
5+
- Selector: "methodA"
6+
MethodKind: Instance
7+
Availability: none
8+
AvailabilityMsg: "anything but this"

0 commit comments

Comments
 (0)