1
0
mirror of synced 2025-01-10 21:41:53 +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
#include <cstddef>
#include <optional>
#include <string>
#include <string_view>
@ -32,7 +33,7 @@ enum : int {
/// Returns a non-NULL pointer to a NUL-terminated C style string
/// that should be explicitly freed, if successful. Otherwise, may return
/// 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 {
MSDF_None = 0,
@ -54,6 +55,9 @@ enum MSDemangleFlags {
char *microsoftDemangle(std::string_view mangled_name, size_t *n_read,
int *status, MSDemangleFlags Flags = MSDF_None);
std::optional<size_t>
getArm64ECInsertionPointInMangledName(std::string_view MangledName);
// Demangles a Rust v0 mangled symbol.
char *rustDemangle(std::string_view MangledName);
@ -67,7 +71,9 @@ char *dlangDemangle(std::string_view MangledName);
/// demangling occurred.
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
/// (typically an intermediate stage in itaniumDemangle) and querying certain
@ -102,7 +108,7 @@ struct ItaniumPartialDemangler {
char *getFunctionParameters(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.
bool hasFunctionQualifiers() const;

View File

@ -86,6 +86,11 @@
#define DEMANGLE_FALLTHROUGH
#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_END } }

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -9,6 +9,7 @@
#ifndef LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
#define LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
#include "llvm/Demangle/Demangle.h"
#include "llvm/Demangle/MicrosoftDemangleNodes.h"
#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) {
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 also has a set of functions to convert Type instances to strings.
class Demangler {
friend std::optional<size_t>
llvm::getArm64ECInsertionPointInMangledName(std::string_view MangledName);
public:
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.
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
changes you made to libcxxabi over. Note that this script just
blindly overwrites all changes to the generic library in llvm, so be

View File

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

View File

@ -24,7 +24,8 @@ std::string llvm::demangle(std::string_view MangledName) {
return Result;
if (starts_with(MangledName, '_') &&
nonMicrosoftDemangle(MangledName.substr(1), Result))
nonMicrosoftDemangle(MangledName.substr(1), Result,
/*CanHaveLeadingDot=*/false))
return Result;
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"); }
bool llvm::nonMicrosoftDemangle(std::string_view MangledName,
std::string &Result) {
std::string &Result, bool CanHaveLeadingDot,
bool ParseParams) {
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))
Demangled = itaniumDemangle(MangledName);
Demangled = itaniumDemangle(MangledName, ParseParams);
else if (isRustEncoding(MangledName))
Demangled = rustDemangle(MangledName);
else if (isDLangEncoding(MangledName))
@ -58,7 +67,7 @@ bool llvm::nonMicrosoftDemangle(std::string_view MangledName,
if (!Demangled)
return false;
Result = Demangled;
Result += Demangled;
std::free(Demangled);
return true;
}

View File

@ -366,13 +366,13 @@ public:
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())
return nullptr;
Demangler Parser(MangledName.data(),
MangledName.data() + MangledName.length());
Node *AST = Parser.parse();
Node *AST = Parser.parse(ParseParams);
if (!AST)
return nullptr;

View File

@ -24,6 +24,7 @@
#include <array>
#include <cctype>
#include <cstdio>
#include <optional>
#include <string_view>
#include <tuple>
@ -53,6 +54,18 @@ static bool consumeFront(std::string_view &S, std::string_view C) {
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) {
Error = false;
const char F = MangledName.front();
@ -2256,6 +2269,18 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
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;
if (consumeFront(MangledName, "$$Y")) {
// Template alias
@ -2266,15 +2291,17 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
} else if (consumeFront(MangledName, "$$C")) {
// Type has qualifiers.
TP.N = demangleType(MangledName, QualifierMangleMode::Mangle);
} else if (llvm::itanium_demangle::starts_with(MangledName, "$1") ||
llvm::itanium_demangle::starts_with(MangledName, "$H") ||
llvm::itanium_demangle::starts_with(MangledName, "$I") ||
llvm::itanium_demangle::starts_with(MangledName, "$J")) {
} else if (startsWith(MangledName, "$1", "1", !IsAutoNTTP) ||
startsWith(MangledName, "$H", "H", !IsAutoNTTP) ||
startsWith(MangledName, "$I", "I", !IsAutoNTTP) ||
startsWith(MangledName, "$J", "J", !IsAutoNTTP)) {
// Pointer to member
TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>();
TPRN->IsMemberPointer = true;
MangledName.remove_prefix(1);
if (!IsAutoNTTP)
MangledName.remove_prefix(1); // Remove leading '$'
// 1 - single inheritance <name>
// H - multiple inheritance <name> <number>
// I - virtual inheritance <name> <number> <number>
@ -2317,12 +2344,13 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>();
TPRN->Symbol = parse(MangledName);
TPRN->Affinity = PointerAffinity::Reference;
} else if (llvm::itanium_demangle::starts_with(MangledName, "$F") ||
llvm::itanium_demangle::starts_with(MangledName, "$G")) {
} else if (startsWith(MangledName, "$F", "F", !IsAutoNTTP) ||
startsWith(MangledName, "$G", "G", !IsAutoNTTP)) {
TP.N = TPRN = Arena.alloc<TemplateParameterReferenceNode>();
// Data member pointer.
MangledName.remove_prefix(1);
if (!IsAutoNTTP)
MangledName.remove_prefix(1); // Remove leading '$'
char InheritanceSpecifier = MangledName.front();
MangledName.remove_prefix(1);
@ -2342,7 +2370,7 @@ Demangler::demangleTemplateParameterList(std::string_view &MangledName) {
}
TPRN->IsMemberPointer = true;
} else if (consumeFront(MangledName, "$0")) {
} else if (consumeFront(MangledName, "$0", "0", !IsAutoNTTP)) {
// Integral non-type template parameter
bool IsNegative = false;
uint64_t Value = 0;
@ -2397,6 +2425,24 @@ void Demangler::dumpBackReferences() {
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,
int *Status, MSDemangleFlags Flags) {
Demangler D;

File diff suppressed because it is too large Load Diff