[InterfaceGen] Print bodies of inlinable functions in textual interfaces (#19224)

* Introduce stored inlinable function bodies

* Remove serialization changes

* [InterfaceGen] Print inlinable function bodies

* Clean up a little bit and add test

* Undo changes to InlinableText

* Add serialization and deserialization for inlinable body text

* Allow parser to parse accessor bodies in interfaces

* Fix some tests

* Fix remaining tests

* Add tests for usableFromInline decls

* Add comments

* Clean up function body printing throughout

* Add tests for subscripts

* Remove comment about subscript inlinable text

* Address some comments

* Handle lack of @objc on Linux
This commit is contained in:
Harlan
2018-09-14 10:23:15 -07:00
committed by GitHub
parent e034025f1f
commit 665db876ea
19 changed files with 477 additions and 115 deletions

View File

@@ -2849,6 +2849,9 @@ ModuleFile::getDeclCheckedImpl(DeclID DID) {
if (auto errorConvention = maybeReadForeignErrorConvention())
ctor->setForeignErrorConvention(*errorConvention);
if (auto bodyText = maybeReadInlinableBodyText())
ctor->setBodyStringRepresentation(*bodyText);
if (isImplicit)
ctor->setImplicit();
ctor->setIsObjC(isObjC);
@@ -3241,6 +3244,9 @@ ModuleFile::getDeclCheckedImpl(DeclID DID) {
if (auto errorConvention = maybeReadForeignErrorConvention())
fn->setForeignErrorConvention(*errorConvention);
if (auto bodyText = maybeReadInlinableBodyText())
fn->setBodyStringRepresentation(*bodyText);
fn->setOverriddenDecl(cast_or_null<FuncDecl>(overridden.get()));
if (fn->getOverriddenDecl())
AddAttribute(new (ctx) OverrideAttr(SourceLoc()));
@@ -3945,6 +3951,9 @@ ModuleFile::getDeclCheckedImpl(DeclID DID) {
auto dtor = createDecl<DestructorDecl>(SourceLoc(), DC);
declOrOffset = dtor;
if (auto bodyText = maybeReadInlinableBodyText())
dtor->setBodyStringRepresentation(*bodyText);
configureGenericEnvironment(dtor, genericEnvID);
dtor->setAccess(std::max(cast<ClassDecl>(DC)->getFormalAccess(),
@@ -5351,6 +5360,25 @@ decodeRawStableForeignErrorConventionKind(uint8_t kind) {
}
}
Optional<StringRef> ModuleFile::maybeReadInlinableBodyText() {
using namespace decls_block;
SmallVector<uint64_t, 8> scratch;
BCOffsetRAII restoreOffset(DeclTypeCursor);
StringRef blobData;
auto next = DeclTypeCursor.advance(AF_DontPopBlockAtEnd);
if (next.Kind != llvm::BitstreamEntry::Record)
return None;
unsigned recKind = DeclTypeCursor.readRecord(next.ID, scratch, &blobData);
if (recKind != INLINABLE_BODY_TEXT)
return None;
restoreOffset.reset();
return blobData;
}
Optional<ForeignErrorConvention> ModuleFile::maybeReadForeignErrorConvention() {
using namespace decls_block;