[llvm] ab20f23 - [DebugInfo] Use llvm::to_underlying (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 8 22:07:39 PST 2023
Author: Kazu Hirata
Date: 2023-12-08T22:07:29-08:00
New Revision: ab20f23e7e65c7b19469e7d6e438ea14e22b9fff
URL: https://github.com/llvm/llvm-project/commit/ab20f23e7e65c7b19469e7d6e438ea14e22b9fff
DIFF: https://github.com/llvm/llvm-project/commit/ab20f23e7e65c7b19469e7d6e438ea14e22b9fff.diff
LOG: [DebugInfo] Use llvm::to_underlying (NFC)
Added:
Modified:
llvm/include/llvm/DebugInfo/CodeView/CodeView.h
llvm/include/llvm/DebugInfo/PDB/Native/FormatUtil.h
llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/DebugInfo/CodeView/CodeView.h b/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
index 62e559e2cebaef..0bfd06e05bd89a 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
@@ -16,6 +16,7 @@
#include <cinttypes>
#include <type_traits>
+#include "llvm/ADT/STLForwardCompat.h"
#include "llvm/Support/Endian.h"
namespace llvm {
@@ -51,15 +52,15 @@ enum SymbolKind : uint16_t {
#define CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(Class) \
inline Class operator|(Class a, Class b) { \
- return static_cast<Class>(static_cast<std::underlying_type_t<Class>>(a) | \
- static_cast<std::underlying_type_t<Class>>(b)); \
+ return static_cast<Class>(llvm::to_underlying(a) | \
+ llvm::to_underlying(b)); \
} \
inline Class operator&(Class a, Class b) { \
- return static_cast<Class>(static_cast<std::underlying_type_t<Class>>(a) & \
- static_cast<std::underlying_type_t<Class>>(b)); \
+ return static_cast<Class>(llvm::to_underlying(a) & \
+ llvm::to_underlying(b)); \
} \
inline Class operator~(Class a) { \
- return static_cast<Class>(~static_cast<std::underlying_type_t<Class>>(a)); \
+ return static_cast<Class>(~llvm::to_underlying(a)); \
} \
inline Class &operator|=(Class &a, Class b) { \
a = a | b; \
diff --git a/llvm/include/llvm/DebugInfo/PDB/Native/FormatUtil.h b/llvm/include/llvm/DebugInfo/PDB/Native/FormatUtil.h
index 01de8b49dd78fd..0adbd25cb369ea 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Native/FormatUtil.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Native/FormatUtil.h
@@ -10,6 +10,7 @@
#define LLVM_DEBUGINFO_PDB_NATIVE_FORMATUTIL_H
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLForwardCompat.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/Support/Endian.h"
@@ -34,8 +35,7 @@ namespace pdb {
return Ret;
template <typename T> std::string formatUnknownEnum(T Value) {
- return formatv("unknown ({0})", static_cast<std::underlying_type_t<T>>(Value))
- .str();
+ return formatv("unknown ({0})", llvm::to_underlying(Value)).str();
}
std::string formatSegmentOffset(uint16_t Segment, uint32_t Offset);
diff --git a/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp b/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp
index 9c05d585831a92..c5999bffc021da 100644
--- a/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp
@@ -9,6 +9,7 @@
#include "llvm/DebugInfo/PDB/Native/FormatUtil.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/STLForwardCompat.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
@@ -119,9 +120,7 @@ std::string llvm::pdb::formatTypeLeafKind(TypeLeafKind K) {
return #EnumName;
#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
default:
- return formatv("UNKNOWN RECORD ({0:X})",
- static_cast<std::underlying_type_t<TypeLeafKind>>(K))
- .str();
+ return formatv("UNKNOWN RECORD ({0:X})", llvm::to_underlying(K)).str();
}
}
More information about the llvm-commits
mailing list