Michael J. Spencer
fae76d0734
This is the first step in adding sane error handling support to LLVMSystem.
...
The system API's will be shifted over to returning an error_code, and returning
other return values as out parameters to the function.
Code that needs to check error conditions will use the errc enum values which
are the same as the posix_errno defines (EBADF, E2BIG, etc...), and are
compatable with the error codes in WinError.h due to some magic in system_error.
An example would be:
if (error_code ec = KillEvil("Java")) { // error_code can be converted to bool.
handle_error(ec);
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119360 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-16 18:31:52 +00:00
Rafael Espindola
9e07a149b0
Add method for checking if a path is a symbolic link.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118367 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-07 04:36:50 +00:00
Dan Gohman
4e0a9c51b4
Delete unused variables.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118128 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-03 00:09:12 +00:00
Dan Gohman
aabb9b67bc
Remove several unhelpful checks for isValid from sys::Path.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118127 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-03 00:01:23 +00:00
Dan Gohman
ac793822cd
Don't try to enforce MAXPATHLEN in sys::Path for Unix. OS's can check
...
limits on their own.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118113 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 23:19:55 +00:00
Dan Gohman
9e2e0c39e7
Simplify.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118110 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 23:16:26 +00:00
Dan Gohman
6f6021ecfe
Fix a copy+pasto.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118106 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 22:56:51 +00:00
Dan Gohman
b48a8fddbf
Avoid manipulating paths in fixed-sized arrays.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118105 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 22:55:34 +00:00
Dan Gohman
0803ebe0c8
Simplify this code.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118102 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 22:50:10 +00:00
Dan Gohman
a0f1a2baee
Use '\0' instead of 0 for nul character constants.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118096 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 22:41:19 +00:00
Mikhail Glushenkov
bd6e0323b9
appendSuffix: don't append a dot when the suffix is empty.
...
Additionally, move the implementation of appendSuffix to Path.cpp: it is
platform-independent.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118089 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 22:18:37 +00:00
Dan Gohman
8d4fd965d4
Eliminate some temporary std::strings.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118086 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 22:07:47 +00:00
Dan Gohman
8eeb5ae31d
Micro-optimize.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118058 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 20:52:47 +00:00
Mikhail Glushenkov
9cd5971228
Make FindProgramByName return paths with slashes unmodified on Windows.
...
This makes its behaviour more consistent across platforms.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118048 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 20:32:39 +00:00
Mikhail Glushenkov
f5a95ce0d4
Path: Add GetEXESuffix() to complement GetDLLSuffix().
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118042 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 20:32:26 +00:00
Dan Gohman
3545635a60
Check if ErrMsg is null. This fixes the "not" command.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117666 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-29 17:20:42 +00:00
Dan Gohman
e5f77cda25
Make Program::Wait differentiate execution failure due to the file
...
being not found from the file being not executable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117664 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-29 16:54:25 +00:00
Dan Gohman
695e85d477
Make Program::Wait provide an error message string for errors
...
executing the child process and abnormal child process termination.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117661 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-29 16:39:01 +00:00
Dan Gohman
24a492683c
Revert r117582, which reverted r77396. Searching PATH for a string
...
which contains slashes is inconsistent with the meaning of PATH on
Unix-type platforms, and pretty surprising.
If the user has given a specific path to execute and we can't
execute it, we should fail and say why. (Apparently the new
posix_spawn code doesn't always say why, but that's a separate
issue.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117596 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-28 20:34:33 +00:00
Mikhail Glushenkov
c61c7549a8
Revert r77396.
...
Original commit message:
On "Unix", if Program::FindProgramByName is given a name containing
slashes, just go with it, regardless of whether it looks like it will
be executable. This follows the behavior of sh(1) more closely.
It's better when behaviour is consistent between platforms. This change also
makes FindExecutable() behave as expected on unix-likes (before this commit, it
used to always succeed).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117582 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-28 19:32:58 +00:00
Mikhail Glushenkov
7289d06e48
Trailing whitespace.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117581 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-28 19:32:53 +00:00
Daniel Dunbar
95b4672234
CrashRecovery: Fix raise() override to actually send the right signal, *cough*.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116072 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-08 18:31:34 +00:00
Evan Cheng
a98111cf15
Correctly check if a path is a directory. Fix by Brian Korver.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115991 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-07 22:05:57 +00:00
Daniel Dunbar
a7e3b56477
Add an explicit initialization to work around what appears to be a valgrind
...
false positive, at least on Darwin. I haven't filed this, but you can feel free.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115242 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 23:56:49 +00:00
Daniel Dunbar
e4e06a86bc
CrashRecovery/Darwin: Override raise() as well so that crash recovery doesn't
...
end up altering the thread on which crashes are done because of its use of
Darwin's broken raise() implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114558 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-22 17:46:10 +00:00
Dan Gohman
b52d44a0e6
Issue a #error if the host doesn't have an implementation for
...
GetMainExecutable yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113240 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-07 18:26:49 +00:00
Dan Gohman
86759acf01
Apply a patch from Kees van Reeuwijk to add support for Minix.
...
Minix apparently doesn't like double-slash separators, and there's
no apparent need for them here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112844 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-02 18:24:46 +00:00
Dan Gohman
41154114f6
Add an interface for unregistering a file from the FilesToRemove list.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112705 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-01 14:17:34 +00:00
Anton Korobeynikov
1d76ab7f56
Some fixes for NetBSD
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112662 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 22:38:00 +00:00
Daniel Dunbar
b08ceb8135
CrashRecovery/Darwin: On Darwin, raise sends a signal to the main thread instead
...
of the current thread. This has the unfortunate effect that assert() and abort()
will end up bypassing our crash recovery attempts. We work around this for
anything in the same linkage unit by just defining our own versions of the
assert handler and abort.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111583 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19 23:45:39 +00:00
Dan Gohman
d98af0a5b8
Eliminate unnecessary empty string literals.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110183 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-04 01:39:08 +00:00
Owen Anderson
826c148aa5
Add an erase() method to llvm::ThreadLocal.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109686 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-28 22:49:43 +00:00
Duncan Sands
3dc7224379
Rather than using an ifdef on the target to zero out fields,
...
just use memset to zero the entire struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108330 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-14 14:32:33 +00:00
Chris Lattner
1f01109254
improve Path::makeUnique when mkstemp/mktemp are not available
...
patch by Lasse Kärkkäinen in PR7404.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108110 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-12 00:09:55 +00:00
Chris Lattner
29269d03af
add some triple for minix, patch by Kees van Reeuwijk from PR7582
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107785 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-07 15:52:27 +00:00
Dan Gohman
39f76bb6c8
Factor out the handler work from SignalHandler into a helper function,
...
and change llvm::sys::RunInterruptHandlers to call that function directly
instead of calling SignalHandler, because the rest of SignalHandler
invokes side effects which aren't appropriate, including raising the
signal.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104896 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-27 23:11:55 +00:00
Dan Gohman
02d5824266
Don't bother clearing the Magic string when the magic number
...
can't be read, since it isn't cleared on other error paths.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104852 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-27 17:14:10 +00:00
Daniel Dunbar
fb89e08413
Add llvm::sys::RunInterruptHandlers(), which runs the registered SIGINT cleanup
...
stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103333 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-08 02:10:34 +00:00
Dan Gohman
023f8aaa16
This doesn't need SmallVector.h anymore.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101790 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 17:51:31 +00:00
Dan Gohman
17192a1dd8
Fix this for std::vectors which don't have .data().
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101785 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 16:33:28 +00:00
Dan Gohman
985744ecc6
Fix -Wcast-qual warnings.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101782 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 15:55:10 +00:00
Dan Gohman
72bdd4ca07
Revert 91528 and use a std::vector instead, fixing an abuse of std::string.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101781 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 15:54:44 +00:00
Chris Lattner
d65077a509
avoid temporary std::string in non posix_spawn path.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101723 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-18 17:34:10 +00:00
Benjamin Kramer
d7aef9b440
Eliminate temporary string.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101711 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-18 09:19:41 +00:00
Benjamin Kramer
bceaffc7cc
Properly inherit the environment on darwin where environ is not available for shared libraries.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101710 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-18 09:16:04 +00:00
Nick Lewycky
6523803203
This is horrible. Split the difference, and declare 'environ' on all non-Darwin
...
platforms to unbreak the darwin and linux builds. The BSD folks should feel
free to change the #if, if this breaks them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101703 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-18 07:07:48 +00:00
Nick Lewycky
1a3eb953cc
Revert r101701, Darwin doesn't have 'environ'. Go figure.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101702 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-18 06:44:21 +00:00
Nick Lewycky
b7dfca9778
Fix linux build. posix_spawn doesn't inherit the environment by default.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101701 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-18 06:22:26 +00:00
Chris Lattner
4f098b68a5
make Program::Execute use posix_spawn on systems that support it,
...
as it is more efficient than fork/exec.
Thanks to Eric for adding the autoconf check. It would be nice if
a cmake guru could add a cmake check for posix_spawn as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101693 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-18 04:14:37 +00:00
Chris Lattner
47e476609b
improve haiku portability, patch by Paul Davey.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100933 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-10 17:54:51 +00:00