[Serialization] Only serialize inlinable body text in partial modules

Since this text is only needed for printing a parseable interface during
a non-whole-module build, only put the text inside partial modules. When
we're merging the modules at the end, skip serializing the text.

rdar://44394186
This commit is contained in:
Harlan Haskins
2018-12-13 14:01:26 -08:00
parent 5154886491
commit 11f4d05db4
4 changed files with 114 additions and 84 deletions

View File

@@ -1345,9 +1345,15 @@ void Serializer::writeGenericRequirements(ArrayRef<Requirement> requirements,
void Serializer::writeInlinableBodyTextIfNeeded(
const AbstractFunctionDecl *AFD) {
using namespace decls_block;
// Only serialize the text for an inlinable function body if we're emitting
// a partial module. It's not needed in the final module file, but it's
// needed in partial modules so you can emit a parseable interface after
// merging them.
if (!SF) return;
if (AFD->getResilienceExpansion() != swift::ResilienceExpansion::Minimal)
return;
if (!AFD->hasInlinableBodyText()) return;
SmallString<128> scratch;
auto body = AFD->getInlinableBodyText(scratch);