Commit d3d9bac0 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

Revert "[base] Add NO_UNIQUE_ADDRESS attribute"

This reverts commit d3742a4b.

Reason for revert: https://crbug.com/1144431
Bug: 1144431

Original change's description:
> [base] Add NO_UNIQUE_ADDRESS attribute
>
> This change adds the HAS_CPP_ATTRIBUTE and NO_UNIQUE_ADDRESS macros to
> base/compiler_specific.h. This allows using the C++20 no_unique_address
> attribute in prior dialects if the compiler supports it.
>
> Bug: None
> Change-Id: I6aff82e7b195f5eaf93551049c9dfa6a3fd1fbc6
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2510396
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#822768}

TBR=dcheng@chromium.org,jdoerrie@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: None
Change-Id: I375099e835dbc7d4cab98cc15faf66124335bb0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2514208
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823202}
parent 78586941
...@@ -11,19 +11,6 @@ ...@@ -11,19 +11,6 @@
#error "Only clang-cl is supported on Windows, see https://crbug.com/988071" #error "Only clang-cl is supported on Windows, see https://crbug.com/988071"
#endif #endif
// This is a wrapper around `__has_cpp_attribute`, which can be used to test for
// the presence of an attribute. In case the compiler does not support this
// macro it will simply evaluate to 0.
//
// References:
// https://wg21.link/sd6#testing-for-the-presence-of-an-attribute-__has_cpp_attribute
// https://wg21.link/cpp.cond#:__has_cpp_attribute
#if defined(__has_cpp_attribute)
#define HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
#else
#define HAS_CPP_ATTRIBUTE(x) 0
#endif
// Annotate a variable indicating it's ok if the variable is not used. // Annotate a variable indicating it's ok if the variable is not used.
// (Typically used to silence a compiler warning when the assignment // (Typically used to silence a compiler warning when the assignment
// is important for some other reason.) // is important for some other reason.)
...@@ -112,20 +99,6 @@ ...@@ -112,20 +99,6 @@
#define WARN_UNUSED_RESULT #define WARN_UNUSED_RESULT
#endif #endif
// In case the compiler supports it NO_UNIQUE_ADDRESS evaluates to the C++20
// attribute [[no_unique_address]]. This allows annotating data members so that
// they need not have an address distinct from all other non-static data members
// of its class.
//
// References:
// * https://en.cppreference.com/w/cpp/language/attributes/no_unique_address
// * https://wg21.link/dcl.attr.nouniqueaddr
#if HAS_CPP_ATTRIBUTE(no_unique_address)
#define NO_UNIQUE_ADDRESS [[no_unique_address]]
#else
#define NO_UNIQUE_ADDRESS
#endif
// Tell the compiler a function is using a printf-style format string. // Tell the compiler a function is using a printf-style format string.
// |format_param| is the one-based index of the format string parameter; // |format_param| is the one-based index of the format string parameter;
// |dots_param| is the one-based index of the "..." parameter. // |dots_param| is the one-based index of the "..." parameter.
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include "base/compiler_specific.h"
#include "base/functional/identity.h" #include "base/functional/identity.h"
#include "base/functional/invoke.h" #include "base/functional/invoke.h"
#include "base/ranges/functional.h" #include "base/ranges/functional.h"
...@@ -151,13 +150,14 @@ using range_category_t = iterator_category_t<ranges::iterator_t<Range>>; ...@@ -151,13 +150,14 @@ using range_category_t = iterator_category_t<ranges::iterator_t<Range>>;
namespace ranges { namespace ranges {
// C++14 implementation of std::ranges::in_fun_result. // C++14 implementation of std::ranges::in_fun_result. Note the because C++14
// lacks the `no_unique_address` attribute it is commented out.
// //
// Reference: https://wg21.link/algorithms.results#:~:text=in_fun_result // Reference: https://wg21.link/algorithms.results#:~:text=in_fun_result
template <typename I, typename F> template <typename I, typename F>
struct in_fun_result { struct in_fun_result {
NO_UNIQUE_ADDRESS I in; /* [[no_unique_address]] */ I in;
NO_UNIQUE_ADDRESS F fun; /* [[no_unique_address]] */ F fun;
template <typename I2, template <typename I2,
typename F2, typename F2,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment