summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
Commit message (Collapse)AuthorAgeFilesLines
...
* [SmallBitVector] Fix bug in find_next_unset for small types with indices >=32Simon Pilgrim2019-07-211-0/+32
| | | | | | | | We were creating a bitmask from a shift of unsigned instead of uintptr_t, meaning we couldn't create masks for indices above 31. Noticed due to a MSVC analyzer warning. llvm-svn: 366657
* [ADT] Remove MSVC-only "no two-phase name lookup" typename path.Simon Pilgrim2019-07-091-9/+0
| | | | | | Now that we've dropped VS2015 support (D64326) we can use the regular codepath as VS2017+ correctly handles it llvm-svn: 365502
* [ADT] Enable ArrayRef/StringRef is_assignable tests on MSVCSimon Pilgrim2019-07-092-11/+0
| | | | | | Now that we've dropped VS2015 support (D64326) we can enable these static_asserts on MSVC builds as VS2017+ correctly handles them llvm-svn: 365471
* Standardize on MSVC behavior for triples with no environmentReid Kleckner2019-07-081-0/+2
| | | | | | | | | | | | | | | | | | | | | Summary: This makes it so that IR files using triples without an environment work out of the box, without normalizing them. Typically, the MSVC behavior is more desirable. For example, it tends to enable things like constant merging, use of associative comdats, etc. Addresses PR42491 Reviewers: compnerd Subscribers: hiraditya, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64109 llvm-svn: 365387
* [Triple] Add isRISCV functionAlex Bradbury2019-07-081-0/+2
| | | | | | | | | | | | This matches isARM, isThumb, isAArch64 and similar helpers. Future commits which clean-up code that currently checks for Triple::riscv32 || Triple::riscv64. Differential Revision: https://reviews.llvm.org/D54215 Patch by Simon Cook. Test case added by Alex Bradbury. llvm-svn: 365327
* [triple] Use 'macabi' environment name for the Mac Catalyst triplesAlex Lorenz2019-07-031-2/+2
| | | | | | The 'macabi' environment name is preferred instead of 'maccatalyst'. llvm-svn: 364988
* [triple] add 'macCatalyst' environment typeAlex Lorenz2019-07-021-0/+11
| | | | | | | | Mac Catalyst is a new deployment platform in macOS Catalina. Differential Revision: https://reviews.llvm.org/D64097 llvm-svn: 364971
* [APIntTest] multiplicativeInverse(): clarify testRoman Lebedev2019-07-021-4/+7
| | | | | | | Clarify that multiplicative inverse exists for all odd numbers, and does not exist for all even numbers (including 0). llvm-svn: 364920
* Cleanup: llvm::bsearch -> llvm::partition_point after r364719Fangrui Song2019-06-301-4/+5
| | | | llvm-svn: 364720
* [ADT] Implement llvm::bsearch() with std::partition_point()Fangrui Song2019-06-301-12/+0
| | | | | | | | | | | | | | | | | | | Summary: Delete the begin-end form because the standard std::partition_point can be easily used as a replacement. The ranges-style llvm::bsearch will be renamed to llvm::partition_point in the next clean-up patch. The name "bsearch" doesn't meet people's expectation because in C: > If two or more members compare equal, which member is returned is unspecified. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D63718 llvm-svn: 364719
* [APInt] Fix getBitsNeeded for INT_MIN valuesDmitry Venikov2019-06-291-2/+15
| | | | | | | | | | | | | | | | Summary: This patch fixes behaviour of APInt::getBitsNeeded for INT_MIN 10 bits values. Reviewers: regehr, RKSimon Reviewed By: RKSimon Subscribers: grandinj, dexonsmith, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63691 llvm-svn: 364710
* Silence gcc warning in testcase [NFC]Mikael Holmen2019-06-281-1/+1
| | | | | | | | | | | Without the fix gcc (7.4.0) complains with ../unittests/ADT/APIntTest.cpp: In member function 'virtual void {anonymous}::APIntTest_MultiplicativeInverseExaustive_Test::TestBody()': ../unittests/ADT/APIntTest.cpp:2510:36: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] for (unsigned Value = 0; Value < (1 << BitWidth); ++Value) { ~~~~~~^~~~~~~~~~~~~~~~~ llvm-svn: 364624
* [NFC][APInt] Add (exhaustive) test for multiplicativeInverse()Roman Lebedev2019-06-271-0/+17
| | | | | | | Else there is no direct test coverage at all. The function should either return '0' or precise answer. llvm-svn: 364599
* [ADT] Enable set_difference() to be used on StringSetMichael Pozulp2019-06-073-15/+45
| | | | | | | | | | | | | | | | Summary: Re-land r362766 after it was reverted in r362823. Reviewers: jhenderson, dsanders, aaron.ballman, MatzeB, lhames, dblaikie Reviewed By: dblaikie Subscribers: smeenai, mgrang, mgorny, dexonsmith, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62369 llvm-svn: 362835
* Revert "[ADT] Enable set_difference() to be used on StringSet"Vlad Tsyrklevich2019-06-073-44/+15
| | | | | | | | This reverts commit 0bddef79019a23ab14fcdb27028e55e484674c88, it was causing ASan failures on the sanitizer bots: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/32800 llvm-svn: 362823
* [ADT] Enable set_difference() to be used on StringSetMichael Pozulp2019-06-073-15/+44
| | | | | | | | | | Subscribers: mgorny, mgrang, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62992 llvm-svn: 362766
* [APInt] Add PR40897 test caseSimon Pilgrim2019-06-011-0/+3
| | | | | | In reality APInt::getBitsNeeded(INT_MIN, base) cases require one less bit than is returned llvm-svn: 362301
* Fix broken test case.Richard Trieu2019-05-171-3/+3
| | | | | | EXPECT_EQ takes two arguments, not a single expression that evaluates to bool. llvm-svn: 360969
* Convert PointerUnion to a variadic template.Richard Smith2019-05-171-0/+37
| | | | | | | | | | | | | | | | | | | | | | Summary: Rather than duplicating code between PointerUnion, PointerUnion3, and PointerUnion4 (and missing things from the latter cases, such as some of the DenseMap support and operator==), convert PointerUnion to a variadic template that can be used as a union of any number of pointers. (This doesn't support PointerUnion<> right now. Adding a special case for that would be possible, and perhaps even useful in some situations, but it doesn't seem worthwhile until we have a concrete use case.) Reviewers: dblaikie Subscribers: dexonsmith, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D62027 llvm-svn: 360962
* arm64_32: add some unittests that were in the wrong commit.Tim Northover2019-05-151-0/+11
| | | | | | | Accidentally dropped them when committing the arm64_32 binutils support. There's no change to real code. llvm-svn: 360763
* [WebAssembly] Test the "wasm32-wasi" tripleDan Gohman2019-04-301-8/+18
| | | | | | | | | | | | Add triple tests for "wasm32-wasi" and "wasm64-wasi", and also remove the "-musl" component from the existing wasm triple tests as we're not using that in practice (WASI libc is derived in part from musl, but it is not fully musl-compatible). Differential Revision: https://reviews.llvm.org/D61334 Reviewer: sbc100 llvm-svn: 359629
* [APSInt][OpenMP] Fix isNegative, etc. for unsigned typesJoel E. Denny2019-04-231-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this patch, APSInt inherits APInt::isNegative, which merely checks the sign bit without regard to whether the type is actually signed. isNonNegative and isStrictlyPositive call isNegative and so are also affected. This patch adjusts APSInt to override isNegative, isNonNegative, and isStrictlyPositive with implementations that consider whether the type is signed. A large set of Clang OpenMP tests are affected. Without this patch, these tests assume that `true` is not a valid argument for clauses like `collapse`. Indeed, `true` fails APInt::isStrictlyPositive but not APSInt::isStrictlyPositive. This patch adjusts those tests to assume `true` should be accepted. This patch also adds tests revealing various other similar fixes due to APSInt::isNegative calls in Clang's ExprConstant.cpp and SemaExpr.cpp: `++` and `--` overflow in `constexpr`, evaluated object size based on `alloc_size`, `<<` and `>>` shift count validation, and OpenMP array section validation. Reviewed By: lebedev.ri, ABataev, hfinkel Differential Revision: https://reviews.llvm.org/D59712 llvm-svn: 359012
* [ADT] Avoid warning in bsearch testcaseSam McCall2019-04-201-3/+3
| | | | llvm-svn: 358811
* [APInt] Optimize umul_ovFangrui Song2019-04-191-0/+36
| | | | | | | | | | | | | Change two costly udiv() calls to lshr(1)*RHS + left-shift + plus On one 64-bit umul_ov benchmark, I measured an obvious improvement: 12.8129s -> 3.6257s Note, there may be some value to special case 64-bit (the most common case) with __builtin_umulll_overflow(). Differential Revision: https://reviews.llvm.org/D60669 llvm-svn: 358730
* [ADT] llvm::bsearch, binary search for mere mortalsSam McCall2019-04-161-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add to STLExtras a binary search function with a simple mental model: You provide a range and a predicate which is true above a certain point. bsearch() tells you that point. Overloads are provided for integers, iterators, and containers. This is more suitable than std:: alternatives in many cases: - std::binary_search only indicates presence/absence - upper_bound/lower_bound give you the opportunity to pick the wrong one - all of the options have confusing names and definitions when your predicate doesn't have simple "less than" semantics - all of the options require iterators - we plumb around a useless `value` parameter that should be a lambda capture The API is inspired by Go's standard library, but we add an extra parameter as well as some overloads and templates to show how clever C++ is. Reviewers: ilya-biryukov, gribozavr Subscribers: dexonsmith, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60779 llvm-svn: 358540
* [ADT] Fix OwningArrayRef's move ctorFangrui Song2019-04-131-0/+7
| | | | llvm-svn: 358332
* [MC] Fix floating-point literal lexing.Eli Friedman2019-03-281-30/+27
| | | | | | | | | | | | | | | | | | | | | This patch has three related fixes to improve float literal lexing: 1. Make AsmLexer::LexDigit handle floats without a decimal point more consistently. 2. Make AsmLexer::LexFloatLiteral print an error for floats which are apparently missing an "e". 3. Make APFloat::convertFromString use binutils-compatible exponent parsing. Together, this fixes some cases where a float would be incorrectly rejected, fixes some cases where the compiler would crash, and improves diagnostics in some cases. Patch by Brandon Jones. Differential Revision: https://reviews.llvm.org/D57321 llvm-svn: 357214
* [ADT] Update SmallVectorTest.EmplaceBack tests after rL356312Fangrui Song2019-03-261-36/+42
| | | | | | | | | | | | | | | | | rL356312 changed the return type of emplace_back from void to reference. Update the tests to check the behavior. Reviewers: dblaikie Reviewed By: dblaikie Subscribers: dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59809 llvm-svn: 356980
* Add XCOFF triple object format type for AIXJason Liu2019-03-121-0/+8
| | | | | | | | | This patch adds an XCOFF triple object format type into LLVM. This XCOFF triple object file type will be used later by object file and assembly generation for the AIX platform. Differential Revision: https://reviews.llvm.org/D58930 llvm-svn: 355989
* Add partial implementation of std::to_address() as llvm::to_address()Daniel Sanders2019-02-201-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Following on from the review for D58088, this patch provides the prerequisite to_address() implementation that's needed to have pointer_iterator support unique_ptr. The late bound return should be removed once we move to C++14 to better align with the C++20 declaration. Also, this implementation can be removed once we move to C++20 where it's defined as std::to_addres() The std::pointer_traits<>::to_address(p) variations of these overloads has not been implemented. Reviewers: dblaikie, paquette Reviewed By: dblaikie Subscribers: dexonsmith, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58421 llvm-svn: 354491
* [NFC] Make Optional<T> trivially copyable when T is trivially copyableSerge Guelton2019-02-181-0/+21
| | | | | | | | | | | This is a follow-up to r354246 and a reimplementation of https://reviews.llvm.org/D57097?id=186600 that should not trigger any UB thanks to the use of an union. This may still be subject to the problem solved by std::launder, but I'm unsure how it interacts whith union. /me plans to revert if this triggers any relevant bot failure. At least this validates in Release mode with clang 6.0.1 and gcc 4.8.5. llvm-svn: 354264
* Revert r354199: Make Optional<T> Trivially Copyable when T is trivially ↵Serge Guelton2019-02-161-7/+0
| | | | | | copyable llvm-svn: 354200
* Make Optional<T> Trivially Copyable when T is trivially copyableSerge Guelton2019-02-161-0/+7
| | | | | | | This is another attempt in the process, works nicely on my setup, let's check how it behaves on other targets. llvm-svn: 354199
* Speculatively revert r354051 "Recommit Optional specialization for trivially ↵Hans Wennborg2019-02-151-20/+0
| | | | | | | | | | | | | | | | | | | | | copyable types" and r354055 "Optional specialization for trivially copyable types, part2" These are suspected to cause Clang to get miscompiled on Ubuntu 14.04 (Trusty) which uses GCC 4.8.4. Reverting for an hour to see if this helps. See llvm-commits thread. > Recommit Optional specialization for trivially copyable types > > Unfortunately the original code gets misscompiled by GCC (at least 8.1), > this is a tentative workaround using std::memcpy instead of inplace new > for trivially copyable types. I'll revert if it breaks. > > Original revision: https://reviews.llvm.org/D57097 llvm-svn: 354126
* Recommit Optional specialization for trivially copyable typesSerge Guelton2019-02-141-0/+20
| | | | | | | | | | Unfortunately the original code gets misscompiled by GCC (at least 8.1), this is a tentative workaround using std::memcpy instead of inplace new for trivially copyable types. I'll revert if it breaks. Original revision: https://reviews.llvm.org/D57097 llvm-svn: 354051
* Revert r353962Serge Guelton2019-02-131-20/+0
| | | | | | | Specialization of Optional for trivially copyable types yields failure on the buildbots I fail to reproduce locally. Better safe than sorry, reverting. llvm-svn: 353982
* Re-commit rL353927, patch includedSerge Guelton2019-02-131-0/+20
| | | | | | | | | | | | | | | Make llvm::Optional<T> trivially copyable when T is trivially copyable This is an ever-recurring issue (see https://bugs.llvm.org/show_bug.cgi?id=39427 and https://bugs.llvm.org/show_bug.cgi?id=35978) but I believe that thanks to https://reviews.llvm.org/D54472 we can now ship a decent implementation of this. Basically the fact that llvm::is_trivially_copyable has a consistent behavior across compilers should prevent any ABI issue, and using in-place new instead of memcpy should keep compiler bugs away. This patch is slightly different from the original revision https://reviews.llvm.org/rL353927 but achieves the same goal. It just avoids going through std::conditional which may the code more explicit. llvm-svn: 353962
* Revert r353927Serge Guelton2019-02-131-20/+0
| | | | llvm-svn: 353940
* Missing headerSerge Guelton2019-02-131-0/+2
| | | | llvm-svn: 353933
* Make llvm::Optional<T> trivially copyable when T is trivially copyableSerge Guelton2019-02-131-0/+20
| | | | | | | | | | | | This is an ever-recurring issue (see https://bugs.llvm.org/show_bug.cgi?id=39427 and https://bugs.llvm.org/show_bug.cgi?id=35978) but I believe that thanks to https://reviews.llvm.org/D54472 we can now ship a decent implementation of this. Basically the fact that llvm::is_trivially_copyable has a consistent behavior across compilers should prevent any ABI issue, and using in-place new instead of memcpy should keep compiler bugs away. Differential Revision: https://reviews.llvm.org/D57097 llvm-svn: 353927
* [ADT] Add a fallible_iterator wrapper.Lang Hames2019-02-052-0/+294
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A fallible iterator is one whose increment or decrement operations may fail. This would usually be supported by replacing the ++ and -- operators with methods that return error: class MyFallibleIterator { public: // ... Error inc(); Errro dec(); // ... }; The downside of this style is that it no longer conforms to the C++ iterator concept, and can not make use of standard algorithms and features such as range-based for loops. The fallible_iterator wrapper takes an iterator written in the style above and adapts it to (mostly) conform with the C++ iterator concept. It does this by providing standard ++ and -- operator implementations, returning any errors generated via a side channel (an Error reference passed into the wrapper at construction time), and immediately jumping the iterator to a known 'end' value upon error. It also marks the Error as checked any time an iterator is compared with a known end value and found to be inequal, allowing early exit from loops without redundant error checking*. Usage looks like: MyFallibleIterator I = ..., E = ...; Error Err = Error::success(); for (auto &Elem : make_fallible_range(I, E, Err)) { // Loop body is only entered when safe. // Early exits from loop body permitted without checking Err. if (SomeCondition) return; } if (Err) // Handle error. * Since failure causes a fallible iterator to jump to end, testing that a fallible iterator is not an end value implicitly verifies that the error is a success value, and so is equivalent to an error check. Reviewers: dblaikie, rupprecht Subscribers: mgorny, dexonsmith, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57618 llvm-svn: 353237
* Revert r351954 "Add a value_type to ArrayRef."Clement Courbet2019-01-251-8/+0
| | | | | | This breaks arm self-hosted buildbots. llvm-svn: 352206
* [ADT] Notify ilist traits about in-list transfersReid Kleckner2019-01-231-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously no client of ilist traits has needed to know about transfers of nodes within the same list, so as an optimization, ilist doesn't call transferNodesFromList in that case. However, now there are clients that want to use ilist traits to cache instruction ordering information to optimize dominance queries of instructions in the same basic block. This change updates the existing ilist traits users to detect in-list transfers and do nothing in that case. After this change, we can start caching instruction ordering information in LLVM IR data structures. There are two main ways to do that: - by putting an order integer into the Instruction class - by maintaining order integers in a hash table on BasicBlock I plan to implement and measure both, but I wanted to commit this change first to enable other out of tree ilist clients to implement this optimization as well. Reviewers: lattner, hfinkel, chandlerc Subscribers: hiraditya, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D57120 llvm-svn: 351992
* Re-land rL322538 "Add a value_type to ArrayRef."Clement Courbet2019-01-231-0/+8
| | | | llvm-svn: 351954
* Fix compilation error with gcc 4.8Pavel Labath2019-01-211-4/+4
| | | | | | | This version of gcc seems to be having issues with raw literals inside macro arguments. I change the string to use regular string literals instead. llvm-svn: 351756
* Replace llvm::isPodLike<...> by llvm::is_trivially_copyable<...>Serge Guelton2019-01-204-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As noted in https://bugs.llvm.org/show_bug.cgi?id=36651, the specialization for isPodLike<std::pair<...>> did not match the expectation of std::is_trivially_copyable which makes the memcpy optimization invalid. This patch renames the llvm::isPodLike trait into llvm::is_trivially_copyable. Unfortunately std::is_trivially_copyable is not portable across compiler / STL versions. So a portable version is provided too. Note that the following specialization were invalid: std::pair<T0, T1> llvm::Optional<T> Tests have been added to assert that former specialization are respected by the standard usage of llvm::is_trivially_copyable, and that when a decent version of std::is_trivially_copyable is available, llvm::is_trivially_copyable is compared to std::is_trivially_copyable. As of this patch, llvm::Optional is no longer considered trivially copyable, even if T is. This is to be fixed in a later patch, as it has impact on a long-running bug (see r347004) Note that GCC warns about this UB, but this got silented by https://reviews.llvm.org/D50296. Differential Revision: https://reviews.llvm.org/D54472 llvm-svn: 351701
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1967-268/+201
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [ADT] Add streaming operators for llvm::OptionalPavel Labath2019-01-181-1/+51
| | | | | | | | | | | | | | | | | | | | | | | Summary: The operators simply print the underlying value or "None". The trickier part of this patch is making sure the streaming operators work even in unit tests (which was my primary motivation, though I can also see them being useful elsewhere). Since the stream operator was a template, implicit conversions did not kick in, and our gtest glue code was explicitly introducing an implicit conversion to make sure other implicit conversions do not kick in :P. I resolve that by specializing llvm_gtest::StreamSwitch for llvm:Optional<T>. Reviewers: sammccall, dblaikie Reviewed By: sammccall Subscribers: mgorny, dexonsmith, kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D56795 llvm-svn: 351548
* [WebAssembly] COWS has been renamed to WASI.Dan Gohman2019-01-161-8/+8
| | | | llvm-svn: 351297
* [WebAssembly] Support multilibs for wasm32 and add a wasm OS that uses itDan Gohman2019-01-151-0/+18
| | | | | | | | | | | | This adds support for multilib paths for wasm32 targets, following [Debian's Multiarch conventions], and also adds an experimental OS name in order to test it. [Debian's Multiarch conventions]: https://wiki.debian.org/Multiarch/ Differential Revision: https://reviews.llvm.org/D56553 llvm-svn: 351163
OpenPOWER on IntegriCloud