diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h --- a/llvm/include/llvm/Demangle/ItaniumDemangle.h +++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h @@ -2349,7 +2349,7 @@ #endif char num[FloatData::max_demangled_size] = {0}; int n = snprintf(num, sizeof(num), FloatData::spec, value); - OB += StringView(num, num + n); + OB += StringView(num, n); } } }; @@ -2477,7 +2477,7 @@ } bool consumeIf(StringView S) { - if (StringView(First, Last).startsWith(S)) { + if (StringView(First, Last - First).startsWith(S)) { First += S.size(); return true; } @@ -2933,7 +2933,7 @@ return nullptr; if (numLeft() < Length || Length == 0) return nullptr; - StringView Name(First, First + Length); + StringView Name(First, Length); First += Length; if (Name.startsWith("_GLOBAL__N")) return make("(anonymous namespace)"); @@ -3470,7 +3470,7 @@ return StringView(); while (numLeft() != 0 && std::isdigit(*First)) ++First; - return StringView(Tmp, First); + return StringView(Tmp, First - Tmp); } // ::= [0-9]* @@ -3491,7 +3491,7 @@ size_t Int = 0; if (parsePositiveInteger(&Int) || numLeft() < Int) return StringView(); - StringView R(First, First + Int); + StringView R(First, Int); First += Int; return R; } @@ -5143,7 +5143,7 @@ const size_t N = FloatData::mangled_size; if (numLeft() <= N) return nullptr; - StringView Data(First, First + N); + StringView Data(First, N); for (char C : Data) if (!std::isxdigit(C)) return nullptr; @@ -5463,7 +5463,7 @@ if (Encoding == nullptr) return nullptr; if (look() == '.') { - Encoding = make(Encoding, StringView(First, Last)); + Encoding = make(Encoding, StringView(First, Last - First)); First = Last; } if (numLeft() != 0) diff --git a/llvm/include/llvm/Demangle/StringView.h b/llvm/include/llvm/Demangle/StringView.h --- a/llvm/include/llvm/Demangle/StringView.h +++ b/llvm/include/llvm/Demangle/StringView.h @@ -31,8 +31,6 @@ template StringView(const char (&Str)[N]) : First(Str), Last(Str + N - 1) {} - StringView(const char *First_, const char *Last_) - : First(First_), Last(Last_) {} StringView(const char *First_, size_t Len) : First(First_), Last(First_ + Len) {} StringView(const char *Str) : First(Str), Last(Str + std::strlen(Str)) {} diff --git a/llvm/include/llvm/Demangle/Utility.h b/llvm/include/llvm/Demangle/Utility.h --- a/llvm/include/llvm/Demangle/Utility.h +++ b/llvm/include/llvm/Demangle/Utility.h @@ -64,7 +64,7 @@ if (isNeg) *--TempPtr = '-'; - return operator+=(StringView(TempPtr, Temp.data() + Temp.size())); + return operator+=(StringView(TempPtr, Temp.data() + Temp.size() - TempPtr)); } public: diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp --- a/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -779,7 +779,7 @@ // either. MangledName.consumeFront("??_R4@"); - StringView MD5(Start, MangledName.begin()); + StringView MD5(Start, MangledName.begin() - Start); SymbolNode *S = Arena.alloc(NodeKind::Md5Symbol); S->Name = synthesizeQualifiedName(Arena, MD5); diff --git a/llvm/lib/Demangle/RustDemangle.cpp b/llvm/lib/Demangle/RustDemangle.cpp --- a/llvm/lib/Demangle/RustDemangle.cpp +++ b/llvm/lib/Demangle/RustDemangle.cpp @@ -1122,7 +1122,7 @@ return false; // Code points are padded with zeros while decoding is in progress. char UTF8[4] = {C}; - Output += StringView(UTF8, UTF8 + 4); + Output += StringView(UTF8, 4); } // Skip over the delimiter. ++InputIdx;