summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
Commit message (Collapse)AuthorAgeFilesLines
...
* [ADT] IntervalMap: add overlaps(a, b) methodPavel Labath2018-12-211-0/+44
| | | | | | | | | | | | | | | Summary: This function checks whether the mappings in the interval map overlap with the given range [a;b]. The motivation is to enable checking for overlap before inserting a new interval into the map. Reviewers: vsk, dblaikie Subscribers: dexonsmith, kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D55760 llvm-svn: 349898
* [ADT] Fix bugs in SmallBitVector.Zachary Turner2018-12-141-7/+261
| | | | | | | | | | | Fixes: * find_last/find_last_unset - off-by-one error * Compound assignment ops and operator== when mixing big/small modes Patch by Brad Moody Differential Revision: https://reviews.llvm.org/D54933 llvm-svn: 349173
* APFloat: allow 64-bit of payloadJF Bastien2018-12-101-22/+38
| | | | | | | | | | | | | | | | | | | | Summary: The APFloat and Constant APIs taking an APInt allow arbitrary payloads, and that's great. There's a convenience API which takes an unsigned, and that's silly because it then directly creates a 64-bit APInt. Just change it to 64-bits directly. At the same time, add ConstantFP NaN getters which match the APFloat ones (with getQNaN / getSNaN and APInt parameters). Improve the APFloat testing to set more payload bits. Reviewers: scanon, rjmccall Subscribers: jkorous, dexonsmith, kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D55460 llvm-svn: 348791
* [ADT] Add zip_longest iterators.Michael Kruse2018-12-051-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like the already existing zip_shortest/zip_first iterators, zip_longest iterates over multiple iterators at once, but has as many iterations as the longest sequence. This means some iterators may reach the end before others do. zip_longest uses llvm::Optional's None value to mark a past-the-end value. zip_longest is not reverse-iteratable because the tuples iterated over would be different for different length sequences (IMHO for the same reason neither zip_shortest nor zip_first should be reverse-iteratable; one can still reverse the ranges individually if that's the expected behavior). In contrast to zip_shortest/zip_first, zip_longest tuples contain rvalues instead of references. This is because llvm::Optional cannot contain reference types and the value-initialized default does not have a memory location a reference could point to. The motivation for these iterators is to use C++ foreach to compare two lists of ordered attributes in D48100 (SemaOverload.cpp and ASTReaderDecl.cpp). Idea by @hfinkel. This re-commits r348301 which was reverted by r348303. The compilation error by gcc 5.4 was resolved using make_tuple in the in the initializer_list. The compileration error by msvc14 was resolved by splitting ZipLongestValueType (which already was a workaround for msvc15) into ZipLongestItemType and ZipLongestTupleType. Differential Revision: https://reviews.llvm.org/D48348 llvm-svn: 348323
* Revert "[ADT] Add zip_longest iterators"Michael Kruse2018-12-041-30/+0
| | | | | | | | This reverts commit r348301. Compilation fails on buildbots with older versions of gcc and msvc. llvm-svn: 348303
* [ADT] Add zip_longest iteratorsMichael Kruse2018-12-041-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like the already existing zip_shortest/zip_first iterators, zip_longest iterates over multiple iterators at once, but has as many iterations as the longest sequence. This means some iterators may reach the end before others do. zip_longest uses llvm::Optional's None value to mark a past-the-end value. zip_longest is not reverse-iteratable because the tuples iterated over would be different for different length sequences (IMHO for the same reason neither zip_shortest nor zip_first should be reverse-iteratable; one can still reverse the ranges individually if that's the expected behavior). In contrast to zip_shortest/zip_first, zip_longest tuples contain rvalues instead of references. This is because llvm::Optional cannot contain reference types and the value-initialized default does not have a memory location a reference could point to. The motivation for these iterators is to use C++ foreach to compare two lists of ordered attributes in D48100 (SemaOverload.cpp and ASTReaderDecl.cpp). Idea by @hfinkel. Differential Revision: https://reviews.llvm.org/D48348 llvm-svn: 348301
* Add Hurd target to LLVMSupport (1/2)Kristina Brooks2018-11-291-0/+6
| | | | | | | | | | | Add the required target triples to LLVMSupport to support Hurd in LLVM (formally `pc-hurd-gnu`). Patch by sthibaul (Samuel Thibault) Differential Revision: https://reviews.llvm.org/D54378 llvm-svn: 347832
* [APInt] Add methods for saturated add and subSanjay Patel2018-11-201-0/+24
| | | | | | | | | | | | This adds the sadd_sat, uadd_sat, ssub_sat, usub_sat methods for performing saturating additions and subtractions to APInt. Split out from D54237. Patch by: nikic (Nikita Popov) Differential Revision: https://reviews.llvm.org/D54332 llvm-svn: 347324
* Re-apply r346985: [ADT] Drop llvm::Optional clang-specific optimization for ↵Tom Stellard2018-11-161-8/+0
| | | | | | | | | trivially copyable types Remove a test case that was added with the optimization we are now removing. llvm-svn: 347004
* Correctly instantiate `iterator_adaptor_base` when defining `pointer_iterator`David Blaikie2018-11-141-0/+29
| | | | | | | | | | | | | | | | The definition of `pointer_iterator` omits what should be a `iterator_traits::<>::iterator_category` parameter from `iterator_adaptor_base`. As a result, iterators based on `pointer_iterator` always have defaulted value types and the wrong iterator category. The definition of `pointee_iterator` just a few lines above does this correctly. This resolves [[ https://bugs.llvm.org/show_bug.cgi?id=39617 | bug 39617 ]]. Patch by Dylan MacKenzie! Reviewers: dblaikie Differential Revision: https://reviews.llvm.org/D54377 llvm-svn: 346833
* [ADT] Clean up SparseBitVector copying and make it moveableBenjamin Kramer2018-11-011-0/+16
| | | | llvm-svn: 345829
* [adt] SparseBitVector::test() should be constDaniel Sanders2018-10-311-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Re-worked SparseBitVector's most-recently-used-word caching (CurrElementIter) such that SparseBitVector::test() can be made const. This came up when attempting to test individual bits in a SparseBitVector which was a member of a const object. The cached iterator has no bearing on the externally visible state, it's merely a performance optimization. Therefore it has been made mutable and FindLowerBound() has been split into a const and non-const function (FindLowerBound/FindLowerBoundConst) for the const/non-const interfaces. Reviewers: rtereshin Reviewed By: rtereshin Subscribers: rtereshin, dexonsmith, kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D53447 llvm-svn: 345772
* [ADT] Remove illegal comparison of singular iterators from SmallSetTestFlorian Hahn2018-10-311-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes the assertion that a copy of a moved-from SmallSetIterator equals the original, which is illegal due to SmallSetIterator including an instance of a standard `std::set` iterator. C++ [iterator.requirements.general] states that comparing singular iterators has undefined result: > Iterators can also have singular values that are not associated with > any sequence. [...] Results of most expressions are undefined for > singular values; the only exceptions are destroying an iterator that > holds a singular value, the assignment of a non-singular value to an > iterator that holds a singular value, and, for iterators that satisfy > the Cpp17DefaultConstructible requirements, using a value-initialized > iterator as the source of a copy or move operation. This assertion triggers the following error in the GNU C++ Library in debug mode under EXPENSIVE_CHECKS: /usr/include/c++/8.2.1/debug/safe_iterator.h:518: Error: attempt to compare a singular iterator to a singular iterator. Objects involved in the operation: iterator "lhs" @ 0x0x7fff86420670 { state = singular; } iterator "rhs" @ 0x0x7fff86420640 { state = singular; } Patch by Eugene Sharygin. Reviewers: fhahn, dblaikie, chandlerc Reviewed By: fhahn, dblaikie Differential Revision: https://reviews.llvm.org/D53793 llvm-svn: 345712
* 2nd attempt to fix ambiguities because of ADLMatthias Braun2018-10-311-9/+6
| | | | llvm-svn: 345690
* Try to fix ambiguities with C++17 headers in unittestMatthias Braun2018-10-311-0/+3
| | | | llvm-svn: 345689
* ADT/STLExtras: Introduce llvm::empty; NFCMatthias Braun2018-10-311-0/+17
| | | | | | | | This is modeled after C++17 std::empty(). Differential Revision: https://reviews.llvm.org/D53909 llvm-svn: 345679
* [ADT] Fix a bug in DenseSet's initializer_list constructor.Lang Hames2018-10-151-0/+8
| | | | | | | Without this fix, DenseSet crashes with an assertion if constructed with an initializer_list whose length is not a power of two. llvm-svn: 344542
* [ADT] Adds equality operators for DenseMap and DenseSet, and an initializer_listLang Hames2018-10-152-0/+29
| | | | | | | | | | constructor for DenseMap (DenseSet already had an initializer_list constructor). These changes make it easier to migrate existing code that uses std::map and std::set (which support initializer_list construction and equality comparison) to DenseMap and DenseSet. llvm-svn: 344522
* [Intrinsic] Add llvm.minimum and llvm.maximum instrinsic functionsThomas Lively2018-10-131-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | Summary: These new intrinsics have the semantics of the `minimum` and `maximum` operations specified by the latest draft of IEEE 754-2018. Unlike llvm.minnum and llvm.maxnum, these new intrinsics propagate NaNs and always treat -0.0 as less than 0.0. `minimum` and `maximum` lower directly to the existing `fminnan` and `fmaxnan` ISel DAG nodes. It is safe to reuse these DAG nodes because before this patch were only emitted in situations where there were known to be no NaN arguments or where NaN propagation was correct and there were known to be no zero arguments. I know of only four backends that lower fminnan and fmaxnan: WebAssembly, ARM, AArch64, and SystemZ, and each of these lowers fminnan and fmaxnan to instructions that are compatible with the IEEE 754-2018 semantics. Reviewers: aheejin, dschuff, sunfish, javed.absar Subscribers: kristof.beyls, dexonsmith, kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D52764 llvm-svn: 344437
* [mips] Add support MIPS r6 Debian triplesSimon Atanasyan2018-09-271-0/+104
| | | | | | | | | | | | | | | | | | | Debian uses different triples for MIPS r6 and paths. Here we use SubArch to determine whether it is r6, if we found `r6' in CPU section of triple. These new triples include: mipsisa32r6-linux-gnu mipsisa32r6el-linux-gnu mipsisa64r6-linux-gnuabi64 mipsisa64r6el-linux-gnuabi64 mipsisa64r6-linux-gnuabin32 mipsisa64r6el-linux-gnuabin32 Patch by YunQiang Su. Differential revision: https://reviews.llvm.org/D50857 llvm-svn: 343185
* llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)Fangrui Song2018-09-271-2/+2
| | | | | | | | | | | | Summary: The convenience wrapper in STLExtras is available since rL342102. Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits Differential Revision: https://reviews.llvm.org/D52573 llvm-svn: 343163
* Fix DenseSet::ConstIterator typedefsDavid Blaikie2018-09-201-0/+7
| | | | | | | | | | Fix DenseSet::ConstIterator pointer/reference typedefs to be const Patch by Brad Moody! Differential Revision: https://reviews.llvm.org/D52260 llvm-svn: 342697
* Fix -Wsign-compare warnings. NFCISimon Pilgrim2018-09-191-10/+10
| | | | llvm-svn: 342551
* [ADT][BitVector] Add push_back()Simon Pilgrim2018-09-191-0/+31
| | | | | | | | Add a higher performance alternative to calling resize() every time which performs a lot of clearing to zero - when we're adding a single bit most of the time this will be completely unnecessary. Differential Revision: https://reviews.llvm.org/D52236 llvm-svn: 342535
* [mips] Fix MIPS N32 ABI triples supportSimon Atanasyan2018-09-171-0/+53
| | | | | | | | | | | | Add support mips64(el)-linux-gnuabin32 triples, and set them to N32. Debian architecture name mipsn32/mipsn32el are also added. Set UseIntegratedAssembler for N32 if we can detect it. Patch by YunQiang Su. Differential revision: https://reviews.llvm.org/D51408 llvm-svn: 342416
* [ADT] Made numerous methods of ImmutableList constKristof Umann2018-09-121-0/+30
| | | | | | | | Also added ImmutableList<T>::iterator::operator->. Differential Revision: https://reviews.llvm.org/D51881 llvm-svn: 342045
* [ADT] Support converting to lowercase string in toHexPetr Hosek2018-09-101-0/+2
| | | | | | | | This is useful in certain use-cases such as D51833. Differential Revision: https://reviews.llvm.org/D51835 llvm-svn: 341852
* Add header guards to some headers that are missing themArgyrios Kyrtzidis2018-09-031-3/+3
| | | | | | | Also adjust some of dsymutil's headers to put the header guards at the top, otherwise the compiler will not recognize them as header guards. llvm-svn: 341323
* Tests: fix tests encoding specific hash values for 32-bit systems.Tim Northover2018-08-311-54/+1
| | | | | | | I changed the seed slightly, but forgot to run the tests on a 32-bit system, so tests which hard-code a specific hash value started breaking. llvm-svn: 341240
* [ADT] ImmutableList no longer requires elements to be copy constructibleKristof Umann2018-08-281-0/+43
| | | | | | | | | | | ImmutableList used to require elements to have a copy constructor for no good reason, this patch aims to fix this. It also required but did not enforce its elements to be trivially destructible, so a new static_assert is added to guard against misuse. Differential Revision: https://reviews.llvm.org/D49985 llvm-svn: 340824
* This patch adds support to LLVM for writing HermitCore ↵Eric Christopher2018-08-251-0/+6
| | | | | | | | | | | (https://hermitcore.org) ELF binaries. HermitCore is a POSIX-compatible kernel for running a single application in an isolated environment to get maximum performance and predictable runtime behavior. It can either be used bare-metal on hardware or a VM (Unikernel) or side by side to an existing Linux system (Multikernel). Due to the latter feature, HermitCore binaries are marked with ELFOSABI_STANDALONE to let the Linux ELF loader distinguish them from regular Unix/Linux binaries and load them using the HermitCore "proxy" tool. Patch by Colin Finck! llvm-svn: 340675
* [MISC]Fix wrong usage of std::equal()Chen Zheng2018-08-171-0/+15
| | | | | | Differential Revision: https://reviews.llvm.org/D49958 llvm-svn: 340000
* [ADT] Implemented unittests for ImmutableListKristof Umann2018-08-132-0/+199
| | | | | | | | Also fixed a typo that wasn't discovered as `create` was never instantiated. Differential Revision: https://reviews.llvm.org/D50646 llvm-svn: 339586
* [ADT] Normalize empty triple componentsPetr Hosek2018-08-081-46/+79
| | | | | | | | | | | | | | | | | LLVM triple normalization is handling "unknown" and empty components differently; for example given "x86_64-unknown-linux-gnu" and "x86_64-linux-gnu" which should be equivalent, triple normalization returns "x86_64-unknown-linux-gnu" and "x86_64--linux-gnu". autoconf's config.sub returns "x86_64-unknown-linux-gnu" for both "x86_64-linux-gnu" and "x86_64-unknown-linux-gnu". This changes the triple normalization to behave the same way, replacing empty triple components with "unknown". This addresses PR37129. Differential Revision: https://reviews.llvm.org/D50219 llvm-svn: 339294
* [ADT] Add an early-increment iterator-like type and range adaptor.Chandler Carruth2018-08-041-0/+51
| | | | | | | | | | | | | | This allows us to model the common LLVM idiom of incrementing immediately after dereferencing so that we can remove or update the entity w/o losing our ability to reach the "next". However, these are not real or proper iterators. They are just enough to allow range based for loops and very simple range algorithms to work, but should not be considered full general. Differential Revision: https://reviews.llvm.org/D49956 llvm-svn: 338955
* [Unittests] Fix returning string in SolveQuadraticEquationWrapKrzysztof Parzyszek2018-08-021-3/+3
| | | | | | | Returning a Twine caused runtime failures. Convert it to std::string before retuning. llvm-svn: 338768
* [SCEV] Properly solve quadratic equationsKrzysztof Parzyszek2018-08-021-0/+86
| | | | | | Differential Revision: https://reviews.llvm.org/D48283 llvm-svn: 338758
* [ADT] Replace std::isprint by llvm::isPrint.Michael Kruse2018-07-261-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The standard library functions ::isprint/std::isprint have platform- and locale-dependent behavior which makes LLVM's output less predictable. In particular, regression tests my fail depending on the implementation of these functions. Implement llvm::isPrint in StringExtras.h with a standard behavior and replace all uses of ::isprint/std::isprint by a call it llvm::isPrint. The function is inlined and does not look up language settings so it should perform better than the standard library's version. Such a replacement has already been done for isdigit, isalpha, isxdigit in r314883. gtest does the same in gtest-printers.cc using the following justification: // Returns true if c is a printable ASCII character. We test the // value of c directly instead of calling isprint(), which is buggy on // Windows Mobile. inline bool IsPrintableAscii(wchar_t c) { return 0x20 <= c && c <= 0x7E; } Similar issues have also been encountered by Julia: https://github.com/JuliaLang/julia/issues/7416 I noticed the problem myself when on Windows isprint('\t') started to evaluate to true (see https://stackoverflow.com/questions/51435249) and thus caused several unit tests to fail. The result of isprint doesn't seem to be well-defined even for ASCII characters. Therefore I suggest to replace isprint by a platform-independent version. Differential Revision: https://reviews.llvm.org/D49680 llvm-svn: 338034
* Recommit r334887: [SmallSet] Add SmallSetIterator.Florian Hahn2018-07-241-0/+79
| | | | | | | Updated to make sure we properly construct/destroy SetIter if it has a non-trivial ctors/dtors, like in MSVC. llvm-svn: 337818
* [ADT] Only run death tests in !NDEBUGBenjamin Kramer2018-07-201-5/+7
| | | | | | These invoke undefined behavior. llvm-svn: 337625
* Add llvm::Any.Zachary Turner2018-07-202-0/+174
| | | | | | | | This is analogous to std::any which is only available in C++17. Differential Revision: https://reviews.llvm.org/D48807 llvm-svn: 337573
* [OpenEmbedded] Add a unittest for aarch64-oe-linuxMandeep Singh Grang2018-07-191-0/+6
| | | | | | | | | | | | | | Summary: Added a unittest for aarch64-oe-linux which was missed in D48861. Reviewers: compnerd, rengolin, javed.absar Reviewed By: compnerd Subscribers: kristof.beyls, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D49314 llvm-svn: 337479
* [APInt] Keep the original bit width in quotient and remainderKrzysztof Parzyszek2018-07-191-0/+32
| | | | | | | | | | | Some trivial cases in udivrem were handled by directly assigning 0 or 1 to APInt objects. This would set the bit width to 1, instead of the bit width of the inputs. A potentially undesirable side effect of that is that with the bit width of 1, 1 equals -1. Differential Revision: https://reviews.llvm.org/D49554 llvm-svn: 337478
* Revert rL337292 due to another MSVC STL problem.Florian Hahn2018-07-171-55/+0
| | | | llvm-svn: 337303
* Recommit r334887: [SmallSet] Add SmallSetIterator.Florian Hahn2018-07-171-0/+55
| | | | | | | Spell out destructor, copy/move constructor and assignment operators for MSVC STL, where set<T>::const_iterator is not trivially copy constructible. llvm-svn: 337292
* [WebAssembly] Remove ELF file support.Sam Clegg2018-07-161-5/+0
| | | | | | | | | This support was partial and temporary. Now that we have wasm object file support its no longer needed. Differential Revision: https://reviews.llvm.org/D48744 llvm-svn: 337222
* Reverted r336805 as it broke llvm-clang-x86_64-expensive-checks-win build botGalina Kistanova2018-07-121-55/+0
| | | | llvm-svn: 336923
* Recommit r334887: [SmallSet] Add SmallSetIterator.Florian Hahn2018-07-111-0/+55
| | | | | | | This version now uses the subset of is_trivially_XXX provided by GCC 4.8 and llvm/Support/type_traits.h llvm-svn: 336805
* [OpenEmbedded] Add OpenEmbedded vendorMandeep Singh Grang2018-07-051-0/+6
| | | | | | | | | | | | | | | | | | Summary: The lib paths are not correctly picked up for OpenEmbedded sysroots (like arm-oe-linux-gnueabi). I fix this in a follow-up clang patch. But in order to add the correct libs I need to detect if the vendor is oe. For this reason, it is first necessary to teach llvm to detect oe vendor, which is what this patch does. Reviewers: chandlerc, compnerd, rengolin, javed.absar Reviewed By: compnerd Subscribers: kristof.beyls, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D48861 llvm-svn: 336401
* [ADT] Add llvm::unique_function which is like std::function butChandler Carruth2018-07-022-0/+229
| | | | | | | | | | | | | | | | | | | | | | | | | | | | supporting move-only closures. Most of the core optimizations for std::function are here plus a potentially novel one that detects trivially movable and destroyable functors and implements those with fewer indirections. This is especially useful as we start trying to add concurrency primitives as those often end up with move-only types (futures, promises, etc) and wanting them to work through lambdas. As further work, we could add better support for things like const-qualified operator()s to support more algorithms, and r-value ref qualified operator()s to model call-once. None of that is here though. We can also provide our own llvm::function that has some of the optimizations used in this class, but with copy semantics instead of move semantics. This is motivated by increasing usage of things like executors and the task queue where it is useful to embed move-only types like a std::promise within a type erased function. That isn't possible without this version of a type erased function. Differential Revision: https://reviews.llvm.org/D48349 llvm-svn: 336156
OpenPOWER on IntegriCloud