[Lldb-commits] [lldb] d81cdb4 - Revert D148384 "[Demangle] replace use of llvm::StringView w/ std::string_view"

Fangrui Song via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 14 18:42:18 PDT 2023


Author: Fangrui Song
Date: 2023-04-14T18:42:11-07:00
New Revision: d81cdb49d74064e88843733e7da92db865943509

URL: https://github.com/llvm/llvm-project/commit/d81cdb49d74064e88843733e7da92db865943509
DIFF: https://github.com/llvm/llvm-project/commit/d81cdb49d74064e88843733e7da92db865943509.diff

LOG: Revert D148384 "[Demangle] replace use of llvm::StringView w/ std::string_view"

This reverts commit 3e559509b426b6aae735a7f57dbdaed1041d2622 and e0c4ffa796b553fa78c638a9584c05ac21fe07d5.

This still breaks Windows builds.

In addition, `#include <llvm/ADT/StringViewExtras.h>` in
llvm/include/llvm/Demangle/ItaniumDemangle.h is a library layering violation
(LLVMDemangle is the lowest LLVM library and cannot depend on LLVMSupport).

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
    lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
    llvm/include/llvm/Demangle/ItaniumDemangle.h
    llvm/include/llvm/Demangle/MicrosoftDemangle.h
    llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
    llvm/include/llvm/Demangle/Utility.h
    llvm/lib/Demangle/DLangDemangle.cpp
    llvm/lib/Demangle/ItaniumDemangle.cpp
    llvm/lib/Demangle/MicrosoftDemangle.cpp
    llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
    llvm/lib/Demangle/RustDemangle.cpp
    llvm/lib/ProfileData/ItaniumManglingCanonicalizer.cpp
    llvm/unittests/Demangle/ItaniumDemangleTest.cpp
    llvm/unittests/Demangle/OutputBufferTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index 71e4d566545e5..1e9e1be62e3b5 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -25,7 +25,6 @@
 #include "UdtRecordCompleter.h"
 #include "SymbolFileNativePDB.h"
 #include <optional>
-#include <string_view>
 
 using namespace lldb_private;
 using namespace lldb_private::npdb;
@@ -175,7 +174,7 @@ PdbAstBuilder::CreateDeclInfoForType(const TagRecord &record, TypeIndex ti) {
     return CreateDeclInfoForUndecoratedName(record.Name);
 
   llvm::ms_demangle::Demangler demangler;
-  std::string_view sv(record.UniqueName.begin(), record.UniqueName.size());
+  StringView sv(record.UniqueName.begin(), record.UniqueName.size());
   llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
   if (demangler.Error)
     return {m_clang.GetTranslationUnitDecl(), std::string(record.UniqueName)};

diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 8c91033ba2604..01756e47e917f 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -57,7 +57,6 @@
 #include "PdbUtil.h"
 #include "UdtRecordCompleter.h"
 #include <optional>
-#include <string_view>
 
 using namespace lldb;
 using namespace lldb_private;
@@ -632,7 +631,7 @@ static std::string GetUnqualifiedTypeName(const TagRecord &record) {
   }
 
   llvm::ms_demangle::Demangler demangler;
-  std::string_view sv(record.UniqueName.begin(), record.UniqueName.size());
+  StringView sv(record.UniqueName.begin(), record.UniqueName.size());
   llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
   if (demangler.Error)
     return std::string(record.Name);

diff  --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 05a21d9ec6255..a0029b94815dc 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -16,9 +16,8 @@
 #ifndef DEMANGLE_ITANIUMDEMANGLE_H
 #define DEMANGLE_ITANIUMDEMANGLE_H
 
-#include <llvm/ADT/StringViewExtras.h>
-
 #include "DemangleConfig.h"
+#include "StringView.h"
 #include "Utility.h"
 #include <algorithm>
 #include <cassert>
@@ -28,7 +27,6 @@
 #include <cstring>
 #include <limits>
 #include <new>
-#include <string_view>
 #include <type_traits>
 #include <utility>
 
@@ -289,7 +287,7 @@ class Node {
   // implementation.
   virtual void printRight(OutputBuffer &) const {}
 
-  virtual std::string_view getBaseName() const { return {}; }
+  virtual StringView getBaseName() const { return StringView(); }
 
   // Silence compiler warnings, this dtor will never be called.
   virtual ~Node() = default;
@@ -348,10 +346,10 @@ struct NodeArrayNode : Node {
 
 class DotSuffix final : public Node {
   const Node *Prefix;
-  const std::string_view Suffix;
+  const StringView Suffix;
 
 public:
-  DotSuffix(const Node *Prefix_, std::string_view Suffix_)
+  DotSuffix(const Node *Prefix_, StringView Suffix_)
       : Node(KDotSuffix), Prefix(Prefix_), Suffix(Suffix_) {}
 
   template<typename Fn> void match(Fn F) const { F(Prefix, Suffix); }
@@ -366,15 +364,15 @@ class DotSuffix final : public Node {
 
 class VendorExtQualType final : public Node {
   const Node *Ty;
-  std::string_view Ext;
+  StringView Ext;
   const Node *TA;
 
 public:
-  VendorExtQualType(const Node *Ty_, std::string_view Ext_, const Node *TA_)
+  VendorExtQualType(const Node *Ty_, StringView Ext_, const Node *TA_)
       : Node(KVendorExtQualType), Ty(Ty_), Ext(Ext_), TA(TA_) {}
 
   const Node *getTy() const { return Ty; }
-  std::string_view getExt() const { return Ext; }
+  StringView getExt() const { return Ext; }
   const Node *getTA() const { return TA; }
 
   template <typename Fn> void match(Fn F) const { F(Ty, Ext, TA); }
@@ -465,10 +463,10 @@ class ConversionOperatorType final : public Node {
 
 class PostfixQualifiedType final : public Node {
   const Node *Ty;
-  const std::string_view Postfix;
+  const StringView Postfix;
 
 public:
-  PostfixQualifiedType(const Node *Ty_, std::string_view Postfix_)
+  PostfixQualifiedType(const Node *Ty_, StringView Postfix_)
       : Node(KPostfixQualifiedType), Ty(Ty_), Postfix(Postfix_) {}
 
   template<typename Fn> void match(Fn F) const { F(Ty, Postfix); }
@@ -480,15 +478,15 @@ class PostfixQualifiedType final : public Node {
 };
 
 class NameType final : public Node {
-  const std::string_view Name;
+  const StringView Name;
 
 public:
-  NameType(std::string_view Name_) : Node(KNameType), Name(Name_) {}
+  NameType(StringView Name_) : Node(KNameType), Name(Name_) {}
 
   template<typename Fn> void match(Fn F) const { F(Name); }
 
-  std::string_view getName() const { return Name; }
-  std::string_view getBaseName() const override { return Name; }
+  StringView getName() const { return Name; }
+  StringView getBaseName() const override { return Name; }
 
   void printLeft(OutputBuffer &OB) const override { OB += Name; }
 };
@@ -514,10 +512,10 @@ class BitIntType final : public Node {
 };
 
 class ElaboratedTypeSpefType : public Node {
-  std::string_view Kind;
+  StringView Kind;
   Node *Child;
 public:
-  ElaboratedTypeSpefType(std::string_view Kind_, Node *Child_)
+  ElaboratedTypeSpefType(StringView Kind_, Node *Child_)
       : Node(KElaboratedTypeSpefType), Kind(Kind_), Child(Child_) {}
 
   template<typename Fn> void match(Fn F) const { F(Kind, Child); }
@@ -531,16 +529,16 @@ class ElaboratedTypeSpefType : public Node {
 
 struct AbiTagAttr : Node {
   Node *Base;
-  std::string_view Tag;
+  StringView Tag;
 
-  AbiTagAttr(Node *Base_, std::string_view Tag_)
+  AbiTagAttr(Node *Base_, StringView Tag_)
       : Node(KAbiTagAttr, Base_->RHSComponentCache, Base_->ArrayCache,
              Base_->FunctionCache),
         Base(Base_), Tag(Tag_) {}
 
   template<typename Fn> void match(Fn F) const { F(Base, Tag); }
 
-  std::string_view getBaseName() const override { return Base->getBaseName(); }
+  StringView getBaseName() const override { return Base->getBaseName(); }
 
   void printLeft(OutputBuffer &OB) const override {
     Base->printLeft(OB);
@@ -567,12 +565,12 @@ class EnableIfAttr : public Node {
 
 class ObjCProtoName : public Node {
   const Node *Ty;
-  std::string_view Protocol;
+  StringView Protocol;
 
   friend class PointerType;
 
 public:
-  ObjCProtoName(const Node *Ty_, std::string_view Protocol_)
+  ObjCProtoName(const Node *Ty_, StringView Protocol_)
       : Node(KObjCProtoName), Ty(Ty_), Protocol(Protocol_) {}
 
   template<typename Fn> void match(Fn F) const { F(Ty, Protocol); }
@@ -949,11 +947,11 @@ class LiteralOperator : public Node {
 };
 
 class SpecialName final : public Node {
-  const std::string_view Special;
+  const StringView Special;
   const Node *Child;
 
 public:
-  SpecialName(std::string_view Special_, const Node *Child_)
+  SpecialName(StringView Special_, const Node *Child_)
       : Node(KSpecialName), Special(Special_), Child(Child_) {}
 
   template<typename Fn> void match(Fn F) const { F(Special, Child); }
@@ -992,7 +990,7 @@ struct NestedName : Node {
 
   template<typename Fn> void match(Fn F) const { F(Qual, Name); }
 
-  std::string_view getBaseName() const override { return Name->getBaseName(); }
+  StringView getBaseName() const override { return Name->getBaseName(); }
 
   void printLeft(OutputBuffer &OB) const override {
     Qual->print(OB);
@@ -1032,7 +1030,7 @@ struct ModuleEntity : Node {
 
   template <typename Fn> void match(Fn F) const { F(Module, Name); }
 
-  std::string_view getBaseName() const override { return Name->getBaseName(); }
+  StringView getBaseName() const override { return Name->getBaseName(); }
 
   void printLeft(OutputBuffer &OB) const override {
     Name->print(OB);
@@ -1068,7 +1066,7 @@ class QualifiedName final : public Node {
 
   template<typename Fn> void match(Fn F) const { F(Qualifier, Name); }
 
-  std::string_view getBaseName() const override { return Name->getBaseName(); }
+  StringView getBaseName() const override { return Name->getBaseName(); }
 
   void printLeft(OutputBuffer &OB) const override {
     Qualifier->print(OB);
@@ -1490,7 +1488,7 @@ struct NameWithTemplateArgs : Node {
 
   template<typename Fn> void match(Fn F) const { F(Name, TemplateArgs); }
 
-  std::string_view getBaseName() const override { return Name->getBaseName(); }
+  StringView getBaseName() const override { return Name->getBaseName(); }
 
   void printLeft(OutputBuffer &OB) const override {
     Name->print(OB);
@@ -1507,7 +1505,7 @@ class GlobalQualifiedName final : public Node {
 
   template<typename Fn> void match(Fn F) const { F(Child); }
 
-  std::string_view getBaseName() const override { return Child->getBaseName(); }
+  StringView getBaseName() const override { return Child->getBaseName(); }
 
   void printLeft(OutputBuffer &OB) const override {
     OB += "::";
@@ -1543,20 +1541,20 @@ class ExpandedSpecialSubstitution : public Node {
     return unsigned(SSK) >= unsigned(SpecialSubKind::string);
   }
 
-  std::string_view getBaseName() const override {
+  StringView getBaseName() const override {
     switch (SSK) {
     case SpecialSubKind::allocator:
-      return {"allocator"};
+      return StringView("allocator");
     case SpecialSubKind::basic_string:
-      return {"basic_string"};
+      return StringView("basic_string");
     case SpecialSubKind::string:
-      return {"basic_string"};
+      return StringView("basic_string");
     case SpecialSubKind::istream:
-      return {"basic_istream"};
+      return StringView("basic_istream");
     case SpecialSubKind::ostream:
-      return {"basic_ostream"};
+      return StringView("basic_ostream");
     case SpecialSubKind::iostream:
-      return {"basic_iostream"};
+      return StringView("basic_iostream");
     }
     DEMANGLE_UNREACHABLE;
   }
@@ -1580,11 +1578,11 @@ class SpecialSubstitution final : public ExpandedSpecialSubstitution {
 
   template<typename Fn> void match(Fn F) const { F(SSK); }
 
-  std::string_view getBaseName() const override {
-    std::string_view SV = ExpandedSpecialSubstitution::getBaseName();
+  StringView getBaseName() const override {
+    auto SV = ExpandedSpecialSubstitution::getBaseName();
     if (isInstantiation()) {
       // The instantiations are typedefs that drop the "basic_" prefix.
-      assert(llvm::starts_with(SV, "basic_"));
+      assert(SV.startsWith("basic_"));
       SV.remove_prefix(sizeof("basic_") - 1);
     }
     return SV;
@@ -1633,11 +1631,10 @@ class DtorName : public Node {
 };
 
 class UnnamedTypeName : public Node {
-  const std::string_view Count;
+  const StringView Count;
 
 public:
-  UnnamedTypeName(std::string_view Count_)
-      : Node(KUnnamedTypeName), Count(Count_) {}
+  UnnamedTypeName(StringView Count_) : Node(KUnnamedTypeName), Count(Count_) {}
 
   template<typename Fn> void match(Fn F) const { F(Count); }
 
@@ -1651,11 +1648,11 @@ class UnnamedTypeName : public Node {
 class ClosureTypeName : public Node {
   NodeArray TemplateParams;
   NodeArray Params;
-  std::string_view Count;
+  StringView Count;
 
 public:
   ClosureTypeName(NodeArray TemplateParams_, NodeArray Params_,
-                  std::string_view Count_)
+                  StringView Count_)
       : Node(KClosureTypeName), TemplateParams(TemplateParams_),
         Params(Params_), Count(Count_) {}
 
@@ -1702,12 +1699,12 @@ class StructuredBindingName : public Node {
 
 class BinaryExpr : public Node {
   const Node *LHS;
-  const std::string_view InfixOperator;
+  const StringView InfixOperator;
   const Node *RHS;
 
 public:
-  BinaryExpr(const Node *LHS_, std::string_view InfixOperator_,
-             const Node *RHS_, Prec Prec_)
+  BinaryExpr(const Node *LHS_, StringView InfixOperator_, const Node *RHS_,
+             Prec Prec_)
       : Node(KBinaryExpr, Prec_), LHS(LHS_), InfixOperator(InfixOperator_),
         RHS(RHS_) {}
 
@@ -1756,10 +1753,10 @@ class ArraySubscriptExpr : public Node {
 
 class PostfixExpr : public Node {
   const Node *Child;
-  const std::string_view Operator;
+  const StringView Operator;
 
 public:
-  PostfixExpr(const Node *Child_, std::string_view Operator_, Prec Prec_)
+  PostfixExpr(const Node *Child_, StringView Operator_, Prec Prec_)
       : Node(KPostfixExpr, Prec_), Child(Child_), Operator(Operator_) {}
 
   template <typename Fn> void match(Fn F) const {
@@ -1797,12 +1794,11 @@ class ConditionalExpr : public Node {
 
 class MemberExpr : public Node {
   const Node *LHS;
-  const std::string_view Kind;
+  const StringView Kind;
   const Node *RHS;
 
 public:
-  MemberExpr(const Node *LHS_, std::string_view Kind_, const Node *RHS_,
-             Prec Prec_)
+  MemberExpr(const Node *LHS_, StringView Kind_, const Node *RHS_, Prec Prec_)
       : Node(KMemberExpr, Prec_), LHS(LHS_), Kind(Kind_), RHS(RHS_) {}
 
   template <typename Fn> void match(Fn F) const {
@@ -1819,14 +1815,13 @@ class MemberExpr : public Node {
 class SubobjectExpr : public Node {
   const Node *Type;
   const Node *SubExpr;
-  std::string_view Offset;
+  StringView Offset;
   NodeArray UnionSelectors;
   bool OnePastTheEnd;
 
 public:
-  SubobjectExpr(const Node *Type_, const Node *SubExpr_,
-                std::string_view Offset_, NodeArray UnionSelectors_,
-                bool OnePastTheEnd_)
+  SubobjectExpr(const Node *Type_, const Node *SubExpr_, StringView Offset_,
+                NodeArray UnionSelectors_, bool OnePastTheEnd_)
       : Node(KSubobjectExpr), Type(Type_), SubExpr(SubExpr_), Offset(Offset_),
         UnionSelectors(UnionSelectors_), OnePastTheEnd(OnePastTheEnd_) {}
 
@@ -1852,12 +1847,12 @@ class SubobjectExpr : public Node {
 };
 
 class EnclosingExpr : public Node {
-  const std::string_view Prefix;
+  const StringView Prefix;
   const Node *Infix;
-  const std::string_view Postfix;
+  const StringView Postfix;
 
 public:
-  EnclosingExpr(std::string_view Prefix_, const Node *Infix_,
+  EnclosingExpr(StringView Prefix_, const Node *Infix_,
                 Prec Prec_ = Prec::Primary)
       : Node(KEnclosingExpr, Prec_), Prefix(Prefix_), Infix(Infix_) {}
 
@@ -1876,13 +1871,12 @@ class EnclosingExpr : public Node {
 
 class CastExpr : public Node {
   // cast_kind<to>(from)
-  const std::string_view CastKind;
+  const StringView CastKind;
   const Node *To;
   const Node *From;
 
 public:
-  CastExpr(std::string_view CastKind_, const Node *To_, const Node *From_,
-           Prec Prec_)
+  CastExpr(StringView CastKind_, const Node *To_, const Node *From_, Prec Prec_)
       : Node(KCastExpr, Prec_), CastKind(CastKind_), To(To_), From(From_) {}
 
   template <typename Fn> void match(Fn F) const {
@@ -2005,11 +1999,11 @@ class DeleteExpr : public Node {
 };
 
 class PrefixExpr : public Node {
-  std::string_view Prefix;
+  StringView Prefix;
   Node *Child;
 
 public:
-  PrefixExpr(std::string_view Prefix_, Node *Child_, Prec Prec_)
+  PrefixExpr(StringView Prefix_, Node *Child_, Prec Prec_)
       : Node(KPrefixExpr, Prec_), Prefix(Prefix_), Child(Child_) {}
 
   template <typename Fn> void match(Fn F) const {
@@ -2023,11 +2017,10 @@ class PrefixExpr : public Node {
 };
 
 class FunctionParam : public Node {
-  std::string_view Number;
+  StringView Number;
 
 public:
-  FunctionParam(std::string_view Number_)
-      : Node(KFunctionParam), Number(Number_) {}
+  FunctionParam(StringView Number_) : Node(KFunctionParam), Number(Number_) {}
 
   template<typename Fn> void match(Fn F) const { F(Number); }
 
@@ -2062,11 +2055,11 @@ class ConversionExpr : public Node {
 class PointerToMemberConversionExpr : public Node {
   const Node *Type;
   const Node *SubExpr;
-  std::string_view Offset;
+  StringView Offset;
 
 public:
   PointerToMemberConversionExpr(const Node *Type_, const Node *SubExpr_,
-                                std::string_view Offset_, Prec Prec_)
+                                StringView Offset_, Prec Prec_)
       : Node(KPointerToMemberConversionExpr, Prec_), Type(Type_),
         SubExpr(SubExpr_), Offset(Offset_) {}
 
@@ -2151,11 +2144,11 @@ class BracedRangeExpr : public Node {
 
 class FoldExpr : public Node {
   const Node *Pack, *Init;
-  std::string_view OperatorName;
+  StringView OperatorName;
   bool IsLeftFold;
 
 public:
-  FoldExpr(bool IsLeftFold_, std::string_view OperatorName_, const Node *Pack_,
+  FoldExpr(bool IsLeftFold_, StringView OperatorName_, const Node *Pack_,
            const Node *Init_)
       : Node(KFoldExpr), Pack(Pack_), Init(Init_), OperatorName(OperatorName_),
         IsLeftFold(IsLeftFold_) {}
@@ -2219,7 +2212,7 @@ class BoolExpr : public Node {
   template<typename Fn> void match(Fn F) const { F(Value); }
 
   void printLeft(OutputBuffer &OB) const override {
-    OB += Value ? std::string_view("true") : std::string_view("false");
+    OB += Value ? StringView("true") : StringView("false");
   }
 };
 
@@ -2257,10 +2250,10 @@ class LambdaExpr : public Node {
 class EnumLiteral : public Node {
   // ty(integer)
   const Node *Ty;
-  std::string_view Integer;
+  StringView Integer;
 
 public:
-  EnumLiteral(const Node *Ty_, std::string_view Integer_)
+  EnumLiteral(const Node *Ty_, StringView Integer_)
       : Node(KEnumLiteral), Ty(Ty_), Integer(Integer_) {}
 
   template<typename Fn> void match(Fn F) const { F(Ty, Integer); }
@@ -2278,11 +2271,11 @@ class EnumLiteral : public Node {
 };
 
 class IntegerLiteral : public Node {
-  std::string_view Type;
-  std::string_view Value;
+  StringView Type;
+  StringView Value;
 
 public:
-  IntegerLiteral(std::string_view Type_, std::string_view Value_)
+  IntegerLiteral(StringView Type_, StringView Value_)
       : Node(KIntegerLiteral), Type(Type_), Value(Value_) {}
 
   template<typename Fn> void match(Fn F) const { F(Type, Value); }
@@ -2319,13 +2312,13 @@ constexpr Node::Kind getFloatLiteralKind(long double *) {
 }
 
 template <class Float> class FloatLiteralImpl : public Node {
-  const std::string_view Contents;
+  const StringView Contents;
 
   static constexpr Kind KindForClass =
       float_literal_impl::getFloatLiteralKind((Float *)nullptr);
 
 public:
-  FloatLiteralImpl(std::string_view Contents_)
+  FloatLiteralImpl(StringView Contents_)
       : Node(KindForClass), Contents(Contents_) {}
 
   template<typename Fn> void match(Fn F) const { F(Contents); }
@@ -2356,7 +2349,7 @@ template <class Float> class FloatLiteralImpl : public Node {
 #endif
       char num[FloatData<Float>::max_demangled_size] = {0};
       int n = snprintf(num, sizeof(num), FloatData<Float>::spec, value);
-      OB += std::string_view(num, n);
+      OB += StringView(num, n);
     }
   }
 };
@@ -2483,8 +2476,8 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
     return res;
   }
 
-  bool consumeIf(std::string_view S) {
-    if (llvm::starts_with(std::string_view(First, Last - First), S)) {
+  bool consumeIf(StringView S) {
+    if (StringView(First, Last - First).startsWith(S)) {
       First += S.size();
       return true;
     }
@@ -2509,10 +2502,10 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
 
   size_t numLeft() const { return static_cast<size_t>(Last - First); }
 
-  std::string_view parseNumber(bool AllowNegative = false);
+  StringView parseNumber(bool AllowNegative = false);
   Qualifiers parseCVQualifiers();
   bool parsePositiveInteger(size_t *Out);
-  std::string_view parseBareSourceName();
+  StringView parseBareSourceName();
 
   bool parseSeqId(size_t *Out);
   Node *parseSubstitution();
@@ -2523,9 +2516,9 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
 
   /// Parse the <expr> production.
   Node *parseExpr();
-  Node *parsePrefixExpr(std::string_view Kind, Node::Prec Prec);
-  Node *parseBinaryExpr(std::string_view Kind, Node::Prec Prec);
-  Node *parseIntegerLiteral(std::string_view Lit);
+  Node *parsePrefixExpr(StringView Kind, Node::Prec Prec);
+  Node *parseBinaryExpr(StringView Kind, Node::Prec Prec);
+  Node *parseIntegerLiteral(StringView Lit);
   Node *parseExprPrimary();
   template <class Float> Node *parseFloatingLiteral();
   Node *parseFunctionParam();
@@ -2633,18 +2626,18 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
     bool operator!=(const char *Peek) const { return !this->operator==(Peek); }
 
   public:
-    std::string_view getSymbol() const {
-      std::string_view Res = Name;
+    StringView getSymbol() const {
+      StringView Res = Name;
       if (Kind < Unnameable) {
-        assert(llvm::starts_with(Res, "operator") &&
+        assert(Res.startsWith("operator") &&
                "operator name does not start with 'operator'");
         Res.remove_prefix(sizeof("operator") - 1);
-        if (llvm::starts_with(Res, ' '))
+        if (Res.startsWith(' '))
           Res.remove_prefix(1);
       }
       return Res;
     }
-    std::string_view getName() const { return Name; }
+    StringView getName() const { return Name; }
     OIKind getKind() const { return Kind; }
     bool getFlag() const { return Flag; }
     Node::Prec getPrecedence() const { return Prec; }
@@ -2864,7 +2857,7 @@ AbstractManglingParser<Derived, Alloc>::parseUnnamedTypeName(NameState *State) {
     TemplateParams.clear();
 
   if (consumeIf("Ut")) {
-    std::string_view Count = parseNumber();
+    StringView Count = parseNumber();
     if (!consumeIf('_'))
       return nullptr;
     return make<UnnamedTypeName>(Count);
@@ -2876,7 +2869,7 @@ AbstractManglingParser<Derived, Alloc>::parseUnnamedTypeName(NameState *State) {
 
     size_t ParamsBegin = Names.size();
     while (look() == 'T' &&
-           std::string_view("yptn").find(look(1)) != std::string_view::npos) {
+           StringView("yptn").find(look(1)) != StringView::npos) {
       Node *T = parseTemplateParamDecl();
       if (!T)
         return nullptr;
@@ -2919,7 +2912,7 @@ AbstractManglingParser<Derived, Alloc>::parseUnnamedTypeName(NameState *State) {
     }
     NodeArray Params = popTrailingNodeArray(ParamsBegin);
 
-    std::string_view Count = parseNumber();
+    StringView Count = parseNumber();
     if (!consumeIf('_'))
       return nullptr;
     return make<ClosureTypeName>(TempParams, Params, Count);
@@ -2941,9 +2934,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseSourceName(NameState *) {
     return nullptr;
   if (numLeft() < Length || Length == 0)
     return nullptr;
-  std::string_view Name(First, Length);
+  StringView Name(First, Length);
   First += Length;
-  if (llvm::starts_with(Name, "_GLOBAL__N"))
+  if (Name.startsWith("_GLOBAL__N"))
     return make<NameType>("(anonymous namespace)");
   return make<NameType>(Name);
 }
@@ -3457,7 +3450,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseUnresolvedName(bool Global) {
 template <typename Derived, typename Alloc>
 Node *AbstractManglingParser<Derived, Alloc>::parseAbiTags(Node *N) {
   while (consumeIf('B')) {
-    std::string_view SN = parseBareSourceName();
+    StringView SN = parseBareSourceName();
     if (SN.empty())
       return nullptr;
     N = make<AbiTagAttr>(N, SN);
@@ -3469,16 +3462,16 @@ Node *AbstractManglingParser<Derived, Alloc>::parseAbiTags(Node *N) {
 
 // <number> ::= [n] <non-negative decimal integer>
 template <typename Alloc, typename Derived>
-std::string_view
+StringView
 AbstractManglingParser<Alloc, Derived>::parseNumber(bool AllowNegative) {
   const char *Tmp = First;
   if (AllowNegative)
     consumeIf('n');
   if (numLeft() == 0 || !std::isdigit(*First))
-    return std::string_view();
+    return StringView();
   while (numLeft() != 0 && std::isdigit(*First))
     ++First;
-  return std::string_view(Tmp, First - Tmp);
+  return StringView(Tmp, First - Tmp);
 }
 
 // <positive length number> ::= [0-9]*
@@ -3495,11 +3488,11 @@ bool AbstractManglingParser<Alloc, Derived>::parsePositiveInteger(size_t *Out) {
 }
 
 template <typename Alloc, typename Derived>
-std::string_view AbstractManglingParser<Alloc, Derived>::parseBareSourceName() {
+StringView AbstractManglingParser<Alloc, Derived>::parseBareSourceName() {
   size_t Int = 0;
   if (parsePositiveInteger(&Int) || numLeft() < Int)
-    return {};
-  std::string_view R(First, Int);
+    return StringView();
+  StringView R(First, Int);
   First += Int;
   return R;
 }
@@ -3683,7 +3676,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parsePointerToMemberType() {
 //                   ::= Te <name>  # dependent elaborated type specifier using 'enum'
 template <typename Derived, typename Alloc>
 Node *AbstractManglingParser<Derived, Alloc>::parseClassEnumType() {
-  std::string_view ElabSpef;
+  StringView ElabSpef;
   if (consumeIf("Ts"))
     ElabSpef = "struct";
   else if (consumeIf("Tu"))
@@ -3707,14 +3700,14 @@ Node *AbstractManglingParser<Derived, Alloc>::parseClassEnumType() {
 template <typename Derived, typename Alloc>
 Node *AbstractManglingParser<Derived, Alloc>::parseQualifiedType() {
   if (consumeIf('U')) {
-    std::string_view Qual = parseBareSourceName();
+    StringView Qual = parseBareSourceName();
     if (Qual.empty())
       return nullptr;
 
     // extension            ::= U <objc-name> <objc-type>  # objc-type<identifier>
-    if (llvm::starts_with(Qual, "objcproto")) {
-      std::string_view ProtoSourceName = Qual.substr(std::strlen("objcproto"));
-      std::string_view Proto;
+    if (Qual.startsWith("objcproto")) {
+      StringView ProtoSourceName = Qual.substr(std::strlen("objcproto"));
+      StringView Proto;
       {
         ScopedOverride<const char *> SaveFirst(First, ProtoSourceName.begin()),
             SaveLast(Last, ProtoSourceName.end());
@@ -3885,7 +3878,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
   // <builtin-type> ::= u <source-name>    # vendor extended type
   case 'u': {
     ++First;
-    std::string_view Res = parseBareSourceName();
+    StringView Res = parseBareSourceName();
     if (Res.empty())
       return nullptr;
     // Typically, <builtin-type>s are not considered substitution candidates,
@@ -4133,9 +4126,8 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
 }
 
 template <typename Derived, typename Alloc>
-Node *
-AbstractManglingParser<Derived, Alloc>::parsePrefixExpr(std::string_view Kind,
-                                                        Node::Prec Prec) {
+Node *AbstractManglingParser<Derived, Alloc>::parsePrefixExpr(StringView Kind,
+                                                              Node::Prec Prec) {
   Node *E = getDerived().parseExpr();
   if (E == nullptr)
     return nullptr;
@@ -4143,9 +4135,8 @@ AbstractManglingParser<Derived, Alloc>::parsePrefixExpr(std::string_view Kind,
 }
 
 template <typename Derived, typename Alloc>
-Node *
-AbstractManglingParser<Derived, Alloc>::parseBinaryExpr(std::string_view Kind,
-                                                        Node::Prec Prec) {
+Node *AbstractManglingParser<Derived, Alloc>::parseBinaryExpr(StringView Kind,
+                                                              Node::Prec Prec) {
   Node *LHS = getDerived().parseExpr();
   if (LHS == nullptr)
     return nullptr;
@@ -4156,9 +4147,9 @@ AbstractManglingParser<Derived, Alloc>::parseBinaryExpr(std::string_view Kind,
 }
 
 template <typename Derived, typename Alloc>
-Node *AbstractManglingParser<Derived, Alloc>::parseIntegerLiteral(
-    std::string_view Lit) {
-  std::string_view Tmp = parseNumber(true);
+Node *
+AbstractManglingParser<Derived, Alloc>::parseIntegerLiteral(StringView Lit) {
+  StringView Tmp = parseNumber(true);
   if (!Tmp.empty() && consumeIf('E'))
     return make<IntegerLiteral>(Lit, Tmp);
   return nullptr;
@@ -4188,7 +4179,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseFunctionParam() {
     return make<NameType>("this");
   if (consumeIf("fp")) {
     parseCVQualifiers();
-    std::string_view Num = parseNumber();
+    StringView Num = parseNumber();
     if (!consumeIf('_'))
       return nullptr;
     return make<FunctionParam>(Num);
@@ -4199,7 +4190,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseFunctionParam() {
     if (!consumeIf('p'))
       return nullptr;
     parseCVQualifiers();
-    std::string_view Num = parseNumber();
+    StringView Num = parseNumber();
     if (!consumeIf('_'))
       return nullptr;
     return make<FunctionParam>(Num);
@@ -4353,7 +4344,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExprPrimary() {
     Node *T = getDerived().parseType();
     if (T == nullptr)
       return nullptr;
-    std::string_view N = parseNumber(/*AllowNegative=*/true);
+    StringView N = parseNumber(/*AllowNegative=*/true);
     if (N.empty())
       return nullptr;
     if (!consumeIf('E'))
@@ -4476,7 +4467,7 @@ AbstractManglingParser<Derived, Alloc>::parsePointerToMemberConversionExpr(
   Node *Expr = getDerived().parseExpr();
   if (!Expr)
     return nullptr;
-  std::string_view Offset = getDerived().parseNumber(true);
+  StringView Offset = getDerived().parseNumber(true);
   if (!consumeIf('E'))
     return nullptr;
   return make<PointerToMemberConversionExpr>(Ty, Expr, Offset, Prec);
@@ -4494,7 +4485,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseSubobjectExpr() {
   Node *Expr = getDerived().parseExpr();
   if (!Expr)
     return nullptr;
-  std::string_view Offset = getDerived().parseNumber(true);
+  StringView Offset = getDerived().parseNumber(true);
   size_t SelectorsBegin = Names.size();
   while (consumeIf('_')) {
     Node *Selector = make<NameType>(parseNumber());
@@ -5153,7 +5144,7 @@ Node *AbstractManglingParser<Alloc, Derived>::parseFloatingLiteral() {
   const size_t N = FloatData<Float>::mangled_size;
   if (numLeft() <= N)
     return nullptr;
-  std::string_view Data(First, N);
+  StringView Data(First, N);
   for (char C : Data)
     if (!std::isxdigit(C))
       return nullptr;
@@ -5473,8 +5464,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parse() {
     if (Encoding == nullptr)
       return nullptr;
     if (look() == '.') {
-      Encoding =
-          make<DotSuffix>(Encoding, std::string_view(First, Last - First));
+      Encoding = make<DotSuffix>(Encoding, StringView(First, Last - First));
       First = Last;
     }
     if (numLeft() != 0)

diff  --git a/llvm/include/llvm/Demangle/MicrosoftDemangle.h b/llvm/include/llvm/Demangle/MicrosoftDemangle.h
index 085cd87223587..f1a5e1b64ebbd 100644
--- a/llvm/include/llvm/Demangle/MicrosoftDemangle.h
+++ b/llvm/include/llvm/Demangle/MicrosoftDemangle.h
@@ -10,9 +10,8 @@
 #define LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
 
 #include "llvm/Demangle/MicrosoftDemangleNodes.h"
+#include "llvm/Demangle/StringView.h"
 
-#include <cassert>
-#include <string_view>
 #include <utility>
 
 namespace llvm {
@@ -143,9 +142,9 @@ class Demangler {
 
   // You are supposed to call parse() first and then check if error is true.  If
   // it is false, call output() to write the formatted name to the given stream.
-  SymbolNode *parse(std::string_view &MangledName);
+  SymbolNode *parse(StringView &MangledName);
 
-  TagTypeNode *parseTagUniqueName(std::string_view &MangledName);
+  TagTypeNode *parseTagUniqueName(StringView &MangledName);
 
   // True if an error occurred.
   bool Error = false;
@@ -153,110 +152,104 @@ class Demangler {
   void dumpBackReferences();
 
 private:
-  SymbolNode *demangleEncodedSymbol(std::string_view &MangledName,
+  SymbolNode *demangleEncodedSymbol(StringView &MangledName,
                                     QualifiedNameNode *QN);
-  SymbolNode *demangleDeclarator(std::string_view &MangledName);
-  SymbolNode *demangleMD5Name(std::string_view &MangledName);
-  SymbolNode *demangleTypeinfoName(std::string_view &MangledName);
+  SymbolNode *demangleDeclarator(StringView &MangledName);
+  SymbolNode *demangleMD5Name(StringView &MangledName);
+  SymbolNode *demangleTypeinfoName(StringView &MangledName);
 
-  VariableSymbolNode *demangleVariableEncoding(std::string_view &MangledName,
+  VariableSymbolNode *demangleVariableEncoding(StringView &MangledName,
                                                StorageClass SC);
-  FunctionSymbolNode *demangleFunctionEncoding(std::string_view &MangledName);
+  FunctionSymbolNode *demangleFunctionEncoding(StringView &MangledName);
 
-  Qualifiers demanglePointerExtQualifiers(std::string_view &MangledName);
+  Qualifiers demanglePointerExtQualifiers(StringView &MangledName);
 
   // Parser functions. This is a recursive-descent parser.
-  TypeNode *demangleType(std::string_view &MangledName, QualifierMangleMode QMM);
-  PrimitiveTypeNode *demanglePrimitiveType(std::string_view &MangledName);
-  CustomTypeNode *demangleCustomType(std::string_view &MangledName);
-  TagTypeNode *demangleClassType(std::string_view &MangledName);
-  PointerTypeNode *demanglePointerType(std::string_view &MangledName);
-  PointerTypeNode *demangleMemberPointerType(std::string_view &MangledName);
-  FunctionSignatureNode *demangleFunctionType(std::string_view &MangledName,
+  TypeNode *demangleType(StringView &MangledName, QualifierMangleMode QMM);
+  PrimitiveTypeNode *demanglePrimitiveType(StringView &MangledName);
+  CustomTypeNode *demangleCustomType(StringView &MangledName);
+  TagTypeNode *demangleClassType(StringView &MangledName);
+  PointerTypeNode *demanglePointerType(StringView &MangledName);
+  PointerTypeNode *demangleMemberPointerType(StringView &MangledName);
+  FunctionSignatureNode *demangleFunctionType(StringView &MangledName,
                                               bool HasThisQuals);
 
-  ArrayTypeNode *demangleArrayType(std::string_view &MangledName);
+  ArrayTypeNode *demangleArrayType(StringView &MangledName);
 
-  NodeArrayNode *demangleFunctionParameterList(std::string_view &MangledName,
+  NodeArrayNode *demangleFunctionParameterList(StringView &MangledName,
                                                bool &IsVariadic);
-  NodeArrayNode *demangleTemplateParameterList(std::string_view &MangledName);
+  NodeArrayNode *demangleTemplateParameterList(StringView &MangledName);
 
-  std::pair<uint64_t, bool> demangleNumber(std::string_view &MangledName);
-  uint64_t demangleUnsigned(std::string_view &MangledName);
-  int64_t demangleSigned(std::string_view &MangledName);
+  std::pair<uint64_t, bool> demangleNumber(StringView &MangledName);
+  uint64_t demangleUnsigned(StringView &MangledName);
+  int64_t demangleSigned(StringView &MangledName);
 
-  void memorizeString(std::string_view s);
+  void memorizeString(StringView s);
   void memorizeIdentifier(IdentifierNode *Identifier);
 
   /// Allocate a copy of \p Borrowed into memory that we own.
-  std::string_view copyString(std::string_view Borrowed);
+  StringView copyString(StringView Borrowed);
 
-  QualifiedNameNode *
-  demangleFullyQualifiedTypeName(std::string_view &MangledName);
-  QualifiedNameNode *
-  demangleFullyQualifiedSymbolName(std::string_view &MangledName);
+  QualifiedNameNode *demangleFullyQualifiedTypeName(StringView &MangledName);
+  QualifiedNameNode *demangleFullyQualifiedSymbolName(StringView &MangledName);
 
-  IdentifierNode *demangleUnqualifiedTypeName(std::string_view &MangledName,
+  IdentifierNode *demangleUnqualifiedTypeName(StringView &MangledName,
                                               bool Memorize);
-  IdentifierNode *demangleUnqualifiedSymbolName(std::string_view &MangledName,
+  IdentifierNode *demangleUnqualifiedSymbolName(StringView &MangledName,
                                                 NameBackrefBehavior NBB);
 
-  QualifiedNameNode *demangleNameScopeChain(std::string_view &MangledName,
+  QualifiedNameNode *demangleNameScopeChain(StringView &MangledName,
                                             IdentifierNode *UnqualifiedName);
-  IdentifierNode *demangleNameScopePiece(std::string_view &MangledName);
+  IdentifierNode *demangleNameScopePiece(StringView &MangledName);
 
-  NamedIdentifierNode *demangleBackRefName(std::string_view &MangledName);
-  IdentifierNode *
-  demangleTemplateInstantiationName(std::string_view &MangledName,
-                                    NameBackrefBehavior NBB);
+  NamedIdentifierNode *demangleBackRefName(StringView &MangledName);
+  IdentifierNode *demangleTemplateInstantiationName(StringView &MangledName,
+                                                    NameBackrefBehavior NBB);
   IntrinsicFunctionKind
   translateIntrinsicFunctionCode(char CH, FunctionIdentifierCodeGroup Group);
-  IdentifierNode *demangleFunctionIdentifierCode(std::string_view &MangledName);
+  IdentifierNode *demangleFunctionIdentifierCode(StringView &MangledName);
   IdentifierNode *
-  demangleFunctionIdentifierCode(std::string_view &MangledName,
+  demangleFunctionIdentifierCode(StringView &MangledName,
                                  FunctionIdentifierCodeGroup Group);
-  StructorIdentifierNode *
-  demangleStructorIdentifier(std::string_view &MangledName, bool IsDestructor);
+  StructorIdentifierNode *demangleStructorIdentifier(StringView &MangledName,
+                                                     bool IsDestructor);
   ConversionOperatorIdentifierNode *
-  demangleConversionOperatorIdentifier(std::string_view &MangledName);
+  demangleConversionOperatorIdentifier(StringView &MangledName);
   LiteralOperatorIdentifierNode *
-  demangleLiteralOperatorIdentifier(std::string_view &MangledName);
+  demangleLiteralOperatorIdentifier(StringView &MangledName);
 
-  SymbolNode *demangleSpecialIntrinsic(std::string_view &MangledName);
+  SymbolNode *demangleSpecialIntrinsic(StringView &MangledName);
   SpecialTableSymbolNode *
-  demangleSpecialTableSymbolNode(std::string_view &MangledName,
+  demangleSpecialTableSymbolNode(StringView &MangledName,
                                  SpecialIntrinsicKind SIK);
   LocalStaticGuardVariableNode *
-  demangleLocalStaticGuard(std::string_view &MangledName, bool IsThread);
+  demangleLocalStaticGuard(StringView &MangledName, bool IsThread);
   VariableSymbolNode *demangleUntypedVariable(ArenaAllocator &Arena,
-                                              std::string_view &MangledName,
-                                              std::string_view VariableName);
+                                              StringView &MangledName,
+                                              StringView VariableName);
   VariableSymbolNode *
   demangleRttiBaseClassDescriptorNode(ArenaAllocator &Arena,
-                                      std::string_view &MangledName);
-  FunctionSymbolNode *demangleInitFiniStub(std::string_view &MangledName,
+                                      StringView &MangledName);
+  FunctionSymbolNode *demangleInitFiniStub(StringView &MangledName,
                                            bool IsDestructor);
 
-  NamedIdentifierNode *demangleSimpleName(std::string_view &MangledName,
+  NamedIdentifierNode *demangleSimpleName(StringView &MangledName,
                                           bool Memorize);
-  NamedIdentifierNode *
-  demangleAnonymousNamespaceName(std::string_view &MangledName);
-  NamedIdentifierNode *
-  demangleLocallyScopedNamePiece(std::string_view &MangledName);
-  EncodedStringLiteralNode *demangleStringLiteral(std::string_view &MangledName);
-  FunctionSymbolNode *demangleVcallThunkNode(std::string_view &MangledName);
-
-  std::string_view demangleSimpleString(std::string_view &MangledName,
-                                        bool Memorize);
-
-  FuncClass demangleFunctionClass(std::string_view &MangledName);
-  CallingConv demangleCallingConvention(std::string_view &MangledName);
-  StorageClass demangleVariableStorageClass(std::string_view &MangledName);
-  bool demangleThrowSpecification(std::string_view &MangledName);
-  wchar_t demangleWcharLiteral(std::string_view &MangledName);
-  uint8_t demangleCharLiteral(std::string_view &MangledName);
-
-  std::pair<Qualifiers, bool> demangleQualifiers(std::string_view &MangledName);
+  NamedIdentifierNode *demangleAnonymousNamespaceName(StringView &MangledName);
+  NamedIdentifierNode *demangleLocallyScopedNamePiece(StringView &MangledName);
+  EncodedStringLiteralNode *demangleStringLiteral(StringView &MangledName);
+  FunctionSymbolNode *demangleVcallThunkNode(StringView &MangledName);
+
+  StringView demangleSimpleString(StringView &MangledName, bool Memorize);
+
+  FuncClass demangleFunctionClass(StringView &MangledName);
+  CallingConv demangleCallingConvention(StringView &MangledName);
+  StorageClass demangleVariableStorageClass(StringView &MangledName);
+  bool demangleThrowSpecification(StringView &MangledName);
+  wchar_t demangleWcharLiteral(StringView &MangledName);
+  uint8_t demangleCharLiteral(StringView &MangledName);
+
+  std::pair<Qualifiers, bool> demangleQualifiers(StringView &MangledName);
 
   // Memory allocator.
   ArenaAllocator Arena;

diff  --git a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
index 1913bff0ada7f..8ad2472364b4c 100644
--- a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
+++ b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
@@ -13,10 +13,10 @@
 #ifndef LLVM_DEMANGLE_MICROSOFTDEMANGLENODES_H
 #define LLVM_DEMANGLE_MICROSOFTDEMANGLENODES_H
 
+#include "llvm/Demangle/StringView.h"
 #include <array>
 #include <cstdint>
 #include <string>
-#include <string_view>
 
 namespace llvm {
 namespace itanium_demangle {
@@ -25,6 +25,7 @@ class OutputBuffer;
 }
 
 using llvm::itanium_demangle::OutputBuffer;
+using llvm::itanium_demangle::StringView;
 
 namespace llvm {
 namespace ms_demangle {
@@ -383,7 +384,7 @@ struct NamedIdentifierNode : public IdentifierNode {
 
   void output(OutputBuffer &OB, OutputFlags Flags) const override;
 
-  std::string_view Name;
+  StringView Name;
 };
 
 struct IntrinsicFunctionIdentifierNode : public IdentifierNode {
@@ -402,7 +403,7 @@ struct LiteralOperatorIdentifierNode : public IdentifierNode {
 
   void output(OutputBuffer &OB, OutputFlags Flags) const override;
 
-  std::string_view Name;
+  StringView Name;
 };
 
 struct LocalStaticGuardIdentifierNode : public IdentifierNode {
@@ -515,8 +516,7 @@ struct NodeArrayNode : public Node {
 
   void output(OutputBuffer &OB, OutputFlags Flags) const override;
 
-  void output(OutputBuffer &OB, OutputFlags Flags,
-              std::string_view Separator) const;
+  void output(OutputBuffer &OB, OutputFlags Flags, StringView Separator) const;
 
   Node **Nodes = nullptr;
   size_t Count = 0;
@@ -601,7 +601,7 @@ struct EncodedStringLiteralNode : public SymbolNode {
 
   void output(OutputBuffer &OB, OutputFlags Flags) const override;
 
-  std::string_view DecodedString;
+  StringView DecodedString;
   bool IsTruncated = false;
   CharKind Char = CharKind::Char;
 };

diff  --git a/llvm/include/llvm/Demangle/Utility.h b/llvm/include/llvm/Demangle/Utility.h
index a906d238cf447..248d410f06407 100644
--- a/llvm/include/llvm/Demangle/Utility.h
+++ b/llvm/include/llvm/Demangle/Utility.h
@@ -16,16 +16,13 @@
 #ifndef DEMANGLE_UTILITY_H
 #define DEMANGLE_UTILITY_H
 
-#include "DemangleConfig.h"
-
+#include "StringView.h"
 #include <array>
-#include <cassert>
 #include <cstdint>
 #include <cstdlib>
 #include <cstring>
 #include <exception>
 #include <limits>
-#include <string_view>
 
 DEMANGLE_NAMESPACE_BEGIN
 
@@ -67,8 +64,7 @@ class OutputBuffer {
     if (isNeg)
       *--TempPtr = '-';
 
-    return operator+=(
-        std::string_view(TempPtr, Temp.data() + Temp.size() - TempPtr));
+    return operator+=(StringView(TempPtr, Temp.data() + Temp.size() - TempPtr));
   }
 
 public:
@@ -81,9 +77,7 @@ class OutputBuffer {
   OutputBuffer(const OutputBuffer &) = delete;
   OutputBuffer &operator=(const OutputBuffer &) = delete;
 
-  operator std::string_view() const {
-    return std::string_view(Buffer, CurrentPosition);
-  }
+  operator StringView() const { return StringView(Buffer, CurrentPosition); }
 
   /// If a ParameterPackExpansion (or similar type) is encountered, the offset
   /// into the pack that we're currently printing.
@@ -105,10 +99,10 @@ class OutputBuffer {
     *this += Close;
   }
 
-  OutputBuffer &operator+=(std::string_view R) {
+  OutputBuffer &operator+=(StringView R) {
     if (size_t Size = R.size()) {
       grow(Size);
-      std::memcpy(Buffer + CurrentPosition, &*R.begin(), Size);
+      std::memcpy(Buffer + CurrentPosition, R.begin(), Size);
       CurrentPosition += Size;
     }
     return *this;
@@ -120,18 +114,18 @@ class OutputBuffer {
     return *this;
   }
 
-  OutputBuffer &prepend(std::string_view R) {
+  OutputBuffer &prepend(StringView R) {
     size_t Size = R.size();
 
     grow(Size);
     std::memmove(Buffer + Size, Buffer, CurrentPosition);
-    std::memcpy(Buffer, &*R.begin(), Size);
+    std::memcpy(Buffer, R.begin(), Size);
     CurrentPosition += Size;
 
     return *this;
   }
 
-  OutputBuffer &operator<<(std::string_view R) { return (*this += R); }
+  OutputBuffer &operator<<(StringView R) { return (*this += R); }
 
   OutputBuffer &operator<<(char C) { return (*this += C); }
 

diff  --git a/llvm/lib/Demangle/DLangDemangle.cpp b/llvm/lib/Demangle/DLangDemangle.cpp
index ad583b86946fd..b747b0f9cc677 100644
--- a/llvm/lib/Demangle/DLangDemangle.cpp
+++ b/llvm/lib/Demangle/DLangDemangle.cpp
@@ -14,6 +14,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Demangle/Demangle.h"
+#include "llvm/Demangle/StringView.h"
 #include "llvm/Demangle/Utility.h"
 
 #include <cctype>
@@ -22,6 +23,7 @@
 
 using namespace llvm;
 using llvm::itanium_demangle::OutputBuffer;
+using llvm::itanium_demangle::StringView;
 
 namespace {
 
@@ -528,7 +530,7 @@ const char *Demangler::parseLName(OutputBuffer *Demangled, const char *Mangled,
     break;
   }
 
-  *Demangled << std::string_view(Mangled, Len);
+  *Demangled << StringView(Mangled, Len);
   Mangled += Len;
 
   return Mangled;

diff  --git a/llvm/lib/Demangle/ItaniumDemangle.cpp b/llvm/lib/Demangle/ItaniumDemangle.cpp
index 7a7bcd36fc689..9b646ea800aa6 100644
--- a/llvm/lib/Demangle/ItaniumDemangle.cpp
+++ b/llvm/lib/Demangle/ItaniumDemangle.cpp
@@ -78,8 +78,8 @@ struct DumpVisitor {
   }
 
   void printStr(const char *S) { fprintf(stderr, "%s", S); }
-  void print(std::string_view SV) {
-    fprintf(stderr, "\"%.*s\"", (int)SV.size(), &*SV.begin());
+  void print(StringView SV) {
+    fprintf(stderr, "\"%.*s\"", (int)SV.size(), SV.begin());
   }
   void print(const Node *N) {
     if (N)

diff  --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp
index 1885f556cd9e0..248b748e6f973 100644
--- a/llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -14,23 +14,22 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Demangle/MicrosoftDemangle.h"
-
-#include "llvm/ADT/StringViewExtras.h"
 #include "llvm/Demangle/Demangle.h"
-#include "llvm/Demangle/DemangleConfig.h"
 #include "llvm/Demangle/MicrosoftDemangleNodes.h"
+
+#include "llvm/Demangle/DemangleConfig.h"
+#include "llvm/Demangle/StringView.h"
 #include "llvm/Demangle/Utility.h"
 
 #include <array>
 #include <cctype>
 #include <cstdio>
-#include <string_view>
 #include <tuple>
 
 using namespace llvm;
 using namespace ms_demangle;
 
-static bool startsWithDigit(std::string_view S) {
+static bool startsWithDigit(StringView S) {
   return !S.empty() && std::isdigit(S.front());
 }
 
@@ -39,21 +38,21 @@ struct NodeList {
   NodeList *Next = nullptr;
 };
 
-static bool consumeFront(std::string_view &S, char C) {
-  if (!llvm::starts_with(S, C))
+static bool consumeFront(StringView &S, char C) {
+  if (!S.startsWith(C))
     return false;
   S.remove_prefix(1);
   return true;
 }
 
-static bool consumeFront(std::string_view &S, std::string_view C) {
-  if (!llvm::starts_with(S, C))
+static bool consumeFront(StringView &S, StringView C) {
+  if (!S.startsWith(C))
     return false;
   S.remove_prefix(C.size());
   return true;
 }
 
-static bool isMemberPointer(std::string_view MangledName, bool &Error) {
+static bool isMemberPointer(StringView MangledName, bool &Error) {
   Error = false;
   const char F = MangledName.front();
   MangledName.remove_prefix(1);
@@ -119,7 +118,7 @@ static bool isMemberPointer(std::string_view MangledName, bool &Error) {
 }
 
 static SpecialIntrinsicKind
-consumeSpecialIntrinsicKind(std::string_view &MangledName) {
+consumeSpecialIntrinsicKind(StringView &MangledName) {
   if (consumeFront(MangledName, "?_7"))
     return SpecialIntrinsicKind::Vftable;
   if (consumeFront(MangledName, "?_8"))
@@ -155,14 +154,14 @@ consumeSpecialIntrinsicKind(std::string_view &MangledName) {
   return SpecialIntrinsicKind::None;
 }
 
-static bool startsWithLocalScopePattern(std::string_view S) {
+static bool startsWithLocalScopePattern(StringView S) {
   if (!consumeFront(S, '?'))
     return false;
 
   size_t End = S.find('?');
-  if (End == std::string_view::npos)
+  if (End == StringView::npos)
     return false;
-  std::string_view Candidate = S.substr(0, End);
+  StringView Candidate = S.substr(0, End);
   if (Candidate.empty())
     return false;
 
@@ -194,7 +193,7 @@ static bool startsWithLocalScopePattern(std::string_view S) {
   return true;
 }
 
-static bool isTagType(std::string_view S) {
+static bool isTagType(StringView S) {
   switch (S.front()) {
   case 'T': // union
   case 'U': // struct
@@ -205,10 +204,10 @@ static bool isTagType(std::string_view S) {
   return false;
 }
 
-static bool isCustomType(std::string_view S) { return S[0] == '?'; }
+static bool isCustomType(StringView S) { return S[0] == '?'; }
 
-static bool isPointerType(std::string_view S) {
-  if (llvm::starts_with(S, "$$Q")) // foo &&
+static bool isPointerType(StringView S) {
+  if (S.startsWith("$$Q")) // foo &&
     return true;
 
   switch (S.front()) {
@@ -222,14 +221,14 @@ static bool isPointerType(std::string_view S) {
   return false;
 }
 
-static bool isArrayType(std::string_view S) { return S[0] == 'Y'; }
+static bool isArrayType(StringView S) { return S[0] == 'Y'; }
 
-static bool isFunctionType(std::string_view S) {
-  return llvm::starts_with(S, "$$A8@@") || llvm::starts_with(S, "$$A6");
+static bool isFunctionType(StringView S) {
+  return S.startsWith("$$A8@@") || S.startsWith("$$A6");
 }
 
 static FunctionRefQualifier
-demangleFunctionRefQualifier(std::string_view &MangledName) {
+demangleFunctionRefQualifier(StringView &MangledName) {
   if (consumeFront(MangledName, 'G'))
     return FunctionRefQualifier::Reference;
   else if (consumeFront(MangledName, 'H'))
@@ -238,7 +237,7 @@ demangleFunctionRefQualifier(std::string_view &MangledName) {
 }
 
 static std::pair<Qualifiers, PointerAffinity>
-demanglePointerCVQualifiers(std::string_view &MangledName) {
+demanglePointerCVQualifiers(StringView &MangledName) {
   if (consumeFront(MangledName, "$$Q"))
     return std::make_pair(Q_None, PointerAffinity::RValueReference);
 
@@ -262,18 +261,18 @@ demanglePointerCVQualifiers(std::string_view &MangledName) {
   DEMANGLE_UNREACHABLE;
 }
 
-std::string_view Demangler::copyString(std::string_view Borrowed) {
+StringView Demangler::copyString(StringView Borrowed) {
   char *Stable = Arena.allocUnalignedBuffer(Borrowed.size());
   // 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());
+    std::memcpy(Stable, Borrowed.begin(), Borrowed.size());
 
   return {Stable, Borrowed.size()};
 }
 
 SpecialTableSymbolNode *
-Demangler::demangleSpecialTableSymbolNode(std::string_view &MangledName,
+Demangler::demangleSpecialTableSymbolNode(StringView &MangledName,
                                           SpecialIntrinsicKind K) {
   NamedIdentifierNode *NI = Arena.alloc<NamedIdentifierNode>();
   switch (K) {
@@ -314,8 +313,7 @@ Demangler::demangleSpecialTableSymbolNode(std::string_view &MangledName,
 }
 
 LocalStaticGuardVariableNode *
-Demangler::demangleLocalStaticGuard(std::string_view &MangledName,
-                                    bool IsThread) {
+Demangler::demangleLocalStaticGuard(StringView &MangledName, bool IsThread) {
   LocalStaticGuardIdentifierNode *LSGI =
       Arena.alloc<LocalStaticGuardIdentifierNode>();
   LSGI->IsThread = IsThread;
@@ -339,7 +337,7 @@ Demangler::demangleLocalStaticGuard(std::string_view &MangledName,
 }
 
 static NamedIdentifierNode *synthesizeNamedIdentifier(ArenaAllocator &Arena,
-                                                      std::string_view Name) {
+                                                      StringView Name) {
   NamedIdentifierNode *Id = Arena.alloc<NamedIdentifierNode>();
   Id->Name = Name;
   return Id;
@@ -356,24 +354,22 @@ static QualifiedNameNode *synthesizeQualifiedName(ArenaAllocator &Arena,
 }
 
 static QualifiedNameNode *synthesizeQualifiedName(ArenaAllocator &Arena,
-                                                  std::string_view Name) {
+                                                  StringView Name) {
   NamedIdentifierNode *Id = synthesizeNamedIdentifier(Arena, Name);
   return synthesizeQualifiedName(Arena, Id);
 }
 
 static VariableSymbolNode *synthesizeVariable(ArenaAllocator &Arena,
                                               TypeNode *Type,
-                                              std::string_view VariableName) {
+                                              StringView VariableName) {
   VariableSymbolNode *VSN = Arena.alloc<VariableSymbolNode>();
   VSN->Type = Type;
   VSN->Name = synthesizeQualifiedName(Arena, VariableName);
   return VSN;
 }
 
-VariableSymbolNode *
-Demangler::demangleUntypedVariable(ArenaAllocator &Arena,
-                                   std::string_view &MangledName,
-                                   std::string_view VariableName) {
+VariableSymbolNode *Demangler::demangleUntypedVariable(
+    ArenaAllocator &Arena, StringView &MangledName, StringView VariableName) {
   NamedIdentifierNode *NI = synthesizeNamedIdentifier(Arena, VariableName);
   QualifiedNameNode *QN = demangleNameScopeChain(MangledName, NI);
   VariableSymbolNode *VSN = Arena.alloc<VariableSymbolNode>();
@@ -387,7 +383,7 @@ Demangler::demangleUntypedVariable(ArenaAllocator &Arena,
 
 VariableSymbolNode *
 Demangler::demangleRttiBaseClassDescriptorNode(ArenaAllocator &Arena,
-                                               std::string_view &MangledName) {
+                                               StringView &MangledName) {
   RttiBaseClassDescriptorNode *RBCDN =
       Arena.alloc<RttiBaseClassDescriptorNode>();
   RBCDN->NVOffset = demangleUnsigned(MangledName);
@@ -403,9 +399,8 @@ Demangler::demangleRttiBaseClassDescriptorNode(ArenaAllocator &Arena,
   return VSN;
 }
 
-FunctionSymbolNode *
-Demangler::demangleInitFiniStub(std::string_view &MangledName,
-                                bool IsDestructor) {
+FunctionSymbolNode *Demangler::demangleInitFiniStub(StringView &MangledName,
+                                                    bool IsDestructor) {
   DynamicStructorIdentifierNode *DSIN =
       Arena.alloc<DynamicStructorIdentifierNode>();
   DSIN->IsDestructor = IsDestructor;
@@ -453,7 +448,7 @@ Demangler::demangleInitFiniStub(std::string_view &MangledName,
   return FSN;
 }
 
-SymbolNode *Demangler::demangleSpecialIntrinsic(std::string_view &MangledName) {
+SymbolNode *Demangler::demangleSpecialIntrinsic(StringView &MangledName) {
   SpecialIntrinsicKind SIK = consumeSpecialIntrinsicKind(MangledName);
 
   switch (SIK) {
@@ -507,8 +502,8 @@ SymbolNode *Demangler::demangleSpecialIntrinsic(std::string_view &MangledName) {
 }
 
 IdentifierNode *
-Demangler::demangleFunctionIdentifierCode(std::string_view &MangledName) {
-  assert(llvm::starts_with(MangledName, '?'));
+Demangler::demangleFunctionIdentifierCode(StringView &MangledName) {
+  assert(MangledName.startsWith('?'));
   MangledName.remove_prefix(1);
   if (MangledName.empty()) {
     Error = true;
@@ -526,7 +521,7 @@ Demangler::demangleFunctionIdentifierCode(std::string_view &MangledName) {
 }
 
 StructorIdentifierNode *
-Demangler::demangleStructorIdentifier(std::string_view &MangledName,
+Demangler::demangleStructorIdentifier(StringView &MangledName,
                                       bool IsDestructor) {
   StructorIdentifierNode *N = Arena.alloc<StructorIdentifierNode>();
   N->IsDestructor = IsDestructor;
@@ -534,14 +529,14 @@ Demangler::demangleStructorIdentifier(std::string_view &MangledName,
 }
 
 ConversionOperatorIdentifierNode *
-Demangler::demangleConversionOperatorIdentifier(std::string_view &MangledName) {
+Demangler::demangleConversionOperatorIdentifier(StringView &MangledName) {
   ConversionOperatorIdentifierNode *N =
       Arena.alloc<ConversionOperatorIdentifierNode>();
   return N;
 }
 
 LiteralOperatorIdentifierNode *
-Demangler::demangleLiteralOperatorIdentifier(std::string_view &MangledName) {
+Demangler::demangleLiteralOperatorIdentifier(StringView &MangledName) {
   LiteralOperatorIdentifierNode *N =
       Arena.alloc<LiteralOperatorIdentifierNode>();
   N->Name = demangleSimpleString(MangledName, /*Memorize=*/false);
@@ -689,7 +684,7 @@ Demangler::translateIntrinsicFunctionCode(char CH,
 }
 
 IdentifierNode *
-Demangler::demangleFunctionIdentifierCode(std::string_view &MangledName,
+Demangler::demangleFunctionIdentifierCode(StringView &MangledName,
                                           FunctionIdentifierCodeGroup Group) {
   if (MangledName.empty()) {
     Error = true;
@@ -727,7 +722,7 @@ Demangler::demangleFunctionIdentifierCode(std::string_view &MangledName,
   DEMANGLE_UNREACHABLE;
 }
 
-SymbolNode *Demangler::demangleEncodedSymbol(std::string_view &MangledName,
+SymbolNode *Demangler::demangleEncodedSymbol(StringView &MangledName,
                                              QualifiedNameNode *Name) {
   if (MangledName.empty()) {
     Error = true;
@@ -757,7 +752,7 @@ SymbolNode *Demangler::demangleEncodedSymbol(std::string_view &MangledName,
   return FSN;
 }
 
-SymbolNode *Demangler::demangleDeclarator(std::string_view &MangledName) {
+SymbolNode *Demangler::demangleDeclarator(StringView &MangledName) {
   // What follows is a main symbol name. This may include namespaces or class
   // back references.
   QualifiedNameNode *QN = demangleFullyQualifiedSymbolName(MangledName);
@@ -781,17 +776,17 @@ SymbolNode *Demangler::demangleDeclarator(std::string_view &MangledName) {
   return Symbol;
 }
 
-SymbolNode *Demangler::demangleMD5Name(std::string_view &MangledName) {
-  assert(llvm::starts_with(MangledName, "??@"));
+SymbolNode *Demangler::demangleMD5Name(StringView &MangledName) {
+  assert(MangledName.startsWith("??@"));
   // This is an MD5 mangled name.  We can't demangle it, just return the
   // mangled name.
   // An MD5 mangled name is ??@ followed by 32 characters and a terminating @.
   size_t MD5Last = MangledName.find('@', strlen("??@"));
-  if (MD5Last == std::string_view::npos) {
+  if (MD5Last == StringView::npos) {
     Error = true;
     return nullptr;
   }
-  const char *Start = &*MangledName.begin();
+  const char *Start = MangledName.begin();
   MangledName.remove_prefix(MD5Last + 1);
 
   // There are two additional special cases for MD5 names:
@@ -806,15 +801,15 @@ SymbolNode *Demangler::demangleMD5Name(std::string_view &MangledName) {
   //    either.
   consumeFront(MangledName, "??_R4@");
 
-  std::string_view MD5(Start, MangledName.begin() - Start);
+  StringView MD5(Start, MangledName.begin() - Start);
   SymbolNode *S = Arena.alloc<SymbolNode>(NodeKind::Md5Symbol);
   S->Name = synthesizeQualifiedName(Arena, MD5);
 
   return S;
 }
 
-SymbolNode *Demangler::demangleTypeinfoName(std::string_view &MangledName) {
-  assert(llvm::starts_with(MangledName, '.'));
+SymbolNode *Demangler::demangleTypeinfoName(StringView &MangledName) {
+  assert(MangledName.startsWith('.'));
   consumeFront(MangledName, '.');
 
   TypeNode *T = demangleType(MangledName, QualifierMangleMode::Result);
@@ -826,18 +821,18 @@ SymbolNode *Demangler::demangleTypeinfoName(std::string_view &MangledName) {
 }
 
 // Parser entry point.
-SymbolNode *Demangler::parse(std::string_view &MangledName) {
+SymbolNode *Demangler::parse(StringView &MangledName) {
   // Typeinfo names are strings stored in RTTI data. They're not symbol names.
   // It's still useful to demangle them. They're the only demangled entity
   // that doesn't start with a "?" but a ".".
-  if (llvm::starts_with(MangledName, '.'))
+  if (MangledName.startsWith('.'))
     return demangleTypeinfoName(MangledName);
 
-  if (llvm::starts_with(MangledName, "??@"))
+  if (MangledName.startsWith("??@"))
     return demangleMD5Name(MangledName);
 
   // MSVC-style mangled symbols must start with '?'.
-  if (!llvm::starts_with(MangledName, '?')) {
+  if (!MangledName.startsWith('?')) {
     Error = true;
     return nullptr;
   }
@@ -852,7 +847,7 @@ SymbolNode *Demangler::parse(std::string_view &MangledName) {
   return demangleDeclarator(MangledName);
 }
 
-TagTypeNode *Demangler::parseTagUniqueName(std::string_view &MangledName) {
+TagTypeNode *Demangler::parseTagUniqueName(StringView &MangledName) {
   if (!consumeFront(MangledName, ".?A")) {
     Error = true;
     return nullptr;
@@ -873,9 +868,8 @@ TagTypeNode *Demangler::parseTagUniqueName(std::string_view &MangledName) {
 //                 ::= 3  # global
 //                 ::= 4  # static local
 
-VariableSymbolNode *
-Demangler::demangleVariableEncoding(std::string_view &MangledName,
-                                    StorageClass SC) {
+VariableSymbolNode *Demangler::demangleVariableEncoding(StringView &MangledName,
+                                                        StorageClass SC) {
   VariableSymbolNode *VSN = Arena.alloc<VariableSymbolNode>();
 
   VSN->Type = demangleType(MangledName, QualifierMangleMode::Drop);
@@ -925,8 +919,7 @@ Demangler::demangleVariableEncoding(std::string_view &MangledName,
 //                        ::= <hex digit>+ @  # when Number == 0 or >= 10
 //
 // <hex-digit>            ::= [A-P]           # A = 0, B = 1, ...
-std::pair<uint64_t, bool>
-Demangler::demangleNumber(std::string_view &MangledName) {
+std::pair<uint64_t, bool> Demangler::demangleNumber(StringView &MangledName) {
   bool IsNegative = consumeFront(MangledName, '?');
 
   if (startsWithDigit(MangledName)) {
@@ -953,7 +946,7 @@ Demangler::demangleNumber(std::string_view &MangledName) {
   return {0ULL, false};
 }
 
-uint64_t Demangler::demangleUnsigned(std::string_view &MangledName) {
+uint64_t Demangler::demangleUnsigned(StringView &MangledName) {
   bool IsNegative = false;
   uint64_t Number = 0;
   std::tie(Number, IsNegative) = demangleNumber(MangledName);
@@ -962,7 +955,7 @@ uint64_t Demangler::demangleUnsigned(std::string_view &MangledName) {
   return Number;
 }
 
-int64_t Demangler::demangleSigned(std::string_view &MangledName) {
+int64_t Demangler::demangleSigned(StringView &MangledName) {
   bool IsNegative = false;
   uint64_t Number = 0;
   std::tie(Number, IsNegative) = demangleNumber(MangledName);
@@ -974,7 +967,7 @@ int64_t Demangler::demangleSigned(std::string_view &MangledName) {
 
 // First 10 strings can be referenced by special BackReferences ?0, ?1, ..., ?9.
 // Memorize it.
-void Demangler::memorizeString(std::string_view S) {
+void Demangler::memorizeString(StringView S) {
   if (Backrefs.NamesCount >= BackrefContext::Max)
     return;
   for (size_t i = 0; i < Backrefs.NamesCount; ++i)
@@ -985,8 +978,7 @@ void Demangler::memorizeString(std::string_view S) {
   Backrefs.Names[Backrefs.NamesCount++] = N;
 }
 
-NamedIdentifierNode *
-Demangler::demangleBackRefName(std::string_view &MangledName) {
+NamedIdentifierNode *Demangler::demangleBackRefName(StringView &MangledName) {
   assert(startsWithDigit(MangledName));
 
   size_t I = MangledName[0] - '0';
@@ -1004,15 +996,15 @@ void Demangler::memorizeIdentifier(IdentifierNode *Identifier) {
   // memorize it for the purpose of back-referencing.
   OutputBuffer OB;
   Identifier->output(OB, OF_Default);
-  std::string_view Owned = copyString(OB);
+  StringView Owned = copyString(OB);
   memorizeString(Owned);
   std::free(OB.getBuffer());
 }
 
 IdentifierNode *
-Demangler::demangleTemplateInstantiationName(std::string_view &MangledName,
+Demangler::demangleTemplateInstantiationName(StringView &MangledName,
                                              NameBackrefBehavior NBB) {
-  assert(llvm::starts_with(MangledName, "?$"));
+  assert(MangledName.startsWith("?$"));
   consumeFront(MangledName, "?$");
 
   BackrefContext OuterContext;
@@ -1043,9 +1035,9 @@ Demangler::demangleTemplateInstantiationName(std::string_view &MangledName,
   return Identifier;
 }
 
-NamedIdentifierNode *Demangler::demangleSimpleName(std::string_view &MangledName,
+NamedIdentifierNode *Demangler::demangleSimpleName(StringView &MangledName,
                                                    bool Memorize) {
-  std::string_view S = demangleSimpleString(MangledName, Memorize);
+  StringView S = demangleSimpleString(MangledName, Memorize);
   if (Error)
     return nullptr;
 
@@ -1061,9 +1053,9 @@ static uint8_t rebasedHexDigitToNumber(char C) {
   return (C <= 'J') ? (C - 'A') : (10 + C - 'K');
 }
 
-uint8_t Demangler::demangleCharLiteral(std::string_view &MangledName) {
+uint8_t Demangler::demangleCharLiteral(StringView &MangledName) {
   assert(!MangledName.empty());
-  if (!llvm::starts_with(MangledName, '?')) {
+  if (!MangledName.startsWith('?')) {
     const uint8_t F = MangledName.front();
     MangledName.remove_prefix(1);
     return F;
@@ -1077,7 +1069,7 @@ uint8_t Demangler::demangleCharLiteral(std::string_view &MangledName) {
     // Two hex digits
     if (MangledName.size() < 2)
       goto CharLiteralError;
-    std::string_view Nibbles = MangledName.substr(0, 2);
+    StringView Nibbles = MangledName.substr(0, 2);
     if (!isRebasedHexDigit(Nibbles[0]) || !isRebasedHexDigit(Nibbles[1]))
       goto CharLiteralError;
     // Don't append the null terminator.
@@ -1119,7 +1111,7 @@ uint8_t Demangler::demangleCharLiteral(std::string_view &MangledName) {
   return '\0';
 }
 
-wchar_t Demangler::demangleWcharLiteral(std::string_view &MangledName) {
+wchar_t Demangler::demangleWcharLiteral(StringView &MangledName) {
   uint8_t C1, C2;
 
   C1 = demangleCharLiteral(MangledName);
@@ -1164,7 +1156,7 @@ static void outputHex(OutputBuffer &OB, unsigned C) {
   TempBuffer[Pos--] = 'x';
   assert(Pos >= 0);
   TempBuffer[Pos--] = '\\';
-  OB << std::string_view(&TempBuffer[Pos + 1]);
+  OB << StringView(&TempBuffer[Pos + 1]);
 }
 
 static void outputEscapedChar(OutputBuffer &OB, unsigned C) {
@@ -1286,8 +1278,7 @@ static unsigned decodeMultiByteChar(const uint8_t *StringBytes,
   return Result;
 }
 
-FunctionSymbolNode *
-Demangler::demangleVcallThunkNode(std::string_view &MangledName) {
+FunctionSymbolNode *Demangler::demangleVcallThunkNode(StringView &MangledName) {
   FunctionSymbolNode *FSN = Arena.alloc<FunctionSymbolNode>();
   VcallThunkIdentifierNode *VTIN = Arena.alloc<VcallThunkIdentifierNode>();
   FSN->Signature = Arena.alloc<ThunkSignatureNode>();
@@ -1306,10 +1297,10 @@ Demangler::demangleVcallThunkNode(std::string_view &MangledName) {
 }
 
 EncodedStringLiteralNode *
-Demangler::demangleStringLiteral(std::string_view &MangledName) {
+Demangler::demangleStringLiteral(StringView &MangledName) {
   // This function uses goto, so declare all variables up front.
   OutputBuffer OB;
-  std::string_view CRC;
+  StringView CRC;
   uint64_t StringByteSize;
   bool IsWcharT = false;
   bool IsNegative = false;
@@ -1344,7 +1335,7 @@ Demangler::demangleStringLiteral(std::string_view &MangledName) {
 
   // CRC 32 (always 8 characters plus a terminator)
   CrcEndPos = MangledName.find('@');
-  if (CrcEndPos == std::string_view::npos)
+  if (CrcEndPos == StringView::npos)
     goto StringLiteralError;
   CRC = MangledName.substr(0, CrcEndPos);
   MangledName.remove_prefix(CrcEndPos + 1);
@@ -1419,9 +1410,9 @@ Demangler::demangleStringLiteral(std::string_view &MangledName) {
 
 // Returns MangledName's prefix before the first '@', or an error if
 // MangledName contains no '@' or the prefix has length 0.
-std::string_view Demangler::demangleSimpleString(std::string_view &MangledName,
-                                                 bool Memorize) {
-  std::string_view S;
+StringView Demangler::demangleSimpleString(StringView &MangledName,
+                                           bool Memorize) {
+  StringView S;
   for (size_t i = 0; i < MangledName.size(); ++i) {
     if (MangledName[i] != '@')
       continue;
@@ -1440,25 +1431,25 @@ std::string_view Demangler::demangleSimpleString(std::string_view &MangledName,
 }
 
 NamedIdentifierNode *
-Demangler::demangleAnonymousNamespaceName(std::string_view &MangledName) {
-  assert(llvm::starts_with(MangledName, "?A"));
+Demangler::demangleAnonymousNamespaceName(StringView &MangledName) {
+  assert(MangledName.startsWith("?A"));
   consumeFront(MangledName, "?A");
 
   NamedIdentifierNode *Node = Arena.alloc<NamedIdentifierNode>();
   Node->Name = "`anonymous namespace'";
   size_t EndPos = MangledName.find('@');
-  if (EndPos == std::string_view::npos) {
+  if (EndPos == StringView::npos) {
     Error = true;
     return nullptr;
   }
-  std::string_view NamespaceKey = MangledName.substr(0, EndPos);
+  StringView NamespaceKey = MangledName.substr(0, EndPos);
   memorizeString(NamespaceKey);
   MangledName = MangledName.substr(EndPos + 1);
   return Node;
 }
 
 NamedIdentifierNode *
-Demangler::demangleLocallyScopedNamePiece(std::string_view &MangledName) {
+Demangler::demangleLocallyScopedNamePiece(StringView &MangledName) {
   assert(startsWithLocalScopePattern(MangledName));
 
   NamedIdentifierNode *Identifier = Arena.alloc<NamedIdentifierNode>();
@@ -1490,7 +1481,7 @@ Demangler::demangleLocallyScopedNamePiece(std::string_view &MangledName) {
 
 // Parses a type name in the form of A at B@C@@ which represents C::B::A.
 QualifiedNameNode *
-Demangler::demangleFullyQualifiedTypeName(std::string_view &MangledName) {
+Demangler::demangleFullyQualifiedTypeName(StringView &MangledName) {
   IdentifierNode *Identifier =
       demangleUnqualifiedTypeName(MangledName, /*Memorize=*/true);
   if (Error)
@@ -1508,7 +1499,7 @@ Demangler::demangleFullyQualifiedTypeName(std::string_view &MangledName) {
 // Symbol names have slightly 
diff erent rules regarding what can appear
 // so we separate out the implementations for flexibility.
 QualifiedNameNode *
-Demangler::demangleFullyQualifiedSymbolName(std::string_view &MangledName) {
+Demangler::demangleFullyQualifiedSymbolName(StringView &MangledName) {
   // This is the final component of a symbol name (i.e. the leftmost component
   // of a mangled name.  Since the only possible template instantiation that
   // can appear in this context is a function template, and since those are
@@ -1537,9 +1528,8 @@ Demangler::demangleFullyQualifiedSymbolName(std::string_view &MangledName) {
   return QN;
 }
 
-IdentifierNode *
-Demangler::demangleUnqualifiedTypeName(std::string_view &MangledName,
-                                       bool Memorize) {
+IdentifierNode *Demangler::demangleUnqualifiedTypeName(StringView &MangledName,
+                                                       bool Memorize) {
   // An inner-most name can be a back-reference, because a fully-qualified name
   // (e.g. Scope + Inner) can contain other fully qualified names inside of
   // them (for example template parameters), and these nested parameters can
@@ -1547,33 +1537,32 @@ Demangler::demangleUnqualifiedTypeName(std::string_view &MangledName,
   if (startsWithDigit(MangledName))
     return demangleBackRefName(MangledName);
 
-  if (llvm::starts_with(MangledName, "?$"))
+  if (MangledName.startsWith("?$"))
     return demangleTemplateInstantiationName(MangledName, NBB_Template);
 
   return demangleSimpleName(MangledName, Memorize);
 }
 
 IdentifierNode *
-Demangler::demangleUnqualifiedSymbolName(std::string_view &MangledName,
+Demangler::demangleUnqualifiedSymbolName(StringView &MangledName,
                                          NameBackrefBehavior NBB) {
   if (startsWithDigit(MangledName))
     return demangleBackRefName(MangledName);
-  if (llvm::starts_with(MangledName, "?$"))
+  if (MangledName.startsWith("?$"))
     return demangleTemplateInstantiationName(MangledName, NBB);
-  if (llvm::starts_with(MangledName, '?'))
+  if (MangledName.startsWith('?'))
     return demangleFunctionIdentifierCode(MangledName);
   return demangleSimpleName(MangledName, /*Memorize=*/(NBB & NBB_Simple) != 0);
 }
 
-IdentifierNode *
-Demangler::demangleNameScopePiece(std::string_view &MangledName) {
+IdentifierNode *Demangler::demangleNameScopePiece(StringView &MangledName) {
   if (startsWithDigit(MangledName))
     return demangleBackRefName(MangledName);
 
-  if (llvm::starts_with(MangledName, "?$"))
+  if (MangledName.startsWith("?$"))
     return demangleTemplateInstantiationName(MangledName, NBB_Template);
 
-  if (llvm::starts_with(MangledName, "?A"))
+  if (MangledName.startsWith("?A"))
     return demangleAnonymousNamespaceName(MangledName);
 
   if (startsWithLocalScopePattern(MangledName))
@@ -1595,7 +1584,7 @@ static NodeArrayNode *nodeListToNodeArray(ArenaAllocator &Arena, NodeList *Head,
 }
 
 QualifiedNameNode *
-Demangler::demangleNameScopeChain(std::string_view &MangledName,
+Demangler::demangleNameScopeChain(StringView &MangledName,
                                   IdentifierNode *UnqualifiedName) {
   NodeList *Head = Arena.alloc<NodeList>();
 
@@ -1626,7 +1615,7 @@ Demangler::demangleNameScopeChain(std::string_view &MangledName,
   return QN;
 }
 
-FuncClass Demangler::demangleFunctionClass(std::string_view &MangledName) {
+FuncClass Demangler::demangleFunctionClass(StringView &MangledName) {
   const char F = MangledName.front();
   MangledName.remove_prefix(1);
   switch (F) {
@@ -1713,7 +1702,7 @@ FuncClass Demangler::demangleFunctionClass(std::string_view &MangledName) {
   return FC_Public;
 }
 
-CallingConv Demangler::demangleCallingConvention(std::string_view &MangledName) {
+CallingConv Demangler::demangleCallingConvention(StringView &MangledName) {
   if (MangledName.empty()) {
     Error = true;
     return CallingConv::None;
@@ -1754,8 +1743,7 @@ CallingConv Demangler::demangleCallingConvention(std::string_view &MangledName)
   return CallingConv::None;
 }
 
-StorageClass
-Demangler::demangleVariableStorageClass(std::string_view &MangledName) {
+StorageClass Demangler::demangleVariableStorageClass(StringView &MangledName) {
   assert(MangledName.front() >= '0' && MangledName.front() <= '4');
 
   const char F = MangledName.front();
@@ -1776,7 +1764,7 @@ Demangler::demangleVariableStorageClass(std::string_view &MangledName) {
 }
 
 std::pair<Qualifiers, bool>
-Demangler::demangleQualifiers(std::string_view &MangledName) {
+Demangler::demangleQualifiers(StringView &MangledName) {
   if (MangledName.empty()) {
     Error = true;
     return std::make_pair(Q_None, false);
@@ -1810,7 +1798,7 @@ Demangler::demangleQualifiers(std::string_view &MangledName) {
 
 // <variable-type> ::= <type> <cvr-qualifiers>
 //                 ::= <type> <pointee-cvr-qualifiers> # pointers, references
-TypeNode *Demangler::demangleType(std::string_view &MangledName,
+TypeNode *Demangler::demangleType(StringView &MangledName,
                                   QualifierMangleMode QMM) {
   Qualifiers Quals = Q_None;
   bool IsMember = false;
@@ -1842,7 +1830,7 @@ TypeNode *Demangler::demangleType(std::string_view &MangledName,
     if (consumeFront(MangledName, "$$A8@@"))
       Ty = demangleFunctionType(MangledName, true);
     else {
-      assert(llvm::starts_with(MangledName, "$$A6"));
+      assert(MangledName.startsWith("$$A6"));
       consumeFront(MangledName, "$$A6");
       Ty = demangleFunctionType(MangledName, false);
     }
@@ -1858,7 +1846,7 @@ TypeNode *Demangler::demangleType(std::string_view &MangledName,
   return Ty;
 }
 
-bool Demangler::demangleThrowSpecification(std::string_view &MangledName) {
+bool Demangler::demangleThrowSpecification(StringView &MangledName) {
   if (consumeFront(MangledName, "_E"))
     return true;
   if (consumeFront(MangledName, 'Z'))
@@ -1868,9 +1856,8 @@ bool Demangler::demangleThrowSpecification(std::string_view &MangledName) {
   return false;
 }
 
-FunctionSignatureNode *
-Demangler::demangleFunctionType(std::string_view &MangledName,
-                                bool HasThisQuals) {
+FunctionSignatureNode *Demangler::demangleFunctionType(StringView &MangledName,
+                                                       bool HasThisQuals) {
   FunctionSignatureNode *FTy = Arena.alloc<FunctionSignatureNode>();
 
   if (HasThisQuals) {
@@ -1896,7 +1883,7 @@ Demangler::demangleFunctionType(std::string_view &MangledName,
 }
 
 FunctionSymbolNode *
-Demangler::demangleFunctionEncoding(std::string_view &MangledName) {
+Demangler::demangleFunctionEncoding(StringView &MangledName) {
   FuncClass ExtraFlags = FC_None;
   if (consumeFront(MangledName, "$$J0"))
     ExtraFlags = FC_ExternC;
@@ -1948,8 +1935,8 @@ Demangler::demangleFunctionEncoding(std::string_view &MangledName) {
   return Symbol;
 }
 
-CustomTypeNode *Demangler::demangleCustomType(std::string_view &MangledName) {
-  assert(llvm::starts_with(MangledName, '?'));
+CustomTypeNode *Demangler::demangleCustomType(StringView &MangledName) {
+  assert(MangledName.startsWith('?'));
   MangledName.remove_prefix(1);
 
   CustomTypeNode *CTN = Arena.alloc<CustomTypeNode>();
@@ -1962,8 +1949,7 @@ CustomTypeNode *Demangler::demangleCustomType(std::string_view &MangledName) {
 }
 
 // Reads a primitive type.
-PrimitiveTypeNode *
-Demangler::demanglePrimitiveType(std::string_view &MangledName) {
+PrimitiveTypeNode *Demangler::demanglePrimitiveType(StringView &MangledName) {
   if (consumeFront(MangledName, "$$T"))
     return Arena.alloc<PrimitiveTypeNode>(PrimitiveKind::Nullptr);
 
@@ -2026,7 +2012,7 @@ Demangler::demanglePrimitiveType(std::string_view &MangledName) {
   return nullptr;
 }
 
-TagTypeNode *Demangler::demangleClassType(std::string_view &MangledName) {
+TagTypeNode *Demangler::demangleClassType(StringView &MangledName) {
   TagTypeNode *TT = nullptr;
 
   const char F = MangledName.front();
@@ -2058,7 +2044,7 @@ TagTypeNode *Demangler::demangleClassType(std::string_view &MangledName) {
 
 // <pointer-type> ::= E? <pointer-cvr-qualifiers> <ext-qualifiers> <type>
 //                       # the E is required for 64-bit non-static pointers
-PointerTypeNode *Demangler::demanglePointerType(std::string_view &MangledName) {
+PointerTypeNode *Demangler::demanglePointerType(StringView &MangledName) {
   PointerTypeNode *Pointer = Arena.alloc<PointerTypeNode>();
 
   std::tie(Pointer->Quals, Pointer->Affinity) =
@@ -2076,8 +2062,7 @@ PointerTypeNode *Demangler::demanglePointerType(std::string_view &MangledName) {
   return Pointer;
 }
 
-PointerTypeNode *
-Demangler::demangleMemberPointerType(std::string_view &MangledName) {
+PointerTypeNode *Demangler::demangleMemberPointerType(StringView &MangledName) {
   PointerTypeNode *Pointer = Arena.alloc<PointerTypeNode>();
 
   std::tie(Pointer->Quals, Pointer->Affinity) =
@@ -2107,8 +2092,7 @@ Demangler::demangleMemberPointerType(std::string_view &MangledName) {
   return Pointer;
 }
 
-Qualifiers
-Demangler::demanglePointerExtQualifiers(std::string_view &MangledName) {
+Qualifiers Demangler::demanglePointerExtQualifiers(StringView &MangledName) {
   Qualifiers Quals = Q_None;
   if (consumeFront(MangledName, 'E'))
     Quals = Qualifiers(Quals | Q_Pointer64);
@@ -2120,7 +2104,7 @@ Demangler::demanglePointerExtQualifiers(std::string_view &MangledName) {
   return Quals;
 }
 
-ArrayTypeNode *Demangler::demangleArrayType(std::string_view &MangledName) {
+ArrayTypeNode *Demangler::demangleArrayType(StringView &MangledName) {
   assert(MangledName.front() == 'Y');
   MangledName.remove_prefix(1);
 
@@ -2165,9 +2149,8 @@ ArrayTypeNode *Demangler::demangleArrayType(std::string_view &MangledName) {
 }
 
 // Reads a function's parameters.
-NodeArrayNode *
-Demangler::demangleFunctionParameterList(std::string_view &MangledName,
-                                         bool &IsVariadic) {
+NodeArrayNode *Demangler::demangleFunctionParameterList(StringView &MangledName,
+                                                        bool &IsVariadic) {
   // Empty parameter list.
   if (consumeFront(MangledName, 'X'))
     return nullptr;
@@ -2175,8 +2158,8 @@ Demangler::demangleFunctionParameterList(std::string_view &MangledName,
   NodeList *Head = Arena.alloc<NodeList>();
   NodeList **Current = &Head;
   size_t Count = 0;
-  while (!Error && !llvm::starts_with(MangledName, '@') &&
-         !llvm::starts_with(MangledName, 'Z')) {
+  while (!Error && !MangledName.startsWith('@') &&
+         !MangledName.startsWith('Z')) {
     ++Count;
 
     if (startsWithDigit(MangledName)) {
@@ -2232,12 +2215,12 @@ Demangler::demangleFunctionParameterList(std::string_view &MangledName,
 }
 
 NodeArrayNode *
-Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
+Demangler::demangleTemplateParameterList(StringView &MangledName) {
   NodeList *Head = nullptr;
   NodeList **Current = &Head;
   size_t Count = 0;
 
-  while (!llvm::starts_with(MangledName, '@')) {
+  while (!MangledName.startsWith('@')) {
     if (consumeFront(MangledName, "$S") || consumeFront(MangledName, "$$V") ||
         consumeFront(MangledName, "$$$V") || consumeFront(MangledName, "$$Z")) {
       // parameter pack separator
@@ -2261,10 +2244,8 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
     } else if (consumeFront(MangledName, "$$C")) {
       // Type has qualifiers.
       TP.N = demangleType(MangledName, QualifierMangleMode::Mangle);
-    } else if (llvm::starts_with(MangledName, "$1") ||
-               llvm::starts_with(MangledName, "$H") ||
-               llvm::starts_with(MangledName, "$I") ||
-               llvm::starts_with(MangledName, "$J")) {
+    } else if (MangledName.startsWith("$1") || MangledName.startsWith("$H") ||
+               MangledName.startsWith("$I") || MangledName.startsWith("$J")) {
       // Pointer to member
       TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>();
       TPRN->IsMemberPointer = true;
@@ -2277,7 +2258,7 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
       char InheritanceSpecifier = MangledName.front();
       MangledName.remove_prefix(1);
       SymbolNode *S = nullptr;
-      if (llvm::starts_with(MangledName, '?')) {
+      if (MangledName.startsWith('?')) {
         S = parse(MangledName);
         if (Error || !S->Name) {
           Error = true;
@@ -2306,14 +2287,13 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
       }
       TPRN->Affinity = PointerAffinity::Pointer;
       TPRN->Symbol = S;
-    } else if (llvm::starts_with(MangledName, "$E?")) {
+    } else if (MangledName.startsWith("$E?")) {
       consumeFront(MangledName, "$E");
       // Reference to symbol
       TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>();
       TPRN->Symbol = parse(MangledName);
       TPRN->Affinity = PointerAffinity::Reference;
-    } else if (llvm::starts_with(MangledName, "$F") ||
-               llvm::starts_with(MangledName, "$G")) {
+    } else if (MangledName.startsWith("$F") || MangledName.startsWith("$G")) {
       TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>();
 
       // Data member pointer.
@@ -2358,8 +2338,7 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
 
   // Template parameter lists cannot be variadic, so it can only be terminated
   // by @ (as opposed to 'Z' in the function parameter case).
-  assert(
-      llvm::starts_with(MangledName, '@')); // The above loop exits only on '@'.
+  assert(MangledName.startsWith('@')); // The above loop exits only on '@'.
   consumeFront(MangledName, '@');
   return nodeListToNodeArray(Arena, Head, Count);
 }
@@ -2376,8 +2355,8 @@ void Demangler::dumpBackReferences() {
     TypeNode *T = Backrefs.FunctionParams[I];
     T->output(OB, OF_Default);
 
-    std::string_view B = OB;
-    std::printf("  [%d] - %.*s\n", (int)I, (int)B.size(), &*B.begin());
+    StringView B = OB;
+    std::printf("  [%d] - %.*s\n", (int)I, (int)B.size(), B.begin());
   }
   std::free(OB.getBuffer());
 
@@ -2386,7 +2365,7 @@ void Demangler::dumpBackReferences() {
   std::printf("%d name backreferences\n", (int)Backrefs.NamesCount);
   for (size_t I = 0; I < Backrefs.NamesCount; ++I) {
     std::printf("  [%d] - %.*s\n", (int)I, (int)Backrefs.Names[I]->Name.size(),
-                &*Backrefs.Names[I]->Name.begin());
+                Backrefs.Names[I]->Name.begin());
   }
   if (Backrefs.NamesCount > 0)
     std::printf("\n");
@@ -2397,10 +2376,10 @@ char *llvm::microsoftDemangle(const char *MangledName, size_t *NMangled,
                               int *Status, MSDemangleFlags Flags) {
   Demangler D;
 
-  std::string_view Name{MangledName};
+  StringView Name{MangledName};
   SymbolNode *AST = D.parse(Name);
   if (!D.Error && NMangled)
-    *NMangled = &*Name.begin() - MangledName;
+    *NMangled = Name.begin() - MangledName;
 
   if (Flags & MSDF_DumpBackrefs)
     D.dumpBackReferences();

diff  --git a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
index 9a9c34ec6d348..975649f28ad21 100644
--- a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
@@ -120,7 +120,7 @@ static void outputCallingConvention(OutputBuffer &OB, CallingConv CC) {
 std::string Node::toString(OutputFlags Flags) const {
   OutputBuffer OB;
   this->output(OB, Flags);
-  std::string_view SV = OB;
+  StringView SV = OB;
   std::string Owned(SV.begin(), SV.end());
   std::free(OB.getBuffer());
   return Owned;
@@ -158,7 +158,7 @@ void NodeArrayNode::output(OutputBuffer &OB, OutputFlags Flags) const {
 }
 
 void NodeArrayNode::output(OutputBuffer &OB, OutputFlags Flags,
-                           std::string_view Separator) const {
+                           StringView Separator) const {
   if (Count == 0)
     return;
   if (Nodes[0])

diff  --git a/llvm/lib/Demangle/RustDemangle.cpp b/llvm/lib/Demangle/RustDemangle.cpp
index 475e7e7482d2c..874f754941c74 100644
--- a/llvm/lib/Demangle/RustDemangle.cpp
+++ b/llvm/lib/Demangle/RustDemangle.cpp
@@ -11,8 +11,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/ADT/StringViewExtras.h"
 #include "llvm/Demangle/Demangle.h"
+#include "llvm/Demangle/StringView.h"
 #include "llvm/Demangle/Utility.h"
 
 #include <algorithm>
@@ -25,11 +25,12 @@ using namespace llvm;
 
 using llvm::itanium_demangle::OutputBuffer;
 using llvm::itanium_demangle::ScopedOverride;
+using llvm::itanium_demangle::StringView;
 
 namespace {
 
 struct Identifier {
-  std::string_view Name;
+  StringView Name;
   bool Punycode;
 
   bool empty() const { return Name.empty(); }
@@ -76,7 +77,7 @@ class Demangler {
   size_t RecursionLevel;
   size_t BoundLifetimes;
   // Input string that is being demangled with "_R" prefix removed.
-  std::string_view Input;
+  StringView Input;
   // Position in the input string.
   size_t Position;
   // When true, print methods append the output to the stream.
@@ -91,7 +92,7 @@ class Demangler {
 
   Demangler(size_t MaxRecursionLevel = 500);
 
-  bool demangle(std::string_view MangledName);
+  bool demangle(StringView MangledName);
 
 private:
   bool demanglePath(IsInType Type,
@@ -127,10 +128,10 @@ class Demangler {
   uint64_t parseOptionalBase62Number(char Tag);
   uint64_t parseBase62Number();
   uint64_t parseDecimalNumber();
-  uint64_t parseHexNumber(std::string_view &HexDigits);
+  uint64_t parseHexNumber(StringView &HexDigits);
 
   void print(char C);
-  void print(std::string_view S);
+  void print(StringView S);
   void printDecimalNumber(uint64_t N);
   void printBasicType(BasicType);
   void printLifetime(uint64_t Index);
@@ -151,8 +152,8 @@ char *llvm::rustDemangle(const char *MangledName) {
     return nullptr;
 
   // Return early if mangled name doesn't look like a Rust symbol.
-  std::string_view Mangled(MangledName);
-  if (!llvm::starts_with(Mangled, "_R"))
+  StringView Mangled(MangledName);
+  if (!Mangled.startsWith("_R"))
     return nullptr;
 
   Demangler D;
@@ -189,20 +190,20 @@ static inline bool isValid(const char C) {
 // responsibility of the caller to free the memory behind the output stream.
 //
 // <symbol-name> = "_R" <path> [<instantiating-crate>]
-bool Demangler::demangle(std::string_view Mangled) {
+bool Demangler::demangle(StringView Mangled) {
   Position = 0;
   Error = false;
   Print = true;
   RecursionLevel = 0;
   BoundLifetimes = 0;
 
-  if (!llvm::starts_with(Mangled, "_R")) {
+  if (!Mangled.startsWith("_R")) {
     Error = true;
     return false;
   }
   Mangled.remove_prefix(2);
   size_t Dot = Mangled.find('.');
-  Input = Dot == std::string_view::npos ? Mangled : Mangled.substr(0, Dot);
+  Input = Dot == StringView::npos ? Mangled : Mangled.substr(0, Dot);
 
   demanglePath(IsInType::No);
 
@@ -214,7 +215,7 @@ bool Demangler::demangle(std::string_view Mangled) {
   if (Position != Input.size())
     Error = true;
 
-  if (Dot != std::string_view::npos) {
+  if (Dot != StringView::npos) {
     print(" (");
     print(Mangled.substr(Dot));
     print(")");
@@ -774,7 +775,7 @@ void Demangler::demangleConstInt() {
   if (consumeIf('n'))
     print('-');
 
-  std::string_view HexDigits;
+  StringView HexDigits;
   uint64_t Value = parseHexNumber(HexDigits);
   if (HexDigits.size() <= 16) {
     printDecimalNumber(Value);
@@ -787,7 +788,7 @@ void Demangler::demangleConstInt() {
 // <const-data> = "0_" // false
 //              | "1_" // true
 void Demangler::demangleConstBool() {
-  std::string_view HexDigits;
+  StringView HexDigits;
   parseHexNumber(HexDigits);
   if (HexDigits == "0")
     print("false");
@@ -804,7 +805,7 @@ static bool isAsciiPrintable(uint64_t CodePoint) {
 
 // <const-data> = <hex-number>
 void Demangler::demangleConstChar() {
-  std::string_view HexDigits;
+  StringView HexDigits;
   uint64_t CodePoint = parseHexNumber(HexDigits);
   if (Error || HexDigits.size() > 6) {
     Error = true;
@@ -858,7 +859,7 @@ Identifier Demangler::parseIdentifier() {
     Error = true;
     return {};
   }
-  std::string_view S = Input.substr(Position, Bytes);
+  StringView S = Input.substr(Position, Bytes);
   Position += Bytes;
 
   if (!std::all_of(S.begin(), S.end(), isValid)) {
@@ -966,7 +967,7 @@ uint64_t Demangler::parseDecimalNumber() {
 //
 // <hex-number> = "0_"
 //              | <1-9a-f> {<0-9a-f>} "_"
-uint64_t Demangler::parseHexNumber(std::string_view &HexDigits) {
+uint64_t Demangler::parseHexNumber(StringView &HexDigits) {
   size_t Start = Position;
   uint64_t Value = 0;
 
@@ -990,7 +991,7 @@ uint64_t Demangler::parseHexNumber(std::string_view &HexDigits) {
   }
 
   if (Error) {
-    HexDigits = std::string_view();
+    HexDigits = StringView();
     return 0;
   }
 
@@ -1007,7 +1008,7 @@ void Demangler::print(char C) {
   Output += C;
 }
 
-void Demangler::print(std::string_view S) {
+void Demangler::print(StringView S) {
   if (Error || !Print)
     return;
 
@@ -1104,17 +1105,17 @@ static inline bool encodeUTF8(size_t CodePoint, char *Output) {
 
 // Decodes string encoded using punycode and appends results to Output.
 // Returns true if decoding was successful.
-static bool decodePunycode(std::string_view Input, OutputBuffer &Output) {
+static bool decodePunycode(StringView Input, OutputBuffer &Output) {
   size_t OutputSize = Output.getCurrentPosition();
   size_t InputIdx = 0;
 
   // Rust uses an underscore as a delimiter.
-  size_t DelimiterPos = std::string_view::npos;
+  size_t DelimiterPos = StringView::npos;
   for (size_t I = 0; I != Input.size(); ++I)
     if (Input[I] == '_')
       DelimiterPos = I;
 
-  if (DelimiterPos != std::string_view::npos) {
+  if (DelimiterPos != StringView::npos) {
     // Copy basic code points before the last delimiter to the output.
     for (; InputIdx != DelimiterPos; ++InputIdx) {
       char C = Input[InputIdx];
@@ -1122,7 +1123,7 @@ static bool decodePunycode(std::string_view Input, OutputBuffer &Output) {
         return false;
       // Code points are padded with zeros while decoding is in progress.
       char UTF8[4] = {C};
-      Output += std::string_view(UTF8, 4);
+      Output += StringView(UTF8, 4);
     }
     // Skip over the delimiter.
     ++InputIdx;

diff  --git a/llvm/lib/ProfileData/ItaniumManglingCanonicalizer.cpp b/llvm/lib/ProfileData/ItaniumManglingCanonicalizer.cpp
index fb9eab36decb7..22ec17fcafd14 100644
--- a/llvm/lib/ProfileData/ItaniumManglingCanonicalizer.cpp
+++ b/llvm/lib/ProfileData/ItaniumManglingCanonicalizer.cpp
@@ -17,12 +17,13 @@ using namespace llvm;
 using llvm::itanium_demangle::ForwardTemplateReference;
 using llvm::itanium_demangle::Node;
 using llvm::itanium_demangle::NodeKind;
+using llvm::itanium_demangle::StringView;
 
 namespace {
 struct FoldingSetNodeIDBuilder {
   llvm::FoldingSetNodeID &ID;
   void operator()(const Node *P) { ID.AddPointer(P); }
-  void operator()(std::string_view Str) {
+  void operator()(StringView Str) {
     ID.AddString(llvm::StringRef(Str.begin(), Str.size()));
   }
   template <typename T>
@@ -291,7 +292,7 @@ parseMaybeMangledName(CanonicalizingDemangler &Demangler, StringRef Mangling,
     N = Demangler.parse();
   else
     N = Demangler.make<itanium_demangle::NameType>(
-        std::string_view(Mangling.data(), Mangling.size()));
+        StringView(Mangling.data(), Mangling.size()));
   return reinterpret_cast<ItaniumManglingCanonicalizer::Key>(N);
 }
 

diff  --git a/llvm/unittests/Demangle/ItaniumDemangleTest.cpp b/llvm/unittests/Demangle/ItaniumDemangleTest.cpp
index bc6ccc2e16e65..c0db749539d86 100644
--- a/llvm/unittests/Demangle/ItaniumDemangleTest.cpp
+++ b/llvm/unittests/Demangle/ItaniumDemangleTest.cpp
@@ -11,7 +11,6 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include <cstdlib>
-#include <string_view>
 #include <vector>
 
 using namespace llvm;
@@ -84,7 +83,7 @@ TEST(ItaniumDemangle, MethodOverride) {
 }
 
 static std::string toString(OutputBuffer &OB) {
-  std::string_view SV = OB;
+  StringView SV = OB;
   return {SV.begin(), SV.end()};
 }
 
@@ -99,7 +98,7 @@ TEST(ItaniumDemangle, HalfType) {
       OutputBuffer OB;
       Node *N = AbstractManglingParser<TestParser, TestAllocator>::parseType();
       N->printLeft(OB);
-      std::string_view Name = N->getBaseName();
+      StringView Name = N->getBaseName();
       if (!Name.empty())
         Types.push_back(std::string(Name.begin(), Name.end()));
       else

diff  --git a/llvm/unittests/Demangle/OutputBufferTest.cpp b/llvm/unittests/Demangle/OutputBufferTest.cpp
index 76031e523d781..829169ba61754 100644
--- a/llvm/unittests/Demangle/OutputBufferTest.cpp
+++ b/llvm/unittests/Demangle/OutputBufferTest.cpp
@@ -10,13 +10,12 @@
 #include "llvm/Demangle/Utility.h"
 #include "gtest/gtest.h"
 #include <string>
-#include <string_view>
 
 using namespace llvm;
 using llvm::itanium_demangle::OutputBuffer;
 
 static std::string toString(OutputBuffer &OB) {
-  std::string_view SV = OB;
+  StringView SV = OB;
   return {SV.begin(), SV.end()};
 }
 


        


More information about the lldb-commits mailing list