1
0
mirror of synced 2025-01-11 05:42:15 +01:00

build: Updated more dependencies

This commit is contained in:
WerWolv 2024-12-26 14:41:43 +01:00
parent 72d9c5019c
commit f11205bba7
11 changed files with 2595 additions and 1064 deletions

View File

@ -10,6 +10,7 @@
#define LLVM_DEMANGLE_DEMANGLE_H #define LLVM_DEMANGLE_DEMANGLE_H
#include <cstddef> #include <cstddef>
#include <optional>
#include <string> #include <string>
#include <string_view> #include <string_view>
@ -32,7 +33,7 @@ enum : int {
/// Returns a non-NULL pointer to a NUL-terminated C style string /// Returns a non-NULL pointer to a NUL-terminated C style string
/// that should be explicitly freed, if successful. Otherwise, may return /// that should be explicitly freed, if successful. Otherwise, may return
/// nullptr if mangled_name is not a valid mangling or is nullptr. /// nullptr if mangled_name is not a valid mangling or is nullptr.
char *itaniumDemangle(std::string_view mangled_name); char *itaniumDemangle(std::string_view mangled_name, bool ParseParams = true);
enum MSDemangleFlags { enum MSDemangleFlags {
MSDF_None = 0, MSDF_None = 0,
@ -54,6 +55,9 @@ enum MSDemangleFlags {
char *microsoftDemangle(std::string_view mangled_name, size_t *n_read, char *microsoftDemangle(std::string_view mangled_name, size_t *n_read,
int *status, MSDemangleFlags Flags = MSDF_None); int *status, MSDemangleFlags Flags = MSDF_None);
std::optional<size_t>
getArm64ECInsertionPointInMangledName(std::string_view MangledName);
// Demangles a Rust v0 mangled symbol. // Demangles a Rust v0 mangled symbol.
char *rustDemangle(std::string_view MangledName); char *rustDemangle(std::string_view MangledName);
@ -67,7 +71,9 @@ char *dlangDemangle(std::string_view MangledName);
/// demangling occurred. /// demangling occurred.
std::string demangle(std::string_view MangledName); std::string demangle(std::string_view MangledName);
bool nonMicrosoftDemangle(std::string_view MangledName, std::string &Result); bool nonMicrosoftDemangle(std::string_view MangledName, std::string &Result,
bool CanHaveLeadingDot = true,
bool ParseParams = true);
/// "Partial" demangler. This supports demangling a string into an AST /// "Partial" demangler. This supports demangling a string into an AST
/// (typically an intermediate stage in itaniumDemangle) and querying certain /// (typically an intermediate stage in itaniumDemangle) and querying certain
@ -102,7 +108,7 @@ struct ItaniumPartialDemangler {
char *getFunctionParameters(char *Buf, size_t *N) const; char *getFunctionParameters(char *Buf, size_t *N) const;
char *getFunctionReturnType(char *Buf, size_t *N) const; char *getFunctionReturnType(char *Buf, size_t *N) const;
/// If this function has any any cv or reference qualifiers. These imply that /// If this function has any cv or reference qualifiers. These imply that
/// the function is a non-static member function. /// the function is a non-static member function.
bool hasFunctionQualifiers() const; bool hasFunctionQualifiers() const;

View File

@ -86,6 +86,11 @@
#define DEMANGLE_FALLTHROUGH #define DEMANGLE_FALLTHROUGH
#endif #endif
#ifndef DEMANGLE_ASSERT
#include <cassert>
#define DEMANGLE_ASSERT(__expr, __msg) assert((__expr) && (__msg))
#endif
#define DEMANGLE_NAMESPACE_BEGIN namespace llvm { namespace itanium_demangle { #define DEMANGLE_NAMESPACE_BEGIN namespace llvm { namespace itanium_demangle {
#define DEMANGLE_NAMESPACE_END } } #define DEMANGLE_NAMESPACE_END } }

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,7 @@ NODE(QualType)
NODE(ConversionOperatorType) NODE(ConversionOperatorType)
NODE(PostfixQualifiedType) NODE(PostfixQualifiedType)
NODE(ElaboratedTypeSpefType) NODE(ElaboratedTypeSpefType)
NODE(TransformedType)
NODE(NameType) NODE(NameType)
NODE(AbiTagAttr) NODE(AbiTagAttr)
NODE(EnableIfAttr) NODE(EnableIfAttr)
@ -36,6 +37,7 @@ NODE(SpecialName)
NODE(CtorVtableSpecialName) NODE(CtorVtableSpecialName)
NODE(QualifiedName) NODE(QualifiedName)
NODE(NestedName) NODE(NestedName)
NODE(MemberLikeFriendName)
NODE(LocalName) NODE(LocalName)
NODE(ModuleName) NODE(ModuleName)
NODE(ModuleEntity) NODE(ModuleEntity)
@ -44,7 +46,9 @@ NODE(PixelVectorType)
NODE(BinaryFPType) NODE(BinaryFPType)
NODE(BitIntType) NODE(BitIntType)
NODE(SyntheticTemplateParamName) NODE(SyntheticTemplateParamName)
NODE(TemplateParamQualifiedArg)
NODE(TypeTemplateParamDecl) NODE(TypeTemplateParamDecl)
NODE(ConstrainedTypeTemplateParamDecl)
NODE(NonTypeTemplateParamDecl) NODE(NonTypeTemplateParamDecl)
NODE(TemplateTemplateParamDecl) NODE(TemplateTemplateParamDecl)
NODE(TemplateParamPackDecl) NODE(TemplateParamPackDecl)
@ -91,5 +95,10 @@ NODE(DoubleLiteral)
NODE(LongDoubleLiteral) NODE(LongDoubleLiteral)
NODE(BracedExpr) NODE(BracedExpr)
NODE(BracedRangeExpr) NODE(BracedRangeExpr)
NODE(RequiresExpr)
NODE(ExprRequirement)
NODE(TypeRequirement)
NODE(NestedRequirement)
NODE(ExplicitObjectParameter)
#undef NODE #undef NODE

View File

@ -9,6 +9,7 @@
#ifndef LLVM_DEMANGLE_MICROSOFTDEMANGLE_H #ifndef LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
#define LLVM_DEMANGLE_MICROSOFTDEMANGLE_H #define LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
#include "llvm/Demangle/Demangle.h"
#include "llvm/Demangle/MicrosoftDemangleNodes.h" #include "llvm/Demangle/MicrosoftDemangleNodes.h"
#include <cassert> #include <cassert>
@ -54,6 +55,10 @@ public:
} }
} }
// Delete the copy constructor and the copy assignment operator.
ArenaAllocator(const ArenaAllocator &) = delete;
ArenaAllocator &operator=(const ArenaAllocator &) = delete;
char *allocUnalignedBuffer(size_t Size) { char *allocUnalignedBuffer(size_t Size) {
assert(Head && Head->Buf); assert(Head && Head->Buf);
@ -137,6 +142,9 @@ enum class FunctionIdentifierCodeGroup { Basic, Under, DoubleUnder };
// It has a set of functions to parse mangled symbols into Type instances. // It has a set of functions to parse mangled symbols into Type instances.
// It also has a set of functions to convert Type instances to strings. // It also has a set of functions to convert Type instances to strings.
class Demangler { class Demangler {
friend std::optional<size_t>
llvm::getArm64ECInsertionPointInMangledName(std::string_view MangledName);
public: public:
Demangler() = default; Demangler() = default;
virtual ~Demangler() = default; virtual ~Demangler() = default;

View File

@ -34,7 +34,7 @@ differences, we want to keep the "core" generic demangling library
identical between both copies to simplify development and testing. identical between both copies to simplify development and testing.
If you're working on the generic library, then do the work first in If you're working on the generic library, then do the work first in
libcxxabi, then run the cp-to-llvm.sh script in src/demangle. This libcxxabi, then run libcxxabi/src/demangle/cp-to-llvm.sh. This
script takes as an optional argument the path to llvm, and copies the script takes as an optional argument the path to llvm, and copies the
changes you made to libcxxabi over. Note that this script just changes you made to libcxxabi over. Note that this script just
blindly overwrites all changes to the generic library in llvm, so be blindly overwrites all changes to the generic library in llvm, so be

View File

@ -19,11 +19,9 @@
#include "DemangleConfig.h" #include "DemangleConfig.h"
#include <array> #include <array>
#include <cassert>
#include <cstdint> #include <cstdint>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <exception>
#include <limits> #include <limits>
#include <string_view> #include <string_view>
@ -49,7 +47,7 @@ class OutputBuffer {
BufferCapacity = Need; BufferCapacity = Need;
Buffer = static_cast<char *>(std::realloc(Buffer, BufferCapacity)); Buffer = static_cast<char *>(std::realloc(Buffer, BufferCapacity));
if (Buffer == nullptr) if (Buffer == nullptr)
std::terminate(); std::abort();
} }
} }
@ -160,7 +158,7 @@ public:
} }
void insert(size_t Pos, const char *S, size_t N) { void insert(size_t Pos, const char *S, size_t N) {
assert(Pos <= CurrentPosition); DEMANGLE_ASSERT(Pos <= CurrentPosition, "");
if (N == 0) if (N == 0)
return; return;
grow(N); grow(N);
@ -173,7 +171,7 @@ public:
void setCurrentPosition(size_t NewPos) { CurrentPosition = NewPos; } void setCurrentPosition(size_t NewPos) { CurrentPosition = NewPos; }
char back() const { char back() const {
assert(CurrentPosition); DEMANGLE_ASSERT(CurrentPosition, "");
return Buffer[CurrentPosition - 1]; return Buffer[CurrentPosition - 1];
} }

View File

@ -24,7 +24,8 @@ std::string llvm::demangle(std::string_view MangledName) {
return Result; return Result;
if (starts_with(MangledName, '_') && if (starts_with(MangledName, '_') &&
nonMicrosoftDemangle(MangledName.substr(1), Result)) nonMicrosoftDemangle(MangledName.substr(1), Result,
/*CanHaveLeadingDot=*/false))
return Result; return Result;
if (char *Demangled = microsoftDemangle(MangledName, nullptr, nullptr)) { if (char *Demangled = microsoftDemangle(MangledName, nullptr, nullptr)) {
@ -46,10 +47,18 @@ static bool isRustEncoding(std::string_view S) { return starts_with(S, "_R"); }
static bool isDLangEncoding(std::string_view S) { return starts_with(S, "_D"); } static bool isDLangEncoding(std::string_view S) { return starts_with(S, "_D"); }
bool llvm::nonMicrosoftDemangle(std::string_view MangledName, bool llvm::nonMicrosoftDemangle(std::string_view MangledName,
std::string &Result) { std::string &Result, bool CanHaveLeadingDot,
bool ParseParams) {
char *Demangled = nullptr; char *Demangled = nullptr;
// Do not consider the dot prefix as part of the demangled symbol name.
if (CanHaveLeadingDot && MangledName.size() > 0 && MangledName[0] == '.') {
MangledName.remove_prefix(1);
Result = ".";
}
if (isItaniumEncoding(MangledName)) if (isItaniumEncoding(MangledName))
Demangled = itaniumDemangle(MangledName); Demangled = itaniumDemangle(MangledName, ParseParams);
else if (isRustEncoding(MangledName)) else if (isRustEncoding(MangledName))
Demangled = rustDemangle(MangledName); Demangled = rustDemangle(MangledName);
else if (isDLangEncoding(MangledName)) else if (isDLangEncoding(MangledName))
@ -58,7 +67,7 @@ bool llvm::nonMicrosoftDemangle(std::string_view MangledName,
if (!Demangled) if (!Demangled)
return false; return false;
Result = Demangled; Result += Demangled;
std::free(Demangled); std::free(Demangled);
return true; return true;
} }

View File

@ -366,13 +366,13 @@ public:
using Demangler = itanium_demangle::ManglingParser<DefaultAllocator>; using Demangler = itanium_demangle::ManglingParser<DefaultAllocator>;
char *llvm::itaniumDemangle(std::string_view MangledName) { char *llvm::itaniumDemangle(std::string_view MangledName, bool ParseParams) {
if (MangledName.empty()) if (MangledName.empty())
return nullptr; return nullptr;
Demangler Parser(MangledName.data(), Demangler Parser(MangledName.data(),
MangledName.data() + MangledName.length()); MangledName.data() + MangledName.length());
Node *AST = Parser.parse(); Node *AST = Parser.parse(ParseParams);
if (!AST) if (!AST)
return nullptr; return nullptr;

View File

@ -24,6 +24,7 @@
#include <array> #include <array>
#include <cctype> #include <cctype>
#include <cstdio> #include <cstdio>
#include <optional>
#include <string_view> #include <string_view>
#include <tuple> #include <tuple>
@ -53,6 +54,18 @@ static bool consumeFront(std::string_view &S, std::string_view C) {
return true; return true;
} }
static bool consumeFront(std::string_view &S, std::string_view PrefixA,
std::string_view PrefixB, bool A) {
const std::string_view &Prefix = A ? PrefixA : PrefixB;
return consumeFront(S, Prefix);
}
static bool startsWith(std::string_view S, std::string_view PrefixA,
std::string_view PrefixB, bool A) {
const std::string_view &Prefix = A ? PrefixA : PrefixB;
return llvm::itanium_demangle::starts_with(S, Prefix);
}
static bool isMemberPointer(std::string_view MangledName, bool &Error) { static bool isMemberPointer(std::string_view MangledName, bool &Error) {
Error = false; Error = false;
const char F = MangledName.front(); const char F = MangledName.front();
@ -2256,6 +2269,18 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
NodeList &TP = **Current; NodeList &TP = **Current;
// <auto-nttp> ::= $ M <type> <nttp>
const bool IsAutoNTTP = consumeFront(MangledName, "$M");
if (IsAutoNTTP) {
// The deduced type of the auto NTTP parameter isn't printed so
// we want to ignore the AST created from demangling the type.
//
// TODO: Avoid the extra allocations to the bump allocator in this case.
(void)demangleType(MangledName, QualifierMangleMode::Drop);
if (Error)
return nullptr;
}
TemplateParameterReferenceNode *TPRN = nullptr; TemplateParameterReferenceNode *TPRN = nullptr;
if (consumeFront(MangledName, "$$Y")) { if (consumeFront(MangledName, "$$Y")) {
// Template alias // Template alias
@ -2266,15 +2291,17 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
} else if (consumeFront(MangledName, "$$C")) { } else if (consumeFront(MangledName, "$$C")) {
// Type has qualifiers. // Type has qualifiers.
TP.N = demangleType(MangledName, QualifierMangleMode::Mangle); TP.N = demangleType(MangledName, QualifierMangleMode::Mangle);
} else if (llvm::itanium_demangle::starts_with(MangledName, "$1") || } else if (startsWith(MangledName, "$1", "1", !IsAutoNTTP) ||
llvm::itanium_demangle::starts_with(MangledName, "$H") || startsWith(MangledName, "$H", "H", !IsAutoNTTP) ||
llvm::itanium_demangle::starts_with(MangledName, "$I") || startsWith(MangledName, "$I", "I", !IsAutoNTTP) ||
llvm::itanium_demangle::starts_with(MangledName, "$J")) { startsWith(MangledName, "$J", "J", !IsAutoNTTP)) {
// Pointer to member // Pointer to member
TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>(); TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>();
TPRN->IsMemberPointer = true; TPRN->IsMemberPointer = true;
MangledName.remove_prefix(1); if (!IsAutoNTTP)
MangledName.remove_prefix(1); // Remove leading '$'
// 1 - single inheritance <name> // 1 - single inheritance <name>
// H - multiple inheritance <name> <number> // H - multiple inheritance <name> <number>
// I - virtual inheritance <name> <number> <number> // I - virtual inheritance <name> <number> <number>
@ -2317,12 +2344,13 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>(); TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>();
TPRN->Symbol = parse(MangledName); TPRN->Symbol = parse(MangledName);
TPRN->Affinity = PointerAffinity::Reference; TPRN->Affinity = PointerAffinity::Reference;
} else if (llvm::itanium_demangle::starts_with(MangledName, "$F") || } else if (startsWith(MangledName, "$F", "F", !IsAutoNTTP) ||
llvm::itanium_demangle::starts_with(MangledName, "$G")) { startsWith(MangledName, "$G", "G", !IsAutoNTTP)) {
TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>(); TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>();
// Data member pointer. // Data member pointer.
MangledName.remove_prefix(1); if (!IsAutoNTTP)
MangledName.remove_prefix(1); // Remove leading '$'
char InheritanceSpecifier = MangledName.front(); char InheritanceSpecifier = MangledName.front();
MangledName.remove_prefix(1); MangledName.remove_prefix(1);
@ -2342,7 +2370,7 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
} }
TPRN->IsMemberPointer = true; TPRN->IsMemberPointer = true;
} else if (consumeFront(MangledName, "$0")) { } else if (consumeFront(MangledName, "$0", "0", !IsAutoNTTP)) {
// Integral non-type template parameter // Integral non-type template parameter
bool IsNegative = false; bool IsNegative = false;
uint64_t Value = 0; uint64_t Value = 0;
@ -2397,6 +2425,24 @@ void Demangler::dumpBackReferences() {
std::printf("\n"); std::printf("\n");
} }
std::optional<size_t>
llvm::getArm64ECInsertionPointInMangledName(std::string_view MangledName) {
std::string_view ProcessedName{MangledName};
// We only support this for MSVC-style C++ symbols.
if (!consumeFront(ProcessedName, '?'))
return std::nullopt;
// The insertion point is just after the name of the symbol, so parse that to
// remove it from the processed name.
Demangler D;
D.demangleFullyQualifiedSymbolName(ProcessedName);
if (D.Error)
return std::nullopt;
return MangledName.length() - ProcessedName.length();
}
char *llvm::microsoftDemangle(std::string_view MangledName, size_t *NMangled, char *llvm::microsoftDemangle(std::string_view MangledName, size_t *NMangled,
int *Status, MSDemangleFlags Flags) { int *Status, MSDemangleFlags Flags) {
Demangler D; Demangler D;

File diff suppressed because it is too large Load Diff