diff --git a/compiler-rt/lib/scudo/standalone/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/CMakeLists.txt index dc700cec9becb..3f9ae866a7553 100644 --- a/compiler-rt/lib/scudo/standalone/CMakeLists.txt +++ b/compiler-rt/lib/scudo/standalone/CMakeLists.txt @@ -98,6 +98,7 @@ set(SCUDO_HEADERS tsd_exclusive.h tsd_shared.h tsd.h + type_traits.h vector.h wrappers_c_checks.h wrappers_c.h diff --git a/compiler-rt/lib/scudo/standalone/allocator_config_wrapper.h b/compiler-rt/lib/scudo/standalone/allocator_config_wrapper.h index 5477236ac1f39..ea12a5b1447f6 100644 --- a/compiler-rt/lib/scudo/standalone/allocator_config_wrapper.h +++ b/compiler-rt/lib/scudo/standalone/allocator_config_wrapper.h @@ -12,35 +12,7 @@ #include "condition_variable.h" #include "internal_defs.h" #include "secondary.h" - -namespace { - -template struct removeConst { - using type = T; -}; -template struct removeConst { - using type = T; -}; - -// This is only used for SFINAE when detecting if a type is defined. -template struct voidAdaptor { - using type = void; -}; - -// This is used for detecting the case that defines the flag with wrong type and -// it'll be viewed as undefined optional flag. -template struct assertSameType { - template struct isSame { - static constexpr bool value = false; - }; - template struct isSame { - static constexpr bool value = true; - }; - static_assert(isSame::value, "Flag type mismatches"); - using type = R; -}; - -} // namespace +#include "type_traits.h" namespace scudo { diff --git a/compiler-rt/lib/scudo/standalone/list.h b/compiler-rt/lib/scudo/standalone/list.h index c6bd32a8fa325..5c34cbb049e60 100644 --- a/compiler-rt/lib/scudo/standalone/list.h +++ b/compiler-rt/lib/scudo/standalone/list.h @@ -10,17 +10,7 @@ #define SCUDO_LIST_H_ #include "internal_defs.h" - -// TODO: Move the helpers to a header. -namespace { -template struct isPointer { - static constexpr bool value = false; -}; - -template struct isPointer { - static constexpr bool value = true; -}; -} // namespace +#include "type_traits.h" namespace scudo { diff --git a/compiler-rt/lib/scudo/standalone/type_traits.h b/compiler-rt/lib/scudo/standalone/type_traits.h new file mode 100644 index 0000000000000..16ed5a048f82b --- /dev/null +++ b/compiler-rt/lib/scudo/standalone/type_traits.h @@ -0,0 +1,47 @@ +//===-- type_traits.h -------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef SCUDO_TYPE_TRAITS_H_ +#define SCUDO_TYPE_TRAITS_H_ + +namespace scudo { + +template struct removeConst { + using type = T; +}; +template struct removeConst { + using type = T; +}; + +// This is only used for SFINAE when detecting if a type is defined. +template struct voidAdaptor { + using type = void; +}; + +template struct assertSameType { + template struct isSame { + static constexpr bool value = false; + }; + template struct isSame { + static constexpr bool value = true; + }; + static_assert(isSame::value, "Type mismatches"); + using type = R; +}; + +template struct isPointer { + static constexpr bool value = false; +}; + +template struct isPointer { + static constexpr bool value = true; +}; + +} // namespace scudo + +#endif // SCUDO_TYPE_TRAITS_H_