forked from OSchip/llvm-project
[demangler] Resync demangler sources
Recent commits changed llvm/include/llvm/Demangle without also changing libcxxabi/src/Demangle, which is the canonical source location. This resyncs those commits to the libcxxabi directory. Commits: *1f9e18b656
*f53d359816
*065044c443
Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D117990.diff
This commit is contained in:
parent
853e79d8d8
commit
38ffea9b4c
|
@ -21,12 +21,13 @@
|
||||||
#include "DemangleConfig.h"
|
#include "DemangleConfig.h"
|
||||||
#include "StringView.h"
|
#include "StringView.h"
|
||||||
#include "Utility.h"
|
#include "Utility.h"
|
||||||
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <numeric>
|
#include <limits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#define FOR_EACH_NODE_KIND(X) \
|
#define FOR_EACH_NODE_KIND(X) \
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#define DEMANGLE_STRINGVIEW_H
|
#define DEMANGLE_STRINGVIEW_H
|
||||||
|
|
||||||
#include "DemangleConfig.h"
|
#include "DemangleConfig.h"
|
||||||
#include <algorithm>
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
@ -38,15 +37,16 @@ public:
|
||||||
|
|
||||||
StringView substr(size_t Pos, size_t Len = npos) const {
|
StringView substr(size_t Pos, size_t Len = npos) const {
|
||||||
assert(Pos <= size());
|
assert(Pos <= size());
|
||||||
return StringView(begin() + Pos, std::min(Len, size() - Pos));
|
if (Len > size() - Pos)
|
||||||
|
Len = size() - Pos;
|
||||||
|
return StringView(begin() + Pos, Len);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t find(char C, size_t From = 0) const {
|
size_t find(char C, size_t From = 0) const {
|
||||||
size_t FindBegin = std::min(From, size());
|
|
||||||
// Avoid calling memchr with nullptr.
|
// Avoid calling memchr with nullptr.
|
||||||
if (FindBegin < size()) {
|
if (From < size()) {
|
||||||
// Just forward to memchr, which is faster than a hand-rolled loop.
|
// Just forward to memchr, which is faster than a hand-rolled loop.
|
||||||
if (const void *P = ::memchr(First + FindBegin, C, size() - FindBegin))
|
if (const void *P = ::memchr(First + From, C, size() - From))
|
||||||
return size_t(static_cast<const char *>(P) - First);
|
return size_t(static_cast<const char *>(P) - First);
|
||||||
}
|
}
|
||||||
return npos;
|
return npos;
|
||||||
|
@ -98,7 +98,7 @@ public:
|
||||||
bool startsWith(StringView Str) const {
|
bool startsWith(StringView Str) const {
|
||||||
if (Str.size() > size())
|
if (Str.size() > size())
|
||||||
return false;
|
return false;
|
||||||
return std::equal(Str.begin(), Str.end(), begin());
|
return std::strncmp(Str.begin(), begin(), Str.size()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char &operator[](size_t Idx) const { return *(begin() + Idx); }
|
const char &operator[](size_t Idx) const { return *(begin() + Idx); }
|
||||||
|
@ -111,7 +111,7 @@ public:
|
||||||
|
|
||||||
inline bool operator==(const StringView &LHS, const StringView &RHS) {
|
inline bool operator==(const StringView &LHS, const StringView &RHS) {
|
||||||
return LHS.size() == RHS.size() &&
|
return LHS.size() == RHS.size() &&
|
||||||
std::equal(LHS.begin(), LHS.end(), RHS.begin());
|
std::strncmp(LHS.begin(), RHS.begin(), LHS.size()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEMANGLE_NAMESPACE_END
|
DEMANGLE_NAMESPACE_END
|
||||||
|
|
|
@ -14,10 +14,11 @@
|
||||||
#define DEMANGLE_UTILITY_H
|
#define DEMANGLE_UTILITY_H
|
||||||
|
|
||||||
#include "StringView.h"
|
#include "StringView.h"
|
||||||
|
#include <array>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iterator>
|
#include <exception>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
DEMANGLE_NAMESPACE_BEGIN
|
DEMANGLE_NAMESPACE_BEGIN
|
||||||
|
@ -48,8 +49,8 @@ class OutputBuffer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char Temp[21];
|
std::array<char, 21> Temp;
|
||||||
char *TempPtr = std::end(Temp);
|
char *TempPtr = Temp.data() + Temp.size();
|
||||||
|
|
||||||
while (N) {
|
while (N) {
|
||||||
*--TempPtr = char('0' + N % 10);
|
*--TempPtr = char('0' + N % 10);
|
||||||
|
@ -59,7 +60,7 @@ class OutputBuffer {
|
||||||
// Add negative sign...
|
// Add negative sign...
|
||||||
if (isNeg)
|
if (isNeg)
|
||||||
*--TempPtr = '-';
|
*--TempPtr = '-';
|
||||||
this->operator<<(StringView(TempPtr, std::end(Temp)));
|
this->operator<<(StringView(TempPtr, Temp.data() + Temp.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue