[PATCH] D47688: [Support] Add functions that return native file handles on Windows instead of fds.

Adrian McCarthy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 4 08:25:47 PDT 2018


amccarth added a comment.

I like the direction.  Just a question about the implicit type conversion.



================
Comment at: llvm/include/llvm/Support/FileSystem.h:848
+///
+/// The caller is responsible for closing the freeing the file once they are
+/// finished with it.
----------------
s/the freeing//


================
Comment at: llvm/include/llvm/Support/FileSystem.h:881
+///
+/// The caller is responsible for closing the freeing the file once they are
+/// finished with it.
----------------
s/the freeing//


================
Comment at: llvm/lib/Support/Windows/Path.inc:1070
                                 SmallVectorImpl<char> *RealPath) {
-  ResultFD = -1;
+  Expected<HANDLE> NativeFile = openNativeFileForRead(Name, RealPath);
+  return nativeFileToFd(std::move(NativeFile), ResultFD, 0);
----------------
Does this work?  Function returns `Expected<native_file_t>` which is `Expected<void *>`.  Can you assign that to `Expected<HANDLE>` and get the implicit (reinterpret) cast from `void *` to `HANDLE`?


https://reviews.llvm.org/D47688





More information about the llvm-commits mailing list