summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "ADT: Move ArrayRef comparison operators into the class"Pavel Labath2018-06-281-4/+0
| | | | | | This reverts commit r335839, because it breaks the MSVC build. llvm-svn: 335844
* ADT: Move ArrayRef comparison operators into the classPavel Labath2018-06-281-0/+4
| | | | | | | | | | | | | | Summary: This allows the implicit ArrayRef conversions to kick in when e.g. comparing ArrayRef to a SmallVector. Reviewers: zturner, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D48632 llvm-svn: 335839
* [ADT] drop_begin: use adl_begin/adl_end. NFC.Michael Kruse2018-06-271-0/+13
| | | | | | | | | | | | | | | | | | | Summary: The instantiation of the drop_begin function template usually fails because the functions begin() and end() do not exist. Only when using on a container from the std namespace (or `llvm::iterator_range`s of something derived from `std::iterator`), they are matched to std::begin() and std::end() due to Koenig-lookup. Explicitly use llvm::adl_begin and llvm::adl_end to make drop_begin applicable to anything iterable (including C-style arrays). A solution for general `llvm::iterator_range`s was already tried in r244620, but got reverted in r244621 due to MSVC not liking it. Reviewers: dblaikie, grosbach, aaron.ballman, ruiu Reviewed By: dblaikie, aaron.ballman Subscribers: aaron.ballman, llvm-commits Differential Revision: https://reviews.llvm.org/D48598 llvm-svn: 335772
* [ADT] Pass DerivedT from pointe{e,r}_iterator to iterator_adaptor_baseJustin Bogner2018-06-271-0/+14
| | | | | | | These were passing the wrong type into iterator_adaptor_base if T was anything but the default. llvm-svn: 335698
* [APInt] Add helpers for rounding u/sdivs.Tim Shen2018-06-251-0/+67
| | | | | | | | | | Reviewers: sanjoy, craig.topper Subscribers: jlebar, hiraditya, bixia, llvm-commits Differential Revision: https://reviews.llvm.org/D48498 llvm-svn: 335557
* Revert r334887, as GCC 4.8 does not have is_trivially_copy_constructible & coFlorian Hahn2018-06-161-55/+0
| | | | llvm-svn: 334889
* [SmallSet] Add SmallSetIterator.Florian Hahn2018-06-161-0/+55
| | | | | | | | | | | | | | | This patch adds a simple const_iterator implementation for SmallSet by delegating to either a SmallVector::const_iterator or std::set::const_iterator, depending on which storage is used by the SmallSet. Reviewers: dblaikie, craig.topper Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D47942 llvm-svn: 334887
* [SmallSet] Add some simple unit tests.Florian Hahn2018-06-082-0/+71
| | | | | | | | | | Reviewers: craig.topper, dblaikie Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D47940 llvm-svn: 334321
* [ADT] Add `StringRef::rsplit(StringRef Separator)`.Henry Wong2018-06-081-0/+11
| | | | | | | | | | | | | | Summary: Add `StringRef::rsplit(StringRef Separator)` to achieve the function of getting the tail substring according to the separator. A typical usage is to get `data` in `std::basic_string::data`. Reviewers: mehdi_amini, zturner, beanz, xbolva00, vsk Reviewed By: zturner, xbolva00, vsk Subscribers: vsk, xbolva00, llvm-commits, MTC Differential Revision: https://reviews.llvm.org/D47406 llvm-svn: 334283
* [ADT] Make escaping fn conform to coding guidelinesJonas Devlieghere2018-05-311-2/+2
| | | | | | | | As noted by Adrian on llvm-commits, PrintHTMLEscaped and PrintEscaped in StringExtras did not conform to the LLVM coding guidelines. This commit rectifies that. llvm-svn: 333669
* [ADT] Add unit test for PrintHTMLEscapedJonas Devlieghere2018-05-301-0/+7
| | | | | | Add unit tests for PrintHTMLEscaped which was added in r333565. llvm-svn: 333590
* [STLExtras] Add size() for ranges, and remove distance()Vedant Kumar2018-05-161-2/+2
| | | | | | | | | | r332057 introduced distance() for ranges. Based on post-commit feedback, this renames distance() to size(). The new size() is also only enabled when the operation is O(1). Differential Revision: https://reviews.llvm.org/D46976 llvm-svn: 332551
* Inline a few CMake variables into their only uses.Nico Weber2018-05-141-5/+1
| | | | | | No behavior change. Makes unittests CMakeLists.txt files more self-consistent. llvm-svn: 332280
* [STLExtras] Add distance() for ranges, pred_size(), and succ_size()Vedant Kumar2018-05-101-0/+8
| | | | | | | | | | | This commit adds a wrapper for std::distance() which works with ranges. As it would be a common case to write `distance(predecessors(BB))`, this also introduces `pred_size()` and `succ_size()` helpers to make that easier to write. Differential Revision: https://reviews.llvm.org/D46668 llvm-svn: 332057
* APFloat/x87: Fix string conversion for "unnormal" values (pr35860)Pavel Labath2018-05-091-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Unnormal values are a feature of some very old x87 processors. We handle them correctly for the most part -- the only exception was an unnormal value whose significand happened to be zero. In this case the APFloat was still initialized as normal number (category = fcNormal), but a subsequent toString operation would assert because the math would produce nonsensical values for the zero significand. During review, it was decided that the correct way to fix this is to treat all unnormal values as NaNs (as that is what any >=386 processor will do). The issue was discovered because LLDB would crash when trying to print some "long double" values. Reviewers: skatkov, scanon, gottesmm Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41868 llvm-svn: 331884
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-011-1/+1
| | | | | | | | | | | | | | | | We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46290 llvm-svn: 331272
* [ADT] Make filter_iterator support bidirectional iterationVedant Kumar2018-04-251-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it possible to reverse a filtered range. For example, here's a way to visit memory accesses in a BasicBlock in reverse order: auto MemInsts = reverse(make_filter_range(BB, [](Instruction &I) { return isa<StoreInst>(&I) || isa<LoadInst>(&I); })); for (auto &MI : MemInsts) ... To implement this functionality, I factored out forward iteration functionality into filter_iterator_base, and added a specialization of filter_iterator_impl which supports bidirectional iteration. Thanks to Tim Shen, Zachary Turner, and others for suggesting this design and providing feedback! This version of the patch supersedes the original (https://reviews.llvm.org/D45792). This was motivated by a problem we encountered in D45657: we'd like to visit the non-debug-info instructions in a BasicBlock in reverse order. Testing: check-llvm, check-clang Differential Revision: https://reviews.llvm.org/D45853 llvm-svn: 330875
* Bring back APInt self-move assignment check for MSVC onlyReid Kleckner2018-04-241-0/+32
| | | | | | | | | | | | | | | | | Summary: It was removed about a year ago in r300477. Bring it back, along with its unittest, when the MSVC STL is in use. The MSVC STL performs self-assignment in std::shuffle. These days, llvm::sort calls std::shuffle when expensive checks are enabled to help find non-determinism bugs. Reviewers: craig.topper, chandlerc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D46028 llvm-svn: 330776
* [ADT] Fix MapVector when 'Map::mapped_type != unsigned'.Eric Fiselier2018-04-081-0/+39
| | | | | | | | | | | Previously MapVector assumed `Map::mapped_type` was `unsigned`. This caused problems when using MapVector with a user-specified map where this didn't hold (For example StringMap<unsigned>). This patch adjusts MapVector to use the same type as the underlying map, avoiding reference binding errors in functions like `insert`. llvm-svn: 329523
* [unittests] ADT: silence -Wself-assign diagnosticsRoman Lebedev2018-04-073-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: D44883 extends -Wself-assign to also work on C++ classes. In it's current state (as suggested by @rjmccall), it is not under it's own sub-group. Since that diag is enabled by `-Wall`, stage2 testing showed that: * It does not fire on any llvm code * It does fire for these 3 unittests * It does fire for libc++ tests This diff simply silences those new warnings in llvm's unittests. A similar diff will be needed for libcxx. (`libcxx/test/std/language.support/support.types/byteops/`, maybe something else) Since i don't think we want to repeat rL322901, let's talk about it. I've subscribed everyone who i think might be interested... There are several ways forward: * Not extend -Wself-assign, close D44883. Not very productive outcome i'd say. * Keep D44883 in it's current state. Unless your custom overloaded operators do something unusual for when self-assigning, the warning is no less of a false-positive than the current -Wself-assign. Except for tests of course, there you'd want to silence it. The current suggestion is: ``` S a; a = (S &)a; ``` * Split the diagnostic in two - `-Wself-assign-builtin` (i.e. what is `-Wself-assign` in trunk), and `-Wself-assign-overloaded` - the new part in D44883. Since, as i said, i'm not really sure why it would be less of a error than the current `-Wself-assign`, both would still be in `-Wall`. That way one could simply pass `-Wno-self-assign-overloaded` for all the tests. Pretty simple to do, and will surely work. * Split the diagnostic in two - `-Wself-assign-trivial`, and `-Wself-assign-nontrivial`. The choice of which diag to emit would depend on trivial-ness of that particular operator. The current `-Wself-assign` would be `-Wself-assign-trivial`. https://godbolt.org/g/gwDASe - `A`, `B` and `C` case would be treated as trivial, and `D`, `E` and `F` as non-trivial. Will be the most complicated to implement. Thoughts? Reviewers: aaron.ballman, rsmith, rtrieu, rjmccall, dblaikie, atrick, gottesmm Reviewed By: dblaikie Subscribers: lebedev.ri, phosek, vsk, rnk, thakis, sammccall, mclow.lists, llvm-commits, rjmccall Differential Revision: https://reviews.llvm.org/D45082 llvm-svn: 329491
* [unittests] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-04-073-5/+5
| | | | | | | | | | | | | | | r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort. Refer the comments section in D44363 for a list of all the required patches. llvm-svn: 329475
* [AMDGPU] Remove use of OpenCL triple environment and replace with function ↵Tony Tye2018-03-231-6/+0
| | | | | | | | | | | attribute for AMDGPU - Remove use of the opencl and amdopencl environment member of the target triple for the AMDGPU target. - Use function attribute to communicate to the AMDGPU backend to add implicit arguments for OpenCL kernels for the AMDHSA OS. Differential Revision: https://reviews.llvm.org/D43736 llvm-svn: 328349
* Fix unused function warning in StatisticTest.cppDaniel Sanders2018-03-081-0/+2
| | | | llvm-svn: 327015
* Support resetting STATISTIC() values using llvm::ResetStatistics()Daniel Sanders2018-03-081-31/+83
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Most of the time, compiler statistics can be obtained using a process that performs a single compilation and terminates such as llc. However, this isn't always the case. JITs for example, perform multiple compilations over their lifetime and STATISTIC() will record cumulative values across all of them. Provide tools like this with the facilities needed to measure individual compilations by allowing them to reset the STATISTIC() values back to zero using llvm::ResetStatistics(). It's still the tools responsibility to ensure that they perform compilations in such a way that the results are meaningful to their intended use. Reviewers: qcolombet, rtereshin, bogner, aditya_nandakumar Reviewed By: bogner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D44181 llvm-svn: 326981
* [AMDGPU] Remove unused AMDOpenCL triple environmentTony Tye2018-03-051-3/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D43895 llvm-svn: 326745
* Re-commit: Make STATISTIC() values available programmaticallyDaniel Sanders2018-03-052-0/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: It can be useful for tools to be able to retrieve the values of variables declared via STATISTIC() directly without having to emit them and parse them back. Use cases include: * Needing to report specific statistics to a test harness * Wanting to post-process statistics. For example, to produce a percentage of functions that were fully selected by GlobalISel Make this possible by adding llvm::GetStatistics() which returns an iterator_range that can be used to inspect the statistics that have been touched during execution. When statistics are disabled (NDEBUG and not LLVM_ENABLE_STATISTICS) this method will return an empty range. This patch doesn't address the effect of multiple compilations within the same process. In such situations, the statistics will be cumulative for all compilations up to the GetStatistics() call. Reviewers: qcolombet, rtereshin, aditya_nandakumar, bogner Reviewed By: rtereshin, bogner Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D43901 This re-commit fixes a missing include of <vector> which it seems clang didn't mind but G++ and MSVC objected to. It seems that, clang was ok with std::vector only being forward declared at the point of use since it was fully defined eventually but G++/MSVC both rejected it at the point of use. llvm-svn: 326738
* Revert r326723: Make STATISTIC() values available programmaticallyDaniel Sanders2018-03-052-107/+0
| | | | | | Despite building cleanly on my machine in three separate configs, it's failing on pretty much all bots due to missing includes among other things. Investigating. llvm-svn: 326726
* Make STATISTIC() values available programmaticallyDaniel Sanders2018-03-052-0/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: It can be useful for tools to be able to retrieve the values of variables declared via STATISTIC() directly without having to emit them and parse them back. Use cases include: * Needing to report specific statistics to a test harness * Wanting to post-process statistics. For example, to produce a percentage of functions that were fully selected by GlobalISel Make this possible by adding llvm::GetStatistics() which returns an iterator_range that can be used to inspect the statistics that have been touched during execution. When statistics are disabled (NDEBUG and not LLVM_ENABLE_STATISTICS) this method will return an empty range. This patch doesn't address the effect of multiple compilations within the same process. In such situations, the statistics will be cumulative for all compilations up to the GetStatistics() call. Reviewers: qcolombet, rtereshin, aditya_nandakumar, bogner Reviewed By: rtereshin, bogner Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D43901 llvm-svn: 326723
* [ADT] Recognize ppc as valid architecture in target triple.Jonas Devlieghere2018-02-271-0/+17
| | | | | | | | | | | | | | | | Until this patch, only `powerpc` and `ppc32` were recognized as valid PowerPC 32-bit architectures in a target triple. This was incompatible with the triple `ppc-apple-darwin` as returned for libObject. I found out about this when working on a test case using a binary generated on an old PowerBook G4. We had the choice of either fix this in the Mach-O object parser or in the Triple implementation. I chose the latter because it feels like the most canonical place. Differential revision: https://reviews.llvm.org/D43760 llvm-svn: 326182
* [ADT] Simplify and optimize StringSwitchDavid Zarzycki2018-02-261-2/+4
| | | | | | | | This change improves incremental rebuild performance on dual Xeon 8168 machines by 54%. This change also improves run time code gen by not forcing the case values to be lvalues. llvm-svn: 326109
* [APInt] Fix extractBits to correctly handle Result.isSingleWord() case.Tim Shen2018-02-161-0/+7
| | | | | | | | | | | | Summary: extractBits assumes that `!this->isSingleWord() implies !Result.isSingleWord()`, which may not necessarily be true. Handle both cases. Reviewers: RKSimon Subscribers: sanjoy, llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D43363 llvm-svn: 325311
* [WebAssembly] Restore "*-wasm" tests.Dan Gohman2018-02-151-0/+5
| | | | | | | Even though "...-wasm" is now the default for wasm, it's still desirable to test this form. llvm-svn: 325273
* [WebAssembly] Update ADT/TripleTest.cpp now that default file format has changedSam Clegg2018-02-121-2/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D43212 llvm-svn: 324966
* Fix incorrect usage of std::is_assignable.Richard Smith2018-02-022-10/+10
| | | | | | We want to check that we can assign to an lvalue here, not a prvalue. llvm-svn: 324152
* [ADT] Make moving Optional not reset the Optional it moves from.Benjamin Kramer2018-01-251-6/+6
| | | | | | | | | This brings it in line with std::optional. My recent changes to make Optional of trivial types trivially copyable introduced diverging behavior depending on the type, which is bad. Now all types have the same moving behavior. llvm-svn: 323445
* Give scope_exit helper correct move semanticsSam McCall2018-01-251-0/+17
| | | | llvm-svn: 323442
* Fix typos of occurred and occurrenceMalcolm Parsons2018-01-242-6/+6
| | | | llvm-svn: 323318
* [ADT] Just give up on GCC, I can't fix this.Benjamin Kramer2018-01-181-2/+1
| | | | | | | | | | While the memmove workaround fixed it for GCC 6.3. GCC 4.8 and GCC 7.1 are still broken. I have no clue what's going on, just blacklist GCC for now. Needless to say this code is ubsan, asan and msan-clean. llvm-svn: 322862
* [ADT] Split optional to only include copy mechanics and dtor for non-trivial ↵Benjamin Kramer2018-01-181-0/+9
| | | | | | | | | | | | | types. This makes uses of Optional more transparent to the compiler (and clang-tidy) and generates slightly smaller code. This is a re-land of r317019, which had issues with GCC 4.8 back then. Those issues don't reproduce anymore, but I'll watch the buildbots closely in case anything goes wrong. llvm-svn: 322838
* Revert "Add a value_type to ArrayRef."Clement Courbet2018-01-181-8/+0
| | | | | | | | clang OOMs on arm. This reverts commit a272b2f2ef63f7f602c9ef4d9e10dc4eb9f00aa1. llvm-svn: 322818
* Add a value_type to ArrayRef.Clement Courbet2018-01-161-0/+8
| | | | | | | | | | Summary: Not sure this needs a review or not. Erring on the safe side. Reviewers: dblaikie Differential Revision: https://reviews.llvm.org/D41666 llvm-svn: 322538
* Use size_t to represent the size of a StringMapEntry length and alignment ↵Aaron Ballman2018-01-111-0/+40
| | | | | | | | rather than unsigned. Patch by Matt Davis. llvm-svn: 322305
* Fix APFloat from string conversion for InfSerguei Katkov2017-12-192-1/+23
| | | | | | | | | | | | | | | | | | The method IEEEFloat::convertFromStringSpecials() does not recognize the "+Inf" and "-Inf" strings but these strings are printed for the double Infinities by the IEEEFloat::toString(). This patch adds the "+Inf" and "-Inf" strings to the list of recognized patterns in IEEEFloat::convertFromStringSpecials(). Re-landing after fix. Reviewers: sberg, bogner, majnemer, timshen, rnk, skatkov, gottesmm, bkramer, scanon, anna Reviewed By: anna Subscribers: mkazantsev, FlameTop, llvm-commits, reames, apilipenko Differential Revision: https://reviews.llvm.org/D38030 llvm-svn: 321054
* Ensure moved-from container is cleared on moveGeorge Burgess IV2017-12-111-0/+6
| | | | | | | | | In all cases except for this optimistic attempt to reuse memory, the moved-from TinyPtrVector was left `empty()` at the end of this assignment. Though using a container after it's been moved from can be a bit sketchy, it's probably best to just be consistent here. llvm-svn: 320408
* [Support] Add unit test for printLowerCaseFrancis Visoiu Mistrih2017-11-281-0/+8
| | | | | | Add test case for the function added in r319171. llvm-svn: 319177
* [NFC] Add missing unit tests for EquivalenceClassesMax Kazantsev2017-11-272-0/+86
| | | | llvm-svn: 319018
* Add ADL support to range based <algorithm> extensionsDavid Blaikie2017-11-201-14/+52
| | | | | | | | | | | | | | | | | This adds support for ADL in the range based <algorithm> extensions (llvm::for_each etc.). Also adds the helper functions llvm::adl::begin and llvm::adl::end which wrap std::begin and std::end with ADL support. Saw this was missing from a recent llvm weekly post about adding llvm::for_each and thought I might add it. Patch by Stephen Dollberg! Differential Revision: https://reviews.llvm.org/D40006 llvm-svn: 318703
* [ADT] Rewrite mapped_iterator in terms of iterator_adaptor_base.Lang Hames2017-11-102-0/+52
| | | | | | | | | | | | | | | | | | Summary: This eliminates the boilerplate implementation of the iterator interface in mapped_iterator. This patch also adds unit tests that verify that the mapped function is applied by operator* and operator->, and that references returned by the map function are returned via operator*. Reviewers: dblaikie, chandlerc Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D39855 llvm-svn: 317902
* Add llvm::for_each as a range-based extensions to <algorithm> and make use ↵Aaron Ballman2017-11-031-6/+14
| | | | | | of it in some cases where it is a more clear alternative to std::for_each. llvm-svn: 317356
* Fix APFloat mod signSerguei Katkov2017-11-011-0/+14
| | | | | | | | | | | | fmod specification requires the sign of the remainder is the same as numerator in case remainder is zero. Reviewers: gottesmm, scanon, arsenm, davide, craig.topper Reviewed By: scanon Subscribers: wdng, llvm-commits Differential Revision: https://reviews.llvm.org/D39225 llvm-svn: 317081
OpenPOWER on IntegriCloud