[llvm] [ADT] Fix llvm::join on containers of char*s (PR #67113)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 25 16:20:06 PDT 2023


================
@@ -417,8 +418,13 @@ inline std::string join_impl(IteratorT Begin, IteratorT End,
     return S;
 
   size_t Len = (std::distance(Begin, End) - 1) * Separator.size();
-  for (IteratorT I = Begin; I != End; ++I)
-    Len += (*I).size();
+  for (IteratorT I = Begin; I != End; ++I) {
+    if constexpr (std::is_same_v<std::remove_reference_t<decltype(*I)>,
+                                 const char *>)
+      Len += strlen(*I);
+    else
+      Len += (*I).size();
----------------
dwblaikie wrote:

any chance of using StringRef in the callers? Rather than having more places dealing with null terminated strings?

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


More information about the llvm-commits mailing list