Commit Graph

1066 Commits

Author SHA1 Message Date
Martin Storsjo 9b60b9289c Add missing _LIBCXXABI_FUNC_VIS to __gxx_personality_seh0
This was missed in SVN r337754.

llvm-svn: 339503
2018-08-11 19:36:06 +00:00
Erik Pilkington 90dc82e955 [itanium demangler] Support dot suffixes on block invocation functions
rdar://32378759

llvm-svn: 338747
2018-08-02 17:45:01 +00:00
Hans Wennborg f2eafcc816 Update version to 8.0.0svn
llvm-svn: 338564
2018-08-01 14:25:03 +00:00
Louis Dionne c8e84ff251 [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since _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
2018-08-01 02:08:59 +00:00
Erik Pilkington 256db4b799 [demangler] Fix an oss-fuzz bug from r338138
Stack overflow on invalid. While collapsing references, we were skipping over a
cycle check in ForwardTemplateReference leading to a stack overflow. This commit
fixes the problem by duplicating the cycle check in ReferenceType.

llvm-svn: 338190
2018-07-28 04:06:30 +00:00
Erik Pilkington 3a6fed4a7b [demangler] Support for reference collapsing
llvm.org/PR38323

llvm-svn: 338138
2018-07-27 17:27:40 +00:00
Sam Clegg 77c99ee5d9 [CMake] Don't use LIBCXXABI_ENABLE_STATIC option before its declared
Summary:
rL337867 introduced two new cmake_dependent_option options:
- LIBCXXABI_INSTALL_STATIC_LIBRARY
- LIBCXXABI_INSTALL_SHARED_LIBRARY

They depend on LIBCXXABI_ENABLE_STATIC and LIBCXXABI_ENABLE_SHARED
and so therefore need to (it seems) come after the declaration of
these two options.

Subscribers: mgorny, aheejin, christof, ldionne, cfe-commits

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

llvm-svn: 337982
2018-07-25 23:13:00 +00:00
Petr Hosek cbb4313b1c [CMake] Use LIBCXXABI_LIBDIR_SUFFIX in libc++abi build
This was changed unintentionally in r335809.

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

llvm-svn: 337937
2018-07-25 16:51:00 +00:00
Eric Fiselier a596ea5842 Fix dangling reference in test
llvm-svn: 337906
2018-07-25 11:19:13 +00:00
Petr Hosek 4a1e14ea78 [CMake] Option to control whether shared/static library is installed
Currently it's only possible to control whether shared or static library
build of libc++, libc++abi and libunwind is enabled or disabled and
whether to install everything we've built or not. However, it'd be
useful to have more fine grained control, e.g. when static libraries are
merged together into libc++.a we don't need to install libc++abi.a and
libunwind.a. This change adds this option.

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

llvm-svn: 337867
2018-07-24 23:27:51 +00:00
Petr Hosek 058c04c3dd Reland "[CMake] Support statically linking dependencies only to shared or static library"
This is a reland of commit r337668.

llvm-svn: 337814
2018-07-24 07:06:17 +00:00
Erik Pilkington 28e08a0a61 [demangler] call terminate() if allocation failed
We really should set *status to memory_alloc_failure, but we need to refactor
the demangler a bit to properly propagate the failure up the stack. Until then,
its better to explicitly terminate then rely on a null dereference crash.

rdar://31240372

llvm-svn: 337759
2018-07-23 22:23:04 +00:00
Martin Storsjo 64142ba98b Implement a GCC compatible SEH unwinding personality, __gxx_personality_seh0
This allows handling SEH based exceptions, with unwind functions
provided by libgcc.

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

llvm-svn: 337754
2018-07-23 22:09:23 +00:00
Petr Hosek 781ee0bc5a Revert "[CMake] Support statically linking dependencies only to shared or static library"
This reverts commit r337668: broke the cxxabi build when using Make.

llvm-svn: 337670
2018-07-23 05:07:44 +00:00
Petr Hosek 7a0295cbc8 [CMake] Support statically linking dependencies only to shared or static library
Currently it's possible to select whether to statically link unwinder
or the C++ ABI library, but this option applies to both the shared
and static library. However, in some scenarios it may be desirable to
only statically link unwinder and C++ ABI library into static C++
library since for shared C++ library we can rely on dynamic linking
and linker scripts. This change enables selectively enabling or
disabling statically linking only to shared or static library.

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

llvm-svn: 337668
2018-07-23 04:19:55 +00:00
Eric Fiselier 6fa95b8787 Add GCC 9 to XFAILs list for test
llvm-svn: 337662
2018-07-22 21:58:46 +00:00
Zachary Turner 0e3fbf6b8b Merge changes to ItaniumDemangle over to libcxxabi.
ItaniumDemangle had a small NFC refactor to make some of its
code reusable by the newly added Microsoft demangler.  To keep
the libcxxabi demangler as close as possible to the master copy
this refactor is being merged over.

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

llvm-svn: 337582
2018-07-20 17:16:49 +00:00
Petr Hosek 6aae861e0e [CMake] Set per-runtime library directory suffix in runtimes build
Do not use LLVM_RUNTIMES_LIBDIR_SUFFIX variable which is an internal
variable used by the runtimes build from individual runtimes, instead
set per-runtime librarhy directory suffix variable which is necessary
for the sanitized runtimes build to install libraries into correct
location.

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

llvm-svn: 336713
2018-07-10 19:13:33 +00:00
Serge Pavlov 2f17e969e4 [demangler] Avoid alignment warning
The alignment specified by a constant for the field
`BumpPointerAllocator::InitialBuffer` exceeded the alignment
guaranteed by `malloc` and `new` on Windows. This change set
the alignment value to that of `long double`, which is defined
by the used platform.

It fixes https://bugs.llvm.org/show_bug.cgi?id=37944.

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

llvm-svn: 336312
2018-07-05 06:24:29 +00:00
Erik Pilkington 988a16af92 Revert r336159, r336157. Some bots failed on qualified std::max_align_t, and other on unqualified max_align_t.
I'll take another stab at this tomorrow. Any ideas for fixing this would be appreciated!

http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/23071/steps/build_Lld/logs/stdio
http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/11185/steps/build-stage1-compiler/logs/stdio

llvm-svn: 336162
2018-07-03 01:30:53 +00:00
Erik Pilkington 0409a8ade7 Some buildbots were choking on std::max_align_t, try using the global alias.
llvm-svn: 336159
2018-07-03 00:48:27 +00:00
Erik Pilkington d26ace3955 [demangler] Fix a MSVC alignment warning.
This should fix llvm.org/PR37944

llvm-svn: 336157
2018-07-03 00:23:18 +00:00
Shoaib Meenai 51d5cc9228 [libc++abi] Look for __config instead of vector
vector is a generic C++ header, whereas __config is libc++-specific, so
we can look for it instead to guarantee we're finding a libc++
installation. This was suggested by Eric in https://reviews.llvm.org/D48694.

This is less important now that we're limiting the header search to the
specified directories (which definitely shouldn't have any other C++
library's headers anyway), but it shouldn't hurt either. There's a
chance some other library could also be providing a __config header, so
there's still a trade-off there. It would be ideal if we could check for
the presence of both __config and vector in the same directory, but
there doesn't seem to be any easy way to do that in CMake.

llvm-svn: 336034
2018-06-30 01:25:47 +00:00
Shoaib Meenai 777ec37659 [libc++abi] Limit libc++ header search to specified paths
Right now, when libc++abi is locating libc++ headers, it specifies
several search locations, but it also doesn't prevent CMake from looking
for those headers in system directories. I don't know if this was
intentional or an oversight, but it has several issues:

* We're looking specifically for the vector header, which could just as
  easily be found in a libstdc++ (or other C++ library) installation.
* No system I know of places their C++ headers directly in system
  include directories (they're always under a C++ subdirectory), so the
  system search will never succeed.
* find_path searches system paths before the user-specified PATHS, so
  if some system does happen to have C++ headers in its system include
  directories, those headers will be preferred, which doesn't seem
  desirable.

It makes sense to me to limit this header search to the explicitly
specified paths (using NO_DEFAULT_PATH, as is done for the other
find_path call in this file), but I'm putting it up for review in case
there's some use case I'm not thinking of.

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

llvm-svn: 336032
2018-06-30 01:04:50 +00:00
Petr Hosek 887f26d470 Support for multiarch runtimes layout
This change adds a support for multiarch style runtimes layout, so in
addition to the existing layout where runtimes get installed to:

lib/clang/$version/lib/$os

Clang now allows runtimes to be installed to:

lib/clang/$version/$target/lib

This also includes libc++, libc++abi and libunwind; today those are
assumed to be in Clang library directory built for host, with the
new layout it is possible to install libc++, libc++abi and libunwind
into the runtime directory built for different targets.

The use of new layout is enabled by setting the
LLVM_ENABLE_RUNTIME_TARGET_DIR CMake variable and is supported by both
projects and runtimes layouts. The runtimes CMake build has been further
modified to use the new layout when building runtimes for multiple
targets.

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

llvm-svn: 335809
2018-06-28 03:11:52 +00:00
Martin Storsjo dd75eb531d [CMake] Convert paths to the right form in standalone builds on Windows
The paths output from llvm-config --cmakedir and from clang
--print-libgcc-file-name can contain backslashes, while CMake
can't handle the paths in this form.

This matches what compiler-rt already does (since SVN r203789
and r293195).

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

llvm-svn: 335171
2018-06-20 20:59:18 +00:00
Paul Robinson 7555c589af Update copyright year to 2018.
llvm-svn: 334936
2018-06-18 12:22:17 +00:00
Vitaly Buka e26d5f4b12 Fix libcxxabi tests after clang r334924
llvm-svn: 334926
2018-06-18 06:43:55 +00:00
Vitaly Buka db666a44e7 Fix libcxx tests after clang r334677.
llvm-svn: 334924
2018-06-18 06:24:29 +00:00
Eric Fiselier 29e0265732 private_typeinfo: limit is_dst_type_derived_from_static_type optimization
Patch by Ryan Prichard

If the destination type does not derive from the static type, we can skip
the search_above_dst call, but we still need to run the
!does_dst_type_point_to_our_static_type block of code. That block of code
will increment info->number_to_dst_ptr to 2, and because dest isn't derived
from static, the cast will ultimately fail.

Fixes PR33439

Reviewed as https://reviews.llvm.org/D36447

llvm-svn: 332767
2018-05-18 20:51:38 +00:00
Eric Fiselier 4938d48f09 private_typeinfo: propagate static flags in vmi search_above_dst method
This adds the test which was mistakenly not committed in r332763.

Patch by Ryan Prichard

Propagate the found_our_static_ptr and found_any_static_type flags from
__vmi_class_type_info::search_above_dst to its caller.

Fixes PR33425 and PR33487

Reviewed as https://reviews.llvm.org/D36446

llvm-svn: 332764
2018-05-18 20:42:53 +00:00
Eric Fiselier 77eaa59cd2 private_typeinfo: propagate static flags in vmi search_above_dst method
Patch by Ryan Prichard

Propagate the found_our_static_ptr and found_any_static_type flags from
__vmi_class_type_info::search_above_dst to its caller.

Fixes PR33425 and PR33487

Reviewed as https://reviews.llvm.org/D36446

llvm-svn: 332763
2018-05-18 20:39:57 +00:00
Nico Weber 377d68fd2c Fix test failure for missing _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
This is a follow-up change to r331150. The CL moved the macro from individual
file to build file, but the macro is missed in a test config file.

https://reviews.llvm.org/D46385
Patch from Taiju Tsuiki <tzik@chromium.org>!

llvm-svn: 331450
2018-05-03 12:44:27 +00:00
Nico Weber 297ec32b86 Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build system
_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS is currently used to
bring back std::unexpected, which is removed in C++17, but still needed
for libc++abi for backward compatibility.

This macro used to define in cxa_exception.cpp only, but actually
needed for all sources that touches exceptions.
So, a build-system-level macro is better fit to define this macro.

https://reviews.llvm.org/D46056
Patch from Taiju Tsuiku <tzik@chromium.org>!

llvm-svn: 331150
2018-04-29 23:05:11 +00:00
Eli Friedman 17a47b915a [libc++abi] Replace __sync_* functions with __libcpp_atomic_* functions.
This is basically part 2 of r313694.

It's a little unfortunate that I had to copy-paste atomic_support.h,
but I don't really see any alternative.

The refstring.h changes are the same as the libcxx changes in r313694.

llvm-svn: 330162
2018-04-16 22:00:14 +00:00
Erik Pilkington f2a9b0fdda [demangler] NFC: Some refactoring to support partial demangling.
I'm committing this to libcxxabi too so that the two demanglers remain as
simular as possible.

llvm-svn: 329950
2018-04-12 20:41:06 +00:00
Vlad Tsyrklevich b89e9b5e2f [CFI] Disable CFI checks for __cxa_decrement_exception_refcount
Summary:
exception_header->exceptionDestructor is a void(*)(void*) function
pointer; however, it can point to destructors like std::
exception::~exception that don't match that type signature.

Reviewers: pcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: kcc, christof, cfe-commits

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

llvm-svn: 329629
2018-04-09 22:11:28 +00:00
Erik Pilkington d43931dcb8 [demangler] Support for fold expressions.
llvm-svn: 329601
2018-04-09 18:33:01 +00:00
Erik Pilkington 452e2ef996 [demangler] Support for <data-member-prefix>.
llvm-svn: 329600
2018-04-09 18:32:25 +00:00
Erik Pilkington 650130ac04 [demangler] Support for partially substituted sizeof....
llvm-svn: 329599
2018-04-09 18:31:50 +00:00
Petr Hosek 86a9ddcd1a [CMake] Support for monorepo layout
Support finding libcxx and libunwind sources in monorepo style layout.

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

llvm-svn: 329208
2018-04-04 17:40:59 +00:00
Erik Pilkington 615e753e09 [demangler] Fix a bug in r328464 found by oss-fuzz.
llvm-svn: 328507
2018-03-26 15:34:36 +00:00
Erik Pilkington 8a1cb33ba5 [demangler] Use a back-patching scheme to resolve forward references.
Strictly in a conversion operator's type, a <template-param> refers to a
<template-arg> that is further ahead in the mangled name. Instead of
doing a second parse to resolve these, introduce a
ForwardTemplateReference Node and back-patch the referenced
<template-arg> when we're in the right context.

This is also a correctness fix, previously we would only do a second
parse if the <template-param> was out of bounds in the current set of
<template-args>. This lead to misdemangles (gasp!) when the conversion
operator was a member of a templated struct, for instance.

llvm-svn: 328464
2018-03-25 22:50:33 +00:00
Erik Pilkington 8c7013d4ca [demangler] Tweak how parameter pack sizes are determined.
Rather than eagerly propagating up parameter pack sizes in Node ctors,
find the parameter pack size during printing. This is being done to
support back-patching forward referencing <template-param>s.

llvm-svn: 328463
2018-03-25 22:49:57 +00:00
Erik Pilkington c728786b1d [demangler] Support for clang's enable_if attribute.
Fixes PR33569.

llvm-svn: 328462
2018-03-25 22:49:16 +00:00
Erik Pilkington e9c2a3c565 [demangler] Support for <template-param>s in generic lambdas.
These <template-param>s refer to "artifical" <template-arg>s that don't appear
in the mangled name, so we just print them as "auto".

llvm-svn: 327690
2018-03-16 03:06:30 +00:00
Erik Pilkington 4fb6f8189f [demangler] Simplify printing of structured bindings.
Thanks to Richard Smith for the post-commit review!

llvm-svn: 327228
2018-03-10 22:33:49 +00:00
Erik Pilkington fcc9a80241 [demangler] Support for sequence numbers on lifetime extended temporaries.
llvm-svn: 327227
2018-03-10 21:31:22 +00:00
Erik Pilkington b1a7f3c741 [demangler] Support for structured bindings.
llvm-svn: 327226
2018-03-10 21:31:15 +00:00
Erik Pilkington bec42c848d [demangler] Fix a mistake in r326797.
Thanks to Nico Weber for pointing this out!

llvm-svn: 326871
2018-03-07 04:29:33 +00:00
Erik Pilkington 98e7036587 [demangler] Modernize the rest of the demangler.
llvm-svn: 326797
2018-03-06 14:21:10 +00:00
Erik Pilkington 4352d7221c [demangler] Modernize parse_unresolved_name.
llvm-svn: 326796
2018-03-06 14:21:08 +00:00
Erik Pilkington 3402e876ef [demangler] Modernize parse_name.
llvm-svn: 326717
2018-03-05 16:35:06 +00:00
Erik Pilkington 0bae6d8c14 [demangler] Support for exception specifications on function types.
llvm-svn: 325093
2018-02-14 01:08:20 +00:00
Erik Pilkington bb0e34558f [demangler] Simplify the AST for function types, NFC.
llvm-svn: 325092
2018-02-14 01:08:17 +00:00
Erik Pilkington b39094e39e [demangler] Support for inheriting constructors.
Fixes PR33223.

llvm-svn: 325023
2018-02-13 17:09:07 +00:00
Erik Pilkington aec1e58c99 [demangler] Rewrite parse_nested_name in the new style.
llvm-svn: 325022
2018-02-13 17:09:03 +00:00
Erik Pilkington 8b15f1f272 [demangler] Support for initializer lists and designated initializers.
llvm-svn: 324970
2018-02-13 00:15:56 +00:00
Erik Pilkington 8d2aca0697 [demangler] Support for dependent elaborate type specifiers.
llvm-svn: 324969
2018-02-13 00:15:53 +00:00
Erik Pilkington 94bd832518 [demangler] All <qualifiers> on one type should share one entry in the substitution table.
Previously, both <extended-qualifier>s and <CV-qualifiers> got their own entries.

llvm-svn: 324968
2018-02-13 00:15:46 +00:00
Richard Smith 8e6107a0e4 Fix compilation in C++17 mode.
C++17 removes `std::unexpected_handler`, but libc++abi needs it to define
`__cxa_exception`. When building against libc++, this is easily rectified by
telling libc++ we're building the library. We already do this in the other
places where we need these symbols.

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

llvm-svn: 324542
2018-02-07 23:23:23 +00:00
Erik Pilkington 9cbd9bfaa5 [demangler] Refactor the type parser
Differential revision: https://reviews.llvm.org/D41889

llvm-svn: 324282
2018-02-05 22:41:20 +00:00
Erik Pilkington 0923542c61 [demangler] return early if conditional expr parsing failed
This should fix some bugs found by oss-fuzz.

llvm-svn: 324203
2018-02-05 02:34:41 +00:00
Erik Pilkington 4f052d075c [demangler] Clean up the expression parser
This commit cleans up the expression parser, using a new style:
  - parse* functions now return Node pointers.
  - The mangled name is now held in Db and accessed with look() and consume()
  - LLVM coding style

This style is meant to avoid the 2 most common types of bugs in the
old demanger, namely misusing the Names stack (ie, calling back() on
empty) and going out of bounds on the mangled name. I also think it
makes the demangler a lot cleaner.

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

llvm-svn: 324111
2018-02-02 18:04:32 +00:00
Erik Pilkington 862987abe7 [demangler] Improve variadic template support
This commit changes how variadic templates are represented in the
demangler, in order to fix some longstanding bugs. Now instead of
expanding variadic templates during parsing, the expansion is done
during printing by reusing the unexpanded AST. This allows the
demangler to handle cases where multiple packs contribute to a single
production, and correctly handle "Dp" and "sp" productions, which
corrispond to pack expansions in type and expression contexts.

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

llvm-svn: 323906
2018-01-31 20:17:06 +00:00
Don Hinton 4877063e19 [cmake] [libcxxabi] LLVM_FOUND isn't always set, so just test if
llvm_setup_rpath() is available instead.

llvm-svn: 323600
2018-01-27 19:18:04 +00:00
Don Hinton e3b3b8094d Reland:
[cmake] [libcxxabi] Call llvm_setup_rpath() when adding shared libraries.

Clang and llvm already use llvm_setup_rpath(), so this change will
help standarize rpath usage across all projects.

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

llvm-svn: 323495
2018-01-26 03:41:58 +00:00
Don Hinton bc595f5702 Revert [libcxxabi] r323455 - [cmake] [libcxxabi] Call llvm_setup_rpath() when adding shared libraries.
Shoaib Meenai pointed out this will break standalone builds can be built without llvm.

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

llvm-svn: 323458
2018-01-25 19:18:51 +00:00
Don Hinton 0106b4305f [cmake] [libcxxabi] Call llvm_setup_rpath() when adding shared libraries.
Clang and llvm already use llvm_setup_rpath(), so this change will
help standarize rpath usage across all projects.

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

llvm-svn: 323455
2018-01-25 18:43:18 +00:00
Peter Collingbourne a674a8fd1e [libc++abi] Fix unused function when building with LIBCXXABI_SILENT_TERMINATE
This fixes:
src/cxa_default_handlers.cpp:25:13: error: unused function 'demangling_terminate_handler' [-Werror,-Wunused-function]

Patch by Thomas Anderson!

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

llvm-svn: 323397
2018-01-25 01:38:43 +00:00
Don Hinton ae858bf65f [cmake] [libcxxabi] Fix find_path() problems when cross compiling
When CMAKE_SYSROOT or CMAKE_FIND_ROOT_PATH is set, cmake
recommends setting CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
globally which means find_path() always prepends CMAKE_SYSROOT or
CMAKE_FIND_ROOT_PATH to all paths used in the search.

However, these find_path() invocations are looking for paths in
the libcxx and libunwind projects on the host system, not the
target system, which can be done by passing
NO_CMAKE_FIND_ROOT_PATH.

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

llvm-svn: 323145
2018-01-22 19:41:05 +00:00
Don Hinton 964ea50ff8 [cmake] [libcxxabi] Don't print warning when tests are disabled.
Summary:
Don't print, possibly erroneous, warning if
LIBCXXABI_INCLUDE_TESTS is false.

This patch fixes a problem introduced in r291367.

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

llvm-svn: 322870
2018-01-18 18:29:36 +00:00
Eric Fiselier 6ae8abf241 Fix standalone test-suite run.
This patch updates libc++abi's HandleOutOfTreeLLVM.cmake to match
libc++'s -- and more importantly, to fix a bug where llvm-lit wasn't
found/created when libc++abi was built out-of-tree. This prevented
the test suite from running.

llvm-svn: 322768
2018-01-17 22:07:09 +00:00
Hans Wennborg 4ebc5ab7a5 Update version to 7.0.0svn
llvm-svn: 321726
2018-01-03 15:42:34 +00:00
Jonathan Roelofs 01b938279c Try again, this time with the correct address
llvm-svn: 321569
2017-12-29 19:26:28 +00:00
Jonathan Roelofs 8e8378ba77 Update CREDITS.txt with personal email address
llvm-svn: 321564
2017-12-29 19:16:12 +00:00
Petr Hosek 2ffea93c57 [libcxxabi] Pass LIBCXXABI_SYSROOT and LIBCXXABI_GCC_TOOLCHAIN to lit
These are expected to be set by the shared lit scripts used from libc++.

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

llvm-svn: 320445
2017-12-12 01:20:37 +00:00
Ben Hamilton 4bf869c87e [libcxxabi] Set up .arcconfig to point to new Diffusion CXXA repository
Summary:
We want to automatically copy the appropriate mailing list
for review requests to the libc++abi repository.

For context, see the proposal and discussion here:

http://lists.llvm.org/pipermail/cfe-dev/2017-November/056032.html

Similar to D40500, I set up a new Diffusion repository with callsign
"CXXA" for libc++abi:

https://reviews.llvm.org/source/libcxxabi/

This explicitly updates libcxxabi's .arcconfig to point to the new
CXX repository in Diffusion, which will let us use Herald rule H268.

Reviewers: phosek, beanz, EricWF, compnerd

Reviewed By: phosek

Subscribers: cfe-commits, klimek, sammccall, dlj, bkramer

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

llvm-svn: 319713
2017-12-04 23:14:03 +00:00
Shoaib Meenai acee992852 [libc++abi] Add install-cxxabi-stripped target
LLVM is gaining install-*-stripped targets to perform stripped installs,
and in order for this to be useful for install-distribution, all
potential distribution components should have stripped installation
targets. LLVM has a function to create these install targets, but since
we can't use LLVM CMake functions in libc++abi, let's do it manually.

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

llvm-svn: 319499
2017-11-30 23:25:51 +00:00
Akira Hatanaka 9ef1daa46e Insert padding before the __cxa_exception header to ensure the thrown
object is sufficiently aligned.

r303175 annotated field unwindHeader of __cxa_exception with attribute
'aligned' to ensure the thrown object following the __cxa_exception
header was sufficiently aligned. This caused changes in the field
offsets of __cxa_exception relative to the start of the thrown object,
which was an ABI breaking change for some clients.

Instead of annotating field unwindHeader, this commit inserts extra
space before the header. This ensures the thrown object following the
header is sufficiently aligned without changing the field offsets, thus
avoiding any ABI breakages.

rdar://problem/25364625
rdar://problem/35556163

llvm-svn: 319123
2017-11-28 00:36:29 +00:00
Erik Pilkington 24d6534038 [demangler] Support for abi_tag attribute
Differential revision: https://reviews.llvm.org/D40279

llvm-svn: 318874
2017-11-22 20:38:22 +00:00
Erik Pilkington 1b7f8d5b04 [demangler] Document some features that the demangler doesn't yet support, NFC
llvm-svn: 318765
2017-11-21 15:04:08 +00:00
Petr Hosek aa96d2ebbc [libcxxabi][CMake] Provide option to disable installing of the library
This is useful in cases where we only build static library and
libc++abi.a is combined with libc++.a into a single archive in which
case we don't want to have libc++abi.a installed separately. The same
option is already provided by libcxx CMake build.

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

llvm-svn: 318568
2017-11-17 23:25:09 +00:00
Petr Hosek 56a1f07156 [CMake][libcxxabi] Support merging objects when statically linking unwinder
When using LLVM unwinder and static unwinder option is set, merge
libunwind and libc++abi objects into a single archive. libc++ already
supports merging libc++abi.a and libc++.a into a single archive; with
this change, it is possible to also include libunwind.a in the same
archive which is useful when doing static link and using libc++ as
a default C++ library and compiler-rt as a default runtime library.

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

llvm-svn: 318563
2017-11-17 22:49:39 +00:00
Stephan Bergmann 511c284b82 Remove excess whitespace from syslog message; NFC
llvm-svn: 318043
2017-11-13 15:40:31 +00:00
Eric Fiselier c4600ccf89 Fix ASAN build with older compiler-rt versions.
compiler-rt recently added the __asan_handle_no_return() function that libc++abi
needs to use, however older versions of compiler-rt don't declare this interface
publicly and that breaks the libc++abi build.

This patch attempts to fix the issues by declaring the asan function explicitly,
so we don't depend on compiler-rt to provide the declaration.

llvm-svn: 313308
2017-09-14 22:37:34 +00:00
Eric Fiselier 8635f7d2c6 [libc++abi] Fix ASAN build with older compiler-rt versions.
Summary:
compiler-rt recently added the `__asan_handle_no_return()` function that libc++abi needs to use, however older versions of compiler-rt don't provide this interface and that breaks the libc++abi build.

This patch attempts to fix the issues by using a macro to detect if `asan_interface.h` is new enough to provide the function.

See D37871

Reviewers: phosek, vitalybuka

Reviewed By: phosek, vitalybuka

Subscribers: dberris, cfe-commits

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

llvm-svn: 313304
2017-09-14 22:19:28 +00:00
Petr Hosek 229e0854ed Reland "When built with ASan, __cxa_throw calls __asan_handle_no_return"
The ASan runtime on many systems intercepts cxa_throw just so it
can call asan_handle_no_return first. Some newer systems such as
Fuchsia don't use interceptors on standard library functions at all,
but instead use sanitizer-instrumented versions of the standard
libraries. When libc++abi is built with ASan, cxa_throw can just
call asan_handle_no_return itself so no interceptor is required.

Patch by Roland McGrath

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

llvm-svn: 313215
2017-09-13 23:35:07 +00:00
Petr Hosek a69a3a3f62 Revert "[libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_return"
This reverts commit r312606 because it's causing an error on
libcxx-libcxxabi-x86_64-linux-ubuntu-asan bot.

llvm-svn: 312609
2017-09-06 03:00:42 +00:00
Petr Hosek 53335d6d86 [libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_return
The ASan runtime on many systems intercepts cxa_throw just so it
can call asan_handle_no_return first. Some newer systems such as
Fuchsia don't use interceptors on standard library functions at all,
but instead use sanitizer-instrumented versions of the standard
libraries. When libc++abi is built with ASan, cxa_throw can just
call asan_handle_no_return itself so no interceptor is required.

This is a re-land of r311045, which has become safe after r311869
changed compiler-rt to declare __asan_handle_no_return.

Patch by Roland McGrath

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

llvm-svn: 312606
2017-09-06 02:43:54 +00:00
Petr Hosek ce7aa6f2bd Revert "[libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_return"
This reverts commit r311045 because it's causing an error on
libcxx-libcxxabi-x86_64-linux-ubuntu-asan bot.

llvm-svn: 311047
2017-08-16 22:05:54 +00:00
Petr Hosek 00135562e5 [libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_return
The ASan runtime on many systems intercepts cxa_throw just so it
can call asan_handle_no_return first. Some newer systems such as
Fuchsia don't use interceptors on standard library functions at all,
but instead use sanitizer-instrumented versions of the standard
libraries. When libc++abi is built with ASan, cxa_throw can just
call asan_handle_no_return itself so no interceptor is required.

Patch by Roland McGrath

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

llvm-svn: 311045
2017-08-16 21:58:09 +00:00
Erik Pilkington a95eae2d4b [demangler] Fix some more -Wshadow warnings I missed in r310535
llvm-svn: 310546
2017-08-10 02:48:13 +00:00
Erik Pilkington f514ccadbd [demangler] Fix a bunch of -Wshadow warnings
These were causing failures in -Werror builds.

llvm-svn: 310535
2017-08-09 22:45:35 +00:00
Erik Pilkington 7377525fce Mark test as unsupported c++98/03 to fix buildbots
llvm-svn: 310530
2017-08-09 21:51:56 +00:00
Erik Pilkington ab04a08c49 [demangler] Improve representation of substitutions/templates
Differential revision: https://reviews.llvm.org/D36427

llvm-svn: 310525
2017-08-09 21:30:57 +00:00
Erik Pilkington 512253292c [demangler] Rename some variables, NFC
llvm-svn: 310415
2017-08-08 20:57:10 +00:00
Shoaib Meenai 1285013dbe [libc++abi] Use proper calling convention for TLS destructor
This is needed when using Windows threading.

llvm-svn: 310329
2017-08-08 00:54:33 +00:00
Erik Pilkington 39dc8800c1 [demangler] Fix another oss-fuzz bug
llvm-svn: 310226
2017-08-06 20:46:33 +00:00
Erik Pilkington 906d585686 [demangler] Fix another bug found by oss-fuzz in r309340
llvm-svn: 309650
2017-08-01 02:38:41 +00:00
Erik Pilkington deec87836a [demangler] Use _LIBCPP_UNREACHABLE()
llvm-svn: 309649
2017-08-01 02:38:40 +00:00
NAKAMURA Takumi 83105a4ae1 libcxxabi: Suppress LLVM_ENABLE_MODULES
Differential Revision: https://reviews.llvm.org/D35542

llvm-svn: 309551
2017-07-31 09:35:08 +00:00
Erik Pilkington 39bbe2f5de [demangler] Fix some bugs in r309340 found by oss-fuzz
llvm-svn: 309520
2017-07-30 20:09:55 +00:00
Erik Pilkington fe33551051 [demangler] Fix some overzealous -Wreturn-type errors
llvm-svn: 309349
2017-07-28 01:35:14 +00:00
Erik Pilkington bdfd1228f6 [demangler] Attempt to fix linux bots, include <cstdio>
llvm-svn: 309342
2017-07-28 00:53:30 +00:00
Erik Pilkington 94d2ac7160 [demangler] Use an AST to represent demangled names
The demangler now demangles by producing an AST, then traverses that
AST to produce a demangled name. This is done for performance reasons,
now the demangler doesn't manuiplate std::strings, which hurt
performance and caused string operations to be inlined into the
parser, leading to large code size and stack usage.

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

llvm-svn: 309340
2017-07-28 00:43:49 +00:00
Hans Wennborg a25946c8e8 Update version to 6.0.0svn
llvm-svn: 308461
2017-07-19 13:42:18 +00:00
Erik Pilkington 28a4d0b981 [demangler] Respect try_to_parse_template_args
Fixes an exponential parse found by oss-fuzz.

llvm-svn: 307941
2017-07-13 19:37:37 +00:00
Eric Fiselier 84800d999c Remove dependancy on __refstring header; use local copy instead.
This patch removes the dependancy on libc++'s __refstring header,
which was only a header in the first place so that libc++abi could
build library code using it, and not because libc++ needed it in
the headers.

This patch allows libc++ to stop shipping <__refstring> publicaly
at the cost of duplicating it across projects. Ideally libc++abi
would always require the libc++ sources when building, but that's
a separate discussion I plan to start on the mailing lists shortly.

llvm-svn: 307748
2017-07-12 01:34:21 +00:00
Petr Hosek 60fe5792ae [libcxxabi][CMake] Add install path variable to allow overriding the destination
This is going to be used by the runtime build in the multi-target
setup to allow using different install prefix for each target.

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

llvm-svn: 307611
2017-07-11 01:42:26 +00:00
Erik Pilkington c113b96ec4 [Demangler] NFC: Don't make the parse_* functions templates
Differential revision: https://reviews.llvm.org/D35158

llvm-svn: 307482
2017-07-08 18:54:08 +00:00
Erik Pilkington ffac67419b [Demangler] NFC: Move Db struct to beginning of file
Differential revision: https://reviews.llvm.org/D35158

llvm-svn: 307481
2017-07-08 18:54:07 +00:00
Eric Fiselier ce02c1bc15 Fix incomplete type test on OS X; workaround weird DYLD_LIBRARY_PATH behavior
llvm-svn: 307230
2017-07-06 00:29:09 +00:00
Marshall Clow f74609b15f Add some catch(...) blocks to the tests so that if they fail, we get a good error message. No functional change.
llvm-svn: 305977
2017-06-22 00:49:03 +00:00
Eric Fiselier 187fd40ca4 Use _LIBCPP_FALLTHROUGH() to avoid warnings about [[gnu::fallthrough]] being unsupported
llvm-svn: 305500
2017-06-15 20:18:10 +00:00
Ismail Donmez dea7590a04 Set a default value for LIBCXXABI_LIBDIR_SUFFIX, fixes installing into lib64 after r304374
llvm-svn: 305278
2017-06-13 08:16:44 +00:00
Saleem Abdulrasool cf0e48ca01 build: use cmake to pass -std=c++11
Rather than manually checking for support for the spelling of the C++
standard, indicate to CMake that we require that the compiler support
C++11 and that we compile without the GNU extensions.  This simplifies
the flags handling in libc++abi itself by relying on CMake to translate
the flag and add it as appropriate.

llvm-svn: 305175
2017-06-11 23:59:26 +00:00
Saleem Abdulrasool e3568b4b3d build: use POSITION_INDEPENDENT_CODE CMake property
Use the POSITION_INDEPENDENT_CODE target property to indicate that we
should be building with -fPIC or the equivalent flag based on the
toolchain that we are using.  This makes the check more portable and
simplifies the flags management.  Because we don't want this setting to
propagate in the case of an in-tree build, set the property on the
targets we construct explicitly rather than setting
CMAKE_POSITION_INDEPENDENT_CODE to ON globally.

llvm-svn: 305174
2017-06-11 23:59:24 +00:00
Saleem Abdulrasool d1c2302fc5 cxa_demangle: fix -Wimplicit-fallthrough for GCC:7
Use the C++11 (formalised in C++17) tag to indicate a fallthrough in the
switch case.  Silences a -Wimplicit-fallthrough warning with gcc:7

llvm-svn: 305173
2017-06-11 22:57:31 +00:00
Saleem Abdulrasool 52bb919615 private_typeinfo: add missing field initializers
Cleanup the -Wmissing-field-initializers warnings from gcc:7 builds.
NFC.

llvm-svn: 305172
2017-06-11 22:57:26 +00:00
Martell Malone 2fdf185bea [libcxxabi] HandleLLVMOptions in out of tree build
Differential revision: https://reviews.llvm.org/D33753

llvm-svn: 304664
2017-06-03 17:23:19 +00:00
Martell Malone 062f8f00ae [libcxxabi] Rework CMakeLists.txt into modules
Refactor cmake to remove dependence on LLVM's cmake modules.
This improves handling of cmake checks when cross compiling and brings
libcxxabi in line with libcxx and other project modules.

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

llvm-svn: 304374
2017-06-01 00:09:20 +00:00
Eric Fiselier 27db230ab0 Remove requirement for libunwind sources. Patch by Shiz.
As per r241993, libunwind_ext.h is not used anymore, and thus only the public libunwind includes are needed.
This eases distro packaging efforts and removes an unneeded requirement for out-of-tree building.

Reviewed as D33178

llvm-svn: 304359
2017-05-31 22:11:42 +00:00
Erik Pilkington a34ea7583f [demangler] Fix a exponential string copying bug
The problem was that if base_name() was called from a context without
an actual base name, it could gulp up the entire string, which can
result in recursive duplications. The fix is to be more strict as to
what qualifies as a base name.

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

llvm-svn: 304113
2017-05-28 23:15:50 +00:00
Martell Malone 41119cd07b [libcxxabi] Disable DLL annotations on static
rL288692 renames
_LIBCXXABI_DISABLE_DLL_IMPORT_EXPORT to
_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS

llvm-svn: 304110
2017-05-28 22:46:50 +00:00
Martell Malone fedd33f155 [libcxxabi] iconv is not needed for mingw-w64
llvm-svn: 304026
2017-05-26 19:39:39 +00:00
Erik Pilkington 00efd50476 [Demangler] Remove a failing assert introduced in r303718
llvm-svn: 303806
2017-05-24 20:53:13 +00:00
Tamas Berghammer 8bc9b88a24 __cxa_demangle: Fix constructor cv qualifier handling
Summary:
Previously if we parsed a constructor then we set parsed_ctor_dtor_cv
to true and never reseted it. This causes issue when a template argument
references a constructor (e.g. type of lambda defined inside a
constructor) as we will have the parsed_ctor_dtor_cv flag set what will
cause issues when parsing later arguments.

Reviewers: EricWF, compnerd

Subscribers: cfe-commits

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

llvm-svn: 303737
2017-05-24 11:21:34 +00:00
Erik Pilkington 17dfebcc39 [demangler] Fix a crash in the demangler during parsing of a lamdba
The problem is that multiple types could have been parsed from parse_type(),
which the lamdba parameter parsing didn't handle.

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

llvm-svn: 303718
2017-05-24 05:44:19 +00:00
Akira Hatanaka 7d5d9dc18a [libcxxabi] Fix the test case committed in r303175.
Free the __cxa_exception object allocated with __cxa_allocate_exception.

This is an attempt to fix this asan bot:

http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-asan/builds/560

llvm-svn: 303194
2017-05-16 18:18:03 +00:00
Akira Hatanaka 0c1016a337 [libcxxabi] Align unwindHeader on a double-word boundary.
r276215 made a change to annotate _Unwind_Exception with attribute
"aligned" so that an exception object following field __cxa_exception
is sufficiently aligned. This fix hasn't been incorporated to unwind.h
on Darwin since it is an ABI breaking change.

Instead of annotating struct _Unwind_Exception with the attribute, this
commit annotates field unwindHeader of __cxa_exception. This ensures the
exception object is sufficiently aligned without breaking the ABI.

This recommits r302978 and r302981, which were reverted in r303016
because a libcxx test was failing on an AArch64 bot. I also modified the
libcxxabi test case to check the alignment of the pointer returned by
__cxa_allocate_exception rather than compiling the test with -O1 and
checking whether it segfaults.

rdar://problem/25364625

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

llvm-svn: 303175
2017-05-16 15:19:08 +00:00
Akira Hatanaka c1c78617e7 Revert r302978 and r302981.
Revert the two commits to understand why the following aarch64 bot is
failing.

http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux

llvm-svn: 303016
2017-05-14 18:46:19 +00:00
Akira Hatanaka c57477b2bd [libcxxabi] Do not align field unwindHeader when building for ARM EHABI.
For ARM EHABI, _Unwind_Exception is an alias of _Unwind_Control_Block,
which is not aligned, so we shouldn't align unwindHeader either.

rdar://problem/25364625

llvm-svn: 302981
2017-05-13 06:28:17 +00:00
Akira Hatanaka c501f754a5 [libcxxabi] Align unwindHeader on a double-word boundary.
r276215 made a change to annotate _Unwind_Exception with attribute
"aligned" so that an exception object following field __cxa_exception
is sufficiently aligned. This fix hasn't been incorporated to unwind.h
on Darwin since it is an ABI breaking change.

Instead of annotating struct _Unwind_Exception with the attribute, this
commit annotates field unwindHeader of __cxa_exception. This ensures the
exception object is sufficiently aligned without breaking the ABI.

This recommits r302763 with fixes to RUN lines in the test case.

rdar://problem/25364625

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

llvm-svn: 302978
2017-05-13 03:14:49 +00:00
Martell Malone 53877bc5b9 [Libcxxabi]: Support using compiler-rt for MinGW64
Reviewers: EricWF

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

llvm-svn: 302824
2017-05-11 21:16:29 +00:00
Akira Hatanaka 5662e55de5 Revert "[libcxxabi] Align unwindHeader on a double-word boundary."
This reverts commit r302763.

The commit caused bot failures.

llvm-svn: 302764
2017-05-11 06:17:49 +00:00
Akira Hatanaka a9bbdc507c [libcxxabi] Align unwindHeader on a double-word boundary.
r276215 made a change to annotate _Unwind_Exception with attribute
"aligned" so that an exception object following field __cxa_exception
is sufficiently aligned. This fix hasn't been incorporated to unwind.h
on Darwin since it is an ABI breaking change.

Instead of annotating struct _Unwind_Exception with the attribute, this
commit annotates field unwindHeader of __cxa_exception. This ensures the
exception object is sufficiently aligned without breaking the ABI.

rdar://problem/25364625

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

llvm-svn: 302763
2017-05-11 05:58:52 +00:00
Eric Fiselier 6c3eb5fe0e Revert "Rename c++abi.a on Windows to libc++abi to avoid name conflicts"
This reverts commit r302759

llvm-svn: 302762
2017-05-11 05:05:06 +00:00
Eric Fiselier 70c2b1c551 Allow undefined symbols when linking libc++abi.dll on Windows
llvm-svn: 302761
2017-05-11 03:49:48 +00:00
Eric Fiselier accba012b4 Fix Libc++abi linking under MinGW64
llvm-svn: 302760
2017-05-11 03:29:59 +00:00
Eric Fiselier 144019ac22 Rename c++abi.a on Windows to libc++abi to avoid name conflicts
llvm-svn: 302759
2017-05-11 03:18:29 +00:00
Eric Fiselier 9226279daa Don't use posix_memalign under MinGW
llvm-svn: 302755
2017-05-11 02:01:05 +00:00
Eric Fiselier f57d5d08ba Apply libc++ MinGW CMake fix to libc++abi
llvm-svn: 302754
2017-05-11 02:00:25 +00:00
Shoaib Meenai f43726cd22 [libc++abi] Disable libc++ extern templates project-wide
libc++abi can't depend on libc++, so disable extern templates in libc++
headers project-wide. This was previously done in cxa_demangle.cpp, but
I consider it more appropriate to do at the cmake level (since none of
libc++abi's source files can use libc++ extern templates).

I also think the _LIBCPP_NO_EXCEPTIONS in cxa_demangle.cpp is
suspicious, but I'm doing one thing at a time.

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

llvm-svn: 302739
2017-05-10 21:52:39 +00:00
Eric Fiselier daffb57605 Fix use of now removed %exec test substitution
llvm-svn: 302698
2017-05-10 17:52:53 +00:00
Eric Fiselier 3ab4600c1e Fix use of removed SH test replacement %exec
llvm-svn: 302629
2017-05-10 08:15:40 +00:00
Eric Fiselier 0af535636e XFAIL noexcept member function throw/catch test under GCC.
I'm still not exactly sure why the test fails, but I suspect it's
a bug in GCC. More investigation needed.

llvm-svn: 302489
2017-05-09 00:11:02 +00:00
Jonas Hahnfeld 57aa0d42d9 [libcxxabi][CMake] Set library dir when built under runtimes/
This will put libraries into the build root's lib/ directory by default.

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

llvm-svn: 302118
2017-05-04 06:04:49 +00:00
Eric Fiselier 096d636a35 Fix PR25874 - cxa_thread_atexit_test.pass.cpp has an incorrect XFAIL.
llvm-svn: 300925
2017-04-20 23:40:35 +00:00
Petr Hosek d3a3fb8391 [CMake][libcxxabi] Fix the -target and -gcc-toolchain flag handling
CMake has the problem with the single dash variant because of the
space, so use the double dash with equal sign version. These flag
need to be included in compile flags to propagate correctly. We also
don't have to pass the target triple when checking for compiler-rt
since that flag is already included in compile flags now.

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

llvm-svn: 300418
2017-04-16 06:08:34 +00:00
Petr Hosek 5f3d5be3dd [CMake][libcxxabi] Use -nodefaultlibs for CMake checks
Since libc++abi is built with -nodefaultlibs, we should be using this
option even for CMake checks to avoid any inconsistency and also to
avoid dependency on a working C++ standard library just for the setting
up the build itself. The implementation is largely similar to the one
used by libc++.

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

llvm-svn: 299797
2017-04-07 20:10:41 +00:00
Asiri Rathnayake 4cc78d7008 Fix exception address alignment test for EHABI
This test fails on ARM bare-metal targets because it assumes the Itanium ABI,
whereas EHABI requires the exception address to be 8-byte aligned.

I was a bit puzzled at first because this should've failed on the public
arm-linux builder too. I think the reason it passes there is because we don't
include libunwind headers in the include path when running the libcxxabi tests,
so the system unwind.h gets picked up.

Reviewers: rengolin, EricWF
Differential revision: https://reviews.llvm.org/D31178

llvm-svn: 299435
2017-04-04 14:03:54 +00:00
Mehdi Amini 5a403580e3 Uses quote to include cxxabi.h to make sure the local one is included
llvm-svn: 299414
2017-04-04 05:38:38 +00:00
Shoaib Meenai 8377febb37 [libc++abi] Remove missed use of config.h
llvm-svn: 299143
2017-03-31 00:29:25 +00:00
Shoaib Meenai a40507574e [libc++abi] Delete config.h
Summary: It's now completely empty, so we can remove it entirely.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

llvm-svn: 299129
2017-03-30 23:31:33 +00:00
Shoaib Meenai 5d293eb34a [libc++abi] Remove unistd.h include
This was originally there for the _POSIX_THREADS define, to detect the
presence of pthreads. That went away with the externalized threading
support, so the include can go away too.

config.h is now completely empty. A follow-up commit will remove it
entirely.

llvm-svn: 299087
2017-03-30 16:27:09 +00:00
Eric Fiselier 8524cbaa57 Fully Reformat fallback_malloc.cpp
This patch fully reformats fallback_malloc.cpp. Previously the test
was a mess of different styles and indentations. This made it very
hard to work in and read. Therefore I felt it was best to re-format
the whole thing.

Unfortuantly this means some history will be lost, but hopefully
much of it will still be accessible after ignoring whitespace changes.

llvm-svn: 296960
2017-03-04 03:23:15 +00:00
Eric Fiselier f4313ebfef Add missing UNSUPPORTED for -fno-exception mode
llvm-svn: 296957
2017-03-04 03:03:27 +00:00
Eric Fiselier d532ddcce9 Attempt to suppress test failures on OS X
llvm-svn: 296955
2017-03-04 02:29:25 +00:00
Eric Fiselier 6f8d62ddee Fix CMake configuration errors on OS X
llvm-svn: 296954
2017-03-04 02:15:37 +00:00
Eric Fiselier c74a2e1297 [libcxxabi] Fix alignment of allocated exceptions in 32 bit builds
Summary:
In 32 bit builds on a 64 bit system `std::malloc` does not return correctly aligned memory.  This leads to undefined behavior.

This patch switches to using `posix_memalign` to allocate correctly aligned memory instead.

Reviewers: mclow.lists, danalbert, jroelofs, compnerd

Reviewed By: compnerd

Subscribers: cfe-commits

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

llvm-svn: 296952
2017-03-04 02:04:45 +00:00
Eric Fiselier afa6f9793a Fix PR25874 - Detect features required for cxa_thread_atexit_test.pass.cpp
llvm-svn: 296940
2017-03-04 01:26:41 +00:00
Eric Fiselier 6aa4f1d1af Turn on -Wunused-function and cleanup occurances
llvm-svn: 296936
2017-03-04 01:02:35 +00:00
Eric Fiselier 38643b9d8a Work around GCC linking errors within libc++abi due to missing new/delete definitions
llvm-svn: 296823
2017-03-02 21:55:17 +00:00
Eric Fiselier 2ee1d90cb9 [libc++abi] Add option to enable definitions for the new/delete overloads.
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 `-DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS` which defaults to `OFF` unless otherwise specified. This means that by default
only libc++ provides the new/delete definitions.



Reviewers: mclow.lists, mehdi_amini, dexonsmith, beanz, jroelofs, danalbert, smeenai, rmaprath, mgorny

Reviewed By: mehdi_amini

Subscribers: cfe-commits

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

llvm-svn: 296801
2017-03-02 19:34:35 +00:00
Eric Fiselier b2577e5d6b [libc++abi] Update new/delete definitions to match libc++
Summary:
Currently both libc++ and libc++abi provide definitions for new/delete. However libc++abi's definitions haven't been updated to include aligned new/delete or sized deallocation.
I don't see any reason why libc++abi shouldn't provide these newer overloads.

This patch copies libc++'s implementation of `new/delete` into libc++abi so that it's now up to date.

After applying this patch I plan to fix a longstanding bug where both libc++ and libc++abi provide definitions for new/delete.


Reviewers: mclow.lists, mehdi_amini, dexonsmith, danalbert, smeenai, rmaprath, jroelofs

Reviewed By: mehdi_amini

Subscribers: cfe-commits

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

llvm-svn: 296787
2017-03-02 19:25:53 +00:00
Eric Fiselier 3781227448 Cleanup new/delete definitions
This patch cleans up how libc++abi handles the definitions for new/delete.
It is in preperation for upcoming changes to fix how both libc++ and libc++abi
handle new/delete.

The primary changes in this patch are:

* Move the definitions for bad_array_length and bad_new_array_length
  into stdlib_exception.cpp. This way stdlib_new_delete.cpp only
  contains new/delete.

* Rename cxa_new_delete.cpp -> stdlib_new_delete.cpp for consistency
  with other files.

* Add a FIXME regarding when stdlib_new_delete.cpp is actually compiled
  as part of the dylib.

llvm-svn: 296715
2017-03-01 23:59:34 +00:00
Ranjeet Singh ef6e672d04 [libcxxabi] Clean up macro usage.
Convention in libcxxabi is to use !defined(FOO) not !FOO.

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

llvm-svn: 296612
2017-03-01 11:42:01 +00:00
Shoaib Meenai fe989a9817 [libc++abi] Clean up visibility
Use the libc++abi visibility macros instead of pragmas or using
visibility attributes directly. Clean up redundant attributes on
definitions (where the declarations already have visibility attributes
applied, from either libc++ or libc++abi headers).

Introduce _LIBCXXABI_WEAK as a drive-by cleanup, which matches the
semantics of _LIBCPP_WEAK.

No functional change. Tested by building on Linux before and after this
change and verifying that the list of exported symbols is identical.

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

llvm-svn: 296576
2017-03-01 03:55:57 +00:00
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
Asiri Rathnayake 0b59cf64a0 Attempt to fix arm-native libcxxabi tests for the no-exceptions variant
These tests embed calls to exceptions-related symbols from the abi library,
which are absent in the no-exceptions variant. The tests need to be marked
as unsupported for the no-exceptions configuration.

llvm-svn: 296344
2017-02-27 15:31:34 +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
Petr Hosek 460af4bb9e [CMake][libcxxabi] Update the libc++ test module path
The libcxx/test/libcxx Python package has been moved into
libcxx/utils/libcxx in r294651, but libcxxabi's CMakeLists.txt still
looks for the old path.

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

llvm-svn: 295540
2017-02-18 04:37:59 +00:00
Eric Fiselier 1cb33118d9 Fix test_exception_storage.pass.cpp in C++17 my re-enabling the unexpected handlers
llvm-svn: 295411
2017-02-17 04:26:22 +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
Eric Fiselier 11306e5113 Fix path to libc++'s python test module
llvm-svn: 294671
2017-02-09 23:58:54 +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
Eric Fiselier 5aeb880d90 Remove all usages of REQUIRES-ANY in the test suite.
Pending LIT changes are about to remove the REQUIRES-ANY keyword
in place of supporting boolean && and || within "REQUIRES". This
patch prepares libc++ for that change so that when applied
the bots don't lose their mind.

llvm-svn: 292906
2017-01-24 10:28:23 +00:00
Eric Fiselier 35c8983c33 Fix catch_reference_nullptr.pass.cpp test for GCC.
This test contained an implicit conversion from nullptr to bool.
Clang warns about this but the test had supressed that warning.
However GCC diagnoses the same code as an error and requires
-fpermissive to accept it.

This patch fixes both the warning and the error by explicitly
converting the pointer to bool.

llvm-svn: 292638
2017-01-20 19:34:19 +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
Marshall Clow b4a2a63373 Mark the dynamic-exception tests as unsupported under C++17, since it has no dynamic-exception specs. Also, remove a FIXME workaround from the config that allowed these tests to work under C++17. This addresses PR#31621.
llvm-svn: 292135
2017-01-16 15:28:03 +00:00
Michal Gorny 40180b0360 [cmake] Handle missing LIBUNWIND_* directories gracefully
Add LIBUNWIND_* directories to include path only if they were actually
found, in order to fix the CMake error. Both of the directories are
usually unnecessary since libcxxabi uses only the common part of
unwind.h that is supplied both by GCC and Clang.

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

llvm-svn: 292018
2017-01-14 17:05:16 +00:00
Eric Fiselier ead6a4fc75 Don't dump llvm-config --cmakedir output if command fails.
This patch adjusts the out-of-tree CMake configuration so that
the stderr output is ignored when an old llvm-config is found
that doesn't support --cmakedir.

llvm-svn: 291993
2017-01-14 03:47:49 +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
Hans Wennborg 5d0ca65c98 Bump version to 5.0.0svn
llvm-svn: 291829
2017-01-12 21:36:22 +00:00
Michal Gorny db2e8acccf [cmake] Obtain LLVM_CMAKE_PATH from llvm-config if available
Use the new --cmakedir option to obtain LLVM_CMAKE_PATH straight from
llvm-config. Fallback to local reconstruction if llvm-config does not
support this option.

llvm-svn: 291506
2017-01-09 23:31:05 +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
Bryant Wong 04060ab619 [libcxxabi] Enable tests by default in standalone.
Tests targets will now be enabled by default when building libcxxabi out of tree
(unless turned off with LIBCXXABI_INCLUDE_TESTS=OFF).

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

llvm-svn: 291378
2017-01-08 00:33:30 +00:00
Bryant Wong 66b5441c86 [libcxxabi] Add flag to conditionally enable tests
Differential Revision: https://reviews.llvm.org/D28449

llvm-svn: 291367
2017-01-07 22:14:04 +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 c8466671e1 Update LICENSE.TXT to 2017
llvm-svn: 290877
2017-01-03 11:21:43 +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
Kostya Serebryany 4eb60cb9c9 add cxa_demangle_fuzzer
Summary:
All easy-to-find bugs in cxa_demangle where fixed now
(https://bugs.chromium.org/p/chromium/issues/detail?id=606626)
except for one (https://llvm.org/bugs/show_bug.cgi?id=31031).
Now I'd like to properly integrate this fuzzer with the source tree
and then run the fuzzer continuously on https://github.com/google/oss-fuzz

Reviewers: compnerd, mclow.lists, mehdi_amini

Subscribers: cfe-commits, mgorny

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

llvm-svn: 290650
2016-12-28 03:28:29 +00:00
Eric Fiselier 47570b8d2c Suppress unreachable code warning in unwind tests
llvm-svn: 290487
2016-12-24 05:01:55 +00:00
Eric Fiselier a140cba795 Fix warnings in libc++abi tests
llvm-svn: 290471
2016-12-24 00:37:13 +00:00
Shoaib Meenai 5723c4f4c2 [libc++abi] Mark failing test on Darwin as XFAIL
The macOS thread-local variable finalizer routines do not handle the
case where a termination function registers another termination function
correctly, causing this test to fail. I've filed a radar for this;
mark the test XFAIL in the meantime. See [1] for more details.

[1] http://lists.llvm.org/pipermail/cfe-dev/2016-November/051376.html

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

llvm-svn: 289513
2016-12-13 02:43:04 +00:00
Eric Fiselier 2f179bd85b Fix signed comparison warning
llvm-svn: 289365
2016-12-11 05:43:20 +00:00
Eric Fiselier 58f4a59731 Workaround the removal of dynamic exception specifications in C++17
llvm-svn: 289353
2016-12-11 01:35:55 +00:00
Shoaib Meenai 1bc40a8e2d [libc++abi] Add _LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS
It's useful to be able to disable visibility annotations entirely; for
example, if we're building libc++abi static to include in another library,
and we don't want any libc++abi functions getting exported out of that
library. This is a generalization of _LIBCXXABI_DISABLE_DLL_IMPORT_EXPORT.

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

llvm-svn: 288692
2016-12-05 19:42:11 +00:00
Richard Smith 366bb54f81 Check for SD-6 feature test macro when determining which tests should be
available, rather than #ifdef'ing away the relevant tests if it's unavailable.

llvm-svn: 288543
2016-12-02 22:14:59 +00:00
Richard Smith cc2d21111d Fix up r288457 for compilers that don't support noexcept function types:
disable the test entirely for those cases. This is a quick patch, I'll look at
a proper feature flag next.

llvm-svn: 288539
2016-12-02 21:43:36 +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
Eric Fiselier 79ff8f0375 Fix GCC libc++abi build
llvm-svn: 286783
2016-11-13 22:27:00 +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
Logan Chien 71cdd30e70 [CMake] Fix libc++abi arm build w/o libunwind.
This commit fixes libc++abi build when LLVM unwinder (libunwind_llvm) is
not enabled.

This commit fixes the problem by removing "LLVM_NATIVE_ARCH MATCHES ARM"
from CMakeLists.txt so that LIBCXXABI_USE_LLVM_UNWINDER will only be
defined when LLVM unwinder is enabled.

We need LIBCXXABI_USE_LLVM_UNWINDER becase there is a subtle difference
between the unwinder from libgcc and the one from libunwind_llvm.  For
the unwinder from libgcc, we have to initialize register r12 with the
address of _Unwind_Control_Block; otherwise,
_Unwind_GetLanguageSpecificData() and _Unwind_GetRegionStart() won't
work properly.  Consequently, there is an extra _Unwind_SetGR() when
LLVM unwinder is disabled.  Check cxa_personality.cpp for details.

llvm-svn: 286759
2016-11-13 14:42:15 +00:00
Petr Hosek bfb371a083 [CMake] Check runtimes subdir when looking for libcxx and libuwind
The runtimes subdir is the new location for runtimes, we should
include it when looking for libcxx and libunwind headers.

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

llvm-svn: 286614
2016-11-11 19:12:58 +00:00
Igor Kudrin d7407628cc [libc++abi] Remove the test for checking using of fallback malloc in case of dynamic memory exhaustion.
This test is too fragile and doesn't add significant value. See https://reviews.llvm.org/D26150 for some details.

llvm-svn: 286337
2016-11-09 04:14:31 +00:00
Petr Hosek 48c84f9596 Revert "[CMake] Check runtimes subdir when looking for libcxx and libuwind"
This reverts commit eecb79506d88b268fb0d00cce178213b4aa17933.

llvm-svn: 286334
2016-11-09 03:38:21 +00:00
Petr Hosek b346e3e527 [CMake] Check runtimes subdir when looking for libcxx and libuwind
The runtimes subdir is the new location for runtimes, we should
include it when looking for libcxx and libunwind headers.

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

llvm-svn: 286332
2016-11-09 03:22:19 +00:00
Mehdi Amini b4459b1cb2 Fix typo in CMakeLists.txt: provide the path to libcxx checkout and not the include subdir
llvm-svn: 286164
2016-11-07 22:16:27 +00:00
Mehdi Amini c1f152d8d1 Fix libcxxabi CMake detection of libcxx path to handle LLVM_EXTERNAL_LIBCXX_SOURCE_DIR flag
Differential Revision: https://reviews.llvm.org/D26364

llvm-svn: 286161
2016-11-07 22:07:43 +00:00
Mehdi Amini a09c7e7e66 Revert "Add some facilities to work with a git monorepo (experimental setup)"
This reverts commit r286123, accidentally commited while testing itself...

llvm-svn: 286124
2016-11-07 17:43:08 +00:00
Mehdi Amini 7b9e9f2857 Add some facilities to work with a git monorepo (experimental setup)
Summary:
Some changes are made to cmake, especially the addition of a new
LLVM_ENABLE_PROJECTS option that makes the build system aware of
the monorepo directory structure.

Also a new script is added in llvm/utils/git-svn/. When present in
the $PATH, it enables a `git llvm` command. It is providing at this
point only the ability to push from the git monorepo: `git llvm push`.
It is intended to evolves with more features, for instance I plan on
features like `git llvm show r284955` to help working with sequential
revision numbers.
The push feature is taken from Justin Lebar's script available here:
https://github.com/jlebar/llvm-repo-tools/

Reviewers: jlebar

Subscribers: mgorny, modocache, llvm-commits

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

llvm-svn: 286123
2016-11-07 17:40:28 +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 82a1fc8db6 Spell libcxxabi-no-threads correctly
llvm-svn: 285571
2016-10-31 14:14:04 +00:00
Eric Fiselier 2d4fbb7b0c Mark thread exit test as unsupported w/o threads
llvm-svn: 285523
2016-10-30 20:05:52 +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
Eric Fiselier ccc6502abc Mark test as unsupported without threads
llvm-svn: 284217
2016-10-14 09:12:53 +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 c3dc89e4ab Fix libc++abi test config after recent libc++ changes
llvm-svn: 283962
2016-10-12 01:19:16 +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
Logan Chien 78d8ac368f [CMake] Fix libc++abi standalone cmake build.
The cmake files install directory has been changed to
${prefix}/lib/cmake/llvm since r259821.  Searching cmake modules in
${prefix}/share/llvm/cmake will result in fatal errors.

This commit fixes the out-of-tree build by changing the CMake module
search path to: "$(llvm-config --obj-root)/lib/cmake/llvm"

llvm-svn: 283100
2016-10-03 11:08:17 +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
Shoaib Meenai 88c6acfedc [libc++abi] Default to DLL annotations on Windows
`__declspec(dllexport)` and `__declspec(dllimport)` should only be used
when building libc++abi as a DLL, but that's the more common use case,
so default to adding the annotations and add an option to opt out.

Similar to r282449, which made the corresponding change for libc++.

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

llvm-svn: 282470
2016-09-27 03:44:09 +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
Eric Fiselier b4e15b8cee Fix side effect in assertion
llvm-svn: 281709
2016-09-16 08:16:07 +00:00
Logan Chien 7a78e5113a [lit] Replace print with lit_config.note().
This commit replaces print statement with lit_config.note().  This fixes
python3 support for check-libcxxabi.

llvm-svn: 280484
2016-09-02 13:56:05 +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
Chris Bieneman fafcb85e79 [CMake] Trying to fix the bots I broke
See: http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-cxx1z/builds/981/steps/build.libcxxabi/logs/stdio
llvm-svn: 280023
2016-08-29 22:26:00 +00:00
Chris Bieneman 8223a1d09f [CMake] Use -std=c++11 if supported
Summary: This patch adds a check for if -std=c++11 is a supported flag, and adds it to CMAKE_CXX_FLAGS if it is supported.

Reviewers: EricWF

Subscribers: cfe-commits

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

llvm-svn: 280021
2016-08-29 22:12:21 +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
Saleem Abdulrasool 0b7b36a9dd test: fix test under ASAN and MSAN
When we're running tests under ASAN or MSAN, they're compiled with -O1, which
enables tail call elimination. This causes backtrace_test to fail: the compiler
performs tail call elimination for call3_nothrow, but it can't for call3_throw,
leading to a mismatched frame count. Disable tail call elimination (and
inlining, just to be explicit) to avoid this.

Patch by Shoaib Meenai!

llvm-svn: 279935
2016-08-28 18:16:00 +00:00
Eric Fiselier 937c13d922 Default LIBCXXABI_LIBDIR_SUFFIX to LLVM_LIBDIR_SUFFIX
llvm-svn: 278773
2016-08-16 03:44:55 +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
Petr Hosek daee3be364 Do not depend on unwind when building standalone
When libcxxabi is being built standalone, unwind dependency is not
available, so do not use it even when LLVM unwinder is being
requested.

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

llvm-svn: 278058
2016-08-08 22:09:54 +00:00
Eugene Zelenko 9d09275fa6 CMakeLists.txt cleanups: synchronize version with rest of LLVM, consistent spacing.
Differential revision: https://reviews.llvm.org/D23092

llvm-svn: 278030
2016-08-08 17:59:02 +00:00
Richard Smith 398d9c0c4a Attempt to bring peace to -Werror buildbots.
llvm-svn: 276022
2016-07-19 20:35:09 +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
Eric Fiselier b6b04e2013 Fix arc config to use https
llvm-svn: 275752
2016-07-18 02:05:52 +00:00
Saleem Abdulrasool 6e2aa5e1a9 libc++abi: add a top level option for using CompilerRT
Add an option to opt into compiler-rt instead of libgcc.  This option defaults
to OFF to avoid a behaviour change.  It is not possible to mix and match
different runtime libraries.  Disabling this requires that libc++ is built
accordingly.  This knob is particularly useful for targets that are GCC by
default (i.e. Linux).

llvm-svn: 275505
2016-07-15 00:49:42 +00:00
Eric Fiselier d1804db966 Fix [libcxxabi] Fix warning about uninitialized const member.
llvm-svn: 272824
2016-06-15 19:59:16 +00:00
Eric Fiselier 567b755b7c Fix warning about uninitialized const member. NFC
llvm-svn: 272823
2016-06-15 19:48:26 +00:00
Eric Fiselier 78621e4076 [libcxxabi] Reorder base class initializers in libc++abi tests to prevent -Wreorder
Summary:
This patch fixes -Wreorder warnings on test classes with virtual bases. Since the compiler is performing the reordering anyway this change *should* have NFC.

However the test notes that it is checking that "virtual base classes work properly". Since initialization order is clearly part of correctness I want to confirm that this wasn't an intentional mistake.



Reviewers: mclow.lists, howard.hinnant

Subscribers: cfe-commits

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

llvm-svn: 272821
2016-06-15 19:33:01 +00:00
Eric Fiselier f5ff11c432 Suppress warnings about the operations currently under test.
llvm-svn: 272819
2016-06-15 19:07:19 +00:00
Eric Fiselier 2d6714a9c5 Partially revert r270816: build with -fvisibility=hidden.
This patch breaks the ABI on linux when libc++abi.a is statically linked into
libc++.so. Certain libc++ symbols get exported from libc++abi.a as hidden
and therefore they also get hidden in libc++.so.

The symbols is question are:

* _ZNKSt3__121__basic_string_commonILb1EE20__throw_out_of_rangeEv
* _ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv
* _ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv

I imagine we just need to fix the visibility for these symbols in the libc++
headers but I'm reverting the patch until it's sorted.

llvm-svn: 271500
2016-06-02 08:14:28 +00:00
Eric Fiselier ffd1893df5 [libcxxabi] Allow target flags to affect configuration tests.
Summary:
This patch changes the libc++abi CMake so that it adds certain target flags like  '-m32' or '--gcc-toolchain' before including `config-ix.cmake`.
Since these flags can affect things like `check_library_exists([...])` they needed to be added before the tests are performed.

Additionally this patch adds `LIBCXXABI_BUILD_32_BITS` which defaults to `LLVM_BUILD_32_BITS`.

This patch fixes:

https://llvm.org/bugs/show_bug.cgi?id=27950
https://llvm.org/bugs/show_bug.cgi?id=27959

Reviewers: danalbert, jroelofs, bcraig, compnerd, EricWF

Subscribers: cfe-commits

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

llvm-svn: 271470
2016-06-02 02:18:31 +00:00
Asiri Rathnayake ece18f4c14 [libcxxabi][test] Add missing return statement.
This causes a test failure when running with -Werror=return-type.

NFC.

llvm-svn: 271423
2016-06-01 19:13:53 +00:00
Ben Craig 658310b83e Missed part of D16545 (static lib testing)
http://reviews.llvm.org/D16545

llvm-svn: 271388
2016-06-01 12:50:30 +00:00
Chris Bieneman 1d72b89580 [CMake] Update to requiring CMake 3.4.3
Summary:
This is as per the discussions on developer lists:

http://lists.llvm.org/pipermail/llvm-dev/2016-April/098780.html
http://lists.llvm.org/pipermail/llvm-dev/2016-May/100058.html

Subscribers: cfe-commits

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

llvm-svn: 271330
2016-05-31 20:21:53 +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
Ben Craig 24a986108f Allow explicit pthread opt-in
When building libcxxabi in tree (i.e. in llvm/projects/libcxxabi,
along with llvm/projects/libcxx), libcxx's config_site.in doesn't
get created in a timely manner. This means that any configuration
that is normally set in libcxx's config_site.in needs to be
duplicated in libcxxabi to successfully build libcxxabi. This patch
does exactly that for the _LIBCPP_HAS_THREAD_API_PTHREAD
preprocessor define.

http://reviews.llvm.org/D20574

llvm-svn: 270732
2016-05-25 17:37:38 +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 e9fdfd868a Enable testing for static libc++abi
This change leverages framework changes made in libcxx. See those changes for
more details. (http://reviews.llvm.org/D16544)

Some Mac specific logic for testing against libc++abi had to be moved from
libcxxabi's config.py, as it was overriding choices made in libcxx's config.py.
That logic is now in libcxx's target_info.py.

http://reviews.llvm.org/D16545

llvm-svn: 266729
2016-04-19 12:47:38 +00:00
Eugene Zelenko 7deb1ac8a1 [CMake] Fix misleading error message in CMakeLists.txt.
Differential revision: http://reviews.llvm.org/D17117

llvm-svn: 266635
2016-04-18 17:40:18 +00:00
Ben Craig ab56c4041b Respect LIBCXXABI_LIBDIR_SUFFIX before an install
Prior to this patch, setting LIBCXXABI_LIBDIR_SUFFIX would confuse the
check-libcxxabi target. libc++abi.* would get output to lib instead of
lib${LIBCXXABI_LIBDIR_SUFFIX}, but the tests would look in the suffixed
directory.

Now, we match what libcxx does, and set the CMAKE_*_OUTPUT_DIRECTORY to the
LIBRARY_DIR.

http://reviews.llvm.org/D17410

llvm-svn: 266611
2016-04-18 13:30:38 +00:00
Paul Robinson d74e849270 Update copyright year to 2016.
llvm-svn: 264952
2016-03-30 22:40:47 +00:00
Jonas Hahnfeld 626557be6b [libcxxabi] Disable cxa_thread_atexit_test if unavailable
The feature check is already in place when building the library but wasn't
honored for the tests.

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

llvm-svn: 263699
2016-03-17 10:00:24 +00:00
Ben Craig 5d78477ba1 Reducing stack usage of test
This test has a lot of classes with large amounts of manually inserted padding in them, presumably to prevent various optimizations. The test then creates lots of these objects on the stack. On embedded targets, this was usually enough to overflow the stack.

I moved the objects to global / namespace scope. Since the tests are each in their own namespace, there should be no cross-test conflicts.

llvm-svn: 262717
2016-03-04 14:25:13 +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
Ben Craig a6dc36f65e [libcxxabi] Make test tolerant of uncommon floating literal demanglings
libcxxabi uses the C99 library's %a format specifier to turn a floating
point value into a hexadecimal string representation. The %a format
specifier is rather loosely defined in the C spec though, and some C
libraries emit a different (but valid) string for a given floating
point value. In particular, the C spec only requires that there is a
single, non-zero hexadecimal digit on the left of the decimal point.
Given that constraint, there are typically four different valid 
representations of a floating point number. I have updated the test to
accept any of the valid representations for demangled floating
point literals.

llvm-svn: 258311
2016-01-20 14:03:27 +00:00
Eric Fiselier 3f7c20747d Mark some tests as XFAIL with GCC due to compiler bugs
llvm-svn: 258284
2016-01-20 04:06:46 +00:00
Eric Fiselier 203655a936 Fix link flags order in RUN command.
llvm-svn: 258277
2016-01-20 03:04:50 +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
Eric Fiselier 58ad9b19cc Add missing license headers
llvm-svn: 258201
2016-01-19 22:07:10 +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 dfe216dba8 Add new tests for throwing incomplete pointer types
llvm-svn: 256323
2015-12-23 07:04:32 +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
Evgeniy Stepanov 3e01d1b32e Replace cmake check for printf with a check for fopen.
Printf is a builtin, and the check fails with -Werror because of a clang
warning about an incompatible redeclaration.

llvm-svn: 255186
2015-12-10 00:44:42 +00:00
Saleem Abdulrasool 1750b2ba89 .gitignore: ignore vim swap files
llvm-svn: 254692
2015-12-04 02:15:02 +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
Eric Fiselier 3cf3cfc4c5 Fix LIBCXXABI_HAS_NO_THREADS configuration.
llvm-svn: 250316
2015-10-14 19:21:38 +00:00
Eric Fiselier 035ddc2046 Configure for config site header
llvm-svn: 250313
2015-10-14 19:01:47 +00:00
Eric Fiselier 453da19d2d Add config.project_obj_root to the libc++abi testsuite
llvm-svn: 250307
2015-10-14 18:20:48 +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 388c1a040a Convert LIBCXXABI_BUILD_32_BITS to LLVM_BUILD_32_BITS.
llvm-svn: 246516
2015-09-01 01:02:06 +00:00
Eric Fiselier c79a8f7753 Fix or disable C++11 tests in C++03 mode
llvm-svn: 245531
2015-08-20 01:22:17 +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
Nico Weber da99734d89 Revert r243752, it broke running tests on OS X (PR24491).
llvm-svn: 245325
2015-08-18 18:29:33 +00:00
Tanya Lattner be2225f115 Update to new lists.llvm.org
llvm-svn: 244004
2015-08-05 04:01:26 +00:00
Renato Golin 9e737939fb [libc++abi] Allow use just compiled clang++ for tests
Currently, the tests assume the system compiler is the one we want
to test, but if we build libcxxabi together with LLVM+Clang, it'll
get the wrong compiler.

This patch allows us to test if we have clang++ in our /bin directory,
and if so, use it.

llvm-svn: 243752
2015-07-31 15:25:11 +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
Daniel Sanders 83934d3915 [libcxxabi] Add -funwind-tables to the test compilation options.
Summary:
backtrace_test.pass.cpp depends on unwind tables. These are generated by
-funwind-tables which is the default for x86 but not for other targets.

Thanks to Nitesh Jain for helping to narrow this down.

Fixes PR24148

Reviewers: jroelofs

Subscribers: cfe-commits, jroelofs, llvm-commits, hans

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

llvm-svn: 243296
2015-07-27 18:20:17 +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
Anton Korobeynikov 1af9c7b9d4 LIBCXXABI_LIBUNWIND_INCLUDES is already set before calling find_path, and find_path will not update it.
So cmake will throw error "include_directories given empty-string as include directory". 
Use other variable name for the include path and do not find the default libunwind.h in the system path.

http://reviews.llvm.org/D9641

Patch by Jingyi Wei!

llvm-svn: 236936
2015-05-09 21:03:01 +00:00
Anton Korobeynikov 396441c873 Typos
llvm-svn: 236889
2015-05-08 18:14:14 +00:00
Anton Korobeynikov d3b50dce40 Fix "TODO" and provide the configure-time options to find libunwind.
This is done the same way as we're looking for libc++

llvm-svn: 236874
2015-05-08 16:10:11 +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
Eric Fiselier 9429684cce Fix syntax error in CMake created when a variable is not defined.
llvm-svn: 236115
2015-04-29 15:53:03 +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 e5f6e2b671 libc++abi: try harder to force the LLVM unwinder on ARM
Attempting to default the option to ON for ARM doesnt seem to work.  Force the
check lower and perform the check at the two sites that matter: the CPPFLAGS
definition and the header search path setup.

llvm-svn: 235964
2015-04-28 02:09:53 +00:00
Saleem Abdulrasool fd8a75d730 libc++abi: enable LLVM unwinder by default for ARM
libc++abi uses EHABI extensions, which are only part of the LLVM unwinder.  When
targeting ARM by default, enable the use of the LLVM unwinder.  Hopefully this
will fix the ARM native bot

llvm-svn: 235904
2015-04-27 18:19:33 +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 a121d08ff8 libc++abi: remove build infrastructure for unwind
This removes the libunwind build infrastructure as libunwind is gaining its own
CMakeLists.txt.  The removal must occur first due to the multiple definitions of
the same target.

llvm-svn: 235794
2015-04-25 01:46:29 +00:00
Saleem Abdulrasool ac18e0639f libc++abi: move tests back
These are apparently related to libc++'s unwind personality handler and not
unwind core.  Move them back to the correct location.

llvm-svn: 235765
2015-04-24 20:20:54 +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
Eric Fiselier 0e90f3ff9a Revert r228351 - Dont install header files.
llvm-svn: 233781
2015-04-01 02:56:13 +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 cf74f5d20b Let libc++'s LIT configuration setup our linker paths and env.
llvm-svn: 232529
2015-03-17 19:45:21 +00:00
Eric Fiselier 4260252222 add option to tell LIT where to find the libc++ library when built out of tree
llvm-svn: 232518
2015-03-17 18:58:14 +00:00
Renato Golin fab3c735c3 Update copyright year to 2015.
llvm-svn: 232095
2015-03-12 20:13:54 +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