summaryrefslogtreecommitdiff
path: root/unittests/ADT
Commit message (Collapse)AuthorAge
* Fix layering StringRef copy using BumpPtrAllocator.Nick Kledzik2014-02-05
| | | | | | | | | | | Now to copy a string into a BumpPtrAllocator and get a StringRef to the copy: StringRef myCopy = myStr.copy(myAllocator); git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200885 91177308-0d34-0410-b5e6-96231b3b80d8
* Clean up whitespaceDuncan P. N. Exon Smith2014-01-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200579 91177308-0d34-0410-b5e6-96231b3b80d8
* Roll back the ConstStringRef change for nowAlp Toker2014-01-27
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200194 91177308-0d34-0410-b5e6-96231b3b80d8
* StringRef: Extend constexpr capabilities and introduce ConstStringRefAlp Toker2014-01-27
| | | | | | | | | | | | | | | | | | | (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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200187 91177308-0d34-0410-b5e6-96231b3b80d8
* [APInt] Fix nearestLogBase2 to return correct answers for very large APInt ↵Michael Gottesman2014-01-19
| | | | | | | | and APInt with a bitwidth of 1. I also improved the comments, added some more tests, etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199610 91177308-0d34-0410-b5e6-96231b3b80d8
* [APInt] Fixed bug where APInt(UINT32_MAX, 0) would blow up when being ↵Michael Gottesman2014-01-19
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199609 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-sort all of the includes with ./utils/sort_includes.py so thatChandler Carruth2014-01-07
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198685 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix break introduced in r198377 due to using a local type as a template ↵David Blaikie2014-01-03
| | | | | | parameter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198379 91177308-0d34-0410-b5e6-96231b3b80d8
* Test coverage for non-default-constructible elements in a StringMapDavid Blaikie2014-01-02
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198377 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove StringMapEntryInitializer support.David Blaikie2014-01-02
| | | | | | | It was never specialized so let's just remove that unused configurability and always do the default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198374 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a buffer overrun detected by AddressSanitizer.Anna Zaks2013-12-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197647 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove APInt::extractBit since it is already implemented via operator[]. ↵Michael Gottesman2013-12-13
| | | | | | Change tests for extractBit to test operator[]. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197277 91177308-0d34-0410-b5e6-96231b3b80d8
* [block-freq] Add the method APInt::nearestLogBase2().Michael Gottesman2013-12-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197272 91177308-0d34-0410-b5e6-96231b3b80d8
* [block-freq] Add the APInt method extractBit.Michael Gottesman2013-12-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197271 91177308-0d34-0410-b5e6-96231b3b80d8
* Darwin: update default iOS version to 5.0Tim Northover2013-12-10
| | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196912 91177308-0d34-0410-b5e6-96231b3b80d8
* Make the moved-from SmallPtrSet be a valid, empty, small-state object.Chandler Carruth2013-11-20
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195261 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a test for assignment operator behavior which was changed inChandler Carruth2013-11-20
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195260 91177308-0d34-0410-b5e6-96231b3b80d8
* Give SmallPtrSet move semantics when we have R-value references.Chandler Carruth2013-11-20
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195239 91177308-0d34-0410-b5e6-96231b3b80d8
* [weak vtables] Place class definitions into anonymous namespaces to prevent ↵Juergen Ributzka2013-11-19
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195092 91177308-0d34-0410-b5e6-96231b3b80d8
* [weak vtables] Remove a bunch of weak vtablesJuergen Ributzka2013-11-19
| | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195064 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r194865 and r194874.Alexey Samsonov2013-11-18
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194997 91177308-0d34-0410-b5e6-96231b3b80d8
* [weak vtables] Remove a bunch of weak vtablesJuergen Ributzka2013-11-15
| | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194865 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a null pointer dereference when copying a null polymorphic pointer.Chandler Carruth2013-11-13
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194548 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch to allow implicit construction. In many cases, we're wrappingChandler Carruth2013-11-09
| | | | | | a derived type and this makes it *much* easier to write this code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194321 91177308-0d34-0410-b5e6-96231b3b80d8
* Test the polymorphic behavior of this utility.Chandler Carruth2013-11-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194320 91177308-0d34-0410-b5e6-96231b3b80d8
* Use something really explicit to test "move semantics" on builds withoutChandler Carruth2013-11-09
| | | | | | | | | 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? ;] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194318 91177308-0d34-0410-b5e6-96231b3b80d8
* Add the critically missing 'clone' method. =]Chandler Carruth2013-11-09
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194317 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the test type out of the function and into the anonymous namespaceChandler Carruth2013-11-09
| | | | | | to fix C++98 builds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194316 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a polymorphic_ptr<T> smart pointer data type. It's a somewhat sillyChandler Carruth2013-11-09
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194315 91177308-0d34-0410-b5e6-96231b3b80d8
* Add {start,end}with_lower methods to StringRef.Rui Ueyama2013-10-30
| | | | | | | | | startswith_lower is ocassionally useful and I think worth adding. endwith_lower is added for completeness. Differential Revision: http://llvm-reviews.chandlerc.com/D2041 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193706 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a few tests for StringRef::{start,end}with.Rui Ueyama2013-10-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193550 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a Python-like join function to merge a list of strings with aJoerg Sonnenberger2013-09-03
| | | | | | | separator between each two elements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189846 91177308-0d34-0410-b5e6-96231b3b80d8
* Change default # of digits for APFloat::toStringEli Friedman2013-08-29
| | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189624 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r189442 "Change default # of digits for APFloat::toString"Ted Kremenek2013-08-28
| | | | | | This is breaking numerous Clang tests on the buildbot. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189447 91177308-0d34-0410-b5e6-96231b3b80d8
* Change default # of digits for APFloat::toStringEli Friedman2013-08-28
| | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189442 91177308-0d34-0410-b5e6-96231b3b80d8
* Basic unit tests for PointerUnionDavid Blaikie2013-08-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188933 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Make all arithmetic operations with NaN produce positive NaNs.Michael Gottesman2013-07-27
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187314 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[PowerPC] Improve consistency in use of __ppc__, __powerpc__, etc."Rafael Espindola2013-07-26
| | | | | | This reverts commit r187248. It broke many bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187254 91177308-0d34-0410-b5e6-96231b3b80d8
* [PowerPC] Improve consistency in use of __ppc__, __powerpc__, etc.Bill Schmidt2013-07-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187248 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle '.' correctly in hex float literal parsing.Eli Friedman2013-07-17
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186539 91177308-0d34-0410-b5e6-96231b3b80d8
* Sync SmallBitVector with BitVector. Add unit tests for the missing methods.Benjamin Kramer2013-07-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186123 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Ensure that we can properly parse strings that do not have null ↵Michael Gottesman2013-07-01
| | | | | | | | terminators. rdar://14323230 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185397 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Added unittest for APFloat.divide that checks special cases, ↵Michael Gottesman2013-06-27
| | | | | | result categories, and result statuses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185050 91177308-0d34-0410-b5e6-96231b3b80d8
* Removed two logging printf statements from the APFloat tests... = /.Michael Gottesman2013-06-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185045 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Added unittest for APFloat.multiply that checks special cases, ↵Michael Gottesman2013-06-26
| | | | | | result categories, and result status. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185044 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Added unittest for APFloat.subtract that checks special cases, ↵Michael Gottesman2013-06-26
| | | | | | result categories, and result status. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185043 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Removed debugging cruft that snuck in.Michael Gottesman2013-06-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184974 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Removed trailing whitespace from unittests.Michael Gottesman2013-06-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184715 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Added a large unittest for APFloat.add that checks that special ↵Michael Gottesman2013-06-24
| | | | | | values are computed correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184714 91177308-0d34-0410-b5e6-96231b3b80d8
* [APFloat] Rename isIEEENormal => isNormal and remove old isNormal method.Michael Gottesman2013-06-20
| | | | | | | | The old isNormal is already functionally replaced by the method isFiniteNonZero in r184350 and all references to said method were replaced in LLVM/clang in r184356/134366. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184449 91177308-0d34-0410-b5e6-96231b3b80d8