Skip to content

Commit a8c3baf

Browse files
committed
---
yaml --- r: 340440 b: refs/heads/rxwei-patch-1 c: 2e9c904 h: refs/heads/master
1 parent 4748684 commit a8c3baf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+482
-477
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 57666fde9645f02051f199ac578c10ee6da1c0d0
1018+
refs/heads/rxwei-patch-1: 2e9c904e163bfac7a1db526d1eee358488344842
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Instructions for installing CMake and Ninja directly can be found [below](#build
9898

9999
For Ubuntu, you'll need the following development dependencies:
100100

101-
sudo apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev systemtap-sdt-dev tzdata rsync
101+
sudo apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev systemtap-sdt-dev tzdata rsync
102102

103103
**Note:** LLDB currently requires at least `swig-1.3.40` but will successfully build
104104
with version 2 shipped with Ubuntu.

branches/rxwei-patch-1/include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ SIMPLE_DECL_ATTR(_implementationOnly, ImplementationOnly,
401401
DECL_ATTR(_custom, Custom,
402402
OnAnyDecl | UserInaccessible,
403403
85)
404-
SIMPLE_DECL_ATTR(propertyWrapper, PropertyWrapper,
404+
SIMPLE_DECL_ATTR(_propertyWrapper, PropertyWrapper,
405405
OnStruct | OnClass | OnEnum,
406406
86)
407407
SIMPLE_DECL_ATTR(_disfavoredOverload, DisfavoredOverload,

branches/rxwei-patch-1/include/swift/AST/Decl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5150,10 +5150,6 @@ class VarDecl : public AbstractStorageDecl {
51505150
/// \end
51515151
bool isPropertyWrapperInitializedWithInitialValue() const;
51525152

5153-
/// Whether the memberwise initializer parameter for a property with a property wrapper type
5154-
/// uses the wrapped type.
5155-
bool isPropertyMemberwiseInitializedWithWrappedType() const;
5156-
51575153
/// If this property is the backing storage for a property with an attached
51585154
/// property wrapper, return the original property.
51595155
///

branches/rxwei-patch-1/include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4462,9 +4462,6 @@ ERROR(property_wrapper_type_not_usable_from_inline,none,
44624462
"%select{%select{variable|constant}0|property}1 "
44634463
"must be '@usableFromInline' or public",
44644464
(bool, bool))
4465-
WARNING(property_wrapper_delegateValue,none,
4466-
"property wrapper's `delegateValue` property should be renamed to "
4467-
"'wrapperValue'; use of 'delegateValue' is deprecated", ())
44684465

44694466
//------------------------------------------------------------------------------
44704467
// MARK: function builder diagnostics

branches/rxwei-patch-1/lib/AST/Decl.cpp

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5473,35 +5473,10 @@ VarDecl *VarDecl::getPropertyWrapperBackingProperty() const {
54735473
}
54745474

54755475
bool VarDecl::isPropertyWrapperInitializedWithInitialValue() const {
5476-
auto customAttr = getAttachedPropertyWrapper();
5477-
if (!customAttr)
5478-
return false;
5479-
5480-
auto *PBD = getParentPatternBinding();
5481-
if (!PBD)
5482-
return false;
5483-
5484-
// If there was an initializer on the original property, initialize
5485-
// via the initial value.
5486-
if (PBD->getPatternList()[0].getEqualLoc().isValid())
5487-
return true;
5488-
5489-
// If there was an initializer on the attribute itself, initialize
5490-
// via the full wrapper.
5491-
if (customAttr->getArg() != nullptr)
5492-
return false;
5493-
5494-
// Default initialization does not use a value.
5495-
auto wrapperTypeInfo = getAttachedPropertyWrapperTypeInfo();
5496-
if (wrapperTypeInfo.defaultInit)
5476+
auto &ctx = getASTContext();
5477+
if (!ctx.getLazyResolver())
54975478
return false;
54985479

5499-
// There is no initializer, so the initialization form depends on
5500-
// whether the property wrapper type has an init(initialValue:).
5501-
return wrapperTypeInfo.initialValueInit != nullptr;
5502-
}
5503-
5504-
bool VarDecl::isPropertyMemberwiseInitializedWithWrappedType() const {
55055480
auto customAttr = getAttachedPropertyWrapper();
55065481
if (!customAttr)
55075482
return false;
@@ -5520,6 +5495,11 @@ bool VarDecl::isPropertyMemberwiseInitializedWithWrappedType() const {
55205495
if (customAttr->getArg() != nullptr)
55215496
return false;
55225497

5498+
// If the property wrapper is default-initializable, it's the wrapper
5499+
// being initialized.
5500+
if (PBD->isDefaultInitializable(0))
5501+
return false;
5502+
55235503
// There is no initializer, so the initialization form depends on
55245504
// whether the property wrapper type has an init(initialValue:).
55255505
auto wrapperTypeInfo = getAttachedPropertyWrapperTypeInfo();

branches/rxwei-patch-1/lib/Parse/ParseDecl.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,12 +1800,6 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc At
18001800
checkInvalidAttrName("_inlineable", "inlinable", DAK_Inlinable);
18011801
}
18021802

1803-
// Other names of property wrappers...
1804-
checkInvalidAttrName("propertyDelegate", "propertyWrapper",
1805-
DAK_PropertyWrapper, diag::attr_renamed_warning);
1806-
checkInvalidAttrName("_propertyWrapper", "propertyWrapper",
1807-
DAK_PropertyWrapper, diag::attr_renamed_warning);
1808-
18091803
if (DK == DAK_Count && Tok.getText() == "warn_unused_result") {
18101804
// The behavior created by @warn_unused_result is now the default. Emit a
18111805
// Fix-It to remove.

branches/rxwei-patch-1/lib/SILGen/SILGen.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,13 +1137,10 @@ emitStoredPropertyInitialization(PatternBindingDecl *pbd, unsigned i) {
11371137
// If this is the backing storage for a property with an attached wrapper
11381138
// that was initialized with `=`, use that expression as the initializer.
11391139
if (auto originalProperty = var->getOriginalWrappedProperty()) {
1140-
if (originalProperty
1141-
->isPropertyMemberwiseInitializedWithWrappedType()) {
1142-
auto wrapperInfo =
1143-
originalProperty->getPropertyWrapperBackingPropertyInfo();
1144-
if (wrapperInfo.originalInitialValue)
1145-
init = wrapperInfo.originalInitialValue;
1146-
}
1140+
auto wrapperInfo =
1141+
originalProperty->getPropertyWrapperBackingPropertyInfo();
1142+
if (wrapperInfo.originalInitialValue)
1143+
init = wrapperInfo.originalInitialValue;
11471144
}
11481145

11491146
SILDeclRef constant(var, SILDeclRef::Kind::StoredPropertyInitializer);

branches/rxwei-patch-1/lib/SILGen/SILGenConstructor.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static bool maybeEmitPropertyWrapperInitFromValue(
112112
llvm::function_ref<void(Expr *)> body) {
113113
auto originalProperty = field->getOriginalWrappedProperty();
114114
if (!originalProperty ||
115-
!originalProperty->isPropertyMemberwiseInitializedWithWrappedType())
115+
!originalProperty->isPropertyWrapperInitializedWithInitialValue())
116116
return false;
117117

118118
auto wrapperInfo = originalProperty->getPropertyWrapperBackingPropertyInfo();
@@ -981,15 +981,11 @@ void SILGenFunction::emitMemberInitializers(DeclContext *dc,
981981
// property wrapper initialized with `=`, inject the value into an
982982
// instance of the wrapper.
983983
if (auto singleVar = pbd->getSingleVar()) {
984-
auto originalVar = singleVar->getOriginalWrappedProperty();
985-
if (originalVar &&
986-
originalVar->isPropertyWrapperInitializedWithInitialValue()) {
987-
(void)maybeEmitPropertyWrapperInitFromValue(
988-
*this, init, singleVar, std::move(result),
989-
[&](Expr *expr) {
990-
result = emitRValue(expr);
991-
});
992-
}
984+
(void)maybeEmitPropertyWrapperInitFromValue(
985+
*this, init, singleVar, std::move(result),
986+
[&](Expr *expr) {
987+
result = emitRValue(expr);
988+
});
993989
}
994990

995991
emitMemberInit(*this, selfDecl, entry.getPattern(), std::move(result));

branches/rxwei-patch-1/lib/SILOptimizer/Mandatory/MandatoryInlining.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ static void diagnose(ASTContext &Context, SourceLoc loc, Diag<T...> diag,
4646
Context.Diags.diagnose(loc, diag, std::forward<U>(args)...);
4747
}
4848

49-
static SILValue stripCopies(SILValue v) {
50-
while (auto *cvi = dyn_cast<CopyValueInst>(v)) {
51-
v = cvi->getOperand();
49+
static SILValue stripCopiesAndBorrows(SILValue v) {
50+
while (isa<CopyValueInst>(v) || isa<BeginBorrowInst>(v)) {
51+
v = cast<SingleValueInstruction>(v)->getOperand(0);
5252
}
5353
return v;
5454
}
@@ -329,7 +329,7 @@ static void cleanupCalleeValue(SILValue calleeValue) {
329329
}
330330
}
331331

332-
calleeValue = stripCopies(calleeValue);
332+
calleeValue = stripCopiesAndBorrows(calleeValue);
333333

334334
// Inline constructor
335335
auto calleeSource = ([&]() -> SILValue {
@@ -339,12 +339,12 @@ static void cleanupCalleeValue(SILValue calleeValue) {
339339
// will delete any uses of the closure, including a
340340
// convert_escape_to_noescape conversion.
341341
if (auto *cfi = dyn_cast<ConvertFunctionInst>(calleeValue))
342-
return stripCopies(cfi->getOperand());
342+
return stripCopiesAndBorrows(cfi->getOperand());
343343

344344
if (auto *cvt = dyn_cast<ConvertEscapeToNoEscapeInst>(calleeValue))
345-
return stripCopies(cvt->getOperand());
345+
return stripCopiesAndBorrows(cvt->getOperand());
346346

347-
return stripCopies(calleeValue);
347+
return stripCopiesAndBorrows(calleeValue);
348348
})();
349349

350350
if (auto *pai = dyn_cast<PartialApplyInst>(calleeSource)) {
@@ -359,7 +359,7 @@ static void cleanupCalleeValue(SILValue calleeValue) {
359359
calleeValue = callee;
360360
}
361361

362-
calleeValue = stripCopies(calleeValue);
362+
calleeValue = stripCopiesAndBorrows(calleeValue);
363363

364364
// Handle function_ref -> convert_function -> partial_apply/thin_to_thick.
365365
if (auto *cfi = dyn_cast<ConvertFunctionInst>(calleeValue)) {
@@ -579,7 +579,7 @@ getCalleeFunction(SILFunction *F, FullApplySite AI, bool &IsThick,
579579

580580
// Then grab a first approximation of our apply by stripping off all copy
581581
// operations.
582-
SILValue CalleeValue = stripCopies(AI.getCallee());
582+
SILValue CalleeValue = stripCopiesAndBorrows(AI.getCallee());
583583

584584
// If after stripping off copy_values, we have a load then see if we the
585585
// function we want to inline has a simple available value through a simple
@@ -588,7 +588,7 @@ getCalleeFunction(SILFunction *F, FullApplySite AI, bool &IsThick,
588588
CalleeValue = getLoadedCalleeValue(li);
589589
if (!CalleeValue)
590590
return nullptr;
591-
CalleeValue = stripCopies(CalleeValue);
591+
CalleeValue = stripCopiesAndBorrows(CalleeValue);
592592
}
593593

594594
// PartialApply/ThinToThick -> ConvertFunction patterns are generated
@@ -599,7 +599,7 @@ getCalleeFunction(SILFunction *F, FullApplySite AI, bool &IsThick,
599599
// a cast.
600600
auto skipFuncConvert = [](SILValue CalleeValue) {
601601
// Skip any copies that we see.
602-
CalleeValue = stripCopies(CalleeValue);
602+
CalleeValue = stripCopiesAndBorrows(CalleeValue);
603603

604604
// We can also allow a thin @escape to noescape conversion as such:
605605
// %1 = function_ref @thin_closure_impl : $@convention(thin) () -> ()
@@ -619,7 +619,7 @@ getCalleeFunction(SILFunction *F, FullApplySite AI, bool &IsThick,
619619
ToCalleeTy->getExtInfo().withNoEscape(false));
620620
if (FromCalleeTy != EscapingCalleeTy)
621621
return CalleeValue;
622-
return stripCopies(ThinToNoescapeCast->getOperand());
622+
return stripCopiesAndBorrows(ThinToNoescapeCast->getOperand());
623623
}
624624

625625
// Ignore mark_dependence users. A partial_apply [stack] uses them to mark
@@ -635,7 +635,7 @@ getCalleeFunction(SILFunction *F, FullApplySite AI, bool &IsThick,
635635

636636
auto *CFI = dyn_cast<ConvertEscapeToNoEscapeInst>(CalleeValue);
637637
if (!CFI)
638-
return stripCopies(CalleeValue);
638+
return stripCopiesAndBorrows(CalleeValue);
639639

640640
// TODO: Handle argument conversion. All the code in this file needs to be
641641
// cleaned up and generalized. The argument conversion handling in
@@ -651,9 +651,9 @@ getCalleeFunction(SILFunction *F, FullApplySite AI, bool &IsThick,
651651
auto EscapingCalleeTy =
652652
ToCalleeTy->getWithExtInfo(ToCalleeTy->getExtInfo().withNoEscape(false));
653653
if (FromCalleeTy != EscapingCalleeTy)
654-
return stripCopies(CalleeValue);
654+
return stripCopiesAndBorrows(CalleeValue);
655655

656-
return stripCopies(CFI->getOperand());
656+
return stripCopiesAndBorrows(CFI->getOperand());
657657
};
658658

659659
// Look through a escape to @noescape conversion.
@@ -666,11 +666,11 @@ getCalleeFunction(SILFunction *F, FullApplySite AI, bool &IsThick,
666666
// Collect the applied arguments and their convention.
667667
collectPartiallyAppliedArguments(PAI, CapturedArgConventions, FullArgs);
668668

669-
CalleeValue = stripCopies(PAI->getCallee());
669+
CalleeValue = stripCopiesAndBorrows(PAI->getCallee());
670670
IsThick = true;
671671
PartialApply = PAI;
672672
} else if (auto *TTTFI = dyn_cast<ThinToThickFunctionInst>(CalleeValue)) {
673-
CalleeValue = stripCopies(TTTFI->getOperand());
673+
CalleeValue = stripCopiesAndBorrows(TTTFI->getOperand());
674674
IsThick = true;
675675
}
676676

branches/rxwei-patch-1/lib/SILOptimizer/Utils/Local.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,9 @@ swift::tryToConcatenateStrings(ApplyInst *AI, SILBuilder &B) {
931931
// Closure Deletion
932932
//===----------------------------------------------------------------------===//
933933

934+
/// NOTE: Instructions with transitive ownership kind are assumed to not keep
935+
/// the underlying closure alive as well. This is meant for instructions only
936+
/// with non-transitive users.
934937
static bool useDoesNotKeepClosureAlive(const SILInstruction *I) {
935938
switch (I->getKind()) {
936939
case SILInstructionKind::StrongRetainInst:
@@ -939,6 +942,7 @@ static bool useDoesNotKeepClosureAlive(const SILInstruction *I) {
939942
case SILInstructionKind::RetainValueInst:
940943
case SILInstructionKind::ReleaseValueInst:
941944
case SILInstructionKind::DebugValueInst:
945+
case SILInstructionKind::EndBorrowInst:
942946
return true;
943947
default:
944948
return false;
@@ -951,9 +955,9 @@ static bool useHasTransitiveOwnership(const SILInstruction *I) {
951955
if (isa<ConvertEscapeToNoEscapeInst>(I))
952956
return true;
953957

954-
// Look through copy_value. It is inert for our purposes, but we need to look
955-
// through it.
956-
return isa<CopyValueInst>(I);
958+
// Look through copy_value, begin_borrow. They are inert for our purposes, but
959+
// we need to look through it.
960+
return isa<CopyValueInst>(I) || isa<BeginBorrowInst>(I);
957961
}
958962

959963
static SILValue createLifetimeExtendedAllocStack(

branches/rxwei-patch-1/lib/Sema/CodeSynthesis.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,18 +2247,12 @@ static void maybeAddMemberwiseDefaultArg(ParamDecl *arg, VarDecl *var,
22472247
if (!var->getParentPattern()->getSingleVar())
22482248
return;
22492249

2250-
// Determine whether this variable will be 'nil' initialized.
2251-
bool isNilInitialized =
2252-
(isa<OptionalType>(var->getValueInterfaceType().getPointer()) &&
2253-
!var->isParentInitialized()) ||
2254-
var->getAttrs().hasAttribute<LazyAttr>();
2255-
2256-
// Whether we have explicit initialization.
2257-
bool isExplicitlyInitialized = var->isParentInitialized();
2258-
2259-
// If this is neither nil-initialized nor explicitly initialized, don't add
2260-
// anything.
2261-
if (!isNilInitialized && !isExplicitlyInitialized)
2250+
// If we don't have an expression initializer or silgen can't assign a default
2251+
// initializer, then we can't generate a default value. An example of where
2252+
// silgen can assign a default is var x: Int? where the default is nil.
2253+
// If the variable is lazy, go ahead and give it a default value.
2254+
if (!var->getAttrs().hasAttribute<LazyAttr>() &&
2255+
!var->getParentPatternBinding()->isDefaultInitializable())
22622256
return;
22632257

22642258
// We can add a default value now.
@@ -2274,14 +2268,13 @@ static void maybeAddMemberwiseDefaultArg(ParamDecl *arg, VarDecl *var,
22742268
// default arg. All lazy variables return a nil literal as well. *Note* that
22752269
// the type will always be a sugared T? because we don't default init an
22762270
// explicit Optional<T>.
2277-
if (isNilInitialized) {
2271+
if ((isa<OptionalType>(var->getValueInterfaceType().getPointer()) &&
2272+
!var->isParentInitialized()) ||
2273+
var->getAttrs().hasAttribute<LazyAttr>()) {
22782274
arg->setDefaultArgumentKind(DefaultArgumentKind::NilLiteral);
22792275
return;
22802276
}
22812277

2282-
// Explicitly initialize.
2283-
assert(isExplicitlyInitialized);
2284-
22852278
// If there's a backing storage property, the memberwise initializer
22862279
// will be in terms of that.
22872280
VarDecl *backingStorageVar = var->getPropertyWrapperBackingProperty();
@@ -2341,7 +2334,7 @@ ConstructorDecl *swift::createImplicitConstructor(TypeChecker &tc,
23412334
// accept a value of the original property type. Otherwise, the
23422335
// memberwise initializer will be in terms of the backing storage
23432336
// type.
2344-
if (!var->isPropertyMemberwiseInitializedWithWrappedType()) {
2337+
if (!var->isPropertyWrapperInitializedWithInitialValue()) {
23452338
varInterfaceType = backingPropertyType;
23462339
}
23472340
}

branches/rxwei-patch-1/lib/Sema/TypeCheckAccess.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,12 +1872,7 @@ class ExportabilityChecker : public DeclVisitor<ExportabilityChecker> {
18721872
}
18731873

18741874
void visitExtensionDecl(ExtensionDecl *ED) {
1875-
auto extendedType = ED->getExtendedNominal();
1876-
// TODO: Sometimes we have an extension that is marked valid but has no
1877-
// extended type. Assert, just in case we see it while testing, but
1878-
// don't crash. rdar://50401284
1879-
assert(extendedType && "valid extension with no extended type?");
1880-
if (!extendedType || shouldSkipChecking(extendedType))
1875+
if (shouldSkipChecking(ED->getExtendedNominal()))
18811876
return;
18821877

18831878
// FIXME: We should allow conforming to implementation-only protocols,

0 commit comments

Comments
 (0)