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

Commit a8b724e

Browse files
committed
Merge remote-tracking branch 'origin/swift-5.0-branch' into stable
2 parents caa7676 + dd92bf3 commit a8b724e

File tree

16 files changed

+54
-8
lines changed

16 files changed

+54
-8
lines changed

lib/APINotes/APINotesManager.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@ static void checkPrivateAPINotesName(DiagnosticsEngine &diags,
245245
diags.Report(SourceLocation(), diagID) << module->Name << realFilename;
246246
}
247247

248+
/// \returns true if any of \p module's immediate submodules are defined in a
249+
/// private module map
250+
static bool hasPrivateSubmodules(const Module *module) {
251+
return llvm::any_of(module->submodules(), [](const Module *submodule) {
252+
return submodule->ModuleMapIsPrivate;
253+
});
254+
}
255+
248256
bool APINotesManager::loadCurrentModuleAPINotes(
249257
const Module *module,
250258
bool lookInModule,
@@ -281,7 +289,7 @@ bool APINotesManager::loadCurrentModuleAPINotes(
281289
//
282290
// Public modules:
283291
// - Headers/Foo.apinotes
284-
// - PrivateHeaders/Foo_private.apinotes
292+
// - PrivateHeaders/Foo_private.apinotes (if there are private submodules)
285293
// Private modules:
286294
// - PrivateHeaders/Bar.apinotes (except that 'Bar' probably already has
287295
// the word "Private" in it in practice)
@@ -298,20 +306,22 @@ bool APINotesManager::loadCurrentModuleAPINotes(
298306
path.resize(pathLen);
299307
}
300308

301-
llvm::sys::path::append(path, "PrivateHeaders");
302-
if (auto privateAPINotesDir = fileMgr.getDirectory(path)) {
303-
tryAPINotes(privateAPINotesDir,
304-
/*wantPublic=*/module->ModuleMapIsPrivate);
309+
if (module->ModuleMapIsPrivate || hasPrivateSubmodules(module)) {
310+
llvm::sys::path::append(path, "PrivateHeaders");
311+
if (auto privateAPINotesDir = fileMgr.getDirectory(path)) {
312+
tryAPINotes(privateAPINotesDir,
313+
/*wantPublic=*/module->ModuleMapIsPrivate);
314+
}
305315
}
306316
} else {
307317
// Public modules:
308318
// - Foo.apinotes
309-
// - Foo_private.apinotes
319+
// - Foo_private.apinotes (if there are private submodules)
310320
// Private modules:
311321
// - Bar.apinotes (except that 'Bar' probably already has the word
312322
// "Private" in it in practice)
313323
tryAPINotes(module->Directory, /*wantPublic=*/true);
314-
if (!module->ModuleMapIsPrivate)
324+
if (!module->ModuleMapIsPrivate && hasPrivateSubmodules(module))
315325
tryAPINotes(module->Directory, /*wantPublic=*/false);
316326
}
317327

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extern int FrameworkWithActualPrivateModule;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
framework module FrameworkWithActualPrivateModule {
2+
umbrella header "FrameworkWithActualPrivateModule.h"
3+
export *
4+
module * { export * }
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
framework module FrameworkWithActualPrivateModule_Private {
2+
umbrella header "FrameworkWithActualPrivateModule_Private.h"
3+
export *
4+
module * { export * }
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Name: FrameworkWithActualPrivateModule_Private
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include <FrameworkWithActualPrivateModule/FrameworkWithActualPrivateModule.h>
2+
extern int FrameworkWithActualPrivateModule_Private;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extern int FrameworkWithWrongCase;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
framework module FrameworkWithWrongCase {
2+
umbrella header "FrameworkWithWrongCase.h"
3+
export *
4+
module * { export * }
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Name: FrameworkWithWrongCase
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module FrameworkWithWrongCasePrivate.Inner {}

0 commit comments

Comments
 (0)