hanchenye-llvm-project/lldb
Adrian McCarthy ffa857c7a6 Fix and simplify PrepareCommandsForSourcing
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. 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
before.)

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

I wrapped the call to open the pipe to get the `#ifdef`s out of the
mainline.  I replaced the `close`/`_close` calls with a platform-neutral
helper from `llvm::sys` for the same reason.  Per discussion on the
review, I'm leaving the `fdopen` call to use the spelling that Windows
has officially deprecated because it still works it avoids more `#ifdef`s.

Differential Revision: https://reviews.llvm.org/D60152

llvm-svn: 357626
2019-04-03 19:49:14 +00:00
..
cmake [Cmake] Unify python variables 2019-03-29 17:35:42 +00:00
docs Don't abort() in lldb_assert and document why. 2019-03-29 16:12:27 +00:00
examples python 2/3 compat: commands vs subprocess 2019-03-26 14:46:15 +00:00
include/lldb Fix typo; NFC 2019-04-02 17:02:21 +00:00
lit [LLDB] - Update the test cases after yaml2obj change. 2019-04-03 15:28:35 +00:00
lldb.xcodeproj [Platform] Remove Kalimba Platform 2019-03-27 16:23:50 +00:00
lldb.xcworkspace Remove accidentally commited file in xcshareddata 2019-02-05 23:35:01 +00:00
packages/Python/lldbsuite Attempt #2 to get this patch working. I will watch the build bots carefully today. 2019-04-03 16:30:44 +00:00
resources [CMake] Revised LLDB.framework builds 2019-01-04 12:46:50 +00:00
scripts modify-python-lldb.py: clean up __iter__ and __len__ support 2019-04-03 11:48:38 +00:00
source Attempt #2 to get this patch working. I will watch the build bots carefully today. 2019-04-03 16:30:44 +00:00
test [CMake] Make lldb-test-deps a dependency of check-lldb 2019-02-13 20:51:13 +00:00
third_party/Python/module [lldb/thirdparty] Remove unneeded files, asked by Jonas. 2019-03-12 20:41:36 +00:00
tools Fix and simplify PrepareCommandsForSourcing 2019-04-03 19:49:14 +00:00
unittests [LLDB] - Update the test cases after yaml2obj change. 2019-04-03 15:28:35 +00:00
utils [lldb-dotest] Print dotest.py invocation. 2019-04-03 01:26:38 +00:00
www Don't abort() in lldb_assert and document why. 2019-03-29 16:12:27 +00:00
.arcconfig
.clang-format
.gitignore
CMakeLists.txt Add lldb-vscode as a dependency of lldb tests. 2019-03-26 18:36:44 +00:00
CODE_OWNERS.txt Fix/unify the spelling of Objective-C. 2018-06-13 16:21:24 +00:00
INSTALL.txt
LICENSE.TXT Fix typos throughout the license files that somehow I and my reviewers 2019-01-21 09:52:34 +00:00
use_lldb_suite_root.py