[PATCH] D73331: [llvm][TextAPI/MachO] Emit swift ABI version as an un integer in TBD_V4
Jonas Devlieghere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 23:54:32 PST 2020
JDevlieghere created this revision.
JDevlieghere added a reviewer: cishida.
Herald added subscribers: dexonsmith, hiraditya.
Herald added a project: LLVM.
JDevlieghere added a parent revision: D73330: [llvm][TextAPI/MachO] Extend TBD_V4 unittest to verify writing.
TBD_V4 requires the swift ABI version to be an integer, however we were unconditionally emitting it as a float for versions 4 and below.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73331
Files:
llvm/lib/TextAPI/MachO/TextStubCommon.cpp
llvm/unittests/TextAPI/TextStubV4Tests.cpp
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) {
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<SwiftVersion>::output(const SwiftVersion &Value, void *,
+void ScalarTraits<SwiftVersion>::output(const SwiftVersion &Value, void *IO,
raw_ostream &OS) {
+ const auto *Ctx = reinterpret_cast<TextAPIContext *>(IO);
+ if (Ctx->FileKind == FileType::TBD_V4) {
+ OS << (unsigned)Value;
+ return;
+ }
+
switch (Value) {
case 1:
OS << "1.0";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73331.240107.patch
Type: text/x-patch
Size: 1789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200124/c9908091/attachment.bin>
More information about the llvm-commits
mailing list