[PATCH] D102736: Fix tmp files being left on Windows builds.

Amy Huang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 20 16:10:20 PDT 2021


akhuang marked 2 inline comments as done.
akhuang added a comment.

In D102736#2769747 <https://reviews.llvm.org/D102736#2769747>, @akhuang wrote:

> In D102736#2769358 <https://reviews.llvm.org/D102736#2769358>, @amccarth wrote:
>
>> At some point, the duplicate handle must be closed.  I don't see that happening.  I've added an inline comment where I think it should be done.
>>
>> (I find it weird that duplicating the handle seems necessary.)
>>
>> At a high level, it seems a shame that `llvm::support::fs` doesn't have create-temporary-file and keep-temporary-file operations to hide all this detail from the frontend.
>
> So, there is a `TempFile` class in `llvm::support::fs` with create temp file and keep temp file operations, and it would be nice to use that. The issue I was running into is that it uses a file descriptor (`int fd`) to keep track of the file, but for some reason, the function to convert the fd to a handle (`_get_osfhandle`) was not working (exits the program when called). I haven't yet figured out why this is happening

Ok, apparently the whole issue with it not being able to open the handle is just because we were passing `shouldClose=true` to the `raw_fd_ostream`, which makes it close the file when done writing.
 Since that's figured out, I think using `TempFile` makes the most sense


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102736/new/

https://reviews.llvm.org/D102736



More information about the cfe-commits mailing list