Skip to content

Commit f5e91ac

Browse files
author
Harlan Haskins
committed
Address some comments
1 parent f1f7be5 commit f5e91ac

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

lib/AST/ASTVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,9 @@ class Verifier : public ASTWalker {
490490
case AbstractFunctionDecl::BodyKind::TypeChecked:
491491
case AbstractFunctionDecl::BodyKind::Skipped:
492492
case AbstractFunctionDecl::BodyKind::MemberwiseInitializer:
493+
case AbstractFunctionDecl::BodyKind::Deserialized:
493494
return true;
494495

495-
case AbstractFunctionDecl::BodyKind::Deserialized:
496496
case AbstractFunctionDecl::BodyKind::Unparsed:
497497
case AbstractFunctionDecl::BodyKind::Parsed:
498498
case AbstractFunctionDecl::BodyKind::Synthesize:

lib/AST/Decl.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5421,13 +5421,19 @@ void AbstractFunctionDecl::computeType(AnyFunctionType::ExtInfo info) {
54215421
}
54225422

54235423
bool AbstractFunctionDecl::hasInlinableBodyText() const {
5424-
if (getBodyKind() == BodyKind::Deserialized)
5424+
switch (getBodyKind()) {
5425+
case BodyKind::Deserialized:
54255426
return true;
5426-
if (getBodyKind() != BodyKind::Parsed &&
5427-
getBodyKind() != BodyKind::TypeChecked)
5427+
case BodyKind::Parsed:
5428+
case BodyKind::TypeChecked:
5429+
return getBody() && !getBody()->isImplicit();
5430+
case BodyKind::None:
5431+
case BodyKind::Unparsed:
5432+
case BodyKind::Synthesize:
5433+
case BodyKind::Skipped:
5434+
case BodyKind::MemberwiseInitializer:
54285435
return false;
5429-
auto body = getBody();
5430-
return body && !body->isImplicit();
5436+
}
54315437
}
54325438

54335439
StringRef AbstractFunctionDecl::getInlinableBodyText(

lib/Serialization/Serialization.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,6 @@ void Serializer::writeBlockInfoBlock() {
898898
decls_block::GENERIC_REQUIREMENT);
899899
BLOCK_RECORD_WITH_NAMESPACE(sil_block,
900900
decls_block::LAYOUT_REQUIREMENT);
901-
BLOCK_RECORD_WITH_NAMESPACE(sil_block,
902-
decls_block::INLINABLE_BODY_TEXT);
903901

904902
BLOCK(SIL_INDEX_BLOCK);
905903
BLOCK_RECORD(sil_index_block, SIL_FUNC_NAMES);
@@ -1363,7 +1361,8 @@ void Serializer::writeGenericRequirements(ArrayRef<Requirement> requirements,
13631361
}
13641362
}
13651363

1366-
void Serializer::writeInlinableBodyText(const AbstractFunctionDecl *AFD) {
1364+
void Serializer::writeInlinableBodyTextIfNeeded(
1365+
const AbstractFunctionDecl *AFD) {
13671366
using namespace decls_block;
13681367

13691368
if (AFD->getResilienceExpansion() != swift::ResilienceExpansion::Minimal)
@@ -3250,7 +3249,7 @@ void Serializer::writeDecl(const Decl *D) {
32503249
if (auto errorConvention = fn->getForeignErrorConvention())
32513250
writeForeignErrorConvention(*errorConvention);
32523251

3253-
writeInlinableBodyText(fn);
3252+
writeInlinableBodyTextIfNeeded(fn);
32543253

32553254
break;
32563255
}
@@ -3309,7 +3308,7 @@ void Serializer::writeDecl(const Decl *D) {
33093308
if (auto errorConvention = fn->getForeignErrorConvention())
33103309
writeForeignErrorConvention(*errorConvention);
33113310

3312-
writeInlinableBodyText(fn);
3311+
writeInlinableBodyTextIfNeeded(fn);
33133312

33143313
break;
33153314
}
@@ -3464,8 +3463,7 @@ void Serializer::writeDecl(const Decl *D) {
34643463
if (auto errorConvention = ctor->getForeignErrorConvention())
34653464
writeForeignErrorConvention(*errorConvention);
34663465

3467-
writeInlinableBodyText(ctor);
3468-
3466+
writeInlinableBodyTextIfNeeded(ctor);
34693467
break;
34703468
}
34713469

@@ -3482,7 +3480,7 @@ void Serializer::writeDecl(const Decl *D) {
34823480
dtor->isObjC(),
34833481
addGenericEnvironmentRef(
34843482
dtor->getGenericEnvironment()));
3485-
writeInlinableBodyText(dtor);
3483+
writeInlinableBodyTextIfNeeded(dtor);
34863484
break;
34873485
}
34883486

lib/Serialization/Serialization.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ class Serializer {
326326

327327
/// Writes the body text of the provided funciton, if the function is
328328
/// inlinable and has body text.
329-
void writeInlinableBodyText(const AbstractFunctionDecl *decl);
329+
void writeInlinableBodyTextIfNeeded(const AbstractFunctionDecl *decl);
330330

331331
/// Writes a list of protocol conformances.
332332
void writeConformances(ArrayRef<ProtocolConformanceRef> conformances,

test/ModuleInterface/inlinable-function.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public struct Foo: Hashable {
1818
set {
1919
print("I am set to \(newValue)")
2020
}
21+
// CHECK-NEXT: {{^}} }
2122
}
2223

2324
// CHECK: public var noAccessors: [[INT]]{{$}}
@@ -31,13 +32,13 @@ public struct Foo: Hashable {
3132
didSet {
3233
print("b set to \(hasDidSet)")
3334
}
34-
// CHECK-NEXT: }
35+
// CHECK-NEXT: {{^}} }
3536
}
3637

3738

3839
// CHECK: @_transparent public var transparent: [[INT]] {
39-
// CHECK: return 34
40-
// CHECK: }
40+
// CHECK-NEXT: return 34
41+
// CHECK-NEXT: }
4142
@_transparent
4243
public var transparent: Int {
4344
return 34
@@ -59,6 +60,7 @@ public struct Foo: Hashable {
5960
// CHECK: print("I am set to \(newValue)")
6061
// CHECK-NOT: #endif
6162
// CHECK-NOT: #endif
63+
// CHECK-NEXT: }
6264
@_transparent
6365
set {
6466
#if false
@@ -97,6 +99,7 @@ public struct Foo: Hashable {
9799
print("I should not appear")
98100
#endif
99101
}
102+
// CHECK-NEXT: }
100103
}
101104

102105
// CHECK: @inlinable public func inlinableMethod() {

0 commit comments

Comments
 (0)