Skip to content

Commit bbdbcd8

Browse files
[Support] Rename llvm::support::endianness to llvm::endianness (#68174)
As part of an effort to make our codebase ready for the migration from llvm::support::endianness to std::endian in C++20, this patch renames llvm::support::endianness to llvm::endianness. The intent of this patch is to make fully qualified names less painful. That is, with this patch, we can just say llvm::endianness::big rather than llvm::support::endianness::big. I'm not renaming llvm::support::endianness to llvm::endian because we have a lot of places with "using namespace support;" where it would be ambiguous whether "endian" refers to llvm::endian or llvm::support::endian. This patch defines several helpers for gradual migration: namespace llvm { namespace support { using endianness = llvm::endianness; constexpr llvm::endianness big = llvm::endianness::big; constexpr llvm::endianness little = llvm::endianness::little; constexpr llvm::endianness native = llvm::endianness::native; While we are at it, this patch changes the enum to "enum class". The "enum class" prevents implicit conversions from endianness to bool. I've fixed three such instances of implicit conversions: 95f4b2a 8de2ecc a7517e1
1 parent f37028c commit bbdbcd8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

llvm/include/llvm/Support/Endian.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@
2222
#include <type_traits>
2323

2424
namespace llvm {
25-
namespace support {
2625

27-
enum endianness {
26+
enum class endianness {
2827
big,
2928
little,
3029
native = llvm::sys::IsBigEndianHost ? big : little
3130
};
3231

32+
namespace support {
33+
34+
// TODO: Remove the following once we are done migrating to llvm::endianness,
35+
// llvm::endianness::big, etc.
36+
using endianness = llvm::endianness;
37+
constexpr llvm::endianness big = llvm::endianness::big;
38+
constexpr llvm::endianness little = llvm::endianness::little;
39+
constexpr llvm::endianness native = llvm::endianness::native;
40+
3341
// These are named values for common alignments.
3442
enum {aligned = 0, unaligned = 1};
3543

0 commit comments

Comments
 (0)