summaryrefslogtreecommitdiffstats
path: root/libcxx/src/new.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [libc++][CMake] Remove unnecessary conditional for defining new handlersLouis Dionne2019-04-171-1/+1
| | | | | | | | | | | It turns out that whether the new handlers should be provided is orthogonal to whether new/delete are provided in libc++ or libc++abi. The reason why I initially added this conditional is because of an incorrect understanding of the path we're taking when building on Apple platforms. In fact, we always build libc++ on top of libc++abi on Apple platforms, so we take the branch for `LIBCXX_BUILDING_LIBCXXABI` there. llvm-svn: 358616
* [libc++] Remove old workaround for builditLouis Dionne2019-04-161-6/+2
| | | | | | | | | | | | | | | | | | | | Summary: I'm not sure what the problem was at the time, however I don't think this is necessary since buildit doesn't exist anymore. Instead of the workaround, the correct thing to do is to leave out the get_new_handler/set_new_handler definitions from libc++ when we're getting them from libc++abi. Reviewers: EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D60717 llvm-svn: 358518
* [NFC][libc++] Reindent #ifdefsLouis Dionne2019-03-211-12/+12
| | | | | | | | I don't understand why we don't always do that. We do it for normal `if`s in the code, but not for preprocessor `if`s? It's a lot more readable when indented properly. llvm-svn: 356693
* Make VCRuntime ABI configuration a first-class option.Eric Fiselier2019-03-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: On Windows we currently provide two separate ABI configurations. One which defers to `vcruntime` to provide the C++ runtime and another which doesn't. Using `vcruntime` allows interoperability which programs compiled against the MSVC STL, and should be preferred whenever possible. When deferring to `vcruntime` much of the ABI we provide changes. Including the layout of `<stdexcept>` types, their vtables, and how the linkage of their members. This patch introduces the `_LIBCPP_ABI_VCRUNTIME` macro to denote this configuration. It also cleans up the existing configuration for using `vcruntime`. This cleanup lays the groundwork for fixing a number of ABI and interoperability bugs in `<stdexcept>`. Reviewers: thomasanderson, ldionne, smeenai Reviewed By: smeenai Subscribers: jdoerfert, libcxx-commits, #libc Differential Revision: https://reviews.llvm.org/D58942 llvm-svn: 355366
* [libc++] Explicitly initialize std::nothrowThomas Anderson2019-01-301-1/+1
| | | | | | | | | | | | | When building on Windows without libc++abi, this change fixes a build error of the form: src/new.cpp(38,17): error: chosen constructor is explicit in copy-initialization const nothrow_t nothrow = {}; include/vcruntime_new.h(53,22): note: explicit constructor declared here explicit nothrow_t() = default; Differential Revision: https://reviews.llvm.org/D57351 llvm-svn: 352648
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. 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: 351648
* Distinguish between library and language support for aligned allocation.Eric Fiselier2018-10-111-3/+3
| | | | | | | | | | | | | | | | | | | | There are two cases: 1. The library has all it needs to provide align_val_t and the new/delete overloads needed to support aligned allocation. 2. The compiler has actually turned the language feature on. There are times where libc++ needs to distinguish between the two. This patch adds the additional macro _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION which denotes when case (1) does not hold. _LIBCPP_HAS_NO_ALIGNED_ALLOCATION is defined whenever _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION is defined, or when the compiler has not enabled the language feature. Additionally this patch cleans up a number of other macros related to detection of aligned allocation machinery. llvm-svn: 344207
* Remove redundant null pointer check in operator deleteFangrui Song2018-10-011-5/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: C89 4.10.3.2 The free function C99 7.20.3.2 The free function C11 7.22.3.3 The free function If ptr is a null pointer, no action shall occur. _aligned_free on MSDN: If memblock is a NULL pointer, this function simply performs no actions. Reviewers: EricWF, mclow.lists, khng300, hotpxl Reviewed By: mclow.lists, khng300, hotpxl Subscribers: lichray, llvm-commits, hotpxl, khng300, christof, ldionne, cfe-commits, libcxx-commits Differential Revision: https://reviews.llvm.org/D52401 llvm-svn: 343503
* Revert r342936 "Remove redundant null pointer check in operator delete"Louis Dionne2018-09-251-3/+5
| | | | | | | | A review for the change was opened in https://reviews.llvm.org/D52401 but the change was committed before being approved by any of the code owners for libc++. llvm-svn: 342938
* Remove redundant null pointer check in operator deleteFangrui Song2018-09-251-5/+3
| | | | | | | | | | | | | | | | | | | | C89 4.10.3.2 The free function C99 7.20.3.2 The free function C11 7.22.3.3 The free function If ptr is a null pointer, no action shall occur. _aligned_free on MSDN: If memblock is a NULL pointer, this function simply performs no actions. Reviewers: EricWF, mclow.lists Subscribers: christof, ldionne, cfe-commits, libcxx-commits Differential Revision: https://reviews.llvm.org/D52401 llvm-svn: 342936
* [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since ↵Louis Dionne2018-08-011-2/+0
| | | | | | | | | | | | | | _LIBCPP_BUILDING_LIBRARY Summary: As suggested by Marshall in https://reviews.llvm.org/D49914 Reviewers: mclow.lists, EricWF Subscribers: christof, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D50008 llvm-svn: 338475
* [libc++] Support Microsoft ABI without vcruntime headersShoaib Meenai2017-10-091-3/+6
| | | | | | | | | | | | | | | | | The vcruntime headers are hairy and clash with both libc++ headers themselves and other libraries. libc++ normally deals with the clashes by deferring to the vcruntime headers and silencing its own definitions, but for clients which don't want to depend on vcruntime headers, it's desirable to support the opposite, i.e. have libc++ provide its own definitions. Certain operator new/delete replacement scenarios are not currently supported in this mode, which requires some tests to be marked XFAIL. The added documentation has more details. Differential Revision: https://reviews.llvm.org/D38522 llvm-svn: 315234
* [libc++] Replace __sync_* functions with __libcpp_atomic_* functionsWeiming Zhao2017-09-191-0/+1
| | | | | | | | | | | | | | | | Summary: This patch replaces __sync_* with __libcpp_atomic_* and adds a wrapper function for __atomic_exchange to support _LIBCPP_HAS_NO_THREADS. Reviewers: EricWF, jroelofs, mclow.lists, compnerd Reviewed By: EricWF, compnerd Subscribers: compnerd, efriedma, cfe-commits, joerg, llvm-commits Differential Revision: https://reviews.llvm.org/D35235 llvm-svn: 313694
* Fix Libc++ build with MinGW64Eric Fiselier2017-05-311-2/+2
| | | | | | | | | | | | | | Summary: This patch corrects the build errors I encountered when building on MinGW64. Reviewers: mati865, rnk, compnerd, smeenai, bcraig Reviewed By: mati865, smeenai Subscribers: martell, chapuni, cfe-commits Differential Revision: https://reviews.llvm.org/D33082 llvm-svn: 304360
* [libc++] Add option to disable new/delete overloads when libc++abi provides ↵Eric Fiselier2017-03-021-2/+3
| | | | | | | | | | | | | | | | | | | | | them. Summary: Currently both libc++ and libc++abi provide definitions for operator new/delete. However I believe this is incorrect and that one or the other should offer them. This patch adds the CMake option `-DLIBCXX_ENABLE_NEW_DELETE_DEFINITIONS` which defaults no `ON` unless `-DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS=ON` is specified. Reviewers: mclow.lists, mehdi_amini, dexonsmith, danalbert, smeenai, mgorny, rmaprath Reviewed By: mehdi_amini Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30516 llvm-svn: 296802
* Attempt to fix Apple buildit botsEric Fiselier2017-02-101-1/+5
| | | | llvm-svn: 294731
* Recommit "Split exception.cpp and new.cpp implementation into different ↵Eric Fiselier2017-02-101-122/+36
| | | | | | | | | | | | | | | | | | | | | | files for different runtimes." This recommits r294707 with additional fixes. The main difference is libc++ now correctly builds without any ABI library. exception.cpp is a bloody mess. It's full of confusing #ifdef branches for each different ABI library we support, and it's getting unmaintainable. This patch breaks down exception.cpp into multiple different header files, roughly one per implementation. Additionally it moves the definitions of exceptions in new.cpp into the correct implementation header. This patch also removes an unmaintained libc++abi configuration. This configuration may still be used by Apple internally but there are no other possible users. If it turns out that Apple still uses this configuration internally I will re-add it in a later commit. See http://llvm.org/PR31904. llvm-svn: 294730
* Revert "Split exception.cpp and new.cpp implementation into different files ↵Eric Fiselier2017-02-101-38/+122
| | | | | | | | for different runtimes." The compiler-rt CMake configuration needs some tweaking before this can land. llvm-svn: 294727
* Split exception.cpp and new.cpp implementation into different files for ↵Eric Fiselier2017-02-101-122/+38
| | | | | | | | | | | | | | | | | | | different runtimes. exception.cpp is a bloody mess. It's full of confusing #ifdef branches for each different ABI library we support, and it's getting unmaintainable. This patch breaks down exception.cpp into multiple different header files, roughly one per implementation. Additionally it moves the definitions of exceptions in new.cpp into the correct implementation header. This patch also removes an unmaintained libc++abi configuration. This configuration may still be used by Apple internally but there are no other possible users. If it turns out that Apple still uses this configuration internally I will re-add it in a later commit. See http://llvm.org/PR31904. llvm-svn: 294707
* Disable aligned new/delete on Apple platforms without posix_memalignEric Fiselier2017-01-201-0/+4
| | | | | | | | | | | | | | | | | | | Summary: This patch disables the aligned new/delet overloads on Apple platforms without `posix_memalign`. This fixes libc++.dylib build regressions on such platforms. This fixes http://llvm.org/PR31448. This patch should also be merged into the 4.0 release branch Reviewers: mclow.lists, rsmith, dexonsmith, jeremyhu Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28931 llvm-svn: 292564
* [NFC] Group aligned new/delete definitions together in new.cppEric Fiselier2017-01-201-85/+85
| | | | | | This patch is cleanup to prepare for future changes llvm-svn: 292560
* [libc++] Pair _aligned_malloc with _aligned_freeShoaib Meenai2017-01-121-0/+4
| | | | | | | | | | | | | | | | | | Attempting to pair an `_aligned_malloc` with a regular free causes heap corruption. Pairing with `_aligned_free` is required instead. Makes the following libc++ tests pass on Windows: ``` std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp ``` Differential Revision: https://reviews.llvm.org/D28512 llvm-svn: 291743
* clean up use of _WIN32Saleem Abdulrasool2017-01-031-1/+1
| | | | | | | | | Replace the use of _WIN32 in libc++. Replace most use with a C runtime check _LIBCPP_MSVCRT or the new _LIBCPP_WIN32 to indicate that we are using the Win32 API. Use a new _LIBCPP_WCHAR_IS_UCS2 to indicate that we are on an environment that has a short wchar_t. llvm-svn: 290910
* Recommit r290839 - Fix configuring and building libc++ w/o an ABI library.Eric Fiselier2017-01-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch re-commits a previous attempt to support building libc++ w/o an ABI library. That patch was originally reverted because: 1) It forgot to teach the test suite about "default" ABI libraries. 2) Some LLVM builders don't clear the CMake cache between builds. The previous patch caused those builders to fail since their old cache entry for LIBCXX_CXX_ABI="" is no longer valid. The updated patch addresses both issues. It works around (2) by adding a hack to force the builders to update their cache entries. The hack will be removed shortly once all LLVM builders have run. Original commit message ----------------------- Typically libc++ uses libc++abi or libcxxrt to provide the ABI and runtime bits of the C++ STL. However we also support building w/o an ABI library entirely. This patch fixes building libc++ w/o an ABI library (and incorporates the `~type_info()` fix in D28211). The main changes in this patch are: 1) Add `-DLIBCXX_CXX_ABI=default` instead of using the empty string to mean "default". 2) Fix CMake bits which treated "none" as "default" on OS X. 3) Teach the source files to respect `-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY`. 4) Define ~type_info() when _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY is defined. Unfortunately this patch doesn't help clean up the macro mess that we use to configure for different ABI libraries. llvm-svn: 290849
* Revert r290839 - Fix configuring and building libc++ w/o an ABI libraryEric Fiselier2017-01-021-4/+2
| | | | llvm-svn: 290841
* Fix configuring and building libc++ w/o an ABI library.Eric Fiselier2017-01-021-2/+4
| | | | | | | | | | | | | | | | | | | Typically libc++ uses libc++abi or libcxxrt to provide the ABI and runtime bits of the C++ STL. However we also support building w/o an ABI library entirely. This patch fixes building libc++ w/o an ABI library (and incorporates the `~type_info()` fix in D28211). The main changes in this patch are: 1) Add `-DLIBCXX_CXX_ABI=default` instead of using the empty string to mean "default". 2) Fix CMake bits which treated "none" as "default" on OS X. 3) Teach the source files to respect `-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY`. 4) Define ~type_info() when _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY is defined. Unfortunately this patch doesn't help clean up the macro mess that we use to configure for different ABI libraries. llvm-svn: 290839
* Don't use posix_memalign on Windows platformsEric Fiselier2016-12-231-0/+4
| | | | llvm-svn: 290448
* Allow using libsupc++ with LIBCXX_ENABLE_STATIC_ABI_LIBRARY. Patch from ↵Eric Fiselier2016-11-181-5/+13
| | | | | | | | | | | | | | | | | | | | | | Michael Daniels. The code cannot currently link when using libsupc++ with the LIBCXX_ENABLE_STATIC_ABI_LIBRARY option. This change ifdef's out the the destructor and 'what' function for bad_array_length and bad_array_new_length when GLIBCXX is defined. The constructors that are left in are the only functions not being provided by libsupc++ itself, and follows the same pattern that was used to ifdef bad_alloc. Testing was done on a Linux x86_64 host using GCC 5.4 and libc++ from ToT. I see no change to the test results when using libsup++ or libstdc++ without LIBCXX_ENABLE_STATIC_ABI_LIBRARY. When using libsupc++ with LIBCXX_ENABLE_STATIC_ABI_LIBRARY it will now build and test results are the same as those without the option specified. Reviewed as https://reviews.llvm.org/D26186 llvm-svn: 287388
* [libc++] Introduce `_LIBCPP_OVERRIDABLE_FUNC_VIS`Shoaib Meenai2016-11-161-20/+20
| | | | | | | | | | This is a generalization of `_LIBCPP_NEW_DELETE_VIS`; the new macro name captures the semantics better, and also allows us to get rid of the `_WIN32` check in `include/new`. No functional change. Differential Revision: https://reviews.llvm.org/D26702 llvm-svn: 287164
* Implement P0035R4 -- Add C++17 aligned allocation functionsEric Fiselier2016-10-141-8/+118
| | | | | | | | | | | | | | | | Summary: This patch implements the library side of P0035R4. The implementation is thanks to @rsmith. In addition to the C++17 implementation, the library implementation can be explicitly turned on using `-faligned-allocation` in all dialects. Reviewers: mclow.lists, rsmith Subscribers: rsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D25591 llvm-svn: 284206
* Add an _LIBCPP_NORETURN inline function named __throw_XXX for each exception ↵Marshall Clow2016-08-251-0/+2
| | | | | | type we define. They either construct and throw the exception, or abort() (if exceptions are disabled). Use these functions everywhere instead of assert()ing when exceptions are disabled. WARNING: This is a behavior change - but only with exceptions disabled. Reviewed as: https://reviews.llvm.org/D23855. llvm-svn: 279744
* Remove a long-standing __has_include hack.Benjamin Kramer2015-10-161-6/+2
| | | | | | | | | This was put in to get libc++ building without libcxxabi. We now have macros that show that we are building against libcxxabi so use that instead. This guards against existing but broken cxxabi.h headers on the system. llvm-svn: 250507
* Fix a typo: overidden -> overridden - Patch from Kai ZhaoEric Fiselier2015-08-201-1/+1
| | | | llvm-svn: 245539
* Fix for LWG Issue 2458: N3778 and new library deallocation signatures.Marshall Clow2015-05-181-14/+0
| | | | llvm-svn: 237592
* More on adding sized deallocation functions in libc++: Continuing from ↵Larisse Voufo2015-02-201-8/+8
| | | | | | r229281, this adds version guards and test cases. llvm-svn: 229968
* Implement C++14's sized deallocation functions, since there are no longer ↵Larisse Voufo2015-02-151-1/+29
| | | | | | implicitly defined by clang, as of r229241. llvm-svn: 229281
* Partial fix for building w/ libcxxrt on OSX. Patch from C Bergstrom.Eric Fiselier2014-11-011-1/+1
| | | | llvm-svn: 221029
* libcxxrt defines bad_array_new_length::what() so move that into a ↵Eric Fiselier2014-11-011-6/+6
| | | | | | conditional compilation block llvm-svn: 221025
* libcxxrt now implements bad_array_new_length and need to gaurd against ↵Eric Fiselier2014-10-291-2/+2
| | | | | | multiple defines. Patch from Baptiste Daroussin. llvm-svn: 220882
* Switch to using C++ style casts.Joerg Sonnenberger2014-01-041-1/+1
| | | | llvm-svn: 198505
* Patch from Bruce Mitchener; fixes two typos in comments. No functionality ↵Marshall Clow2013-11-111-1/+1
| | | | | | change. PR17843 llvm-svn: 194432
* Make it possible to link against libstdc++ as well as libsupc++ with CMake.Peter Collingbourne2013-10-061-0/+4
| | | | | | | | | | | | | | | Linking against libstdc++, rather than libsupc++, is probably better for people who need to link against clients of libstdc++. Because libsupc++ is provided only as a static library, its globals are not shared between the static library and the copy linked into libstdc++. This has been found to cause at least one test failure. This also removes a number of symbols which were multiply defined between libstdc++ and libc++, only when linking with libstdc++. Differential Revision: http://llvm-reviews.chandlerc.com/D1825 llvm-svn: 192075
* Eliminate more symbols multiply defined between libsupc++ and libc++.Peter Collingbourne2013-10-061-1/+15
| | | | | | | | | | | | | | | The remaining multiple definitions were flushed out by attempting to link libsupc++ and libc++ into the same executable with --whole-archive, e.g. clang++ -I../llvm/projects/libcxx/include -nodefaultlibs -Wl,--whole-archive lib/libc++.a /usr/lib/gcc/x86_64-linux-gnu/4.6/libsupc++.a -Wl,--no-whole-archive -lgcc -lgcc_s -lc -lpthread -lrt (The same technique was used to flush out multiple definitions in libstdc++.) Differential Revision: http://llvm-reviews.chandlerc.com/D1824 llvm-svn: 192074
* Use _LIBCPP_NEW_DELETE_VIS instead of LIBCPP_FUNC_VIS in src/new.cpp.Howard Hinnant2013-10-061-8/+8
| | | | llvm-svn: 192071
* G M: The attached patch is for libcxx's new.cpp and __config files. The ↵Howard Hinnant2013-10-041-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | patch's intent is to make new.cpp compile using MS's cl.exe compiler without changing the meaning of anything for any other compiler. The issue this patch seeks to address is that MS's compiler (cl.exe) doesn't support the __attribute__((__weak__)) or __atribute__((__visibility__("default")) syntax; so a solution must be found where cl.exe doesn't see this syntax. This patch seeks to solve this problem by changing code patterned like this: __attribute__((__weak__, __visibility__("default"))) void* operator new(size_t size, const std::nothrow_t&) _NOEXCEPT { /*snip*/; return p; } to code like this: _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) _NOEXCEPT { return p; } Howard: Thanks for all the comments regarding the default visibility tag on the definition. I agree it isn't needed, and that there are lots of other places where it is missing. That being said, I'm not wanting to rock the boat on that issue right now. So I've added it back to the definition via _LIBCPP_FUNC_VIS. A later pass dedicated just to this issue can bring things in to a consistent state one way or the other. Note that we do not want to have the exact same attributes on the declaration and defintion in this case. The declaration should not be marked weak, whereas the definition should (which is what G M's patch did). I've fully tested on OS X to ensure that the resultant attribute syntax actually works. llvm-svn: 192007
* Adding bad_array_length to libc++Marshall Clow2013-09-111-1/+17
| | | | llvm-svn: 190478
* Removed raw references to __APPLE__; now just check to see if it is defined.Marshall Clow2013-03-181-1/+1
| | | | llvm-svn: 177297
* Patch by Andrew C. Morrow: Conditionally include cxxabi.h in new.cpp and ↵Howard Hinnant2012-07-261-1/+10
| | | | | | | | | | | | typeinfo.cpp. Both new.cpp and typeinfo.cpp have code that is conditionally compiled based on the LIBCXXRT and _LIBCPPABI_VERSION defines, but those files do not currently include <cxxabi.h> in the non __APPLE__ case. The attached patch updates those files so that for non __APPLE__ builds <cxxabi.h> is included if available or if LIBCXXRT is set. I'm modeling this on the recent updates to exception.cpp. llvm-svn: 160790
* Undo some overzealous #ifdefs for LIBCXXRT.David Chisnall2012-03-141-5/+2
| | | | llvm-svn: 152718
* Some libcxxrt-compatibility cleanups (avoid defining things twice).David Chisnall2012-02-291-2/+5
| | | | llvm-svn: 151717
OpenPOWER on IntegriCloud