[LLVM][SupportTests] Fix Windows build breakage
authorMichael Spencer <bigcheesegs@gmail.com>
Wed, 15 Apr 2020 21:46:29 +0000 (14:46 -0700)
committerMichael Spencer <bigcheesegs@gmail.com>
Wed, 15 Apr 2020 21:47:27 +0000 (14:47 -0700)
`MemoryBuffer::getOpenFile` take an OS file handle, not an int.

llvm/unittests/Support/MemoryBufferTest.cpp

index 1a424f6..ae0c5ea 100644 (file)
@@ -398,9 +398,14 @@ TEST_F(MemoryBufferTest, mmapVolatileNoNull) {
   // Create a file large enough to mmap. A 32KiB file should be enough.
   for (unsigned i = 0; i < 0x1000; ++i)
     OF << "01234567";
-  OF.flush();
+  OF.close();
+
+  Expected<sys::fs::file_t> File = sys::fs::openNativeFileForRead(TestPath);
+  ASSERT_THAT_EXPECTED(File, Succeeded());
+  auto OnExit =
+      make_scope_exit([&] { ASSERT_NO_ERROR(sys::fs::closeFile(*File)); });
 
-  auto MBOrError = MemoryBuffer::getOpenFile(FD, TestPath,
+  auto MBOrError = MemoryBuffer::getOpenFile(*File, TestPath,
       /*FileSize=*/-1, /*RequiresNullTerminator=*/false, /*IsVolatile=*/true);
   ASSERT_NO_ERROR(MBOrError.getError())
   OwningBuffer MB = std::move(*MBOrError);