[llvm] [TableGen] Use llvm::enumerate in one place (NFC) (PR #136399)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 18 21:07:55 PDT 2025


================
@@ -200,26 +200,24 @@ CodeGenInstAlias::CodeGenInstAlias(const Record *R, const CodeGenTarget &T)
 
   // Decode and validate the arguments of the result.
   unsigned AliasOpNo = 0;
-  for (unsigned i = 0, e = ResultInst->Operands.size(); i != e; ++i) {
-
+  for (auto [OpIdx, OpInfo] : enumerate(ResultInst->Operands)) {
----------------
s-barannikov wrote:

If you're concerned about copying `OpInfo`, then there is no copy, AFAICT.
`static_assert(std::is_reference_v<decltype(OpInfo)>);` doesn't trigger.
I never learned how structured bindings exactly work, but it must be something with the fact that `&` applies to the *structure* itself and not to its elements (which in this case are already references).


https://github.com/llvm/llvm-project/pull/136399


More information about the llvm-commits mailing list