Skip to content

Commit eeefe6e

Browse files
committed
---
yaml --- r: 319230 b: refs/heads/master-rebranch c: 672b3f6 h: refs/heads/master
1 parent cc37424 commit eeefe6e

24 files changed

+374
-321
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,4 +1457,4 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14571457
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14581458
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14591459
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1460-
refs/heads/master-rebranch: 103ad49e39ff1dc9ef36492e902b998d236c0e71
1460+
refs/heads/master-rebranch: 672b3f6d83206c3bc4a77ee4b95159b81f95426e

branches/master-rebranch/include/swift/AST/DiagnosticsSema.def

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3986,8 +3986,9 @@ ERROR(dynamic_replacement_replaced_constructor_is_not_convenience, none,
39863986
//------------------------------------------------------------------------------
39873987

39883988
ERROR(availability_decl_unavailable, none,
3989-
"%select{getter for |setter for |}0%1 is unavailable",
3990-
(unsigned, DeclName))
3989+
"%select{getter for |setter for |}0%1 is unavailable"
3990+
"%select{ in %3|}2",
3991+
(unsigned, DeclName, bool, StringRef))
39913992

39923993
#define REPLACEMENT_DECL_KIND_SELECT "select{| instance method| property}"
39933994
ERROR(availability_decl_unavailable_rename, none,
@@ -4003,16 +4004,9 @@ ERROR(availability_decl_unavailable_rename_msg, none,
40034004
(unsigned, DeclName, bool, unsigned, StringRef, StringRef))
40044005

40054006
ERROR(availability_decl_unavailable_msg, none,
4006-
"%select{getter for |setter for |}0%1 is unavailable: %2",
4007-
(unsigned, DeclName, StringRef))
4008-
4009-
ERROR(availability_decl_unavailable_in_swift, none,
4010-
"%select{getter for |setter for |}0%1 is unavailable in Swift",
4011-
(unsigned, DeclName))
4012-
4013-
ERROR(availability_decl_unavailable_in_swift_msg, none,
4014-
"%select{getter for |setter for |}0%1 is unavailable in Swift: %2",
4015-
(unsigned, DeclName, StringRef))
4007+
"%select{getter for |setter for |}0%1 is unavailable"
4008+
"%select{ in %3|}2: %4",
4009+
(unsigned, DeclName, bool, StringRef, StringRef))
40164010

40174011
NOTE(availability_marked_unavailable, none,
40184012
"%select{getter for |setter for |}0%1 has been explicitly marked "
@@ -4028,18 +4022,18 @@ NOTE(availability_obsoleted, none,
40284022

40294023
WARNING(availability_deprecated, none,
40304024
"%select{getter for |setter for |}0%1 %select{is|%select{is|was}4}2 "
4031-
"deprecated%select{| %select{on|in}4 %3%select{| %5}4}2",
4025+
"deprecated%select{| in %3%select{| %5}4}2",
40324026
(unsigned, DeclName, bool, StringRef, bool, llvm::VersionTuple))
40334027

40344028
WARNING(availability_deprecated_msg, none,
40354029
"%select{getter for |setter for |}0%1 %select{is|%select{is|was}4}2 "
4036-
"deprecated%select{| %select{on|in}4 %3%select{| %5}4}2: %6",
4030+
"deprecated%select{| in %3%select{| %5}4}2: %6",
40374031
(unsigned, DeclName, bool, StringRef, bool, llvm::VersionTuple,
40384032
StringRef))
40394033

40404034
WARNING(availability_deprecated_rename, none,
40414035
"%select{getter for |setter for |}0%1 %select{is|%select{is|was}4}2 "
4042-
"deprecated%select{| %select{on|in}4 %3%select{| %5}4}2: "
4036+
"deprecated%select{| in %3%select{| %5}4}2: "
40434037
"%select{renamed to|replaced by}6%" REPLACEMENT_DECL_KIND_SELECT "7 "
40444038
"'%8'",
40454039
(unsigned, DeclName, bool, StringRef, bool, llvm::VersionTuple, bool,
@@ -4056,7 +4050,7 @@ NOTE(availability_decl_more_than_enclosing_enclosing_here, none,
40564050
"enclosing scope here", ())
40574051

40584052
ERROR(availability_decl_only_version_newer, none,
4059-
"%0 is only available on %1 %2 or newer",
4053+
"%0 is only available in %1 %2 or newer",
40604054
(DeclName, StringRef, llvm::VersionTuple))
40614055

40624056
NOTE(availability_guard_with_version_check, none,
@@ -4066,13 +4060,13 @@ NOTE(availability_add_attribute, none,
40664060
"add @available attribute to enclosing %0", (DescriptiveDeclKind))
40674061

40684062
ERROR(availability_accessor_only_version_newer, none,
4069-
"%select{getter|setter}0 for %1 is only available on %2 %3"
4063+
"%select{getter|setter}0 for %1 is only available in %2 %3"
40704064
" or newer",
40714065
(/*AccessorKind*/unsigned, DeclName, StringRef, llvm::VersionTuple))
40724066

40734067
ERROR(availability_inout_accessor_only_version_newer, none,
40744068
"cannot pass as inout because %select{getter|setter}0 for %1 is only "
4075-
"available on %2 %3 or newer",
4069+
"available in %2 %3 or newer",
40764070
(/*AccessorKind*/unsigned, DeclName, StringRef, llvm::VersionTuple))
40774071

40784072
ERROR(availability_query_required_for_platform, none,
@@ -4094,7 +4088,7 @@ ERROR(availability_stored_property_no_potential,
40944088
"'@available'", ())
40954089

40964090
ERROR(availability_protocol_requires_version,
4097-
none, "protocol %0 requires %1 to be available on %2 %3 and newer",
4091+
none, "protocol %0 requires %1 to be available in %2 %3 and newer",
40984092
(DeclName, DeclName, StringRef, llvm::VersionTuple))
40994093

41004094
NOTE(availability_protocol_requirement_here, none,

branches/master-rebranch/include/swift/AST/PlatformKind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ StringRef platformString(PlatformKind platform);
4141
Optional<PlatformKind> platformFromString(StringRef Name);
4242

4343
/// Returns a human-readable version of the platform name as a string, suitable
44-
/// for emission in diagnostics (e.g., "OS X").
44+
/// for emission in diagnostics (e.g., "macOS").
4545
StringRef prettyPlatformString(PlatformKind platform);
4646

4747
/// Returns whether the passed-in platform is active, given the language

branches/master-rebranch/include/swift/AST/PlatformKinds.def

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
AVAILABILITY_PLATFORM(iOS, "iOS")
2626
AVAILABILITY_PLATFORM(tvOS, "tvOS")
2727
AVAILABILITY_PLATFORM(watchOS, "watchOS")
28-
AVAILABILITY_PLATFORM(OSX, "OS X")
29-
AVAILABILITY_PLATFORM(iOSApplicationExtension, "iOS application extension")
30-
AVAILABILITY_PLATFORM(tvOSApplicationExtension, "tvOS application extension")
31-
AVAILABILITY_PLATFORM(watchOSApplicationExtension, "watchOS application extension")
32-
AVAILABILITY_PLATFORM(OSXApplicationExtension, "OS X application extension")
28+
AVAILABILITY_PLATFORM(OSX, "macOS")
29+
AVAILABILITY_PLATFORM(iOSApplicationExtension, "application extensions for iOS")
30+
AVAILABILITY_PLATFORM(tvOSApplicationExtension, "application extensions for tvOS")
31+
AVAILABILITY_PLATFORM(watchOSApplicationExtension, "application extensions for watchOS")
32+
AVAILABILITY_PLATFORM(OSXApplicationExtension, "application extensions for macOS")
3333

3434
#undef AVAILABILITY_PLATFORM

branches/master-rebranch/include/swift/Serialization/ModuleFormat.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5252
/// describe what change you made. The content of this comment isn't important;
5353
/// it just ensures a conflict if two people change the module format.
5454
/// Don't worry about adhering to the 80-column limit for this line.
55-
const uint16_t SWIFTMODULE_VERSION_MINOR = 489; // backing variables
55+
const uint16_t SWIFTMODULE_VERSION_MINOR = 490; // dependency directories
5656

5757
using DeclIDField = BCFixed<31>;
5858

@@ -644,6 +644,7 @@ namespace input_block {
644644
MODULE_FLAGS, // [unused]
645645
SEARCH_PATH,
646646
FILE_DEPENDENCY,
647+
DEPENDENCY_DIRECTORY,
647648
PARSEABLE_INTERFACE_PATH
648649
};
649650

@@ -689,9 +690,15 @@ namespace input_block {
689690
FileModTimeOrContentHashField, // mtime or content hash (for validation)
690691
BCFixed<1>, // are we reading mtime (0) or hash (1)?
691692
BCFixed<1>, // SDK-relative?
693+
BCVBR<8>, // subpath-relative index (0=none)
692694
BCBlob // path
693695
>;
694696

697+
using DependencyDirectoryLayout = BCRecordLayout<
698+
DEPENDENCY_DIRECTORY,
699+
BCBlob
700+
>;
701+
695702
using ParseableInterfaceLayout = BCRecordLayout<
696703
PARSEABLE_INTERFACE_PATH,
697704
BCBlob // file path

branches/master-rebranch/lib/Sema/TypeCheckAvailability.cpp

Lines changed: 62 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,64 +2114,74 @@ bool swift::diagnoseExplicitUnavailability(
21142114

21152115
ASTContext &ctx = D->getASTContext();
21162116
auto &diags = ctx.Diags;
2117+
2118+
StringRef platform;
21172119
switch (Attr->getPlatformAgnosticAvailability()) {
21182120
case PlatformAgnosticAvailabilityKind::Deprecated:
2119-
break;
2121+
llvm_unreachable("shouldn't see deprecations in explicit unavailability");
21202122

21212123
case PlatformAgnosticAvailabilityKind::None:
21222124
case PlatformAgnosticAvailabilityKind::Unavailable:
2125+
if (Attr->Platform != PlatformKind::none) {
2126+
// This was platform-specific; indicate the platform.
2127+
platform = Attr->prettyPlatformString();
2128+
break;
2129+
}
2130+
LLVM_FALLTHROUGH;
2131+
21232132
case PlatformAgnosticAvailabilityKind::SwiftVersionSpecific:
21242133
case PlatformAgnosticAvailabilityKind::PackageDescriptionVersionSpecific:
2125-
case PlatformAgnosticAvailabilityKind::UnavailableInSwift: {
2126-
bool inSwift = (Attr->getPlatformAgnosticAvailability() ==
2127-
PlatformAgnosticAvailabilityKind::UnavailableInSwift);
2128-
2129-
if (!Attr->Rename.empty()) {
2130-
SmallString<32> newNameBuf;
2131-
Optional<ReplacementDeclKind> replaceKind =
2132-
describeRename(ctx, Attr, D, newNameBuf);
2133-
unsigned rawReplaceKind = static_cast<unsigned>(
2134-
replaceKind.getValueOr(ReplacementDeclKind::None));
2135-
StringRef newName = replaceKind ? newNameBuf.str() : Attr->Rename;
2136-
2137-
if (Attr->Message.empty()) {
2138-
auto diag = diags.diagnose(Loc,
2139-
diag::availability_decl_unavailable_rename,
2140-
RawAccessorKind, Name,
2141-
replaceKind.hasValue(),
2142-
rawReplaceKind, newName);
2143-
attachRenameFixIts(diag);
2144-
} else {
2145-
EncodedDiagnosticMessage EncodedMessage(Attr->Message);
2146-
auto diag =
2147-
diags.diagnose(Loc, diag::availability_decl_unavailable_rename_msg,
2148-
RawAccessorKind, Name, replaceKind.hasValue(),
2149-
rawReplaceKind, newName, EncodedMessage.Message);
2150-
attachRenameFixIts(diag);
2151-
}
2152-
} else if (isSubscriptReturningString(D, ctx)) {
2153-
diags.diagnose(Loc, diag::availabilty_string_subscript_migration)
2154-
.highlight(R)
2155-
.fixItInsert(R.Start, "String(")
2156-
.fixItInsertAfter(R.End, ")");
2134+
// We don't want to give further detail about these.
2135+
platform = "";
2136+
break;
21572137

2158-
// Skip the note emitted below.
2159-
return true;
2160-
} else if (Attr->Message.empty()) {
2161-
diags.diagnose(Loc, inSwift ? diag::availability_decl_unavailable_in_swift
2162-
: diag::availability_decl_unavailable,
2163-
RawAccessorKind, Name)
2164-
.highlight(R);
2165-
} else {
2166-
EncodedDiagnosticMessage EncodedMessage(Attr->Message);
2167-
diags.diagnose(Loc,
2168-
inSwift ? diag::availability_decl_unavailable_in_swift_msg
2169-
: diag::availability_decl_unavailable_msg,
2170-
RawAccessorKind, Name, EncodedMessage.Message)
2171-
.highlight(R);
2172-
}
2138+
case PlatformAgnosticAvailabilityKind::UnavailableInSwift:
2139+
// This API is explicitly unavailable in Swift.
2140+
platform = "Swift";
21732141
break;
21742142
}
2143+
2144+
if (!Attr->Rename.empty()) {
2145+
SmallString<32> newNameBuf;
2146+
Optional<ReplacementDeclKind> replaceKind =
2147+
describeRename(ctx, Attr, D, newNameBuf);
2148+
unsigned rawReplaceKind = static_cast<unsigned>(
2149+
replaceKind.getValueOr(ReplacementDeclKind::None));
2150+
StringRef newName = replaceKind ? newNameBuf.str() : Attr->Rename;
2151+
2152+
if (Attr->Message.empty()) {
2153+
auto diag = diags.diagnose(Loc,
2154+
diag::availability_decl_unavailable_rename,
2155+
RawAccessorKind, Name,
2156+
replaceKind.hasValue(),
2157+
rawReplaceKind, newName);
2158+
attachRenameFixIts(diag);
2159+
} else {
2160+
EncodedDiagnosticMessage EncodedMessage(Attr->Message);
2161+
auto diag =
2162+
diags.diagnose(Loc, diag::availability_decl_unavailable_rename_msg,
2163+
RawAccessorKind, Name, replaceKind.hasValue(),
2164+
rawReplaceKind, newName, EncodedMessage.Message);
2165+
attachRenameFixIts(diag);
2166+
}
2167+
} else if (isSubscriptReturningString(D, ctx)) {
2168+
diags.diagnose(Loc, diag::availabilty_string_subscript_migration)
2169+
.highlight(R)
2170+
.fixItInsert(R.Start, "String(")
2171+
.fixItInsertAfter(R.End, ")");
2172+
2173+
// Skip the note emitted below.
2174+
return true;
2175+
} else if (Attr->Message.empty()) {
2176+
diags.diagnose(Loc, diag::availability_decl_unavailable,
2177+
RawAccessorKind, Name, platform.empty(), platform)
2178+
.highlight(R);
2179+
} else {
2180+
EncodedDiagnosticMessage EncodedMessage(Attr->Message);
2181+
diags.diagnose(Loc, diag::availability_decl_unavailable_msg,
2182+
RawAccessorKind, Name, platform.empty(), platform,
2183+
EncodedMessage.Message)
2184+
.highlight(R);
21752185
}
21762186

21772187
switch (Attr->getVersionAvailability(ctx)) {
@@ -2205,7 +2215,7 @@ bool swift::diagnoseExplicitUnavailability(
22052215
} else if (Attr->isPackageDescriptionVersionSpecific()) {
22062216
platformDisplayString = "PackageDescription";
22072217
} else {
2208-
platformDisplayString = Attr->prettyPlatformString();
2218+
platformDisplayString = platform;
22092219
}
22102220

22112221
diags.diagnose(D, diag::availability_obsoleted,
@@ -2642,7 +2652,7 @@ AvailabilityWalker::diagnoseIncDecRemoval(const ValueDecl *D, SourceRange R,
26422652

26432653
// If we emit a deprecation diagnostic, produce a fixit hint as well.
26442654
auto diag = TC.diagnose(R.Start, diag::availability_decl_unavailable_msg,
2645-
RawAccessorKind, Name,
2655+
RawAccessorKind, Name, true, "",
26462656
"it has been removed in Swift 3");
26472657
if (isa<PrefixUnaryExpr>(call)) {
26482658
// Prefix: remove the ++ or --.
@@ -2693,7 +2703,8 @@ AvailabilityWalker::diagnoseMemoryLayoutMigration(const ValueDecl *D,
26932703

26942704
EncodedDiagnosticMessage EncodedMessage(Attr->Message);
26952705
auto diag = TC.diagnose(R.Start, diag::availability_decl_unavailable_msg,
2696-
RawAccessorKind, Name, EncodedMessage.Message);
2706+
RawAccessorKind, Name, true, "",
2707+
EncodedMessage.Message);
26972708
diag.highlight(R);
26982709

26992710
auto subject = args->getSubExpr();

branches/master-rebranch/lib/Serialization/ModuleFile.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ validateControlBlock(llvm::BitstreamCursor &cursor,
239239
static bool validateInputBlock(
240240
llvm::BitstreamCursor &cursor, SmallVectorImpl<uint64_t> &scratch,
241241
SmallVectorImpl<SerializationOptions::FileDependency> &dependencies) {
242+
SmallVector<StringRef, 4> dependencyDirectories;
243+
SmallString<256> dependencyFullPathBuffer;
244+
242245
while (!cursor.AtEndOfStream()) {
243246
auto entry = cursor.advance();
244247
if (entry.Kind == llvm::BitstreamEntry::EndBlock)
@@ -255,17 +258,30 @@ static bool validateInputBlock(
255258
bool isHashBased = scratch[2] != 0;
256259
bool isSDKRelative = scratch[3] != 0;
257260

261+
StringRef path = blobData;
262+
size_t directoryIndex = scratch[4];
263+
if (directoryIndex != 0) {
264+
if (directoryIndex > dependencyDirectories.size())
265+
return true;
266+
dependencyFullPathBuffer = dependencyDirectories[directoryIndex-1];
267+
llvm::sys::path::append(dependencyFullPathBuffer, blobData);
268+
path = dependencyFullPathBuffer;
269+
}
270+
258271
if (isHashBased) {
259272
dependencies.push_back(
260273
SerializationOptions::FileDependency::hashBased(
261-
blobData, isSDKRelative, scratch[0], scratch[1]));
274+
path, isSDKRelative, scratch[0], scratch[1]));
262275
} else {
263276
dependencies.push_back(
264277
SerializationOptions::FileDependency::modTimeBased(
265-
blobData, isSDKRelative, scratch[0], scratch[1]));
278+
path, isSDKRelative, scratch[0], scratch[1]));
266279
}
267280
break;
268281
}
282+
case input_block::DEPENDENCY_DIRECTORY:
283+
dependencyDirectories.push_back(blobData);
284+
break;
269285
default:
270286
// Unknown metadata record, possibly for use by a future version of the
271287
// module format.

branches/master-rebranch/lib/Serialization/Serialization.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ void Serializer::writeBlockInfoBlock() {
835835
BLOCK_RECORD(input_block, MODULE_FLAGS);
836836
BLOCK_RECORD(input_block, SEARCH_PATH);
837837
BLOCK_RECORD(input_block, FILE_DEPENDENCY);
838+
BLOCK_RECORD(input_block, DEPENDENCY_DIRECTORY);
838839
BLOCK_RECORD(input_block, PARSEABLE_INTERFACE_PATH);
839840

840841
BLOCK(DECLS_AND_TYPES_BLOCK);
@@ -1062,6 +1063,7 @@ void Serializer::writeInputBlock(const SerializationOptions &options) {
10621063
input_block::ImportedHeaderContentsLayout ImportedHeaderContents(Out);
10631064
input_block::SearchPathLayout SearchPath(Out);
10641065
input_block::FileDependencyLayout FileDependency(Out);
1066+
input_block::DependencyDirectoryLayout DependencyDirectory(Out);
10651067
input_block::ParseableInterfaceLayout ParseableInterface(Out);
10661068

10671069
if (options.SerializeOptionsForDebugging) {
@@ -1075,13 +1077,24 @@ void Serializer::writeInputBlock(const SerializationOptions &options) {
10751077
SearchPath.emit(ScratchRecord, /*framework=*/false, /*system=*/false, path);
10761078
}
10771079

1080+
// Note: We're not using StringMap here because we don't need to own the
1081+
// strings.
1082+
llvm::DenseMap<StringRef, unsigned> dependencyDirectories;
10781083
for (auto const &dep : options.Dependencies) {
1084+
StringRef directoryName = llvm::sys::path::parent_path(dep.getPath());
1085+
unsigned &dependencyDirectoryIndex = dependencyDirectories[directoryName];
1086+
if (!dependencyDirectoryIndex) {
1087+
// This name must be newly-added. Give it a new ID (and skip 0).
1088+
dependencyDirectoryIndex = dependencyDirectories.size();
1089+
DependencyDirectory.emit(ScratchRecord, directoryName);
1090+
}
10791091
FileDependency.emit(ScratchRecord,
10801092
dep.getSize(),
10811093
getRawModTimeOrHash(dep),
10821094
dep.isHashBased(),
10831095
dep.isSDKRelative(),
1084-
dep.getPath());
1096+
dependencyDirectoryIndex,
1097+
llvm::sys::path::filename(dep.getPath()));
10851098
}
10861099

10871100
if (!options.ParseableInterface.empty())

0 commit comments

Comments
 (0)