Commit Graph

444 Commits

Author SHA1 Message Date
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 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
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
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 187fd40ca4 Use _LIBCPP_FALLTHROUGH() to avoid warnings about [[gnu::fallthrough]] being unsupported
llvm-svn: 305500
2017-06-15 20:18:10 +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 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
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
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 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
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 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
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
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 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 6aa4f1d1af Turn on -Wunused-function and cleanup occurances
llvm-svn: 296936
2017-03-04 01:02:35 +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