Commit Graph

444 Commits

Author SHA1 Message Date
Eric Fiselier 71e329266a Fix non-reserved macro names LIBCXXABI_NORETURN and LIBCXXABI_ARM_EHABI.
This patch adds the required leading underscore to those macros.

llvm-svn: 296567
2017-03-01 02:23:54 +00:00
Ranjeet Singh b078439250 [libcxxabi] Fix condition typo in rL296136
Made a mistake in the condition typo because LIBCXXABI_BAREMETAL is always
defined, I should have been checking the contents to see if it's enabled.

Differential Revision: https://reviews.llvm.org/D30343

llvm-svn: 296146
2017-02-24 18:22:59 +00:00
Ranjeet Singh 4987856fbc [libcxxabi] Disable calls to fprintf for baremetal targets.
We've been having issues with using libcxxabi and libunwind for baremetal
targets because fprintf is dependent on io functions, this patch disables calls
to fprintf when building for baremetal in release mode.

Differential Revision: https://reviews.llvm.org/D30339

llvm-svn: 296136
2017-02-24 16:43:36 +00:00
Asiri Rathnayake d717ce580b Fix couple of test failures when using the LIBCXXABI_SILENT_TERMINATE mode.
When libcxxabi is built in LIBCXXABI_SILENT_TERMINATE mode, libcxx test suite reports
two failures:

  std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
  std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp

This is because the default unexpected handler is set to std::abort instead of
std::terminate which these tests expect.

llvm-svn: 295175
2017-02-15 13:43:05 +00:00
Petr Hosek ef6f231f56 [libcxxabi][CMake] Support in-tree libunwind when building as part of runtimes
When building as part of runtimes, there is no predefined order in
which the runtimes are loaded, so the targets from other projects
might not be available. We need to rely on HAVE_<name> variables
instead in that case.

Differential Revision: https://reviews.llvm.org/D29574

llvm-svn: 294552
2017-02-09 02:19:30 +00:00
David Bozier ec78fd11ca Add support for demangling C++11 thread_local variables. In clang, the grammar for mangling for these names are "<special-name> ::= TW <object name>" for wrapper variables or "<special-name> ::= TH <object name>" for initialization variables.
llvm-svn: 293638
2017-01-31 15:18:56 +00:00
Mehdi Amini 453ab3522b Fix ASAN failure in cxa_demangle
Found with ASAN + libFuzzer by Kostya Serebryany <kcc@google.com>

llvm-svn: 293330
2017-01-27 20:32:16 +00:00
Asiri Rathnayake 085b612c31 Fix chromium build (libcxxabi)
Pull the dependency on pthread_mach_thread_np() back into libcxxabi.

llvm-svn: 293166
2017-01-26 10:38:03 +00:00
Saleem Abdulrasool f5d26bb142 cxa_demangle: fix rvalue ref check
When checking if the type is a r-value ref, we would not do a complete
check.  This would result in us treating a trailing parameter reference
`&)` as a r-value ref, and improperly inject the cv qualifier on the
type.  We now correctly demangle the type `KFvRmE` as a constant
function rather than a constant reference.

Fixes PR31741!

llvm-svn: 292973
2017-01-24 19:57:05 +00:00
Saleem Abdulrasool 0c44db8f0a cxa_demangle: avoid butchering the last parameter type
Fix an off-by-one case which would destroy the final parameter in a
CV-qualified function type with a reference.  We still get the CV
qualification incorrect, but at least we do not clobber the type name
any longer.

Partially fixes PR31741.

llvm-svn: 292963
2017-01-24 18:42:56 +00:00
Jonathan Roelofs 8829e961e6 Revert r286788
The Itanium ABI [1] specifies that __cxa_demangle accept either:

   1) symbol names, which start with "_Z"
   2) type manglings, which do not start with "_Z"

r286788 erroneously assumes that it should only handle symbols, so this patch
reverts it and adds a counterexample to the testcase.

1: https://mentorembedded.github.io/cxx-abi/abi.html#demangler


Reviewers: zygoloid, EricWF
llvm-svn: 292418
2017-01-18 18:12:39 +00:00
James Y Knight 0d3145ff8d [libc++abi] Add a silent terminate handler to libcxxabi.
The current std::terminate_handler pulls in some string code, some I/O
code, and more. Since it is automatically setup as the default, this
means that any trivial binary linking against libcxxabi will get this
extra bloat.

This patch allows disabling it as a build-time option, if you want to
avoid the extra bloat.

Patch by Tom Rybka!

Reviewers: EricWF

Subscribers: danalbert, llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D28497

llvm-svn: 291946
2017-01-13 19:22:26 +00:00
Asiri Rathnayake a573fe25e6 [libcxxabi] Cleanup and adapt for r291275. NFC.
+ Now that libcxxabi shares the same threading API as libcxx, a whole
  chunk of code in src/config.h is made redundant (I missed this earlier).

+ r291275 split off the externalized-thread-api libcxx configuration from the
  external-thread-library libcxx configuration. libcxxabi should follow the
  same approach.

llvm-svn: 291440
2017-01-09 11:57:21 +00:00
Saleem Abdulrasool 51f0c20dc2 tweak definition to avoid GCC warning
Use an `extern "C" { }` block around the definition rather than doing
the inline definition.  This avoids a GCC warning about a declaration
being extern and having a definition.  NFC.

llvm-svn: 290937
2017-01-04 05:45:24 +00:00
Asiri Rathnayake 97ba9fae1f [libcxxabi] Introduce an externally threaded libc++abi variant.
r281179 Introduced an externally threaded variant of the libc++ library. This
patch adds support for a similar library variant for libc++abi.

Differential revision: https://reviews.llvm.org/D27575

Reviewers: EricWF
llvm-svn: 290888
2017-01-03 12:58:34 +00:00
Eric Fiselier 0afab98979 Fix new/delete exception specifications to match libc++ after r290845
llvm-svn: 290847
2017-01-03 00:16:18 +00:00
Saleem Abdulrasool 94865f9ab0 clean up `-Wmisleading-indentation` warning
Clean up the misleading indentation warning from GCC 6.  NFC

llvm-svn: 290788
2016-12-31 18:09:51 +00:00
Richard Smith 6afcab3588 Update implementation of ABI support for throwing noexcept function pointers
and catching as non-noexcept to match the final design per discusson on
cxx-abi-dev.

llvm-svn: 288457
2016-12-02 02:06:53 +00:00
Saleem Abdulrasool a03c489a41 __cxa_demangle: use default member initialization
Sink the Db initialization into the structure rather than out-of-line at the
declaration size.  This just makes it easier to see what initialization is being
performed.  NFC.

llvm-svn: 287364
2016-11-18 19:01:53 +00:00
Eric Fiselier e9c9f002d7 Rename TU names to not conflict with libc++.
In order to easily merge libc++ and libc++abi static archives it's important
that none of the source files share the same name.
(See http://stackoverflow.com/questions/3821916/how-to-merge-two-ar-static-libraries-into-one)

This patch renames source files which share a name with libc++ sources.

llvm-svn: 287327
2016-11-18 09:54:49 +00:00
Saleem Abdulrasool 4d7f90b064 __cxa_demangle: allow demangling invocation blocks
The block invocation function uses an extension where the prefix is ___Z
as opposed to _Z.  This should make the tests pass again.

Disable a negative test which was testing a crasher.  The symbol being
demangled is not a valid mangled symbol and will return a nullptr.

Adjust the type info decoding test to be a valid symbol name.

llvm-svn: 286793
2016-11-14 03:07:47 +00:00
Saleem Abdulrasool f13ad10208 __cxa_demangle: ensure that we have a mangled symbol
Ensure that we have a mangled symbol before attempting to demangle it.  We would
previously treat any input as a mangled symbol rather than checking that the
symbol has the initial C++ Itanium v3 mangling prefix of `_Z`.  This changes the
behaviour from the previous case which would undecorate `f` to `float` rather
than nullptr as it should.

Unfortunately, we do not have any negative testing for the demangler.

llvm-svn: 286788
2016-11-14 01:55:54 +00:00
Logan Chien 22012a5973 arm: Fix ttype encoding assertion failure.
GCC 4.7 or newer emits 0x90 (indirect | pcrel) as the ttype encoding.
This would hit an assertion in cxa_personality.cpp.  This commit fixes
the problem by relaxing the assertion.

llvm-svn: 286760
2016-11-13 14:44:41 +00:00
Richard Smith 80b64f0861 [p0012] Implement ABI support for throwing a noexcept function pointer and
catching as non-noexcept

This implements the following proposal from cxx-abi-dev:

http://sourcerytools.com/pipermail/cxx-abi-dev/2016-October/002988.html

... which is necessary for complete support of http://wg21.link/p0012,
specifically throwing noexcept function and member function pointers and
catching them as non-noexcept pointers.

Differential Review: https://reviews.llvm.org/D26178

llvm-svn: 285867
2016-11-02 23:41:51 +00:00
Eric Fiselier f6c4ab901b Get libc++abi building with LLVM_ENABLE_MODULES
llvm-svn: 285107
2016-10-25 20:07:49 +00:00
Vitaly Buka 5468832aca Fix typo in comment
llvm-svn: 284295
2016-10-15 00:02:20 +00:00
Vitaly Buka b8e9603acd Don't compile cxa_thread_atexit.cpp with -DLIBCXX_ENABLE_THREADS=OFF
Reviewers: rmaprath

Subscribers: beanz, mgorny

Differential Revision: https://reviews.llvm.org/D25636

llvm-svn: 284294
2016-10-14 23:51:41 +00:00
Asiri Rathnayake 0b357ed2ab [libcxxabi] Fix gcc build after r284128
NFC.

llvm-svn: 284141
2016-10-13 18:40:57 +00:00
Asiri Rathnayake 6d3ea6831d [libcxxabi] Refactor pthread usage into a separate API
This patch refactors all pthread uses of libc++abi into a separate API. This
is the first step towards supporting an externlly-threaded libc++abi library.

I've followed the conventions already used in the libc++ library for the same
purpose.

Patch from: Saleem Abdulrasool and Asiri Rathnayake

Reviewed by: compnerd, EricWF

Differential revisions:
  https://reviews.llvm.org/D18482 (original)
  https://reviews.llvm.org/D24864 (final)

llvm-svn: 284128
2016-10-13 15:05:19 +00:00
Eric Fiselier 829c0eab91 Provide a fallback __cxa_thread_atexit() implementation. Patch from Tavian Barnes
llvm-svn: 283988
2016-10-12 08:54:10 +00:00
Eric Fiselier fc1b0d5c24 [libc++abi] Fix bug which cased the static libunwind to always be chosen
llvm-svn: 283699
2016-10-09 20:44:48 +00:00
Igor Kudrin d9edde4ae2 Recommit r282692: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.
Throwing an exception for the first time may lead to call calloc to
allocate memory for __cxa_eh_globals. If the memory pool is exhausted
at that moment, it results in abnormal termination of the program.

This patch addresses the issue by using fallback_malloc in that case.

In this revision, some restrictions were added into the test to not
run it in unsuitable environments.

Differential Revision: https://reviews.llvm.org/D17815

llvm-svn: 283531
2016-10-07 08:48:28 +00:00
Igor Kudrin 49df799762 Revert r282692: Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.
The test breaks build bots.

llvm-svn: 282703
2016-09-29 08:11:57 +00:00
Igor Kudrin 962750b511 [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.
Throwing an exception for the first time may lead to call calloc to
allocate memory for __cxa_eh_globals. If the memory pool is exhausted
at that moment, it results in abnormal termination of the program.

This patch addresses the issue by using fallback_malloc in that case.

Differential Revision: https://reviews.llvm.org/D17815

llvm-svn: 282692
2016-09-29 06:38:06 +00:00
Saleem Abdulrasool 7ec747fe95 annotate more function visibility
These data and text symbols were missing annotations for building with hidden
visibility.  As we do not currently enable hidden visibility by default, this is
a NFC for the buildbots.

llvm-svn: 282300
2016-09-23 21:36:24 +00:00
Asiri Rathnayake 7c98baab29 [libcxxabi] cleanup the use of LIBCXXABI_HAS_NO_THREADS macro (NFC)
Align the naming / use of the macro LIBCXXABI_HAS_NO_THREADS to follow what we
have in libcxx. NFC.

llvm-svn: 282062
2016-09-21 09:09:32 +00:00
Saleem Abdulrasool 7c4700525c libc++abi: fix some -Wunused-function warnings
is_initialized is only used in the no threads case or if on non ARM Apple
targets.  Use the preprocessor to remove the function otherwise.  NFC.

llvm-svn: 280286
2016-08-31 20:29:05 +00:00
Logan Chien b2e620a23b Wrap LIBCXXABI_USE_LLVM_UNWINDER with defined().
This commit fixes -Wundef by replacing:

    #if !LIBCXXABI_USE_LLVM_UNWINDER

with:

    #if !defined(LIBCXXABI_USE_LLVM_UNWINDER)

llvm-svn: 280251
2016-08-31 15:16:40 +00:00
Eric Fiselier 36ca35f505 [CMake] Be more consistent about naming targets and components in libc++abi
This patch (and commit summary) mirror r279675 by Chris B which was applied
to libc++ but not libc++abi.

Summary:
The point of this patch is to have a consistent convention for naming build,
check and install targets so that the targets can be constructed from the
project name.

This change renames a bunch of CMake components and targets from libcxxabi to
cxxabi. For each renamed target I've added a convenience target that matches
the old target name and depends on the new target. This will preserve function
of the old targets so that the change doesn't break the world. We can evaluate
if it is worth removing the extra targets later.

llvm-svn: 279938
2016-08-28 18:28:51 +00:00
Eric Fiselier 4b3308c27f [CMake] Apply r279151 cleanup to libc++abi.
This patch applies changes similar to those in r279515 to libc++abi.

Summary of changes in this patch:

* Renamed variable LLVM_CONFIG -> LLVM_CONFIG_PATH
* Renamed variable LIBCXXABI_BUILT_STANDALONE -> LIBCXXABI_STANDALONE_BUILD
* Add an include of AddLLVM in the tests subdirectory for add_lit_testsuite.

llvm-svn: 279936
2016-08-28 18:16:18 +00:00
Mehdi Amini 4d03572c14 Fix ASAN failures in the demangler
These were found fuzzing with ASAN.

llvm-svn: 278579
2016-08-13 00:02:33 +00:00
Petr Hosek 8ec04577d6 Depend directly on unwind when not building standalone
When using libunwind and not building as standalone project, we
can directly depend on the unwind library target.

Differential Revision: https://reviews.llvm.org/D23289

llvm-svn: 278169
2016-08-09 21:28:52 +00:00
Petr Hosek b9a77f827d Add lib directory to linker paths when using libunwind
When using libunwind and not building as standalone project, we
need to add LLVM library directory to the list of linker directories
to ensure it can find libunwind dependency.

Differential Revision: https://reviews.llvm.org/D23287

llvm-svn: 278076
2016-08-09 00:27:19 +00:00
Richard Smith 2f984cab4f [libcxxabi] When catching an exception of type nullptr_t with a handler of
pointer-to-member type, produce a null value of the right type.

This fixes a bug where throwing an exception of type nullptr_t and catching it
as a pointer-to-member would not guarantee to produce a null value in the catch
handler. The fix is pretty simple: we statically allocate a constant null
pointer-to-data-member representation and a constant null
pointer-to-member-function representation, and produce the address of the
relevant value as the adjusted pointer for the exception.

llvm-svn: 276016
2016-07-19 20:19:37 +00:00
Asiri Rathnayake 57e446dafa [libcxxabi] Introduce a -fno-exceptions libc++abi libary variant
Currently there is only support for a -fno-exceptions libc++ build. This is
problematic for functions such as std::terminate() which are defined in
libc++abi and using any of those functions throws away most of the benefits
of using -fno-exceptions (code-size). This patch introduces a -fno-exceptions
libc++abi build to address this issue.

This new variant of libc++abi cannot be linked against any with-exceptions
code as some symbols necessary for handling exceptions are missing in this
library.

Differential revision: http://reviews.llvm.org/D20677

Reviewers: EricWF, mclow.lists, bcraig
llvm-svn: 271267
2016-05-31 12:01:32 +00:00
Saleem Abdulrasool 18ef564c8b libc++abi: build with -fvisibility=hidden
Enable building libc++abi with hidden visibility by default.  The ABI mandated
interfaces (and a few extra) are already set up to be externally visible.  This
allows us to ensure that any implementation details are not leaked.

llvm-svn: 270816
2016-05-26 02:12:20 +00:00
Saleem Abdulrasool f51af6c9cd libc++abi: make __cxa_call_unexpected visible
This may be invoked by the compiler, and needs to be made available so that the
users can reference it.

llvm-svn: 269255
2016-05-11 23:56:37 +00:00
Saleem Abdulrasool 7d5169b68d libc++abi: fix visibility of personalities
The personality routines need to be exposed to the users as the functions
reference the personality routine to handle exceptions.

llvm-svn: 268477
2016-05-04 04:22:29 +00:00
Ben Craig acd5ee88df [libcxxabi] Teach cxa_demangle about Hexagon's long double size
cxa_demangle's default size for a long double is 10 bytes. Hexagon
only has an 8 byte long double though.

llvm-svn: 258313
2016-01-20 14:10:23 +00:00
Eric Fiselier 6f630f800b Recommit r256322: Fix PR25898 - Check for incomplete pointers types in can_catch(...)
This patch re-commits r256322 and r256323. They were reverted due to a OS X
test failure. The test failure has been fixed by libc++ commit r258217.

This patch also adds some additional tests.

llvm-svn: 258249
2016-01-19 23:42:10 +00:00
Eric Fiselier 88c15c9d6f Revert r258222 because it's missing files. Will re-commit complete patch
llvm-svn: 258228
2016-01-19 23:40:49 +00:00
Eric Fiselier ccd5d8d801 Recommit r256322: Fix PR25898 - Check for incomplete pointers types in can_catch(...)
This patch re-commits r256322 and r256323. They were reverted due to a OS X
test failure. The test failure has been fixed by libc++ commit r258217.

This patch also adds some additional tests.

llvm-svn: 258222
2016-01-19 23:37:51 +00:00
Nico Weber 6977ee7f4c Revert r256322 (and follow-up 256323), the test it added does not pass on OS X.
llvm-svn: 257896
2016-01-15 15:44:14 +00:00
Dan Gohman d51bd8dd2e [WebAssembly] Accomodate wasm's 128-bit long double.
llvm-svn: 257614
2016-01-13 16:39:30 +00:00
Eric Fiselier 88b26886b2 Fix PR25898 - Check for incomplete pointers types in can_catch(...)
llvm-svn: 256322
2015-12-23 06:35:25 +00:00
Logan Chien 338d6de5fa Fix ARM __cxa_end_cleanup() and gc-sections.
This commit adds SHF_ALLOC and SHF_EXECINSTR section flags to
`.text.__cxa_end_cleanup` section.  This fixes a link error when we are
using integrated-as and `ld.gold` (with `-Wl,--gc-sections` and
`-Wl,--fatal-warnings`.)

Detailed Explanation:

1. There might be some problem with LLVM integrated-as.  It is not
   emitting any section flags for text sections.  (This will be fixed in
   an independent commit.)

2. `ld.gold` will skip the external symbols in the section without
   SHF_ALLOC.  This is the reason why `.text.__cxa_end_cleanup_impl`
   section is discarded even though it is referenced by
   `__cxa_end_cleanup()`.

This commit workaround the problem by specifying the section flags
explicitly.

Fix http://llvm.org/PR21292

llvm-svn: 256241
2015-12-22 14:38:30 +00:00
Eric Fiselier 3c9babc55f [libc++abi] Use libgcc and libgcc_s to provide _Unwind symbols instead of libgcc_eh.a
Summary:
libgcc_eh.a cannot be used when building libc++abi as a shared library (the default configuration). See this post for some more discussion: https://gcc.gnu.org/ml/gcc/2012-03/msg00104.html

This patch reverts back to using libgcc_s when linking libc++abi.so. 


Reviewers: danalbert, chandlerc, mclow.lists, ismail, compnerd

Subscribers: vkalintiris, cfe-commits

Differential Revision: http://reviews.llvm.org/D15440

llvm-svn: 255559
2015-12-14 22:20:04 +00:00
Saleem Abdulrasool 12315edf03 ibc++abi: mark visibility
Mark functions and types with the appropriate visibility.  This is particularly
useful for environments which explicitly indicate origin of functions (Windows).
This aids in generating libc++abi as a DSO which exposes only the public
interfaces.

llvm-svn: 254691
2015-12-04 02:14:58 +00:00
Saleem Abdulrasool 242d67b687 c++abi: whitespace adjustment
Cleanup some code with clang-format to make the following change easier to
identify material difference.  NFC.

llvm-svn: 254690
2015-12-04 02:14:41 +00:00
Saleem Abdulrasool e113b5e9af c++abi: use __builtin_offsetof instead of offsetof
Use `__builtin_offsetof` in place of `offsetof`.  Certain environments provide a
macro definition of `offsetof` which may end up causing issues.  This was
observed on Windows.  Use `__builtin_offsetof` to ensure correct evaluation
everywhere.  NFC.

llvm-svn: 253435
2015-11-18 05:33:38 +00:00
Marshall Clow 8ebfb60efa Fix Bug 25103 - _cxa_demangle improperly demangles virtual thunks. Thanks to Jason King for the report and suggested fix
llvm-svn: 250097
2015-10-12 20:45:05 +00:00
Marshall Clow a552480298 Fix incorrect parsing of arguments for nested functions. Reviewed as http://reviews.llvm.org/D13192. Thanks to Anseny Kapoulkine for the patch.
llvm-svn: 249649
2015-10-08 03:02:09 +00:00
Nico Weber 4a88f1ed71 Let cxa_demangle.cpp compile with gcc/libstdc++ 4.8 and clang-cl/MSVC2013's STL.
libstdc++ needs a few typedefs in malloc_alloc. MSVC's STL needs rebind(),
construct(), destroy().  MSVC2013 also has no snprintf, but it exists in 2015.

llvm-svn: 248129
2015-09-20 18:10:46 +00:00
Saleem Abdulrasool af99cd4174 EH: fix register usage for SjLj
When using SjLj EH, do not use __builtin_eh_return_regno, map directly to the
ID.  This would work on some targets, particularly those where the non-SjLj EH
personality used the same register mapping (0 -> 0, 1 -> 1).  However, this is
not guaranteed.  Avoiding the use of the builtin enables the use of libc++ with
SjLj EH on all targets.

llvm-svn: 248108
2015-09-20 02:08:31 +00:00
Eric Fiselier 2838c169a5 [libcxxabi] Add "install-libcxxabi" target.
Summary:
Currently you can't install libc++abi from within the LLVM tree without installing all of LLVM. This patch adds an install rule for libc++abi.


Reviewers: danalbert, compnerd, rengolin, beanz

Subscribers: martell, beanz, jroelofs, cfe-commits

Differential Revision: http://reviews.llvm.org/D11682

llvm-svn: 245461
2015-08-19 17:17:21 +00:00
Renato Golin 4b79ebceb4 [AArch64] Quick fix for cxa demangler
This makes all libcxxabi tests pass on AArch64. Further changes and
new tests to come.

Patch by Keith Walker.

llvm-svn: 245449
2015-08-19 15:24:03 +00:00
Daniel Sanders f8e6f4496b [libcxxabi][mips] Correct float_data::mangled_size for all ABI's.
Summary:
Patch by Nitesh Jain and Jaydeep Patil with a small revision to use ABIs rather
than Architecture Revisions (which currently imply particular ABIs).

Fixes test_demangle.pass.cpp (PR24149).

Subscribers: mclow.lists, jaydeep, nitesh.jain, hans, cfe-commits

Differential Revision: http://reviews.llvm.org/D11483

llvm-svn: 243645
2015-07-30 16:11:04 +00:00
Logan Chien ac1d84ebb1 Remove include directive for the unused libunwind_ext.h.
llvm-svn: 241993
2015-07-12 14:47:53 +00:00
Saleem Abdulrasool 8d5ab875f6 fallback_malloc: silence conversion warning (NFC)
This silences some conversion warnings from GCC 4.9.2.  Simply casting the RHS
doesn't seem to be sufficient to silence the warning.  Convert the operation
equal operator usage to calculation and assignment.

llvm-svn: 238945
2015-06-03 17:25:35 +00:00
Saleem Abdulrasool fcdcf1b1e9 fallback_malloc: silence qual-cast warning (NFC)
This silences a GCC 4.9.2 qual-cast warning in the fallback_malloc codepath.
NFC.

llvm-svn: 238944
2015-06-03 17:25:33 +00:00
Marshall Clow 604de5c256 Implement uncaught_exceptions() to get a count, rather than a bool. Update the libc++abi version. Reviewed as http://reviews.llvm.org/D10067
llvm-svn: 238827
2015-06-02 13:03:17 +00:00
Logan Chien bbb4b1ca25 libcxx: Switch to use __gnu_unwind_frame() for libunwind.
As a step to fix libunwind unw_step(), a new function
__gnu_unwind_frame() has been introduced to libunwind, and it is
required to use this function so that some libunwind internal data
structure can be updated properly.

llvm-svn: 238561
2015-05-29 15:34:24 +00:00
Chaoren Lin 3abb86da62 Make sure !empty() before calling String::front().
Reviewers: howard.hinnant

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D9954

llvm-svn: 238263
2015-05-26 23:14:26 +00:00
Eric Fiselier 65ace9daa3 Disallow conversions from function pointers to void*.
Function pointers and member function pointers cannot be converted to void*.
libc++abi incorrectly allows this conversion for function pointers.

Review URL: http://reviews.llvm.org/D8811

llvm-svn: 236299
2015-05-01 01:49:37 +00:00
Saleem Abdulrasool 03b487bf19 libc++abi: work around layering violation
This papers over a layering violation currently between libc++abi and libunwind.
It reaches into the sources to get the declaration of an ABI defined function.
This should allow the ARM buildbot to continue building libc++abi again.

llvm-svn: 235965
2015-04-28 02:52:47 +00:00
Saleem Abdulrasool 7c5d5ac831 libc++abi: remove unused variable
The externC variable was set but unused.  This constantly flagged a warning from
gcc.  Replace it with a comment until such a time that we need it.

llvm-svn: 235830
2015-04-27 02:21:57 +00:00
Saleem Abdulrasool a49aa027c1 libc++abi: clear up some -Wqual-cast warnings
Cleans up cast qualifier warnings identified by GCC 4.9.2.

llvm-svn: 235829
2015-04-27 02:21:55 +00:00
Saleem Abdulrasool 91aef804b1 libc++abi: silence some warnings
Cleans up the -Wundef warning caused by the use of the __LITTLE_ENDIAN__ macro.
Instead use `__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__`.  `__BYTE_ORDER__` is
defined by GCC since 4.2 and by clang.  This avoids the undef case where a macro
may be undefined.  This has previously caught real errors in libunwind.

llvm-svn: 235828
2015-04-27 02:21:52 +00:00
Saleem Abdulrasool a01b1afad4 libc++abi: remove the duplicated unwind content
The unwinder has been moved into its own project setup at
http://svn.llvm.org/projects/libunwind/trunk.  This simply removes the now
duplicated content.  This move was previously discussed on llvmdev at [1].

[1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-January/081507.html

llvm-svn: 235759
2015-04-24 19:40:31 +00:00
Reid Kleckner fa990f0338 Declare __cxa_new_handler as extern "C", or it declares a new variable
Reverts change from r219012 to fix ABI incompatibility. Let's not worry
about the GCC warning here.

llvm-svn: 235013
2015-04-15 15:35:56 +00:00
Eric Fiselier b6030b9dbf [libcxxabi] Disallow Base to Derived conversions for catching pointers to members.
Summary:
I accidentally implemented the 4.11 [conv.mem] conversions for libc++abi in a recent patch. @majnemer pointed out that 5.13 [except.handle] only allows the pointer conversions in 4.10 and not those is 4.11. This patch no longer allows the following example code:

```c++
struct A {};
struct B : public A {};

int main() {
  try {
    throw (int A::*)0;
  } catch (int B::*) {
    // exception caught here.
  }
}
```

Reviewers: mclow.lists, jroelofs, majnemer

Reviewed By: majnemer

Subscribers: majnemer, cfe-commits

Differential Revision: http://reviews.llvm.org/D8845

llvm-svn: 234254
2015-04-06 23:03:01 +00:00
Eric Fiselier 1b00fc5d81 [libcxxabi] Fix multi-level pointer conversions and pointer to member conversion detection.
Summary:
Currently there are bugs in out detection of multi-level pointer conversions and pointer to member conversions. This patch fixes the following issues.

* Allow multi-level pointers with different nested qualifiers.
* Allow multi-level mixed pointers to objects and pointers to members with different nested qualifiers.
* Allow conversions from `int Base::*` to `int Derived::*` but only for non-nested pointers.

There is still some work that needs to be done to clean this patch up but I want to get some input on it.
Open questions:

* Does `__pointer_to_member_type_info::can_catch(...)` need to adjust the pointer if a base to derived conversion is performed?


Reviewers: danalbert, compnerd, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D8758

llvm-svn: 233984
2015-04-02 23:26:37 +00:00
Ed Schouten 25a624e43d Also use dl_iterate_phdr() on CloudABI.
The unwinder now works on CloudABI. All exception-related libc++ tests
now pass.

This change was actually part of D8169, which also adds support for
FreeBSD. That, however, still requires some more polishing.

llvm-svn: 233676
2015-03-31 07:59:53 +00:00
Ed Schouten d0c480b04c Don't print debugging messages to stdout.
There is some debugging code in cxa_demangle.cpp that prints messages on
stdout. In general this is not safe, as the program itself may use
stdout to write its output. Change this code to write to stderr.

Differential Revision:	http://reviews.llvm.org/D8167

llvm-svn: 232716
2015-03-19 09:17:21 +00:00
Eric Fiselier fe2f1f095f Remove unneeded const_cast in readPointerHelper. Pointed out by jroelofs
llvm-svn: 231852
2015-03-10 21:32:53 +00:00
Eric Fiselier e6cdf34116 [libcxx] Fix PR21580 - Undefined behavior in readEncodedPointer()
Summary: This patch fixes a bug in `readEncodedPointer()` where it would read from memory that was not suitably aligned. This patch fixes it by using memcpy.

Reviewers: danalbert, echristo, compnerd, mclow.lists

Reviewed By: compnerd, mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D8179

llvm-svn: 231839
2015-03-10 20:43:34 +00:00
Saleem Abdulrasool 762ff68a95 Unwind: define more interfaces more often
These are also part of the Unwind interfaces.  However, their implementation is
different in EHABI vs frame tables based exception handling.  Always provide a
definition.  This partially undoes a movement change from earlier to make the
handling a bit simpler rather than grouping the two implementations together.

llvm-svn: 231690
2015-03-09 19:35:12 +00:00
Saleem Abdulrasool d9e577933b Unwind: always define unwind APIs
These interfaces are not zero cost related, but rather generic unwind APIs used
by consumers of the Unwind library.  Always provide the definition as they are
needed for both Zero Cost and Frame Table based implementations.

llvm-svn: 231666
2015-03-09 16:46:43 +00:00
Saleem Abdulrasool a99e152e80 Unwind: remove unnecessary check
Linux/GNU on AArch64 EH ABI Level III is implemented using exception frame
tables as defined in LSB II.11.6.  The exception frame tables use the DWARF
Exception Header Encoding as described in LSB II.11.5.1.  We already defined the
appropriate definition _LIBUNWIND_SUPPORT_DWARF_UNWIND to enable this.

llvm-svn: 231580
2015-03-07 22:21:31 +00:00
Saleem Abdulrasool af7e539595 Unwind: tweak register handling for AArch64
AArch64 uses // as the comment character (although, Darwin uses ;).  However,
since we are using the C preprocessor on these files, // can be used as the
comment character across the board.

Tweak the platform guard to recognise __aarch64__ as well as __arm64__ for the
platform identifier.

llvm-svn: 231578
2015-03-07 21:36:08 +00:00
Nick Lewycky 5b2d125c92 Fix build with GCC:
- GCC doesn't support #pragma mark, only Apple GCC and clang. Wrap the pragma mark's in #if 0 to make gcc ignore them but xcode still see them.
 - Wrap a bunch of "#pragma clang" lines in #ifdef __clang__.
 - Pacify gcc's -Wparenthesis in a case where it's quite reasonable.

llvm-svn: 231344
2015-03-05 02:56:05 +00:00
Eric Fiselier 14dbeaadc1 [libcxxabi] Build both static and shared versions of libc++abi by default.
Summary:
This patch builds both static and shared versions of libc++abi by default. It adds/repurposes the following cmake options:
* `LIBCXXABI_ENABLE_SHARED`: Enable/disable building the shared library. (Previously using `OFF` would build the static library instead)
* `LIBCXXABI_ENABLE_STATIC`: Enable/disable building the static library.

This patch also re-purposes the CMake target `cxxabi` to be a meta-target for `cxxabi_shared` and `cxxabi_static`. This could potentially break other builds that depend on `cxxabi` being a library target. We will need to apply a patch to libc++'s CMake before committing this change. 

Running the tests is still only supported when the shared version is built. Support for running the tests against the static library will come in another patch.


Reviewers: jroelofs, mclow.lists, danalbert, compnerd

Reviewed By: danalbert, compnerd

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D8013

llvm-svn: 231075
2015-03-03 15:59:09 +00:00
Saleem Abdulrasool 48205982a3 Unwind: make it build on Darwin again
The support for the LSB eh_frame_hdr extension was overzealous in trying to
include headers.  Be more careful to permit building on Darwin.

llvm-svn: 230837
2015-02-28 02:23:54 +00:00
Dan Albert 198d366fad Add .eh_frame_hdr search to Linux unwinder.
This improves the performance of unwinding on DWARF based targets. The
32-bit x86 support for scanning the full eh_frame
(CFI_Parser::findFDE) apparently does not work (at least not on
Linux). Since the eh_frame_hdr code delegates to that, this still
doesn't work for x86 Linux, but it has been tested on x86_64 Linux and
aarch64 Android.

llvm-svn: 230802
2015-02-27 22:21:07 +00:00
Saleem Abdulrasool bd04c44f48 Unwind: clean up some GCC warnings
This cleans up a set of -Wsign-conversion, -Wint-conversion, and -Wformat
warnings from GCC 4.9.2 on Linux.  NFC.

llvm-svn: 230606
2015-02-26 04:01:37 +00:00
Jonathan Roelofs ea163d9fa8 Add .fpu directives to ARM unwind save & restore functions.
TODO: The iwmmx register save & restore functions still need the same treatment.
      I didn't do that in this patch because the integrated assembler has a bug
      where it refuses to build them on -march=armv6-m, even with
         .march armv5t
         .arm
      in front of those functions.

This should fix PR22384.

http://reviews.llvm.org/D7258

llvm-svn: 230360
2015-02-24 20:09:29 +00:00
Sergey Dmitrouk 0aa66cf8f8 Do not add -fno-exceptions without -funwind-tables
Adding just -fno-exceptions breaks libunwind in quite mysterious way
when it's there, but exception handling doesn't work because of dummy
unwind tables.

Also as using exceptions implies references to symbols defined in
libcxx, abort build of libcxxabi as shared library if we have to keep
exceptions (when compiler supports -fno-exceptions, but not
-funwind-tables; one example would be a cross-compiler, in which case
testing for -funwind-tables flag by CMake actually requires libunwind to
be available before it's built).

llvm-svn: 229427
2015-02-16 19:51:06 +00:00
Jonathan Roelofs d76078f81b Moar post-commit review.
Apparently typing is hard.

llvm-svn: 229216
2015-02-14 02:02:56 +00:00
Jonathan Roelofs bb755d614a Address post-commit review comments
llvm-svn: 229207
2015-02-14 01:38:35 +00:00
Jonathan Roelofs c1d025fb61 Make the unwinder build on thumbv6-m with the integrated assembler.
http://reviews.llvm.org/D7630

llvm-svn: 229194
2015-02-14 00:21:03 +00:00