Skip to content

Commit 1209005

Browse files
authored
---
yaml --- r: 294767 b: refs/heads/tensorflow c: e80b965 h: refs/heads/master i: 294765: d73f061 294763: 0b7e2a0 294759: eb3937a 294751: 24b3328
1 parent 428ff8f commit 1209005

File tree

19 files changed

+200
-65
lines changed

19 files changed

+200
-65
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: 8daa0348edf1e5b94b6faa9148a0465617861491
819+
refs/heads/tensorflow: e80b965e794db766d92d274934a043ea2ccdf5a1
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/docs/SIL.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,7 +2337,7 @@ assign_by_delegate
23372337
``````````````````
23382338
::
23392339

2340-
sil-instruction ::= 'assign_by_delegate' sil-operand 'to' sil-operand ',' 'init' sil-operand ',' 'set' sil-operand
2340+
sil-instruction ::= 'assign_by_delegate' sil-operand 'to' sil-operand ',' 'init' sil-operand ',' 'set' sil-operand
23412341

23422342
assign_by_delegate %0 : $S to %1 : $*T, init %2 : $F, set %3 : $G
23432343
// $S can be a value or address type
@@ -3054,7 +3054,7 @@ function_ref
30543054
Creates a reference to a SIL function.
30553055

30563056
dynamic_function_ref
3057-
````````````
3057+
````````````````````
30583058
::
30593059

30603060
sil-instruction ::= 'dynamic_function_ref' sil-function-name ':' sil-type
@@ -3091,7 +3091,7 @@ We will generate::
30913091
}
30923092

30933093
prev_dynamic_function_ref
3094-
````````````
3094+
`````````````````````````
30953095
::
30963096

30973097
sil-instruction ::= 'prev_dynamic_function_ref' sil-function-name ':' sil-type

branches/tensorflow/lib/AST/DiagnosticEngine.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,14 @@ static DiagnosticKind toDiagnosticKind(DiagnosticState::Behavior behavior) {
622622
llvm_unreachable("Unhandled DiagnosticKind in switch.");
623623
}
624624

625-
/// A special option only for compiler writers that causes Diagnostics to assert
626-
/// when a failure diagnostic is emitted. Intended for use in the debugger.
625+
// A special option only for compiler writers that causes Diagnostics to assert
626+
// when a failure diagnostic is emitted. Intended for use in the debugger.
627627
llvm::cl::opt<bool> AssertOnError("swift-diagnostics-assert-on-error",
628628
llvm::cl::init(false));
629+
// A special option only for compiler writers that causes Diagnostics to assert
630+
// when a warning diagnostic is emitted. Intended for use in the debugger.
631+
llvm::cl::opt<bool> AssertOnWarning("swift-diagnostics-assert-on-warning",
632+
llvm::cl::init(false));
629633

630634
DiagnosticState::Behavior DiagnosticState::determineBehavior(DiagID id) {
631635
auto set = [this](DiagnosticState::Behavior lvl) {
@@ -637,6 +641,8 @@ DiagnosticState::Behavior DiagnosticState::determineBehavior(DiagID id) {
637641
}
638642

639643
assert((!AssertOnError || !anyErrorOccurred) && "We emitted an error?!");
644+
assert((!AssertOnWarning || (lvl != Behavior::Warning)) &&
645+
"We emitted a warning?!");
640646
previousBehavior = lvl;
641647
return lvl;
642648
};

branches/tensorflow/lib/IDE/SyntaxModel.cpp

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ SyntaxModelContext::SyntaxModelContext(SourceFile &SrcFile)
5656
std::vector<SyntaxNode> Nodes;
5757
SourceLoc AttrLoc;
5858
SourceLoc UnaryMinusLoc;
59-
auto LiteralStartLoc = Optional<SourceLoc>();
6059
for (unsigned I = 0, E = Tokens.size(); I != E; ++I) {
6160
auto &Tok = Tokens[I];
6261
// Ignore empty string literals between interpolations, e.g. "\(1)\(2)"
@@ -85,16 +84,6 @@ SyntaxModelContext::SyntaxModelContext(SourceFile &SrcFile)
8584
Loc = Tok.getLoc();
8685
Length = Tok.getLength();
8786

88-
if (LiteralStartLoc.hasValue() && Length.hasValue()) {
89-
if (Tok.getKind() != tok::r_paren)
90-
continue;
91-
Kind = SyntaxNodeKind::ObjectLiteral;
92-
Nodes.emplace_back(Kind, CharSourceRange(SM, LiteralStartLoc.getValue(),
93-
Tok.getRange().getEnd()));
94-
LiteralStartLoc = Optional<SourceLoc>();
95-
continue;
96-
}
97-
9887
switch(Tok.getKind()) {
9988
#define KEYWORD(X) case tok::kw_##X:
10089
#include "swift/Syntax/TokenKinds.def"
@@ -105,8 +94,8 @@ SyntaxModelContext::SyntaxModelContext(SourceFile &SrcFile)
10594

10695
#define POUND_OBJECT_LITERAL(Name, Desc, Proto) case tok::pound_##Name:
10796
#include "swift/Syntax/TokenKinds.def"
108-
LiteralStartLoc = Loc;
109-
continue;
97+
Kind = SyntaxNodeKind::Keyword;
98+
break;
11099

111100
#define POUND_COND_DIRECTIVE_KEYWORD(Name) case tok::pound_##Name:
112101
#include "swift/Syntax/TokenKinds.def"
@@ -260,6 +249,9 @@ class ModelASTWalker : public ASTWalker {
260249
Optional<SyntaxNode> parseFieldNode(StringRef Text, StringRef OrigText,
261250
SourceLoc OrigLoc);
262251
llvm::DenseSet<ASTNode> VisitedNodesInsideIfConfig;
252+
/// When non-zero, we should avoid passing tokens as syntax nodes since a parent of several tokens
253+
/// is considered as one, e.g. object literal expression.
254+
uint8_t AvoidPassingSyntaxToken = 0;
263255

264256
public:
265257
SyntaxModelWalker &Walker;
@@ -494,8 +486,9 @@ std::pair<bool, Expr *> ModelASTWalker::walkToExprPre(Expr *E) {
494486
SN.NameRange = CharSourceRange(SM, NRStart, NREnd);
495487
SN.BodyRange =
496488
innerCharSourceRangeFromSourceRange(SM, ObjectE->getSourceRange());
489+
// Consider the object literal as a single syntax token for highlighting.
490+
passNonTokenNode({SyntaxNodeKind::ObjectLiteral, SN.Range});
497491
pushStructureNode(SN, E);
498-
499492
} else if (auto *ArrayE = dyn_cast<ArrayExpr>(E)) {
500493
SyntaxStructureNode SN;
501494
SN.Kind = SyntaxStructureKind::ArrayExpression;
@@ -1152,8 +1145,10 @@ bool ModelASTWalker::passTokenNodesUntil(SourceLoc Loc,
11521145
}
11531146
break;
11541147
}
1155-
if (!passNode(TokenNodes[I]))
1156-
return false;
1148+
if (!AvoidPassingSyntaxToken) {
1149+
if (!passNode(TokenNodes[I]))
1150+
return false;
1151+
}
11571152
}
11581153

11591154
TokenNodes = TokenNodes.slice(I);
@@ -1200,9 +1195,15 @@ bool ModelASTWalker::passNode(const SyntaxNode &Node) {
12001195
return Walker.walkToNodePost(Node);
12011196
}
12021197

1198+
static bool shouldAvoidPssingSyntaxToken(const SyntaxStructureNode &Node) {
1199+
return Node.Kind == SyntaxStructureKind::ObjectLiteralExpression;
1200+
}
1201+
12031202
bool ModelASTWalker::pushStructureNode(const SyntaxStructureNode &Node,
12041203
const ASTNodeType& ASTNode) {
12051204
SubStructureStack.emplace_back(Node, ASTNode);
1205+
if (shouldAvoidPssingSyntaxToken(Node))
1206+
AvoidPassingSyntaxToken ++;
12061207

12071208
if (!passTokenNodesUntil(Node.Range.getStart(), ExcludeNodeAtLocation))
12081209
return false;
@@ -1215,6 +1216,12 @@ bool ModelASTWalker::pushStructureNode(const SyntaxStructureNode &Node,
12151216
bool ModelASTWalker::popStructureNode() {
12161217
assert(!SubStructureStack.empty());
12171218
SyntaxStructureNode Node = SubStructureStack.back().StructureNode;
1219+
SWIFT_DEFER {
1220+
if (shouldAvoidPssingSyntaxToken(Node)) {
1221+
assert(AvoidPassingSyntaxToken);
1222+
AvoidPassingSyntaxToken --;
1223+
}
1224+
};
12181225
SubStructureStack.pop_back();
12191226

12201227
// VarDecls are popped before we see their TypeRepr, so if we pass the token

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -529,15 +529,20 @@ static bool simplifyBlocksWithCallsToNoReturn(SILBasicBlock &BB,
529529
// Diagnose the unreachable code within the same block as the call to
530530
// noreturn.
531531
if (isUserCode(CurrentInst) && !DiagnosedUnreachableCode) {
532-
if (NoReturnCall->getLoc().is<RegularLocation>()) {
533-
if (!NoReturnCall->getLoc().isASTNode<ExplicitCastExpr>()) {
534-
diagnose(BB.getModule().getASTContext(),
535-
CurrentInst->getLoc().getSourceLoc(),
536-
diag::unreachable_code);
537-
diagnose(BB.getModule().getASTContext(),
538-
NoReturnCall->getLoc().getSourceLoc(),
539-
diag::call_to_noreturn_note);
540-
DiagnosedUnreachableCode = true;
532+
// If we have an instruction that is an end_borrow, ignore it. This
533+
// happens when passing a guaranteed argument through generic code paths
534+
// to no return functions.
535+
if (!isa<EndBorrowInst>(CurrentInst)) {
536+
if (NoReturnCall->getLoc().is<RegularLocation>()) {
537+
if (!NoReturnCall->getLoc().isASTNode<ExplicitCastExpr>()) {
538+
diagnose(BB.getModule().getASTContext(),
539+
CurrentInst->getLoc().getSourceLoc(),
540+
diag::unreachable_code);
541+
diagnose(BB.getModule().getASTContext(),
542+
NoReturnCall->getLoc().getSourceLoc(),
543+
diag::call_to_noreturn_note);
544+
DiagnosedUnreachableCode = true;
545+
}
541546
}
542547
}
543548
}

branches/tensorflow/test/IDE/coloring.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ func bar(x: Int) -> (Int, Float) {
262262
foo(Float())
263263
}
264264

265+
// CHECK: <object-literal>#colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)</object-literal>
266+
#colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
267+
265268
class GenC<T1,T2> {}
266269

267270
func test() {
@@ -277,6 +280,9 @@ func test2(x: Int) {
277280
"\(x)"
278281
}
279282

283+
// CHECK: <kw>#colorLiteral</kw>
284+
#colorLiteral
285+
280286
// CHECK: <kw>class</kw> Observers {
281287
class Observers {
282288
// CHECK: <kw>var</kw> p1 : <type>Int</type> {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
internal class TestClass {
2+
internal var field = "goodbye"
3+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift -force-single-frontend-invocation -c -o %t/Module.o -enable-testing -parse-as-library -emit-module -emit-module-path %t/Module.swiftmodule -module-name Module %S/Inputs/testable_key_path_2.swift
3+
// RUN: %target-build-swift -o %t/a.out -I %t %s %t/Module.o
4+
// RUN: %target-run %t/a.out | %FileCheck %s
5+
6+
// REQUIRES: executable_test
7+
8+
@testable import Module
9+
10+
let c = TestClass()
11+
12+
print("You say \(c.field)")
13+
14+
let kp = \TestClass.field
15+
16+
c[keyPath: kp] = "hello"
17+
18+
print("I say \(c.field)")
19+
20+
// CHECK: I say hello

branches/tensorflow/test/Runtime/crash_without_backtrace_optimized.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,21 @@
2323

2424
import Swift
2525

26+
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
27+
import Darwin
28+
#elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku)
29+
import Glibc
30+
#elseif os(Windows)
31+
import MSVCRT
32+
#else
33+
#error("Unsupported platform")
34+
#endif
35+
2636
func foo() -> Int {
2737
return UnsafePointer<Int>(bitPattern: 0)!.pointee
2838
}
2939

40+
// Give FileCheck something to look at to keep it happy. It fails on
41+
// empty output even if the only directive is a CHECK-NOT.
42+
fputs("Running test.\n", stderr)
3043
foo()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-frontend %s -enable-ownership-stripping-after-serialization -emit-sil -verify
2+
3+
class TuringMachine {
4+
func halt() -> Never {
5+
repeat { } while true
6+
}
7+
}
8+
9+
func diagnose_missing_return_no_error_after_noreturn_method() -> Int {
10+
TuringMachine().halt()
11+
} // no error
12+
13+
func testUnreachableAfterNoReturnMethod() -> Int {
14+
TuringMachine().halt(); // expected-note{{a call to a never-returning function}}
15+
return 0; // expected-warning {{will never be executed}}
16+
}
17+

branches/tensorflow/test/stdlib/Inputs/NSSlowString/NSSlowString.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ - (instancetype)initWithString:(NSString *)name {
1818
return self;
1919
}
2020

21+
- (instancetype)initWithCharacters:(const unichar * _Nonnull)chars length:(NSUInteger)count {
22+
NSString *str = [[NSString alloc] initWithCharacters: chars length: count];
23+
self = [self initWithString: str];
24+
return self;
25+
}
26+
2127
- (NSUInteger)length {
2228
return self.stringHolder.length;
2329
}
@@ -34,4 +40,4 @@ - (void *) _fastCharacterContents {
3440
return nil;
3541
}
3642

37-
@end
43+
@end

branches/tensorflow/tools/swift-api-digester/ModuleAnalyzerNodes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,8 @@ SwiftDeclCollector::addMembersToRoot(SDKNode *Root, IterableDeclContext *Context
15531553
// All containing variables should have been handled.
15541554
} else if (isa<DestructorDecl>(Member)) {
15551555
// deinit has no impact.
1556+
} else if (isa<MissingMemberDecl>(Member)) {
1557+
// avoid adding MissingMemberDecl
15561558
} else {
15571559
llvm_unreachable("unhandled member decl kind.");
15581560
}

branches/tensorflow/utils/api_checker/swift-api-checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def check_call(cmd, cwd=None, env=os.environ, verbose=False, output=None):
3434
if verbose:
3535
print(' '.join([escapeCmdArg(arg) for arg in cmd]))
3636
return subprocess.check_call(cmd, cwd=cwd, env=env,
37-
stderr=subprocess.STDOUT, stdout=output)
37+
stderr=None, stdout=output)
3838

3939

4040
def check_output(cmd, verbose=False):

0 commit comments

Comments
 (0)