Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

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.

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.
@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2025

@llvm/pr-subscribers-backend-webassembly

Author: Kazu Hirata (kazutakahirata)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/167155.diff

1 Files Affected:

  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h (+2-2)
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);
   }
 };
 

@kazutakahirata kazutakahirata merged commit 6b42c91 into llvm:main Nov 8, 2025
12 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20251108_clang_tidy_readability-redundant-string-cstr_WebAssembly branch November 8, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants