From 86d601d3f3c539234736533889bfe1b4b528685d Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 12 Oct 2025 10:20:59 -0700 Subject: [PATCH] [Support] Use llvm::to_underlying in BinaryStreamWriter.h (NFC) llvm::to_underlying, forward ported from C++23, conveniently packages static_cast and std::underlying_type_t like so: static_cast>(E) --- llvm/include/llvm/Support/BinaryStreamWriter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/Support/BinaryStreamWriter.h b/llvm/include/llvm/Support/BinaryStreamWriter.h index dddf53bd5483c..39ce0b6e4c110 100644 --- a/llvm/include/llvm/Support/BinaryStreamWriter.h +++ b/llvm/include/llvm/Support/BinaryStreamWriter.h @@ -10,6 +10,7 @@ #define LLVM_SUPPORT_BINARYSTREAMWRITER_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLForwardCompat.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/BinaryStreamError.h" @@ -69,8 +70,7 @@ class BinaryStreamWriter { static_assert(std::is_enum::value, "Cannot call writeEnum with non-Enum type"); - using U = std::underlying_type_t; - return writeInteger(static_cast(Num)); + return writeInteger(llvm::to_underlying(Num)); } /// Write the unsigned integer Value to the underlying stream using ULEB128