aboutsummaryrefslogtreecommitdiff
path: root/libcxx/src/exception.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-08-27[libc++] Deprecate and remove std::uncaught_exception (#101830)A. Jiang1-0/+3
Works towards P0619R4/#99985. - std::uncaught_exception was not previously deprecated. This patch deprecates it since C++17 as per N4259. std::uncaught_exceptions is used instead as libc++ unconditionally provides this function. - _LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION restores std::uncaught_exception. - As a drive-by, this patch updates the C++20 status page to explain that D.11 is already done, since it was done in 578d09c1b195d859ca7e62840ff6bb83421a77b5.
2023-12-18[libc++] Format the code base (#74334)Louis Dionne1-14/+14
This patch runs clang-format on all of libcxx/include and libcxx/src, in accordance with the RFC discussed at [1]. Follow-up patches will format the benchmarks, the test suite and remaining parts of the code. I'm splitting this one into its own patch so the diff is a bit easier to review. This patch was generated with: find libcxx/include libcxx/src -type f \ | grep -v 'module.modulemap.in' \ | grep -v 'CMakeLists.txt' \ | grep -v 'README.txt' \ | grep -v 'libcxx.imp' \ | grep -v '__config_site.in' \ | xargs clang-format -i A Git merge driver is available in libcxx/utils/clang-format-merge-driver.sh to help resolve merge and rebase issues across these formatting changes. [1]: https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
2022-02-15[libc++] Replace `#include ""` with `<>` in libcxx/src/. NFCI.Arthur O'Dwyer1-3/+3
Our best guess is that the two syntaxes should have exactly equivalent effects, so, let's be consistent with what we do in libcxx/include/. I've left `#include "include/x.h"` and `#include "../y.h"` alone because I'm less sure that they're interchangeable, and they aren't inconsistent with libcxx/include/ because libcxx/include/ never does that kind of thing. Also, use the `_LIBCPP_PUSH_MACROS/POP_MACROS` dance for `<__undef_macros>`, even though it's technically unnecessary in a standalone .cpp file, just so we have consistently one way to do it. Differential Revision: https://reviews.llvm.org/D119561
2021-11-17[runtimes][NFC] Remove filenames at the top of the license noticeLouis Dionne1-1/+1
We've stopped doing it in libc++ for a while now because these names would end up rotting as we move things around and copy/paste stuff. This cleans up all the existing files so as to stop the spreading as people copy-paste headers around.
2019-04-23[libc++] Remove redundant conditionals for Apple platformsLouis Dionne1-2/+1
Summary: In a bunch of places, we used to check whether LIBCXX_BUILDING_LIBCXXABI is defined OR we're building for an Apple platform. This used to be necessary in a time when Apple's build script did NOT define LIBCXX_BUILDING_LIBCXXABI. However this is not relevant anymore since Apple's build does define LIBCXX_BUILDING_LIBCXXABI. Reviewers: EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D60842 llvm-svn: 358988
2019-01-19Update more file headers across all of the LLVM projects in the monorepoChandler Carruth1-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
2017-09-19[libc++] Replace __sync_* functions with __libcpp_atomic_* functionsWeiming Zhao1-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
2017-05-08[libc++] Implement exception_ptr on WindowsEric Fiselier1-1/+1
Summary: This patch implements exception_ptr on Windows using the `__ExceptionPtrFoo` functions provided by MSVC. The `__ExceptionPtrFoo` functions are defined inside the C++ standard library, `msvcprt`, which is unfortunate because it requires libc++ to link to the MSVC STL. However this doesn't seem to cause any immediate problems. However to be safe I kept all usages within the libc++ dylib so that user programs wouldn't have to link to MSVCPRT as well. Note there are still 2 outstanding exception_ptr/nested_exception test failures. * `current_exception.pass.cpp` needs to be rewritten for the Windows exception_ptr semantics which copy the exception every time. * `rethrow_if_nested.pass.cpp` need investigation. It hits a stack overflow, likely from recursion. This patch also gets most of the `<future>` tests passing as well. Reviewers: mclow.lists, compnerd, bcraig, rmaprath, majnemer, BillyONeal, STL_MSFT Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D32927 llvm-svn: 302393
2017-02-10Recommit "Split exception.cpp and new.cpp implementation into different ↵Eric Fiselier1-312/+15
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
2017-02-10Revert "Split exception.cpp and new.cpp implementation into different files ↵Eric Fiselier1-14/+312
for different runtimes." The compiler-rt CMake configuration needs some tweaking before this can land. llvm-svn: 294727
2017-02-10Split exception.cpp and new.cpp implementation into different files for ↵Eric Fiselier1-312/+14
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
2017-02-06Refer to _LIBCPP_MSVC macro where applicableSaleem Abdulrasool1-6/+6
Replace preprocess conditions of defined(_MSC_VER) && !defined(__clang__) with defined(_LIBCPP_MSVC). NFC. Patch by Dave Lee! llvm-svn: 294171
2017-01-07[libc++] Implement terminate(), unexpected() and uncaught_exceptions() on ↵Eric Fiselier1-6/+28
Windows Summary: This patch implements the following functions on Windows by forwarding to the MSVCRT: * `get_terminate()` * `set_terminate()` * `terminate()` * `set_unexpected()` * `get_unexpected()` * `unexpected()` * `uncaught_exception()` * `uncaught_exceptions()` Reviewers: compnerd, rnk, majnemer, smeenai Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28442 llvm-svn: 291343
2017-01-03Recommit r290839 - Fix configuring and building libc++ w/o an ABI library.Eric Fiselier1-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
2017-01-02Revert r290839 - Fix configuring and building libc++ w/o an ABI libraryEric Fiselier1-4/+2
llvm-svn: 290841
2017-01-02Fix configuring and building libc++ w/o an ABI library.Eric Fiselier1-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
2016-09-28Mark libc++ internal globals with _LIBCPP_SAFE_STATIC.Eric Fiselier1-2/+2
This patch applies the _LIBCPP_SAFE_STATIC attribute to internal globals, most of which are locking primitives, in order to ensure that they can safely be used during program startup. This patch also fixes an unsafe static init issue with the global locks used to implement atomic operations on shared pointers. Previously the locks were initialized using a dynamically initialized pointer, so it was possible that the pointer was uninitialized. llvm-svn: 282640
2015-10-16Remove a long-standing __has_include hack.Benjamin Kramer1-7/+3
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
2015-06-02Move uncaught_exeption() definition inside the #ifdef block like ↵Marshall Clow1-1/+1
uncaught_exceptions() llvm-svn: 238879
2015-06-02Implement uncaught_exceptions() using the newly added hooks in libc++abi, ↵Marshall Clow1-5/+11
when available llvm-svn: 238846
2015-05-20Fix building and testing libc++ with GCC.Eric Fiselier1-1/+1
The changes in src/exception.cpp and cmake/Modules/HandleLibCXXABI.cmake fix a bug when building libc++ with GCC. Because GCC does not support __has_include we need to explicitly tell it that we are building against libc++abi via the preprocessor definition `LIBCXX_BUILDING_LIBCXXABI`. The changes in include/ratio are to work around CWG defect 1712 (constexpr variable template declarations). GCC 4.8 and before has not adopted the resolution to this defect. The changes in include/exception work around an issue where is_final is used without it being defined in type_traits. llvm-svn: 237767
2015-03-10Print log/error messages on stderr, not stdoutEd Schouten1-8/+8
There are a couple of places where libc++ prints log/error messages to stdout on its own. This may of course interfere with the output generated with applications. Log/error messages should be directed to stderr instead. Differential Revision: http://reviews.llvm.org/D8135 Reviewed by: marshall llvm-svn: 231767
2014-11-01Partial fix for building w/ libcxxrt on OSX. Patch from C Bergstrom.Eric Fiselier1-1/+1
llvm-svn: 221029
2013-11-19Patch by Bruce Mitchener. Change all references to EMSCRIPTEN to ↵Marshall Clow1-3/+3
__EMSCRIPTEN__. If you're not using the PP symbol EMSCRIPTEN, then you should see no functionality change. llvm-svn: 195136
2013-11-11Patch from Bruce Mitchener; fixes two typos in comments. No functionality ↵Marshall Clow1-1/+1
change. PR17843 llvm-svn: 194432
2013-10-06Silence the unused function warning in exception.cpp.Peter Collingbourne1-17/+16
Rather than try to protect the function behind a precise, ever-changing #if expression, just inline it into every caller. llvm-svn: 192077
2013-10-06Implement std::exception_ptr under libsupc++.Peter Collingbourne1-12/+51
libsupc++ does not implement the dependent EH ABI and the functionality it uses to implement std::exception_ptr (which it declares as an alias of std::__exception_ptr::exception_ptr) is not directly exported to clients. So we have little choice but to hijack std::__exception_ptr::exception_ptr's (which fortunately has the same layout as our std::exception_ptr) copy constructor, assignment operator and destructor (which are part of its stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr) function. Also, remove some out of date comments. Differential Revision: http://llvm-reviews.chandlerc.com/D1826 llvm-svn: 192076
2013-10-06Eliminate more symbols multiply defined between libsupc++ and libc++.Peter Collingbourne1-0/+4
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
2013-10-04G M: Provides the _LIBCPP_WARNING macro, to be used for MSVC only, since ↵Howard Hinnant1-22/+52
that compiler doesn't support #warning. llvm-svn: 191980
2013-07-23Add some friendly messages to libcxx calls to abort().Howard Hinnant1-0/+9
llvm-svn: 186951
2013-03-29Bruce Mitchener, Jr.: Port to emscripten. Fixes ↵Howard Hinnant1-1/+3
http://llvm.org/bugs/show_bug.cgi?id=15624. llvm-svn: 178354
2013-03-18Removed raw references to __APPLE__; now just check to see if it is defined.Marshall Clow1-2/+2
llvm-svn: 177297
2013-01-22Saleem Abdulrasool: __terminate_handler and __unexpected_handler are defined ↵Howard Hinnant1-1/+1
but not used when building against libsupc++ as the functions for which they are used are provided by libsupc++. Simply preprocess them away when building against libsupc++. llvm-svn: 173165
2012-11-30[CMake] Add support for selecting which c++ abi library to use.Michael J. Spencer1-3/+3
llvm-svn: 169036
2012-07-26libc++: switch from using _ATTRIBUTE(noreturn) (which conflicts with aRichard Smith1-4/+4
platform-provided macro on some systems) to _LIBCPP_NORETURN. llvm-svn: 160773
2012-07-11Teach libc++ to check for libc++abi and use its features if they're available.Richard Smith1-8/+11
llvm-svn: 160038
2012-03-14Undo some overzealous #ifdefs for LIBCXXRT.David Chisnall1-5/+9
llvm-svn: 152718
2012-02-29I'm reverting one of the changes made to exception.cpp in r151717. I'm ↵Howard Hinnant1-0/+4
unsure what the change was trying to do, but it didn't do the right thing for __APPLE__. So instead of trying to guess what was intended, I'm just putting it back the way it was. llvm-svn: 151727
2012-02-29Some libcxxrt-compatibility cleanups (avoid defining things twice).David Chisnall1-27/+25
llvm-svn: 151717
2012-02-03Make attributes on definition consistent with those on declaration.Howard Hinnant1-0/+1
llvm-svn: 149701
2012-02-02Prepare for running on top of new libc++abi.Howard Hinnant1-9/+17
llvm-svn: 149634
2011-09-21Correct change to exception.cpp from r140245Howard Hinnant1-1/+1
llvm-svn: 140253
2011-09-21Fixes for FreeBSD, including some fairly obvious copy-and-paste errors.David Chisnall1-14/+23
libc++ now mostly works on FreeBSD with libcxxrt and this patch applied to the base system: http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20110920/e666632c/xlocale-0001.obj Summary of tests on FreeBSD: **************************************************** Results for /root/libcxx/test: using FreeBSD clang version 3.0 (trunk 135360) 20110717 Target: x86_64-unknown-freebsd9.0 Thread model: posix with -std=c++0x -stdlib=libc++ -I/root/libcxx/include -L/root/libcxx/build/lib ---------------------------------------------------- sections without tests : 1 sections with failures : 48 sections without failures: 1015 + ---- total number of sections : 1064 ---------------------------------------------------- number of tests failed : 145 number of tests passed : 4179 + ---- total number of tests : 4324 **************************************************** (Many due to this clang version not supporting C++ atomics) More fixes to follow... llvm-svn: 140245
2011-07-29Configure to get along with 2.9 clangHoward Hinnant1-0/+1
llvm-svn: 136526
2011-05-26Applied noexcept to everything in [language.support] (Chapter 18)Howard Hinnant1-15/+15
llvm-svn: 132129
2011-05-26Added [[noreturn]] attribute everywhere it should beHoward Hinnant1-2/+4
llvm-svn: 132125
2010-12-06Add a couple more std-qualifers.Howard Hinnant1-2/+2
llvm-svn: 121002
2010-12-04Fix up uses of new/terminate/unexpected handlers to use the new getters.Howard Hinnant1-2/+2
llvm-svn: 120914
2010-12-02N3189 Observers for the three handler functionsHoward Hinnant1-6/+14
llvm-svn: 120712
2010-11-16license changeHoward Hinnant1-2/+2
llvm-svn: 119395