Skip to content

Commit 6aa050a

Browse files
committed
Reland "[llvm][NFC] Use c++17 style variable type traits"
This reverts commit 632a389. This relands commit 1834a31. Differential Revision: https://reviews.llvm.org/D137493
1 parent 281f213 commit 6aa050a

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

+175
-211
lines changed

llvm/include/llvm/Support/YAMLTraits.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,9 +2019,8 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
20192019
namespace llvm { \
20202020
namespace yaml { \
20212021
static_assert( \
2022-
!std::is_fundamental<TYPE>::value && \
2023-
!std::is_same<TYPE, std::string>::value && \
2024-
!std::is_same<TYPE, llvm::StringRef>::value, \
2022+
!std::is_fundamental_v<TYPE> && !std::is_same_v<TYPE, std::string> && \
2023+
!std::is_same_v<TYPE, llvm::StringRef>, \
20252024
"only use LLVM_YAML_IS_SEQUENCE_VECTOR for types you control"); \
20262025
template <> struct SequenceElementTraits<TYPE> { \
20272026
static const bool flow = FLOW; \

llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ struct LocIndex {
237237
}
238238

239239
template<typename IntT> static LocIndex fromRawInteger(IntT ID) {
240-
static_assert(std::is_unsigned<IntT>::value &&
241-
sizeof(ID) == sizeof(uint64_t),
240+
static_assert(std::is_unsigned_v<IntT> && sizeof(ID) == sizeof(uint64_t),
242241
"Cannot convert raw integer to LocIndex");
243242
return {static_cast<u32_location_t>(ID >> 32),
244243
static_cast<u32_index_t>(ID)};

llvm/lib/DebugInfo/CodeView/EnumTables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using namespace llvm;
1414
using namespace codeview;
1515

1616
#define CV_ENUM_CLASS_ENT(enum_class, enum) \
17-
{ #enum, std::underlying_type < enum_class > ::type(enum_class::enum) }
17+
{ #enum, std::underlying_type_t<enum_class>(enum_class::enum) }
1818

1919
#define CV_ENUM_ENT(ns, enum) \
2020
{ #enum, ns::enum }

llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static const EnumEntry<TypeLeafKind> LeafTypeNames[] = {
2727
};
2828

2929
#define ENUM_ENTRY(enum_class, enum) \
30-
{ #enum, std::underlying_type < enum_class > ::type(enum_class::enum) }
30+
{ #enum, std::underlying_type_t<enum_class>(enum_class::enum) }
3131

3232
static const EnumEntry<uint16_t> ClassOptionNames[] = {
3333
ENUM_ENTRY(ClassOptions, Packed),

llvm/lib/DebugInfo/PDB/Native/EnumTables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using namespace llvm;
1414
using namespace llvm::pdb;
1515

1616
#define PDB_ENUM_CLASS_ENT(enum_class, enum) \
17-
{ #enum, std::underlying_type < enum_class > ::type(enum_class::enum) }
17+
{ #enum, std::underlying_type_t<enum_class>(enum_class::enum) }
1818

1919
#define PDB_ENUM_ENT(ns, enum) \
2020
{ #enum, ns::enum }

llvm/lib/Object/DXContainer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static Error readStruct(StringRef Buffer, const char *Src, T &Struct) {
3232

3333
template <typename T>
3434
static Error readInteger(StringRef Buffer, const char *Src, T &Val) {
35-
static_assert(std::is_integral<T>::value,
35+
static_assert(std::is_integral_v<T>,
3636
"Cannot call readInteger on non-integral type.");
3737
// Don't read before the beginning or past the end of the file
3838
if (Src < Buffer.begin() || Src + sizeof(T) > Buffer.end())

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ uint64_t Header::formatVersion() const {
13511351

13521352
Expected<Header> Header::readFromBuffer(const unsigned char *Buffer) {
13531353
using namespace support;
1354-
static_assert(std::is_standard_layout<Header>::value,
1354+
static_assert(std::is_standard_layout_v<Header>,
13551355
"The header should be standard layout type since we use offset "
13561356
"of fields to read.");
13571357
Header H;

llvm/lib/Support/ItaniumManglingCanonicalizer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ struct FoldingSetNodeIDBuilder {
2727
ID.AddString(llvm::StringRef(Str.begin(), Str.size()));
2828
}
2929
template <typename T>
30-
std::enable_if_t<std::is_integral<T>::value || std::is_enum<T>::value>
31-
operator()(T V) {
30+
std::enable_if_t<std::is_integral_v<T> || std::is_enum_v<T>> operator()(T V) {
3231
ID.AddInteger((unsigned long long)V);
3332
}
3433
void operator()(itanium_demangle::NodeArray A) {

llvm/lib/Support/NativeFormatting.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static void writeWithCommas(raw_ostream &S, ArrayRef<char> Buffer) {
5555
template <typename T>
5656
static void write_unsigned_impl(raw_ostream &S, T N, size_t MinDigits,
5757
IntegerStyle Style, bool IsNegative) {
58-
static_assert(std::is_unsigned<T>::value, "Value is not unsigned!");
58+
static_assert(std::is_unsigned_v<T>, "Value is not unsigned!");
5959

6060
char NumberBuffer[128];
6161
std::memset(NumberBuffer, '0', sizeof(NumberBuffer));
@@ -92,7 +92,7 @@ static void write_unsigned(raw_ostream &S, T N, size_t MinDigits,
9292
template <typename T>
9393
static void write_signed(raw_ostream &S, T N, size_t MinDigits,
9494
IntegerStyle Style) {
95-
static_assert(std::is_signed<T>::value, "Value is not signed!");
95+
static_assert(std::is_signed_v<T>, "Value is not signed!");
9696

9797
using UnsignedT = std::make_unsigned_t<T>;
9898

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3574,8 +3574,8 @@ template <typename T>
35743574
static bool hasCalleePopSRet(const SmallVectorImpl<T> &Args,
35753575
const X86Subtarget &Subtarget) {
35763576
// Not C++20 (yet), so no concepts available.
3577-
static_assert(std::is_same<T, ISD::OutputArg>::value ||
3578-
std::is_same<T, ISD::InputArg>::value,
3577+
static_assert(std::is_same_v<T, ISD::OutputArg> ||
3578+
std::is_same_v<T, ISD::InputArg>,
35793579
"requires ISD::OutputArg or ISD::InputArg");
35803580

35813581
// Only 32-bit pops the sret. It's a 64-bit world these days, so early-out

0 commit comments

Comments
 (0)