[lld] [llvm] [Object] Define ELFType::Endian as alias for TargetEndianness (PR #86604)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 27 02:40:44 PDT 2024
jh7370 wrote:
TL;DR: I don't think we should be using the term "endian" in this context, and I think existing usages of it as a variable name is a mistake/not-conformant with our coding standards. It also saves a whole 4 characters, which, frankly, you shouldn't be worrying about. I can get behind dropping the "Target" prefix, since it is redundant in the context. "Endianness" is the more correct term and is much more widely used in this kind of context than "endian".
I also think it would be better to just do a blanket rename rather than create an alias and have a migration period. Out-of-tree targets are very unlikely to switch until forced. In-tree code is entirely within our control and there's no benefit in staggering the rename locally.
---
I fell down a linguistic rabbit hole: I did some searching of various online dictionaries, including one computing-specific one, and the term "endian" either a) doesn't appear at all, b) appears but only in the form "big-endian" and "little-endian", or c) in one sole case, standalone, but only as a suffix (so not really standalone). Wikipedia's page on the topic uses the term "endianness" only. I was about to declare that "endian" isn't even really a word, and the usage within LLVM's codebase is a mistake. Then I stumbled upon the C++20 `std::endian` enum. So it looks like the committee has decreed that "endian" is a legitimate term (though note that the discussion https://groups.google.com/a/isocpp.org/g/std-proposals/c/Hx4ipachs1E/m/yCxriKIvEgAJ and linked proposal primarily used "endianness").
LLVM coding standard states that variables should be nouns. There's a clear precedent for ignoring this for boolean-like types, to allow these to be phrases (e.g. `Is64Bits`), so something like `IsLittleEndian` is fine, but that's not applicable here. The case of `next`/`previous` is a prior art thing due to traditional linked list-like structures. I'm not sure I'd personally ever use a member name `old` (I'd use a full name like `oldThing`). Either way, that case doesn't apply here either.
https://github.com/llvm/llvm-project/pull/86604
More information about the llvm-commits
mailing list