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 @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -2350,7 +2351,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); } } }; @@ -2478,7 +2479,8 @@ } bool consumeIf(StringView S) { - if (StringView(First, Last).startsWith(S)) { + size_t n = std::distance(First, Last); + if (StringView(First, n).startsWith(S)) { First += S.size(); return true; } @@ -2934,7 +2936,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)"); @@ -3471,7 +3473,8 @@ return StringView(); while (numLeft() != 0 && std::isdigit(*First)) ++First; - return StringView(Tmp, First); + size_t n = std::distance(Tmp, First); + return StringView(Tmp, n); } // ::= [0-9]* @@ -3492,7 +3495,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; } @@ -5144,7 +5147,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; @@ -5464,7 +5467,8 @@ if (Encoding == nullptr) return nullptr; if (look() == '.') { - Encoding = make(Encoding, StringView(First, Last)); + size_t n = std::distance(First, Last); + Encoding = make(Encoding, StringView(First, n)); 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 @@ -19,6 +19,7 @@ #include "DemangleConfig.h" #include #include +#include DEMANGLE_NAMESPACE_BEGIN @@ -31,8 +32,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)) {} @@ -58,7 +57,8 @@ StringView dropFront(size_t N = 1) const { if (N >= size()) N = size(); - return StringView(First + N, Last); + size_t n = std::distance(First + N, Last); + return StringView(First + N, n); } void remove_prefix(size_t N) { 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.size())); } 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,8 @@ // either. MangledName.consumeFront("??_R4@"); - StringView MD5(Start, MangledName.begin()); + size_t n = std::distance(Start, MangledName.begin()); + StringView MD5(Start, n); 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;