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

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 09:30:23 PDT 2022


dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good (alternatively, to the suggested edits - I'd probably be OK with the conversion operator being explicit, then keeping all those explicit ctor/conversions - either way's roughly fine by me)



================
Comment at: llvm/lib/Demangle/MicrosoftDemangle.cpp:1374
 
-  OB << '\0';
-  ResultBuffer = OB.getBuffer();
-  Result->DecodedString = copyString(ResultBuffer);
-  std::free(ResultBuffer);
+  Result->DecodedString = copyString(StringView(OB));
+  std::free(OB.getBuffer());
----------------



================
Comment at: llvm/lib/Demangle/MicrosoftDemangle.cpp:1453
+
+  Identifier->Name = copyString(StringView(OB));
+  std::free(OB.getBuffer());
----------------



================
Comment at: llvm/lib/Demangle/MicrosoftDemangleNodes.cpp:124
   this->output(OB, Flags);
-  OB << '\0';
-  std::string Owned(OB.getBuffer());
+  StringView SV(OB);
+  std::string Owned(SV.begin(), SV.end());
----------------



================
Comment at: llvm/unittests/Demangle/ItaniumDemangleTest.cpp:56
 static std::string toString(OutputBuffer &OB) {
-  return {OB.getBuffer(), OB.getCurrentPosition()};
+  StringView SV(OB);
+  return {SV.begin(), SV.end()};
----------------



================
Comment at: llvm/unittests/Demangle/OutputBufferTest.cpp:18
 static std::string toString(OutputBuffer &OB) {
-  return {OB.getBuffer(), OB.getCurrentPosition()};
+  StringView SV(OB);
+  return {SV.begin(), SV.end()};
----------------



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

https://reviews.llvm.org/D120990



More information about the llvm-commits mailing list