Skip to content

Commit 3d1bf02

Browse files
committed
[libc++] Fix non-uglified name in scoped_allocator_adaptor
As mentioned in #78754, the 'base' typedef in scoped_allocator_adaptor was not uglified properly.
1 parent fee204f commit 3d1bf02

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

libcxx/include/scoped_allocator

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,12 @@ struct __outermost<_Alloc, true> {
334334
template <class _OuterAlloc, class... _InnerAllocs>
335335
class _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>
336336
: public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> {
337-
typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base;
337+
typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> _Base;
338338
typedef allocator_traits<_OuterAlloc> _OuterTraits;
339339

340340
public:
341341
typedef _OuterAlloc outer_allocator_type;
342-
typedef typename base::inner_allocator_type inner_allocator_type;
342+
typedef typename _Base::inner_allocator_type inner_allocator_type;
343343
typedef typename _OuterTraits::size_type size_type;
344344
typedef typename _OuterTraits::difference_type difference_type;
345345
typedef typename _OuterTraits::pointer pointer;
@@ -365,29 +365,29 @@ public:
365365
template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
366366
_LIBCPP_HIDE_FROM_ABI
367367
scoped_allocator_adaptor(_OuterA2&& __outer_alloc, const _InnerAllocs&... __inner_allocs) _NOEXCEPT
368-
: base(std::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {}
368+
: _Base(std::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {}
369369
// scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;
370370
template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0>
371371
_LIBCPP_HIDE_FROM_ABI
372372
scoped_allocator_adaptor(const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
373-
: base(__other) {}
373+
: _Base(__other) {}
374374
template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
375375
_LIBCPP_HIDE_FROM_ABI
376376
scoped_allocator_adaptor(scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
377-
: base(std::move(__other)) {}
377+
: _Base(std::move(__other)) {}
378378

379379
// scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
380380
// scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
381381
// ~scoped_allocator_adaptor() = default;
382382

383-
_LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { return base::inner_allocator(); }
383+
_LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { return _Base::inner_allocator(); }
384384
_LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT {
385-
return base::inner_allocator();
385+
return _Base::inner_allocator();
386386
}
387387

388-
_LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT { return base::outer_allocator(); }
388+
_LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT { return _Base::outer_allocator(); }
389389
_LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT {
390-
return base::outer_allocator();
390+
return _Base::outer_allocator();
391391
}
392392

393393
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) {
@@ -472,13 +472,13 @@ public:
472472
}
473473

474474
_LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT {
475-
return base::select_on_container_copy_construction();
475+
return _Base::select_on_container_copy_construction();
476476
}
477477

478478
private:
479479
template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
480480
_LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor(_OuterA2&& __o, const inner_allocator_type& __i) _NOEXCEPT
481-
: base(std::forward<_OuterA2>(__o), __i) {}
481+
: _Base(std::forward<_OuterA2>(__o), __i) {}
482482

483483
template <class _Tp, class... _Args>
484484
_LIBCPP_HIDE_FROM_ABI void __construct(integral_constant<int, 0>, _Tp* __p, _Args&&... __args) {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: c++03
10+
11+
// <memory>
12+
13+
// This test ensures that we don't use a non-uglified name 'base' in the
14+
// implementation of scoped_allocator_adaptor.
15+
//
16+
// See https://github.com/llvm/llvm-project/issues/78754.
17+
18+
#include <memory>
19+
#include <scoped_allocator>
20+
21+
using ScopedAlloc = std::scoped_allocator_adaptor<std::allocator<int>, std::allocator<int>>;
22+
struct MyBase {
23+
using base = MyBase;
24+
};
25+
struct MyDerived : ScopedAlloc, MyBase {};
26+
27+
using T = MyDerived::base; // Should be well-formed

0 commit comments

Comments
 (0)