Skip to content

Commit 9f34fa3

Browse files
authored
Merge pull request #62148 from xymus/library-level-ipi-intro
[Sema] Accept and store the IPI library-level
2 parents f352537 + a926b05 commit 9f34fa3

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ERROR(error_upcoming_feature_on_by_default, none,
4646

4747
ERROR(error_unknown_library_level, none,
4848
"unknown library level '%0', "
49-
"expected one of 'api', 'spi' or 'other'", (StringRef))
49+
"expected one of 'api', 'spi', 'ipi', or 'other'", (StringRef))
5050

5151
ERROR(error_unknown_require_explicit_availability, none,
5252
"unknown argument '%0', passed to -require-explicit-availability, "

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ namespace swift {
8585
/// all decls in the module are considered to be SPI including public ones.
8686
SPI,
8787

88+
/// Internal Programming Interface that is not distributed and only usable
89+
/// from within a project.
90+
IPI,
91+
8892
/// The library has some other undefined distribution.
8993
Other
9094
};

lib/Frontend/CompilerInvocation.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -720,17 +720,15 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
720720
Opts.LibraryLevel = LibraryLevel::API;
721721
} else if (contents == "spi") {
722722
Opts.LibraryLevel = LibraryLevel::SPI;
723+
} else if (contents == "ipi") {
724+
Opts.LibraryLevel = LibraryLevel::IPI;
723725
} else {
724726
Opts.LibraryLevel = LibraryLevel::Other;
725727
if (contents != "other") {
726728
// Error on unknown library levels.
727-
auto inFlight = Diags.diagnose(SourceLoc(),
728-
diag::error_unknown_library_level,
729-
contents);
730-
731-
// Only warn for "ipi" as we may use it in the future.
732-
if (contents == "ipi")
733-
inFlight.limitBehavior(DiagnosticBehavior::Warning);
729+
Diags.diagnose(SourceLoc(),
730+
diag::error_unknown_library_level,
731+
contents);
734732
}
735733
}
736734
}

test/Sema/implementation-only-import-suggestion.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
// RUN: %target-swift-frontend -typecheck -sdk %t/sdk %t/PublicImports.swift \
3535
// RUN: -F %t/sdk/System/Library/PrivateFrameworks/ -module-cache-path %t \
3636
// RUN: -library-level other -module-name MainLib
37+
// RUN: %target-swift-frontend -typecheck -sdk %t/sdk %t/PublicImports.swift \
38+
// RUN: -F %t/sdk/System/Library/PrivateFrameworks/ -module-cache-path %t \
39+
// RUN: -library-level ipi -module-name MainLib
3740
//--- PublicImports.swift
3841
import PublicSwift
3942
import PrivateSwift // expected-error{{private module 'PrivateSwift' is imported publicly from the public module 'MainLib'}}
@@ -70,7 +73,7 @@ import LocalClang // expected-error{{private module 'LocalClang' is imported pub
7073
/// Test error message on an unknown library level name.
7174
// RUN: not %target-swift-frontend -typecheck %s -library-level ThatsNotALibraryLevel 2>&1 \
7275
// RUN: | %FileCheck %s --check-prefix CHECK-ARG
73-
// CHECK-ARG: error: unknown library level 'ThatsNotALibraryLevel', expected one of 'api', 'spi' or 'other'
76+
// CHECK-ARG: error: unknown library level 'ThatsNotALibraryLevel', expected one of 'api', 'spi', 'ipi', or 'other'
7477

7578
/// Expect no errors in swiftinterfaces.
7679
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.private.swiftinterface) \

0 commit comments

Comments
 (0)