Skip to content

Commit 3ada00d

Browse files
---
yaml --- r: 340447 b: refs/heads/rxwei-patch-1 c: ff3d081 h: refs/heads/master i: 340445: 4807d99 340443: ea35aaa 340439: 4748684 340431: be92935 340415: 7451b36
1 parent 66aedab commit 3ada00d

Some content is hidden

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

49 files changed

+629
-401
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: 8d1d863f435c62b1f7a598b27f5880760504bf47
1018+
refs/heads/rxwei-patch-1: ff3d081284a8136c50ce6240bff53a73c402f72f
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 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
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 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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5150,6 +5150,10 @@ 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+
51535157
/// If this property is the backing storage for a property with an attached
51545158
/// property wrapper, return the original property.
51555159
///

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4462,6 +4462,9 @@ 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", ())
44654468

44664469
//------------------------------------------------------------------------------
44674470
// MARK: function builder diagnostics

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

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

54755475
bool VarDecl::isPropertyWrapperInitializedWithInitialValue() const {
5476-
auto &ctx = getASTContext();
5477-
if (!ctx.getLazyResolver())
5478-
return false;
5479-
54805476
auto customAttr = getAttachedPropertyWrapper();
54815477
if (!customAttr)
54825478
return false;
@@ -5495,9 +5491,33 @@ bool VarDecl::isPropertyWrapperInitializedWithInitialValue() const {
54955491
if (customAttr->getArg() != nullptr)
54965492
return false;
54975493

5498-
// If the property wrapper is default-initializable, it's the wrapper
5499-
// being initialized.
5500-
if (PBD->isDefaultInitializable(0))
5494+
// Default initialization does not use a value.
5495+
auto wrapperTypeInfo = getAttachedPropertyWrapperTypeInfo();
5496+
if (wrapperTypeInfo.defaultInit)
5497+
return false;
5498+
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 {
5505+
auto customAttr = getAttachedPropertyWrapper();
5506+
if (!customAttr)
5507+
return false;
5508+
5509+
auto *PBD = getParentPatternBinding();
5510+
if (!PBD)
5511+
return false;
5512+
5513+
// If there was an initializer on the original property, initialize
5514+
// via the initial value.
5515+
if (PBD->getPatternList()[0].getEqualLoc().isValid())
5516+
return true;
5517+
5518+
// If there was an initializer on the attribute itself, initialize
5519+
// via the full wrapper.
5520+
if (customAttr->getArg() != nullptr)
55015521
return false;
55025522

55035523
// There is no initializer, so the initialization form depends on

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,12 @@ 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+
18031809
if (DK == DAK_Count && Tok.getText() == "warn_unused_result") {
18041810
// The behavior created by @warn_unused_result is now the default. Emit a
18051811
// Fix-It to remove.

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,10 +1137,13 @@ 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-
auto wrapperInfo =
1141-
originalProperty->getPropertyWrapperBackingPropertyInfo();
1142-
if (wrapperInfo.originalInitialValue)
1143-
init = wrapperInfo.originalInitialValue;
1140+
if (originalProperty
1141+
->isPropertyMemberwiseInitializedWithWrappedType()) {
1142+
auto wrapperInfo =
1143+
originalProperty->getPropertyWrapperBackingPropertyInfo();
1144+
if (wrapperInfo.originalInitialValue)
1145+
init = wrapperInfo.originalInitialValue;
1146+
}
11441147
}
11451148

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

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

Lines changed: 10 additions & 6 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->isPropertyWrapperInitializedWithInitialValue())
115+
!originalProperty->isPropertyMemberwiseInitializedWithWrappedType())
116116
return false;
117117

118118
auto wrapperInfo = originalProperty->getPropertyWrapperBackingPropertyInfo();
@@ -981,11 +981,15 @@ 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-
(void)maybeEmitPropertyWrapperInitFromValue(
985-
*this, init, singleVar, std::move(result),
986-
[&](Expr *expr) {
987-
result = emitRValue(expr);
988-
});
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+
}
989993
}
990994

991995
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/CSDiag.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,7 +2239,7 @@ bool FailureDiagnosis::diagnoseContextualConversionError(
22392239
CS.TC.isConvertibleTo(srcFT->getResult(), contextualType, CS.DC)) {
22402240

22412241
auto locator =
2242-
CS.getConstraintLocator(expr, ConstraintLocator::ContextualType);
2242+
CS.getConstraintLocator(expr, LocatorPathElt::getContextualType());
22432243
ContextualFailure failure =
22442244
ContextualFailure(nullptr, CS, srcFT, contextualType, locator);
22452245
auto diagnosed = failure.diagnoseAsError();
@@ -2320,7 +2320,7 @@ bool FailureDiagnosis::diagnoseContextualConversionError(
23202320
if (contextualType->isExistentialType()) {
23212321
MissingContextualConformanceFailure failure(
23222322
expr, CS, CTP, exprType, contextualType,
2323-
CS.getConstraintLocator(expr, ConstraintLocator::ContextualType));
2323+
CS.getConstraintLocator(expr, LocatorPathElt::getContextualType()));
23242324
return failure.diagnoseAsError();
23252325
}
23262326

@@ -5688,7 +5688,7 @@ bool FailureDiagnosis::diagnoseClosureExpr(
56885688

56895689
MissingArgumentsFailure failure(
56905690
expr, CS, fnType, inferredArgCount - actualArgCount,
5691-
CS.getConstraintLocator(CE, ConstraintLocator::ContextualType));
5691+
CS.getConstraintLocator(CE, LocatorPathElt::getContextualType()));
56925692
return failure.diagnoseAsError();
56935693
}
56945694

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,8 +2950,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
29502950
// literals and expressions representing an implicit return type of the single
29512951
// expression functions.
29522952
if (auto elt = locator.last()) {
2953-
if (elt->getKind() == ConstraintLocator::ClosureResult ||
2954-
elt->getKind() == ConstraintLocator::SingleExprFuncResultType) {
2953+
if (elt->isClosureResult() || elt->isResultOfSingleExprFunction()) {
29552954
if (kind >= ConstraintKind::Subtype &&
29562955
(type1->isUninhabited() || type2->isVoid())) {
29572956
increaseScore(SK_FunctionConversion);
@@ -5420,8 +5419,9 @@ ConstraintSystem::simplifyKeyPathConstraint(Type keyPathTy,
54205419
{rootTy, valueTy});
54215420
// Let's check whether deduced key path type would match
54225421
// expected contextual one.
5423-
return matchTypes(resolvedKPTy, keyPathTy, ConstraintKind::Bind, subflags,
5424-
locator.withPathElement(ConstraintLocator::ContextualType));
5422+
return matchTypes(
5423+
resolvedKPTy, keyPathTy, ConstraintKind::Bind, subflags,
5424+
locator.withPathElement(LocatorPathElt::getContextualType()));
54255425
}
54265426

54275427
ConstraintSystem::SolutionKind

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,10 +1216,10 @@ ConstraintSystem::solveImpl(Expr *&expr,
12161216
if (getContextualTypePurpose() == CTP_YieldByReference)
12171217
constraintKind = ConstraintKind::Bind;
12181218

1219+
bool isForSingleExprFunction =
1220+
getContextualTypePurpose() == CTP_ReturnSingleExpr;
12191221
auto *convertTypeLocator = getConstraintLocator(
1220-
expr, getContextualTypePurpose() == CTP_ReturnSingleExpr
1221-
? ConstraintLocator::SingleExprFuncResultType
1222-
: ConstraintLocator::ContextualType);
1222+
expr, LocatorPathElt::getContextualType(isForSingleExprFunction));
12231223

12241224
if (allowFreeTypeVariables == FreeTypeVariableBinding::UnresolvedType) {
12251225
convertType = convertType.transform([&](Type type) -> Type {

0 commit comments

Comments
 (0)