[Lldb-commits] [PATCH] D60152: Fix and simplify PrepareCommandsForSourcing

Adrian McCarthy via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 2 14:15:25 PDT 2019

amccarth created this revision.
amccarth added reviewers: zturner, labath, rnk.

Spotted some problems in the Driver's PrepareCommandsForSourcing while
helping a colleague track another problem.

1. One error case was not handled because there was no else clause.

Fixed by switching to llvm's early-out style instead of nested
`if (succes) { } else { }` cases.  This keeps error handling close
to the actual error.

2. It used `fdopen` on Windows, which is a deprecated name.  In other

places the function used `#ifdef _WIN32` to use the proper names
for Windows and Posix.  For readability and consistency, I factored
these out into small static functions.

3. One call-site failed to call the clean-up function.  I solved this

by simplifying the API.  PrepareCommandsForSourcing no longer requires
the caller to provide a buffer for the pipe's file descriptors and to
call a separate clean-up function later.  PrepareCommandsForSourcing
now ensures the file descriptors are handled before returning.
(The read end of the pipe is held open by the returned FILE * as

I also eliminated an unnecessary local, shorted the lifetime of another,
and tried to improve the comments.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60152.193364.patch
Type: text/x-patch
Size: 6285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190402/cfdfc0fb/attachment.bin>

More information about the lldb-commits mailing list