summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/FoldingSet.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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
* fix typosAdrian Prantl2018-09-141-1/+1
| | | | llvm-svn: 342241
* Remove trailing spaceFangrui Song2018-07-301-20/+20
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338293
* Use uniform mechanism for OOM errors handlingSerge Pavlov2018-06-091-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a recommit of r333506, which was reverted in r333518. The original commit message is below. In r325551 many calls of malloc/calloc/realloc were replaces with calls of their safe counterparts defined in the namespace llvm. There functions generate crash if memory cannot be allocated, such behavior facilitates handling of out of memory errors on Windows. If the result of *alloc function were checked for success, the function was not replaced with the safe variant. In these cases the calling function made the error handling, like: T *NewElts = static_cast<T*>(malloc(NewCapacity*sizeof(T))); if (NewElts == nullptr) report_bad_alloc_error("Allocation of SmallVector element failed."); Actually knowledge about the function where OOM occurred is useless. Moreover having a single entry point for OOM handling is convenient for investigation of memory problems. This change removes custom OOM errors handling and replaces them with calls to functions `llvm::safe_*alloc`. Declarations of `safe_*alloc` are moved to a separate include file, to avoid cyclic dependency in SmallVector.h Differential Revision: https://reviews.llvm.org/D47440 llvm-svn: 334344
* Revert commit 333506Serge Pavlov2018-05-301-2/+5
| | | | | | | It looks like this commit is responsible for the fail: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/24382. llvm-svn: 333518
* Use uniform mechanism for OOM errors handlingSerge Pavlov2018-05-301-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a recommit of r333390, which was reverted in r333395, because it caused cyclic dependency when building shared library `LLVMDemangle.so`. In this commit `ItaniumDemangler.cpp` was not changed. The original commit message is below. In r325551 many calls of malloc/calloc/realloc were replaces with calls of their safe counterparts defined in the namespace llvm. There functions generate crash if memory cannot be allocated, such behavior facilitates handling of out of memory errors on Windows. If the result of *alloc function were checked for success, the function was not replaced with the safe variant. In these cases the calling function made the error handling, like: T *NewElts = static_cast<T*>(malloc(NewCapacity*sizeof(T))); if (NewElts == nullptr) report_bad_alloc_error("Allocation of SmallVector element failed."); Actually knowledge about the function where OOM occurred is useless. Moreover having a single entry point for OOM handling is convenient for investigation of memory problems. This change removes custom OOM errors handling and replaces them with calls to functions `llvm::safe_*alloc`. Declarations of `safe_*alloc` are moved to a separate include file, to avoid cyclic dependency in SmallVector.h Differential Revision: https://reviews.llvm.org/D47440 llvm-svn: 333506
* Reverted commits 333390, 333391 and 333394Serge Pavlov2018-05-291-2/+5
| | | | | | Build of shared library LLVMDemangle.so fails due to dependency problem. llvm-svn: 333395
* Use uniform mechanism for OOM errors handlingSerge Pavlov2018-05-291-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | In r325551 many calls of malloc/calloc/realloc were replaces with calls of their safe counterparts defined in the namespace llvm. There functions generate crash if memory cannot be allocated, such behavior facilitates handling of out of memory errors on Windows. If the result of *alloc function were checked for success, the function was not replaced with the safe variant. In these cases the calling function made the error handling, like: T *NewElts = static_cast<T*>(malloc(NewCapacity*sizeof(T))); if (NewElts == nullptr) report_bad_alloc_error("Allocation of SmallVector element failed."); Actually knowledge about the function where OOM occurred is useless. Moreover having a single entry point for OOM handling is convenient for investigation of memory problems. This change removes custom OOM errors handling and replaces them with calls to functions `llvm::safe_*alloc`. Declarations of `safe_*alloc` are moved to a separate include file, to avoid cyclic dependency in SmallVector.h Differential Revision: https://reviews.llvm.org/D47440 llvm-svn: 333390
* Revert r325224 "Report fatal error in the case of out of memory"Serge Pavlov2018-02-151-2/+1
| | | | | | It caused fails on some buildbots. llvm-svn: 325227
* Report fatal error in the case of out of memorySerge Pavlov2018-02-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis of fails in the case of out of memory errors can be tricky on Windows. Such error emerges at the point where memory allocation function fails, but manifests itself when null pointer is used. These two points may be distant from each other. Besides, next runs may not exhibit allocation error. Usual programming practice does not require checking result of 'operator new' because it throws 'std::bad_alloc' in the case of allocation error. However, LLVM is usually built with exceptions turned off, so 'new' can return null pointer. This change installs custom new handler, which causes fatal error in the case of out of memory. The handler is installed automatically prior to call to 'main' during construction of a static object defined in 'lib/Support/ErrorHandling.cpp'. If the application does not use this file, the handler may be installed manually by a call to 'llvm::install_out_of_memory_new_handler', declared in 'include/llvm/Support/ErrorHandling.h". There are calls to C allocation functions, malloc, calloc and realloc. They are used for interoperability with C code, when allocated object has variable size and when it is necessary to avoid call of constructors. In many calls the result is not checked against null pointer. To simplify checks, new functions are defined in the namespace 'llvm' with the same names as these C function. These functions produce fatal error if allocation fails. User should use 'llvm::malloc' instead of 'std::malloc' in order to use the safe variant. This change replaces 'std::malloc' in the cases when the result of allocation function is not checked against null pointer. Finally, there are plain C code, that uses malloc and similar functions. If the result is not checked, assert statements are added. Differential Revision: https://reviews.llvm.org/D43010 llvm-svn: 325224
* Support, IR, ADT: Check nullptr after allocation with malloc/realloc or callocMatthias Braun2017-07-201-2/+7
| | | | | | | | | | | | As a follow up of the bad alloc handler patch, this patch introduces nullptr checks on pointers returned from the malloc/realloc/calloc functions. In addition some memory size assignments are moved behind the allocation of the corresponding memory to fulfill exception safe memory management (RAII). patch by Klaus Kretzschmar Differential Revision: https://reviews.llvm.org/D35414 llvm-svn: 308576
* [ADT] Reduce duplication between {Contextual,}FoldingSet; NFCGeorge Burgess IV2017-06-121-21/+21
| | | | | | | | | | | | | This is a precursor to another change (coming soon) that aims to make FoldingSet's API more type-safe. Without this, the type-safety change would just duplicate 4 more public methods between the already very similar classes. This renames FoldingSetImpl to FoldingSetBase so it's consistent with the FooBase -> FooImpl<T> -> Foo<T> convention we seem to have with other containers. llvm-svn: 305231
* PR30711: Fix incorrect profiling of 'long long' in FoldingSet, then use it toRichard Smith2016-10-161-4/+4
| | | | | | fix TBAA violation in profiling of pointers. llvm-svn: 284336
* Replace a few more "fall through" comments with LLVM_FALLTHROUGHJustin Bogner2016-08-171-2/+2
| | | | | | Follow up to r278902. I had missed "fall through", with a space. llvm-svn: 278970
* Adding reserve and capacity methods to FoldingSetBen Craig2016-06-031-5/+20
| | | | | | http://reviews.llvm.org/D20930 llvm-svn: 271669
* [ADT] Teach FoldingSet to be movable.Chandler Carruth2015-08-161-0/+20
| | | | | | | | | | This is a very minimal move support - it leaves the moved-from object in a zombie state that is only valid for destruction and move assignment. This seems fine to me, and leaving it in the default constructed state would require adding more state to the object and potentially allocating memory (!!!) and so seems like a Bad Idea. llvm-svn: 245192
* fix typos; NFCSanjay Patel2015-04-061-2/+2
| | | | llvm-svn: 234171
* FoldingSet: Make FoldingSetImpl's dtor protected and non-virtualBenjamin Kramer2015-03-221-0/+2
| | | | | | | | | It's not intended to be polymorphically deleted. Make FoldingSet and ContextualFoldingSet final to avoid noise from -Wnon-virtual-dtor. No functional change intended. llvm-svn: 232922
* [llvm] Replacing asserts with static_asserts where appropriateGabor Horvath2015-03-161-2/+3
| | | | | | | | | | | | | | | | Summary: This patch consists of the suggestions of clang-tidy/misc-static-assert check. Reviewers: alexfh Reviewed By: alexfh Subscribers: xazax.hun, llvm-commits Differential Revision: http://reviews.llvm.org/D8343 llvm-svn: 232366
* [C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper2014-04-151-1/+1
| | | | | | instead of comparing to nullptr. llvm-svn: 206252
* [C++11] Replace some comparisons with 'nullptr' with simple boolean checks ↵Craig Topper2014-04-091-6/+5
| | | | | | to reduce verbosity. llvm-svn: 205829
* [C++11] Make use of 'nullptr' in the Support library.Craig Topper2014-04-071-10/+11
| | | | llvm-svn: 205697
* Make the host endianness check an integer constant expression.Rafael Espindola2013-04-151-2/+2
| | | | | | | | | | | | | | | I will remove the isBigEndianHost function once I update clang. The ifdef logic is designed to * not use configure/cmake to avoid breaking -arch i686 -arch ppc. * default to little endian * be as small as possible It looks like sys/endian.h is the preferred header on most modern BSD systems, but it is better to change this in a followup patch as machine/endian.h is available on FreeBSD, OpenBSD, NetBSD and OS X. llvm-svn: 179527
* Fix whitespace. No functionality change.Nick Lewycky2012-12-251-2/+2
| | | | llvm-svn: 171051
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-1/+1
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
* move irrelevant attribution.Chris Lattner2012-11-161-3/+1
| | | | llvm-svn: 168182
* Add operator< for FoldingSetNodeID.Ted Kremenek2012-09-081-0/+18
| | | | llvm-svn: 163454
* FoldingSet: Push the hash through FoldingSetTraits::Equals, so clients can ↵Benjamin Kramer2012-04-111-3/+3
| | | | | | use it. llvm-svn: 154496
* Revert commit 152300 (ddunbar) since it still seems to be breakingDuncan Sands2012-03-081-1/+43
| | | | | | | | | buildbots. Original commit message: [ADT] Change the trivial FoldingSetNodeID::Add* methods to be inline, reapplied with a fix for the longstanding over-read of 32-bit pointer values. llvm-svn: 152304
* [ADT] Change the trivial FoldingSetNodeID::Add* methods to be inline, reappliedDaniel Dunbar2012-03-081-43/+1
| | | | | | with a fix for the longstanding over-read of 32-bit pointer values. llvm-svn: 152300
* Revert r152288, "[ADT] Change the trivial FoldingSetNodeID::Add* methods to beDaniel Dunbar2012-03-081-1/+43
| | | | | | inline.", which is breaking the bots in a way I don't understand. llvm-svn: 152295
* [ADT] Change the trivial FoldingSetNodeID::Add* methods to be inline.Daniel Dunbar2012-03-081-43/+1
| | | | llvm-svn: 152288
* Switch FoldingSet over to the new hashing infrastructure. We might wantChandler Carruth2012-03-011-18/+2
| | | | | | | | to do more invasive refactoring here to get FoldingSet to use size_t or even hash_code directly, but for now this is a good first step to remove Yet Another Hashing Algorithm from LLVM. llvm-svn: 151859
* Simplify & microoptimize code. No intended functionality change.Benjamin Kramer2011-07-181-4/+2
| | | | llvm-svn: 135364
* singed int causes signed extension, which contradicts the intention to pick upZhongxing Xu2011-06-031-1/+1
| | | | | | integers with high 32 bits being zero. llvm-svn: 132538
* allow adding a FoldingSetNodeID to a FastFoldingSetNode, resolving PR9499,Chris Lattner2011-04-251-0/+5
| | | | | | patch by Johannes Schaub! llvm-svn: 130151
* Merge System into Support.Michael J. Spencer2010-11-291-1/+1
| | | | llvm-svn: 120298
* Aligned and unaligned copies of the same stringDale Johannesen2010-11-191-7/+22
| | | | | | | were not hashing to the same value. Analysis and patch by Frits van Bommel! llvm-svn: 119770
* Use Bits.data() instead of &Bits[0].Dan Gohman2010-08-241-3/+3
| | | | llvm-svn: 111993
* Add hooks to FoldingSetTrait to allow specializations to provideDan Gohman2010-08-161-35/+52
| | | | | | | | implementations of equality comparison and hash computation. This can be used to optimize node lookup by avoiding creating lots of temporary ID values just for hashing and comparison purposes. llvm-svn: 111130
* Reverse the order of GetNodeProfile's arguments, for consistencyDan Gohman2010-08-161-4/+4
| | | | | | with FoldingSetTrait::Profile. llvm-svn: 111127
* Use calloc instead of new/memset, it is more efficient when the set is very ↵Benjamin Kramer2010-06-191-6/+14
| | | | | | large. llvm-svn: 106390
* Add the ability to "intern" FoldingSetNodeID data into aDan Gohman2010-03-181-0/+10
| | | | | | | | | | | | BumpPtrAllocator-allocated region to allow it to be stored in a more compact form and to avoid the need for a non-trivial destructor call. Use this new mechanism in ScalarEvolution instead of FastFoldingSetNode to avoid leaking memory in the case where a FoldingSetNodeID uses heap storage, and to reduce overall memory usage. llvm-svn: 98829
* Switch FoldingSet::AddString to StringRef based API.Daniel Dunbar2009-09-221-11/+3
| | | | | | - This also fixes a dereference of std::string::end, which makes MSVC unhappy and was causing all the static analyzer clang tests to fail. llvm-svn: 82517
* llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.Torok Edwin2009-07-141-1/+1
| | | | | | | | | This adds location info for all llvm_unreachable calls (which is a macro now) in !NDEBUG builds. In NDEBUG builds location info and the message is off (it only prints "UREACHABLE executed"). llvm-svn: 75640
* assert(0) -> LLVM_UNREACHABLE.Torok Edwin2009-07-111-1/+2
| | | | | | | | | Make llvm_unreachable take an optional string, thus moving the cerr<< out of line. LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for NDEBUG builds. llvm-svn: 75379
* Add an API for strings with possible NULLs in the middle. Refactor the otherNick Lewycky2009-02-071-37/+8
| | | | | | two AddString methods to use it. llvm-svn: 64005
* Do not use host floating point types when emittingDale Johannesen2009-01-211-6/+0
| | | | | | | | | ASCII IR; loading and storing these can change the bits of NaNs on some hosts. Remove or add warnings at a few other places using host floating point; this is a bad thing to do in general. llvm-svn: 62712
* Overload AddInteger on int/long/long long instead of on int/int64_t,Dan Gohman2008-11-031-6/+16
| | | | | | | to avoid overload ambiguities. This fixes build errors introduced by r58623. llvm-svn: 58632
* Add a clear() method to FoldingSet.Dan Gohman2008-08-231-12/+13
| | | | llvm-svn: 55210
OpenPOWER on IntegriCloud