llvm.org GIT mirror llvm / da9c5af
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369119 91177308-0d34-0410-b5e6-96231b3b80d8 Cyndy Ishida a month ago
5 changed file(s) with 104 addition(s) and 122 deletion(s). Raw diff Collapse all Expand all
1919 class TextAPIReader {
2020 public:
2121 static Expected>
22 get(std::unique_ptr InputBuffer);
23
24 static Expected>
25 getUnmanaged(llvm::MemoryBuffer *InputBuffer);
22 get(MemoryBufferRef InputBuffer);
2623
2724 TextAPIReader() = delete;
2825 };
622622 }
623623
624624 Expected>
625 TextAPIReader::get(std::unique_ptr InputBuffer) {
625 TextAPIReader::get(MemoryBufferRef InputBuffer) {
626626 TextAPIContext Ctx;
627 Ctx.Path = InputBuffer->getBufferIdentifier();
628 yaml::Input YAMLIn(InputBuffer->getBuffer(), &Ctx, DiagHandler, &Ctx);
627 Ctx.Path = InputBuffer.getBufferIdentifier();
628 yaml::Input YAMLIn(InputBuffer.getBuffer(), &Ctx, DiagHandler, &Ctx);
629629
630630 // Fill vector with interface file objects created by parsing the YAML file.
631631 std::vector Files;
632632 YAMLIn >> Files;
633633
634 // YAMLIn dynamically allocates for Interface file and in case of error,
635 // memory leak will occur unless wrapped around unique_ptr
634636 auto File = std::unique_ptr(
635637 const_cast(Files.front()));
636638
8181 " thread-local-symbols: [ _tlv3 ]\n"
8282 "...\n";
8383
84 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_file1, "Test.tbd");
85 auto Result = TextAPIReader::get(std::move(Buffer));
84 auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_file1, "Test.tbd"));
8685 EXPECT_TRUE(!!Result);
8786 auto File = std::move(Result.get());
8887 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
126125 "install-name: Test.dylib\n"
127126 "...\n";
128127
129 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_file2, "Test.tbd");
130 auto Result = TextAPIReader::get(std::move(Buffer));
128 auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_file2, "Test.tbd"));
131129 EXPECT_TRUE(!!Result);
132130 auto File = std::move(Result.get());
133131 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
204202 "install-name: Test.dylib\n"
205203 "...\n";
206204
207 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_macos, "Test.tbd");
208 auto Result = TextAPIReader::get(std::move(Buffer));
205 auto Result =
206 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_macos, "Test.tbd"));
209207 EXPECT_TRUE(!!Result);
210208 auto File = std::move(Result.get());
211209 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
219217 "install-name: Test.dylib\n"
220218 "...\n";
221219
222 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_ios, "Test.tbd");
223 auto Result = TextAPIReader::get(std::move(Buffer));
220 auto Result =
221 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_ios, "Test.tbd"));
224222 EXPECT_TRUE(!!Result);
225223 auto File = std::move(Result.get());
226224 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
234232 "install-name: Test.dylib\n"
235233 "...\n";
236234
237 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_watchos, "Test.tbd");
238 auto Result = TextAPIReader::get(std::move(Buffer));
235 auto Result =
236 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_watchos, "Test.tbd"));
239237 EXPECT_TRUE(!!Result);
240238 auto File = std::move(Result.get());
241239 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
249247 "install-name: Test.dylib\n"
250248 "...\n";
251249
252 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_tvos, "Test.tbd");
253 auto Result = TextAPIReader::get(std::move(Buffer));
250 auto Result =
251 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_tvos, "Test.tbd"));
254252 EXPECT_TRUE(!!Result);
255253 auto File = std::move(Result.get());
256254 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
264262 "install-name: Test.dylib\n"
265263 "...\n";
266264
267 auto Buffer =
268 MemoryBuffer::getMemBuffer(tbd_v1_platform_bridgeos, "Test.tbd");
269 auto Result = TextAPIReader::get(std::move(Buffer));
265 auto Result =
266 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_bridgeos, "Test.tbd"));
270267 EXPECT_TRUE(!!Result);
271268 auto File = std::move(Result.get());
272269 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
281278 "swift-version: 1.0\n"
282279 "...\n";
283280
284 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_0, "Test.tbd");
285 auto Result = TextAPIReader::get(std::move(Buffer));
281 auto Result =
282 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_0, "Test.tbd"));
286283 EXPECT_TRUE(!!Result);
287284 auto File = std::move(Result.get());
288285 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
297294 "swift-version: 1.1\n"
298295 "...\n";
299296
300 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_1, "Test.tbd");
301 auto Result = TextAPIReader::get(std::move(Buffer));
297 auto Result =
298 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_1, "Test.tbd"));
302299 EXPECT_TRUE(!!Result);
303300 auto File = std::move(Result.get());
304301 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
313310 "swift-version: 2.0\n"
314311 "...\n";
315312
316 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_2_0, "Test.tbd");
317 auto Result = TextAPIReader::get(std::move(Buffer));
313 auto Result =
314 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_2_0, "Test.tbd"));
318315 EXPECT_TRUE(!!Result);
319316 auto File = std::move(Result.get());
320317 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
329326 "swift-version: 3.0\n"
330327 "...\n";
331328
332 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_3_0, "Test.tbd");
333 auto Result = TextAPIReader::get(std::move(Buffer));
329 auto Result =
330 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_3_0, "Test.tbd"));
334331 EXPECT_TRUE(!!Result);
335332 auto File = std::move(Result.get());
336333 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
345342 "swift-version: 4.0\n"
346343 "...\n";
347344
348 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_4_0, "Test.tbd");
349 auto Result = TextAPIReader::get(std::move(Buffer));
345 auto Result =
346 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_4_0, "Test.tbd"));
350347 EXPECT_FALSE(!!Result);
351348 auto errorMessage = toString(Result.takeError());
352349 EXPECT_EQ("malformed file\nTest.tbd:5:16: error: invalid Swift ABI "
362359 "swift-version: 5\n"
363360 "...\n";
364361
365 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_5, "Test.tbd");
366 auto Result = TextAPIReader::get(std::move(Buffer));
362 auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_5, "Test.tbd"));
367363 EXPECT_TRUE(!!Result);
368364 auto File = std::move(Result.get());
369365 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
378374 "swift-version: 99\n"
379375 "...\n";
380376
381 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_99, "Test.tbd");
382 auto Result = TextAPIReader::get(std::move(Buffer));
377 auto Result =
378 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_99, "Test.tbd"));
383379 EXPECT_TRUE(!!Result);
384380 auto File = std::move(Result.get());
385381 EXPECT_EQ(FileType::TBD_V1, File->getFileType());
394390 "install-name: Test.dylib\n"
395391 "...\n";
396392
397 auto Buffer =
398 MemoryBuffer::getMemBuffer(tbd_v1_file_unknown_architecture, "Test.tbd");
399 auto Result = TextAPIReader::get(std::move(Buffer));
393 auto Result = TextAPIReader::get(
394 MemoryBufferRef(tbd_v1_file_unknown_architecture, "Test.tbd"));
400395 EXPECT_TRUE(!!Result);
401396 }
402397
406401 "platform: newOS\n"
407402 "...\n";
408403
409 auto Buffer =
410 MemoryBuffer::getMemBuffer(tbd_v1_file_unknown_platform, "Test.tbd");
411 auto Result = TextAPIReader::get(std::move(Buffer));
404 auto Result = TextAPIReader::get(
405 MemoryBufferRef(tbd_v1_file_unknown_platform, "Test.tbd"));
412406 EXPECT_FALSE(!!Result);
413407 auto errorMessage = toString(Result.takeError());
414408 EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
422416 "foobar: \"Unsupported key\"\n"
423417 "...\n";
424418
425 auto Buffer = MemoryBuffer::getMemBuffer(malformed_file1, "Test.tbd");
426 auto Result = TextAPIReader::get(std::move(Buffer));
419 auto Result =
420 TextAPIReader::get(MemoryBufferRef(malformed_file1, "Test.tbd"));
427421 EXPECT_FALSE(!!Result);
428422 auto errorMessage = toString(Result.takeError());
429423 ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
439433 "foobar: \"Unsupported key\"\n"
440434 "...\n";
441435
442 auto Buffer = MemoryBuffer::getMemBuffer(malformed_file2, "Test.tbd");
443 auto Result = TextAPIReader::get(std::move(Buffer));
436 auto Result =
437 TextAPIReader::get(MemoryBufferRef(malformed_file2, "Test.tbd"));
444438 EXPECT_FALSE(!!Result);
445439 auto errorMessage = toString(Result.takeError());
446440 ASSERT_EQ(
8383 " thread-local-symbols: [ _tlv3 ]\n"
8484 "...\n";
8585
86 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v2_file1, "Test.tbd");
87 auto Result = TextAPIReader::get(std::move(Buffer));
86 auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v2_file1, "Test.tbd"));
8887 EXPECT_TRUE(!!Result);
8988 auto File = std::move(Result.get());
9089 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
150149 " weak-ref-symbols: [ _undefWeak1, _undefWeak2 ]\n"
151150 "...\n";
152151
153 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v2_file2, "Test.tbd");
154 auto Result = TextAPIReader::get(std::move(Buffer));
152 auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v2_file2, "Test.tbd"));
155153 EXPECT_TRUE(!!Result);
156154 auto File = std::move(Result.get());
157155 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
229227 "install-name: Test.dylib\n"
230228 "...\n";
231229
232 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_macos, "Test.tbd");
233 auto Result = TextAPIReader::get(std::move(Buffer));
230 auto Result =
231 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_macos, "Test.tbd"));
234232 EXPECT_TRUE(!!Result);
235233 auto File = std::move(Result.get());
236234 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
244242 "install-name: Test.dylib\n"
245243 "...\n";
246244
247 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_ios, "Test.tbd");
248 auto Result = TextAPIReader::get(std::move(Buffer));
245 auto Result =
246 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_ios, "Test.tbd"));
249247 EXPECT_TRUE(!!Result);
250248 auto File = std::move(Result.get());
251249 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
259257 "install-name: Test.dylib\n"
260258 "...\n";
261259
262 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_watchos, "Test.tbd");
263 auto Result = TextAPIReader::get(std::move(Buffer));
260 auto Result =
261 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_watchos, "Test.tbd"));
264262 EXPECT_TRUE(!!Result);
265263 auto File = std::move(Result.get());
266264 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
274272 "install-name: Test.dylib\n"
275273 "...\n";
276274
277 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_tvos, "Test.tbd");
278 auto Result = TextAPIReader::get(std::move(Buffer));
275 auto Result =
276 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_tvos, "Test.tbd"));
279277 EXPECT_TRUE(!!Result);
280278 auto File = std::move(Result.get());
281279 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
289287 "install-name: Test.dylib\n"
290288 "...\n";
291289
292 auto Buffer =
293 MemoryBuffer::getMemBuffer(tbd_v1_platform_bridgeos, "Test.tbd");
294 auto Result = TextAPIReader::get(std::move(Buffer));
290 auto Result =
291 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_bridgeos, "Test.tbd"));
295292 EXPECT_TRUE(!!Result);
296293 auto File = std::move(Result.get());
297294 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
306303 "swift-version: 1.0\n"
307304 "...\n";
308305
309 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_0, "Test.tbd");
310 auto Result = TextAPIReader::get(std::move(Buffer));
306 auto Result =
307 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_0, "Test.tbd"));
311308 EXPECT_TRUE(!!Result);
312309 auto File = std::move(Result.get());
313310 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
322319 "swift-version: 1.1\n"
323320 "...\n";
324321
325 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_1, "Test.tbd");
326 auto Result = TextAPIReader::get(std::move(Buffer));
322 auto Result =
323 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_1, "Test.tbd"));
327324 EXPECT_TRUE(!!Result);
328325 auto File = std::move(Result.get());
329326 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
338335 "swift-version: 2.0\n"
339336 "...\n";
340337
341 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_2_0, "Test.tbd");
342 auto Result = TextAPIReader::get(std::move(Buffer));
338 auto Result =
339 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_2_0, "Test.tbd"));
343340 EXPECT_TRUE(!!Result);
344341 auto File = std::move(Result.get());
345342 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
354351 "swift-version: 3.0\n"
355352 "...\n";
356353
357 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_3_0, "Test.tbd");
358 auto Result = TextAPIReader::get(std::move(Buffer));
354 auto Result =
355 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_3_0, "Test.tbd"));
359356 EXPECT_TRUE(!!Result);
360357 auto File = std::move(Result.get());
361358 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
370367 "swift-version: 4.0\n"
371368 "...\n";
372369
373 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_4_0, "Test.tbd");
374 auto Result = TextAPIReader::get(std::move(Buffer));
370 auto Result =
371 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_4_0, "Test.tbd"));
375372 EXPECT_FALSE(!!Result);
376373 auto errorMessage = toString(Result.takeError());
377374 EXPECT_EQ("malformed file\nTest.tbd:5:16: error: invalid Swift ABI "
387384 "swift-version: 5\n"
388385 "...\n";
389386
390 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_5, "Test.tbd");
391 auto Result = TextAPIReader::get(std::move(Buffer));
387 auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_5, "Test.tbd"));
392388 EXPECT_TRUE(!!Result);
393389 auto File = std::move(Result.get());
394390 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
403399 "swift-version: 99\n"
404400 "...\n";
405401
406 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_99, "Test.tbd");
407 auto Result = TextAPIReader::get(std::move(Buffer));
402 auto Result =
403 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_99, "Test.tbd"));
408404 EXPECT_TRUE(!!Result);
409405 auto File = std::move(Result.get());
410406 EXPECT_EQ(FileType::TBD_V2, File->getFileType());
419415 "install-name: Test.dylib\n"
420416 "...\n";
421417
422 auto Buffer =
423 MemoryBuffer::getMemBuffer(tbd_v2_file_unknown_architecture, "Test.tbd");
424 auto Result = TextAPIReader::get(std::move(Buffer));
418 auto Result = TextAPIReader::get(
419 MemoryBufferRef(tbd_v2_file_unknown_architecture, "Test.tbd"));
425420 EXPECT_TRUE(!!Result);
426421 }
427422
431426 "platform: newOS\n"
432427 "...\n";
433428
434 auto Buffer =
435 MemoryBuffer::getMemBuffer(tbd_v2_file_unknown_platform, "Test.tbd");
436 auto Result = TextAPIReader::get(std::move(Buffer));
429 auto Result = TextAPIReader::get(
430 MemoryBufferRef(tbd_v2_file_unknown_platform, "Test.tbd"));
437431 EXPECT_FALSE(!!Result);
438432 auto errorMessage = toString(Result.takeError());
439433 EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
447441 "foobar: \"Unsupported key\"\n"
448442 "...\n";
449443
450 auto Buffer = MemoryBuffer::getMemBuffer(malformed_file1, "Test.tbd");
451 auto Result = TextAPIReader::get(std::move(Buffer));
444 auto Result =
445 TextAPIReader::get(MemoryBufferRef(malformed_file1, "Test.tbd"));
452446 EXPECT_FALSE(!!Result);
453447 auto errorMessage = toString(Result.takeError());
454448 ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
464458 "foobar: \"Unsupported key\"\n"
465459 "...\n";
466460
467 auto Buffer = MemoryBuffer::getMemBuffer(malformed_file2, "Test.tbd");
468 auto Result = TextAPIReader::get(std::move(Buffer));
461 auto Result =
462 TextAPIReader::get(MemoryBufferRef(malformed_file2, "Test.tbd"));
469463 EXPECT_FALSE(!!Result);
470464 auto errorMessage = toString(Result.takeError());
471465 ASSERT_EQ(
8787 " thread-local-symbols: [ _tlv3 ]\n"
8888 "...\n";
8989
90 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v3_file1, "Test.tbd");
91 auto Result = TextAPIReader::get(std::move(Buffer));
90 auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v3_file1, "Test.tbd"));
9291 EXPECT_TRUE(!!Result);
9392 auto File = std::move(Result.get());
9493 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
187186 "install-name: Test.dylib\n"
188187 "...\n";
189188
190 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_macos, "Test.tbd");
191 auto Result = TextAPIReader::get(std::move(Buffer));
189 auto Result =
190 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_macos, "Test.tbd"));
192191 EXPECT_TRUE(!!Result);
193192 auto File = std::move(Result.get());
194193 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
202201 "install-name: Test.dylib\n"
203202 "...\n";
204203
205 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_ios, "Test.tbd");
206 auto Result = TextAPIReader::get(std::move(Buffer));
204 auto Result =
205 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_ios, "Test.tbd"));
207206 EXPECT_TRUE(!!Result);
208207 auto File = std::move(Result.get());
209208 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
217216 "install-name: Test.dylib\n"
218217 "...\n";
219218
220 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_watchos, "Test.tbd");
221 auto Result = TextAPIReader::get(std::move(Buffer));
219 auto Result =
220 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_watchos, "Test.tbd"));
222221 EXPECT_TRUE(!!Result);
223222 auto File = std::move(Result.get());
224223 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
232231 "install-name: Test.dylib\n"
233232 "...\n";
234233
235 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_tvos, "Test.tbd");
236 auto Result = TextAPIReader::get(std::move(Buffer));
234 auto Result =
235 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_tvos, "Test.tbd"));
237236 EXPECT_TRUE(!!Result);
238237 auto File = std::move(Result.get());
239238 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
247246 "install-name: Test.dylib\n"
248247 "...\n";
249248
250 auto Buffer =
251 MemoryBuffer::getMemBuffer(tbd_v1_platform_bridgeos, "Test.tbd");
252 auto Result = TextAPIReader::get(std::move(Buffer));
249 auto Result =
250 TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_bridgeos, "Test.tbd"));
253251 EXPECT_TRUE(!!Result);
254252 auto File = std::move(Result.get());
255253 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
264262 "swift-abi-version: 1.0\n"
265263 "...\n";
266264
267 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_0, "Test.tbd");
268 auto Result = TextAPIReader::get(std::move(Buffer));
265 auto Result =
266 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_0, "Test.tbd"));
269267 EXPECT_TRUE(!!Result);
270268 auto File = std::move(Result.get());
271269 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
280278 "swift-abi-version: 1.1\n"
281279 "...\n";
282280
283 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_1, "Test.tbd");
284 auto Result = TextAPIReader::get(std::move(Buffer));
281 auto Result =
282 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_1, "Test.tbd"));
285283 EXPECT_TRUE(!!Result);
286284 auto File = std::move(Result.get());
287285 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
296294 "swift-abi-version: 2.0\n"
297295 "...\n";
298296
299 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_2_0, "Test.tbd");
300 auto Result = TextAPIReader::get(std::move(Buffer));
297 auto Result =
298 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_2_0, "Test.tbd"));
301299 EXPECT_TRUE(!!Result);
302300 auto File = std::move(Result.get());
303301 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
312310 "swift-abi-version: 3.0\n"
313311 "...\n";
314312
315 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_3_0, "Test.tbd");
316 auto Result = TextAPIReader::get(std::move(Buffer));
313 auto Result =
314 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_3_0, "Test.tbd"));
317315 EXPECT_TRUE(!!Result);
318316 auto File = std::move(Result.get());
319317 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
328326 "swift-abi-version: 4.0\n"
329327 "...\n";
330328
331 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_4_0, "Test.tbd");
332 auto Result = TextAPIReader::get(std::move(Buffer));
329 auto Result =
330 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_4_0, "Test.tbd"));
333331 EXPECT_FALSE(!!Result);
334332 auto errorMessage = toString(Result.takeError());
335333 EXPECT_EQ("malformed file\nTest.tbd:5:20: error: invalid Swift ABI "
345343 "swift-abi-version: 5\n"
346344 "...\n";
347345
348 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_5, "Test.tbd");
349 auto Result = TextAPIReader::get(std::move(Buffer));
346 auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_5, "Test.tbd"));
350347 EXPECT_TRUE(!!Result);
351348 auto File = std::move(Result.get());
352349 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
361358 "swift-abi-version: 99\n"
362359 "...\n";
363360
364 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_99, "Test.tbd");
365 auto Result = TextAPIReader::get(std::move(Buffer));
361 auto Result =
362 TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_99, "Test.tbd"));
366363 EXPECT_TRUE(!!Result);
367364 auto File = std::move(Result.get());
368365 EXPECT_EQ(FileType::TBD_V3, File->getFileType());
377374 "install-name: Test.dylib\n"
378375 "...\n";
379376
380 auto Buffer =
381 MemoryBuffer::getMemBuffer(tbd_v3_file_unknown_architecture, "Test.tbd");
382 auto Result = TextAPIReader::get(std::move(Buffer));
377 auto Result = TextAPIReader::get(
378 MemoryBufferRef(tbd_v3_file_unknown_architecture, "Test.tbd"));
383379 EXPECT_TRUE(!!Result);
384380 }
385381
389385 "platform: newOS\n"
390386 "...\n";
391387
392 auto Buffer =
393 MemoryBuffer::getMemBuffer(tbd_v3_file_unknown_platform, "Test.tbd");
394 auto Result = TextAPIReader::get(std::move(Buffer));
388 auto Result = TextAPIReader::get(
389 MemoryBufferRef(tbd_v3_file_unknown_platform, "Test.tbd"));
395390 EXPECT_FALSE(!!Result);
396391 auto errorMessage = toString(Result.takeError());
397392 EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
405400 "foobar: \"Unsupported key\"\n"
406401 "...\n";
407402
408 auto Buffer = MemoryBuffer::getMemBuffer(malformed_file1, "Test.tbd");
409 auto Result = TextAPIReader::get(std::move(Buffer));
403 auto Result =
404 TextAPIReader::get(MemoryBufferRef(malformed_file1, "Test.tbd"));
410405 EXPECT_FALSE(!!Result);
411406 auto errorMessage = toString(Result.takeError());
412407 ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
422417 "foobar: \"Unsupported key\"\n"
423418 "...\n";
424419
425 auto Buffer = MemoryBuffer::getMemBuffer(malformed_file2, "Test.tbd");
426 auto Result = TextAPIReader::get(std::move(Buffer));
420 auto Result =
421 TextAPIReader::get(MemoryBufferRef(malformed_file2, "Test.tbd"));
427422 EXPECT_FALSE(!!Result);
428423 auto errorMessage = toString(Result.takeError());
429424 ASSERT_EQ(