1523 Commits

Author SHA1 Message Date
David Tenty
63195d3d7a
[NFC][CMake] quote ${CMAKE_SYSTEM_NAME} consistently (#154537)
A CMake change included in CMake 4.0 makes `AIX` into a variable
(similar to `APPLE`, etc.)
ff03db6657

However, `${CMAKE_SYSTEM_NAME}` unfortunately also expands exactly to
`AIX` and `if` auto-expands variable names in CMake. That means you get
a double expansion if you write:

`if (${CMAKE_SYSTEM_NAME}  MATCHES "AIX")`
which becomes:
`if (AIX  MATCHES "AIX")`
which is as if you wrote:
`if (ON MATCHES "AIX")`

You can prevent this by quoting the expansion of "${CMAKE_SYSTEM_NAME}",
due to policy
[CMP0054](https://cmake.org/cmake/help/latest/policy/CMP0054.html#policy:CMP0054)
which is on by default in 4.0+. Most of the LLVM CMake already does
this, but this PR fixes the remaining cases where we do not.
2025-08-20 12:45:41 -04:00
Konstantin Varlamov
3eee9fc2c4
[libc++][hardening] Introduce assertion semantics. (#149459)
Assertion semantics closely mimic C++26 Contracts evaluation semantics.
This brings our implementation closer in line with C++26 Library Hardening
(one particular benefit is that using the `observe` semantic makes adopting
hardening easier for projects).
2025-07-29 00:19:15 -07:00
Andrew Rogers
04f5198e3e
[llvm] annotate interfaces in Demangle for DLL export (#147564)
## Purpose

This patch is one in a series of code-mods that annotate LLVM’s public
interface for export. This patch annotates the `Demangle` interface with
a new `DEMANGLE_ABI` annotation, which behaves like the `LLVM_ABI`. This
annotation currently has no meaningful impact on the LLVM build;
however, it is a prerequisite to support an LLVM Windows DLL (shared
library) build.

## Overview

1. Add a new `Demangle/Visibility.h` header file that defines a new
`DEMANGLE_ABI` macro. The macro resolves to the proper DLL export/import
annotation on Windows and a "default" visibility annotation elsewhere.
2. Add a new `LLVM_ENABLE_DEMANGLE_EXPORT_ANNOTATIONS ` `#cmakedefine`
that is used to gate the definition of `DEMANGLE_ABI`.
3. Code-mod annotate the public `Demangle` interface using the
[Interface Definition Scanner (IDS)](https://github.com/compnerd/ids)
tool.
4. Manually fix-up `#include` statements for consistency.
5. Format the changes with `clang-format`.
6. Add a "stub" version of `Visibility.h` under `libcxxabi/src/demangle`
that always defines `DEMANGLE_ABI` to nothing.
7. Update the canonical `libcxxabi/src/demangle/ItaniumDemangle.h`
instead of the llvm copy, and run `cp-to-llvm.sh` to ensure the llvm
copy matches. NOTE: we rely on `ccp-to-llvm.sh` not copying
`Visibillity.h` as is already the case for `DemangleConfig.h`.

## Background

This PR follows the pattern established with the `llvm-c` changes made
in #141701.

This effort is tracked in #109483. Additional context is provided in
[this
discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307),
and documentation for `LLVM_ABI` and related annotations is found in the
LLVM repo
[here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst).

## Validation

Local builds and tests to validate cross-platform compatibility. This
included llvm, clang, and lldb on the following configurations:

- Windows with MSVC
- Windows with Clang
- Linux with GCC
- Linux with Clang
- Darwin with Clang

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2025-07-24 12:50:16 +02:00
Nikolas Klauser
339a1f2e8f
Revert "[libc++][hardening] Introduce assertion semantics" (#148822)
Reverts llvm/llvm-project#148268

It looks like this was based on #148266, which I reverted in #148787.
2025-07-15 12:43:37 +02:00
Konstantin Varlamov
7345508c6f
[libc++][hardening] Introduce assertion semantics (#148268)
Assertion semantics closely mimic C++26 Contracts evaluation semantics.
This brings our implementation closer in line with C++26 Library
Hardening (one particular benefit is that using the `observe` semantic
makes adopting hardening easier for projects).
2025-07-15 02:14:30 -07:00
Petr Hosek
9d3b60dea7
[libcxxabi][libunwind] Support for using LLVM libc (#134893)
This generalizes the support added in #99287 renaming the option to
RUNTIMES_USE_LIBC and integrating the module into libc++abi and
libunwind as well.
2025-07-09 00:48:50 -07:00
Raul Tambre
431507db52
[libcxxabi][cmake] Account for LIBCXXABI_TARGET_SUBDIR in test config (#138527)
This makes the logic and code structure match that of libc++, which handles this case (i.e. the target subdirectory being changed).
The `%{target}` substitution from libc++ is removed as libc++abi's config seems to be the only place it's used.
2025-07-03 12:07:25 +03:00
Larry Meadows
20f56d1409
[libc++abi] Fix C++ demangling for _BitInt type (#143466)
The front-end expects _BitInt to be available for substitution; ensure DB<n> is
added to Subs in ItaniumDemangle.h. Also add a test case to libc++abi and
sync the files to llvm/include/llvm.
2025-06-25 15:06:11 -04:00
tynasello-google
13fe07d670
[libc++] Expand Android libc++ test config files (#142846)
Parameterize (and rename) existing libc++/libc++abi test configuration
files for the Android NDK to work for both the NDK and platform.

Android LLVM downstream seeks to test libc++ for both the NDK and
platform build (currently only testing the NDK), which will use almost
identical test configuration files. The only difference is the name of
the libc++ shared object used. Because of this we parameterize the
current test files (for both libc++ and libc++abi) with the existing
LIBCXX_SHARED_OUTPUT_NAME cmake variable, and rename the file
accordingly.
2025-06-12 11:39:28 -04:00
Nikolas Klauser
42c82fcc29
[libc++] Upgrade to GCC 15 (#138293) 2025-06-11 20:19:26 +02:00
Michael Buch
061ef3c6e2
[libcxxabi][test] Check that all copied files are synced between llvm and libcxxabi (#142262)
This patch expands the list of files we check to all the ones that are
copied via `cp-to-llvm.sh`.
2025-05-31 21:18:54 +01:00
Michael Buch
f7e172da4c
[ItaniumDemangle][test] Factor demangler test-cases into file and sync into LLVM (#137947)
This patch turns the `libcxxabi/test/test_demangle.pass.cpp` into gtest
unit-tests in `llvm/unittests/Demangle`. The main motivation for this is
https://github.com/llvm/llvm-project/pull/137793, where we want to
re-use the test-cases from the ItaniumDemangler to test our OutputBuffer
implementation.

`libcxxabi/test/test_demangle.pass.cpp` now only tests the
`__cxa_demangle` API surface, not the underlying ItaniumDemangle
implementation.
2025-05-30 19:56:50 +01:00
Aiden Grossman
c1970c76ad
[libcxxabi] Add test to assert that ItaniumDemangle.h is the same (#140323)
ItaniumDemangle.h exists in both llvm/ and libcxxabi/. These files are
supposed to be copies of each other (minus the top two lines). This
patch adds a test to assert that this is the case to enable tooling to
automatically detect this as an issue, like in #139825. This makes it
easier for contributors unfamiliar with the duplication to make
changes/get appropriate reviews.

Ideally we would share the file and copy it from one place to the other
but the ideal way to do this (based on previous discussion with libc++
maintainers) would be a new runtime library that clearly outlines
requirements, so that is left for later with the test being used as a
stopgap. This is a relatively common approach for structures shared
between compiler-rt and LLVM.

This patch does make the test reference the LLVM source directory, but
that should be fine given building libcxxabi is only supported through
the runtimes build in the monorepo meaning it should always be
available.
2025-05-27 16:40:26 -07:00
Aiden Grossman
23a674d2ec
[libcxxabi] Update ItaniumDemangle.h from LLVM (#140273)
76ba29bfd8e8aaf5b0267598d18434a0d13945a2 landed changes in
ItaniumDemangle.h on the LLVM side that were not propagated over to the
libcxxabi side. This patch fixes that.
2025-05-16 09:26:09 -07:00
Raul Tambre
fc3b67aee8
[cmake] Normalize TARGET_SUBDIR paths (#138524)
Some code paths normalize ".." and thus don't create the directory. But some execute in a
shell thus requiring the directory to exist to be able to take the parent directory.

This patch normalizes all the `TARGET_SUBDIR` variables to avoid this issue.
2025-05-12 15:59:39 -04:00
Michael Buch
028f70d252
[ItaniumDemangle] Add Named flag to "pm" operator (#136862)
Compilers can generate mangled names such as `_ZN1CpmEi` which we
currently fail to demangle. The OperatorInfo table only marked the `pt`
operator as being "named", which prevented the others from demangling
properly. Removing this logic for the other kinds of member operators
isn't causing any tests to fail.
2025-05-12 15:56:07 -04:00
Petr Hosek
25a03c1c7c
[libcxx][NFC] Use macros for functions that support overriding detection (#133876)
We plan to replace the existing mechanism for overriding detection with
one that doesn't require the use of a special section as an alternative
to llvm/llvm-project#120805 which had other downsides.

This change is a pure refactoring that lays the foundation for a
subsequent change that will introduce the new detection mechanism.
2025-05-09 11:25:14 -07:00
Dmitry Vasilyev
0dce0ea31c
[ItaniumDemangle] Fix libcxxabi OutputBuffer::prepend for empty inputs (#138656)
See #138564 for details.
2025-05-06 13:16:51 +04:00
Michael Buch
bd96fa7788 [ItaniumDemangle][NFC] Add getter to ObjCProtoName::getProtocol
And remove now redunant friend declaration.

For some reason this was failing to build on one of the MSVC bots after
https://github.com/llvm/llvm-project/pull/131836:
```
FAILED: tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.obj

ccache C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\cl.exe  /nologo /TP -DCLANG_BUILD_STATIC -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\source\Plugins\ExpressionParser\Clang -IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\ExpressionParser\Clang -IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\build\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\llvm\include -IC:\Python312\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\llvm\..\clang\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\..\clang\include -IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source -IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\source -D__OPTIMIZE__ /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD   -wd4018 -wd4068 -wd4150 -wd4201 -wd4251 -wd4521 -wd4530 -wd4589  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\lldb\source\Plugins\ExpressionParser\Clang\CMakeFiles\lldbPluginExpressionParserClang.dir\ClangExpressionParser.cpp.obj /Fdtools\lldb\source\Plugins\ExpressionParser\Clang\CMakeFiles\lldbPluginExpressionParserClang.dir\lldbPluginExpressionParserClang.pdb /FS -c C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangExpressionParser.cpp

C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\llvm\include\llvm/Demangle/ItaniumDemangle.h(667): error C2248: 'llvm::itanium_demangle::ObjCProtoName::Protocol': cannot access private member declared in class 'llvm::itanium_demangle::ObjCProtoName'

C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\llvm\include\llvm/Demangle/ItaniumDemangle.h(615): note: see declaration of 'llvm::itanium_demangle::ObjCProtoName::Protocol'

C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\llvm\include\llvm/Demangle/ItaniumDemangle.h(613): note: see declaration of 'llvm::itanium_demangle::ObjCProtoName'
```

It's not quite clear to me why this wasn't compiling but either way this
is cleaner.
2025-04-25 22:12:39 +01:00
Michael Buch
46f18b7c6f [ItaniumDemangle][test] Add test-cases for ref-qualified member pointer parameters
I noticed that there are test-cases that are commented out. But the
manglings for them seem to be impossible to generate from valid C++. I
added two test-cases generated from following C++ program:
```
struct X {
    int func() const && { return 5; }
    const int &&func2() { return 5; }
    const int &&func3(const int &x) volatile { return 5; }
};

void f(int (X::*)() const &&, int const && (X::*)(),
       int const && (X::*)(const int &) volatile) {}

int main() {
    f(&X::func, &X::func2, &X::func3);
    return 0;
}
```
2025-04-23 15:42:56 +01:00
Michael Buch
889dad7f40
[ItaniumDemangle] Add customizable printLeft/printRight APIs to OutputBuffer (#133249)
This patch includes the necessary changes for the LLDB feature proposed
in
https://discourse.llvm.org/t/rfc-lldb-highlighting-function-names-in-lldb-backtraces/85309.
The TL;DR is that we want to track where certain parts of a demangled
name begin/end so we can highlight them in backtraces.

We introduce a new `printLeft`/`printRight` API on `OutputBuffer` that a
client (in our case LLDB) can implement to track state while printing
the demangle tree. This requires redirecting all calls to to
`printLeft`/`printRight` to the `OutputBuffer`. One quirk with the new
API is that `Utility.h` would now depend on `ItaniumDemangle.h` and
vice-versa. To keep these files header-only I made the definitions
`inline` and implement the new APIs in `ItaniumDemangle.h` (so the
definition of `Node` is available to them).

Also introduces `notifyInsertion`/`notifyDeletion` APIs that a client can override to respond to cases where the `OutputBuffer` changes arbitrary parts of the name.
2025-04-17 21:53:32 +01:00
Akira Hatanaka
a3283a92ae
[PAC] Add support for __ptrauth type qualifier (#100830)
The qualifier allows programmer to directly control how pointers are
signed when they are stored in a particular variable.

The qualifier takes three arguments: the signing key, a flag specifying
whether address discrimination should be used, and a non-negative
integer that is used for additional discrimination.

```
typedef void (*my_callback)(const void*);
my_callback __ptrauth(ptrauth_key_process_dependent_code, 1, 0xe27a) callback;
```

Co-Authored-By: John McCall rjmccall@apple.com
2025-04-15 12:54:25 -07:00
Mark de Wever
e15025dd50 [libc++] Another Apple CI quick-fix.
Like #135202 this fixes another issue after the XCode update.
2025-04-11 20:02:49 +02:00
Martin Storsjö
8be4bd8570
[libcxxabi] Fix the long double demangling for PowerPC (#135332)
PowerPC uses a slightly different type of floats for their 128 bit long
doubles, as "double-double", with __LDBL_MANT_DIG__ == 106 rather than
__LDBL_MANT_DIG__ == 113 for IEEE 128 bit floats.

This fixes compiling libcxxabi for PowerPC after
3b70715c13876c51542ebfe2e3f4ee908f6785cb.
2025-04-11 12:24:13 +03:00
Martin Storsjö
3b70715c13
[libcxxabi] Use __LDBL_MANT_DIG__ for configuring demangling of long doubles (#134976)
This avoids needing to hardcode the mapping between architectures and
their sizes of long doubles.

This fixes a case in test_demangle.pass.cpp, that previously failed like
this (XFAILed):

    .---command stdout------------
    | Testing 29859 symbols.
| _ZN5test01hIfEEvRAcvjplstT_Le4001a000000000000000E_c should be invalid
but is not
| Got: 0, void test0::h<float>(char (&) [(unsigned int)(sizeof (float) +
0x0.07ff98f7ep-1022L)])
    `-----------------------------
    .---command stderr------------
| Assertion failed: !passed && "demangle did not fail", file
libcxxabi/test/test_demangle.pass.cpp, line 30338
    `-----------------------------

This testcase is defined within

// Is long double fp80? (Only x87 extended double has 64-bit mantissa)
    #define LDBL_FP80 (__LDBL_MANT_DIG__ == 64)
    ...
    #if !LDBL_FP80
    ...
    #endif

The case failed on x86 architectures with an unusual size for long
doubles, as the test expected the demangler to not be able to demangle
an 80 bit long double (based on the `__LDBL_MANT_DIG__ == 64` condition
in the test). However as the libcxxabi implementation was hardcoded to
demangle 80 bit long doubles on x86_64 regardless of the actual size,
this test failed (by unexpectedly being able to demangle it).

By configuring libcxxabi's demangling of long doubles to match what the
compiler specifies, we no longer hit the expected failures in the
test_demangle.pass.cpp test on Android on x86.

This makes libcxxabi require a GCC-compatible compiler that defines
nonstandard defines like `__LDBL_MANT_DIG__`, but I presume that's
already essentially required anyway.
2025-04-11 08:54:11 +03:00
A. Jiang
ab95005a05
[libc++] P3247R2: Deprecate is_trivial(_v) (#130573)
Requirements on character-like types are updated unconditionally,
because `basic_string` does requires the default-constructibility. It
might be possible to make `basic_string_view` support classes with
non-public trivial default constructor, but this doesn't seem sensible.

libcxxabi's `ItaniumDemangle.h` is also updated to avoid deprecated
features.
2025-04-09 07:40:01 +08:00
Takuto Ikuta
75dd4119b2
[libc++abi] Add a missing include for abort() (#126865)
This is to fix a build error when we use Clang modules in Chromium.
2025-02-12 14:18:02 +01:00
Louis Dionne
a06c893876
[libc++abi] Make once_flag constinit in cxa_exception_storage (#124627)
This makes it clearer that initialization of this global variable is
taking place at compile-time, reducing the likelihood of static
initialization order fiasco.
2025-01-28 16:44:57 -05:00
Petr Hosek
4167ea2cb0
Revert "[libcxx] Use alias for detecting overriden function" (#124431)
Reverts llvm/llvm-project#120805

This change while desirable has two issues we discovered:

- It is incompatible with `-funique-internal-linkage-names`, see
https://github.com/llvm/llvm-project/pull/120805#discussion_r1913709817
- It is incompatible with `-fvisibility-global-new-delete=force-hidden`,
see
https://github.com/llvm/llvm-project/issues/123224#issuecomment-2607963878

We were hoping to address both of these issues with
https://github.com/llvm/llvm-project/pull/122983, but that change has
other issues we haven't yet managed to resolve. For now, we have decided
to revert the change to avoid shipping a broken feature in LLVM 20, and
we plan to follow up with a new approach post branch.
2025-01-27 22:26:15 -08:00
Brad Smith
9fd9263474
[libc++abi] Remove support for Android 4 and older (#124054) 2025-01-23 10:26:02 +01:00
Nikolas Klauser
ef804d8f9b
[libc++] Simplify when the sized global deallocations overloads are available (#114667)
There doesn't seem to be much benefit in always providing declarations
for the sized deallocations from C++14 onwards if the user explicitly
passed `-fno-sized-deallocation` to disable them. This patch simplifies
the declarations to be available exactly when the compiler expects sized
deallocation functions to be available.
2025-01-14 16:21:03 -05:00
Kirill Stoimenov
576b53801f Revert "[libc++] Stop copying headers to the build directory (#115380)"
This reverts commit 428c8767ae997b0f726c0b40160ea8172551babf.

Breaks sanitizer build: https://lab.llvm.org/buildbot/#/builders/51/builds/9056
2025-01-14 18:23:07 +00:00
Alexander Richardson
428c8767ae
[libc++] Stop copying headers to the build directory (#115380)
This was needed before https://github.com/llvm/llvm-project/pull/115077
since the compiler-rt test build made assumptions about the build
layout of libc++ and libc++abi, but now they link against a local
installation of these libraries so we no longer need this workaround.
2025-01-14 08:40:04 -05:00
Fraser Cormack
a100fd8cbd
[libc++abi][ItaniumDemangle] Demangle DF16b as std::bfloat16_t (#120109)
This mangling is official in the Itanium C++ ABI specification and is
already supported by clang.
2025-01-13 16:15:40 -05:00
Petr Hosek
841895543e
[libcxx] Use alias for detecting overriden function (#120805)
This mechanism is preferable in environments like embedded since it
doesn't require special handling of the custom section.

This is a reland of https://github.com/llvm/llvm-project/pull/114961
which addresses the issue reported by downstream users. Specifically,
the two differences from the previous version are:

* The internal `symbol##_impl__` symbol in the Mach-O implementation is
  annotated with `__attribute__((used))` to prevent LTO from deleting it
  which we've seen in the previous version.
* `__is_function_overridden` is marked as `inline` so these symbols are
  placed in a COMDAT (or fully inlined) to avoid duplicate symbol errors
  which we've seen in the previous version.
2025-01-07 16:45:48 -05:00
Nico Weber
8dfae0c462 Revert "[libcxx] Use alias for detecting overriden function (#114961)"
This reverts commit 62bd10f7d18ca6f544286767cae2c9026d493888.
Breaks building with -flto=thin, see
https://github.com/llvm/llvm-project/pull/114961#issuecomment-2555754056
2024-12-19 15:54:06 -05:00
Petr Hosek
62bd10f7d1
[libcxx] Use alias for detecting overriden function (#114961)
This mechanism is preferable in environments like embedded since it
doesn't require special handling of the custom section.
2024-12-17 08:16:26 -08:00
Nikolas Klauser
59890c1334
[libc++] Granularize <new> includes (#119964) 2024-12-17 11:29:16 +01:00
Hubert Tong
d33bf2e9df NFC: clang-format test_demangle.pass.cpp but keep test "lines"
Add clang-format on/off around test "lines"

Run clang-format without breaking string literals:
clang-format --style='{BasedOnStyle: llvm, BreakStringLiterals: false}'
-i test_demangle.pass.cpp

Add clang-format on/off on fp_literal_cases

Fixups: Split UNSUPPORTED to next line; xfail_cases trailing comma

Replace physical tab
2024-12-14 20:01:23 -05:00
Louis Dionne
9474e09459
[libc++] Granularize the <new> header (#119270)
This disentangles the code which previously had a mix of many #ifdefs, a
non-versioned namespace and a versioned namespace. It also makes it
clearer which parts of <new> are implemented on Windows by including <new.h>.
2024-12-13 14:17:56 -05:00
Vitaly Buka
3de5e8b23f
[libc++abi] Build cxxabi with sanitizers (#119612) 2024-12-12 18:03:12 -08:00
Vitaly Buka
a54fce89fc
[libc++abi] Don't do pointer arithmetic on nullptr (#119520)
`nullptr + offset` is possible after `!is_virtual` branch.

Detected with check-cxxabi on configured with:
```
cmake -DLLVM_APPEND_VC_REV=OFF -GNinja \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_CCACHE_BUILD=ON \
  -DLLVM_USE_LINKER=lld \
  -DLLVM_ENABLE_ASSERTIONS=ON \
  -DCMAKE_C_COMPILER=clang \
  -DCMAKE_CXX_COMPILER=clang++ \
  -DLIBCXXABI_USE_LLVM_UNWINDER=OFF \
  -DCMAKE_INSTALL_PREFIX=/home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/libcxx_install_ubsan \
  '-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi;libunwind' \
  -DLIBCXX_TEST_PARAMS=long_tests=False \
  -DLIBCXX_INCLUDE_BENCHMARKS=OFF \
  -DLLVM_USE_SANITIZER=Undefined \
  '-DCMAKE_C_FLAGS=-fsanitize=undefined -fno-sanitize-recover=all   -fno-sanitize=vptr' \
  '-DCMAKE_CXX_FLAGS=-fsanitize=undefined -fno-sanitize-recover=all   -fno-sanitize=vptr' \
  /home/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/../runtimes

********************
Failed Tests (2):
  llvm-libc++abi-shared.cfg.in :: catch_null_pointer_to_object_pr64953.pass.cpp
  llvm-libc++abi-shared.cfg.in :: catch_ptr_02.pass.cpp
```
2024-12-11 12:51:10 -08:00
Louis Dionne
b0b546d447
[libc++abi] Provide an explicit error when trying to build for MSVC (#119370)
Fixes #119322
2024-12-11 12:49:06 -05:00
Vitaly Buka
a4538cdcee
[libc++abi] Don't leak in test (#119505)
Trying to re-enable a test on bots

bb695735db/zorg/buildbot/builders/sanitizers/buildbot_functions.sh (L443)

When we reach `terminate()` `exc` pointer is not
on the stack, so lsan correctly reports a leak.
2024-12-10 22:02:32 -08:00
Hubert Tong
918d4558b0
[libc++abi] Enable demangling of cp expression production (#114882)
See itanium-cxx-abi/cxx-abi#196
2024-12-10 20:24:15 -04:00
Paul Kirth
fac9fcd552
[libcxxabi] Always link against libzircon for Fuchsia targets (#115910)
When using LTO, the deplibs mechanism is insufficient to ensure that
libzircon is always brought into the link prior to LTO code generation.
The general problem is discussed in depth in
https://github.com/llvm/llvm-project/issues/56070

To work around this, we can just provide libzircon as a link input.
2024-12-09 09:19:51 -08:00
Louis Dionne
b23fc2c5bf
[libc++abi] Fix broken check for _LIBCPP_HAS_THREAD_API_PTHREAD (#118999)
We were still using the old `defined(_LIBCPP_HAS_THREAD_API_PTHREAD)`
check, which is always true.
2024-12-06 15:30:02 -05:00
Nikolas Klauser
b69ddbc628
[libc++] Make variables in templates inline (#115785)
The variables are all `constexpr`, which implies `inline`. Since they
aren't `constexpr` in C++03 they're also not `inline` there. Because of
that we define them out-of-line currently. Instead we can use the C++17
extension of `inline` variables, which results in the same weak
definitions of the variables but without having all the boilerplate.
2024-11-13 11:57:16 +01:00
Alexander Richardson
eaed095a56
Revert "Reapply "[libc++abi] Stop copying headers to the build directory"" (#115793)
Reverts llvm/llvm-project#115379

Reverting since this broke the Fuchsia builders.
2024-11-11 16:20:44 -08:00
Alexander Richardson
fd799add21
Reapply "[libc++abi] Stop copying headers to the build directory"
This was needed before https://github.com/llvm/llvm-project/pull/115077
since the compiler-rt test build made assumptions about the build
layout of libc++ and libc++abi, but now they link against a local
installation of these libraries so we no longer need this workaround.

The last attempt at landing this was reverted due to buildbot failures
which should be fixed by https://github.com/llvm/llvm-zorg/pull/299.

Pull Request: https://github.com/llvm/llvm-project/pull/115379
2024-11-07 14:50:10 -08:00