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

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 4 09:07:03 PDT 2018


zturner added inline comments.


================
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);
----------------
amccarth wrote:
> 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`?
`HANDLE` and `void*` are literally the same type, so yes it should work.  From `winnt.h`:

```
#ifdef STRICT
typedef void *HANDLE;
#else
typedef PVOID HANDLE;
#endif
```


https://reviews.llvm.org/D47688





More information about the llvm-commits mailing list