Guard use of custom attributes against macroization (#2649)

This commit is contained in:
Casey Carter 2022-04-15 17:57:02 -07:00 коммит произвёл GitHub
Родитель 3ab44c2155
Коммит 7209f869b7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 31 добавлений и 7 удалений

Просмотреть файл

@ -623,7 +623,7 @@ struct _Constexpr_immortalize_impl {
_Constexpr_immortalize_impl(const _Constexpr_immortalize_impl&) = delete;
_Constexpr_immortalize_impl& operator=(const _Constexpr_immortalize_impl&) = delete;
[[msvc::noop_dtor]] ~_Constexpr_immortalize_impl() {
_MSVC_NOOP_DTOR ~_Constexpr_immortalize_impl() {
// do nothing, allowing _Ty to be used during shutdown
}
};

Просмотреть файл

@ -435,18 +435,42 @@
#define _NODISCARD_FRIEND _NODISCARD friend
#endif // TRANSITION, VSO-568006
// Determine if we should use [[msvc::known_semantics]] to communicate to the compiler
// that certain type trait specializations have the standard-mandated semantics
#pragma push_macro("msvc")
#pragma push_macro("known_semantics")
#pragma push_macro("noop_dtor")
#undef msvc
#undef known_semantics
#undef noop_dtor
#ifndef __has_cpp_attribute
#define _MSVC_KNOWN_SEMANTICS
#define _HAS_MSVC_ATTRIBUTE(x) 0
#elif defined(__CUDACC__) // TRANSITION, CUDA - warning: attribute namespace "msvc" is unrecognized
#define _MSVC_KNOWN_SEMANTICS
#elif __has_cpp_attribute(msvc::known_semantics)
#define _HAS_MSVC_ATTRIBUTE(x) 0
#else
#define _HAS_MSVC_ATTRIBUTE(x) __has_cpp_attribute(msvc::x)
#endif
// Should we use [[msvc::known_semantics]] to tell the compiler that certain
// type trait specializations have the standard-mandated semantics?
#if _HAS_MSVC_ATTRIBUTE(known_semantics)
#define _MSVC_KNOWN_SEMANTICS [[msvc::known_semantics]]
#else
#define _MSVC_KNOWN_SEMANTICS
#endif
// Should we use [[msvc::noop_dtor]] to tell the compiler that some non-trivial
// destructors have no effects?
#if _HAS_MSVC_ATTRIBUTE(noop_dtor)
#define _MSVC_NOOP_DTOR [[msvc::noop_dtor]]
#else
#define _MSVC_NOOP_DTOR
#endif
#undef _HAS_MSVC_ATTRIBUTE
#pragma pop_macro("noop_dtor")
#pragma pop_macro("known_semantics")
#pragma pop_macro("msvc")
// Controls whether the STL uses "conditional explicit" internally
#ifndef _HAS_CONDITIONAL_EXPLICIT
#ifdef __cpp_conditional_explicit

Просмотреть файл

@ -55,7 +55,7 @@ namespace {
_Constexpr_excptptr_immortalize_impl(const _Constexpr_excptptr_immortalize_impl&) = delete;
_Constexpr_excptptr_immortalize_impl& operator=(const _Constexpr_excptptr_immortalize_impl&) = delete;
[[msvc::noop_dtor]] ~_Constexpr_excptptr_immortalize_impl() {
_MSVC_NOOP_DTOR ~_Constexpr_excptptr_immortalize_impl() {
// do nothing, allowing _Ty to be used during shutdown
}
};