From 2cc9e3edb2d3ba2195057b040c72085d7ebb1e66 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 11 Oct 2025 21:42:03 -0700 Subject: [PATCH] [Support] Use llvm::to_underlying in ScopedPrinter.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/ScopedPrinter.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/Support/ScopedPrinter.h b/llvm/include/llvm/Support/ScopedPrinter.h index 94080e85a9048..7b87fdafd68ac 100644 --- a/llvm/include/llvm/Support/ScopedPrinter.h +++ b/llvm/include/llvm/Support/ScopedPrinter.h @@ -11,6 +11,7 @@ #include "llvm/ADT/APSInt.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLForwardCompat.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" @@ -57,8 +58,7 @@ struct HexNumber { HexNumber(unsigned long Value) : Value(Value) {} HexNumber(unsigned long long Value) : Value(Value) {} template >> - HexNumber(EnumT Value) - : HexNumber(static_cast>(Value)) {} + HexNumber(EnumT Value) : HexNumber(llvm::to_underlying(Value)) {} uint64_t Value; }; @@ -84,7 +84,7 @@ struct FlagEntry { : Name(Name), Value(Value) {} template >> FlagEntry(StringRef Name, EnumT Value) - : FlagEntry(Name, static_cast>(Value)) {} + : FlagEntry(Name, llvm::to_underlying(Value)) {} StringRef Name; uint64_t Value;