Skip to content

Commit 0e8f1fe

Browse files
---
yaml --- r: 286335 b: refs/heads/master-next c: a0892f9 h: refs/heads/master i: 286333: 12cc95d 286331: 9c6f0fb 286327: 112acd5 286319: 55e486c 286303: 40785a3 286271: 64e9fe5 286207: 3c96a08
1 parent 2b32f7b commit 0e8f1fe

File tree

11 files changed

+310
-131
lines changed

11 files changed

+310
-131
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: a67ffadd758dfc7a0f10a8afde063b8864663208
3-
refs/heads/master-next: 52dc2e6d5b4de055584ea5eb629dcfb05c220b13
3+
refs/heads/master-next: a0892f98b45547b4a353aef5236eff4f958ff498
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/include/swift/AST/DiagnosticsFrontend.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,13 @@ ERROR(invalid_vfs_overlay_file,none,
261261
WARNING(module_interface_scoped_import_unsupported,none,
262262
"scoped imports are not yet supported in module interfaces",
263263
())
264+
WARNING(warn_unsupported_module_interface_swift_version,none,
265+
"module interfaces are only supported with Swift language version 5 "
266+
"or later (currently using -swift-version %0)",
267+
(StringRef))
268+
WARNING(warn_unsupported_module_interface_library_evolution,none,
269+
"module interfaces are only supported with -enable-library-evolution",
270+
())
264271
ERROR(error_extracting_version_from_module_interface,none,
265272
"error extracting version from module interface", ())
266273
ERROR(unsupported_version_of_module_interface,none,

branches/master-next/lib/Demangling/Remangler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,6 +2361,9 @@ void Remangler::mangleOpaqueReturnTypeOf(Node *node) {
23612361
Buffer << "QO";
23622362
}
23632363
void Remangler::mangleOpaqueType(Node *node) {
2364+
SubstitutionEntry entry;
2365+
if (trySubstitution(node, entry)) return;
2366+
23642367
mangle(node->getChild(0));
23652368
auto boundGenerics = node->getChild(2);
23662369
for (unsigned i = 0; i < boundGenerics->getNumChildren(); ++i) {
@@ -2375,6 +2378,8 @@ void Remangler::mangleOpaqueType(Node *node) {
23752378
}
23762379
Buffer << "Qo";
23772380
mangleIndex(node->getChild(1)->getIndex());
2381+
2382+
addSubstitution(entry);
23782383
}
23792384
void Remangler::mangleAccessorFunctionReference(Node *node) {
23802385
unreachable("can't remangle");

branches/master-next/lib/FrontendTool/FrontendTool.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,26 @@ static bool printAsObjCIfNeeded(StringRef outputPath, ModuleDecl *M,
358358
/// \returns true if there were any errors
359359
///
360360
/// \see swift::emitParseableInterface
361-
static bool printParseableInterfaceIfNeeded(StringRef outputPath,
362-
ParseableInterfaceOptions const &Opts,
363-
ModuleDecl *M) {
361+
static bool
362+
printParseableInterfaceIfNeeded(StringRef outputPath,
363+
ParseableInterfaceOptions const &Opts,
364+
LangOptions const &LangOpts,
365+
ModuleDecl *M) {
364366
if (outputPath.empty())
365367
return false;
366-
return withOutputFile(M->getDiags(), outputPath,
368+
369+
DiagnosticEngine &diags = M->getDiags();
370+
if (!LangOpts.isSwiftVersionAtLeast(5)) {
371+
assert(LangOpts.isSwiftVersionAtLeast(4));
372+
diags.diagnose(SourceLoc(),
373+
diag::warn_unsupported_module_interface_swift_version,
374+
LangOpts.isSwiftVersionAtLeast(4, 2) ? "4.2" : "4");
375+
}
376+
if (M->getResilienceStrategy() != ResilienceStrategy::Resilient) {
377+
diags.diagnose(SourceLoc(),
378+
diag::warn_unsupported_module_interface_library_evolution);
379+
}
380+
return withOutputFile(diags, outputPath,
367381
[M, Opts](raw_ostream &out) -> bool {
368382
return swift::emitParseableInterface(out, Opts, M);
369383
});
@@ -921,6 +935,7 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
921935
hadAnyError |= printParseableInterfaceIfNeeded(
922936
Invocation.getParseableInterfaceOutputPathForWholeModule(),
923937
Invocation.getParseableInterfaceOptions(),
938+
Invocation.getLangOptions(),
924939
Instance.getMainModule());
925940
}
926941

branches/master-next/lib/SIL/SILVerifier.cpp

Lines changed: 126 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,130 @@ void verifyKeyPathComponent(SILModule &M,
410410
baseTy = componentTy;
411411
}
412412

413+
/// Check if according to the SIL language model this memory /must only/ be used
414+
/// immutably. Today this is only applied to in_guaranteed arguments and
415+
/// open_existential_addr. We should expand it as needed.
416+
struct ImmutableAddressUseVerifier {
417+
SmallVector<Operand *, 32> worklist;
418+
419+
bool isConsumingOrMutatingApplyUse(Operand *use) {
420+
ApplySite apply(use->getUser());
421+
assert(apply && "Not an apply instruction kind");
422+
auto conv = apply.getArgumentConvention(*use);
423+
switch (conv) {
424+
case SILArgumentConvention::Indirect_In_Guaranteed:
425+
return false;
426+
427+
case SILArgumentConvention::Indirect_InoutAliasable:
428+
// DISCUSSION: We do not consider inout_aliasable to be "truly mutating"
429+
// since today it is just used as a way to mark a captured argument and
430+
// not that something truly has mutating semantics. The reason why this
431+
// is safe is that the typechecker guarantees that if our value was
432+
// immutable, then the use in the closure must be immutable as well.
433+
//
434+
// TODO: Remove this in favor of using Inout and In_Guaranteed.
435+
return false;
436+
437+
case SILArgumentConvention::Indirect_Out:
438+
case SILArgumentConvention::Indirect_In:
439+
case SILArgumentConvention::Indirect_In_Constant:
440+
case SILArgumentConvention::Indirect_Inout:
441+
return true;
442+
443+
case SILArgumentConvention::Direct_Unowned:
444+
case SILArgumentConvention::Direct_Guaranteed:
445+
case SILArgumentConvention::Direct_Owned:
446+
case SILArgumentConvention::Direct_Deallocating:
447+
assert(conv.isIndirectConvention() && "Expect an indirect convention");
448+
return true; // return something "conservative".
449+
}
450+
llvm_unreachable("covered switch isn't covered?!");
451+
};
452+
453+
/// A "copy_addr %src [take] to *" is consuming on "%src".
454+
/// A "copy_addr * to * %dst" is mutating on "%dst".
455+
bool isConsumingOrMutatingCopyAddrUse(Operand *use) {
456+
auto *copyAddr = cast<CopyAddrInst>(use->getUser());
457+
if (copyAddr->getDest() == use->get())
458+
return true;
459+
if (copyAddr->getSrc() == use->get() && copyAddr->isTakeOfSrc() == IsTake)
460+
return true;
461+
return false;
462+
}
463+
464+
bool isCastToNonConsuming(UncheckedAddrCastInst *i) {
465+
for (auto *use : i->getUses()) {
466+
auto *inst = use->getUser();
467+
switch (inst->getKind()) {
468+
case SILInstructionKind::ApplyInst:
469+
case SILInstructionKind::TryApplyInst:
470+
case SILInstructionKind::PartialApplyInst:
471+
if (isConsumingOrMutatingApplyUse(use))
472+
return false;
473+
continue;
474+
default:
475+
continue;
476+
}
477+
}
478+
return true;
479+
}
480+
481+
bool isMutatingOrConsuming(SILValue address) {
482+
for (auto *use : address->getUses()) {
483+
auto *inst = use->getUser();
484+
if (inst->isTypeDependentOperand(*use))
485+
continue;
486+
switch (inst->getKind()) {
487+
case SILInstructionKind::MarkDependenceInst:
488+
break;
489+
case SILInstructionKind::ApplyInst:
490+
case SILInstructionKind::TryApplyInst:
491+
case SILInstructionKind::PartialApplyInst:
492+
if (isConsumingOrMutatingApplyUse(use))
493+
return true;
494+
else
495+
break;
496+
case SILInstructionKind::CopyAddrInst:
497+
if (isConsumingOrMutatingCopyAddrUse(use))
498+
return true;
499+
else
500+
break;
501+
case SILInstructionKind::DestroyAddrInst:
502+
return true;
503+
case SILInstructionKind::UncheckedAddrCastInst: {
504+
if (isCastToNonConsuming(cast<UncheckedAddrCastInst>(inst))) {
505+
break;
506+
}
507+
return true;
508+
}
509+
case SILInstructionKind::CheckedCastAddrBranchInst:
510+
switch (cast<CheckedCastAddrBranchInst>(inst)->getConsumptionKind()) {
511+
case CastConsumptionKind::BorrowAlways:
512+
llvm_unreachable("checked_cast_addr_br cannot have BorrowAlways");
513+
case CastConsumptionKind::CopyOnSuccess:
514+
break;
515+
case CastConsumptionKind::TakeAlways:
516+
case CastConsumptionKind::TakeOnSuccess:
517+
return true;
518+
}
519+
break;
520+
case SILInstructionKind::LoadInst:
521+
// A 'non-taking' value load is harmless.
522+
return cast<LoadInst>(inst)->getOwnershipQualifier() ==
523+
LoadOwnershipQualifier::Take;
524+
break;
525+
case SILInstructionKind::DebugValueAddrInst:
526+
// Harmless use.
527+
break;
528+
default:
529+
llvm_unreachable("Unhandled unexpected instruction");
530+
break;
531+
}
532+
}
533+
return false;
534+
}
535+
};
536+
413537
/// The SIL verifier walks over a SIL function / basic block / instruction,
414538
/// checking and enforcing its invariants.
415539
class SILVerifier : public SILVerifierBase<SILVerifier> {
@@ -2878,123 +3002,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
28783002
if (allowedAccessKind == OpenedExistentialAccess::Mutable)
28793003
return;
28803004

2881-
auto isConsumingOrMutatingApplyUse = [](Operand *use) -> bool {
2882-
ApplySite apply(use->getUser());
2883-
assert(apply && "Not an apply instruction kind");
2884-
auto conv = apply.getArgumentConvention(*use);
2885-
switch (conv) {
2886-
case SILArgumentConvention::Indirect_In_Guaranteed:
2887-
return false;
2888-
2889-
case SILArgumentConvention::Indirect_InoutAliasable:
2890-
// DISCUSSION: We do not consider inout_aliasable to be "truly mutating"
2891-
// since today it is just used as a way to mark a captured argument and
2892-
// not that something truly has mutating semantics. The reason why this
2893-
// is safe is that the typechecker guarantees that if our value was
2894-
// immutable, then the use in the closure must be immutable as well.
2895-
//
2896-
// TODO: Remove this in favor of using Inout and In_Guaranteed.
2897-
return false;
2898-
2899-
case SILArgumentConvention::Indirect_Out:
2900-
case SILArgumentConvention::Indirect_In:
2901-
case SILArgumentConvention::Indirect_In_Constant:
2902-
case SILArgumentConvention::Indirect_Inout:
2903-
return true;
2904-
2905-
case SILArgumentConvention::Direct_Unowned:
2906-
case SILArgumentConvention::Direct_Guaranteed:
2907-
case SILArgumentConvention::Direct_Owned:
2908-
case SILArgumentConvention::Direct_Deallocating:
2909-
assert(conv.isIndirectConvention() && "Expect an indirect convention");
2910-
return true; // return something "conservative".
2911-
}
2912-
llvm_unreachable("covered switch isn't covered?!");
2913-
};
2914-
2915-
// A "copy_addr %src [take] to *" is consuming on "%src".
2916-
// A "copy_addr * to * %dst" is mutating on "%dst".
2917-
auto isConsumingOrMutatingCopyAddrUse = [](Operand *use) -> bool {
2918-
auto *copyAddr = cast<CopyAddrInst>(use->getUser());
2919-
if (copyAddr->getDest() == use->get())
2920-
return true;
2921-
if (copyAddr->getSrc() == use->get() && copyAddr->isTakeOfSrc() == IsTake)
2922-
return true;
2923-
return false;
2924-
};
2925-
2926-
auto isMutatingOrConsuming = [=](OpenExistentialAddrInst *OEI) -> bool {
2927-
for (auto *use : OEI->getUses()) {
2928-
auto *inst = use->getUser();
2929-
if (inst->isTypeDependentOperand(*use))
2930-
continue;
2931-
switch (inst->getKind()) {
2932-
case SILInstructionKind::MarkDependenceInst:
2933-
break;
2934-
case SILInstructionKind::ApplyInst:
2935-
case SILInstructionKind::TryApplyInst:
2936-
case SILInstructionKind::PartialApplyInst:
2937-
if (isConsumingOrMutatingApplyUse(use))
2938-
return true;
2939-
else
2940-
break;
2941-
case SILInstructionKind::CopyAddrInst:
2942-
if (isConsumingOrMutatingCopyAddrUse(use))
2943-
return true;
2944-
else
2945-
break;
2946-
case SILInstructionKind::DestroyAddrInst:
2947-
return true;
2948-
case SILInstructionKind::UncheckedAddrCastInst: {
2949-
auto isCastToNonConsuming = [=](UncheckedAddrCastInst *I) -> bool {
2950-
for (auto *use : I->getUses()) {
2951-
auto *inst = use->getUser();
2952-
switch (inst->getKind()) {
2953-
case SILInstructionKind::ApplyInst:
2954-
case SILInstructionKind::TryApplyInst:
2955-
case SILInstructionKind::PartialApplyInst:
2956-
if (isConsumingOrMutatingApplyUse(use))
2957-
return false;
2958-
continue;
2959-
default:
2960-
continue;
2961-
}
2962-
}
2963-
return true;
2964-
};
2965-
if (isCastToNonConsuming(cast<UncheckedAddrCastInst>(inst))) {
2966-
break;
2967-
}
2968-
return true;
2969-
}
2970-
case SILInstructionKind::CheckedCastAddrBranchInst:
2971-
switch (cast<CheckedCastAddrBranchInst>(inst)->getConsumptionKind()) {
2972-
case CastConsumptionKind::BorrowAlways:
2973-
llvm_unreachable("checked_cast_addr_br cannot have BorrowAlways");
2974-
case CastConsumptionKind::CopyOnSuccess:
2975-
break;
2976-
case CastConsumptionKind::TakeAlways:
2977-
case CastConsumptionKind::TakeOnSuccess:
2978-
return true;
2979-
}
2980-
break;
2981-
case SILInstructionKind::LoadInst:
2982-
// A 'non-taking' value load is harmless.
2983-
return cast<LoadInst>(inst)->getOwnershipQualifier() ==
2984-
LoadOwnershipQualifier::Take;
2985-
break;
2986-
case SILInstructionKind::DebugValueAddrInst:
2987-
// Harmless use.
2988-
break;
2989-
default:
2990-
llvm_unreachable("Unhandled unexpected instruction");
2991-
break;
2992-
}
2993-
}
2994-
return false;
2995-
};
2996-
require(allowedAccessKind == OpenedExistentialAccess::Mutable
2997-
|| !isMutatingOrConsuming(OEI),
3005+
require(allowedAccessKind == OpenedExistentialAccess::Mutable ||
3006+
!ImmutableAddressUseVerifier().isMutatingOrConsuming(OEI),
29983007
"open_existential_addr uses that consumes or mutates but is not "
29993008
"opened for mutation");
30003009
}

branches/master-next/stdlib/public/Darwin/CMakeLists.txt

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,53 @@ if(SWIFT_BUILD_STATIC_SDK_OVERLAY)
88
list(APPEND SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES STATIC)
99
endif()
1010

11-
set(all_overlays "Accelerate;AppKit;ARKit;AssetsLibrary;AVFoundation;CallKit;CloudKit;Compression;Contacts;CoreAudio;CoreData;CoreFoundation;CoreGraphics;CoreImage;CoreLocation;CoreMedia;CryptoTokenKit;Dispatch;Foundation;GameplayKit;GLKit;HomeKit;IOKit;Intents;MapKit;MediaPlayer;Metal;MetalKit;ModelIO;NaturalLanguage;Network;ObjectiveC;OpenCL;os;Photos;QuartzCore;SafariServices;SceneKit;simd;SpriteKit;UIKit;Vision;WatchKit;XCTest;XPC")
11+
set(all_overlays
12+
Accelerate
13+
AppKit
14+
ARKit
15+
AssetsLibrary
16+
AVFoundation
17+
CallKit
18+
CloudKit
19+
Compression
20+
Contacts
21+
CoreAudio
22+
CoreData
23+
CoreFoundation
24+
CoreGraphics
25+
CoreImage
26+
CoreLocation
27+
CoreMedia
28+
CryptoTokenKit
29+
Dispatch
30+
Foundation
31+
GameplayKit
32+
GLKit
33+
HomeKit
34+
IOKit
35+
Intents
36+
MapKit
37+
MediaPlayer
38+
Metal
39+
MetalKit
40+
ModelIO
41+
NaturalLanguage
42+
Network
43+
ObjectiveC
44+
OpenCL
45+
os
46+
Photos
47+
QuartzCore
48+
SafariServices
49+
SceneKit
50+
simd
51+
SpriteKit
52+
UIKit
53+
Vision
54+
WatchKit
55+
XCTest
56+
XPC
57+
)
1258

1359
if(DEFINED SWIFT_OVERLAY_TARGETS)
1460
set(overlays_to_build ${SWIFT_OVERLAY_TARGETS})

branches/master-next/test/Demangle/Inputs/manglings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ _$S3BBBBf0602365061_ ---> _$S3BBBBf0602365061_
326326
_$S3BBBBi0602365061_ ---> _$S3BBBBi0602365061_
327327
_$S3BBBBv0602365061_ ---> _$S3BBBBv0602365061_
328328
_T0lxxxmmmTk ---> _T0lxxxmmmTk
329+
$s4test3fooV4blahyAA1SV1fQryFQOy_Qo_AHF ---> test.foo.blah(<<opaque return type of test.S.f() -> some>>.0) -> <<opaque return type of test.S.f() -> some>>.0
329330
$S3nix8MystructV1xACyxGx_tcfc7MyaliasL_ayx__GD ---> Myalias #1 in nix.Mystruct<A>.init(x: A) -> nix.Mystruct<A>
330331
$S3nix7MyclassCfd7MyaliasL_ayx__GD ---> Myalias #1 in nix.Myclass<A>.deinit
331332
$S3nix8MystructVyS2icig7MyaliasL_ayx__GD ---> Myalias #1 in nix.Mystruct<A>.subscript.getter : (Swift.Int) -> Swift.Int

0 commit comments

Comments
 (0)