diff --git a/llvm/include/llvm/DebugInfo/CodeView/CodeView.h b/llvm/include/llvm/DebugInfo/CodeView/CodeView.h index 62e559e2cebae..0bfd06e05bd89 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/CodeView.h +++ b/llvm/include/llvm/DebugInfo/CodeView/CodeView.h @@ -16,6 +16,7 @@ #include #include +#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(static_cast>(a) | \ - static_cast>(b)); \ + return static_cast(llvm::to_underlying(a) | \ + llvm::to_underlying(b)); \ } \ inline Class operator&(Class a, Class b) { \ - return static_cast(static_cast>(a) & \ - static_cast>(b)); \ + return static_cast(llvm::to_underlying(a) & \ + llvm::to_underlying(b)); \ } \ inline Class operator~(Class a) { \ - return static_cast(~static_cast>(a)); \ + return static_cast(~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 01de8b49dd78f..0adbd25cb369e 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 std::string formatUnknownEnum(T Value) { - return formatv("unknown ({0})", static_cast>(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 9c05d585831a9..c5999bffc021d 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>(K)) - .str(); + return formatv("UNKNOWN RECORD ({0:X})", llvm::to_underlying(K)).str(); } }