[PATCH] D103935: Add Twine support for std::string_view.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 8 17:19:07 PDT 2021


craig.topper added inline comments.


================
Comment at: llvm/lib/Support/Twine.cpp:48
+#if __cplusplus > 201402L
+    case StdStringViewKind: {
+      const std::string_view *str = LHS.stdStringView;
----------------
saugustine wrote:
> craig.topper wrote:
> > Is string_view guaranteed to be null terminated?
> A string_view is not guaranteed to be null terminated, so it includes the size field, which is filled in when the string_view at construction time, possibly by the constructor searching for a null in the string or array of characters, but perhaps just by passing in a length.
That's what I thought. This function is expecting to return a String that has a null terminator following it isn't it? StringRef isn't directly handled here so I wouldn't expect string_view to be.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103935



More information about the llvm-commits mailing list