[libcxx-commits] [PATCH] D122604: [demangler] Simplify OutputBuffer initialization

David Blaikie via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon May 2 11:13:33 PDT 2022


dblaikie added inline comments.


================
Comment at: llvm/lib/Demangle/MicrosoftDemangle.cpp:249-252
+  // This is not a micro-optimization, it avoids UB, should Borrowed be an null
+  // buffer.
+  if (Borrowed.size())
+    std::memcpy(Stable, Borrowed.begin(), Borrowed.size());
----------------
Looks good to me as an alternative to D124524


================
Comment at: llvm/unittests/Demangle/OutputBufferTest.cpp:19-21
+  // Avoid UB on null buffers
+  if (SV.size())
+    return {SV.begin(), SV.end()};
----------------
I don't think this check is necessary though, is it? nullptr,nullptr should probably be valid iterators, yeah?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122604/new/

https://reviews.llvm.org/D122604



More information about the libcxx-commits mailing list