Index: llvm/lib/TextAPI/MachO/TextStubCommon.cpp =================================================================== --- llvm/lib/TextAPI/MachO/TextStubCommon.cpp +++ llvm/lib/TextAPI/MachO/TextStubCommon.cpp @@ -152,8 +152,14 @@ return QuotingType::None; } -void ScalarTraits::output(const SwiftVersion &Value, void *, +void ScalarTraits::output(const SwiftVersion &Value, void *IO, raw_ostream &OS) { + const auto *Ctx = reinterpret_cast(IO); + if (Ctx->FileKind == FileType::TBD_V4) { + OS << (unsigned)Value; + return; + } + switch (Value) { case 1: OS << "1.0"; Index: llvm/unittests/TextAPI/TextStubV4Tests.cpp =================================================================== --- llvm/unittests/TextAPI/TextStubV4Tests.cpp +++ llvm/unittests/TextAPI/TextStubV4Tests.cpp @@ -504,7 +504,11 @@ EXPECT_EQ(FileType::TBD_V4, File->getFileType()); EXPECT_EQ(1U, File->getSwiftABIVersion()); - // No writer test because we emit "swift-abi-version:1.0". + SmallString<4096> Buffer; + raw_svector_ostream OS(Buffer); + auto WriteResult = TextAPIWriter::writeToStream(OS, *File); + EXPECT_TRUE(!WriteResult); + EXPECT_EQ(stripWhitespace(tbd_swift_1), stripWhitespace(Buffer.c_str())); } TEST(TBDv4, Swift_2) { @@ -521,7 +525,11 @@ EXPECT_EQ(FileType::TBD_V4, File->getFileType()); EXPECT_EQ(2U, File->getSwiftABIVersion()); - // No writer test because we emit "swift-abi-version:2.0". + SmallString<4096> Buffer; + raw_svector_ostream OS(Buffer); + auto WriteResult = TextAPIWriter::writeToStream(OS, *File); + EXPECT_TRUE(!WriteResult); + EXPECT_EQ(stripWhitespace(tbd_v4_swift_2), stripWhitespace(Buffer.c_str())); } TEST(TBDv4, Swift_5) {