aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT
AgeCommit message (Collapse)AuthorFilesLines
2015-01-04[APFloat][ADT] Fix sign handling logic for FMA results that truncate to zero.Lang Hames1-0/+41
This patch adds a check for underflow when truncating results back to lower precision at the end of an FMA. The additional sign handling logic in APFloat::fusedMultiplyAdd should only be performed when the result of the addition step of the FMA (in full precision) is exactly zero, not when the result underflows to zero. Unit tests for this case and related signed zero FMA results are included. Fixes <rdar://problem/18925551>. llvm-svn: 225123
2015-01-01Revert r225053: Add an ArrayRef upcasting constructor from ArrayRef<U*> -> ↵Chandler Carruth1-35/+0
ArrayRef<T*> where T is a base of U. This appears to have broken at least the windows build bots due to compile errors in the predicate that didn't simply supress the overload. I'm not sure what the fix is, and the bots have been broken for a long time now so I'm just reverting until Michael can figure out a fix. llvm-svn: 225064
2014-12-31Add 2x constructors for TinyPtrVector, one that takes in one elemenet and ↵Michael Gottesman1-0/+26
the other that takes in an ArrayRef<EltTy> Currently one can only construct an empty TinyPtrVector. These are just missing elements of the API. llvm-svn: 225055
2014-12-31Add a SmallMapVector class that is a MapVector with a Map of SmallDenseMap ↵Michael Gottesman1-0/+218
and a Vector of SmallVector. llvm-svn: 225054
2014-12-31Add an ArrayRef upcasting constructor from ArrayRef<U*> -> ArrayRef<T*> ↵Michael Gottesman1-0/+35
where T is a base of U. llvm-svn: 225053
2014-12-03Silencing several "multiple copy constructors" warnings from MSVC; NFC.Aaron Ballman1-1/+0
llvm-svn: 223238
2014-12-03ADT: Add SmallVector<>::emplace_back()Duncan P. N. Exon Smith1-0/+131
llvm-svn: 223201
2014-11-20Compilation test for PostOrderIterator.Michael Ilseman2-0/+38
If the template specialization for externally managed sets in PostOrderIterator call too far out of sync with each other, this unit test will fail to build. This is especially useful for developers who may not build Clang (the only in-tree user) every time. llvm-svn: 222447
2014-11-19[ADT] Fix PR20728 - Incorrect APFloat::fusedMultiplyAdd results for x86_fp80.Lang Hames1-0/+12
As detailed at http://llvm.org/PR20728, due to an internal overflow in APFloat::multiplySignificand the APFloat::fusedMultiplyAdd method can return incorrect results for x87DoubleExtended (x86_fp80) values. This commonly manifests as incorrect constant folding of libm fmal calls on x86. E.g. fmal(1.0L, 1.0L, 3.0L) == 0.0L (should be 4.0L) This patch fixes PR20728 by adding an extra bit to the significand for intermediate results of APFloat::multiplySignificand, avoiding the overflow. llvm-svn: 222374
2014-11-19Remove StringMap::GetOrCreateValue in favor of StringMap::insertDavid Blaikie1-6/+4
Having two ways to do this doesn't seem terribly helpful and consistently using the insert version (which we already has) seems like it'll make the code easier to understand to anyone working with standard data structures. (I also updated many references to the Entry's key and value to use first() and second instead of getKey{Data,Length,} and get/setValue - for similar consistency) Also removes the GetOrCreateValue functions so there's less surface area to StringMap to fix/improve/change/accommodate move semantics, etc. llvm-svn: 222319
2014-11-14StringMap: Test and finish off supporting perfectly forwarded values in ↵David Blaikie1-1/+15
StringMap operations. Followup to r221946. llvm-svn: 221958
2014-11-12Ensure function_refs are copyable even from non-const referencesDavid Blaikie2-0/+29
A subtle bug was found where attempting to copy a non-const function_ref lvalue would actually invoke the generic forwarding constructor (as it was a closer match - being T& rather than the const T& of the implicit copy constructor). In the particular case this lead to a dangling function_ref member (since it had referenced the function_ref passed by value to its ctor, rather than the outer function_ref that was still alive) SFINAE the converting constructor to not be considered if the copy constructor is available and demonstrate that this causes the copy to refer to the original functor, not to the function_ref it was copied from. (without the code change, the test would fail as Y would be referencing X and Y() would see the result of the mutation to X, ie: 2) llvm-svn: 221753
2014-10-27Add MapVector::rbegin(), MapVector::rend() to completment ↵Michael Gottesman1-0/+25
MapVector::begin(), MapVector::end(). These just delegate to the underlying vector type in the MapVector. Also just add in some sanity unittests. llvm-svn: 220687
2014-10-19[ADT] Add a 'find_as' operation to DenseSet.Lang Hames1-0/+38
This operation is analogous to its counterpart in DenseMap: It allows lookup via cheap-to-construct keys (provided that getHashValue and isEqual are implemented for the cheap key-type in the DenseMapInfo specialization). Thanks to Chandler for the review. llvm-svn: 220168
2014-10-10[ADT] Add an (ADL-friendly) abs free function for APFloat that returnsChandler Carruth1-0/+38
by value having cleared the sign bit. llvm-svn: 219485
2014-10-10Add minnum / maxnum to APFloatMatt Arsenault1-0/+22
llvm-svn: 219475
2014-10-10[ADT] Replace the logb implementation with the simpler and much closerChandler Carruth1-49/+27
to what we actually want ilogb implementation. This makes everything *much* easier to deal with and is actually what we want when using it anyways. llvm-svn: 219474
2014-10-10[ADT] Add the scalbn function for APFloat.Chandler Carruth1-0/+43
llvm-svn: 219473
2014-10-10[ADT] Implement the 'logb' functionality for APFloat. This is necessaryChandler Carruth1-0/+51
to implement complex division in the constant folder of Clang. llvm-svn: 219471
2014-10-09[ADT] Add basic operator overloads for arithmetic to APFloat to makeChandler Carruth1-0/+20
code using it more readable. Also add a copySign static function that works more like the standard function by accepting the value and sign-carying value as arguments. No interesting logic here, but tests added to cover the basic API additions and make sure they do something plausible. llvm-svn: 219453
2014-10-07Add return value and negative checks to MapVector::erase from r219240.Kaelyn Takata1-1/+4
llvm-svn: 219250
2014-10-07Add size_t MapVector::erase(KeyT) similar to the one in std::map.Kaelyn Takata1-0/+5
llvm-svn: 219240
2014-10-01Update test name to match changes made in r218783David Blaikie1-1/+1
Addressing post commit review feedback from Justin Bogner. llvm-svn: 218821
2014-10-01Add an immovable type to test Optional<T>::emplace more rigorously after ↵David Blaikie1-5/+26
r218732. llvm-svn: 218783
2014-10-01ADTTests/OptionalTest.cpp: Use LLVM_DELETED_FUNCTION.NAKAMURA Takumi1-4/+4
llvm-svn: 218750
2014-10-01Add an emplace(...) method to llvm::Optional<T>.Jordan Rose1-0/+49
This can be used for in-place initialization of non-moveable types. For compilers that don't support variadic templates, only up to four arguments are supported. We can always add more, of course, but this should be good enough until we move to a later MSVC that has full support for variadic templates. Inspired by std::experimental::optional from the "Library Fundamentals" C++ TS. Reviewed by David Blaikie. llvm-svn: 218732
2014-09-29Add getValueOr to llvm::Optional<T>.Jordan Rose1-0/+29
This takes a single argument convertible to T, and - if the Optional has a value, returns the existing value, - otherwise, constructs a T from the argument and returns that. Inspired by std::experimental::optional from the "Library Fundamentals" C++ TS. llvm-svn: 218618
2014-09-19Add hsail and amdil64 to TripleMatt Arsenault1-0/+84
llvm-svn: 218142
2014-09-15Add unit test for r217454Ed Maste1-0/+4
llvm-svn: 217786
2014-08-31Add some negative (and positive) static_assert checks for ↵David Blaikie1-0/+17
ArrayRef-of-pointer conversions introduced in r216709 llvm-svn: 216830
2014-08-30Add a test for converting ArrayRef<T *> to ArrayRef<const T *>.Craig Topper1-0/+10
llvm-svn: 216821
2014-08-27Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper1-4/+4
just letting them be implicitly created. llvm-svn: 216525
2014-08-19ADT: Unit test for ArrayRef::equals change in r215986Duncan P. N. Exon Smith1-0/+4
llvm-svn: 216008
2014-08-12Fix -Wsign-compare warningsDavid Blaikie1-3/+3
llvm-svn: 215483
2014-08-12APInt: Make self-move-assignment a no-op to fix stage3 clang-clReid Kleckner1-0/+17
It's not clear what the semantics of a self-move should be. The consensus appears to be that a self-move should leave the object in a moved-from state, which is what our existing move assignment operator does. However, the MSVC 2013 STL will perform self-moves in some cases. In particular, when doing a std::stable_sort of an already sorted APSInt vector of an appropriate size, one of the merge steps will self-move half of the elements. We don't notice this when building with MSVC, because MSVC will not synthesize the move assignment operator for APSInt. Presumably MSVC does this because APInt, the base class, has user-declared special members that implicitly delete move special members. Instead, MSVC selects the copy-assign operator, which defends against self-assignment. Clang, on the other hand, selects the move-assign operator, and we get garbage APInts. llvm-svn: 215478
2014-08-09ADT: remove MinGW32 and Cygwin OSType enumSaleem Abdulrasool1-1/+1
Remove the MinGW32 and Cygwin types from the OSType enumeration. These values are represented via environments of Windows. It is a source of confusion and needlessly clutters the code. The cost of doing this is that we must sink the check for them into the normalization code path along with the spelling. Addresses PR20592. llvm-svn: 215303
2014-08-04Fix SmallDenseMap assignment operator.Andrew Trick1-0/+5
Self assignment would lead to buckets of garbage, causing quadratic probing to hang. llvm-svn: 214790
2014-07-27[ADT] Add a remarkbly useful little helper routine to ArrayRef forChandler Carruth1-0/+22
checking whether the ArrayRef is equal to an explicit list of arguments. This is particularly easy to implement even without variadic templates because ArrayRef happens to be homogeneously typed. As a consequence we can use a "clever" wrapper type and default arguments to capture in a single method many arguments as well as *how many* arguments the user specified. Thanks to Dave Blaikie for helping me pull together this little helper. Suggestions for how to improve or generalize it are of course welcome. I'll be using it immediately in my follow-up patch. =D llvm-svn: 214041
2014-07-15ADT: Add MapVector::remove_ifDuncan P. N. Exon Smith1-0/+21
Add a `MapVector::remove_if()` that erases items in bulk in linear time, as opposed to quadratic time for repeated calls to `MapVector::erase()`. llvm-svn: 213090
2014-07-15ADT: Fix MapVector::erase()Duncan P. N. Exon Smith1-0/+15
Actually update the changed indexes in the map portion of `MapVector` when erasing from the middle. Add a unit test that checks for this. Note that `MapVector::erase()` is a linear time operation (it was and still is). I'll commit a new method in a moment called `MapVector::remove_if()` that deletes multiple entries in linear time, which should be slightly less painful. llvm-svn: 213084
2014-07-11Move the API and implementation of clang::driver::getARMCPUForMArch() to ↵Argyrios Kyrtzidis1-0/+12
llvm::Triple::getARMCPUForArch(). Suggested by Eric Christopher. llvm-svn: 212846
2014-07-05ADT: Add a drop_back() helper to ArrayRefDavid Majnemer1-0/+7
The slice(N, M) interface is powerful but not concise when wanting to drop a few elements off of an ArrayRef, fix this by adding a drop_back method. llvm-svn: 212370
2014-06-23Recommit 211309 (StringMap::insert), reverted in 211328 due to issues with ↵David Blaikie1-2/+40
private, but non-deleted, move members. Certain versions of GCC (~4.7) couldn't handle the SFINAE on access control, but with "= delete" (hidden behind a macro for portability) this issue is worked around/addressed. Patch by Agustín Bergé llvm-svn: 211525
2014-06-20Fix some -Wsign-compare fallout from changing container count member ↵David Blaikie2-2/+2
functions to return unsigned instead of bool. llvm-svn: 211393
2014-06-20Revert "Add StringMap::insert(pair) consistent with the standard associative ↵Rafael Espindola1-38/+0
container concept." This reverts commit r211309. It looks like it broke some bots: http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/15563/steps/compile/logs/stdio llvm-svn: 211328
2014-06-19Add StringMap::insert(pair) consistent with the standard associative ↵David Blaikie1-0/+38
container concept. Patch by Agustín Bergé. llvm-svn: 211309
2014-06-19Remove OwningPtr.h and associated testsAlp Toker2-274/+0
llvm::OwningPtr is superseded by std::unique_ptr. llvm-svn: 211259
2014-06-11SmallVectorTest: Make the deleted member functions private to help MSVC users.David Blaikie1-0/+1
llvm-svn: 210665
2014-06-11Convert StringMapEntry::Create to use StringRef instead of start/end ↵Craig Topper1-3/+3
pointers. Simpliies all in tree call sites. No functional change. llvm-svn: 210638
2014-06-10SmallVectorTest.cpp: Use LLVM_DELETED_FUNCTION.NAKAMURA Takumi1-2/+2
llvm-svn: 210507