[llvm] [WebAssembly] Clean up CustomMappingTraits<BBNumberMap> (NFC) (PR #167155)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 8 08:33:40 PST 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/167155

This patch does two things for readability:

- Use structured bindings.
- Remove extraneous .c_str().

Note that YamlIO.mapRequired takes StringRef as the key type.  As
such, we can implicitly construct StringRef from std::string.


>From 0edc0671ea3644e003a6d217cee48004aaa66d9d Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 5 Nov 2025 13:23:03 -0800
Subject: [PATCH] [WebAssembly] Clean up CustomMappingTraits<BBNumberMap> (NFC)

This patch does two things for readability:

- Use structured bindings.
- Remove extraneous .c_str().

Note that YamlIO.mapRequired takes StringRef as the key type.  As
such, we can implicitly construct StringRef from std::string.
---
 llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h
index ee575e3527673..0e913fb1ee669 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h
@@ -211,8 +211,8 @@ template <> struct CustomMappingTraits<BBNumberMap> {
   }
 
   static void output(IO &YamlIO, BBNumberMap &SrcToUnwindDest) {
-    for (auto KV : SrcToUnwindDest)
-      YamlIO.mapRequired(std::to_string(KV.first).c_str(), KV.second);
+    for (auto [Src, Dest] : SrcToUnwindDest)
+      YamlIO.mapRequired(std::to_string(Src), Dest);
   }
 };
 



More information about the llvm-commits mailing list