Skip to content

Commit ea35aaa

Browse files
authored
---
yaml --- r: 340443 b: refs/heads/rxwei-patch-1 c: 735a884 h: refs/heads/master i: 340441: f3e8b8f 340439: 4748684
1 parent ef7efb9 commit ea35aaa

File tree

108 files changed

+3384
-689
lines changed

Some content is hidden

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

108 files changed

+3384
-689
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: ba6a5e10f840f2afbda53bafb589c54c96cca836
1018+
refs/heads/rxwei-patch-1: 735a884c062214285ac7b53cd29e3b9a121a82c5
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 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/ASTTypeIDs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct PropertyWrapperTypeInfo;
2727
class Type;
2828
class VarDecl;
2929
class TypeAliasDecl;
30+
class Type;
3031

3132
#define SWIFT_AST_TYPEID_ZONE 1
3233

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,15 @@ 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,
408408
OnAbstractFunction | OnVar | OnSubscript | UserInaccessible,
409409
87)
410+
SIMPLE_DECL_ATTR(_functionBuilder, FunctionBuilder,
411+
OnNominalType,
412+
88)
410413

411414
SIMPLE_DECL_ATTR(IBSegueAction, IBSegueAction,
412415
OnFunc,

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2709,6 +2709,14 @@ class ValueDecl : public Decl {
27092709
/// `this` must be of a decl type that supports opaque return types, and
27102710
/// must not have previously had an opaque result type set.
27112711
void setOpaqueResultTypeDecl(OpaqueTypeDecl *D);
2712+
2713+
/// Retrieve the attribute associating this declaration with a
2714+
/// function builder, if there is one.
2715+
CustomAttr *getAttachedFunctionBuilder() const;
2716+
2717+
/// Retrieve the @functionBuilder type attached to this declaration,
2718+
/// if there is one.
2719+
Type getFunctionBuilderType() const;
27122720
};
27132721

27142722
/// This is a common base class for declarations which declare a type.
@@ -5142,6 +5150,10 @@ class VarDecl : public AbstractStorageDecl {
51425150
/// \end
51435151
bool isPropertyWrapperInitializedWithInitialValue() const;
51445152

5153+
/// Whether the memberwise initializer parameter for a property with a property wrapper type
5154+
/// uses the wrapped type.
5155+
bool isPropertyMemberwiseInitializedWithWrappedType() const;
5156+
51455157
/// If this property is the backing storage for a property with an attached
51465158
/// property wrapper, return the original property.
51475159
///
@@ -5334,7 +5346,7 @@ class ParamDecl : public VarDecl {
53345346
assert(isVariadic());
53355347
return getVarargBaseTy(getInterfaceType());
53365348
}
5337-
5349+
53385350
SourceRange getSourceRange() const;
53395351

53405352
AnyFunctionType::Param toFunctionParam(Type type = Type()) const;

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4462,6 +4462,47 @@ 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", ())
4468+
4469+
//------------------------------------------------------------------------------
4470+
// MARK: function builder diagnostics
4471+
//------------------------------------------------------------------------------
4472+
ERROR(function_builder_decl, none,
4473+
"closure containing a declaration cannot be used with function "
4474+
"builder %0", (DeclName))
4475+
NOTE(note_function_builder_decl, none,
4476+
"closure containing a declaration cannot be used with function "
4477+
"builder %0", (DeclName))
4478+
ERROR(function_builder_control_flow, none,
4479+
"closure containing control flow statement cannot be used with function "
4480+
"builder %0", (DeclName))
4481+
NOTE(note_function_builder_control_flow, none,
4482+
"closure containing control flow statement cannot be used with function "
4483+
"builder %0", (DeclName))
4484+
ERROR(function_builder_attribute_not_allowed_here, none,
4485+
"function builder attribute %0 can only be applied to a parameter, "
4486+
"function, or computed property", (DeclName))
4487+
ERROR(function_builder_attribute_on_storage_without_getter, none,
4488+
"function builder attribute %0 can only be applied to a "
4489+
"%select{subscript|property|constant|variable}1 if it defines a getter",
4490+
(DeclName, unsigned))
4491+
ERROR(function_builder_parameter_not_of_function_type, none,
4492+
"function builder attribute %0 can only be applied to a parameter of "
4493+
"function type",
4494+
(DeclName))
4495+
ERROR(function_builder_parameter_autoclosure, none,
4496+
"function builder attribute %0 cannot be applied to an autoclosure "
4497+
"parameter",
4498+
(DeclName))
4499+
ERROR(function_builder_multiple, none,
4500+
"only one function builder attribute can be attached to a "
4501+
"%select{declaration|parameter}0", (bool))
4502+
NOTE(previous_function_builder_here, none,
4503+
"previous function builder specified here", ())
4504+
ERROR(function_builder_arguments, none,
4505+
"function builder attributes cannot have arguments", ())
44654506

44664507
#ifndef DIAG_NO_UNDEF
44674508
# if defined(DIAG)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ IDENTIFIER(Any)
3131
IDENTIFIER(ArrayLiteralElement)
3232
IDENTIFIER(atIndexedSubscript)
3333
IDENTIFIER_(bridgeToObjectiveC)
34+
IDENTIFIER(buildBlock)
35+
IDENTIFIER(buildDo)
36+
IDENTIFIER(buildEither)
37+
IDENTIFIER(buildIf)
3438
IDENTIFIER(Change)
3539
IDENTIFIER_WITH_NAME(code_, "_code")
3640
IDENTIFIER(CodingKeys)
@@ -59,6 +63,7 @@ IDENTIFIER(Encoder)
5963
IDENTIFIER(encoder)
6064
IDENTIFIER(error)
6165
IDENTIFIER(errorDomain)
66+
IDENTIFIER(first)
6267
IDENTIFIER(forKeyedSubscript)
6368
IDENTIFIER(Foundation)
6469
IDENTIFIER(for)
@@ -93,6 +98,7 @@ IDENTIFIER(parameter)
9398
IDENTIFIER(Protocol)
9499
IDENTIFIER(rawValue)
95100
IDENTIFIER(RawValue)
101+
IDENTIFIER(second)
96102
IDENTIFIER(Selector)
97103
IDENTIFIER(self)
98104
IDENTIFIER(Self)

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

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class RequirementRepr;
3535
class SpecializeAttr;
3636
class TypeAliasDecl;
3737
struct TypeLoc;
38+
class ValueDecl;
3839

3940
/// Display a nominal type or extension thereof.
4041
void simple_display(
@@ -622,6 +623,57 @@ class StructuralTypeRequest :
622623
bool isCached() const { return true; }
623624
};
624625

626+
/// Request the custom attribute which attaches a function builder to the
627+
/// given declaration.
628+
class AttachedFunctionBuilderRequest :
629+
public SimpleRequest<AttachedFunctionBuilderRequest,
630+
CacheKind::Cached,
631+
CustomAttr *,
632+
ValueDecl *> {
633+
public:
634+
using SimpleRequest::SimpleRequest;
635+
636+
private:
637+
friend SimpleRequest;
638+
639+
// Evaluation.
640+
llvm::Expected<CustomAttr *>
641+
evaluate(Evaluator &evaluator, ValueDecl *decl) const;
642+
643+
public:
644+
// Caching
645+
bool isCached() const;
646+
647+
// Cycle handling
648+
void diagnoseCycle(DiagnosticEngine &diags) const;
649+
void noteCycleStep(DiagnosticEngine &diags) const;
650+
};
651+
652+
/// Request the function builder type attached to the given declaration,
653+
/// if any.
654+
class FunctionBuilderTypeRequest :
655+
public SimpleRequest<FunctionBuilderTypeRequest,
656+
CacheKind::Cached,
657+
Type,
658+
ValueDecl *> {
659+
public:
660+
using SimpleRequest::SimpleRequest;
661+
662+
private:
663+
friend SimpleRequest;
664+
665+
llvm::Expected<Type>
666+
evaluate(Evaluator &evaluator, ValueDecl *decl) const;
667+
668+
public:
669+
// Caching
670+
bool isCached() const { return true; }
671+
672+
// Cycle handling
673+
void diagnoseCycle(DiagnosticEngine &diags) const;
674+
void noteCycleStep(DiagnosticEngine &diags) const;
675+
};
676+
625677
// Allow AnyValue to compare two Type values, even though Type doesn't
626678
// support ==.
627679
template<>
@@ -631,7 +683,7 @@ inline bool AnyValue::Holder<Type>::equals(const HolderBase &other) const {
631683
static_cast<const Holder<Type> &>(other).value.getPointer();
632684
}
633685

634-
void simple_display(llvm::raw_ostream &out, const Type &type);
686+
void simple_display(llvm::raw_ostream &out, Type value);
635687

636688
/// The zone number for the type checker.
637689
#define SWIFT_TYPE_CHECKER_REQUESTS_TYPEID_ZONE 10

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ SWIFT_TYPEID(AttachedPropertyWrapperRequest)
3333
SWIFT_TYPEID(AttachedPropertyWrapperTypeRequest)
3434
SWIFT_TYPEID(PropertyWrapperBackingPropertyTypeRequest)
3535
SWIFT_TYPEID(PropertyWrapperBackingPropertyInfoRequest)
36+
SWIFT_TYPEID(AttachedFunctionBuilderRequest)
37+
SWIFT_TYPEID(FunctionBuilderTypeRequest)

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,12 +3113,32 @@ BEGIN_CAN_TYPE_WRAPPER(FunctionType, AnyFunctionType)
31133113
}
31143114
END_CAN_TYPE_WRAPPER(FunctionType, AnyFunctionType)
31153115

3116-
/// Map the given parameter list onto a bitvector describing whether
3117-
/// the argument type at each index has a default argument associated with
3118-
/// it.
3119-
SmallBitVector
3120-
computeDefaultMap(ArrayRef<AnyFunctionType::Param> params,
3121-
const ValueDecl *paramOwner, bool skipCurriedSelf);
3116+
/// Provides information about the parameter list of a given declaration, including whether each parameter
3117+
/// has a default argument.
3118+
struct ParameterListInfo {
3119+
SmallBitVector defaultArguments;
3120+
std::vector<Type> functionBuilderTypes;
3121+
3122+
public:
3123+
ParameterListInfo() { }
3124+
3125+
ParameterListInfo(ArrayRef<AnyFunctionType::Param> params,
3126+
const ValueDecl *paramOwner, bool skipCurriedSelf);
3127+
3128+
/// Whether the parameter at the given index has a default argument.
3129+
bool hasDefaultArgument(unsigned paramIdx) const;
3130+
3131+
/// Retrieve the number of non-defaulted parameters.
3132+
unsigned numNonDefaultedParameters() const {
3133+
return defaultArguments.count();
3134+
}
3135+
3136+
/// Retrieve the number of parameters for which we have information.
3137+
unsigned size() const { return defaultArguments.size(); }
3138+
3139+
/// Retrieve the function builder type for the given parameter.
3140+
Type getFunctionBuilderType(unsigned paramIdx) const;
3141+
};
31223142

31233143
/// Turn a param list into a symbolic and printable representation that does not
31243144
/// include the types, something like (: , b:, c:)

branches/rxwei-patch-1/include/swift/Parse/CodeCompletionCallbacks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class CodeCompletionCallbacks {
116116
};
117117

118118
/// Set target decl for attribute if the CC token is in attribute of the decl.
119-
virtual void setAttrTargetDecl(Decl *D) {}
119+
virtual void setAttrTargetDeclKind(Optional<DeclKind> DK) {}
120120

121121
/// Complete the whole expression. This is a fallback that should
122122
/// produce results when more specific completion methods failed.

branches/rxwei-patch-1/include/swift/SILOptimizer/Utils/CFG.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ bool rotateLoop(SILLoop *L, DominanceInfo *DT, SILLoopInfo *LI,
9696
bool RotateSingleBlockLoops, SILBasicBlock *UpTo,
9797
bool ShouldVerify);
9898

99-
/// Splits the basic block before the instruction with an unconditional
100-
/// branch and updates the dominator tree and loop info.
99+
/// Splits the basic block before the instruction with an unconditional branch
100+
/// and updates the dominator tree and loop info. Returns the new, branched to
101+
/// block that contains the end of \p SplitBeforeInst's block.
101102
SILBasicBlock *splitBasicBlockAndBranch(SILBuilder &B,
102103
SILInstruction *SplitBeforeInst,
103104
DominanceInfo *DT, SILLoopInfo *LI);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,6 +2590,7 @@ void PrintAST::printOneParameter(const ParamDecl *param,
25902590

25912591
auto TheTypeLoc = param->getTypeLoc();
25922592

2593+
printAttributes(param);
25932594
printArgName();
25942595

25952596
if (!TheTypeLoc.getTypeRepr() && param->hasInterfaceType())

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,13 +1154,16 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
11541154
// Walk each parameter's decl and typeloc and default value.
11551155
if (doIt(P))
11561156
return true;
1157-
1157+
1158+
// Visit any custom attributes on the parameter.
1159+
visitCustomAttributes(P);
1160+
11581161
// Don't walk into the type if the decl is implicit, or if the type is
11591162
// implicit.
11601163
if (!P->isImplicit() && !P->isTypeLocImplicit() &&
11611164
doIt(P->getTypeLoc()))
11621165
return true;
1163-
1166+
11641167
if (auto *E = P->getDefaultValue()) {
11651168
auto res = doIt(E);
11661169
if (!res) return true;

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

Lines changed: 51 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
@@ -5740,6 +5760,30 @@ void ParamDecl::setStoredProperty(VarDecl *var) {
57405760
DefaultValueAndFlags.getPointer()->DefaultArg = var;
57415761
}
57425762

5763+
Type ValueDecl::getFunctionBuilderType() const {
5764+
// Fast path: most declarations (especially parameters, which is where
5765+
// this is hottest) do not have any custom attributes at all.
5766+
if (!getAttrs().hasAttribute<CustomAttr>()) return Type();
5767+
5768+
auto &ctx = getASTContext();
5769+
auto mutableThis = const_cast<ValueDecl *>(this);
5770+
return evaluateOrDefault(ctx.evaluator,
5771+
FunctionBuilderTypeRequest{mutableThis},
5772+
Type());
5773+
}
5774+
5775+
CustomAttr *ValueDecl::getAttachedFunctionBuilder() const {
5776+
// Fast path: most declarations (especially parameters, which is where
5777+
// this is hottest) do not have any custom attributes at all.
5778+
if (!getAttrs().hasAttribute<CustomAttr>()) return nullptr;
5779+
5780+
auto &ctx = getASTContext();
5781+
auto mutableThis = const_cast<ValueDecl *>(this);
5782+
return evaluateOrDefault(ctx.evaluator,
5783+
AttachedFunctionBuilderRequest{mutableThis},
5784+
nullptr);
5785+
}
5786+
57435787
void ParamDecl::setDefaultArgumentInitContext(Initializer *initContext) {
57445788
assert(DefaultValueAndFlags.getPointer());
57455789
DefaultValueAndFlags.getPointer()->InitContext = initContext;

0 commit comments

Comments
 (0)