[llvm] 0f9f03a - [StringView] remove ctor incompatible with std::string_view
Nick Desaulniers via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 14 11:16:38 PDT 2023
Author: Nick Desaulniers
Date: 2023-04-14T11:16:11-07:00
New Revision: 0f9f03afca76240cc419d86e6651534e9aa502e0
URL: https://github.com/llvm/llvm-project/commit/0f9f03afca76240cc419d86e6651534e9aa502e0
DIFF: https://github.com/llvm/llvm-project/commit/0f9f03afca76240cc419d86e6651534e9aa502e0.diff
LOG: [StringView] remove ctor incompatible with std::string_view
Towards replacing llvm::StringView with std::string_view, remove ctor
that std::string_view doesn't have an analog for.
Reviewed By: erichkeane, MaskRay
Differential Revision: https://reviews.llvm.org/D148353
Added:
Modified:
llvm/include/llvm/Demangle/ItaniumDemangle.h
llvm/include/llvm/Demangle/StringView.h
llvm/include/llvm/Demangle/Utility.h
llvm/lib/Demangle/MicrosoftDemangle.cpp
llvm/lib/Demangle/RustDemangle.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 15760cc3e717..1a55195f50b8 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -2349,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 += StringView(num, num + n);
+ OB += StringView(num, n);
}
}
};
@@ -2477,7 +2477,7 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
}
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 @@ Node *AbstractManglingParser<Derived, Alloc>::parseSourceName(NameState *) {
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<NameType>("(anonymous namespace)");
@@ -3470,7 +3470,7 @@ AbstractManglingParser<Alloc, Derived>::parseNumber(bool AllowNegative) {
return StringView();
while (numLeft() != 0 && std::isdigit(*First))
++First;
- return StringView(Tmp, First);
+ return StringView(Tmp, First - Tmp);
}
// <positive length number> ::= [0-9]*
@@ -3491,7 +3491,7 @@ StringView AbstractManglingParser<Alloc, Derived>::parseBareSourceName() {
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 @@ Node *AbstractManglingParser<Alloc, Derived>::parseFloatingLiteral() {
const size_t N = FloatData<Float>::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 @@ Node *AbstractManglingParser<Derived, Alloc>::parse() {
if (Encoding == nullptr)
return nullptr;
if (look() == '.') {
- Encoding = make<DotSuffix>(Encoding, StringView(First, Last));
+ Encoding = make<DotSuffix>(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
index 51d9e25cd8ab..f653fa5957e3 100644
--- a/llvm/include/llvm/Demangle/StringView.h
+++ b/llvm/include/llvm/Demangle/StringView.h
@@ -31,8 +31,6 @@ class StringView {
template <size_t N>
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
index 855c56e9df32..248d410f0640 100644
--- a/llvm/include/llvm/Demangle/Utility.h
+++ b/llvm/include/llvm/Demangle/Utility.h
@@ -64,7 +64,7 @@ class OutputBuffer {
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
index 4230deaeaa96..68ae41a346b0 100644
--- a/llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -779,7 +779,7 @@ SymbolNode *Demangler::demangleMD5Name(StringView &MangledName) {
// either.
MangledName.consumeFront("??_R4@");
- StringView MD5(Start, MangledName.begin());
+ StringView MD5(Start, MangledName.begin() - Start);
SymbolNode *S = Arena.alloc<SymbolNode>(NodeKind::Md5Symbol);
S->Name = synthesizeQualifiedName(Arena, MD5);
diff --git a/llvm/lib/Demangle/RustDemangle.cpp b/llvm/lib/Demangle/RustDemangle.cpp
index 0063f415ff8b..ba9f941bdb14 100644
--- a/llvm/lib/Demangle/RustDemangle.cpp
+++ b/llvm/lib/Demangle/RustDemangle.cpp
@@ -1122,7 +1122,7 @@ static bool decodePunycode(StringView Input, OutputBuffer &Output) {
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;
More information about the llvm-commits
mailing list