Skip to content

Commit 73b5b94

Browse files
committed
---
yaml --- r: 294647 b: refs/heads/tensorflow c: 3b02901 h: refs/heads/master i: 294645: 902ae53 294643: dde344d 294639: 34937f7
1 parent 44fd354 commit 73b5b94

34 files changed

+248
-455
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819-
refs/heads/tensorflow: ad79bbaf860a3281b72d9f775b7cbfde57e30639
819+
refs/heads/tensorflow: 3b029010b9293538cd66fce7b76aaa6fe7a59137
820820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/CHANGELOG.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,6 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

29-
* [SR-8974][]:
30-
31-
Duplicate tuple element labels are no longer allowed, because it leads
32-
to incorrect behavior. For example:
33-
34-
```
35-
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)
36-
37-
enum Foo { case bar(x: Int, x: Int) }
38-
let f: Foo = .bar(x: 0, x: 1)
39-
```
40-
41-
will now be diagnosed as an error.
42-
43-
Note: You can still use duplicate labels when declaring functions and
44-
subscripts, as long as the internal labels are different. For example:
45-
46-
```
47-
func foo(bar x: Int, bar y: Int) {}
48-
subscript(a x: Int, a y: Int) -> Int {}
49-
```
50-
5129
* [SR-6118][]:
5230

5331
Subscripts can now declare default arguments:
@@ -7718,6 +7696,5 @@ Swift 1.0
77187696
[SR-7799]: <https://bugs.swift.org/browse/SR-7799>
77197697
[SR-8109]: <https://bugs.swift.org/browse/SR-8109>
77207698
[SR-8546]: <https://bugs.swift.org/browse/SR-8546>
7721-
[SR-8974]: <https://bugs.swift.org/browse/SR-8974>
77227699
[SR-9043]: <https://bugs.swift.org/browse/SR-9043>
77237700
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>

branches/tensorflow/include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,8 +3523,6 @@ ERROR(tuple_single_element,none,
35233523
"cannot create a single-element tuple with an element label", ())
35243524
ERROR(tuple_ellipsis,none,
35253525
"cannot create a variadic tuple", ())
3526-
ERROR(tuple_duplicate_label,none,
3527-
"cannot create a tuple with a duplicate element label", ())
35283526
ERROR(enum_element_ellipsis,none,
35293527
"variadic enum cases are not supported", ())
35303528

branches/tensorflow/include/swift/AST/Expr.h

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -953,25 +953,15 @@ class TapExpr : public Expr {
953953
class InterpolatedStringLiteralExpr : public LiteralExpr {
954954
/// Points at the beginning quote.
955955
SourceLoc Loc;
956-
/// Points at the ending quote.
957-
/// Needed for the upcoming \c ASTScope subsystem because lookups can be
958-
/// targeted to inside an \c InterpolatedStringLiteralExpr. It would be nicer
959-
/// to use \c EndLoc for this value, but then \c Lexer::getLocForEndOfToken()
960-
/// would not work for \c stringLiteral->getEndLoc().
961-
SourceLoc TrailingQuoteLoc;
962956
TapExpr *AppendingExpr;
963957
Expr *SemanticExpr;
964958

965959
public:
966-
InterpolatedStringLiteralExpr(SourceLoc Loc,
967-
SourceLoc TrailingQuoteLoc,
968-
unsigned LiteralCapacity,
960+
InterpolatedStringLiteralExpr(SourceLoc Loc, unsigned LiteralCapacity,
969961
unsigned InterpolationCount,
970962
TapExpr *AppendingExpr)
971963
: LiteralExpr(ExprKind::InterpolatedStringLiteral, /*Implicit=*/false),
972-
Loc(Loc),
973-
TrailingQuoteLoc(TrailingQuoteLoc),
974-
AppendingExpr(AppendingExpr), SemanticExpr() {
964+
Loc(Loc), AppendingExpr(AppendingExpr), SemanticExpr() {
975965
Bits.InterpolatedStringLiteralExpr.InterpolationCount = InterpolationCount;
976966
Bits.InterpolatedStringLiteralExpr.LiteralCapacity = LiteralCapacity;
977967
}
@@ -1008,11 +998,6 @@ class InterpolatedStringLiteralExpr : public LiteralExpr {
1008998
// token, so the range should be (Start == End).
1009999
return Loc;
10101000
}
1011-
SourceLoc getTrailingQuoteLoc() const {
1012-
// Except when computing a SourceRange for an ASTScope. Then the range
1013-
// must be (Start - TrainingQuoteLoc).
1014-
return TrailingQuoteLoc;
1015-
}
10161001

10171002
/// Call the \c callback with information about each segment in turn.
10181003
void forEachSegment(ASTContext &Ctx,

branches/tensorflow/include/swift/Serialization/ModuleFormat.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5252
/// describe what change you made. The content of this comment isn't important;
5353
/// it just ensures a conflict if two people change the module format.
5454
/// Don't worry about adhering to the 80-column limit for this line.
55-
const uint16_t SWIFTMODULE_VERSION_MINOR = 493; // dependency types for structs
55+
const uint16_t SWIFTMODULE_VERSION_MINOR = 491; // mangled class names as vtable keys
5656

5757
using DeclIDField = BCFixed<31>;
5858

@@ -948,8 +948,7 @@ namespace decls_block {
948948
GenericEnvironmentIDField, // generic environment
949949
AccessLevelField, // access level
950950
BCVBR<4>, // number of conformances
951-
BCVBR<4>, // number of inherited types
952-
BCArray<TypeIDField> // inherited types, followed by dependency types
951+
BCArray<TypeIDField> // inherited types
953952
// Trailed by the generic parameters (if any), the members record, and
954953
// finally conformance info (if any).
955954
>;
@@ -982,8 +981,7 @@ namespace decls_block {
982981
TypeIDField, // superclass
983982
AccessLevelField, // access level
984983
BCVBR<4>, // number of conformances
985-
BCVBR<4>, // number of inherited types
986-
BCArray<TypeIDField> // inherited types, followed by dependency types
984+
BCArray<TypeIDField> // inherited types
987985
// Trailed by the generic parameters (if any), the members record, and
988986
// finally conformance info (if any).
989987
>;

branches/tensorflow/lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,19 +1930,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
19301930
}
19311931
void visitInterpolatedStringLiteralExpr(InterpolatedStringLiteralExpr *E) {
19321932
printCommon(E, "interpolated_string_literal_expr");
1933-
1934-
// Print the trailing quote location
1935-
if (auto Ty = GetTypeOfExpr(E)) {
1936-
auto &Ctx = Ty->getASTContext();
1937-
auto TQL = E->getTrailingQuoteLoc();
1938-
if (TQL.isValid()) {
1939-
PrintWithColorRAII(OS, LocationColor) << " trailing_quote_loc=";
1940-
TQL.print(PrintWithColorRAII(OS, LocationColor).getOS(),
1941-
Ctx.SourceMgr);
1942-
}
1943-
}
1944-
PrintWithColorRAII(OS, LiteralValueColor)
1945-
<< " literal_capacity="
1933+
PrintWithColorRAII(OS, LiteralValueColor) << " literal_capacity="
19461934
<< E->getLiteralCapacity() << " interpolation_count="
19471935
<< E->getInterpolationCount() << '\n';
19481936
printRec(E->getAppendingExpr());

branches/tensorflow/lib/AST/Expr.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,6 @@ static LiteralExpr *
813813
shallowCloneImpl(const InterpolatedStringLiteralExpr *E, ASTContext &Ctx,
814814
llvm::function_ref<Type(const Expr *)> getType) {
815815
auto res = new (Ctx) InterpolatedStringLiteralExpr(E->getLoc(),
816-
E->getTrailingQuoteLoc(),
817816
E->getLiteralCapacity(),
818817
E->getInterpolationCount(),
819818
E->getAppendingExpr());

branches/tensorflow/lib/IDE/REPLCodeCompletion.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "swift/IDE/REPLCodeCompletion.h"
1818
#include "swift/AST/ASTContext.h"
19-
#include "swift/AST/DiagnosticSuppression.h"
2019
#include "swift/AST/Module.h"
2120
#include "swift/Basic/LLVM.h"
2221
#include "swift/Basic/SourceManager.h"
@@ -194,7 +193,7 @@ doCodeCompletion(SourceFile &SF, StringRef EnteredCode, unsigned *BufferID,
194193
CodeCompletionCallbacksFactory *CompletionCallbacksFactory) {
195194
// Temporarily disable printing the diagnostics.
196195
ASTContext &Ctx = SF.getASTContext();
197-
DiagnosticSuppression SuppressedDiags(Ctx.Diags);
196+
DiagnosticTransaction DelayedDiags(Ctx.Diags);
198197

199198
std::string AugmentedCode = EnteredCode.str();
200199
AugmentedCode += '\0';
@@ -223,10 +222,7 @@ doCodeCompletion(SourceFile &SF, StringRef EnteredCode, unsigned *BufferID,
223222
// Now we are done with code completion. Remove the declarations we
224223
// temporarily inserted.
225224
SF.Decls.resize(OriginalDeclCount);
226-
227-
// Reset the error state because it's only relevant to the code that we just
228-
// processed, which now gets thrown away.
229-
Ctx.Diags.resetHadAnyError();
225+
DelayedDiags.abort();
230226
}
231227

232228
void REPLCompletions::populate(SourceFile &SF, StringRef EnteredCode) {

branches/tensorflow/lib/Parse/ParseExpr.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,8 +2039,8 @@ ParserResult<Expr> Parser::parseExprStringLiteral() {
20392039
// Return an error, but include an empty InterpolatedStringLiteralExpr
20402040
// so that parseDeclPoundDiagnostic() can figure out why this string
20412041
// literal was bad.
2042-
return makeParserErrorResult(new (Context) InterpolatedStringLiteralExpr(
2043-
Loc, Loc.getAdvancedLoc(CloseQuoteBegin), 0, 0, nullptr));
2042+
return makeParserErrorResult(
2043+
new (Context) InterpolatedStringLiteralExpr(Loc, 0, 0, nullptr));
20442044
}
20452045

20462046
unsigned LiteralCapacity = 0;
@@ -2093,8 +2093,7 @@ ParserResult<Expr> Parser::parseExprStringLiteral() {
20932093
}
20942094

20952095
return makeParserResult(Status, new (Context) InterpolatedStringLiteralExpr(
2096-
Loc, Loc.getAdvancedLoc(CloseQuoteBegin),
2097-
LiteralCapacity, InterpolationCount,
2096+
Loc, LiteralCapacity, InterpolationCount,
20982097
AppendingExpr));
20992098
}
21002099

branches/tensorflow/lib/Parse/ParseIfConfig.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "swift/Parse/Parser.h"
1818

1919
#include "swift/AST/ASTVisitor.h"
20-
#include "swift/AST/DiagnosticSuppression.h"
2120
#include "swift/Basic/Defer.h"
2221
#include "swift/Basic/LangOptions.h"
2322
#include "swift/Basic/Version.h"
@@ -639,12 +638,6 @@ ParserResult<IfConfigDecl> Parser::parseIfConfig(
639638
SmallVector<ASTNode, 16> Elements;
640639
if (isActive || !isVersionCondition) {
641640
parseElements(Elements, isActive);
642-
} else if (SyntaxContext->isEnabled()) {
643-
// We shouldn't skip code if we are building syntax tree.
644-
// The parser will keep running and we just discard the AST part.
645-
DiagnosticSuppression suppression(Context.Diags);
646-
SmallVector<ASTNode, 16> dropedElements;
647-
parseElements(dropedElements, false);
648641
} else {
649642
DiagnosticTransaction DT(Diags);
650643
skipUntilConditionalBlockClose();

branches/tensorflow/lib/SILOptimizer/Mandatory/MandatoryInlining.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ static void fixupReferenceCounts(
8888
DeadEndBlocks deadEndBlocks(pai->getFunction());
8989
SmallVector<SILBasicBlock *, 4> leakingBlocks;
9090

91-
auto errorBehavior =
92-
ownership::ErrorBehaviorKind::ReturnFalseOnLeakAssertOtherwise;
91+
auto errorBehavior = ownership::ErrorBehaviorKind::ReturnFalse;
9392

9493
// Add a copy of each non-address type capture argument to lifetime extend the
9594
// captured argument over at least the inlined function and till the end of a
@@ -142,21 +141,33 @@ static void fixupReferenceCounts(
142141
auto error =
143142
valueHasLinearLifetime(copy, {applySite}, {}, visitedBlocks,
144143
deadEndBlocks, errorBehavior, &leakingBlocks);
145-
if (error.getFoundError()) {
144+
if (error.getFoundLeak()) {
146145
while (!leakingBlocks.empty()) {
147146
auto *leakingBlock = leakingBlocks.pop_back_val();
148147
auto loc = RegularLocation::getAutoGeneratedLocation();
149148
SILBuilderWithScope builder(leakingBlock->begin());
149+
if (hasOwnership) {
150+
builder.createEndBorrow(loc, argument);
151+
}
150152
builder.emitDestroyValueOperation(loc, copy);
151153
}
152154
}
153155

154-
insertAfterApply(applySite, [&](SILBasicBlock::iterator iter) {
155-
if (hasOwnership) {
156-
SILBuilderWithScope(iter).createEndBorrow(loc, argument);
157-
}
158-
SILBuilderWithScope(iter).emitDestroyValueOperation(loc, copy);
159-
});
156+
// If we found an over consume it means that our value is consumed within
157+
// the loop. That means our leak code will have lifetime extended the
158+
// value over the loop. So we should /not/ insert a destroy after the
159+
// apply site. In contrast, if we do not have an over consume, we must
160+
// have been compensating for uses in the top of a diamond and need to
161+
// insert a destroy after the apply since the leak will just cover the
162+
// other path.
163+
if (!error.getFoundOverConsume()) {
164+
insertAfterApply(applySite, [&](SILBasicBlock::iterator iter) {
165+
if (hasOwnership) {
166+
SILBuilderWithScope(iter).createEndBorrow(loc, argument);
167+
}
168+
SILBuilderWithScope(iter).emitDestroyValueOperation(loc, copy);
169+
});
170+
}
160171
v = argument;
161172
break;
162173
}

branches/tensorflow/lib/SILOptimizer/Mandatory/OSLogOptimization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static SILValue emitCodeForSymbolicValue(SymbolicValue symVal,
390390
return newStructInst;
391391
}
392392
default: {
393-
llvm_unreachable("Symbolic value kind is not supported");
393+
assert(false && "Symbolic value kind is not supported");
394394
}
395395
}
396396
}

branches/tensorflow/lib/SILOptimizer/Utils/ConstExpr.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,6 @@ SymbolicValue ConstExprFunctionState::computeConstantValue(SILValue value) {
406406
if (auto *bai = dyn_cast<BeginAccessInst>(value))
407407
return getConstantValue(bai->getOperand());
408408

409-
// Look through copy_value and begin_borrow since the interpreter doesn't
410-
// model these memory management instructions.
411-
if (isa<CopyValueInst>(value) || isa<BeginBorrowInst>(value))
412-
return getConstantValue(cast<SingleValueInstruction>(value)->getOperand(0));
413-
414409
LLVM_DEBUG(llvm::dbgs() << "ConstExpr Unknown simple: " << *value << "\n");
415410

416411
// Otherwise, we don't know how to handle this.
@@ -1297,8 +1292,7 @@ ConstExprFunctionState::evaluateFlowSensitive(SILInstruction *inst) {
12971292
// skip them.
12981293
isa<DestroyAddrInst>(inst) || isa<RetainValueInst>(inst) ||
12991294
isa<ReleaseValueInst>(inst) || isa<StrongRetainInst>(inst) ||
1300-
isa<StrongReleaseInst>(inst) || isa<DestroyValueInst>(inst) ||
1301-
isa<EndBorrowInst>(inst))
1295+
isa<StrongReleaseInst>(inst))
13021296
return None;
13031297

13041298
// If this is a special flow-sensitive instruction like a stack allocation,
@@ -1308,15 +1302,6 @@ ConstExprFunctionState::evaluateFlowSensitive(SILInstruction *inst) {
13081302
return None;
13091303
}
13101304

1311-
// Make sure that our copy_value, begin_borrow form constants. Otherwise,
1312-
// return why.
1313-
if (isa<CopyValueInst>(inst) || isa<BeginBorrowInst>(inst)) {
1314-
auto result = getConstantValue(inst->getOperand(0));
1315-
if (!result.isConstant())
1316-
return result;
1317-
return None;
1318-
}
1319-
13201305
// If this is a deallocation of a memory object that we are tracking, then
13211306
// don't do anything. The memory is allocated in a BumpPtrAllocator so there
13221307
// is no useful way to free it.

branches/tensorflow/lib/Sema/MiscDiagnostics.cpp

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
6464
class DiagnoseWalker : public ASTWalker {
6565
SmallPtrSet<Expr*, 4> AlreadyDiagnosedMetatypes;
6666
SmallPtrSet<DeclRefExpr*, 4> AlreadyDiagnosedBitCasts;
67-
68-
/// Keep track of acceptable DiscardAssignmentExpr's.
67+
68+
// Keep track of acceptable DiscardAssignmentExpr's.
6969
SmallPtrSet<DiscardAssignmentExpr*, 2> CorrectDiscardAssignmentExprs;
7070

7171
/// Keep track of the arguments to CallExprs.
@@ -245,42 +245,6 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
245245
}
246246
}
247247

248-
// Diagnose tuple expressions with duplicate element label
249-
if (auto *tupleExpr = dyn_cast<TupleExpr>(E)) {
250-
// FIXME: Duplicate labels on enum payloads should be diagnosed
251-
// when declared, not when called.
252-
bool isEnumCase = false;
253-
if (auto CE = dyn_cast_or_null<CallExpr>(Parent.getAsExpr())) {
254-
auto calledValue = CE->getCalledValue();
255-
if (calledValue) {
256-
isEnumCase = isa<EnumElementDecl>(calledValue);
257-
}
258-
}
259-
260-
if ((!CallArgs.count(tupleExpr)) || isEnumCase) {
261-
auto diagnose = false;
262-
263-
llvm::SmallDenseSet<Identifier> names;
264-
names.reserve(tupleExpr->getNumElements());
265-
266-
for (auto name : tupleExpr->getElementNames()) {
267-
if (name.empty())
268-
continue;
269-
270-
if (names.count(name) == 1) {
271-
diagnose = true;
272-
break;
273-
}
274-
275-
names.insert(name);
276-
}
277-
278-
if (diagnose) {
279-
TC.diagnose(tupleExpr->getLoc(), diag::tuple_duplicate_label);
280-
}
281-
}
282-
}
283-
284248
return { true, E };
285249
}
286250

branches/tensorflow/lib/Sema/TypeCheckPattern.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class ResolvePattern : public ASTVisitor<ResolvePattern,
313313
Pattern *visitExprPattern(ExprPattern *P) {
314314
if (P->isResolved())
315315
return P;
316-
316+
317317
// Try to convert to a pattern.
318318
Pattern *exprAsPattern = visit(P->getSubExpr());
319319
// If we failed, keep the ExprPattern as is.

0 commit comments

Comments
 (0)