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

352 Commits

Author SHA1 Message Date
Chandler Carruth
137ae633c7 [C++11] Add support for OwningPtr<T> to be converted to and from
std::unique_ptr<T>.

Patch by Ahmed Charles!

llvm-svn: 202609
2014-03-02 03:38:32 +00:00
Chandler Carruth
90cab68af4 [C++11] Add unit tests for OwningPtr<T> in preparation for changes to make
it interoperate (minimally) with std::unique_ptr<T>. This is part of my
plan to migrate LLVM to use std::unique_ptr with a minimal impact on
out-of-tree code.

Patch by Ahmed Charles with some minor cleanups (and bool casts) by me.

llvm-svn: 202608
2014-03-02 03:26:39 +00:00
Chandler Carruth
5814a8b4f3 [C++11] Remove uses of LLVM_HAS_RVALUE_REFERENCES from the unittests.
llvm-svn: 202583
2014-03-01 09:36:06 +00:00
Duncan P. N. Exon Smith
56ef9a3086 fix crash in SmallDenseMap copy constructor
Prevent a crash in the SmallDenseMap copy constructor whenever the other
map is not in small mode.

<rdar://problem/14292693>

llvm-svn: 202206
2014-02-25 23:35:13 +00:00
Reid Kleckner
abe8b5fc2e Tweak an _MSC_VER ifdef to use typename with clang in a unittest
In theory, Clang should figure out how to parse this correctly without
typename, but since this is the last TU that Clang falls back on in the
self-host, I'm going to compromise and check for __clang__.

And now Clang can self-host on -win32 without fallback!  The 'check' and
'check-clang' targets both pass.

llvm-svn: 201358
2014-02-13 19:51:13 +00:00
Nick Kledzik
d2da6e7c22 Fix layering StringRef copy using BumpPtrAllocator.
Now to copy a string into a BumpPtrAllocator and get a StringRef to the copy:

   StringRef myCopy = myStr.copy(myAllocator);
   

llvm-svn: 200885
2014-02-05 22:22:56 +00:00
Duncan P. N. Exon Smith
e9a572242c Clean up whitespace
llvm-svn: 200579
2014-01-31 21:45:51 +00:00
Alp Toker
b29938426f Roll back the ConstStringRef change for now
There are a couple of interesting things here that we want to check over
(particularly the expecting asserts in StringRef) and get right for general use
in ADT so hold back on this one. For clang we have a workable templated
solution to use in the meanwhile.

This reverts commit r200187.

llvm-svn: 200194
2014-01-27 05:24:39 +00:00
Alp Toker
43e8630002 StringRef: Extend constexpr capabilities and introduce ConstStringRef
(1) Add llvm_expect(), an asserting macro that can be evaluated as a constexpr
    expression as well as a runtime assert or compiler hint in release builds. This
    technique can be used to construct functions that are both unevaluated and
    compiled depending on usage.

(2) Update StringRef using llvm_expect() to preserve runtime assertions while
    extending the same checks to static asserts in C++11 builds that support the
    feature.

(3) Introduce ConstStringRef, a strong subclass of StringRef that references
    compile-time constant strings. It's convertible to, but not from, ordinary
    StringRef and thus can be used to add compile-time safety to various interfaces
    in LLVM and clang that only accept fixed inputs such as diagnostic format
    strings that tend to get misused.

llvm-svn: 200187
2014-01-27 04:07:17 +00:00
Michael Gottesman
181ec670ce [APInt] Fix nearestLogBase2 to return correct answers for very large APInt and APInt with a bitwidth of 1.
I also improved the comments, added some more tests, etc.

llvm-svn: 199610
2014-01-19 20:33:48 +00:00
Michael Gottesman
7a8ef6d280 [APInt] Fixed bug where APInt(UINT32_MAX, 0) would blow up when being constructed.
This was due to arithmetic overflow in the getNumBits() computation. Now we
cast BitWidth to a uint64_t so that does not occur during the computation. After
the computation is complete, the uint64_t is truncated when the function
returns.

I know that this is not something that is likely to happen, but it *IS* a valid
input and we should not blow up.

llvm-svn: 199609
2014-01-19 20:33:38 +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
David Blaikie
b1e8db189d Fix break introduced in r198377 due to using a local type as a template parameter.
llvm-svn: 198379
2014-01-03 00:00:41 +00:00
David Blaikie
3036d7607c Test coverage for non-default-constructible elements in a StringMap
This functionality was enabled by r198374. Here's a test to ensure it
works and we don't regress it.

Based on a patch by Maciej Piechotka.

llvm-svn: 198377
2014-01-02 23:57:28 +00:00
David Blaikie
05d9569f03 Remove StringMapEntryInitializer support.
It was never specialized so let's just remove that unused
configurability and always do the default.

llvm-svn: 198374
2014-01-02 23:28:39 +00:00
Anna Zaks
3a3a64f7fe Fix a buffer overrun detected by AddressSanitizer.
llvm-svn: 197647
2013-12-19 02:35:26 +00:00
Michael Gottesman
4c26c21fc1 Remove APInt::extractBit since it is already implemented via operator[]. Change tests for extractBit to test operator[].
llvm-svn: 197277
2013-12-13 22:00:19 +00:00
Michael Gottesman
10caac931c [block-freq] Add the method APInt::nearestLogBase2().
llvm-svn: 197272
2013-12-13 20:47:37 +00:00
Michael Gottesman
7ed19350c0 [block-freq] Add the APInt method extractBit.
llvm-svn: 197271
2013-12-13 20:47:34 +00:00
Tim Northover
a10d9b4c9c Darwin: update default iOS version to 5.0
Defaulting to iOS 3.0 when LLVM has to guess the version is no longer a useful
option and can give surprising results (like tail calls being disabled).

5.0 seems like a reasonable compromise as a platform that's still interesting
to some people.

rdar://problem/15567348

llvm-svn: 196912
2013-12-10 11:53:16 +00:00
Chandler Carruth
ffaacacd23 Make the moved-from SmallPtrSet be a valid, empty, small-state object.
Enhance the tests to actually require moves in C++11 mode, in addition
to testing the moved-from state. Further enhance the tests to cover
copy-assignment into a moved-from object and moving a large-state
object. (Note that we can't really test small-state vs. large-state as
that isn't an observable property of the API really.) This should finish
addressing review on r195239.

llvm-svn: 195261
2013-11-20 18:29:56 +00:00
Chandler Carruth
90ef1fdaca Add a test for assignment operator behavior which was changed in
r195239, as well as a comment about the fact that assigning over
a moved-from object was in fact tested. Addresses some of the review
feedback on r195239.

llvm-svn: 195260
2013-11-20 18:21:25 +00:00
Chandler Carruth
8070950ee8 Give SmallPtrSet move semantics when we have R-value references.
Somehow, this ADT got missed which is moderately terrifying considering
the efficiency of move for it.

The code to implement move semantics for it is pretty horrible
currently but was written to reasonably closely match the rest of the
code. Unittests that cover both copying and moving (at a basic level)
added.

llvm-svn: 195239
2013-11-20 11:14:33 +00:00
Juergen Ributzka
990c8318f8 [weak vtables] Place class definitions into anonymous namespaces to prevent weak vtables.
This patch places class definitions in implementation files into anonymous
namespaces to prevent weak vtables. This eliminates the need of providing an
out-of-line definition to pin the vtable explicitly to the file.

llvm-svn: 195092
2013-11-19 03:08:35 +00:00
Juergen Ributzka
5357a6d64b [weak vtables] Remove a bunch of weak vtables
This patch removes most of the trivial cases of weak vtables by pinning them to
a single object file. The memory leaks in this version have been fixed. Thanks
Alexey for pointing them out.

Differential Revision: http://llvm-reviews.chandlerc.com/D2068

Reviewed by Andy

llvm-svn: 195064
2013-11-19 00:57:56 +00:00
Alexey Samsonov
3bfef6bdb6 Revert r194865 and r194874.
This change is incorrect. If you delete virtual destructor of both a base class
and a subclass, then the following code:
  Base *foo = new Child();
  delete foo;
will not cause the destructor for members of Child class. As a result, I observe
plently of memory leaks. Notable examples I investigated are:
ObjectBuffer and ObjectBufferStream, AttributeImpl and StringSAttributeImpl.

llvm-svn: 194997
2013-11-18 09:31:53 +00:00
Juergen Ributzka
ee3af15269 [weak vtables] Remove a bunch of weak vtables
This patch removes most of the trivial cases of weak vtables by pinning them to
a single object file.

Differential Revision: http://llvm-reviews.chandlerc.com/D2068

Reviewed by Andy

llvm-svn: 194865
2013-11-15 22:34:48 +00:00
Chandler Carruth
7c64c22064 Fix a null pointer dereference when copying a null polymorphic pointer.
This bug only bit the C++98 build bots because all of the actual uses
really do move. ;] But not *quite* ready to do the whole C++11 switch
yet, so clean it up. Also add a unit test that catches this immediately.

llvm-svn: 194548
2013-11-13 02:48:20 +00:00
Chandler Carruth
17436ff36f Switch to allow implicit construction. In many cases, we're wrapping
a derived type and this makes it *much* easier to write this code.

llvm-svn: 194321
2013-11-09 05:55:03 +00:00
Chandler Carruth
04f0969715 Test the polymorphic behavior of this utility.
llvm-svn: 194320
2013-11-09 04:58:13 +00:00
Chandler Carruth
d01da74a3a Use something really explicit to test "move semantics" on builds without
r-value references. I still want to test that when we have them,
llvm_move is actually a move.

Have I mentioned that I really want to move to C++11? ;]

llvm-svn: 194318
2013-11-09 04:49:27 +00:00
Chandler Carruth
2d15bb84b6 Add the critically missing 'clone' method. =]
Clang managed to never instantiate the copy constructor. Added tests to
ensure this path is tested.

We could still use tests for the polymorphic nature. Those coming up
next.

llvm-svn: 194317
2013-11-09 04:32:34 +00:00
Chandler Carruth
034b3fa859 Move the test type out of the function and into the anonymous namespace
to fix C++98 builds.

llvm-svn: 194316
2013-11-09 04:09:50 +00:00
Chandler Carruth
8d866a1fb5 Add a polymorphic_ptr<T> smart pointer data type. It's a somewhat silly
unique ownership smart pointer which is *deep* copyable by assuming it
can call a T::clone() method to allocate a copy of the owned data.

This is mostly useful with containers or other collections of uniquely
owned data in C++98 where they *might* copy. With C++11 we can likely
remove this in favor of move-only types and containers wrapped around
those types.

llvm-svn: 194315
2013-11-09 04:06:02 +00:00
Rui Ueyama
75714118ae Add {start,end}with_lower methods to StringRef.
startswith_lower is ocassionally useful and I think worth adding.
endwith_lower is added for completeness.

Differential Revision: http://llvm-reviews.chandlerc.com/D2041

llvm-svn: 193706
2013-10-30 18:32:26 +00:00
Rui Ueyama
d2d474fbd6 Add a few tests for StringRef::{start,end}with.
llvm-svn: 193550
2013-10-28 22:42:54 +00:00
Joerg Sonnenberger
d6a76ffd81 Add a Python-like join function to merge a list of strings with a
separator between each two elements.

llvm-svn: 189846
2013-09-03 20:43:54 +00:00
Eli Friedman
bb860a63ef Change default # of digits for APFloat::toString
This is a re-commit of r189442; I'll follow up with clang changes.

The previous default was almost, but not quite enough digits to
represent a floating-point value in a manner which preserves the
representation when it's read back in.  The larger default is much
less confusing.

I spent some time looking into printing exactly the right number of
digits if a precision isn't specified, but it's kind of complicated,
and I'm not really sure I understand what APFloat::toString is supposed
to output for FormatPrecision != 0 (or maybe the current API specification
is just silly, not sure which).  I have a WIP patch if anyone is interested.

llvm-svn: 189624
2013-08-29 23:44:34 +00:00
Ted Kremenek
16beb74d93 Revert r189442 "Change default # of digits for APFloat::toString"
This is breaking numerous Clang tests on the buildbot.

llvm-svn: 189447
2013-08-28 06:21:46 +00:00
Eli Friedman
75cdc76b2b Change default # of digits for APFloat::toString
The previous default was almost, but not quite enough digits to
represent a floating-point value in a manner which preserves the
representation when it's read back in.  The larger default is much
less confusing.

I spent some time looking into printing exactly the right number of
digits if a precision isn't specified, but it's kind of complicated,
and I'm not really sure I understand what APFloat::toString is supposed
to output for FormatPrecision != 0 (or maybe the current API specification
is just silly, not sure which).  I have a WIP patch if anyone is interested.

llvm-svn: 189442
2013-08-28 05:23:51 +00:00
David Blaikie
29dad430cd Basic unit tests for PointerUnion
llvm-svn: 188933
2013-08-21 21:30:23 +00:00
Michael Gottesman
f899e8827f [APFloat] Make all arithmetic operations with NaN produce positive NaNs.
IEEE-754R 1.4 Exclusions states that IEEE-754R does not specify the
interpretation of the sign of NaNs. In order to remove an irrelevant
variable that most floating point implementations do not use,
standardize add, sub, mul, div, mod so that operating anything with
NaN always yields a positive NaN.

In a later commit I am going to update the APIs for creating NaNs so
that one can not even create a negative NaN.

llvm-svn: 187314
2013-07-27 21:49:25 +00:00
Rafael Espindola
326babb234 Revert "[PowerPC] Improve consistency in use of __ppc__, __powerpc__, etc."
This reverts commit r187248. It broke many bots.

llvm-svn: 187254
2013-07-26 22:13:57 +00:00
Bill Schmidt
149eda1b1e [PowerPC] Improve consistency in use of __ppc__, __powerpc__, etc.
Both GCC and LLVM will implicitly define __ppc__ and __powerpc__ for
all PowerPC targets, whether 32- or 64-bit.  They will both implicitly
define __ppc64__ and __powerpc64__ for 64-bit PowerPC targets, and not
for 32-bit targets.  We cannot be sure that all other possible
compilers used to compile Clang/LLVM define both __ppc__ and
__powerpc__, for example, so it is best to check for both when relying
on either inside the Clang/LLVM code base.

This patch makes sure we always check for both variants.  In addition,
it fixes one unnecessary check in lib/Target/PowerPC/PPCJITInfo.cpp.
(At least one of __ppc__ and __powerpc__ should always be defined when
compiling for a PowerPC target, no matter which compiler is used, so
testing for them is unnecessary.)

There are some places in the compiler that check for other variants,
like __POWERPC__ and _POWER, and I have left those in place.  There is
no need to add them elsewhere.  This seems to be in Apple-specific
code, and I won't take a chance on breaking it.

There is no intended change in behavior; thus, no test cases are
added.

llvm-svn: 187248
2013-07-26 21:39:15 +00:00
Eli Friedman
d18dd0a7b0 Handle '.' correctly in hex float literal parsing.
There were a couple of different loops that were not handling
'.' correctly in APFloat::convertFromHexadecimalString; these mistakes
could lead to assertion failures and incorrect rounding for overlong
hex float literals.

Fixes PR16643.

llvm-svn: 186539
2013-07-17 22:17:29 +00:00
Benjamin Kramer
5d304115ca Sync SmallBitVector with BitVector. Add unit tests for the missing methods.
llvm-svn: 186123
2013-07-11 21:59:16 +00:00
Michael Gottesman
b399188af0 [APFloat] Ensure that we can properly parse strings that do not have null terminators.
rdar://14323230

llvm-svn: 185397
2013-07-01 23:54:08 +00:00
Michael Gottesman
6fb80a527d [APFloat] Added unittest for APFloat.divide that checks special cases, result categories, and result statuses.
llvm-svn: 185050
2013-06-27 00:42:00 +00:00
Michael Gottesman
e83cdadda7 Removed two logging printf statements from the APFloat tests... = /.
llvm-svn: 185045
2013-06-27 00:00:45 +00:00
Michael Gottesman
34f626681a [APFloat] Added unittest for APFloat.multiply that checks special cases, result categories, and result status.
llvm-svn: 185044
2013-06-26 23:55:26 +00:00