Skip to content

Commit 496f353

Browse files
committed
---
yaml --- r: 347489 b: refs/heads/master c: 1ecc4a5 h: refs/heads/master i: 347487: 2c7c3a6
1 parent f3a4d5d commit 496f353

33 files changed

+720
-900
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 572c7d943bf54360d50dcf13e3ae870fb29a97df
2+
refs/heads/master: 1ecc4a5b72e3188b2773eff95a4f4490c6e5ede7
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,21 +1377,6 @@ WARNING(attr_availability_nonspecific_platform_unexpected_version,none,
13771377
"unexpected version number in '%0' attribute for non-specific platform "
13781378
"'*'", (StringRef))
13791379

1380-
// autoclosure
1381-
ERROR(attr_autoclosure_expected_r_paren,PointsToFirstBadToken,
1382-
"expected ')' in @autoclosure", ())
1383-
ERROR(attr_noescape_conflicts_escaping_autoclosure,none,
1384-
"@noescape conflicts with @autoclosure(escaping)", ())
1385-
ERROR(attr_noescape_implied_by_autoclosure,none,
1386-
"@noescape is implied by @autoclosure and should not be "
1387-
"redundantly specified", ())
1388-
ERROR(attr_autoclosure_escaping_deprecated,none,
1389-
"@autoclosure(escaping) has been removed; use @autoclosure @escaping instead",
1390-
())
1391-
ERROR(attr_noescape_deprecated,none,
1392-
"@noescape is the default and has been removed",
1393-
())
1394-
13951380
// convention
13961381
ERROR(convention_attribute_expected_lparen,none,
13971382
"expected '(' after 'convention' attribute", ())

trunk/include/swift/AST/DiagnosticsSIL.def

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,27 @@ ERROR(unsupported_c_function_pointer_conversion,none,
116116
ERROR(objc_selector_malformed,none,"the type ObjectiveC.Selector is malformed",
117117
())
118118

119+
// Invalid escaping capture diagnostics.
120+
ERROR(escaping_inout_capture,none,
121+
"escaping closure captures 'inout' parameter %0", (Identifier))
122+
NOTE(inout_param_defined_here,none,
123+
"parameter %0 is declared 'inout'", (Identifier))
124+
ERROR(escaping_mutable_self_capture,none,
125+
"escaping closure captures mutating 'self' parameter", ())
126+
127+
ERROR(escaping_noescape_param_capture,none,
128+
"escaping closure captures non-escaping parameter %0", (Identifier))
129+
NOTE(noescape_param_defined_here,none,
130+
"parameter %0 is implicitly non-escaping", (Identifier))
131+
132+
ERROR(escaping_noescape_var_capture,none,
133+
"escaping closure captures non-escaping value", ())
134+
135+
NOTE(value_captured_here,none,"captured here", ())
136+
137+
NOTE(value_captured_transitively,none,
138+
"captured indirectly by this call", ())
139+
119140
// Definite initialization diagnostics.
120141
NOTE(variable_defined_here,none,
121142
"%select{variable|constant}0 defined here", (bool))

trunk/include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,21 +2900,6 @@ NOTE(transitive_capture_through_here,none,
29002900
"%0, declared here, captures %1",
29012901
(Identifier, Identifier))
29022902

2903-
ERROR(closure_implicit_capture_without_noescape,none,
2904-
"escaping closures can only capture inout parameters explicitly by value",
2905-
())
2906-
ERROR(closure_implicit_capture_mutating_self,none,
2907-
"escaping closure cannot capture a mutating self parameter",
2908-
())
2909-
NOTE(create_mutating_copy_or_capture_self,none,
2910-
"create a mutating copy of self, or explicitly capture self for immutability",
2911-
())
2912-
ERROR(nested_function_with_implicit_capture_argument,none,
2913-
"nested function with %select{an |}0implicitly captured inout "
2914-
"parameter%select{|s}0 can only be used as a non-escaping argument", (bool))
2915-
ERROR(nested_function_escaping_inout_capture,none,
2916-
"nested function cannot capture inout parameter and escape", ())
2917-
29182903
WARNING(recursive_accessor_reference,none,
29192904
"attempting to %select{access|modify}1 %0 within its own "
29202905
"%select{getter|setter}1", (Identifier, bool))
@@ -3039,19 +3024,10 @@ WARNING(debug_description_in_string_interpolation_segment,none,
30393024
NOTE(silence_debug_description_in_interpolation_segment_call,none,
30403025
"use 'String(describing:)' to silence this warning", ())
30413026

3042-
ERROR(invalid_noescape_use,none,
3043-
"non-escaping %select{value|parameter}1 %0 may only be called",
3044-
(Identifier, bool))
30453027
NOTE(noescape_parameter,none,
30463028
"parameter %0 is implicitly non-escaping",
30473029
(Identifier))
30483030

3049-
ERROR(closure_noescape_use,none,
3050-
"closure use of non-escaping parameter %0 may allow it to escape",
3051-
(Identifier))
3052-
ERROR(decl_closure_noescape_use,none,
3053-
"declaration closing over non-escaping parameter %0 may allow it to escape",
3054-
(Identifier))
30553031
ERROR(passing_noescape_to_escaping,none,
30563032
"passing non-escaping parameter %0 to function expecting an @escaping closure",
30573033
(Identifier))
@@ -3524,8 +3500,6 @@ NOTE(overridden_required_initializer_here,none,
35243500
// Functions
35253501
ERROR(attribute_requires_function_type,none,
35263502
"@%0 attribute only applies to function types", (StringRef))
3527-
ERROR(attribute_not_supported,none,
3528-
"this attribute is not supported", ())
35293503
ERROR(unsupported_convention,none,
35303504
"convention '%0' not supported", (StringRef))
35313505
ERROR(unreferenced_generic_parameter,none,

trunk/include/swift/AST/Types.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,14 @@ class alignas(1 << TypeAlignInBits) TypeBase {
622622
return getRecursiveProperties().isLValue();
623623
}
624624

625-
/// Is a type with these properties materializable: that is, is it a
626-
/// first-class value type?
625+
/// Is this a first-class value type, meaning it is not an InOutType or a
626+
/// tuple type containing an InOutType?
627627
bool isMaterializable();
628628

629+
/// Is this a non-escaping type, that is, a non-escaping function type or a
630+
/// tuple type containing a non-escaping type?
631+
bool isNoEscape() const;
632+
629633
/// Determine whether the type is dependent on DynamicSelf.
630634
bool hasDynamicSelfType() const {
631635
return getRecursiveProperties().hasDynamicSelf();
@@ -647,11 +651,6 @@ class alignas(1 << TypeAlignInBits) TypeBase {
647651
return getRecursiveProperties().hasDependentMember();
648652
}
649653

650-
/// Check if this type is a valid type for the LHS of an assignment.
651-
/// This mainly means hasLValueType(), but empty tuples and tuples of empty
652-
/// tuples also qualify.
653-
bool isAssignableType();
654-
655654
/// isExistentialType - Determines whether this type is an existential type,
656655
/// whose real (runtime) type is unknown but which is known to conform to
657656
/// some set of protocols. Protocol and protocol-conformance types are

trunk/include/swift/Migrator/FixitFilter.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ struct FixitFilter {
127127
Info.ID == diag::where_inside_brackets.ID ||
128128
Info.ID == diag::selector_construction_suggest.ID ||
129129
Info.ID == diag::selector_literal_deprecated_suggest.ID ||
130-
Info.ID == diag::attr_noescape_deprecated.ID ||
131-
Info.ID == diag::attr_autoclosure_escaping_deprecated.ID ||
132130
Info.ID == diag::attr_warn_unused_result_removed.ID ||
133131
Info.ID == diag::any_as_anyobject_fixit.ID ||
134132
Info.ID == diag::deprecated_protocol_composition.ID ||

trunk/include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ PASS(Devirtualizer, "devirtualizer",
134134
"Indirect Call Devirtualization")
135135
PASS(DiagnoseInfiniteRecursion, "diagnose-infinite-recursion",
136136
"Diagnose Infinitely-Recursive Code")
137+
PASS(DiagnoseInvalidEscapingCaptures, "diagnose-invalid-escaping-captures",
138+
"Diagnose Invalid Escaping Captures")
137139
PASS(DiagnoseStaticExclusivity, "diagnose-static-exclusivity",
138140
"Static Enforcement of Law of Exclusivity")
139141
PASS(DiagnoseUnreachable, "diagnose-unreachable",

trunk/lib/AST/Type.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -543,19 +543,6 @@ bool TypeBase::isBool() {
543543
return false;
544544
}
545545

546-
547-
bool TypeBase::isAssignableType() {
548-
if (hasLValueType()) return true;
549-
if (auto tuple = getAs<TupleType>()) {
550-
for (auto eltType : tuple->getElementTypes()) {
551-
if (!eltType->isAssignableType())
552-
return false;
553-
}
554-
return true;
555-
}
556-
return false;
557-
}
558-
559546
Type TypeBase::getRValueType() {
560547
// If the type is not an lvalue, this is a no-op.
561548
if (!hasLValueType())
@@ -3079,6 +3066,24 @@ const DependentMemberType *TypeBase::findUnresolvedDependentMemberType() {
30793066
return unresolvedDepMemTy;
30803067
}
30813068

3069+
bool TypeBase::isNoEscape() const {
3070+
auto type = getCanonicalType();
3071+
3072+
if (auto silFuncTy = dyn_cast<SILFunctionType>(type))
3073+
return silFuncTy->isNoEscape();
3074+
3075+
if (auto funcTy = dyn_cast<FunctionType>(type))
3076+
return funcTy->isNoEscape();
3077+
3078+
if (auto tupleTy = dyn_cast<TupleType>(type)) {
3079+
for (auto eltTy : tupleTy.getElementTypes())
3080+
if (eltTy->isNoEscape())
3081+
return true;
3082+
}
3083+
3084+
return false;
3085+
}
3086+
30823087
static Type getConcreteTypeForSuperclassTraversing(Type t) {
30833088
if (t->isExistentialType()) {
30843089
return t->getExistentialLayout().getSuperclass();

trunk/lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,31 +1999,10 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
19991999
StringRef Text = Tok.getText();
20002000
SourceLoc Loc = consumeToken();
20012001

2002-
bool isAutoclosureEscaping = false;
2003-
SourceRange autoclosureEscapingParenRange;
20042002
StringRef conventionName;
20052003
StringRef witnessMethodProtocol;
20062004

2007-
// Handle @autoclosure(escaping)
2008-
if (attr == TAK_autoclosure) {
2009-
// We need to do a bit of lookahead here to make sure we parse a (weird)
2010-
// type like: "@autoclosure (escaping) -> Int" correctly (escaping is the
2011-
// name of a type here). We also want to support the case where the
2012-
// function type coming up is a typealias, e.g. "@autoclosure (escaping) T".
2013-
if (Tok.is(tok::l_paren) && peekToken().getText() == "escaping") {
2014-
Parser::BacktrackingScope Backtrack(*this);
2015-
consumeToken(tok::l_paren);
2016-
consumeToken(tok::identifier);
2017-
isAutoclosureEscaping =
2018-
Tok.is(tok::r_paren) && peekToken().isNot(tok::arrow);
2019-
}
2020-
2021-
if (isAutoclosureEscaping) {
2022-
autoclosureEscapingParenRange.Start = consumeToken(tok::l_paren);
2023-
consumeToken(tok::identifier);
2024-
autoclosureEscapingParenRange.End = consumeToken(tok::r_paren);
2025-
}
2026-
} else if (attr == TAK_convention) {
2005+
if (attr == TAK_convention) {
20272006
SourceLoc LPLoc;
20282007
if (!consumeIfNotAtStartOfLine(tok::l_paren)) {
20292008
if (!justChecking)
@@ -2086,48 +2065,10 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
20862065
switch (attr) {
20872066
default: break;
20882067
case TAK_autoclosure:
2089-
// Handle @autoclosure(escaping)
2090-
if (isAutoclosureEscaping) {
2091-
// @noescape @autoclosure(escaping) makes no sense.
2092-
if (Attributes.has(TAK_noescape)) {
2093-
diagnose(Loc, diag::attr_noescape_conflicts_escaping_autoclosure);
2094-
} else {
2095-
diagnose(Loc, diag::attr_autoclosure_escaping_deprecated)
2096-
.fixItReplace(autoclosureEscapingParenRange, " @escaping ");
2097-
}
2098-
Attributes.setAttr(TAK_escaping, Loc);
2099-
} else if (Attributes.has(TAK_noescape) && !isInSILMode()) {
2100-
diagnose(Loc, diag::attr_noescape_implied_by_autoclosure);
2101-
}
2102-
break;
2103-
2104-
case TAK_noescape:
2105-
// You can't specify @noescape and @escaping together.
2106-
if (Attributes.has(TAK_escaping)) {
2107-
diagnose(Loc, diag::attr_escaping_conflicts_noescape);
2108-
return false;
2109-
}
2110-
2111-
// @noescape after @autoclosure is redundant.
2112-
if (Attributes.has(TAK_autoclosure) && !isInSILMode()) {
2113-
diagnose(Loc, diag::attr_noescape_implied_by_autoclosure);
2114-
}
2115-
2116-
// @noescape is deprecated and no longer used
2117-
// In SIL, the polarity of @escaping is reversed.
2118-
// @escaping is the default and @noescape is explicit.
2119-
if (!isInSILMode()) {
2120-
diagnose(Loc, diag::attr_noescape_deprecated)
2121-
.fixItRemove({Attributes.AtLoc, Loc});
2122-
}
2123-
break;
21242068
case TAK_escaping:
2125-
// You can't specify @noescape and @escaping together.
2126-
if (Attributes.has(TAK_noescape)) {
2127-
diagnose(Loc, diag::attr_escaping_conflicts_noescape);
2128-
return false;
2129-
}
2069+
case TAK_noescape:
21302070
break;
2071+
21312072
case TAK_out:
21322073
case TAK_in:
21332074
case TAK_owned:

trunk/lib/SILOptimizer/Mandatory/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ silopt_register_sources(
77
DIMemoryUseCollector.cpp
88
DataflowDiagnostics.cpp
99
DiagnoseInfiniteRecursion.cpp
10+
DiagnoseInvalidEscapingCaptures.cpp
1011
DiagnoseStaticExclusivity.cpp
1112
DiagnoseUnreachable.cpp
1213
GuaranteedARCOpts.cpp

0 commit comments

Comments
 (0)