Skip to content

Commit 7467c71

Browse files
Merge pull request #70989 from nate-chandler/parse-tilde-in-sil
[Parse] Allow ~ in SIL.
2 parents 746de8b + a00aa6d commit 7467c71

File tree

4 files changed

+63
-35
lines changed

4 files changed

+63
-35
lines changed

lib/Parse/ParseType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ ParserResult<TypeRepr> Parser::parseTypeSimple(
172172

173173
// Eat any '~' preceding the type.
174174
SourceLoc tildeLoc;
175-
if (Tok.isTilde() && !isInSILMode()) {
175+
if (Tok.isTilde()) {
176176
tildeLoc = consumeToken();
177177
}
178178

test/SIL/Parser/basic2.sil

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
import Builtin
44

5+
class Klass {}
6+
@_moveOnly struct MoveOnlyPair {
7+
var lhs: Klass
8+
var rhs: Klass
9+
}
10+
511
// CHECK-LABEL: sil [ossa] @test_copy_release_value
612
// CHECK: bb0([[T0:%[0-9]+]] : @owned $Builtin.NativeObject):
713
// CHECK-NEXT: [[COPY_RESULT:%.*]] = copy_value [[T0]] : $Builtin.NativeObject
@@ -301,3 +307,26 @@ bb0(%0 : @owned $Builtin.NativeObject, %1 : @owned $Builtin.NativeObject):
301307
%9999 = tuple()
302308
return %9999 : $()
303309
}
310+
311+
// CHECK-LABEL: sil [ossa] @testMarkUnresolvedNonCopyableValueInst : $@convention(thin) (@guaranteed Klass) -> () {
312+
// CHECK: mark_unresolved_non_copyable_value [consumable_and_assignable] %{{[0-9]+}} : $*MoveOnlyPair
313+
// CHECK: } // end sil function 'testMarkUnresolvedNonCopyableValueInst'
314+
sil [ossa] @testMarkUnresolvedNonCopyableValueInst : $@convention(thin) (@guaranteed Klass) -> () {
315+
bb0(%0 : @guaranteed $Klass):
316+
%1 = alloc_box ${ var MoveOnlyPair }
317+
%2 = project_box %1 : ${ var MoveOnlyPair }, 0
318+
%3 = mark_unresolved_non_copyable_value [consumable_and_assignable] %2 : $*MoveOnlyPair
319+
%3c = begin_access [modify] [static] %3 : $*MoveOnlyPair
320+
%3a = struct_element_addr %3c : $*MoveOnlyPair, #MoveOnlyPair.lhs
321+
%3b = struct_element_addr %3c : $*MoveOnlyPair, #MoveOnlyPair.rhs
322+
%0a = copy_value %0 : $Klass
323+
%0b = copy_value %0 : $Klass
324+
store %0a to [init] %3a : $*Klass
325+
store %0b to [init] %3b : $*Klass
326+
end_access %3c : $*MoveOnlyPair
327+
328+
destroy_value %1 : ${ var MoveOnlyPair }
329+
330+
%9999 = tuple()
331+
return %9999 : $()
332+
}

test/SIL/Parser/basic2_moveonly.sil

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %target-sil-opt \
2+
// RUN: %s \
3+
// RUN: -enable-experimental-feature NoncopyableGenerics \
4+
// RUN: -enable-experimental-feature NonescapableTypes \
5+
// RUN: | \
6+
// RUN: %target-sil-opt \
7+
// RUN: -enable-experimental-feature NoncopyableGenerics \
8+
// RUN: -enable-experimental-feature NonescapableTypes \
9+
// RUN: | \
10+
// RUN: %FileCheck %s
11+
12+
// For -enable-experimental-feature NoncopyableGenerics/NonescapableTypes
13+
// REQUIRES: asserts
14+
// TODO: Once NoncopyableGenerics/NonescapableTypes is no longer behind a feature flag, merge this into basic2.
15+
16+
sil_stage raw
17+
18+
import Swift
19+
20+
// CHECK-LABEL: struct NCG<T> : ~Copyable {
21+
// CHECK-NEXT: var t: T
22+
// CHECK-NEXT: deinit
23+
struct NCG<T> : ~Copyable {
24+
var t: T
25+
deinit
26+
}
27+
28+
// CHECK-LABEL: struct NEG<T> : ~Escapable {
29+
// CHECK-NEXT: var t: T
30+
struct NEG<T> : ~Escapable {
31+
var t: T
32+
}
33+

0 commit comments

Comments
 (0)