[PATCH] D120990: [demangler] Add StringView conversion operator

Nathan Sidwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 06:03:20 PDT 2022


urnathan marked 3 inline comments as done.
urnathan added inline comments.


================
Comment at: llvm/lib/Demangle/MicrosoftDemangle.cpp:973
   Identifier->output(OB, OF_Default);
-  OB << '\0';
-  char *Name = OB.getBuffer();
-
-  StringView Owned = copyString(Name);
+  StringView Owned = copyString(StringView(OB));
   memorizeString(Owned);
----------------
dblaikie wrote:
> Since the conversion operator is implicit, could the `StringView(``)` be omitted here?
indeed it can.


================
Comment at: llvm/lib/Demangle/MicrosoftDemangle.cpp:2318
 
-    std::printf("  [%d] - %.*s\n", (int)I, (int)OB.getCurrentPosition(),
-                OB.getBuffer());
+    StringView B(OB);
+    std::printf("  [%d] - %.*s\n", (int)I, (int)B.size(), B.begin());
----------------
dblaikie wrote:
> I'd tend to recommend writing this as `StringView B = OB` if that's valid (since that syntax only allows implicit conversions - so it simplifies things for readers (they have to consider fewer possible conversion sequences))
sure,


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

https://reviews.llvm.org/D120990



More information about the llvm-commits mailing list