Skip to content

Commit 2be510f

Browse files
authored
Merge branch 'main' into main
2 parents 615eee2 + dacd2f9 commit 2be510f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2356
-739
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5432,8 +5432,7 @@ bool Compiler<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) {
54325432
unsigned EndIndex = 0;
54335433
// Find the init list.
54345434
for (StartIndex = InitStack.size() - 1; StartIndex > 0; --StartIndex) {
5435-
if (InitStack[StartIndex].Kind == InitLink::K_InitList ||
5436-
InitStack[StartIndex].Kind == InitLink::K_This) {
5435+
if (InitStack[StartIndex].Kind == InitLink::K_DIE) {
54375436
EndIndex = StartIndex;
54385437
--StartIndex;
54395438
break;
@@ -5446,7 +5445,8 @@ bool Compiler<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) {
54465445
continue;
54475446

54485447
if (InitStack[StartIndex].Kind != InitLink::K_Field &&
5449-
InitStack[StartIndex].Kind != InitLink::K_Elem)
5448+
InitStack[StartIndex].Kind != InitLink::K_Elem &&
5449+
InitStack[StartIndex].Kind != InitLink::K_DIE)
54505450
break;
54515451
}
54525452

@@ -5457,7 +5457,8 @@ bool Compiler<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) {
54575457

54585458
// Emit the instructions.
54595459
for (unsigned I = StartIndex; I != (EndIndex + 1); ++I) {
5460-
if (InitStack[I].Kind == InitLink::K_InitList)
5460+
if (InitStack[I].Kind == InitLink::K_InitList ||
5461+
InitStack[I].Kind == InitLink::K_DIE)
54615462
continue;
54625463
if (!InitStack[I].template emit<Emitter>(this, E))
54635464
return false;
@@ -6328,8 +6329,8 @@ bool Compiler<Emitter>::compileConstructor(const CXXConstructorDecl *Ctor) {
63286329

63296330
unsigned FirstLinkOffset =
63306331
R->getField(cast<FieldDecl>(IFD->chain()[0]))->Offset;
6331-
InitStackScope<Emitter> ISS(this, isa<CXXDefaultInitExpr>(InitExpr));
63326332
InitLinkScope<Emitter> ILS(this, InitLink::Field(FirstLinkOffset));
6333+
InitStackScope<Emitter> ISS(this, isa<CXXDefaultInitExpr>(InitExpr));
63336334
if (!emitFieldInitializer(NestedField, NestedFieldOffset, InitExpr,
63346335
IsUnion))
63356336
return false;

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ struct InitLink {
5252
K_Decl = 3,
5353
K_Elem = 5,
5454
K_RVO = 6,
55-
K_InitList = 7
55+
K_InitList = 7,
56+
K_DIE = 8,
5657
};
5758

5859
static InitLink This() { return InitLink{K_This}; }
5960
static InitLink InitList() { return InitLink{K_InitList}; }
6061
static InitLink RVO() { return InitLink{K_RVO}; }
62+
static InitLink DIE() { return InitLink{K_DIE}; }
6163
static InitLink Field(unsigned Offset) {
6264
InitLink IL{K_Field};
6365
IL.Offset = Offset;
@@ -668,22 +670,29 @@ template <class Emitter> class InitLinkScope final {
668670

669671
~InitLinkScope() { this->Ctx->InitStack.pop_back(); }
670672

671-
private:
673+
public:
672674
Compiler<Emitter> *Ctx;
673675
};
674676

675677
template <class Emitter> class InitStackScope final {
676678
public:
677679
InitStackScope(Compiler<Emitter> *Ctx, bool Active)
678-
: Ctx(Ctx), OldValue(Ctx->InitStackActive) {
680+
: Ctx(Ctx), OldValue(Ctx->InitStackActive), Active(Active) {
679681
Ctx->InitStackActive = Active;
682+
if (Active)
683+
Ctx->InitStack.push_back(InitLink::DIE());
680684
}
681685

682-
~InitStackScope() { this->Ctx->InitStackActive = OldValue; }
686+
~InitStackScope() {
687+
this->Ctx->InitStackActive = OldValue;
688+
if (Active)
689+
Ctx->InitStack.pop_back();
690+
}
683691

684692
private:
685693
Compiler<Emitter> *Ctx;
686694
bool OldValue;
695+
bool Active;
687696
};
688697

689698
} // namespace interp

clang/test/AST/ByteCode/cxx14.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,24 @@ constexpr int(*null_ptr)() = nullptr;
77
constexpr int test4 = (*null_ptr)(); // both-error {{must be initialized by a constant expression}} \
88
// both-note {{evaluates to a null function pointer}}
99

10+
struct E {
11+
int n = 0;
12+
struct {
13+
void *x = this;
14+
};
15+
void *y = this;
16+
};
17+
constexpr E e1 = E();
18+
static_assert(e1.x != e1.y, "");
19+
constexpr E e2 = E{0};
20+
static_assert(e2.x != e2.y, "");
21+
22+
struct S {
23+
int &&a = 2;
24+
int b[1]{a};
25+
};
26+
constexpr int foo() {
27+
S s{12};
28+
return s.b[0];
29+
}
30+
static_assert(foo() == 12, "");

libcxx/include/__memory/temp_value.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <__config>
1313
#include <__memory/addressof.h>
1414
#include <__memory/allocator_traits.h>
15-
#include <__type_traits/aligned_storage.h>
1615
#include <__utility/forward.h>
1716

1817
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -26,7 +25,7 @@ struct __temp_value {
2625
typedef allocator_traits<_Alloc> _Traits;
2726

2827
#ifdef _LIBCPP_CXX03_LANG
29-
typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
28+
_ALIGNAS_TYPE(_Tp) char __v[sizeof(_Tp)];
3029
#else
3130
union {
3231
_Tp __v;

libcxx/include/any

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ namespace std {
8888
# include <__new/allocate.h>
8989
# include <__type_traits/add_cv_quals.h>
9090
# include <__type_traits/add_pointer.h>
91-
# include <__type_traits/aligned_storage.h>
9291
# include <__type_traits/conditional.h>
9392
# include <__type_traits/decay.h>
9493
# include <__type_traits/enable_if.h>
@@ -147,14 +146,13 @@ template <class _ValueType>
147146
_LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any*) _NOEXCEPT;
148147

149148
namespace __any_imp {
150-
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
151-
using _Buffer _LIBCPP_NODEBUG = aligned_storage_t<3 * sizeof(void*), alignof(void*)>;
152-
_LIBCPP_SUPPRESS_DEPRECATED_POP
149+
inline constexpr size_t __small_buffer_size = 3 * sizeof(void*);
150+
inline constexpr size_t __small_buffer_alignment = alignof(void*);
153151

154152
template <class _Tp>
155153
using _IsSmallObject _LIBCPP_NODEBUG =
156154
integral_constant<bool,
157-
sizeof(_Tp) <= sizeof(_Buffer) && alignof(_Buffer) % alignof(_Tp) == 0 &&
155+
sizeof(_Tp) <= __small_buffer_size && alignof(_Tp) <= __small_buffer_alignment &&
158156
is_nothrow_move_constructible<_Tp>::value >;
159157

160158
enum class _Action { _Destroy, _Copy, _Move, _Get, _TypeInfo };
@@ -284,7 +282,7 @@ private:
284282
union _Storage {
285283
_LIBCPP_HIDE_FROM_ABI constexpr _Storage() : __ptr(nullptr) {}
286284
void* __ptr;
287-
__any_imp::_Buffer __buf;
285+
alignas(__any_imp::__small_buffer_alignment) char __buf[__any_imp::__small_buffer_size];
288286
};
289287

290288
_LIBCPP_HIDE_FROM_ABI void*

libcxx/include/future

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,12 +584,9 @@ inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _P
584584
template <class _Rp>
585585
class _LIBCPP_HIDDEN __assoc_state : public __assoc_sub_state {
586586
typedef __assoc_sub_state base;
587-
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
588-
typedef typename aligned_storage<sizeof(_Rp), _LIBCPP_ALIGNOF(_Rp)>::type _Up;
589-
_LIBCPP_SUPPRESS_DEPRECATED_POP
590587

591588
protected:
592-
_Up __value_;
589+
_ALIGNAS_TYPE(_Rp) char __value_[sizeof(_Rp)];
593590

594591
_LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override;
595592

libcxx/src/exception.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,12 @@
99
#define _LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION
1010
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
1111

12-
#include <exception>
13-
#include <new>
14-
#include <typeinfo>
15-
16-
#if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
17-
# include <cxxabi.h>
18-
using namespace __cxxabiv1;
19-
# define HAVE_DEPENDENT_EH_ABI 1
20-
#endif
12+
#include <__config>
2113

2214
#if defined(_LIBCPP_ABI_MICROSOFT)
2315
# include "support/runtime/exception_msvc.ipp"
2416
# include "support/runtime/exception_pointer_msvc.ipp"
25-
#elif defined(_LIBCPPABI_VERSION)
17+
#elif defined(LIBCXX_BUILDING_LIBCXXABI)
2618
# include "support/runtime/exception_libcxxabi.ipp"
2719
# include "support/runtime/exception_pointer_cxxabi.ipp"
2820
#elif defined(LIBCXXRT)

libcxx/src/support/runtime/exception_fallback.ipp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
//===----------------------------------------------------------------------===//
99

1010
#include <__verbose_abort>
11+
#include <exception>
12+
#include "include/atomic_support.h"
1113

1214
namespace std {
1315

libcxx/src/support/runtime/exception_glibcxx.ipp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
# error header can only be used when targeting libstdc++ or libsupc++
1212
#endif
1313

14+
#include <exception>
15+
#include <new>
16+
1417
namespace std {
1518

1619
bad_alloc::bad_alloc() noexcept {}

libcxx/src/support/runtime/exception_libcxxabi.ipp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10+
#include <exception>
11+
12+
#include <cxxabi.h>
13+
1014
#ifndef _LIBCPPABI_VERSION
1115
# error this header can only be used with libc++abi
1216
#endif
@@ -17,9 +21,9 @@ bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
1721

1822
int uncaught_exceptions() noexcept {
1923
#if _LIBCPPABI_VERSION > 1001
20-
return __cxa_uncaught_exceptions();
24+
return abi::__cxa_uncaught_exceptions();
2125
#else
22-
return __cxa_uncaught_exception() ? 1 : 0;
26+
return abi::__cxa_uncaught_exception() ? 1 : 0;
2327
#endif
2428
}
2529

0 commit comments

Comments
 (0)