[llvm] 59ac5b7 - [Support] Use llvm::to_underlying in BinaryStreamWriter.h (NFC) (#163087)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 12 20:49:30 PDT 2025
Author: Kazu Hirata
Date: 2025-10-12T20:49:26-07:00
New Revision: 59ac5b7eee30ad7a4860946a5e3d2c8822f9655b
URL: https://github.com/llvm/llvm-project/commit/59ac5b7eee30ad7a4860946a5e3d2c8822f9655b
DIFF: https://github.com/llvm/llvm-project/commit/59ac5b7eee30ad7a4860946a5e3d2c8822f9655b.diff
LOG: [Support] Use llvm::to_underlying in BinaryStreamWriter.h (NFC) (#163087)
llvm::to_underlying, forward ported from C++23, conveniently packages
static_cast and std::underlying_type_t like so:
static_cast<std::underlying_type_t<EnumTy>>(E)
Added:
Modified:
llvm/include/llvm/Support/BinaryStreamWriter.h
Removed:
################################################################################
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<T>::value,
"Cannot call writeEnum with non-Enum type");
- using U = std::underlying_type_t<T>;
- return writeInteger<U>(static_cast<U>(Num));
+ return writeInteger(llvm::to_underlying(Num));
}
/// Write the unsigned integer Value to the underlying stream using ULEB128
More information about the llvm-commits
mailing list