1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
Commit Graph

46 Commits

Author SHA1 Message Date
Nick Lewycky
6c9fb2428f Use std::forward to make ErrorOr<T> constructible from a value that has a user-defined conversion to T. No functionality change intended.
llvm-svn: 260196
2016-02-09 04:47:58 +00:00
Nick Lewycky
08898c3fea Fix typo in comment. NFC
llvm-svn: 259620
2016-02-03 02:15:49 +00:00
Eugene Zelenko
966902f532 Fix Clang-tidy modernize-use-nullptr and modernize-use-override warnings; other minor fixes.
Differential revision: reviews.llvm.org/D16568

llvm-svn: 258831
2016-01-26 18:48:36 +00:00
Kevin Enderby
8994e20f69 Reapply r250906 with many suggested updates from Rafael Espindola.
The needed lld matching changes to be submitted immediately next,
but this revision will cause lld failures with this alone which is expected.

This removes the eating of the error in Archive::Child::getSize() when the characters
in the size field in the archive header for the member is not a number.  To do this we
have all of the needed methods return ErrorOr to push them up until we get out of lib.
Then the tools and can handle the error in whatever way is appropriate for that tool.

So the solution is to plumb all the ErrorOr stuff through everything that touches archives.
This include its iterators as one can create an Archive object but the first or any other
Child object may fail to be created due to a bad size field in its header.

Thanks to Lang Hames on the changes making child_iterator contain an
ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add
operator overloading for * and -> .

We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash”
and using report_fatal_error() to move the error checking will cause the program to
stop, neither of which are really correct in library code. There are still some uses of
these that should be cleaned up in this library code for other than the size field.

The test cases use archives with text files so one can see the non-digit character,
in this case a ‘%’, in the size field.

These changes will require corresponding changes to the lld project.  That will be
committed immediately after this change.  But this revision will cause lld failures
with this alone which is expected.

llvm-svn: 252192
2015-11-05 19:24:56 +00:00
Kevin Enderby
1d015d1179 Backing out commit r250906 as it broke lld.
llvm-svn: 250908
2015-10-21 17:13:20 +00:00
Kevin Enderby
bcb0d035e4 This removes the eating of the error in Archive::Child::getSize() when the characters
in the size field in the archive header for the member is not a number.  To do this we
have all of the needed methods return ErrorOr to push them up until we get out of lib.
Then the tools and can handle the error in whatever way is appropriate for that tool.

So the solution is to plumb all the ErrorOr stuff through everything that touches archives.
This include its iterators as one can create an Archive object but the first or any other
Child object may fail to be created due to a bad size field in its header.

Thanks to Lang Hames on the changes making child_iterator contain an
ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add
operator overloading for * and -> .

We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash”
and using report_fatal_error() to move the error checking will cause the program to
stop, neither of which are really correct in library code. There are still some uses of
these that should be cleaned up in this library code for other than the size field.

Also corrected the code where the size gets us to the “at the end of the archive”
which is OK but past the end of the archive will return object_error::parse_failed now.

The test cases use archives with text files so one can see the non-digit character,
in this case a ‘%’, in the size field.

llvm-svn: 250906
2015-10-21 16:59:24 +00:00
Lang Hames
5ef98acf10 Add emacs c++ mode hint.
llvm-svn: 250479
2015-10-16 00:44:01 +00:00
Michael J. Spencer
e4b728c636 [Support] Fix ErrorOr equality operator.
llvm-svn: 237970
2015-05-21 23:15:00 +00:00
Aaron Ballman
0e19b5d670 Removing LLVM_EXPLICIT, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition.
llvm-svn: 229335
2015-02-15 22:00:20 +00:00
Justin Bogner
03d5784ea1 ErrorOr: Be more explicit in the implicit conversion to bool docs
llvm-svn: 221295
2014-11-04 21:01:48 +00:00
Alexey Samsonov
31013fe069 Try to fix GCC error about invalid use of const_cast in const version of ErrorOr::get()
llvm-svn: 220233
2014-10-20 20:41:21 +00:00
David Blaikie
c2ca095c4d Ensure ErrorOr cannot implicitly invoke explicit ctors of the underlying type.
An unpleasant surprise while migrating unique_ptrs (see changes in
lib/Object): ErrorOr<int*> was implicitly convertible to
ErrorOr<std::unique_ptr<int>>.

Keep the explicit conversions otherwise it's a pain to convert
ErrorOr<int*> to ErrorOr<std::unique_ptr<int>>.

I'm not sure if there should be more SFINAE on those explicit ctors (I
could check if !is_convertible && is_constructible, but since the ctor
has to be called explicitly I don't think there's any need to disable
them when !is_constructible - they'll just fail anyway. It's the
converting ctors that can create interesting ambiguities without proper
SFINAE). I had to SFINAE the explicit ones because otherwise they'd be
ambiguous with the implicit ones in an explicit context, so far as I
could tell.

The converting assignment operators seemed unnecessary (and similarly
buggy/dangerous) - just rely on the converting ctors to convert to the
right type for assignment instead.

llvm-svn: 217048
2014-09-03 17:31:25 +00:00
Benjamin Kramer
da144ed5a2 Canonicalize header guards into a common format.
Add header guards to files that were missing guards. Remove #endif comments
as they don't seem common in LLVM (we can easily add them back if we decide
they're useful)

Changes made by clang-tidy with minor tweaks.

llvm-svn: 215558
2014-08-13 16:26:38 +00:00
Rafael Espindola
0df15fc77a Finishing touch for the std::error_code transition.
While std::error_code itself seems to work OK in all platforms, there
are few annoying differences with regards to the std::errc enumeration.

This patch adds a simple llvm enumeration, which will hopefully avoid build
breakages in other platforms and surprises as we get more uses of
std::error_code.

llvm-svn: 210920
2014-06-13 17:20:48 +00:00
Rafael Espindola
e0e308ff6d Don't use 'using std::error_code' in include/llvm.
This should make sure that most new uses use the std prefix.

llvm-svn: 210835
2014-06-12 21:46:39 +00:00
Rafael Espindola
38dc624425 Remove system_error.h.
This is a minimal change to remove the header. I will remove the occurrences
of "using std::error_code" in a followup patch.

llvm-svn: 210803
2014-06-12 17:38:55 +00:00
Rafael Espindola
53875ad05c Replace llvm::error_code with std::error_code.
llvm-svn: 210783
2014-06-12 14:11:22 +00:00
Rafael Espindola
d004f0c75f Don't import make_error_code into the llvm namespace.
llvm-svn: 210772
2014-06-12 11:58:49 +00:00
Rafael Espindola
70f03ca11f Remove some low hanging fruit from system_error.h
llvm-svn: 210728
2014-06-12 01:10:47 +00:00
Rafael Espindola
c86cc04638 Use error_code() instead of error_code::succes()
There is no std::error_code::success, so this removes much of the noise
in transitioning to std::error_code.

llvm-svn: 209952
2014-05-31 01:37:45 +00:00
Benjamin Kramer
c92e236041 [C++11] Replace LLVM-style type traits with C++11 standard ones.
No functionality change.

llvm-svn: 203242
2014-03-07 14:42:25 +00:00
Chandler Carruth
093c36deb9 [C++11] Remove LLVM_HAS_CXX11_TYPETRAITS now that it is a constant due
to the build being C++11.

There is clearly still plenty of simplification than can be done here by
using standard type traits instead of rolling our own in many places.

llvm-svn: 202586
2014-03-01 10:48:14 +00:00
Chandler Carruth
df9f7f4aec [C++11] Remove the R-value reference #if usage from the ADT and Support
libraries. It is now always 1 in LLVM builds.

llvm-svn: 202580
2014-03-01 09:27:28 +00:00
Alexey Samsonov
f0a1f6058a Try to revive buildbots after r201620
llvm-svn: 201651
2014-02-19 08:30:55 +00:00
Rafael Espindola
51ef33c946 Use LLVM_EXPLICIT instead of a function pointer as bool.
llvm-svn: 199437
2014-01-16 23:37:23 +00:00
Rafael Espindola
f8bce2c4fa Update example to be more idiomatic.
llvm-svn: 198872
2014-01-09 14:40:43 +00:00
Rafael Espindola
8934d0e1d7 Use the existing typedef to avoid forming a reference to a reference.
llvm-svn: 198817
2014-01-09 00:25:25 +00:00
Rafael Espindola
9221326f8e Fix the C++03 build.
With c++11 we never instantiate the copy constructor.

llvm-svn: 198803
2014-01-08 22:27:04 +00:00
Rafael Espindola
721b465b58 Use getError and remove the error_code operator.
llvm-svn: 198799
2014-01-08 22:03:39 +00:00
Rafael Espindola
03d710138d Add get and getError methods to ErrorOr.
ErrorOr is modeled after boost::optional which has a get method.

llvm-svn: 198792
2014-01-08 21:17:09 +00:00
Rafael Espindola
0994280828 Add missing rename from the previous commit.
No idea how this was compiling locally. Found by the bots.

llvm-svn: 198775
2014-01-08 17:56:46 +00:00
Rafael Espindola
731f7b3ccb Rename get to getStorage and getError to getErrorStorage.
These private functions return pointers to the internal storage.

llvm-svn: 198774
2014-01-08 17:43:26 +00:00
Chandler Carruth
87f14b4eec Re-sort all of the includes with ./utils/sort_includes.py so that
subsequent changes are easier to review. About to fix some layering
issues, and wanted to separate out the necessary churn.

Also comment and sink the include of "Windows.h" in three .inc files to
match the usage in Memory.inc.

llvm-svn: 198685
2014-01-07 11:48:04 +00:00
Rafael Espindola
292e8533b8 Remove another unused, and IMHO, not very desirable feature of ErrorOr.
One of the uses of the IsValid flag is to support default constructing
a ErrorOr that is not a Error or a Value. There is not much value in
doing that IMHO. If ErrorOr was to have a default constructor, it
should be implemented by default constructing the value, but even that
looks unnecessary.

The other use is to avoid calling destructors on moved objects. This
looks wrong. If the data being moved has non trivial treatment of
moves (an std::vector for example), it is its destructor that should
handle it, not ~ErrorOr.

With this change ErrorOr becomes a fairly simple wrapper and should
always be better than using an error_code + value in an API.

llvm-svn: 194109
2013-11-05 23:41:57 +00:00
Rafael Espindola
4e1620cfb1 Fix MSVC build by not putting an error_code directly in a union.
llvm-svn: 194032
2013-11-05 01:07:06 +00:00
Rafael Espindola
334fa3d8a8 Simplify ErrorOr.
ErrorOr had quiet a bit of complexity and indirection to be able to hold a user
type with the error.

That feature is not used anymore. This patch removes it, it will live in svn
history if we ever need it again.

If we do need it again, IMHO there is one thing that should be done
differently: Holding extra info in the error is not a property a function also
returning a value or not. The ability to hold extra info should be in the error
type and ErrorOr templated over it so that we don't need the funny looking
ErrorOr<void>.

llvm-svn: 194030
2013-11-05 00:28:01 +00:00
Benjamin Kramer
b0d0e9091e Speling fixes.
llvm-svn: 193165
2013-10-22 15:18:03 +00:00
Michael J. Spencer
55347a0780 [Support][ErrorOr] Add support for implicit conversion from error code/condition enums.
llvm-svn: 176228
2013-02-28 01:44:26 +00:00
Michael J. Spencer
c795dd0ca7 [Support][ErrorOr] Add support for convertable types.
Thanks to Andrew, David, and Aaron for helping fix this.

llvm-svn: 174552
2013-02-06 22:28:53 +00:00
Andrew Trick
2e729a5aff Revert "[Support][ErrorOr] Add support for convertable types."
This reverts commit a33e1fafac7fedb1b080ef07ddf9ad6ddff3a830.

This unit test crashes on Darwon. It needs to be temporarily reverted
to unblock the test infrastructure.

llvm-svn: 174458
2013-02-05 22:50:20 +00:00
Meador Inge
fc41768dd0 Support: ensure proper state in ErrorOr copy ctors before calling 'get'
Some paths through the copy constructors for 'ErrorOr' were calling
'get' when 'HasError' and 'IsValid' were not properly initialized.
Depending on what happened to be in memory for those member variables
the asserts in 'get' might incorrectly fire.  Fixed by ensuring that
the member variables in question are always initialized before calling
'get'.

llvm-svn: 174381
2013-02-05 15:41:27 +00:00
Michael J. Spencer
2da5c2c32d [Support][ErrorOr] Add support for convertable types.
llvm-svn: 174357
2013-02-05 08:22:27 +00:00
Michael J. Spencer
ddaa5b9eea [Support][ErrorOr] Don't use nullptr :(
llvm-svn: 173212
2013-01-23 00:22:30 +00:00
Michael J. Spencer
a34e71c387 [Support][ErrorOr] Add optimized specialization of ErrorOr<void>.
ErrorOr<void> represents an operation that returns nothing, but can still fail.
It should be used in cases where you need the aditional user data that ErrorOr
provides over error_code.

llvm-svn: 173209
2013-01-23 00:18:31 +00:00
Michael J. Spencer
faeb8e48a9 [Support][ErrorOr] Make old gcc happy.
Apparently this is how C++98 worked pre-DR. (Thanks Richard).

llvm-svn: 173203
2013-01-22 22:48:46 +00:00
Michael J. Spencer
74395cc7b4 [Support] Port ErrorOr<T> from lld to C++03.
llvm-svn: 172991
2013-01-20 20:32:30 +00:00