mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[TextAPI] Update reader to be supported by lib/Object
Summary: To be able to use the TextAPI/Reader for tbd file consumption (by libObject) it gets passed a MemoryBufferRef which isn't castable to MemoryBuffer. Updated the tests to expect that input as well. Reviewers: ributzka, steven_wu Reviewed By: steven_wu Subscribers: hiraditya, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66147 llvm-svn: 369119
This commit is contained in:
parent
4dcd0a1359
commit
a60baad757
@ -20,10 +20,7 @@ class InterfaceFile;
|
||||
class TextAPIReader {
|
||||
public:
|
||||
static Expected<std::unique_ptr<InterfaceFile>>
|
||||
get(std::unique_ptr<MemoryBuffer> InputBuffer);
|
||||
|
||||
static Expected<std::unique_ptr<InterfaceFile>>
|
||||
getUnmanaged(llvm::MemoryBuffer *InputBuffer);
|
||||
get(MemoryBufferRef InputBuffer);
|
||||
|
||||
TextAPIReader() = delete;
|
||||
};
|
||||
|
@ -623,15 +623,17 @@ static void DiagHandler(const SMDiagnostic &Diag, void *Context) {
|
||||
}
|
||||
|
||||
Expected<std::unique_ptr<InterfaceFile>>
|
||||
TextAPIReader::get(std::unique_ptr<MemoryBuffer> InputBuffer) {
|
||||
TextAPIReader::get(MemoryBufferRef InputBuffer) {
|
||||
TextAPIContext Ctx;
|
||||
Ctx.Path = InputBuffer->getBufferIdentifier();
|
||||
yaml::Input YAMLIn(InputBuffer->getBuffer(), &Ctx, DiagHandler, &Ctx);
|
||||
Ctx.Path = InputBuffer.getBufferIdentifier();
|
||||
yaml::Input YAMLIn(InputBuffer.getBuffer(), &Ctx, DiagHandler, &Ctx);
|
||||
|
||||
// Fill vector with interface file objects created by parsing the YAML file.
|
||||
std::vector<const InterfaceFile *> Files;
|
||||
YAMLIn >> Files;
|
||||
|
||||
// YAMLIn dynamically allocates for Interface file and in case of error,
|
||||
// memory leak will occur unless wrapped around unique_ptr
|
||||
auto File = std::unique_ptr<InterfaceFile>(
|
||||
const_cast<InterfaceFile *>(Files.front()));
|
||||
|
||||
|
@ -82,8 +82,7 @@ TEST(TBDv1, ReadFile) {
|
||||
" thread-local-symbols: [ _tlv3 ]\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_file1, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_file1, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -127,8 +126,7 @@ TEST(TBDv1, ReadFile2) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_file2, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_file2, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -205,8 +203,8 @@ TEST(TBDv1, Platform_macOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_macos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_macos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -220,8 +218,8 @@ TEST(TBDv1, Platform_iOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_ios, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_ios, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -235,8 +233,8 @@ TEST(TBDv1, Platform_watchOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_watchos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_watchos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -250,8 +248,8 @@ TEST(TBDv1, Platform_tvOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_tvos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_tvos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -265,9 +263,8 @@ TEST(TBDv1, Platform_bridgeOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer =
|
||||
MemoryBuffer::getMemBuffer(tbd_v1_platform_bridgeos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_bridgeos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -282,8 +279,8 @@ TEST(TBDv1, Swift_1_0) {
|
||||
"swift-version: 1.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_0, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -298,8 +295,8 @@ TEST(TBDv1, Swift_1_1) {
|
||||
"swift-version: 1.1\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_1, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_1, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -314,8 +311,8 @@ TEST(TBDv1, Swift_2_0) {
|
||||
"swift-version: 2.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_2_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_2_0, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -330,8 +327,8 @@ TEST(TBDv1, Swift_3_0) {
|
||||
"swift-version: 3.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_3_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_3_0, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -346,8 +343,8 @@ TEST(TBDv1, Swift_4_0) {
|
||||
"swift-version: 4.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_4_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_4_0, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
EXPECT_EQ("malformed file\nTest.tbd:5:16: error: invalid Swift ABI "
|
||||
@ -363,8 +360,7 @@ TEST(TBDv1, Swift_5) {
|
||||
"swift-version: 5\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_5, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_5, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -379,8 +375,8 @@ TEST(TBDv1, Swift_99) {
|
||||
"swift-version: 99\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_99, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_99, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
|
||||
@ -395,9 +391,8 @@ TEST(TBDv1, UnknownArchitecture) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer =
|
||||
MemoryBuffer::getMemBuffer(tbd_v1_file_unknown_architecture, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(
|
||||
MemoryBufferRef(tbd_v1_file_unknown_architecture, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
}
|
||||
|
||||
@ -407,9 +402,8 @@ TEST(TBDv1, UnknownPlatform) {
|
||||
"platform: newOS\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer =
|
||||
MemoryBuffer::getMemBuffer(tbd_v1_file_unknown_platform, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(
|
||||
MemoryBufferRef(tbd_v1_file_unknown_platform, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
|
||||
@ -423,8 +417,8 @@ TEST(TBDv1, MalformedFile1) {
|
||||
"foobar: \"Unsupported key\"\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(malformed_file1, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(malformed_file1, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
|
||||
@ -440,8 +434,8 @@ TEST(TBDv1, MalformedFile2) {
|
||||
"foobar: \"Unsupported key\"\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(malformed_file2, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(malformed_file2, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
ASSERT_EQ(
|
||||
|
@ -84,8 +84,7 @@ TEST(TBDv2, ReadFile) {
|
||||
" thread-local-symbols: [ _tlv3 ]\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v2_file1, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v2_file1, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -151,8 +150,7 @@ TEST(TBDv2, ReadFile2) {
|
||||
" weak-ref-symbols: [ _undefWeak1, _undefWeak2 ]\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v2_file2, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v2_file2, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -230,8 +228,8 @@ TEST(TBDv2, Platform_macOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_macos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_macos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -245,8 +243,8 @@ TEST(TBDv2, Platform_iOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_ios, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_ios, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -260,8 +258,8 @@ TEST(TBDv2, Platform_watchOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_watchos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_watchos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -275,8 +273,8 @@ TEST(TBDv2, Platform_tvOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_tvos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_tvos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -290,9 +288,8 @@ TEST(TBDv2, Platform_bridgeOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer =
|
||||
MemoryBuffer::getMemBuffer(tbd_v1_platform_bridgeos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_bridgeos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -307,8 +304,8 @@ TEST(TBDv2, Swift_1_0) {
|
||||
"swift-version: 1.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_0, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -323,8 +320,8 @@ TEST(TBDv2, Swift_1_1) {
|
||||
"swift-version: 1.1\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_1, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_1, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -339,8 +336,8 @@ TEST(TBDv2, Swift_2_0) {
|
||||
"swift-version: 2.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_2_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_2_0, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -355,8 +352,8 @@ TEST(TBDv2, Swift_3_0) {
|
||||
"swift-version: 3.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_3_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_3_0, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -371,8 +368,8 @@ TEST(TBDv2, Swift_4_0) {
|
||||
"swift-version: 4.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_4_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_4_0, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
EXPECT_EQ("malformed file\nTest.tbd:5:16: error: invalid Swift ABI "
|
||||
@ -388,8 +385,7 @@ TEST(TBDv2, Swift_5) {
|
||||
"swift-version: 5\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_5, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_5, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -404,8 +400,8 @@ TEST(TBDv2, Swift_99) {
|
||||
"swift-version: 99\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_99, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_99, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
|
||||
@ -420,9 +416,8 @@ TEST(TBDv2, UnknownArchitecture) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer =
|
||||
MemoryBuffer::getMemBuffer(tbd_v2_file_unknown_architecture, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(
|
||||
MemoryBufferRef(tbd_v2_file_unknown_architecture, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
}
|
||||
|
||||
@ -432,9 +427,8 @@ TEST(TBDv2, UnknownPlatform) {
|
||||
"platform: newOS\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer =
|
||||
MemoryBuffer::getMemBuffer(tbd_v2_file_unknown_platform, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(
|
||||
MemoryBufferRef(tbd_v2_file_unknown_platform, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
|
||||
@ -448,8 +442,8 @@ TEST(TBDv2, MalformedFile1) {
|
||||
"foobar: \"Unsupported key\"\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(malformed_file1, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(malformed_file1, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
|
||||
@ -465,8 +459,8 @@ TEST(TBDv2, MalformedFile2) {
|
||||
"foobar: \"Unsupported key\"\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(malformed_file2, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(malformed_file2, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
ASSERT_EQ(
|
||||
|
@ -88,8 +88,7 @@ TEST(TBDv3, ReadFile) {
|
||||
" thread-local-symbols: [ _tlv3 ]\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v3_file1, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v3_file1, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -188,8 +187,8 @@ TEST(TBDv3, Platform_macOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_macos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_macos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -203,8 +202,8 @@ TEST(TBDv3, Platform_iOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_ios, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_ios, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -218,8 +217,8 @@ TEST(TBDv3, Platform_watchOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_watchos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_watchos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -233,8 +232,8 @@ TEST(TBDv3, Platform_tvOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_tvos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_tvos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -248,9 +247,8 @@ TEST(TBDv3, Platform_bridgeOS) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer =
|
||||
MemoryBuffer::getMemBuffer(tbd_v1_platform_bridgeos, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_bridgeos, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -265,8 +263,8 @@ TEST(TBDv3, Swift_1_0) {
|
||||
"swift-abi-version: 1.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_0, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -281,8 +279,8 @@ TEST(TBDv3, Swift_1_1) {
|
||||
"swift-abi-version: 1.1\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_1, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_1, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -297,8 +295,8 @@ TEST(TBDv3, Swift_2_0) {
|
||||
"swift-abi-version: 2.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_2_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_2_0, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -313,8 +311,8 @@ TEST(TBDv3, Swift_3_0) {
|
||||
"swift-abi-version: 3.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_3_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_3_0, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -329,8 +327,8 @@ TEST(TBDv3, Swift_4_0) {
|
||||
"swift-abi-version: 4.0\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_4_0, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_4_0, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
EXPECT_EQ("malformed file\nTest.tbd:5:20: error: invalid Swift ABI "
|
||||
@ -346,8 +344,7 @@ TEST(TBDv3, Swift_5) {
|
||||
"swift-abi-version: 5\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_5, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_5, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -362,8 +359,8 @@ TEST(TBDv3, Swift_99) {
|
||||
"swift-abi-version: 99\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_99, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_99, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
auto File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
|
||||
@ -378,9 +375,8 @@ TEST(TBDv3, UnknownArchitecture) {
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer =
|
||||
MemoryBuffer::getMemBuffer(tbd_v3_file_unknown_architecture, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(
|
||||
MemoryBufferRef(tbd_v3_file_unknown_architecture, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
}
|
||||
|
||||
@ -390,9 +386,8 @@ TEST(TBDv3, UnknownPlatform) {
|
||||
"platform: newOS\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer =
|
||||
MemoryBuffer::getMemBuffer(tbd_v3_file_unknown_platform, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result = TextAPIReader::get(
|
||||
MemoryBufferRef(tbd_v3_file_unknown_platform, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
|
||||
@ -406,8 +401,8 @@ TEST(TBDv3, MalformedFile1) {
|
||||
"foobar: \"Unsupported key\"\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(malformed_file1, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(malformed_file1, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
|
||||
@ -423,8 +418,8 @@ TEST(TBDv3, MalformedFile2) {
|
||||
"foobar: \"Unsupported key\"\n"
|
||||
"...\n";
|
||||
|
||||
auto Buffer = MemoryBuffer::getMemBuffer(malformed_file2, "Test.tbd");
|
||||
auto Result = TextAPIReader::get(std::move(Buffer));
|
||||
auto Result =
|
||||
TextAPIReader::get(MemoryBufferRef(malformed_file2, "Test.tbd"));
|
||||
EXPECT_FALSE(!!Result);
|
||||
auto errorMessage = toString(Result.takeError());
|
||||
ASSERT_EQ(
|
||||
|
Loading…
Reference in New Issue
Block a user