diff --git a/.gitignore b/.gitignore index a816f6bf6..8f442e243 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.build/ build/* KSCrash/build/* *.pbxuser diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 000000000..9725c77d8 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "swift-demangler", + "kind" : "remoteSourceControl", + "location" : "https://github.com/embrace-io/swift-demangler.git", + "state" : { + "branch" : "main", + "revision" : "602376930d19d1f21ef6501dceede8b1143ab9f9" + } + } + ], + "version" : 2 +} diff --git a/Package.swift b/Package.swift index 2b04eb7bf..e33544d09 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.1 +// swift-tools-version:5.7 import PackageDescription @@ -15,12 +15,15 @@ let package = Package( "KSCrash/Reporting/Filters", "KSCrash/Reporting/Filters/Tools", "KSCrash/Reporting/Tools", - "KSCrash/Reporting/Sinks", - "KSCrash/swift/Basic" + "KSCrash/Reporting/Sinks" ] ) ], dependencies: [ + .package( + url: "https://github.com/embrace-io/swift-demangler.git", + branch: "main" + ), ], targets: [ .target( @@ -63,6 +66,9 @@ let package = Package( ), .target( name: "KSCrash/Recording/Tools", + dependencies: [ + .product(name: "AppleSwiftDemangling", package: "swift-demangler") + ], path: "Source/KSCrash/Recording/Tools", publicHeadersPath: ".", cxxSettings: [ @@ -117,17 +123,6 @@ let package = Package( .headerSearchPath("../../Recording/Tools"), .headerSearchPath("../../Recording/Monitors") ] - ), - .target( - name: "KSCrash/swift/Basic", - path: "Source/KSCrash/swift/Basic", - publicHeadersPath: ".", - cxxSettings: [ - .headerSearchPath(".."), - .headerSearchPath("../../llvm/ADT"), - .headerSearchPath("../../llvm/Config"), - .headerSearchPath("../../llvm/Support") - ] ) ], cxxLanguageStandard: .gnucxx11 diff --git a/Source/KSCrash/Recording/Tools/KSDemangle_Swift.cpp b/Source/KSCrash/Recording/Tools/KSDemangle_Swift.cpp index 12f3f5b29..1af76466f 100644 --- a/Source/KSCrash/Recording/Tools/KSDemangle_Swift.cpp +++ b/Source/KSCrash/Recording/Tools/KSDemangle_Swift.cpp @@ -25,16 +25,10 @@ // -#include "Demangle.h" #include "KSDemangle_Swift.h" +#include "DemangleService.h" extern "C" char* ksdm_demangleSwift(const char* mangledSymbol) { - swift::Demangle::DemangleOptions options = swift::Demangle::DemangleOptions::SimplifiedUIDemangleOptions(); - std::string demangled = swift::Demangle::demangleSymbolAsString(mangledSymbol, options); - if(demangled.length() == 0) - { - return NULL; - } - return strdup(demangled.c_str()); + return demangleSymbol(mangledSymbol); } diff --git a/Source/KSCrash/swift/Basic/Context.cpp b/Source/KSCrash/swift/Basic/Context.cpp deleted file mode 100644 index 6f8d71af5..000000000 --- a/Source/KSCrash/swift/Basic/Context.cpp +++ /dev/null @@ -1,195 +0,0 @@ -//===--- Context.cpp - Demangler Context ----------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file implements the demangler Context. -// -//===----------------------------------------------------------------------===// - -#include "Demangler.h" -#include "ManglingMacros.h" - -namespace swift { - namespace Demangle { - - ////////////////////////////////// - // Context member functions // - ////////////////////////////////// - - Context::Context() : D(new Demangler) { - } - - Context::~Context() { - delete D; - } - - void Context::clear() { - D->clear(); - } - - NodePointer Context::demangleSymbolAsNode(llvm::StringRef MangledName) { - if (isMangledName(MangledName)) { - return D->demangleSymbol(MangledName); - } - return demangleOldSymbolAsNode(MangledName, *D); - } - - NodePointer Context::demangleTypeAsNode(llvm::StringRef MangledName) { - return D->demangleType(MangledName); - } - - std::string Context::demangleSymbolAsString(llvm::StringRef MangledName, - const DemangleOptions &Options) { - NodePointer root = demangleSymbolAsNode(MangledName); - if (!root) return MangledName.str(); - - std::string demangling = nodeToString(root, Options); - if (demangling.empty()) - return MangledName.str(); - return demangling; - } - - std::string Context::demangleTypeAsString(llvm::StringRef MangledName, - const DemangleOptions &Options) { - NodePointer root = demangleTypeAsNode(MangledName); - if (!root) return MangledName.str(); - - std::string demangling = nodeToString(root, Options); - if (demangling.empty()) - return MangledName.str(); - return demangling; - } - - bool Context::isThunkSymbol(llvm::StringRef MangledName) { - if (isMangledName(MangledName)) { - // First do a quick check - if (MangledName.endswith("TA") || // partial application forwarder - MangledName.endswith("Ta") || // ObjC partial application forwarder - MangledName.endswith("To") || // swift-as-ObjC thunk - MangledName.endswith("TO") || // ObjC-as-swift thunk - MangledName.endswith("TR") || // reabstraction thunk helper function - MangledName.endswith("Tr") || // reabstraction thunk - MangledName.endswith("TW") || // protocol witness thunk - MangledName.endswith("fC")) { // allocating constructor - - // To avoid false positives, we need to fully demangle the symbol. - NodePointer Nd = D->demangleSymbol(MangledName); - if (!Nd || Nd->getKind() != Node::Kind::Global || - Nd->getNumChildren() == 0) - return false; - - switch (Nd->getFirstChild()->getKind()) { - case Node::Kind::ObjCAttribute: - case Node::Kind::NonObjCAttribute: - case Node::Kind::PartialApplyObjCForwarder: - case Node::Kind::PartialApplyForwarder: - case Node::Kind::ReabstractionThunkHelper: - case Node::Kind::ReabstractionThunk: - case Node::Kind::ProtocolWitness: - case Node::Kind::Allocator: - return true; - default: - break; - } - } - return false; - } - - if (MangledName.startswith("_T")) { - // Old mangling. - StringRef Remaining = MangledName.substr(2); - if (Remaining.startswith("To") || // swift-as-ObjC thunk - Remaining.startswith("TO") || // ObjC-as-swift thunk - Remaining.startswith("PA_") || // partial application forwarder - Remaining.startswith("PAo_")) { // ObjC partial application forwarder - return true; - } - } - return false; - } - - std::string Context::getThunkTarget(llvm::StringRef MangledName) { - if (!isThunkSymbol(MangledName)) - return std::string(); - - if (isMangledName(MangledName)) { - // The targets of those thunks not derivable from the mangling. - if (MangledName.endswith("TR") || - MangledName.endswith("Tr") || - MangledName.endswith("TW") ) - return std::string(); - - if (MangledName.endswith("fC")) { - std::string target = MangledName.str(); - target[target.size() - 1] = 'c'; - return target; - } - - return MangledName.substr(0, MangledName.size() - 2).str(); - } - // Old mangling. - assert(MangledName.startswith("_T")); - StringRef Remaining = MangledName.substr(2); - if (Remaining.startswith("PA_")) - return Remaining.substr(3).str(); - if (Remaining.startswith("PAo_")) - return Remaining.substr(4).str(); - assert(Remaining.startswith("To") || Remaining.startswith("TO")); - return std::string("_T") + Remaining.substr(2).str(); - } - - bool Context::hasSwiftCallingConvention(llvm::StringRef MangledName) { - Node *Global = demangleSymbolAsNode(MangledName); - if (!Global || Global->getKind() != Node::Kind::Global || - Global->getNumChildren() == 0) - return false; - - Node *TopLevel = Global->getFirstChild(); - switch (TopLevel->getKind()) { - // Functions, which don't have the swift calling conventions: - case Node::Kind::TypeMetadataAccessFunction: - case Node::Kind::ValueWitness: - case Node::Kind::ProtocolWitnessTableAccessor: - case Node::Kind::GenericProtocolWitnessTableInstantiationFunction: - case Node::Kind::LazyProtocolWitnessTableAccessor: - case Node::Kind::AssociatedTypeMetadataAccessor: - case Node::Kind::AssociatedTypeWitnessTableAccessor: - case Node::Kind::BaseWitnessTableAccessor: - case Node::Kind::ObjCAttribute: - return false; - default: - break; - } - return true; - } - - ////////////////////////////////// - // Public utility functions // - ////////////////////////////////// - - std::string demangleSymbolAsString(const char *MangledName, - size_t MangledNameLength, - const DemangleOptions &Options) { - Context Ctx; - return Ctx.demangleSymbolAsString(StringRef(MangledName, MangledNameLength), - Options); - } - - std::string demangleTypeAsString(const char *MangledName, - size_t MangledNameLength, - const DemangleOptions &Options) { - Context Ctx; - return Ctx.demangleTypeAsString(StringRef(MangledName, MangledNameLength), - Options); - } - - } // namespace Demangle -} // namespace swift diff --git a/Source/KSCrash/swift/Basic/Demangle.cpp b/Source/KSCrash/swift/Basic/Demangle.cpp deleted file mode 100644 index b99f509dd..000000000 --- a/Source/KSCrash/swift/Basic/Demangle.cpp +++ /dev/null @@ -1,71 +0,0 @@ -//===--- SwiftDemangle.cpp - Public demangling interface ------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// Functions in the libswiftDemangle library, which provides external -// access to Swift's demangler. -// -//===----------------------------------------------------------------------===// - -#include "Demangle.h" -#include "SwiftDemangle.h" - -static size_t swift_demangle_getDemangledName_Options(const char *MangledName, - char *OutputBuffer, size_t Length, - swift::Demangle::DemangleOptions DemangleOptions) { - assert(MangledName != nullptr && "null input"); - assert(OutputBuffer != nullptr || Length == 0); - - if (!swift::Demangle::isSwiftSymbol(MangledName)) - return 0; // Not a mangled name - - std::string Result = swift::Demangle::demangleSymbolAsString( - llvm::StringRef(MangledName), DemangleOptions); - - if (Result == MangledName) - return 0; // Not a mangled name - - // Copy the result to an output buffer and ensure '\0' termination. - if (OutputBuffer && Length > 0) { - auto Dest = strncpy(OutputBuffer, Result.c_str(), Length); - Dest[Length - 1] = '\0'; - } - return Result.length(); -} - -size_t swift_demangle_getDemangledName(const char *MangledName, - char *OutputBuffer, - size_t Length) { - swift::Demangle::DemangleOptions DemangleOptions; - DemangleOptions.SynthesizeSugarOnTypes = true; - return swift_demangle_getDemangledName_Options(MangledName, OutputBuffer, - Length, DemangleOptions); -} - -size_t swift_demangle_getSimplifiedDemangledName(const char *MangledName, - char *OutputBuffer, - size_t Length) { - auto Opts = swift::Demangle::DemangleOptions::SimplifiedUIDemangleOptions(); - return swift_demangle_getDemangledName_Options(MangledName, OutputBuffer, - Length, Opts); -} - -int swift_demangle_hasSwiftCallingConvention(const char *MangledName) { - swift::Demangle::Context DCtx; - if (DCtx.hasSwiftCallingConvention(llvm::StringRef(MangledName))) - return 1; - return 0; -} - -size_t fnd_get_demangled_name(const char *MangledName, char *OutputBuffer, - size_t Length) { - return swift_demangle_getDemangledName(MangledName, OutputBuffer, Length); -} diff --git a/Source/KSCrash/swift/Basic/Demangle.h b/Source/KSCrash/swift/Basic/Demangle.h deleted file mode 100644 index 5c28d3efd..000000000 --- a/Source/KSCrash/swift/Basic/Demangle.h +++ /dev/null @@ -1,608 +0,0 @@ -//===--- Demangle.h - Interface to Swift symbol demangling ------*- C++ -*-===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file is the public API of the demangler library. -// Tools which use the demangler library (like lldb) must include this - and -// only this - header file. -// -//===----------------------------------------------------------------------===// - -#ifndef SWIFT_DEMANGLING_DEMANGLE_H -#define SWIFT_DEMANGLING_DEMANGLE_H - -#include -#include -#include -#include -#include -#include "StringRef.h" -#include "Config.h" - -namespace llvm { - class raw_ostream; -} - -namespace swift { - namespace Demangle { - - enum class SymbolicReferenceKind : uint8_t; - - struct DemangleOptions { - bool SynthesizeSugarOnTypes = false; - bool DisplayDebuggerGeneratedModule = true; - bool QualifyEntities = true; - bool DisplayExtensionContexts = true; - bool DisplayUnmangledSuffix = true; - bool DisplayModuleNames = true; - bool DisplayGenericSpecializations = true; - bool DisplayProtocolConformances = true; - bool DisplayWhereClauses = true; - bool DisplayEntityTypes = true; - bool ShortenPartialApply = false; - bool ShortenThunk = false; - bool ShortenValueWitness = false; - bool ShortenArchetype = false; - bool ShowPrivateDiscriminators = true; - bool ShowFunctionArgumentTypes = true; - - DemangleOptions() {} - - static DemangleOptions SimplifiedUIDemangleOptions() { - auto Opt = DemangleOptions(); - Opt.SynthesizeSugarOnTypes = true; - Opt.QualifyEntities = true; - Opt.DisplayExtensionContexts = false; - Opt.DisplayUnmangledSuffix = false; - Opt.DisplayModuleNames = false; - Opt.DisplayGenericSpecializations = false; - Opt.DisplayProtocolConformances = false; - Opt.DisplayWhereClauses = false; - Opt.DisplayEntityTypes = false; - Opt.ShortenPartialApply = true; - Opt.ShortenThunk = true; - Opt.ShortenValueWitness = true; - Opt.ShortenArchetype = true; - Opt.ShowPrivateDiscriminators = false; - Opt.ShowFunctionArgumentTypes = false; - return Opt; - }; - }; - - class Node; - using NodePointer = Node *; - - enum class FunctionSigSpecializationParamKind : unsigned { - // Option Flags use bits 0-5. This give us 6 bits implying 64 entries to - // work with. - ConstantPropFunction = 0, - ConstantPropGlobal = 1, - ConstantPropInteger = 2, - ConstantPropFloat = 3, - ConstantPropString = 4, - ClosureProp = 5, - BoxToValue = 6, - BoxToStack = 7, - - // Option Set Flags use bits 6-31. This gives us 26 bits to use for option - // flags. - Dead = 1 << 6, - OwnedToGuaranteed = 1 << 7, - SROA = 1 << 8, - GuaranteedToOwned = 1 << 9, - ExistentialToGeneric = 1 << 10, - }; - - /// The pass that caused the specialization to occur. We use this to make sure - /// that two passes that generate similar changes do not yield the same - /// mangling. This currently cannot happen, so this is just a safety measure - /// that creates separate name spaces. - enum class SpecializationPass : uint8_t { - AllocBoxToStack, - ClosureSpecializer, - CapturePromotion, - CapturePropagation, - FunctionSignatureOpts, - GenericSpecializer, - }; - - static inline char encodeSpecializationPass(SpecializationPass Pass) { - return char(uint8_t(Pass)) + '0'; - } - - enum class ValueWitnessKind { -#define VALUE_WITNESS(MANGLING, NAME) \ -NAME, -#include "ValueWitnessMangling.def" - }; - - enum class Directness { - Direct, Indirect - }; - - class NodeFactory; - class Context; - - class Node { - public: - enum class Kind : uint16_t { -#define NODE(ID) ID, -#include "DemangleNodes.def" - }; - - using IndexType = uint64_t; - - friend class NodeFactory; - - private: - Kind NodeKind; - - enum class PayloadKind : uint8_t { - None, Text, Index - }; - PayloadKind NodePayloadKind; - - union { - llvm::StringRef TextPayload; - IndexType IndexPayload; - }; - - NodePointer *Children = nullptr; - size_t NumChildren = 0; - size_t ReservedChildren = 0; - - Node(Kind k) - : NodeKind(k), NodePayloadKind(PayloadKind::None) { - } - Node(Kind k, llvm::StringRef t) - : NodeKind(k), NodePayloadKind(PayloadKind::Text) { - TextPayload = t; - } - Node(Kind k, IndexType index) - : NodeKind(k), NodePayloadKind(PayloadKind::Index) { - IndexPayload = index; - } - Node(const Node &) = delete; - Node &operator=(const Node &) = delete; - - public: - Kind getKind() const { return NodeKind; } - - bool hasText() const { return NodePayloadKind == PayloadKind::Text; } - llvm::StringRef getText() const { - assert(hasText()); - return TextPayload; - } - - bool hasIndex() const { return NodePayloadKind == PayloadKind::Index; } - uint64_t getIndex() const { - assert(hasIndex()); - return IndexPayload; - } - - using iterator = NodePointer *; - using const_iterator = const NodePointer *; - using size_type = size_t; - - bool hasChildren() const { return NumChildren != 0; } - size_t getNumChildren() const { return NumChildren; } - iterator begin() { return Children; } - iterator end() { return Children + NumChildren; } - const_iterator begin() const { return Children; } - const_iterator end() const { return Children + NumChildren; } - - NodePointer getFirstChild() const { - assert(NumChildren >= 1); - return Children[0]; - } - NodePointer getChild(size_t index) const { - assert(NumChildren > index); - return Children[index]; - } - - // inline void addChild(NodePointer Child, Context &Ctx); - - // Only to be used by the demangler parsers. - void addChild(NodePointer Child, NodeFactory &Factory); - // Only to be used by the demangler parsers. - void removeChildAt(unsigned Pos, NodeFactory &factory); - - // Reverses the order of children. - void reverseChildren(size_t StartingAt = 0); - - /// Prints the whole node tree in readable form to stderr. - /// - /// Useful to be called from the debugger. - void dump(); - }; - - /// Returns the length of the swift mangling prefix of the \p SymbolName. - /// - /// Returns 0 if \p SymbolName is not a mangled swift (>= swift 4.x) name. - int getManglingPrefixLength(llvm::StringRef mangledName); - - /// Returns true if \p SymbolName is a mangled swift name. - /// - /// This does not include the old (<= swift 3.x) mangling prefix "_T". - inline bool isMangledName(llvm::StringRef mangledName) { - return getManglingPrefixLength(mangledName) != 0; - } - - /// Returns true if the mangledName starts with the swift mangling prefix. - /// - /// This includes the old (<= swift 3.x) mangling prefix "_T". - bool isSwiftSymbol(llvm::StringRef mangledName); - - /// Returns true if the mangledName starts with the swift mangling prefix. - /// - /// This includes the old (<= swift 3.x) mangling prefix "_T". - bool isSwiftSymbol(const char *mangledName); - - /// Drops the Swift mangling prefix from the given mangled name, if there is - /// one. - /// - /// This does not include the old (<= swift 3.x) mangling prefix "_T". - llvm::StringRef dropSwiftManglingPrefix(llvm::StringRef mangledName); - - /// Returns true if the mangled name is an alias type name. - /// - /// \param mangledName A null-terminated string containing a mangled name. - bool isAlias(llvm::StringRef mangledName); - - /// Returns true if the mangled name is a class type name. - /// - /// \param mangledName A null-terminated string containing a mangled name. - bool isClass(llvm::StringRef mangledName); - - /// Returns true if the mangled name is an enum type name. - /// - /// \param mangledName A null-terminated string containing a mangled name. - bool isEnum(llvm::StringRef mangledName); - - /// Returns true if the mangled name is a protocol type name. - /// - /// \param mangledName A null-terminated string containing a mangled name. - bool isProtocol(llvm::StringRef mangledName); - - /// Returns true if the mangled name is a structure type name. - /// - /// \param mangledName A null-terminated string containing a mangled name. - bool isStruct(llvm::StringRef mangledName); - - /// Returns true if the mangled name is an Objective-C symbol. - /// - /// \param mangledName A null-terminated string containing a mangled name. - bool isObjCSymbol(llvm::StringRef mangledName); - - /// Returns true if the mangled name has the old scheme of function type - /// mangling where labels are part of the type. - /// - /// \param mangledName A null-terminated string containing a mangled name. - bool isOldFunctionTypeMangling(llvm::StringRef mangledName); - - class Demangler; - - /// The demangler context. - /// - /// It owns the allocated nodes which are created during demangling. - /// It is always preferable to use the demangling via this context class as it - /// ensures efficient memory management. Especially if demangling is done for - /// multiple symbols. Typical usage: - /// \code - /// Context Ctx; - /// for (...) { - /// NodePointer Root = Ctx.demangleSymbolAsNode(MangledName); - /// // Do something with Root - /// Ctx.clear(); // deallocates Root - /// } - /// \endcode - /// Declaring the context out of the loop minimizes the amount of needed memory - /// allocations. - /// - class Context { - Demangler *D; - - friend class Node; - - public: - Context(); - - ~Context(); - - /// Demangle the given symbol and return the parse tree. - /// - /// \param MangledName The mangled symbol string, which start a mangling - /// prefix: _T, _T0, $S, _$S. - /// - /// \returns A parse tree for the demangled string - or a null pointer - /// on failure. - /// The lifetime of the returned node tree ends with the lifetime of the - /// context or with a call of clear(). - NodePointer demangleSymbolAsNode(llvm::StringRef MangledName); - - /// Demangle the given type and return the parse tree. - /// - /// \param MangledName The mangled symbol string, which start a mangling - /// prefix: _T, _T0, $S, _$S. - /// - /// \returns A parse tree for the demangled string - or a null pointer - /// on failure. - /// The lifetime of the returned node tree ends with the lifetime of the - /// context or with a call of clear(). - NodePointer demangleTypeAsNode(llvm::StringRef MangledName); - - /// Demangle the given symbol and return the readable name. - /// - /// \param MangledName The mangled symbol string, which start a mangling - /// prefix: _T, _T0, $S, _$S. - /// - /// \returns The demangled string. - std::string demangleSymbolAsString(llvm::StringRef MangledName, - const DemangleOptions &Options = DemangleOptions()); - - /// Demangle the given type and return the readable name. - /// - /// \param MangledName The mangled type string, which does _not_ start with - /// a mangling prefix. - /// - /// \returns The demangled string. - std::string demangleTypeAsString(llvm::StringRef MangledName, - const DemangleOptions &Options = DemangleOptions()); - - /// Returns true if the mangledName refers to a thunk function. - /// - /// Thunk functions are either (ObjC) partial apply forwarder, swift-as-ObjC - /// or ObjC-as-swift thunks or allocating init functions. - bool isThunkSymbol(llvm::StringRef MangledName); - - /// Returns the mangled name of the target of a thunk. - /// - /// \returns Returns the remaining name after removing the thunk mangling - /// characters from \p MangledName. If \p MangledName is not a thunk symbol - /// or the thunk target cannot be derived from the mangling, an empty string - /// is returned. - std::string getThunkTarget(llvm::StringRef MangledName); - - /// Returns true if the \p mangledName refers to a function which conforms to - /// the Swift calling convention. - /// - /// The return value is unspecified if the \p MangledName does not refer to a - /// function symbol. - bool hasSwiftCallingConvention(llvm::StringRef MangledName); - - /// Deallocates all nodes. - /// - /// The memory which is used for nodes is not freed but recycled for the next - /// demangling operation. - void clear(); - }; - - /// Standalone utility function to demangle the given symbol as string. - /// - /// If performance is an issue when demangling multiple symbols, - /// Context::demangleSymbolAsString should be used instead. - /// \param mangledName The mangled name string pointer. - /// \param mangledNameLength The length of the mangledName string. - /// \returns The demangled string. - std::string - demangleSymbolAsString(const char *mangledName, size_t mangledNameLength, - const DemangleOptions &options = DemangleOptions()); - - /// Standalone utility function to demangle the given symbol as string. - /// - /// If performance is an issue when demangling multiple symbols, - /// Context::demangleSymbolAsString should be used instead. - /// \param mangledName The mangled name string. - /// \returns The demangled string. - inline std::string - demangleSymbolAsString(const std::string &mangledName, - const DemangleOptions &options = DemangleOptions()) { - return demangleSymbolAsString(mangledName.data(), mangledName.size(), - options); - } - - /// Standalone utility function to demangle the given symbol as string. - /// - /// If performance is an issue when demangling multiple symbols, - /// Context::demangleSymbolAsString should be used instead. - /// \param MangledName The mangled name string. - /// \returns The demangled string. -// inline std::string -// demangleSymbolAsString(llvm::StringRef MangledName, -// const DemangleOptions &Options = DemangleOptions()) { -// return demangleSymbolAsString(MangledName.data(), -// MangledName.size(), Options); -// } - - /// Standalone utility function to demangle the given type as string. - /// - /// If performance is an issue when demangling multiple symbols, - /// Context::demangleTypeAsString should be used instead. - /// \param mangledName The mangled name string pointer. - /// \param mangledNameLength The length of the mangledName string. - /// \returns The demangled string. - std::string - demangleTypeAsString(const char *mangledName, size_t mangledNameLength, - const DemangleOptions &options = DemangleOptions()); - - /// Standalone utility function to demangle the given type as string. - /// - /// If performance is an issue when demangling multiple symbols, - /// Context::demangleTypeAsString should be used instead. - /// \param mangledName The mangled name string. - /// \returns The demangled string. - inline std::string - demangleTypeAsString(const std::string &mangledName, - const DemangleOptions &options = DemangleOptions()) { - return demangleTypeAsString(mangledName.data(), mangledName.size(), options); - } - - /// Standalone utility function to demangle the given type as string. - /// - /// If performance is an issue when demangling multiple symbols, - /// Context::demangleTypeAsString should be used instead. - /// \param MangledName The mangled name string. - /// \returns The demangled string. - inline std::string - demangleTypeAsString(llvm::StringRef MangledName, - const DemangleOptions &Options = DemangleOptions()) { - return demangleTypeAsString(MangledName.data(), - MangledName.size(), Options); - } - - - enum class OperatorKind { - NotOperator, - Prefix, - Postfix, - Infix, - }; - - /// Mangle an identifier using Swift's mangling rules. - void mangleIdentifier(const char *data, size_t length, - OperatorKind operatorKind, std::string &out, - bool usePunycode = true); - -// /// Remangle a demangled parse tree. -// /// -// /// This should always round-trip perfectly with demangleSymbolAsNode. -// std::string mangleNode(NodePointer root); -// -// using SymbolicResolver = -// llvm::function_ref; -// -// /// Remangle a demangled parse tree, using a callback to resolve -// /// symbolic references. -// /// -// /// This should always round-trip perfectly with demangleSymbolAsNode. -// std::string mangleNode(NodePointer root, SymbolicResolver resolver); -// -// /// Remangle in the old mangling scheme. -// /// -// /// This is only used for objc-runtime names and should be removed as soon as -// /// we switch to the new mangling for those names as well. -// std::string mangleNodeOld(NodePointer root); -// - /// Transform the node structure to a string. - /// - /// Typical usage: - /// \code - /// std::string aDemangledName = - /// swift::Demangler::nodeToString(aNode) - /// \endcode - /// - /// \param Root A pointer to a parse tree generated by the demangler. - /// \param Options An object encapsulating options to use to perform this demangling. - /// - /// \returns A string representing the demangled name. - /// - std::string nodeToString(NodePointer Root, - const DemangleOptions &Options = DemangleOptions()); - - /// A class for printing to a std::string. - class DemanglerPrinter { - public: - DemanglerPrinter() = default; - - DemanglerPrinter &operator<<(llvm::StringRef Value) & { - Stream.append(Value.data(), Value.size()); - return *this; - } - - DemanglerPrinter &operator<<(char c) & { - Stream.push_back(c); - return *this; - } - DemanglerPrinter &operator<<(unsigned long long n) &; - DemanglerPrinter &operator<<(long long n) &; - DemanglerPrinter &operator<<(unsigned long n) & { - return *this << (unsigned long long)n; - } - DemanglerPrinter &operator<<(long n) & { - return *this << (long long)n; - } - DemanglerPrinter &operator<<(unsigned n) & { - return *this << (unsigned long long)n; - } - DemanglerPrinter &operator<<(int n) & { - return *this << (long long)n; - } - - template - DemanglerPrinter &&operator<<(T &&x) && { - return std::move(*this << std::forward(x)); - } - - DemanglerPrinter &writeHex(unsigned long long n) &; - - std::string &&str() && { return std::move(Stream); } - - llvm::StringRef getStringRef() const { return Stream; } - - /// Shrinks the buffer. - void resetSize(size_t toPos) { - assert(toPos <= Stream.size()); - Stream.resize(toPos); - } - private: - std::string Stream; - }; - - /// Returns a the node kind \p k as string. - const char *getNodeKindString(swift::Demangle::Node::Kind k); - - /// Prints the whole node tree \p Root in readable form into a std::string. - /// - /// Useful for debugging. - std::string getNodeTreeAsString(NodePointer Root); - - bool nodeConsumesGenericArgs(Node *node); - - bool isSpecialized(Node *node); - - NodePointer getUnspecialized(Node *node, NodeFactory &Factory); - std::string archetypeName(Node::IndexType index, Node::IndexType depth); - - /// Form a StringRef around the mangled name starting at base, if the name may - /// contain symbolic references. - llvm::StringRef makeSymbolicMangledNameStringRef(const char *base); - - } // end namespace Demangle - } // end namespace swift - - // NB: This function is not used directly in the Swift codebase, but is - // exported for Xcode support and is used by the sanitizers. Please coordinate - // before changing. - // - /// Demangles a Swift symbol name. - /// - /// \param mangledName is the symbol name that needs to be demangled. - /// \param mangledNameLength is the length of the string that should be - /// demangled. - /// \param outputBuffer is the user provided buffer where the demangled name - /// will be placed. If nullptr, a new buffer will be malloced. In that case, - /// the user of this API is responsible for freeing the returned buffer. - /// \param outputBufferSize is the size of the output buffer. If the demangled - /// name does not fit into the outputBuffer, the output will be truncated and - /// the size will be updated, indicating how large the buffer should be. - /// \param flags can be used to select the demangling style. TODO: We should - //// define what these will be. - /// \returns the demangled name. Returns nullptr if the input String is not a - /// Swift mangled name. - SWIFT_RUNTIME_EXPORT - char *swift_demangle(const char *mangledName, - size_t mangledNameLength, - char *outputBuffer, - size_t *outputBufferSize, - uint32_t flags); - -#endif // SWIFT_DEMANGLING_DEMANGLE_H diff --git a/Source/KSCrash/swift/Basic/DemangleNodes.def b/Source/KSCrash/swift/Basic/DemangleNodes.def deleted file mode 100644 index 9e7e89013..000000000 --- a/Source/KSCrash/swift/Basic/DemangleNodes.def +++ /dev/null @@ -1,260 +0,0 @@ -//===--- DemangleNodes.def - Demangling Tree Metaprogramming ----*- C++ -*-===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file defines macros useful for macro-metaprogramming with nodes in -// the demangling tree. -// -//===----------------------------------------------------------------------===// - -/// NODE(ID) -/// The node's enumerator value is Node::Kind::ID. - -/// CONTEXT_NODE(ID) -/// Nodes that can serve as contexts for other entities. -#ifndef CONTEXT_NODE -#define CONTEXT_NODE(ID) NODE(ID) -#endif - -CONTEXT_NODE(Allocator) -CONTEXT_NODE(AnonymousContext) -NODE(AnyProtocolConformanceList) -NODE(ArgumentTuple) -NODE(AssociatedType) -NODE(AssociatedTypeRef) -NODE(AssociatedTypeMetadataAccessor) -NODE(DefaultAssociatedTypeMetadataAccessor) -NODE(AssociatedTypeWitnessTableAccessor) -NODE(BaseWitnessTableAccessor) -NODE(AutoClosureType) -NODE(BoundGenericClass) -NODE(BoundGenericEnum) -NODE(BoundGenericStructure) -NODE(BoundGenericProtocol) -NODE(BoundGenericOtherNominalType) -NODE(BoundGenericTypeAlias) -NODE(BoundGenericFunction) -NODE(BuiltinTypeName) -NODE(CFunctionPointer) -CONTEXT_NODE(Class) -NODE(ClassMetadataBaseOffset) -NODE(ConcreteProtocolConformance) -CONTEXT_NODE(Constructor) -NODE(CoroutineContinuationPrototype) -CONTEXT_NODE(Deallocator) -NODE(DeclContext) -CONTEXT_NODE(DefaultArgumentInitializer) -NODE(DependentAssociatedConformance) -NODE(DependentAssociatedTypeRef) -NODE(DependentGenericConformanceRequirement) -NODE(DependentGenericParamCount) -NODE(DependentGenericParamType) -NODE(DependentGenericSameTypeRequirement) -NODE(DependentGenericLayoutRequirement) -NODE(DependentGenericSignature) -NODE(DependentGenericType) -NODE(DependentMemberType) -NODE(DependentPseudogenericSignature) -NODE(DependentProtocolConformanceRoot) -NODE(DependentProtocolConformanceInherited) -NODE(DependentProtocolConformanceAssociated) -CONTEXT_NODE(Destructor) -CONTEXT_NODE(DidSet) -NODE(Directness) -NODE(DynamicAttribute) -NODE(DirectMethodReferenceAttribute) -NODE(DynamicSelf) -NODE(DynamicallyReplaceableFunctionImpl) -NODE(DynamicallyReplaceableFunctionKey) -NODE(DynamicallyReplaceableFunctionVar) -CONTEXT_NODE(Enum) -NODE(EnumCase) -NODE(ErrorType) -NODE(EscapingAutoClosureType) -NODE(NoEscapeFunctionType) -NODE(ExistentialMetatype) -CONTEXT_NODE(ExplicitClosure) -CONTEXT_NODE(Extension) -NODE(FieldOffset) -NODE(FullTypeMetadata) -CONTEXT_NODE(Function) -NODE(FunctionSignatureSpecialization) -NODE(FunctionSignatureSpecializationParam) -NODE(FunctionSignatureSpecializationParamKind) -NODE(FunctionSignatureSpecializationParamPayload) -NODE(FunctionType) -NODE(GenericPartialSpecialization) -NODE(GenericPartialSpecializationNotReAbstracted) -NODE(GenericProtocolWitnessTable) -NODE(GenericProtocolWitnessTableInstantiationFunction) -NODE(ResilientProtocolWitnessTable) -NODE(GenericSpecialization) -NODE(GenericSpecializationNotReAbstracted) -NODE(GenericSpecializationParam) -NODE(InlinedGenericFunction) -NODE(GenericTypeMetadataPattern) -CONTEXT_NODE(Getter) -NODE(Global) -CONTEXT_NODE(GlobalGetter) -NODE(Identifier) -NODE(Index) -CONTEXT_NODE(IVarInitializer) -CONTEXT_NODE(IVarDestroyer) -NODE(ImplEscaping) -NODE(ImplConvention) -NODE(ImplFunctionAttribute) -NODE(ImplFunctionType) -CONTEXT_NODE(ImplicitClosure) -NODE(ImplParameter) -NODE(ImplResult) -NODE(ImplErrorResult) -NODE(InOut) -NODE(InfixOperator) -CONTEXT_NODE(Initializer) -NODE(KeyPathGetterThunkHelper) -NODE(KeyPathSetterThunkHelper) -NODE(KeyPathEqualsThunkHelper) -NODE(KeyPathHashThunkHelper) -NODE(LazyProtocolWitnessTableAccessor) -NODE(LazyProtocolWitnessTableCacheVariable) -NODE(LocalDeclName) -CONTEXT_NODE(MaterializeForSet) -NODE(MergedFunction) -NODE(Metatype) -NODE(MetatypeRepresentation) -NODE(Metaclass) -NODE(MethodLookupFunction) -NODE(ObjCMetadataUpdateFunction) -CONTEXT_NODE(ModifyAccessor) -CONTEXT_NODE(Module) -CONTEXT_NODE(NativeOwningAddressor) -CONTEXT_NODE(NativeOwningMutableAddressor) -CONTEXT_NODE(NativePinningAddressor) -CONTEXT_NODE(NativePinningMutableAddressor) -NODE(NominalTypeDescriptor) -NODE(NonObjCAttribute) -NODE(Number) -NODE(ObjCAttribute) -NODE(ObjCBlock) -CONTEXT_NODE(OtherNominalType) -CONTEXT_NODE(OwningAddressor) -CONTEXT_NODE(OwningMutableAddressor) -NODE(PartialApplyForwarder) -NODE(PartialApplyObjCForwarder) -NODE(PostfixOperator) -NODE(PrefixOperator) -NODE(PrivateDeclName) -NODE(PropertyDescriptor) -CONTEXT_NODE(Protocol) -CONTEXT_NODE(ProtocolSymbolicReference) -NODE(ProtocolConformance) -NODE(ProtocolConformanceRefInTypeModule) -NODE(ProtocolConformanceRefInProtocolModule) -NODE(ProtocolConformanceRefInOtherModule) -NODE(ProtocolDescriptor) -NODE(ProtocolConformanceDescriptor) -NODE(ProtocolList) -NODE(ProtocolListWithClass) -NODE(ProtocolListWithAnyObject) -NODE(ProtocolSelfConformanceDescriptor) -NODE(ProtocolSelfConformanceWitness) -NODE(ProtocolSelfConformanceWitnessTable) -NODE(ProtocolWitness) -NODE(ProtocolWitnessTable) -NODE(ProtocolWitnessTableAccessor) -NODE(ProtocolWitnessTablePattern) -NODE(ReabstractionThunk) -NODE(ReabstractionThunkHelper) -CONTEXT_NODE(ReadAccessor) -NODE(RelatedEntityDeclName) -NODE(RetroactiveConformance) -NODE(ReturnType) -NODE(Shared) -NODE(Owned) -NODE(SILBoxType) -NODE(SILBoxTypeWithLayout) -NODE(SILBoxLayout) -NODE(SILBoxMutableField) -NODE(SILBoxImmutableField) -CONTEXT_NODE(Setter) -NODE(SpecializationPassID) -NODE(IsSerialized) -CONTEXT_NODE(Static) -CONTEXT_NODE(Structure) -CONTEXT_NODE(Subscript) -NODE(Suffix) -NODE(ThinFunctionType) -NODE(Tuple) -NODE(TupleElement) -NODE(TupleElementName) -NODE(Type) -CONTEXT_NODE(TypeSymbolicReference) -CONTEXT_NODE(TypeAlias) -NODE(TypeList) -NODE(TypeMangling) -NODE(TypeMetadata) -NODE(TypeMetadataAccessFunction) -NODE(TypeMetadataCompletionFunction) -NODE(TypeMetadataInstantiationCache) -NODE(TypeMetadataInstantiationFunction) -NODE(TypeMetadataSingletonInitializationCache) -NODE(TypeMetadataLazyCache) -NODE(UncurriedFunctionType) -#define REF_STORAGE(Name, ...) NODE(Name) -#include "ReferenceStorage.def" -CONTEXT_NODE(UnsafeAddressor) -CONTEXT_NODE(UnsafeMutableAddressor) -NODE(ValueWitness) -NODE(ValueWitnessTable) -CONTEXT_NODE(Variable) -NODE(VTableThunk) -NODE(VTableAttribute) // note: old mangling only -CONTEXT_NODE(WillSet) -NODE(ReflectionMetadataBuiltinDescriptor) -NODE(ReflectionMetadataFieldDescriptor) -NODE(ReflectionMetadataAssocTypeDescriptor) -NODE(ReflectionMetadataSuperclassDescriptor) -NODE(GenericTypeParamDecl) -NODE(CurryThunk) -NODE(DispatchThunk) -NODE(MethodDescriptor) -NODE(ProtocolRequirementsBaseDescriptor) -NODE(AssociatedConformanceDescriptor) -NODE(DefaultAssociatedConformanceAccessor) -NODE(BaseConformanceDescriptor) -NODE(AssociatedTypeDescriptor) -NODE(ThrowsAnnotation) -NODE(EmptyList) -NODE(FirstElementMarker) -NODE(VariadicMarker) -NODE(OutlinedBridgedMethod) -NODE(OutlinedCopy) -NODE(OutlinedConsume) -NODE(OutlinedRetain) -NODE(OutlinedRelease) -NODE(OutlinedInitializeWithTake) -NODE(OutlinedInitializeWithCopy) -NODE(OutlinedAssignWithTake) -NODE(OutlinedAssignWithCopy) -NODE(OutlinedDestroy) -NODE(OutlinedVariable) -NODE(AssocTypePath) -NODE(LabelList) -NODE(ModuleDescriptor) -NODE(ExtensionDescriptor) -NODE(AnonymousDescriptor) -NODE(AssociatedTypeGenericParamRef) -NODE(SugaredOptional) -NODE(SugaredArray) -NODE(SugaredDictionary) -NODE(SugaredParen) -#undef CONTEXT_NODE -#undef NODE diff --git a/Source/KSCrash/swift/Basic/DemangleNodes.h b/Source/KSCrash/swift/Basic/DemangleNodes.h deleted file mode 100644 index f96b3804f..000000000 --- a/Source/KSCrash/swift/Basic/DemangleNodes.h +++ /dev/null @@ -1,168 +0,0 @@ -//===--- DemangleNodes.def - Demangling Tree Metaprogramming ----*- C++ -*-===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See http://swift.org/LICENSE.txt for license information -// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file defines macros useful for macro-metaprogramming with nodes in -// the demangling tree. -// -//===----------------------------------------------------------------------===// - -/// NODE(ID) -/// The node's enumerator value is Node::Kind::ID. - -/// CONTEXT_NODE(ID) -/// Nodes that can serve as contexts for other entities. -#ifndef CONTEXT_NODE -#define CONTEXT_NODE(ID) NODE(ID) -#endif - -CONTEXT_NODE(Allocator) -NODE(Archetype) -NODE(ArchetypeRef) -NODE(ArgumentTuple) -NODE(AssociatedType) -NODE(AssociatedTypeRef) -NODE(AssociatedTypeMetadataAccessor) -NODE(AssociatedTypeWitnessTableAccessor) -NODE(AutoClosureType) -NODE(BoundGenericClass) -NODE(BoundGenericEnum) -NODE(BoundGenericStructure) -NODE(BuiltinTypeName) -NODE(CFunctionPointer) -CONTEXT_NODE(Class) -CONTEXT_NODE(Constructor) -CONTEXT_NODE(Deallocator) -NODE(DeclContext) -CONTEXT_NODE(DefaultArgumentInitializer) -NODE(DependentAssociatedTypeRef) -NODE(DependentGenericConformanceRequirement) -NODE(DependentGenericParamCount) -NODE(DependentGenericParamType) -NODE(DependentGenericSameTypeRequirement) -NODE(DependentGenericSignature) -NODE(DependentGenericType) -NODE(DependentMemberType) -NODE(DependentPseudogenericSignature) -CONTEXT_NODE(Destructor) -CONTEXT_NODE(DidSet) -NODE(Directness) -NODE(DynamicAttribute) -NODE(DirectMethodReferenceAttribute) -NODE(DynamicSelf) -CONTEXT_NODE(Enum) -NODE(ErrorType) -NODE(ExistentialMetatype) -CONTEXT_NODE(ExplicitClosure) -CONTEXT_NODE(Extension) -NODE(FieldOffset) -NODE(FullTypeMetadata) -CONTEXT_NODE(Function) -NODE(FunctionSignatureSpecialization) -NODE(FunctionSignatureSpecializationParam) -NODE(FunctionSignatureSpecializationParamKind) -NODE(FunctionSignatureSpecializationParamPayload) -NODE(FunctionType) -NODE(GenericProtocolWitnessTable) -NODE(GenericProtocolWitnessTableInstantiationFunction) -NODE(GenericSpecialization) -NODE(GenericSpecializationNotReAbstracted) -NODE(GenericSpecializationParam) -NODE(GenericTypeMetadataPattern) -CONTEXT_NODE(Getter) -NODE(Global) -CONTEXT_NODE(GlobalGetter) -NODE(Identifier) -NODE(Index) -CONTEXT_NODE(IVarInitializer) -CONTEXT_NODE(IVarDestroyer) -NODE(ImplConvention) -NODE(ImplFunctionAttribute) -NODE(ImplFunctionType) -CONTEXT_NODE(ImplicitClosure) -NODE(ImplParameter) -NODE(ImplResult) -NODE(ImplErrorResult) -NODE(InOut) -NODE(InfixOperator) -CONTEXT_NODE(Initializer) -NODE(LazyProtocolWitnessTableAccessor) -NODE(LazyProtocolWitnessTableCacheVariable) -NODE(LocalDeclName) -CONTEXT_NODE(MaterializeForSet) -NODE(Metatype) -NODE(MetatypeRepresentation) -NODE(Metaclass) -CONTEXT_NODE(Module) -CONTEXT_NODE(NativeOwningAddressor) -CONTEXT_NODE(NativeOwningMutableAddressor) -CONTEXT_NODE(NativePinningAddressor) -CONTEXT_NODE(NativePinningMutableAddressor) -NODE(NominalTypeDescriptor) -NODE(NonObjCAttribute) -NODE(NonVariadicTuple) -NODE(Number) -NODE(ObjCAttribute) -NODE(ObjCBlock) -CONTEXT_NODE(OwningAddressor) -CONTEXT_NODE(OwningMutableAddressor) -NODE(PartialApplyForwarder) -NODE(PartialApplyObjCForwarder) -NODE(PostfixOperator) -NODE(PrefixOperator) -NODE(PrivateDeclName) -CONTEXT_NODE(Protocol) -NODE(ProtocolConformance) -NODE(ProtocolDescriptor) -NODE(ProtocolList) -NODE(ProtocolWitness) -NODE(ProtocolWitnessTable) -NODE(ProtocolWitnessTableAccessor) -NODE(QualifiedArchetype) -NODE(ReabstractionThunk) -NODE(ReabstractionThunkHelper) -NODE(ReturnType) -NODE(SILBoxType) -NODE(SelfTypeRef) -CONTEXT_NODE(Setter) -NODE(SpecializationPassID) -NODE(SpecializationIsFragile) -CONTEXT_NODE(Static) -CONTEXT_NODE(Structure) -CONTEXT_NODE(Subscript) -NODE(Suffix) -NODE(ThinFunctionType) -NODE(TupleElement) -NODE(TupleElementName) -NODE(Type) -NODE(TypeAlias) -NODE(TypeList) -NODE(TypeMangling) -NODE(TypeMetadata) -NODE(TypeMetadataAccessFunction) -NODE(TypeMetadataLazyCache) -NODE(UncurriedFunctionType) -NODE(Unmanaged) -NODE(Unowned) -CONTEXT_NODE(UnsafeAddressor) -CONTEXT_NODE(UnsafeMutableAddressor) -NODE(ValueWitness) -NODE(ValueWitnessTable) -CONTEXT_NODE(Variable) -NODE(VariadicTuple) -NODE(VTableAttribute) -NODE(Weak) -CONTEXT_NODE(WillSet) -NODE(WitnessTableOffset) -NODE(ThrowsAnnotation) - -#undef CONTEXT_NODE -#undef NODE diff --git a/Source/KSCrash/swift/Basic/Demangler.cpp b/Source/KSCrash/swift/Basic/Demangler.cpp deleted file mode 100644 index fef979128..000000000 --- a/Source/KSCrash/swift/Basic/Demangler.cpp +++ /dev/null @@ -1,3054 +0,0 @@ -//===--- Demangler.cpp - String to Node-Tree Demangling -------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file implements new Swift de-mangler. -// -//===----------------------------------------------------------------------===// - -#include "Demangler.h" -#include "ManglingUtils.h" -#include "ManglingMacros.h" -#include "Punycode.h" -#include "SwiftStrings.h" - -using namespace swift; -using namespace Mangle; -using swift::Demangle::FunctionSigSpecializationParamKind; - -////////////////////////////////// -// Private utility functions // -////////////////////////////////// - -namespace { - - static bool isDeclName(Node::Kind kind) { - switch (kind) { - case Node::Kind::Identifier: - case Node::Kind::LocalDeclName: - case Node::Kind::PrivateDeclName: - case Node::Kind::RelatedEntityDeclName: - case Node::Kind::PrefixOperator: - case Node::Kind::PostfixOperator: - case Node::Kind::InfixOperator: - case Node::Kind::TypeSymbolicReference: - case Node::Kind::ProtocolSymbolicReference: - return true; - default: - return false; - } - } - - static bool isContext(Node::Kind kind) { - switch (kind) { -#define NODE(ID) -#define CONTEXT_NODE(ID) \ -case Node::Kind::ID: -#include "DemangleNodes.def" - return true; - default: - return false; - } - } - - static bool isAnyGeneric(Node::Kind kind) { - switch (kind) { - case Node::Kind::Structure: - case Node::Kind::Class: - case Node::Kind::Enum: - case Node::Kind::Protocol: - case Node::Kind::ProtocolSymbolicReference: - case Node::Kind::OtherNominalType: - case Node::Kind::TypeAlias: - case Node::Kind::TypeSymbolicReference: - return true; - default: - return false; - } - } - - static bool isEntity(Node::Kind kind) { - // Also accepts some kind which are not entities. - if (kind == Node::Kind::Type) - return true; - return isContext(kind); - } - - static bool isRequirement(Node::Kind kind) { - switch (kind) { - case Node::Kind::DependentGenericSameTypeRequirement: - case Node::Kind::DependentGenericLayoutRequirement: - case Node::Kind::DependentGenericConformanceRequirement: - return true; - default: - return false; - } - } - - static bool isFunctionAttr(Node::Kind kind) { - switch (kind) { - case Node::Kind::FunctionSignatureSpecialization: - case Node::Kind::GenericSpecialization: - case Node::Kind::InlinedGenericFunction: - case Node::Kind::GenericSpecializationNotReAbstracted: - case Node::Kind::GenericPartialSpecialization: - case Node::Kind::GenericPartialSpecializationNotReAbstracted: - case Node::Kind::ObjCAttribute: - case Node::Kind::NonObjCAttribute: - case Node::Kind::DynamicAttribute: - case Node::Kind::DirectMethodReferenceAttribute: - case Node::Kind::VTableAttribute: - case Node::Kind::PartialApplyForwarder: - case Node::Kind::PartialApplyObjCForwarder: - case Node::Kind::OutlinedVariable: - case Node::Kind::OutlinedBridgedMethod: - case Node::Kind::MergedFunction: - case Node::Kind::DynamicallyReplaceableFunctionImpl: - case Node::Kind::DynamicallyReplaceableFunctionKey: - case Node::Kind::DynamicallyReplaceableFunctionVar: - return true; - default: - return false; - } - } - -} // anonymous namespace - -////////////////////////////////// -// Public utility functions // -////////////////////////////////// - -llvm::StringRef -swift::Demangle::makeSymbolicMangledNameStringRef(const char *base) { - if (!base) - return {}; - - auto end = base; - while (*end != '\0') { - // Skip over symbolic references. - if (*end >= '\x01' && *end <= '\x17') - end += sizeof(uint32_t); - else if (*end >= '\x18' && *end <= '\x1F') - end += sizeof(void*); - ++end; - } - return StringRef(base, end - base); -} - -int swift::Demangle::getManglingPrefixLength(llvm::StringRef mangledName) { - if (mangledName.empty()) return 0; - - llvm::StringRef prefixes[] = { - /*Swift 4*/ "_T0", - /*Swift 4.x*/ "$S", "_$S", - /*Swift 5+*/ "$s", "_$s"}; - - // Look for any of the known prefixes - for (auto prefix : prefixes) { - if (mangledName.startswith(prefix)) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wconversion" - return prefix.size(); -#pragma clang diagnostic pop - } - - return 0; -} - -bool swift::Demangle::isSwiftSymbol(llvm::StringRef mangledName) { - if (isOldFunctionTypeMangling(mangledName)) - return true; - - return getManglingPrefixLength(mangledName) != 0; -} - -bool swift::Demangle::isSwiftSymbol(const char *mangledName) { - StringRef mangledNameRef(mangledName); - return isSwiftSymbol(mangledNameRef); -} - -bool swift::Demangle::isObjCSymbol(llvm::StringRef mangledName) { - StringRef nameWithoutPrefix = dropSwiftManglingPrefix(mangledName); - return nameWithoutPrefix.startswith("So") || - nameWithoutPrefix.startswith("SC"); -} - -bool swift::Demangle::isOldFunctionTypeMangling(llvm::StringRef mangledName) { - return mangledName.startswith("_T"); -} - -llvm::StringRef swift::Demangle::dropSwiftManglingPrefix(StringRef mangledName){ - return mangledName.drop_front(getManglingPrefixLength(mangledName)); -} - -static bool isAliasNode(Demangle::NodePointer Node) { - switch (Node->getKind()) { - case Demangle::Node::Kind::Type: - return isAliasNode(Node->getChild(0)); - case Demangle::Node::Kind::TypeAlias: - return true; - default: - return false; - } - assert(0 && "unknown node kind"); -} - -bool swift::Demangle::isAlias(llvm::StringRef mangledName) { - Demangle::Demangler Dem; - return isAliasNode(Dem.demangleType(mangledName)); -} - -static bool isClassNode(Demangle::NodePointer Node) { - switch (Node->getKind()) { - case Demangle::Node::Kind::Type: - return isClassNode(Node->getChild(0)); - case Demangle::Node::Kind::Class: - case Demangle::Node::Kind::BoundGenericClass: - return true; - default: - return false; - } - assert(0 && "unknown node kind"); -} - -bool swift::Demangle::isClass(llvm::StringRef mangledName) { - Demangle::Demangler Dem; - return isClassNode(Dem.demangleType(mangledName)); -} - -static bool isEnumNode(Demangle::NodePointer Node) { - switch (Node->getKind()) { - case Demangle::Node::Kind::Type: - return isEnumNode(Node->getChild(0)); - case Demangle::Node::Kind::Enum: - case Demangle::Node::Kind::BoundGenericEnum: - return true; - default: - return false; - } - assert(0 && "unknown node kind"); -} - -bool swift::Demangle::isEnum(llvm::StringRef mangledName) { - Demangle::Demangler Dem; - return isEnumNode(Dem.demangleType(mangledName)); -} - -static bool isProtocolNode(Demangle::NodePointer Node) { - switch (Node->getKind()) { - case Demangle::Node::Kind::Type: - return isProtocolNode(Node->getChild(0)); - case Demangle::Node::Kind::Protocol: - case Demangle::Node::Kind::ProtocolSymbolicReference: - return true; - default: - return false; - } - assert(0 && "unknown node kind"); -} - -bool swift::Demangle::isProtocol(llvm::StringRef mangledName) { - Demangle::Demangler Dem; - return isProtocolNode(Dem.demangleType(dropSwiftManglingPrefix(mangledName))); -} - -static bool isStructNode(Demangle::NodePointer Node) { - switch (Node->getKind()) { - case Demangle::Node::Kind::Type: - return isStructNode(Node->getChild(0)); - case Demangle::Node::Kind::Structure: - case Demangle::Node::Kind::BoundGenericStructure: - return true; - default: - return false; - } - assert(0 && "unknown node kind"); -} - -bool swift::Demangle::isStruct(llvm::StringRef mangledName) { - Demangle::Demangler Dem; - return isStructNode(Dem.demangleType(mangledName)); -} - -using namespace swift; -using namespace Demangle; - -////////////////////////////////// -// Node member functions // -////////////////////////////////// - -void Node::addChild(NodePointer Child, NodeFactory &Factory) { - assert(Child && "adding null child!"); - if (NumChildren >= ReservedChildren) - Factory.Reallocate(Children, ReservedChildren, 1); - assert(NumChildren < ReservedChildren); - Children[NumChildren++] = Child; -} - -void Node::removeChildAt(unsigned Pos, swift::Demangle::NodeFactory &factory) { - assert(Pos < NumChildren && "invalid child position!"); - - size_t Index = 0; - auto *NewChildren = factory.Allocate(NumChildren - 1); - for (unsigned long i = 0, n = NumChildren; i != n; ++i) { - auto Child = Children[i]; - if (i != Pos) { - NewChildren[Index] = Child; - ++Index; - } else { - --NumChildren; - } - } - Children = NewChildren; -} - -void Node::reverseChildren(size_t StartingAt) { - assert(StartingAt <= NumChildren); - std::reverse(Children + StartingAt, Children + NumChildren); -} - -////////////////////////////////// -// NodeFactory member functions // -////////////////////////////////// - -void NodeFactory::freeSlabs(Slab *slab) { - while (slab) { - Slab *prev = slab->Previous; -#ifdef NODE_FACTORY_DEBUGGING - std::cerr << " free slab = " << slab << "\n"; -#endif - free(slab); - slab = prev; - } -} - -void NodeFactory::clear() { - if (CurrentSlab) { - freeSlabs(CurrentSlab->Previous); - - // Recycle the last allocated slab. - // Note that the size of the last slab is at least as big as all previous - // slabs combined. Therefore it's not worth the effort of reusing all slabs. - // The slab size also stays the same. So at some point the demangling - // process converges to a single large slab across repeated demangle-clear - // cycles. - CurrentSlab->Previous = nullptr; - CurPtr = (char *)(CurrentSlab + 1); - assert(End == CurPtr + SlabSize); - } -} - -NodePointer NodeFactory::createNode(Node::Kind K) { - return new (Allocate()) Node(K); -} -NodePointer NodeFactory::createNode(Node::Kind K, Node::IndexType Index) { - return new (Allocate()) Node(K, Index); -} -NodePointer NodeFactory::createNodeWithAllocatedText(Node::Kind K, - llvm::StringRef Text) { - return new (Allocate()) Node(K, Text); -} -NodePointer NodeFactory::createNode(Node::Kind K, const CharVector &Text) { - return createNodeWithAllocatedText(K, Text.str()); -} -NodePointer NodeFactory::createNode(Node::Kind K, const char *Text) { - return new (Allocate()) Node(K, llvm::StringRef(Text)); -} - -////////////////////////////////// -// CharVector member functions // -////////////////////////////////// - -void CharVector::append(StringRef Rhs, NodeFactory &Factory) { - if (NumElems + Rhs.size() > Capacity) - Factory.Reallocate(Elems, Capacity, /*Growth*/ Rhs.size()); - memcpy(Elems + NumElems, Rhs.data(), Rhs.size()); - NumElems += Rhs.size(); - assert(NumElems <= Capacity); -} - -void CharVector::append(int Number, NodeFactory &Factory) { - const int MaxIntPrintSize = 8; - if (NumElems + MaxIntPrintSize > Capacity) - Factory.Reallocate(Elems, Capacity, /*Growth*/ MaxIntPrintSize); - int Length = snprintf(Elems + NumElems, MaxIntPrintSize, "%d", Number); - assert(Length > 0 && Length < MaxIntPrintSize); - NumElems += Length; -} - -////////////////////////////////// -// Demangler member functions // -////////////////////////////////// - -void Demangler::clear() { - NodeStack.free(); - Substitutions.free(); - NodeFactory::clear(); -} - -void Demangler::init(StringRef MangledName) { - NodeStack.init(*this, 16); - Substitutions.init(*this, 16); - NumWords = 0; - Text = MangledName; - Pos = 0; -} - -NodePointer Demangler::demangleSymbol(StringRef MangledName) { - init(MangledName); - - // Demangle old-style class and protocol names, which are still used in the - // ObjC metadata. - if (nextIf("_Tt")) - return demangleObjCTypeName(); - - unsigned PrefixLength = getManglingPrefixLength(MangledName); - if (PrefixLength == 0) - return nullptr; - - IsOldFunctionTypeMangling = isOldFunctionTypeMangling(MangledName); - Pos += PrefixLength; - - // If any other prefixes are accepted, please update Mangler::verify. - - if (!parseAndPushNodes()) - return nullptr; - - NodePointer topLevel = createNode(Node::Kind::Global); - - NodePointer Parent = topLevel; - while (NodePointer FuncAttr = popNode(isFunctionAttr)) { - Parent->addChild(FuncAttr, *this); - if (FuncAttr->getKind() == Node::Kind::PartialApplyForwarder || - FuncAttr->getKind() == Node::Kind::PartialApplyObjCForwarder) - Parent = FuncAttr; - } - for (Node *Nd : NodeStack) { - switch (Nd->getKind()) { - case Node::Kind::Type: - Parent->addChild(Nd->getFirstChild(), *this); - break; - default: - Parent->addChild(Nd, *this); - break; - } - } - if (topLevel->getNumChildren() == 0) - return nullptr; - - return topLevel; -} - -NodePointer Demangler::demangleType(StringRef MangledName) { - init(MangledName); - - parseAndPushNodes(); - - if (NodePointer Result = popNode()) - return Result; - - return createNode(Node::Kind::Suffix, Text); -} - -bool Demangler::parseAndPushNodes() { - int Idx = 0; - while (Pos < Text.size()) { - NodePointer Node = demangleOperator(); - if (!Node) - return false; - pushNode(Node); - Idx++; - } - return true; -} - -NodePointer Demangler::addChild(NodePointer Parent, NodePointer Child) { - if (!Parent || !Child) - return nullptr; - Parent->addChild(Child, *this); - return Parent; -} - -NodePointer Demangler::createWithChild(Node::Kind kind, - NodePointer Child) { - if (!Child) - return nullptr; - NodePointer Nd = createNode(kind); - Nd->addChild(Child, *this); - return Nd; -} - -NodePointer Demangler::createType(NodePointer Child) { - return createWithChild(Node::Kind::Type, Child); -} - -NodePointer Demangler::Demangler::createWithChildren(Node::Kind kind, - NodePointer Child1, NodePointer Child2) { - if (!Child1 || !Child2) - return nullptr; - NodePointer Nd = createNode(kind); - Nd->addChild(Child1, *this); - Nd->addChild(Child2, *this); - return Nd; -} - -NodePointer Demangler::createWithChildren(Node::Kind kind, - NodePointer Child1, - NodePointer Child2, - NodePointer Child3) { - if (!Child1 || !Child2 || !Child3) - return nullptr; - NodePointer Nd = createNode(kind); - Nd->addChild(Child1, *this); - Nd->addChild(Child2, *this); - Nd->addChild(Child3, *this); - return Nd; -} - -NodePointer Demangler::createWithChildren(Node::Kind kind, NodePointer Child1, - NodePointer Child2, - NodePointer Child3, - NodePointer Child4) { - if (!Child1 || !Child2 || !Child3 || !Child4) - return nullptr; - NodePointer Nd = createNode(kind); - Nd->addChild(Child1, *this); - Nd->addChild(Child2, *this); - Nd->addChild(Child3, *this); - Nd->addChild(Child4, *this); - return Nd; -} - -NodePointer Demangler::changeKind(NodePointer Node, Node::Kind NewKind) { - if (!Node) - return nullptr; - NodePointer NewNode = nullptr; - if (Node->hasText()) { - NewNode = createNodeWithAllocatedText(NewKind, Node->getText()); - } else if (Node->hasIndex()) { - NewNode = createNode(NewKind, Node->getIndex()); - } else { - NewNode = createNode(NewKind); - } - for (NodePointer Child : *Node) { - NewNode->addChild(Child, *this); - } - return NewNode; -} - -NodePointer Demangler::demangleTypeMangling() { - auto Type = popNode(Node::Kind::Type); - auto LabelList = popFunctionParamLabels(Type); - auto TypeMangling = createNode(Node::Kind::TypeMangling); - - addChild(TypeMangling, LabelList); - TypeMangling = addChild(TypeMangling, Type); - return TypeMangling; -} - -NodePointer Demangler::demangleSymbolicReference(unsigned char rawKind, - const void *at) { - // The symbolic reference is a 4-byte machine integer encoded in the following - // four bytes. - int32_t value; - memcpy(&value, Text.data() + Pos, 4); - Pos += 4; - - // Map the encoded kind to a specific kind and directness. - SymbolicReferenceKind kind; - Directness direct; - switch (rawKind) { - case 1: - kind = SymbolicReferenceKind::Context; - direct = Directness::Direct; - break; - case 2: - kind = SymbolicReferenceKind::Context; - direct = Directness::Indirect; - break; - default: - return nullptr; - } - - // Use the resolver, if any, to produce the demangling tree the symbolic - // reference represents. - NodePointer resolved = nullptr; - if (SymbolicReferenceResolver) - resolved = SymbolicReferenceResolver(kind, direct, value, at); - // With no resolver, or a resolver that failed, refuse to demangle further. - if (!resolved) - return nullptr; - - // Types register as substitutions even when symbolically referenced. - if (kind == SymbolicReferenceKind::Context) - addSubstitution(resolved); - return resolved; -} - -NodePointer Demangler::demangleOperator() { - switch (char c = nextChar()) { - case '\1': - case '\2': - case '\3': - case '\4': - return demangleSymbolicReference((unsigned char)c, Text.data() + Pos); - case 'A': return demangleMultiSubstitutions(); - case 'B': return demangleBuiltinType(); - case 'C': return demangleAnyGenericType(Node::Kind::Class); - case 'D': return demangleTypeMangling(); - case 'E': return demangleExtensionContext(); - case 'F': return demanglePlainFunction(); - case 'G': return demangleBoundGenericType(); - case 'H': - switch (char c2 = nextChar()) { - case 'A': return demangleDependentProtocolConformanceAssociated(); - case 'C': return demangleConcreteProtocolConformance(); - case 'D': return demangleDependentProtocolConformanceRoot(); - case 'I': return demangleDependentProtocolConformanceInherited(); - case 'P': - return createWithChild( - Node::Kind::ProtocolConformanceRefInTypeModule, popProtocol()); - case 'p': - return createWithChild( - Node::Kind::ProtocolConformanceRefInProtocolModule, popProtocol()); - default: - pushBack(); - pushBack(); - return demangleIdentifier(); - } - - case 'I': return demangleImplFunctionType(); - case 'K': return createNode(Node::Kind::ThrowsAnnotation); - case 'L': return demangleLocalIdentifier(); - case 'M': return demangleMetatype(); - case 'N': return createWithChild(Node::Kind::TypeMetadata, - popNode(Node::Kind::Type)); - case 'O': return demangleAnyGenericType(Node::Kind::Enum); - case 'P': return demangleAnyGenericType(Node::Kind::Protocol); - case 'Q': return demangleArchetype(); - case 'R': return demangleGenericRequirement(); - case 'S': return demangleStandardSubstitution(); - case 'T': return demangleThunkOrSpecialization(); - case 'V': return demangleAnyGenericType(Node::Kind::Structure); - case 'W': return demangleWitness(); - case 'X': return demangleSpecialType(); - case 'Z': return createWithChild(Node::Kind::Static, popNode(isEntity)); - case 'a': return demangleAnyGenericType(Node::Kind::TypeAlias); - case 'c': return popFunctionType(Node::Kind::FunctionType); - case 'd': return createNode(Node::Kind::VariadicMarker); - case 'f': return demangleFunctionEntity(); - case 'g': return demangleRetroactiveConformance(); - case 'h': return createType(createWithChild(Node::Kind::Shared, - popTypeAndGetChild())); - case 'i': return demangleSubscript(); - case 'l': return demangleGenericSignature(/*hasParamCounts*/ false); - case 'm': return createType(createWithChild(Node::Kind::Metatype, - popNode(Node::Kind::Type))); - case 'n': - return createType( - createWithChild(Node::Kind::Owned, popTypeAndGetChild())); - case 'o': return demangleOperatorIdentifier(); - case 'p': return demangleProtocolListType(); - case 'q': return createType(demangleGenericParamIndex()); - case 'r': return demangleGenericSignature(/*hasParamCounts*/ true); - case 's': return createNode(Node::Kind::Module, STDLIB_NAME); - case 't': return popTuple(); - case 'u': return demangleGenericType(); - case 'v': return demangleVariable(); - case 'w': return demangleValueWitness(); - case 'x': return createType(getDependentGenericParamType(0, 0)); - case 'y': return createNode(Node::Kind::EmptyList); - case 'z': return createType(createWithChild(Node::Kind::InOut, - popTypeAndGetChild())); - case '_': return createNode(Node::Kind::FirstElementMarker); - case '.': - // IRGen still uses '.' to disambiguate partial apply thunks and - // outlined copy functions. We treat such a suffix as "unmangled suffix". - pushBack(); - return createNode(Node::Kind::Suffix, consumeAll()); - default: - pushBack(); - return demangleIdentifier(); - } -} - -int Demangler::demangleNatural() { - if (!isDigit(peekChar())) - return -1000; - int num = 0; - while (true) { - char c = peekChar(); - if (!isDigit(c)) - return num; - int newNum = (10 * num) + (c - '0'); - if (newNum < num) - return -1000; - num = newNum; - nextChar(); - } -} - -int Demangler::demangleIndex() { - if (nextIf('_')) - return 0; - int num = demangleNatural(); - if (num >= 0 && nextIf('_')) - return num + 1; - return -1000; -} - -NodePointer Demangler::demangleIndexAsNode() { - int Idx = demangleIndex(); - if (Idx >= 0) - return createNode(Node::Kind::Number, Idx); - return nullptr; -} - -NodePointer Demangler::demangleMultiSubstitutions() { - int RepeatCount = -1; - while (true) { - char c = nextChar(); - if (c == 0) { - // End of text. - return nullptr; - } - if (isLowerLetter(c)) { - // It's a substitution with an index < 26. - NodePointer Nd = pushMultiSubstitutions(RepeatCount, c - 'a'); - if (!Nd) - return nullptr; - pushNode(Nd); - RepeatCount = -1; - // A lowercase letter indicates that there are more substitutions to - // follow. - continue; - } - if (isUpperLetter(c)) { - // The last substitution. - return pushMultiSubstitutions(RepeatCount, c - 'A'); - } - if (c == '_') { - // The previously demangled number is actually not a repeat count but - // the large (> 26) index of a substitution. Because it's an index we - // have to add 27 and not 26. - unsigned Idx = RepeatCount + 27; - if (Idx >= Substitutions.size()) - return nullptr; - return Substitutions[Idx]; - } - pushBack(); - // Not a letter? Then it can only be a natural number which might be the - // repeat count or a large (> 26) substitution index. - RepeatCount = demangleNatural(); - if (RepeatCount < 0) - return nullptr; - } -} - -NodePointer Demangler::pushMultiSubstitutions(int RepeatCount, - size_t SubstIdx) { - if (SubstIdx >= Substitutions.size()) - return nullptr; - if (RepeatCount > SubstitutionMerging::MaxRepeatCount) - return nullptr; - NodePointer Nd = Substitutions[SubstIdx]; - while (RepeatCount-- > 1) { - pushNode(Nd); - } - return Nd; -} - -NodePointer Demangler::createSwiftType(Node::Kind typeKind, const char *name) { - return createType(createWithChildren(typeKind, - createNode(Node::Kind::Module, STDLIB_NAME), - createNode(Node::Kind::Identifier, name))); -} - -NodePointer Demangler::demangleStandardSubstitution() { - switch (char c = nextChar()) { - case 'o': - return createNode(Node::Kind::Module, MANGLING_MODULE_OBJC); - case 'C': - return createNode(Node::Kind::Module, MANGLING_MODULE_CLANG_IMPORTER); - case 'g': { - NodePointer OptionalTy = - createType(createWithChildren(Node::Kind::BoundGenericEnum, - createSwiftType(Node::Kind::Enum, "Optional"), - createWithChild(Node::Kind::TypeList, popNode(Node::Kind::Type)))); - addSubstitution(OptionalTy); - return OptionalTy; - } - default: { - pushBack(); - int RepeatCount = demangleNatural(); - if (RepeatCount > SubstitutionMerging::MaxRepeatCount) - return nullptr; - if (NodePointer Nd = createStandardSubstitution(nextChar())) { - while (RepeatCount-- > 1) { - pushNode(Nd); - } - return Nd; - } - return nullptr; - } - } -} - -NodePointer Demangler::createStandardSubstitution(char Subst) { -#define STANDARD_TYPE(KIND, MANGLING, TYPENAME) \ -if (Subst == #MANGLING[0]) { \ -return createSwiftType(Node::Kind::KIND, #TYPENAME); \ -} - -#include "StandardTypesMangling.def" - return nullptr; -} - -NodePointer Demangler::demangleIdentifier() { - bool hasWordSubsts = false; - bool isPunycoded = false; - char c = peekChar(); - if (!isDigit(c)) - return nullptr; - if (c == '0') { - nextChar(); - if (peekChar() == '0') { - nextChar(); - isPunycoded = true; - } else { - hasWordSubsts = true; - } - } - CharVector Identifier; - do { - while (hasWordSubsts && isLetter(peekChar())) { - char c = nextChar(); - int WordIdx = 0; - if (isLowerLetter(c)) { - WordIdx = c - 'a'; - } else { - assert(isUpperLetter(c)); - WordIdx = c - 'A'; - hasWordSubsts = false; - } - if (WordIdx >= NumWords) - return nullptr; - assert(WordIdx < MaxNumWords); - StringRef Slice = Words[WordIdx]; - Identifier.append(Slice, *this); - } - if (nextIf('0')) - break; - int numChars = demangleNatural(); - if (numChars <= 0) - return nullptr; - if (isPunycoded) - nextIf('_'); - if (Pos + numChars > Text.size()) - return nullptr; - StringRef Slice = StringRef(Text.data() + Pos, numChars); - if (isPunycoded) { - std::string PunycodedString; - if (!Punycode::decodePunycodeUTF8(Slice, PunycodedString)) - return nullptr; - Identifier.append(StringRef(PunycodedString), *this); - } else { - Identifier.append(Slice, *this); - int wordStartPos = -1; - for (int Idx = 0, End = (int)Slice.size(); Idx <= End; ++Idx) { - char c = (Idx < End ? Slice[Idx] : 0); - if (wordStartPos >= 0 && isWordEnd(c, Slice[Idx - 1])) { - if (Idx - wordStartPos >= 2 && NumWords < MaxNumWords) { - StringRef word(Slice.begin() + wordStartPos, Idx - wordStartPos); - Words[NumWords++] = word; - } - wordStartPos = -1; - } - if (wordStartPos < 0 && isWordStart(c)) { - wordStartPos = Idx; - } - } - } - Pos += numChars; - } while (hasWordSubsts); - - if (Identifier.empty()) - return nullptr; - NodePointer Ident = createNode(Node::Kind::Identifier, Identifier); - addSubstitution(Ident); - return Ident; -} - -NodePointer Demangler::demangleOperatorIdentifier() { - NodePointer Ident = popNode(Node::Kind::Identifier); - if (!Ident) - return nullptr; - - static const char op_char_table[] = "& @/= > <*!|+?%-~ ^ ."; - - CharVector OpStr; - for (signed char c : Ident->getText()) { - if (c < 0) { - // Pass through Unicode characters. - OpStr.push_back(c, *this); - continue; - } - if (!isLowerLetter(c)) - return nullptr; - char o = op_char_table[c - 'a']; - if (o == ' ') - return nullptr; - OpStr.push_back(o, *this); - } - switch (nextChar()) { - case 'i': return createNode(Node::Kind::InfixOperator, OpStr); - case 'p': return createNode(Node::Kind::PrefixOperator, OpStr); - case 'P': return createNode(Node::Kind::PostfixOperator, OpStr); - default: return nullptr; - } -} - -NodePointer Demangler::demangleLocalIdentifier() { - if (nextIf('L')) { - NodePointer discriminator = popNode(Node::Kind::Identifier); - NodePointer name = popNode(isDeclName); - return createWithChildren(Node::Kind::PrivateDeclName, discriminator, name); - } - if (nextIf('l')) { - NodePointer discriminator = popNode(Node::Kind::Identifier); - return createWithChild(Node::Kind::PrivateDeclName, discriminator); - } - if ((peekChar() >= 'a' && peekChar() <= 'j') || - (peekChar() >= 'A' && peekChar() <= 'J')) { - char relatedEntityKind = nextChar(); - NodePointer name = popNode(); - NodePointer result = createNode(Node::Kind::RelatedEntityDeclName, - StringRef(&relatedEntityKind, 1)); - return addChild(result, name); - } - NodePointer discriminator = demangleIndexAsNode(); - NodePointer name = popNode(isDeclName); - return createWithChildren(Node::Kind::LocalDeclName, discriminator, name); -} - -NodePointer Demangler::popModule() { - if (NodePointer Ident = popNode(Node::Kind::Identifier)) - return changeKind(Ident, Node::Kind::Module); - return popNode(Node::Kind::Module); -} - -NodePointer Demangler::popContext() { - if (NodePointer Mod = popModule()) - return Mod; - - if (NodePointer Ty = popNode(Node::Kind::Type)) { - if (Ty->getNumChildren() != 1) - return nullptr; - NodePointer Child = Ty->getFirstChild(); - if (!isContext(Child->getKind())) - return nullptr; - return Child; - } - return popNode(isContext); -} - -NodePointer Demangler::popTypeAndGetChild() { - NodePointer Ty = popNode(Node::Kind::Type); - if (!Ty || Ty->getNumChildren() != 1) - return nullptr; - return Ty->getFirstChild(); -} - -NodePointer Demangler::popTypeAndGetAnyGeneric() { - NodePointer Child = popTypeAndGetChild(); - if (Child && isAnyGeneric(Child->getKind())) - return Child; - return nullptr; -} - -NodePointer Demangler::demangleBuiltinType() { - NodePointer Ty = nullptr; - const int maxTypeSize = 4096; // a very conservative upper bound - switch (nextChar()) { - case 'b': - Ty = createNode(Node::Kind::BuiltinTypeName, - BUILTIN_TYPE_NAME_BRIDGEOBJECT); - break; - case 'B': - Ty = createNode(Node::Kind::BuiltinTypeName, - BUILTIN_TYPE_NAME_UNSAFEVALUEBUFFER); - break; - case 'f': { - int size = demangleIndex() - 1; - if (size <= 0 || size > maxTypeSize) - return nullptr; - CharVector name; - name.append(BUILTIN_TYPE_NAME_FLOAT, *this); - name.append(size, *this); - Ty = createNode(Node::Kind::BuiltinTypeName, name); - break; - } - case 'i': { - int size = demangleIndex() - 1; - if (size <= 0 || size > maxTypeSize) - return nullptr; - CharVector name; - name.append(BUILTIN_TYPE_NAME_INT, *this); - name.append(size, *this); - Ty = createNode(Node::Kind::BuiltinTypeName, name); - break; - } - case 'I': - Ty = createNode(Node::Kind::BuiltinTypeName, - BUILTIN_TYPE_NAME_INTLITERAL); - break; - case 'v': { - int elts = demangleIndex() - 1; - if (elts <= 0 || elts > maxTypeSize) - return nullptr; - NodePointer EltType = popTypeAndGetChild(); - if (!EltType || EltType->getKind() != Node::Kind::BuiltinTypeName || - !EltType->getText().startswith(BUILTIN_TYPE_NAME_PREFIX)) - return nullptr; - CharVector name; - name.append(BUILTIN_TYPE_NAME_VEC, *this); - name.append(elts, *this); - name.push_back('x', *this); - name.append(EltType->getText().substr(strlen(BUILTIN_TYPE_NAME_PREFIX)), *this); - Ty = createNode(Node::Kind::BuiltinTypeName, name); - break; - } - case 'O': - Ty = createNode(Node::Kind::BuiltinTypeName, - BUILTIN_TYPE_NAME_UNKNOWNOBJECT); - break; - case 'o': - Ty = createNode(Node::Kind::BuiltinTypeName, - BUILTIN_TYPE_NAME_NATIVEOBJECT); - break; - case 'p': - Ty = createNode(Node::Kind::BuiltinTypeName, - BUILTIN_TYPE_NAME_RAWPOINTER); - break; - case 't': - Ty = createNode(Node::Kind::BuiltinTypeName, BUILTIN_TYPE_NAME_SILTOKEN); - break; - case 'w': - Ty = createNode(Node::Kind::BuiltinTypeName, - BUILTIN_TYPE_NAME_WORD); - break; - default: - return nullptr; - } - return createType(Ty); -} - -NodePointer Demangler::demangleAnyGenericType(Node::Kind kind) { - NodePointer Name = popNode(isDeclName); - NodePointer Ctx = popContext(); - NodePointer NTy = createType(createWithChildren(kind, Ctx, Name)); - addSubstitution(NTy); - return NTy; -} - -NodePointer Demangler::demangleExtensionContext() { - NodePointer GenSig = popNode(Node::Kind::DependentGenericSignature); - NodePointer Module = popModule(); - NodePointer Type = popTypeAndGetAnyGeneric(); - NodePointer Ext = createWithChildren(Node::Kind::Extension, Module, Type); - if (GenSig) - Ext = addChild(Ext, GenSig); - return Ext; -} - -NodePointer Demangler::demanglePlainFunction() { - NodePointer GenSig = popNode(Node::Kind::DependentGenericSignature); - NodePointer Type = popFunctionType(Node::Kind::FunctionType); - NodePointer LabelList = popFunctionParamLabels(Type); - - if (GenSig) { - Type = createType(createWithChildren(Node::Kind::DependentGenericType, - GenSig, Type)); - } - - auto Name = popNode(isDeclName); - auto Ctx = popContext(); - - if (LabelList) - return createWithChildren(Node::Kind::Function, Ctx, Name, LabelList, Type); - - return createWithChildren(Node::Kind::Function, Ctx, Name, Type); -} - -NodePointer Demangler::popFunctionType(Node::Kind kind) { - NodePointer FuncType = createNode(kind); - addChild(FuncType, popNode(Node::Kind::ThrowsAnnotation)); - - FuncType = addChild(FuncType, popFunctionParams(Node::Kind::ArgumentTuple)); - FuncType = addChild(FuncType, popFunctionParams(Node::Kind::ReturnType)); - return createType(FuncType); -} - -NodePointer Demangler::popFunctionParams(Node::Kind kind) { - NodePointer ParamsType = nullptr; - if (popNode(Node::Kind::EmptyList)) { - ParamsType = createType(createNode(Node::Kind::Tuple)); - } else { - ParamsType = popNode(Node::Kind::Type); - } - - NodePointer Node = nullptr; - // Store the number of parameters in the argument tuple - // node to make it easier to reach it, see `popFunctionParamLabels`. - if (ParamsType && kind == Node::Kind::ArgumentTuple) { - auto Params = ParamsType->getFirstChild(); - Node::IndexType NumParams = - Params->getKind() == Node::Kind::Tuple ? Params->getNumChildren() : 1; - Node = createNode(kind, NumParams); - } else { - Node = createNode(kind); - } - - return addChild(Node, ParamsType); -} - -NodePointer Demangler::popFunctionParamLabels(NodePointer Type) { - if (!IsOldFunctionTypeMangling && popNode(Node::Kind::EmptyList)) - return createNode(Node::Kind::LabelList); - - if (!Type || Type->getKind() != Node::Kind::Type) - return nullptr; - - auto FuncType = Type->getFirstChild(); - if (FuncType->getKind() == Node::Kind::DependentGenericType) - FuncType = FuncType->getChild(1)->getFirstChild(); - - if (FuncType->getKind() != Node::Kind::FunctionType && - FuncType->getKind() != Node::Kind::NoEscapeFunctionType) - return nullptr; - - auto ParameterType = FuncType->getFirstChild(); - if (ParameterType->getKind() == Node::Kind::ThrowsAnnotation) - ParameterType = FuncType->getChild(1); - - assert(ParameterType->getKind() == Node::Kind::ArgumentTuple); - if (ParameterType->getIndex() == 0) - return nullptr; - - auto getChildIf = - [](NodePointer Node, - Node::Kind filterBy) -> std::pair { - for (unsigned long i = 0, n = Node->getNumChildren(); i != n; ++i) { - auto Child = Node->getChild(i); - if (Child->getKind() == filterBy) - return {Child, i}; - } - return {nullptr, 0}; - }; - - auto getLabel = [&](NodePointer Params, unsigned long Idx) -> NodePointer { - // Old-style function type mangling has labels as part of the argument. - if (IsOldFunctionTypeMangling) { - auto Param = Params->getChild(Idx); - auto Label = getChildIf(Param, Node::Kind::TupleElementName); - - if (Label.first) { - Param->removeChildAt(Label.second, *this); - return createNodeWithAllocatedText(Node::Kind::Identifier, - Label.first->getText()); - } - - return createNode(Node::Kind::FirstElementMarker); - } - - return popNode(); - }; - - auto LabelList = createNode(Node::Kind::LabelList); - auto Tuple = ParameterType->getFirstChild()->getFirstChild(); - - if (IsOldFunctionTypeMangling && - (!Tuple || Tuple->getKind() != Node::Kind::Tuple)) - return LabelList; - - bool hasLabels = false; - for (unsigned long long i = 0, n = ParameterType->getIndex(); i != n; ++i) { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wshorten-64-to-32" - auto Label = getLabel(Tuple, i); -#pragma clang diagnostic pop - - if (!Label) - return nullptr; - - if (Label->getKind() != Node::Kind::Identifier && - Label->getKind() != Node::Kind::FirstElementMarker) - return nullptr; - - LabelList->addChild(Label, *this); - hasLabels |= Label->getKind() != Node::Kind::FirstElementMarker; - } - - // Old style label mangling can produce label list without - // actual labels, we need to support that case specifically. - if (!hasLabels) - return createNode(Node::Kind::LabelList); - - if (!IsOldFunctionTypeMangling) - LabelList->reverseChildren(); - - return LabelList; -} - -NodePointer Demangler::popTuple() { - NodePointer Root = createNode(Node::Kind::Tuple); - - if (!popNode(Node::Kind::EmptyList)) { - bool firstElem = false; - do { - firstElem = (popNode(Node::Kind::FirstElementMarker) != nullptr); - NodePointer TupleElmt = createNode(Node::Kind::TupleElement); - addChild(TupleElmt, popNode(Node::Kind::VariadicMarker)); - if (NodePointer Ident = popNode(Node::Kind::Identifier)) { - TupleElmt->addChild(createNodeWithAllocatedText( - Node::Kind::TupleElementName, Ident->getText()), - *this); - } - NodePointer Ty = popNode(Node::Kind::Type); - if (!Ty) - return nullptr; - TupleElmt->addChild(Ty, *this); - Root->addChild(TupleElmt, *this); - } while (!firstElem); - - Root->reverseChildren(); - } - return createType(Root); -} - -NodePointer Demangler::popTypeList() { - NodePointer Root = createNode(Node::Kind::TypeList); - - if (!popNode(Node::Kind::EmptyList)) { - bool firstElem = false; - do { - firstElem = (popNode(Node::Kind::FirstElementMarker) != nullptr); - NodePointer Ty = popNode(Node::Kind::Type); - if (!Ty) - return nullptr; - Root->addChild(Ty, *this); - } while (!firstElem); - - Root->reverseChildren(); - } - return Root; -} - -NodePointer Demangler::popProtocol() { - if (NodePointer Type = popNode(Node::Kind::Type)) { - if (Type->getNumChildren() < 1) - return nullptr; - - if (!isProtocolNode(Type)) - return nullptr; - - return Type; - } - - if (NodePointer SymbolicRef = popNode(Node::Kind::ProtocolSymbolicReference)){ - return SymbolicRef; - } - - NodePointer Name = popNode(isDeclName); - NodePointer Ctx = popContext(); - NodePointer Proto = createWithChildren(Node::Kind::Protocol, Ctx, Name); - return createType(Proto); -} - -NodePointer Demangler::popAnyProtocolConformanceList() { - NodePointer conformanceList - = createNode(Node::Kind::AnyProtocolConformanceList); - if (!popNode(Node::Kind::EmptyList)) { - bool firstElem = false; - do { - firstElem = (popNode(Node::Kind::FirstElementMarker) != nullptr); - NodePointer anyConformance = popAnyProtocolConformance(); - if (!anyConformance) - return nullptr; - conformanceList->addChild(anyConformance, *this); - } while (!firstElem); - - conformanceList->reverseChildren(); - } - return conformanceList; -} - -NodePointer Demangler::popAnyProtocolConformance() { - return popNode([](Node::Kind kind) { - switch (kind) { - case Node::Kind::ConcreteProtocolConformance: - case Node::Kind::DependentProtocolConformanceRoot: - case Node::Kind::DependentProtocolConformanceInherited: - case Node::Kind::DependentProtocolConformanceAssociated: - return true; - - default: - return false; - } - }); -} - -NodePointer Demangler::demangleRetroactiveProtocolConformanceRef() { - NodePointer module = popModule(); - NodePointer proto = popProtocol(); - auto protocolConformanceRef = - createWithChildren(Node::Kind::ProtocolConformanceRefInOtherModule, - proto, module); - return protocolConformanceRef; -} - -NodePointer Demangler::demangleConcreteProtocolConformance() { - NodePointer conditionalConformanceList = popAnyProtocolConformanceList(); - - NodePointer conformanceRef = - popNode(Node::Kind::ProtocolConformanceRefInTypeModule); - if (!conformanceRef) { - conformanceRef = - popNode(Node::Kind::ProtocolConformanceRefInProtocolModule); - } - if (!conformanceRef) - conformanceRef = demangleRetroactiveProtocolConformanceRef(); - - NodePointer type = popNode(Node::Kind::Type); - return createWithChildren(Node::Kind::ConcreteProtocolConformance, - type, conformanceRef, conditionalConformanceList); -} - -NodePointer Demangler::popDependentProtocolConformance() { - return popNode([](Node::Kind kind) { - switch (kind) { - case Node::Kind::DependentProtocolConformanceRoot: - case Node::Kind::DependentProtocolConformanceInherited: - case Node::Kind::DependentProtocolConformanceAssociated: - return true; - - default: - return false; - } - }); -} - -NodePointer Demangler::demangleDependentProtocolConformanceRoot() { - int index = demangleIndex(); - NodePointer conformance = - index > 0 ? createNode(Node::Kind::DependentProtocolConformanceRoot, - index - 1) - : createNode(Node::Kind::DependentProtocolConformanceRoot); - - if (NodePointer protocol = popProtocol()) - conformance->addChild(protocol, *this); - else - return nullptr; - - if (NodePointer dependentType = popNode(Node::Kind::Type)) - conformance->addChild(dependentType, *this); - else - return nullptr; - - return conformance; -} - -NodePointer Demangler::demangleDependentProtocolConformanceInherited() { - int index = demangleIndex(); - NodePointer conformance = - index > 0 ? createNode(Node::Kind::DependentProtocolConformanceInherited, - index - 1) - : createNode(Node::Kind::DependentProtocolConformanceInherited); - - if (NodePointer protocol = popProtocol()) - conformance->addChild(protocol, *this); - else - return nullptr; - - if (auto nested = popDependentProtocolConformance()) - conformance->addChild(nested, *this); - else - return nullptr; - - conformance->reverseChildren(); - return conformance; -} - -NodePointer Demangler::popDependentAssociatedConformance() { - NodePointer protocol = popProtocol(); - NodePointer dependentType = popNode(Node::Kind::Type); - return createWithChildren(Node::Kind::DependentAssociatedConformance, - dependentType, protocol); -} - -NodePointer Demangler::demangleDependentProtocolConformanceAssociated() { - int index = demangleIndex(); - NodePointer conformance = - index > 0 ? createNode(Node::Kind::DependentProtocolConformanceRoot, - index - 1) - : createNode(Node::Kind::DependentProtocolConformanceRoot); - - if (NodePointer associatedConformance = popDependentAssociatedConformance()) - conformance->addChild(associatedConformance, *this); - else - return nullptr; - - if (auto nested = popDependentProtocolConformance()) - conformance->addChild(nested, *this); - else - return nullptr; - - conformance->reverseChildren(); - - return conformance; -} - -NodePointer Demangler::demangleRetroactiveConformance() { - int index = demangleIndex(); - if (index < 0) - return nullptr; - - NodePointer conformance = popAnyProtocolConformance(); - if (!conformance) - return nullptr; - - auto retroactiveConformance = - createNode(Node::Kind::RetroactiveConformance, index); - retroactiveConformance->addChild(conformance, *this); - return retroactiveConformance; -} - -NodePointer Demangler::demangleBoundGenericType() { - NodePointer RetroactiveConformances = nullptr; - while (auto RetroactiveConformance = - popNode(Node::Kind::RetroactiveConformance)) { - if (!RetroactiveConformances) - RetroactiveConformances = createNode(Node::Kind::TypeList); - RetroactiveConformances->addChild(RetroactiveConformance, *this); - } - if (RetroactiveConformances) - RetroactiveConformances->reverseChildren(); - - Vector TypeListList(*this, 4); - for (;;) { - NodePointer TList = createNode(Node::Kind::TypeList); - TypeListList.push_back(TList, *this); - while (NodePointer Ty = popNode(Node::Kind::Type)) { - TList->addChild(Ty, *this); - } - TList->reverseChildren(); - - if (popNode(Node::Kind::EmptyList)) - break; - if (!popNode(Node::Kind::FirstElementMarker)) - return nullptr; - } - NodePointer Nominal = popTypeAndGetAnyGeneric(); - NodePointer BoundNode = demangleBoundGenericArgs(Nominal, TypeListList, 0); - addChild(BoundNode, RetroactiveConformances); - NodePointer NTy = createType(BoundNode); - addSubstitution(NTy); - return NTy; -} - -bool Demangle::nodeConsumesGenericArgs(Node *node) { - switch (node->getKind()) { - case Node::Kind::Variable: - case Node::Kind::Subscript: - case Node::Kind::ImplicitClosure: - case Node::Kind::ExplicitClosure: - case Node::Kind::DefaultArgumentInitializer: - case Node::Kind::Initializer: - return false; - default: - return true; - } -} - -NodePointer Demangler::demangleBoundGenericArgs(NodePointer Nominal, - const Vector &TypeLists, - size_t TypeListIdx) { - // TODO: This would be a lot easier if we represented bound generic args - // flatly in the demangling tree, since that's how they're mangled and also - // how the runtime generally wants to consume them. - - if (!Nominal) - return nullptr; - - if (TypeListIdx >= TypeLists.size()) - return nullptr; - - // Associate a context symbolic reference with all remaining generic - // arguments. - if (Nominal->getKind() == Node::Kind::TypeSymbolicReference - || Nominal->getKind() == Node::Kind::ProtocolSymbolicReference) { - auto remainingTypeList = createNode(Node::Kind::TypeList); - for (unsigned long i = TypeLists.size() - 1; - i >= TypeListIdx && i < TypeLists.size(); - --i) { - auto list = TypeLists[i]; - for (auto child : *list) { - remainingTypeList->addChild(child, *this); - } - } - return createWithChildren(Node::Kind::BoundGenericOtherNominalType, - createType(Nominal), remainingTypeList); - } - - // Generic arguments for the outermost type come first. - if (Nominal->getNumChildren() == 0) - return nullptr; - NodePointer Context = Nominal->getFirstChild(); - - bool consumesGenericArgs = nodeConsumesGenericArgs(Nominal); - - NodePointer args = TypeLists[TypeListIdx]; - - if (consumesGenericArgs) - ++TypeListIdx; - - if (TypeListIdx < TypeLists.size()) { - NodePointer BoundParent = nullptr; - if (Context->getKind() == Node::Kind::Extension) { - BoundParent = demangleBoundGenericArgs(Context->getChild(1), TypeLists, - TypeListIdx); - BoundParent = createWithChildren(Node::Kind::Extension, - Context->getFirstChild(), - BoundParent); - if (Context->getNumChildren() == 3) { - // Add the generic signature of the extension context. - addChild(BoundParent, Context->getChild(2)); - } - } else { - BoundParent = demangleBoundGenericArgs(Context, TypeLists, TypeListIdx); - } - // Rebuild this type with the new parent type, which may have - // had its generic arguments applied. - NodePointer NewNominal = createWithChild(Nominal->getKind(), BoundParent); - if (!NewNominal) - return nullptr; - - // Append remaining children of the origin nominal. - for (unsigned Idx = 1; Idx < Nominal->getNumChildren(); ++Idx) { - addChild(NewNominal, Nominal->getChild(Idx)); - } - Nominal = NewNominal; - } - if (!consumesGenericArgs) - return Nominal; - - // If there were no arguments at this level there is nothing left - // to do. - if (args->getNumChildren() == 0) - return Nominal; - - Node::Kind kind; - switch (Nominal->getKind()) { - case Node::Kind::Class: - kind = Node::Kind::BoundGenericClass; - break; - case Node::Kind::Structure: - kind = Node::Kind::BoundGenericStructure; - break; - case Node::Kind::Enum: - kind = Node::Kind::BoundGenericEnum; - break; - case Node::Kind::Protocol: - kind = Node::Kind::BoundGenericProtocol; - break; - case Node::Kind::OtherNominalType: - kind = Node::Kind::BoundGenericOtherNominalType; - break; - case Node::Kind::TypeAlias: - kind = Node::Kind::BoundGenericTypeAlias; - break; - case Node::Kind::Function: - case Node::Kind::Constructor: - // Well, not really a nominal type. - return createWithChildren(Node::Kind::BoundGenericFunction, Nominal, args); - default: - return nullptr; - } - return createWithChildren(kind, createType(Nominal), args); -} - -NodePointer Demangler::demangleImplParamConvention() { - const char *attr = nullptr; - switch (nextChar()) { - case 'i': attr = "@in"; break; - case 'c': - attr = "@in_constant"; - break; - case 'l': attr = "@inout"; break; - case 'b': attr = "@inout_aliasable"; break; - case 'n': attr = "@in_guaranteed"; break; - case 'x': attr = "@owned"; break; - case 'g': attr = "@guaranteed"; break; - case 'e': attr = "@deallocating"; break; - case 'y': attr = "@unowned"; break; - default: - pushBack(); - return nullptr; - } - return createWithChild(Node::Kind::ImplParameter, - createNode(Node::Kind::ImplConvention, attr)); -} - -NodePointer Demangler::demangleImplResultConvention(Node::Kind ConvKind) { - const char *attr = nullptr; - switch (nextChar()) { - case 'r': attr = "@out"; break; - case 'o': attr = "@owned"; break; - case 'd': attr = "@unowned"; break; - case 'u': attr = "@unowned_inner_pointer"; break; - case 'a': attr = "@autoreleased"; break; - default: - pushBack(); - return nullptr; - } - return createWithChild(ConvKind, - createNode(Node::Kind::ImplConvention, attr)); -} - -NodePointer Demangler::demangleImplFunctionType() { - NodePointer type = createNode(Node::Kind::ImplFunctionType); - - NodePointer GenSig = popNode(Node::Kind::DependentGenericSignature); - if (GenSig && nextIf('P')) - GenSig = changeKind(GenSig, Node::Kind::DependentPseudogenericSignature); - - if (nextIf('e')) - type->addChild(createNode(Node::Kind::ImplEscaping), *this); - - const char *CAttr = nullptr; - switch (nextChar()) { - case 'y': CAttr = "@callee_unowned"; break; - case 'g': CAttr = "@callee_guaranteed"; break; - case 'x': CAttr = "@callee_owned"; break; - case 't': CAttr = "@convention(thin)"; break; - default: return nullptr; - } - type->addChild(createNode(Node::Kind::ImplConvention, CAttr), *this); - - const char *FAttr = nullptr; - switch (nextChar()) { - case 'B': FAttr = "@convention(block)"; break; - case 'C': FAttr = "@convention(c)"; break; - case 'M': FAttr = "@convention(method)"; break; - case 'O': FAttr = "@convention(objc_method)"; break; - case 'K': FAttr = "@convention(closure)"; break; - case 'W': FAttr = "@convention(witness_method)"; break; - default: - pushBack(); - break; - } - if (FAttr) - type->addChild(createNode(Node::Kind::ImplFunctionAttribute, FAttr), *this); - - addChild(type, GenSig); - - int NumTypesToAdd = 0; - while (NodePointer Param = demangleImplParamConvention()) { - type = addChild(type, Param); - NumTypesToAdd++; - } - while (NodePointer Result = demangleImplResultConvention( - Node::Kind::ImplResult)) { - type = addChild(type, Result); - NumTypesToAdd++; - } - if (nextIf('z')) { - NodePointer ErrorResult = demangleImplResultConvention( - Node::Kind::ImplErrorResult); - if (!ErrorResult) - return nullptr; - type = addChild(type, ErrorResult); - NumTypesToAdd++; - } - if (!nextIf('_')) - return nullptr; - - for (int Idx = 0; Idx < NumTypesToAdd; ++Idx) { - NodePointer ConvTy = popNode(Node::Kind::Type); - if (!ConvTy) - return nullptr; - type->getChild(type->getNumChildren() - Idx - 1)->addChild(ConvTy, *this); - } - return createType(type); -} - -NodePointer Demangler::demangleMetatype() { - switch (nextChar()) { - case 'c': - return createWithChild(Node::Kind::ProtocolConformanceDescriptor, - popProtocolConformance()); - case 'f': - return createWithPoppedType(Node::Kind::FullTypeMetadata); - case 'P': - return createWithPoppedType(Node::Kind::GenericTypeMetadataPattern); - case 'a': - return createWithPoppedType(Node::Kind::TypeMetadataAccessFunction); - case 'I': - return createWithPoppedType(Node::Kind::TypeMetadataInstantiationCache); - case 'i': - return createWithPoppedType(Node::Kind::TypeMetadataInstantiationFunction); - case 'r': - return createWithPoppedType(Node::Kind::TypeMetadataCompletionFunction); - case 'l': - return createWithPoppedType( - Node::Kind::TypeMetadataSingletonInitializationCache); - case 'L': - return createWithPoppedType(Node::Kind::TypeMetadataLazyCache); - case 'm': - return createWithPoppedType(Node::Kind::Metaclass); - case 'n': - return createWithPoppedType(Node::Kind::NominalTypeDescriptor); - case 'o': - return createWithPoppedType(Node::Kind::ClassMetadataBaseOffset); - case 'p': - return createWithChild(Node::Kind::ProtocolDescriptor, popProtocol()); - case 'S': - return createWithChild(Node::Kind::ProtocolSelfConformanceDescriptor, - popProtocol()); - case 'u': - return createWithPoppedType(Node::Kind::MethodLookupFunction); - case 'U': - return createWithPoppedType(Node::Kind::ObjCMetadataUpdateFunction); - case 'B': - return createWithChild(Node::Kind::ReflectionMetadataBuiltinDescriptor, - popNode(Node::Kind::Type)); - case 'F': - return createWithChild(Node::Kind::ReflectionMetadataFieldDescriptor, - popNode(Node::Kind::Type)); - case 'A': - return createWithChild(Node::Kind::ReflectionMetadataAssocTypeDescriptor, - popProtocolConformance()); - case 'C': { - NodePointer Ty = popNode(Node::Kind::Type); - if (!Ty || !isAnyGeneric(Ty->getChild(0)->getKind())) - return nullptr; - return createWithChild(Node::Kind::ReflectionMetadataSuperclassDescriptor, - Ty->getChild(0)); - } - case 'V': - return createWithChild(Node::Kind::PropertyDescriptor, - popNode(isEntity)); - case 'X': - return demanglePrivateContextDescriptor(); - default: - return nullptr; - } -} - -NodePointer Demangler::demanglePrivateContextDescriptor() { - switch (nextChar()) { - case 'E': { - auto Extension = popContext(); - if (!Extension) - return nullptr; - return createWithChild(Node::Kind::ExtensionDescriptor, Extension); - } - case 'M': { - auto Module = popModule(); - if (!Module) - return nullptr; - return createWithChild(Node::Kind::ModuleDescriptor, Module); - } - case 'Y': { - auto Discriminator = popNode(); - if (!Discriminator) - return nullptr; - auto Context = popContext(); - if (!Context) - return nullptr; - - auto node = createNode(Node::Kind::AnonymousDescriptor); - node->addChild(Context, *this); - node->addChild(Discriminator, *this); - return node; - } - case 'X': { - auto Context = popContext(); - if (!Context) - return nullptr; - return createWithChild(Node::Kind::AnonymousDescriptor, Context); - } - case 'A': { - auto path = popAssocTypePath(); - if (!path) - return nullptr; - auto base = popNode(Node::Kind::Type); - if (!base) - return nullptr; - return createWithChildren(Node::Kind::AssociatedTypeGenericParamRef, - base, path); - } - default: - return nullptr; - } -} - -NodePointer Demangler::demangleArchetype() { - switch (nextChar()) { - case 'a': { - NodePointer Ident = popNode(Node::Kind::Identifier); - NodePointer ArcheTy = popTypeAndGetChild(); - NodePointer AssocTy = createType( - createWithChildren(Node::Kind::AssociatedTypeRef, ArcheTy, Ident)); - addSubstitution(AssocTy); - return AssocTy; - } - case 'y': { - NodePointer T = demangleAssociatedTypeSimple(demangleGenericParamIndex()); - addSubstitution(T); - return T; - } - case 'z': { - NodePointer T = demangleAssociatedTypeSimple(getDependentGenericParamType(0, 0)); - addSubstitution(T); - return T; - } - case 'Y': { - NodePointer T = demangleAssociatedTypeCompound(demangleGenericParamIndex()); - addSubstitution(T); - return T; - } - case 'Z': { - NodePointer T = demangleAssociatedTypeCompound(getDependentGenericParamType(0, 0)); - addSubstitution(T); - return T; - } - default: - return nullptr; - } -} - -NodePointer Demangler::demangleAssociatedTypeSimple( - NodePointer GenericParamIdx) { - NodePointer GPI = createType(GenericParamIdx); - NodePointer ATName = popAssocTypeName(); - return createType(createWithChildren(Node::Kind::DependentMemberType, - GPI, ATName)); -} - -NodePointer Demangler::demangleAssociatedTypeCompound( - NodePointer GenericParamIdx) { - Vector AssocTyNames(*this, 4); - bool firstElem = false; - do { - firstElem = (popNode(Node::Kind::FirstElementMarker) != nullptr); - NodePointer AssocTyName = popAssocTypeName(); - if (!AssocTyName) - return nullptr; - AssocTyNames.push_back(AssocTyName, *this); - } while (!firstElem); - - NodePointer Base = GenericParamIdx; - - while (NodePointer AssocTy = AssocTyNames.pop_back_val()) { - NodePointer depTy = createNode(Node::Kind::DependentMemberType); - depTy = addChild(depTy, createType(Base)); - Base = addChild(depTy, AssocTy); - } - return createType(Base); -} - -NodePointer Demangler::popAssocTypeName() { - NodePointer Proto = popNode(Node::Kind::Type); - if (Proto && !isProtocolNode(Proto)) - return nullptr; - - // If we haven't seen a protocol, check for a symbolic reference. - if (!Proto) - Proto = popNode(Node::Kind::ProtocolSymbolicReference); - - NodePointer Id = popNode(Node::Kind::Identifier); - NodePointer AssocTy = changeKind(Id, Node::Kind::DependentAssociatedTypeRef); - addChild(AssocTy, Proto); - return AssocTy; -} - -NodePointer Demangler::popAssocTypePath() { - NodePointer AssocTypePath = createNode(Node::Kind::AssocTypePath); - bool firstElem = false; - do { - firstElem = (popNode(Node::Kind::FirstElementMarker) != nullptr); - NodePointer AssocTy = popAssocTypeName(); - if (!AssocTy) - return nullptr; - AssocTypePath->addChild(AssocTy, *this); - } while (!firstElem); - AssocTypePath->reverseChildren(); - return AssocTypePath; -} - -NodePointer Demangler::getDependentGenericParamType(int depth, int index) { - if (depth < 0 || index < 0) - return nullptr; - - CharVector name; - int idxChar = index; - do { - name.push_back((char)('A' + (idxChar % 26)), *this); - idxChar /= 26; - } while (idxChar); - if (depth != 0) - name.append(depth, *this); - - auto paramTy = createNode(Node::Kind::DependentGenericParamType, name); - paramTy->addChild(createNode(Node::Kind::Index, depth), *this); - paramTy->addChild(createNode(Node::Kind::Index, index), *this); - return paramTy; -} - -NodePointer Demangler::demangleGenericParamIndex() { - if (nextIf('d')) { - int depth = demangleIndex() + 1; - int index = demangleIndex(); - return getDependentGenericParamType(depth, index); - } - if (nextIf('z')) { - return getDependentGenericParamType(0, 0); - } - return getDependentGenericParamType(0, demangleIndex() + 1); -} - -NodePointer Demangler::popProtocolConformance() { - NodePointer GenSig = popNode(Node::Kind::DependentGenericSignature); - NodePointer Module = popModule(); - NodePointer Proto = popProtocol(); - NodePointer Type = popNode(Node::Kind::Type); - NodePointer Ident = nullptr; - if (!Type) { - // Property behavior conformance - Ident = popNode(Node::Kind::Identifier); - Type = popNode(Node::Kind::Type); - } - if (GenSig) { - Type = createType(createWithChildren(Node::Kind::DependentGenericType, - GenSig, Type)); - } - NodePointer Conf = createWithChildren(Node::Kind::ProtocolConformance, - Type, Proto, Module); - addChild(Conf, Ident); - return Conf; -} - -NodePointer Demangler::demangleThunkOrSpecialization() { - switch (char c = nextChar()) { - case 'c': return createWithChild(Node::Kind::CurryThunk, popNode(isEntity)); - case 'j': return createWithChild(Node::Kind::DispatchThunk, popNode(isEntity)); - case 'q': return createWithChild(Node::Kind::MethodDescriptor, popNode(isEntity)); - case 'o': return createNode(Node::Kind::ObjCAttribute); - case 'O': return createNode(Node::Kind::NonObjCAttribute); - case 'D': return createNode(Node::Kind::DynamicAttribute); - case 'd': return createNode(Node::Kind::DirectMethodReferenceAttribute); - case 'a': return createNode(Node::Kind::PartialApplyObjCForwarder); - case 'A': return createNode(Node::Kind::PartialApplyForwarder); - case 'm': return createNode(Node::Kind::MergedFunction); - case 'X': return createNode(Node::Kind::DynamicallyReplaceableFunctionVar); - case 'x': return createNode(Node::Kind::DynamicallyReplaceableFunctionKey); - case 'I': return createNode(Node::Kind::DynamicallyReplaceableFunctionImpl); - case 'C': { - NodePointer type = popNode(Node::Kind::Type); - return createWithChild(Node::Kind::CoroutineContinuationPrototype, type); - } - case 'V': { - NodePointer Base = popNode(isEntity); - NodePointer Derived = popNode(isEntity); - return createWithChildren(Node::Kind::VTableThunk, Derived, Base); - } - case 'W': { - NodePointer Entity = popNode(isEntity); - NodePointer Conf = popProtocolConformance(); - return createWithChildren(Node::Kind::ProtocolWitness, Conf, Entity); - } - case 'S': - return createWithChild(Node::Kind::ProtocolSelfConformanceWitness, - popNode(isEntity)); - case 'R': - case 'r': { - NodePointer Thunk = createNode(c == 'R' ? - Node::Kind::ReabstractionThunkHelper : - Node::Kind::ReabstractionThunk); - if (NodePointer GenSig = popNode(Node::Kind::DependentGenericSignature)) - addChild(Thunk, GenSig); - NodePointer Ty2 = popNode(Node::Kind::Type); - Thunk = addChild(Thunk, popNode(Node::Kind::Type)); - return addChild(Thunk, Ty2); - } - case 'g': - return demangleGenericSpecialization(Node::Kind::GenericSpecialization); - case 'G': - return demangleGenericSpecialization(Node::Kind:: - GenericSpecializationNotReAbstracted); - case 'i': - return demangleGenericSpecialization(Node::Kind::InlinedGenericFunction); - case'p': { - NodePointer Spec = demangleSpecAttributes(Node::Kind:: - GenericPartialSpecialization); - NodePointer Param = createWithChild(Node::Kind::GenericSpecializationParam, - popNode(Node::Kind::Type)); - return addChild(Spec, Param); - } - case'P': { - NodePointer Spec = demangleSpecAttributes(Node::Kind:: - GenericPartialSpecializationNotReAbstracted); - NodePointer Param = createWithChild(Node::Kind::GenericSpecializationParam, - popNode(Node::Kind::Type)); - return addChild(Spec, Param); - } - case'f': - return demangleFunctionSpecialization(); - case 'K': - case 'k': { - auto nodeKind = c == 'K' ? Node::Kind::KeyPathGetterThunkHelper - : Node::Kind::KeyPathSetterThunkHelper; - - bool isSerialized = nextIf('q'); - - std::vector types; - auto node = popNode(); - if (!node || node->getKind() != Node::Kind::Type) - return nullptr; - do { - types.push_back(node); - node = popNode(); - } while (node && node->getKind() == Node::Kind::Type); - - NodePointer result; - if (node) { - if (node->getKind() == Node::Kind::DependentGenericSignature) { - auto decl = popNode(); - if (!decl) - return nullptr; - result = createWithChildren(nodeKind, decl, /*sig*/ node); - } else { - result = createWithChild(nodeKind, /*decl*/ node); - } - } else { - return nullptr; - } - for (auto i = types.rbegin(), e = types.rend(); i != e; ++i) { - result->addChild(*i, *this); - } - - if (isSerialized) - result->addChild(createNode(Node::Kind::IsSerialized), *this); - - return result; - } - case 'l': { - auto assocTypeName = popAssocTypeName(); - if (!assocTypeName) - return nullptr; - - return createWithChild(Node::Kind::AssociatedTypeDescriptor, - assocTypeName); - } - case 'L': - return createWithChild(Node::Kind::ProtocolRequirementsBaseDescriptor, - popProtocol()); - case 'M': - return createWithChild(Node::Kind::DefaultAssociatedTypeMetadataAccessor, - popAssocTypeName()); - - case 'n': { - NodePointer requirementTy = popProtocol(); - NodePointer conformingType = popAssocTypePath(); - NodePointer protoTy = popNode(Node::Kind::Type); - return createWithChildren(Node::Kind::AssociatedConformanceDescriptor, - protoTy, conformingType, requirementTy); - } - - case 'N': { - NodePointer requirementTy = popProtocol(); - auto assocTypePath = popAssocTypePath(); - NodePointer protoTy = popNode(Node::Kind::Type); - return createWithChildren( - Node::Kind::DefaultAssociatedConformanceAccessor, - protoTy, assocTypePath, requirementTy); - } - - case 'b': { - NodePointer requirementTy = popProtocol(); - NodePointer protoTy = popNode(Node::Kind::Type); - return createWithChildren(Node::Kind::BaseConformanceDescriptor, - protoTy, requirementTy); - } - - case 'H': - case 'h': { - auto nodeKind = c == 'H' ? Node::Kind::KeyPathEqualsThunkHelper - : Node::Kind::KeyPathHashThunkHelper; - - bool isSerialized = nextIf('q'); - - NodePointer genericSig = nullptr; - std::vector types; - - auto node = popNode(); - if (node) { - if (node->getKind() == Node::Kind::DependentGenericSignature) { - genericSig = node; - } else if (node->getKind() == Node::Kind::Type) { - types.push_back(node); - } else { - return nullptr; - } - } else { - return nullptr; - } - - while (auto node = popNode()) { - if (node->getKind() != Node::Kind::Type) { - return nullptr; - } - types.push_back(node); - } - - NodePointer result = createNode(nodeKind); - for (auto i = types.rbegin(), e = types.rend(); i != e; ++i) { - result->addChild(*i, *this); - } - if (genericSig) - result->addChild(genericSig, *this); - - if (isSerialized) - result->addChild(createNode(Node::Kind::IsSerialized), *this); - - return result; - } - case 'v': { - int Idx = demangleIndex(); - if (Idx < 0) - return nullptr; - return createNode(Node::Kind::OutlinedVariable, Idx); - } - case 'e': { - std::string Params = demangleBridgedMethodParams(); - if (Params.empty()) - return nullptr; - return createNode(Node::Kind::OutlinedBridgedMethod, Params); - } - default: - return nullptr; - } -} - -std::string Demangler::demangleBridgedMethodParams() { - if (nextIf('_')) - return std::string(); - - std::string Str; - - auto kind = nextChar(); - switch (kind) { - default: - return std::string(); - case 'p': case 'a': case 'm': - Str.push_back(kind); - } - - while (!nextIf('_')) { - auto c = nextChar(); - if (!c && c != 'n' && c != 'b') - return std::string(); - Str.push_back(c); - } - return Str; -} - -NodePointer Demangler::demangleGenericSpecialization(Node::Kind SpecKind) { - NodePointer Spec = demangleSpecAttributes(SpecKind); - if (!Spec) - return nullptr; - NodePointer TyList = popTypeList(); - if (!TyList) - return nullptr; - for (NodePointer Ty : *TyList) { - Spec->addChild(createWithChild(Node::Kind::GenericSpecializationParam, Ty), - *this); - } - return Spec; -} - -NodePointer Demangler::demangleFunctionSpecialization() { - NodePointer Spec = demangleSpecAttributes( - Node::Kind::FunctionSignatureSpecialization); - unsigned ParamIdx = 0; - while (Spec && !nextIf('_')) { - Spec = addChild(Spec, demangleFuncSpecParam(ParamIdx)); - ParamIdx++; - } - if (!nextIf('n')) - Spec = addChild(Spec, demangleFuncSpecParam(Node::IndexType(~0))); - - if (!Spec) - return nullptr; - - // Add the required parameters in reverse order. - for (size_t Idx = 0, Num = Spec->getNumChildren(); Idx < Num; ++Idx) { - NodePointer Param = Spec->getChild(Num - Idx - 1); - if (Param->getKind() != Node::Kind::FunctionSignatureSpecializationParam) - continue; - - if (Param->getNumChildren() == 0) - continue; - NodePointer KindNd = Param->getFirstChild(); - assert(KindNd->getKind() == - Node::Kind::FunctionSignatureSpecializationParamKind); - auto ParamKind = (FunctionSigSpecializationParamKind)KindNd->getIndex(); - switch (ParamKind) { - case FunctionSigSpecializationParamKind::ConstantPropFunction: - case FunctionSigSpecializationParamKind::ConstantPropGlobal: - case FunctionSigSpecializationParamKind::ConstantPropString: - case FunctionSigSpecializationParamKind::ClosureProp: { - size_t FixedChildren = Param->getNumChildren(); - while (NodePointer Ty = popNode(Node::Kind::Type)) { - if (ParamKind != FunctionSigSpecializationParamKind::ClosureProp) - return nullptr; - Param = addChild(Param, Ty); - } - NodePointer Name = popNode(Node::Kind::Identifier); - if (!Name) - return nullptr; - StringRef Text = Name->getText(); - if (ParamKind == - FunctionSigSpecializationParamKind::ConstantPropString && - !Text.empty() && Text[0] == '_') { - // A '_' escapes a leading digit or '_' of a string constant. - Text = Text.drop_front(1); - } - addChild(Param, createNodeWithAllocatedText( - Node::Kind::FunctionSignatureSpecializationParamPayload, Text)); - Param->reverseChildren(FixedChildren); - break; - } - default: - break; - } - } - return Spec; -} - -NodePointer Demangler::demangleFuncSpecParam(Node::IndexType ParamIdx) { - NodePointer Param = createNode( - Node::Kind::FunctionSignatureSpecializationParam, ParamIdx); - switch (nextChar()) { - case 'n': - return Param; - case 'c': - // Consumes an identifier and multiple type parameters. - // The parameters will be added later. - return addChild(Param, createNode( - Node::Kind::FunctionSignatureSpecializationParamKind, - uint64_t(FunctionSigSpecializationParamKind::ClosureProp))); - case 'p': { - switch (nextChar()) { - case 'f': - // Consumes an identifier parameter, which will be added later. - return addChild( - Param, - createNode(Node::Kind::FunctionSignatureSpecializationParamKind, - Node::IndexType(FunctionSigSpecializationParamKind:: - ConstantPropFunction))); - case 'g': - // Consumes an identifier parameter, which will be added later. - return addChild( - Param, - createNode( - Node::Kind::FunctionSignatureSpecializationParamKind, - Node::IndexType( - FunctionSigSpecializationParamKind::ConstantPropGlobal))); - case 'i': - return addFuncSpecParamNumber(Param, - FunctionSigSpecializationParamKind::ConstantPropInteger); - case 'd': - return addFuncSpecParamNumber(Param, - FunctionSigSpecializationParamKind::ConstantPropFloat); - case 's': { - // Consumes an identifier parameter (the string constant), - // which will be added later. - const char *Encoding = nullptr; - switch (nextChar()) { - case 'b': Encoding = "u8"; break; - case 'w': Encoding = "u16"; break; - case 'c': Encoding = "objc"; break; - default: return nullptr; - } - addChild(Param, - createNode( - Node::Kind::FunctionSignatureSpecializationParamKind, - Node::IndexType( - swift::Demangle::FunctionSigSpecializationParamKind:: - ConstantPropString))); - return addChild(Param, createNode( - Node::Kind::FunctionSignatureSpecializationParamPayload, - Encoding)); - } - default: - return nullptr; - } - } - case 'e': { - unsigned Value = - unsigned(FunctionSigSpecializationParamKind::ExistentialToGeneric); - if (nextIf('D')) - Value |= unsigned(FunctionSigSpecializationParamKind::Dead); - if (nextIf('G')) - Value |= - unsigned(FunctionSigSpecializationParamKind::OwnedToGuaranteed); - if (nextIf('O')) - Value |= - unsigned(FunctionSigSpecializationParamKind::GuaranteedToOwned); - if (nextIf('X')) - Value |= unsigned(FunctionSigSpecializationParamKind::SROA); - return addChild( - Param, - createNode(Node::Kind::FunctionSignatureSpecializationParamKind, - Value)); - } - case 'd': { - unsigned Value = unsigned(FunctionSigSpecializationParamKind::Dead); - if (nextIf('G')) - Value |= unsigned(FunctionSigSpecializationParamKind::OwnedToGuaranteed); - if (nextIf('O')) - Value |= - unsigned(FunctionSigSpecializationParamKind::GuaranteedToOwned); - if (nextIf('X')) - Value |= unsigned(FunctionSigSpecializationParamKind::SROA); - return addChild(Param, createNode( - Node::Kind::FunctionSignatureSpecializationParamKind, Value)); - } - case 'g': { - unsigned Value = unsigned(FunctionSigSpecializationParamKind:: - OwnedToGuaranteed); - if (nextIf('X')) - Value |= unsigned(FunctionSigSpecializationParamKind::SROA); - return addChild(Param, createNode( - Node::Kind::FunctionSignatureSpecializationParamKind, Value)); - } - case 'o': { - unsigned Value = - unsigned(FunctionSigSpecializationParamKind::GuaranteedToOwned); - if (nextIf('X')) - Value |= unsigned(FunctionSigSpecializationParamKind::SROA); - return addChild( - Param, - createNode(Node::Kind::FunctionSignatureSpecializationParamKind, - Value)); - } - case 'x': - return addChild(Param, createNode( - Node::Kind::FunctionSignatureSpecializationParamKind, - unsigned(FunctionSigSpecializationParamKind::SROA))); - case 'i': - return addChild(Param, createNode( - Node::Kind::FunctionSignatureSpecializationParamKind, - unsigned(FunctionSigSpecializationParamKind::BoxToValue))); - case 's': - return addChild(Param, createNode( - Node::Kind::FunctionSignatureSpecializationParamKind, - unsigned(FunctionSigSpecializationParamKind::BoxToStack))); - default: - return nullptr; - } -} - -NodePointer Demangler::addFuncSpecParamNumber(NodePointer Param, - FunctionSigSpecializationParamKind Kind) { - Param->addChild(createNode( - Node::Kind::FunctionSignatureSpecializationParamKind, unsigned(Kind)), - *this); - CharVector Str; - while (isDigit(peekChar())) { - Str.push_back(nextChar(), *this); - } - if (Str.empty()) - return nullptr; - return addChild(Param, createNode( - Node::Kind::FunctionSignatureSpecializationParamPayload, Str)); -} - -NodePointer Demangler::demangleSpecAttributes(Node::Kind SpecKind) { - bool isSerialized = nextIf('q'); - - int PassID = (int)nextChar() - '0'; - if (PassID < 0 || PassID > 9) - return nullptr; - - NodePointer SpecNd = createNode(SpecKind); - if (isSerialized) - SpecNd->addChild(createNode(Node::Kind::IsSerialized), - *this); - - SpecNd->addChild(createNode(Node::Kind::SpecializationPassID, PassID), - *this); - return SpecNd; -} - -NodePointer Demangler::demangleWitness() { - switch (nextChar()) { - case 'C': - return createWithChild(Node::Kind::EnumCase, - popNode(isEntity)); - case 'V': - return createWithChild(Node::Kind::ValueWitnessTable, - popNode(Node::Kind::Type)); - case 'v': { - unsigned Directness; - switch (nextChar()) { - case 'd': Directness = unsigned(Directness::Direct); break; - case 'i': Directness = unsigned(Directness::Indirect); break; - default: return nullptr; - } - return createWithChildren(Node::Kind::FieldOffset, - createNode(Node::Kind::Directness, Directness), - popNode(isEntity)); - } - case 'S': - return createWithChild(Node::Kind::ProtocolSelfConformanceWitnessTable, - popProtocol()); - case 'P': - return createWithChild(Node::Kind::ProtocolWitnessTable, - popProtocolConformance()); - case 'p': - return createWithChild(Node::Kind::ProtocolWitnessTablePattern, - popProtocolConformance()); - case 'G': - return createWithChild(Node::Kind::GenericProtocolWitnessTable, - popProtocolConformance()); - case 'I': - return createWithChild( - Node::Kind::GenericProtocolWitnessTableInstantiationFunction, - popProtocolConformance()); - - case 'r': - return createWithChild(Node::Kind::ResilientProtocolWitnessTable, - popProtocolConformance()); - - case 'l': { - NodePointer Conf = popProtocolConformance(); - NodePointer Type = popNode(Node::Kind::Type); - return createWithChildren(Node::Kind::LazyProtocolWitnessTableAccessor, - Type, Conf); - } - case 'L': { - NodePointer Conf = popProtocolConformance(); - NodePointer Type = popNode(Node::Kind::Type); - return createWithChildren( - Node::Kind::LazyProtocolWitnessTableCacheVariable, Type, Conf); - } - case 'a': - return createWithChild(Node::Kind::ProtocolWitnessTableAccessor, - popProtocolConformance()); - case 't': { - NodePointer Name = popNode(isDeclName); - NodePointer Conf = popProtocolConformance(); - return createWithChildren(Node::Kind::AssociatedTypeMetadataAccessor, - Conf, Name); - } - case 'T': { - NodePointer ProtoTy = popNode(Node::Kind::Type); - NodePointer ConformingType = popAssocTypePath(); - NodePointer Conf = popProtocolConformance(); - return createWithChildren(Node::Kind::AssociatedTypeWitnessTableAccessor, - Conf, ConformingType, ProtoTy); - } - case 'b': { - NodePointer ProtoTy = popNode(Node::Kind::Type); - NodePointer Conf = popProtocolConformance(); - return createWithChildren(Node::Kind::BaseWitnessTableAccessor, - Conf, ProtoTy); - } - case 'O': { - switch (nextChar()) { - case 'y': { - if (auto sig = popNode(Node::Kind::DependentGenericSignature)) - return createWithChildren(Node::Kind::OutlinedCopy, - popNode(Node::Kind::Type), sig); - return createWithChild(Node::Kind::OutlinedCopy, - popNode(Node::Kind::Type)); - } - case 'e': { - if (auto sig = popNode(Node::Kind::DependentGenericSignature)) - return createWithChildren(Node::Kind::OutlinedConsume, - popNode(Node::Kind::Type), sig); - return createWithChild(Node::Kind::OutlinedConsume, - popNode(Node::Kind::Type)); - } - case 'r': { - if (auto sig = popNode(Node::Kind::DependentGenericSignature)) - return createWithChildren(Node::Kind::OutlinedRetain, - popNode(Node::Kind::Type), sig); - return createWithChild(Node::Kind::OutlinedRetain, - popNode(Node::Kind::Type)); - } - case 's': { - if (auto sig = popNode(Node::Kind::DependentGenericSignature)) - return createWithChildren(Node::Kind::OutlinedRelease, - popNode(Node::Kind::Type), sig); - return createWithChild(Node::Kind::OutlinedRelease, - popNode(Node::Kind::Type)); - } - case 'b': { - if (auto sig = popNode(Node::Kind::DependentGenericSignature)) - return createWithChildren(Node::Kind::OutlinedInitializeWithTake, - popNode(Node::Kind::Type), sig); - return createWithChild(Node::Kind::OutlinedInitializeWithTake, - popNode(Node::Kind::Type)); - } - case 'c': { - if (auto sig = popNode(Node::Kind::DependentGenericSignature)) - return createWithChildren(Node::Kind::OutlinedInitializeWithCopy, - popNode(Node::Kind::Type), sig); - return createWithChild(Node::Kind::OutlinedInitializeWithCopy, - popNode(Node::Kind::Type)); - } - case 'd': { - if (auto sig = popNode(Node::Kind::DependentGenericSignature)) - return createWithChildren(Node::Kind::OutlinedAssignWithTake, - popNode(Node::Kind::Type), sig); - return createWithChild(Node::Kind::OutlinedAssignWithTake, - popNode(Node::Kind::Type)); - } - case 'f': { - if (auto sig = popNode(Node::Kind::DependentGenericSignature)) - return createWithChildren(Node::Kind::OutlinedAssignWithCopy, - popNode(Node::Kind::Type), sig); - return createWithChild(Node::Kind::OutlinedAssignWithCopy, - popNode(Node::Kind::Type)); - } - case 'h': { - if (auto sig = popNode(Node::Kind::DependentGenericSignature)) - return createWithChildren(Node::Kind::OutlinedDestroy, - popNode(Node::Kind::Type), sig); - return createWithChild(Node::Kind::OutlinedDestroy, - popNode(Node::Kind::Type)); - } - default: - return nullptr; - } - } - default: - return nullptr; - } -} - -NodePointer Demangler::demangleSpecialType() { - switch (auto specialChar = nextChar()) { - case 'E': - return popFunctionType(Node::Kind::NoEscapeFunctionType); - case 'A': - return popFunctionType(Node::Kind::EscapingAutoClosureType); - case 'f': - return popFunctionType(Node::Kind::ThinFunctionType); - case 'K': - return popFunctionType(Node::Kind::AutoClosureType); - case 'U': - return popFunctionType(Node::Kind::UncurriedFunctionType); - case 'B': - return popFunctionType(Node::Kind::ObjCBlock); - case 'C': - return popFunctionType(Node::Kind::CFunctionPointer); - case 'o': - return createType(createWithChild(Node::Kind::Owned, - popNode(Node::Kind::Type))); - case 'u': - return createType(createWithChild(Node::Kind::Owned, - popNode(Node::Kind::Type))); - case 'w': - return createType(createWithChild(Node::Kind::Owned, - popNode(Node::Kind::Type))); - case 'b': - return createType(createWithChild(Node::Kind::SILBoxType, - popNode(Node::Kind::Type))); - case 'D': - return createType(createWithChild(Node::Kind::DynamicSelf, - popNode(Node::Kind::Type))); - case 'M': { - NodePointer MTR = demangleMetatypeRepresentation(); - NodePointer Type = popNode(Node::Kind::Type); - return createType(createWithChildren(Node::Kind::Metatype, MTR, Type)); - } - case 'm': { - NodePointer MTR = demangleMetatypeRepresentation(); - NodePointer Type = popNode(Node::Kind::Type); - return createType(createWithChildren(Node::Kind::ExistentialMetatype, - MTR, Type)); - } - case 'p': - return createType(createWithChild(Node::Kind::ExistentialMetatype, - popNode(Node::Kind::Type))); - case 'c': { - NodePointer Superclass = popNode(Node::Kind::Type); - NodePointer Protocols = demangleProtocolList(); - return createType(createWithChildren(Node::Kind::ProtocolListWithClass, - Protocols, Superclass)); - } - case 'l': { - NodePointer Protocols = demangleProtocolList(); - return createType(createWithChild(Node::Kind::ProtocolListWithAnyObject, - Protocols)); - } - case 'X': - case 'x': { - // SIL box types. - NodePointer signature = nullptr, genericArgs = nullptr; - if (specialChar == 'X') { - signature = popNode(Node::Kind::DependentGenericSignature); - if (!signature) - return nullptr; - genericArgs = popTypeList(); - if (!genericArgs) - return nullptr; - } - - auto fieldTypes = popTypeList(); - if (!fieldTypes) - return nullptr; - // Build layout. - auto layout = createNode(Node::Kind::SILBoxLayout); - for (unsigned long i = 0, e = fieldTypes->getNumChildren(); i < e; ++i) { - auto fieldType = fieldTypes->getChild(i); - assert(fieldType->getKind() == Node::Kind::Type); - bool isMutable = false; - // 'inout' typelist mangling is used to represent mutable fields. - if (fieldType->getChild(0)->getKind() == Node::Kind::InOut) { - isMutable = true; - fieldType = createType(fieldType->getChild(0)->getChild(0)); - } - auto field = createNode(isMutable - ? Node::Kind::SILBoxMutableField - : Node::Kind::SILBoxImmutableField); - field->addChild(fieldType, *this); - layout->addChild(field, *this); - } - auto boxTy = createNode(Node::Kind::SILBoxTypeWithLayout); - boxTy->addChild(layout, *this); - if (signature) { - boxTy->addChild(signature, *this); - assert(genericArgs); - boxTy->addChild(genericArgs, *this); - } - return createType(boxTy); - } - case 'Y': - return demangleAnyGenericType(Node::Kind::OtherNominalType); - case 'Z': { - auto types = popTypeList(); - auto name = popNode(Node::Kind::Identifier); - auto parent = popContext(); - auto anon = createNode(Node::Kind::AnonymousContext); - anon = addChild(anon, name); - anon = addChild(anon, parent); - anon = addChild(anon, types); - return anon; - } - case 'e': - return createType(createNode(Node::Kind::ErrorType)); - case 'S': - // Sugared type for debugger. - switch (nextChar()) { - case 'q': - return createType(createWithChild(Node::Kind::SugaredOptional, - popNode(Node::Kind::Type))); - case 'a': - return createType(createWithChild(Node::Kind::SugaredArray, - popNode(Node::Kind::Type))); - case 'D': { - NodePointer value = popNode(Node::Kind::Type); - NodePointer key = popNode(Node::Kind::Type); - return createType(createWithChildren(Node::Kind::SugaredDictionary, - key, value)); - } - case 'p': - return createType(createWithChild(Node::Kind::SugaredParen, - popNode(Node::Kind::Type))); - default: - return nullptr; - } - default: - return nullptr; - } -} - -NodePointer Demangler::demangleMetatypeRepresentation() { - switch (nextChar()) { - case 't': - return createNode(Node::Kind::MetatypeRepresentation, "@thin"); - case 'T': - return createNode(Node::Kind::MetatypeRepresentation, "@thick"); - case 'o': - return createNode(Node::Kind::MetatypeRepresentation, - "@objc_metatype"); - default: - return nullptr; - } -} - -NodePointer Demangler::demangleAccessor(NodePointer ChildNode) { - Node::Kind Kind; - switch (nextChar()) { - case 'm': Kind = Node::Kind::MaterializeForSet; break; - case 's': Kind = Node::Kind::Setter; break; - case 'g': Kind = Node::Kind::Getter; break; - case 'G': Kind = Node::Kind::GlobalGetter; break; - case 'w': Kind = Node::Kind::WillSet; break; - case 'W': Kind = Node::Kind::DidSet; break; - case 'r': Kind = Node::Kind::ReadAccessor; break; - case 'M': Kind = Node::Kind::ModifyAccessor; break; - case 'a': - switch (nextChar()) { - case 'O': Kind = Node::Kind::OwningMutableAddressor; break; - case 'o': Kind = Node::Kind::NativeOwningMutableAddressor; break; - case 'P': Kind = Node::Kind::NativePinningMutableAddressor; break; - case 'u': Kind = Node::Kind::UnsafeMutableAddressor; break; - default: return nullptr; - } - break; - case 'l': - switch (nextChar()) { - case 'O': Kind = Node::Kind::OwningAddressor; break; - case 'o': Kind = Node::Kind::NativeOwningAddressor; break; - case 'p': Kind = Node::Kind::NativePinningAddressor; break; - case 'u': Kind = Node::Kind::UnsafeAddressor; break; - default: return nullptr; - } - break; - case 'p': // Pseudo-accessor referring to the variable/subscript itself - return ChildNode; - default: return nullptr; - } - NodePointer Entity = createWithChild(Kind, ChildNode); - return Entity; -} - -NodePointer Demangler::demangleFunctionEntity() { - enum { - None, - TypeAndMaybePrivateName, - TypeAndIndex, - Index - } Args; - - Node::Kind Kind = Node::Kind::EmptyList; - switch (nextChar()) { - case 'D': Args = None; Kind = Node::Kind::Deallocator; break; - case 'd': Args = None; Kind = Node::Kind::Destructor; break; - case 'E': Args = None; Kind = Node::Kind::IVarDestroyer; break; - case 'e': Args = None; Kind = Node::Kind::IVarInitializer; break; - case 'i': Args = None; Kind = Node::Kind::Initializer; break; - case 'C': - Args = TypeAndMaybePrivateName; Kind = Node::Kind::Allocator; break; - case 'c': - Args = TypeAndMaybePrivateName; Kind = Node::Kind::Constructor; break; - case 'U': Args = TypeAndIndex; Kind = Node::Kind::ExplicitClosure; break; - case 'u': Args = TypeAndIndex; Kind = Node::Kind::ImplicitClosure; break; - case 'A': Args = Index; Kind = Node::Kind::DefaultArgumentInitializer; break; - case 'p': return demangleEntity(Node::Kind::GenericTypeParamDecl); - default: return nullptr; - } - - NodePointer NameOrIndex = nullptr, ParamType = nullptr, LabelList = nullptr; - switch (Args) { - case None: - break; - case TypeAndMaybePrivateName: - NameOrIndex = popNode(Node::Kind::PrivateDeclName); - ParamType = popNode(Node::Kind::Type); - LabelList = popFunctionParamLabels(ParamType); - break; - case TypeAndIndex: - NameOrIndex = demangleIndexAsNode(); - ParamType = popNode(Node::Kind::Type); - break; - case Index: - NameOrIndex = demangleIndexAsNode(); - break; - } - NodePointer Entity = createWithChild(Kind, popContext()); - switch (Args) { - case None: - break; - case Index: - Entity = addChild(Entity, NameOrIndex); - break; - case TypeAndMaybePrivateName: - addChild(Entity, LabelList); - Entity = addChild(Entity, ParamType); - addChild(Entity, NameOrIndex); - break; - case TypeAndIndex: - Entity = addChild(Entity, NameOrIndex); - Entity = addChild(Entity, ParamType); - break; - } - return Entity; -} - -NodePointer Demangler::demangleEntity(Node::Kind Kind) { - NodePointer Type = popNode(Node::Kind::Type); - NodePointer LabelList = popFunctionParamLabels(Type); - NodePointer Name = popNode(isDeclName); - NodePointer Context = popContext(); - return LabelList ? createWithChildren(Kind, Context, Name, LabelList, Type) - : createWithChildren(Kind, Context, Name, Type); -} - -NodePointer Demangler::demangleVariable() { - NodePointer Variable = demangleEntity(Node::Kind::Variable); - return demangleAccessor(Variable); -} - -NodePointer Demangler::demangleSubscript() { - NodePointer PrivateName = popNode(Node::Kind::PrivateDeclName); - NodePointer Type = popNode(Node::Kind::Type); - NodePointer LabelList = popFunctionParamLabels(Type); - NodePointer Context = popContext(); - - NodePointer Subscript = createNode(Node::Kind::Subscript); - Subscript = addChild(Subscript, Context); - addChild(Subscript, LabelList); - Subscript = addChild(Subscript, Type); - addChild(Subscript, PrivateName); - - return demangleAccessor(Subscript); -} - -NodePointer Demangler::demangleProtocolList() { - NodePointer TypeList = createNode(Node::Kind::TypeList); - NodePointer ProtoList = createWithChild(Node::Kind::ProtocolList, TypeList); - if (!popNode(Node::Kind::EmptyList)) { - bool firstElem = false; - do { - firstElem = (popNode(Node::Kind::FirstElementMarker) != nullptr); - NodePointer Proto = popProtocol(); - if (!Proto) - return nullptr; - TypeList->addChild(Proto, *this); - } while (!firstElem); - - TypeList->reverseChildren(); - } - return ProtoList; -} - -NodePointer Demangler::demangleProtocolListType() { - NodePointer ProtoList = demangleProtocolList(); - return createType(ProtoList); -} - -NodePointer Demangler::demangleGenericSignature(bool hasParamCounts) { - NodePointer Sig = createNode(Node::Kind::DependentGenericSignature); - if (hasParamCounts) { - while (!nextIf('l')) { - int count = 0; - if (!nextIf('z')) - count = demangleIndex() + 1; - if (count < 0) - return nullptr; - Sig->addChild(createNode(Node::Kind::DependentGenericParamCount, - count), *this); - } - } else { - Sig->addChild(createNode(Node::Kind::DependentGenericParamCount, 1), - *this); - } - size_t NumCounts = Sig->getNumChildren(); - while (NodePointer Req = popNode(isRequirement)) { - Sig->addChild(Req, *this); - } - Sig->reverseChildren(NumCounts); - return Sig; -} - -NodePointer Demangler::demangleGenericRequirement() { - - enum { Generic, Assoc, CompoundAssoc, Substitution } TypeKind; - enum { Protocol, BaseClass, SameType, Layout } ConstraintKind; - - switch (nextChar()) { - case 'c': ConstraintKind = BaseClass; TypeKind = Assoc; break; - case 'C': ConstraintKind = BaseClass; TypeKind = CompoundAssoc; break; - case 'b': ConstraintKind = BaseClass; TypeKind = Generic; break; - case 'B': ConstraintKind = BaseClass; TypeKind = Substitution; break; - case 't': ConstraintKind = SameType; TypeKind = Assoc; break; - case 'T': ConstraintKind = SameType; TypeKind = CompoundAssoc; break; - case 's': ConstraintKind = SameType; TypeKind = Generic; break; - case 'S': ConstraintKind = SameType; TypeKind = Substitution; break; - case 'm': ConstraintKind = Layout; TypeKind = Assoc; break; - case 'M': ConstraintKind = Layout; TypeKind = CompoundAssoc; break; - case 'l': ConstraintKind = Layout; TypeKind = Generic; break; - case 'L': ConstraintKind = Layout; TypeKind = Substitution; break; - case 'p': ConstraintKind = Protocol; TypeKind = Assoc; break; - case 'P': ConstraintKind = Protocol; TypeKind = CompoundAssoc; break; - case 'Q': ConstraintKind = Protocol; TypeKind = Substitution; break; - default: ConstraintKind = Protocol; TypeKind = Generic; pushBack(); break; - } - - NodePointer ConstrTy = nullptr; - - switch (TypeKind) { - case Generic: - ConstrTy = createType(demangleGenericParamIndex()); - break; - case Assoc: - ConstrTy = demangleAssociatedTypeSimple(demangleGenericParamIndex()); - addSubstitution(ConstrTy); - break; - case CompoundAssoc: - ConstrTy = demangleAssociatedTypeCompound(demangleGenericParamIndex()); - addSubstitution(ConstrTy); - break; - case Substitution: - ConstrTy = popNode(Node::Kind::Type); - break; - } - - switch (ConstraintKind) { - case Protocol: - return createWithChildren( - Node::Kind::DependentGenericConformanceRequirement, ConstrTy, - popProtocol()); - case BaseClass: - return createWithChildren( - Node::Kind::DependentGenericConformanceRequirement, ConstrTy, - popNode(Node::Kind::Type)); - case SameType: - return createWithChildren(Node::Kind::DependentGenericSameTypeRequirement, - ConstrTy, popNode(Node::Kind::Type)); - case Layout: { - auto c = nextChar(); - NodePointer size = nullptr; - NodePointer alignment = nullptr; - const char *name = nullptr; - if (c == 'U') { - name = "U"; - } else if (c == 'R') { - name = "R"; - } else if (c == 'N') { - name = "N"; - } else if (c == 'C') { - name = "C"; - } else if (c == 'D') { - name = "D"; - } else if (c == 'T') { - name = "T"; - } else if (c == 'E') { - size = demangleIndexAsNode(); - if (!size) - return nullptr; - alignment = demangleIndexAsNode(); - name = "E"; - } else if (c == 'e') { - size = demangleIndexAsNode(); - if (!size) - return nullptr; - name = "e"; - } else if (c == 'M') { - size = demangleIndexAsNode(); - if (!size) - return nullptr; - alignment = demangleIndexAsNode(); - name = "M"; - } else if (c == 'm') { - size = demangleIndexAsNode(); - if (!size) - return nullptr; - name = "m"; - } else { - // Unknown layout constraint. - return nullptr; - } - - auto NameNode = createNode(Node::Kind::Identifier, name); - auto LayoutRequirement = createWithChildren( - Node::Kind::DependentGenericLayoutRequirement, ConstrTy, NameNode); - if (size) - addChild(LayoutRequirement, size); - if (alignment) - addChild(LayoutRequirement, alignment); - return LayoutRequirement; - } - } - return nullptr; -} - -NodePointer Demangler::demangleGenericType() { - NodePointer GenSig = popNode(Node::Kind::DependentGenericSignature); - NodePointer Ty = popNode(Node::Kind::Type); - return createType(createWithChildren(Node::Kind::DependentGenericType, - GenSig, Ty)); -} - -static int decodeValueWitnessKind(StringRef CodeStr) { - return -1; -} - -NodePointer Demangler::demangleValueWitness() { - char Code[2]; - Code[0] = nextChar(); - Code[1] = nextChar(); - int Kind = decodeValueWitnessKind(StringRef(Code, 2)); - if (Kind < 0) - return nullptr; - NodePointer VW = createNode(Node::Kind::ValueWitness, unsigned(Kind)); - return addChild(VW, popNode(Node::Kind::Type)); -} - -NodePointer Demangler::demangleObjCTypeName() { - NodePointer Ty = createNode(Node::Kind::Type); - NodePointer Global = addChild(createNode(Node::Kind::Global), - addChild(createNode(Node::Kind::TypeMangling), Ty)); - NodePointer Nominal = nullptr; - bool isProto = false; - if (nextIf('C')) { - Nominal = createNode(Node::Kind::Class); - addChild(Ty, Nominal); - } else if (nextIf('P')) { - isProto = true; - Nominal = createNode(Node::Kind::Protocol); - addChild(Ty, addChild(createNode(Node::Kind::ProtocolList), - addChild(createNode(Node::Kind::TypeList), - addChild(createNode(Node::Kind::Type), Nominal)))); - } else { - return nullptr; - } - - if (nextIf('s')) { - Nominal->addChild(createNode(Node::Kind::Module, "Swift"), *this); - } else { - NodePointer Module = demangleIdentifier(); - if (!Module) - return nullptr; - Nominal->addChild(changeKind(Module, Node::Kind::Module), *this); - } - - NodePointer Ident = demangleIdentifier(); - if (!Ident) - return nullptr; - Nominal->addChild(Ident, *this); - - if (isProto && !nextIf('_')) - return nullptr; - - if (Pos < Text.size()) - return nullptr; - - return Global; -} diff --git a/Source/KSCrash/swift/Basic/Demangler.h b/Source/KSCrash/swift/Basic/Demangler.h deleted file mode 100644 index 1047261de..000000000 --- a/Source/KSCrash/swift/Basic/Demangler.h +++ /dev/null @@ -1,545 +0,0 @@ -//===--- Demangler.h - String to Node-Tree Demangling -----------*- C++ -*-===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file is the compiler-private API of the demangler. -// It should only be used within the swift compiler or runtime library, but not -// by external tools which use the demangler library (like lldb). -// -//===----------------------------------------------------------------------===// - -#ifndef SWIFT_DEMANGLING_DEMANGLER_H -#define SWIFT_DEMANGLING_DEMANGLER_H - -#include "Demangle.h" - -//#define NODE_FACTORY_DEBUGGING - -#ifdef NODE_FACTORY_DEBUGGING -#include -#endif - - -using namespace swift::Demangle; -using llvm::StringRef; - -namespace swift { - namespace Demangle { - - class CharVector; - - /// The allocator for demangling nodes and other demangling-internal stuff. - /// - /// It implements a simple bump-pointer allocator. - class NodeFactory { - - /// Position in the current slab. - char *CurPtr = nullptr; - - /// The end of the current slab. - char *End = nullptr; - - struct Slab { - // The previously allocated slab. - Slab *Previous; - // Tail allocated memory starts here. - }; - - /// The head of the single-linked slab list. - Slab *CurrentSlab = nullptr; - - /// The size of the previously allocated slab. - /// - /// The slab size can only grow, even clear() does not reset the slab size. - /// This initial size is good enough to fit most de-manglings. - size_t SlabSize = 100 * sizeof(Node); - - static char *align(char *Ptr, size_t Alignment) { - assert(Alignment > 0); - return (char*)(((uintptr_t)Ptr + Alignment - 1) - & ~((uintptr_t)Alignment - 1)); - } - - static void freeSlabs(Slab *slab); - - public: - - NodeFactory() { -#ifdef NODE_FACTORY_DEBUGGING - std::cerr << "## New NodeFactory " << this << "\n"; -#endif - } - - virtual ~NodeFactory() { - freeSlabs(CurrentSlab); -#ifdef NODE_FACTORY_DEBUGGING - std::cerr << "Delete NodeFactory " << this << "\n"; -#endif - } - - virtual void clear(); - - /// Allocates an object of type T or an array of objects of type T. - template T *Allocate(size_t NumObjects = 1) { - size_t ObjectSize = NumObjects * sizeof(T); - CurPtr = align(CurPtr, alignof(T)); -#ifdef NODE_FACTORY_DEBUGGING - std::cerr << " alloc " << ObjectSize << ", CurPtr = " - << (void *)CurPtr << "\n"; -#endif - - // Do we have enough space in the current slab? - if (CurPtr + ObjectSize > End) { - // No. We have to malloc a new slab. - // We double the slab size for each allocated slab. - SlabSize = std::max(SlabSize * 2, ObjectSize + alignof(T)); - size_t AllocSize = sizeof(Slab) + SlabSize; - Slab *newSlab = (Slab *)malloc(AllocSize); - - // Insert the new slab in the single-linked list of slabs. - newSlab->Previous = CurrentSlab; - CurrentSlab = newSlab; - - // Initialize the pointers to the new slab. - CurPtr = align((char *)(newSlab + 1), alignof(T)); - End = (char *)newSlab + AllocSize; - assert(CurPtr + ObjectSize <= End); -#ifdef NODE_FACTORY_DEBUGGING - std::cerr << " ** new slab " << newSlab << ", allocsize = " - << AllocSize << ", CurPtr = " << (void *)CurPtr - << ", End = " << (void *)End << "\n"; -#endif - } - T *AllocatedObj = (T *)CurPtr; - CurPtr += ObjectSize; - return AllocatedObj; - } - - /// Tries to enlarge the \p Capacity of an array of \p Objects. - /// - /// If \p Objects is allocated at the end of the current slab and the slab - /// has enough free space, the \p Capacity is simply enlarged and no new - /// allocation needs to be done. - /// Otherwise a new array of objects is allocated and \p Objects is set to the - /// new memory address. - /// The \p Capacity is enlarged at least by \p MinGrowth, but can also be - /// enlarged by a bigger value. - template void Reallocate(T *&Objects, size_t &Capacity, - size_t MinGrowth) { - size_t OldAllocSize = Capacity * sizeof(T); - size_t AdditionalAlloc = MinGrowth * sizeof(T); - -#ifdef NODE_FACTORY_DEBUGGING - std::cerr << " realloc " << Objects << ", num = " << NumObjects - << " (size = " << OldAllocSize << "), Growth = " << Growth - << " (size = " << AdditionalAlloc << ")\n"; -#endif - if ((char *)Objects + OldAllocSize == CurPtr - && CurPtr + AdditionalAlloc <= End) { - // The existing array is at the end of the current slab and there is - // enough space. So we are fine. - CurPtr += AdditionalAlloc; - Capacity += MinGrowth; -#ifdef NODE_FACTORY_DEBUGGING - std::cerr << " ** can grow: CurPtr = " << (void *)CurPtr << "\n"; -#endif - return; - } - // We need a new allocation. - size_t Growth = (MinGrowth >= 4 ? MinGrowth : 4); - if (Growth < Capacity * 2) - Growth = Capacity * 2; - T *NewObjects = Allocate(Capacity + Growth); - memcpy(NewObjects, Objects, OldAllocSize); - Objects = NewObjects; - Capacity += Growth; - } - - /// Creates a node of kind \p K. - NodePointer createNode(Node::Kind K); - - /// Creates a node of kind \p K with an \p Index payload. - NodePointer createNode(Node::Kind K, Node::IndexType Index); - - /// Creates a node of kind \p K with a \p Text payload. - /// - /// The \p Text string must be already allocated with the Factory and therefore - /// it is _not_ copied. - NodePointer createNodeWithAllocatedText(Node::Kind K, llvm::StringRef Text); - - /// Creates a node of kind \p K with a \p Text payload. - /// - /// The \p Text string is copied. - NodePointer createNode(Node::Kind K, llvm::StringRef Text) { - return createNodeWithAllocatedText(K, Text.copy(*this)); - } - - /// Creates a node of kind \p K with a \p Text payload. - /// - /// The \p Text string is already allocated with the Factory and therefore - /// it is _not_ copied. - NodePointer createNode(Node::Kind K, const CharVector &Text); - - /// Creates a node of kind \p K with a \p Text payload, which must be a C - /// string literal. - /// - /// The \p Text string is _not_ copied. - NodePointer createNode(Node::Kind K, const char *Text); - }; - - /// A vector with a storage managed by a NodeFactory. - /// - /// This Vector class only provides the minimal functionality needed by the - /// Demangler. - template class Vector { - - protected: - T *Elems = nullptr; - size_t NumElems = 0; - size_t Capacity = 0; - - public: - using iterator = T *; - - Vector() { } - - /// Construct a vector with an initial capacity. - explicit Vector(NodeFactory &Factory, size_t InitialCapacity) { - init(Factory, InitialCapacity); - } - - /// Clears the content and re-allocates the buffer with an initial capacity. - void init(NodeFactory &Factory, size_t InitialCapacity) { - Elems = Factory.Allocate(InitialCapacity); - NumElems = 0; - Capacity = InitialCapacity; - } - - void free() { - Capacity = 0; - Elems = 0; - } - - iterator begin() { return Elems; } - iterator end() { return Elems + NumElems; } - - T &operator[](size_t Idx) { - assert(Idx < NumElems); - return Elems[Idx]; - } - - const T &operator[](size_t Idx) const { - assert(Idx < NumElems); - return Elems[Idx]; - } - - size_t size() const { return NumElems; } - - bool empty() const { return NumElems == 0; } - - T &back() { return (*this)[NumElems - 1]; } - - void push_back(const T &NewElem, NodeFactory &Factory) { - if (NumElems >= Capacity) - Factory.Reallocate(Elems, Capacity, /*Growth*/ 1); - assert(NumElems < Capacity); - Elems[NumElems++] = NewElem; - } - - T pop_back_val() { - if (empty()) - return T(); - T Val = (*this)[NumElems - 1]; - NumElems--; - return Val; - } - }; - - /// A vector of chars (a string) with a storage managed by a NodeFactory. - /// - /// This CharVector class only provides the minimal functionality needed by the - /// Demangler. - class CharVector : public Vector { - public: - // Append another string. - void append(StringRef Rhs, NodeFactory &Factory); - - // Append an integer as readable number. - void append(int Number, NodeFactory &Factory); - - StringRef str() const { - return StringRef(Elems, NumElems); - } - }; - - /// Kinds of symbolic reference supported. - enum class SymbolicReferenceKind : uint8_t { - /// A symbolic reference to a context descriptor, representing the - /// (unapplied generic) context. - Context, - }; - - using SymbolicReferenceResolver_t = NodePointer (SymbolicReferenceKind, - Directness, - int32_t, const void *); - - /// The demangler. - /// - /// It de-mangles a string and it also owns the returned node-tree. This means - /// The nodes of the tree only live as long as the Demangler itself. - class Demangler : public NodeFactory { - protected: - StringRef Text; - size_t Pos = 0; - - /// Mangling style where function type would have - /// labels attached to it, instead of having them - /// as part of the name. - bool IsOldFunctionTypeMangling = false; - - Vector NodeStack; - Vector Substitutions; - - static const int MaxNumWords = 26; - StringRef Words[MaxNumWords]; - int NumWords = 0; - - std::function SymbolicReferenceResolver; - - bool nextIf(StringRef str) { - if (!Text.substr(Pos).startswith(str)) return false; - Pos += str.size(); - return true; - } - - char peekChar() { - if (Pos >= Text.size()) - return 0; - return Text[Pos]; - } - - char nextChar() { - if (Pos >= Text.size()) - return 0; - return Text[Pos++]; - } - - bool nextIf(char c) { - if (peekChar() != c) - return false; - Pos++; - return true; - } - - void pushBack() { - assert(Pos > 0); - Pos--; - } - - StringRef consumeAll() { - StringRef str = Text.drop_front(Pos); - Pos = Text.size(); - return str; - } - - void pushNode(NodePointer Nd) { - NodeStack.push_back(Nd, *this); - } - - NodePointer popNode() { - return NodeStack.pop_back_val(); - } - - NodePointer popNode(Node::Kind kind) { - if (NodeStack.empty()) - return nullptr; - - Node::Kind NdKind = NodeStack.back()->getKind(); - if (NdKind != kind) - return nullptr; - - return popNode(); - } - - template NodePointer popNode(Pred pred) { - if (NodeStack.empty()) - return nullptr; - - Node::Kind NdKind = NodeStack.back()->getKind(); - if (!pred(NdKind)) - return nullptr; - - return popNode(); - } - - void init(StringRef MangledName); - - void addSubstitution(NodePointer Nd) { - if (Nd) - Substitutions.push_back(Nd, *this); - } - - NodePointer addChild(NodePointer Parent, NodePointer Child); - NodePointer createWithChild(Node::Kind kind, NodePointer Child); - NodePointer createType(NodePointer Child); - NodePointer createWithChildren(Node::Kind kind, NodePointer Child1, - NodePointer Child2); - NodePointer createWithChildren(Node::Kind kind, NodePointer Child1, - NodePointer Child2, NodePointer Child3); - NodePointer createWithChildren(Node::Kind kind, NodePointer Child1, - NodePointer Child2, NodePointer Child3, - NodePointer Child4); - NodePointer createWithPoppedType(Node::Kind kind) { - return createWithChild(kind, popNode(Node::Kind::Type)); - } - - bool parseAndPushNodes(); - - NodePointer changeKind(NodePointer Node, Node::Kind NewKind); - - NodePointer demangleOperator(); - - int demangleNatural(); - int demangleIndex(); - NodePointer demangleIndexAsNode(); - NodePointer demangleIdentifier(); - NodePointer demangleOperatorIdentifier(); - - std::string demangleBridgedMethodParams(); - - NodePointer demangleMultiSubstitutions(); - NodePointer pushMultiSubstitutions(int RepeatCount, size_t SubstIdx); - NodePointer createSwiftType(Node::Kind typeKind, const char *name); - NodePointer demangleStandardSubstitution(); - NodePointer createStandardSubstitution(char Subst); - NodePointer demangleLocalIdentifier(); - - NodePointer popModule(); - NodePointer popContext(); - NodePointer popTypeAndGetChild(); - NodePointer popTypeAndGetAnyGeneric(); - NodePointer demangleBuiltinType(); - NodePointer demangleAnyGenericType(Node::Kind kind); - NodePointer demangleExtensionContext(); - NodePointer demanglePlainFunction(); - NodePointer popFunctionType(Node::Kind kind); - NodePointer popFunctionParams(Node::Kind kind); - NodePointer popFunctionParamLabels(NodePointer FuncType); - NodePointer popTuple(); - NodePointer popTypeList(); - NodePointer popProtocol(); - NodePointer demangleBoundGenericType(); - NodePointer demangleBoundGenericArgs(NodePointer nominalType, - const Vector &TypeLists, - size_t TypeListIdx); - NodePointer popAnyProtocolConformanceList(); - NodePointer demangleRetroactiveConformance(); - NodePointer demangleInitializer(); - NodePointer demangleImplParamConvention(); - NodePointer demangleImplResultConvention(Node::Kind ConvKind); - NodePointer demangleImplFunctionType(); - NodePointer demangleMetatype(); - NodePointer demanglePrivateContextDescriptor(); - NodePointer createArchetypeRef(int depth, int i); - NodePointer demangleArchetype(); - NodePointer demangleAssociatedTypeSimple(NodePointer GenericParamIdx); - NodePointer demangleAssociatedTypeCompound(NodePointer GenericParamIdx); - - NodePointer popAssocTypeName(); - NodePointer popAssocTypePath(); - NodePointer getDependentGenericParamType(int depth, int index); - NodePointer demangleGenericParamIndex(); - NodePointer popProtocolConformance(); - NodePointer demangleRetroactiveProtocolConformanceRef(); - NodePointer popAnyProtocolConformance(); - NodePointer demangleConcreteProtocolConformance(); - NodePointer popDependentProtocolConformance(); - NodePointer demangleDependentProtocolConformanceRoot(); - NodePointer demangleDependentProtocolConformanceInherited(); - NodePointer popDependentAssociatedConformance(); - NodePointer demangleDependentProtocolConformanceAssociated(); - NodePointer demangleThunkOrSpecialization(); - NodePointer demangleGenericSpecialization(Node::Kind SpecKind); - NodePointer demangleFunctionSpecialization(); - NodePointer demangleFuncSpecParam(Node::IndexType ParamIdx); - NodePointer addFuncSpecParamNumber(NodePointer Param, - FunctionSigSpecializationParamKind Kind); - - NodePointer demangleSpecAttributes(Node::Kind SpecKind); - - NodePointer demangleWitness(); - NodePointer demangleSpecialType(); - NodePointer demangleMetatypeRepresentation(); - NodePointer demangleAccessor(NodePointer ChildNode); - NodePointer demangleFunctionEntity(); - NodePointer demangleEntity(Node::Kind Kind); - NodePointer demangleVariable(); - NodePointer demangleSubscript(); - NodePointer demangleProtocolList(); - NodePointer demangleProtocolListType(); - NodePointer demangleGenericSignature(bool hasParamCounts); - NodePointer demangleGenericRequirement(); - NodePointer demangleGenericType(); - NodePointer demangleValueWitness(); - - NodePointer demangleObjCTypeName(); - NodePointer demangleTypeMangling(); - NodePointer demangleSymbolicReference(unsigned char rawKind, - const void *at); - - void dump(); - - public: - Demangler() {} - - void clear() override; - - /// Install a resolver for symbolic references in a mangled string. - void setSymbolicReferenceResolver( - std::function resolver) { - SymbolicReferenceResolver = resolver; - } - - /// Take the symbolic reference resolver. - std::function && - takeSymbolicReferenceResolver() { - return std::move(SymbolicReferenceResolver); - } - - /// Demangle the given symbol and return the parse tree. - /// - /// \param MangledName The mangled symbol string, which start with the - /// mangling prefix $S. - /// - /// \returns A parse tree for the demangled string - or a null pointer - /// on failure. - /// The lifetime of the returned node tree ends with the lifetime of the - /// Demangler or with a call of clear(). - NodePointer demangleSymbol(StringRef MangledName); - - /// Demangle the given type and return the parse tree. - /// - /// \param MangledName The mangled type string, which does _not_ start with - /// the mangling prefix $S. - /// - /// \returns A parse tree for the demangled string - or a null pointer - /// on failure. - /// The lifetime of the returned node tree ends with the lifetime of the - /// Demangler or with a call of clear(). - NodePointer demangleType(StringRef MangledName); - }; - - NodePointer demangleOldSymbolAsNode(StringRef MangledName, - NodeFactory &Factory); - } // end namespace Demangle -} // end namespace swift - -#endif // SWIFT_DEMANGLING_DEMANGLER_H diff --git a/Source/KSCrash/swift/Basic/Fallthrough.h b/Source/KSCrash/swift/Basic/Fallthrough.h deleted file mode 100644 index 56e1a8d3a..000000000 --- a/Source/KSCrash/swift/Basic/Fallthrough.h +++ /dev/null @@ -1,39 +0,0 @@ -//===--- Fallthrough.h - switch fallthrough annotation macro ----*- C++ -*-===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See http://swift.org/LICENSE.txt for license information -// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file defines a SWIFT_FALLTHROUGH macro to annotate intentional -// fallthrough between switch cases. For compilers that support the -// "clang::fallthrough" attribute, it expands to an empty statement with the -// attribute applied; otherwise, it expands to just an empty statement. -// -//===----------------------------------------------------------------------===// - -#ifndef SWIFT_BASIC_FALLTHROUGH_H -#define SWIFT_BASIC_FALLTHROUGH_H - -#ifndef __has_attribute -# define __has_attribute(x) 0 -#endif - -#ifndef __has_cpp_attribute -# define __has_cpp_attribute(x) 0 -#endif - -#if __has_attribute(fallthrough) -# define SWIFT_FALLTHROUGH [[clang::fallthrough]] -#elif __has_cpp_attribute(clang::fallthrough) -# define SWIFT_FALLTHROUGH [[clang::fallthrough]] -#else -# define SWIFT_FALLTHROUGH -#endif - -#endif // SWIFT_BASIC_FALLTHROUGH_H diff --git a/Source/KSCrash/swift/Basic/LLVM.h b/Source/KSCrash/swift/Basic/LLVM.h deleted file mode 100644 index ba4f6ae15..000000000 --- a/Source/KSCrash/swift/Basic/LLVM.h +++ /dev/null @@ -1,90 +0,0 @@ -//===--- LLVM.h - Import various common LLVM datatypes ----------*- C++ -*-===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file forward declares and imports various common LLVM datatypes that -// swift wants to use unqualified. -// -//===----------------------------------------------------------------------===// - -#ifndef SWIFT_BASIC_LLVM_H -#define SWIFT_BASIC_LLVM_H - -// Do not proliferate #includes here, require clients to #include their -// dependencies. -// Casting.h has complex templates that cannot be easily forward declared. -#include "Casting.h" -// None.h includes an enumerator that is desired & cannot be forward declared -// without a definition of NoneType. -#include "None.h" - -// Forward declarations. -namespace llvm { - // Containers. - class StringRef; - class StringLiteral; - class Twine; - template class SmallPtrSetImpl; - template class SmallPtrSet; - template class SmallVectorImpl; - template class SmallVector; - template class SmallString; - template class SmallSetVector; - template class ArrayRef; - template class MutableArrayRef; - template class TinyPtrVector; - template class Optional; - template class PointerUnion; - class SmallBitVector; - - // Other common classes. - class raw_ostream; - class APInt; - class APFloat; - template class function_ref; -} // end namespace llvm - - -namespace swift { - // Casting operators. - using llvm::isa; - using llvm::cast; - using llvm::dyn_cast; - using llvm::dyn_cast_or_null; - using llvm::cast_or_null; - - // Containers. - using llvm::None; - using llvm::Optional; - using llvm::SmallPtrSetImpl; - using llvm::SmallPtrSet; - using llvm::SmallString; - using llvm::StringRef; - using llvm::StringLiteral; - using llvm::Twine; - using llvm::SmallVectorImpl; - using llvm::SmallVector; - using llvm::ArrayRef; - using llvm::MutableArrayRef; - using llvm::TinyPtrVector; - using llvm::PointerUnion; - using llvm::SmallSetVector; - using llvm::SmallBitVector; - - // Other common classes. - using llvm::APFloat; - using llvm::APInt; - using llvm::function_ref; - using llvm::NoneType; - using llvm::raw_ostream; -} // end namespace swift - -#endif // SWIFT_BASIC_LLVM_H diff --git a/Source/KSCrash/swift/Basic/Malloc.h b/Source/KSCrash/swift/Basic/Malloc.h deleted file mode 100644 index 1964828cd..000000000 --- a/Source/KSCrash/swift/Basic/Malloc.h +++ /dev/null @@ -1,59 +0,0 @@ -//===--- Malloc.h - Aligned malloc interface --------------------*- C++ -*-===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See http://swift.org/LICENSE.txt for license information -// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// This file provides an implementation of C11 aligned_alloc(3) for platforms -// that don't have it yet, using posix_memalign(3). -// -//===----------------------------------------------------------------------===// - -#ifndef SWIFT_BASIC_MALLOC_H -#define SWIFT_BASIC_MALLOC_H - -#include -#if defined(_MSC_VER) -#include -#else -#include -#endif - -namespace swift { - -// FIXME: Use C11 aligned_alloc if available. -inline void *AlignedAlloc(size_t size, size_t align) { - // posix_memalign only accepts alignments greater than sizeof(void*). - // - if (align < sizeof(void*)) - align = sizeof(void*); - - void *r; -#if defined(_WIN32) - r = _aligned_malloc(size, align); - assert(r && "_aligned_malloc failed"); -#else - int res = posix_memalign(&r, align, size); - assert(res == 0 && "posix_memalign failed"); - (void)res; // Silence the unused variable warning. -#endif - return r; -} - -inline void AlignedFree(void *p) { -#if defined(_WIN32) - _aligned_free(p); -#else - free(p); -#endif -} - -} // end namespace swift - -#endif // SWIFT_BASIC_MALLOC_H diff --git a/Source/KSCrash/swift/Basic/ManglingMacros.h b/Source/KSCrash/swift/Basic/ManglingMacros.h deleted file mode 100644 index 21a2fbe62..000000000 --- a/Source/KSCrash/swift/Basic/ManglingMacros.h +++ /dev/null @@ -1,84 +0,0 @@ -//===--- ManglingMacros.h - Macros for Swift symbol mangling ----*- C++ -*-===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -#ifndef SWIFT_DEMANGLING_MANGLING_MACROS_H -#define SWIFT_DEMANGLING_MANGLING_MACROS_H - -#define STRINGIFY_MANGLING(M) #M -#define MANGLE_AS_STRING(M) STRINGIFY_MANGLING(M) - -/// The mangling prefix for the new mangling. -#define MANGLING_PREFIX $s - -#define MANGLING_PREFIX_STR MANGLE_AS_STRING(MANGLING_PREFIX) - -// The following macros help to create symbol manglings. They can be used -// if a mangled name is needed at compile-time, e.g. for variable names in the -// swift runtime libraries. - -#define MANGLING_CONCAT2_IMPL(a, b) a##b -#define MANGLING_CONCAT3_IMPL(a, b, c) a##b##c - -#define MANGLING_CONCAT2(a, b) MANGLING_CONCAT2_IMPL(a, b) -#define MANGLING_CONCAT3(a, b, c) MANGLING_CONCAT3_IMPL(a, b, c) -#define MANGLE_SYM(Ops) MANGLING_CONCAT2(MANGLING_PREFIX, Ops) -#define METADATA_MANGLING N -#define METATYPE_MANGLING m -#define EMPTY_TUPLE_MANGLING yt -#define ANY_MANGLING yp -#define ANYOBJECT_MANGLING yXl -#define NO_ARGS_MANGLING yy -#define FUNC_TYPE_MANGLING c -#define NOESCAPE_FUNC_TYPE_MANGLING XE -#define OBJC_PARTIAL_APPLY_THUNK_MANGLING Ta -#define OPTIONAL_MANGLING(Ty) MANGLING_CONCAT2_IMPL(Ty, Sg) - -#define FUNCTION_MANGLING \ -MANGLING_CONCAT2(NO_ARGS_MANGLING, FUNC_TYPE_MANGLING) - -#define NOESCAPE_FUNCTION_MANGLING \ -MANGLING_CONCAT2(NO_ARGS_MANGLING, NOESCAPE_FUNC_TYPE_MANGLING) - -#define THIN_FUNCTION_MANGLING \ -MANGLING_CONCAT2(NO_ARGS_MANGLING, Xf) - -#define METADATA_SYM(Ty) \ -MANGLE_SYM(MANGLING_CONCAT2(Ty, METADATA_MANGLING)) - -#define STRUCT_METADATA_SYM(Ty) \ -MANGLE_SYM(MANGLING_CONCAT3(Ty, V, METADATA_MANGLING)) - -#define CLASS_METADATA_SYM(Ty) \ -MANGLE_SYM(MANGLING_CONCAT3(Ty, C, METADATA_MANGLING)) - -#define STRUCT_MD_ACCESSOR_SYM(Ty) \ -MANGLE_SYM(MANGLING_CONCAT3(Ty, V, Ma)) - -#define VALUE_WITNESS_SYM(Ty) \ -MANGLE_SYM(MANGLING_CONCAT2(Ty, WV)) - -#define METATYPE_VALUE_WITNESS_SYM(Ty) \ -MANGLE_SYM(MANGLING_CONCAT3(Ty, METATYPE_MANGLING, WV)) - -#define NOMINAL_TYPE_DESCR_SYM(Ty) \ -MANGLE_SYM(MANGLING_CONCAT2(Ty, Mn)) - -#define STRUCT_TYPE_DESCR_SYM(Ty) \ -MANGLE_SYM(MANGLING_CONCAT3(Ty, V, Mn)) - -#define PROTOCOL_DESCR_SYM(Ty) \ -MANGLE_SYM(MANGLING_CONCAT2(Ty, Mp)) - -#define OBJC_PARTIAL_APPLY_THUNK_SYM \ -MANGLE_SYM(OBJC_PARTIAL_APPLY_THUNK_MANGLING) - -#endif // SWIFT_DEMANGLING_MANGLING_MACROS_H diff --git a/Source/KSCrash/swift/Basic/ManglingUtils.cpp b/Source/KSCrash/swift/Basic/ManglingUtils.cpp deleted file mode 100644 index d2b334494..000000000 --- a/Source/KSCrash/swift/Basic/ManglingUtils.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===--- ManglingUtils.cpp - Utilities for Swift name mangling ------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -#include "ManglingUtils.h" - -using namespace swift; -using namespace Mangle; - - -bool Mangle::isNonAscii(StringRef str) { - for (unsigned char c : str) { - if (c >= 0x80) - return true; - } - return false; -} - -bool Mangle::needsPunycodeEncoding(StringRef str) { - for (unsigned char c : str) { - if (!isValidSymbolChar(c)) - return true; - } - return false; -} - -/// Translate the given operator character into its mangled form. -/// -/// Current operator characters: @/=-+*%<>!&|^~ and the special operator '..' -char Mangle::translateOperatorChar(char op) { - switch (op) { - case '&': return 'a'; // 'and' - case '@': return 'c'; // 'commercial at sign' - case '/': return 'd'; // 'divide' - case '=': return 'e'; // 'equal' - case '>': return 'g'; // 'greater' - case '<': return 'l'; // 'less' - case '*': return 'm'; // 'multiply' - case '!': return 'n'; // 'negate' - case '|': return 'o'; // 'or' - case '+': return 'p'; // 'plus' - case '?': return 'q'; // 'question' - case '%': return 'r'; // 'remainder' - case '-': return 's'; // 'subtract' - case '~': return 't'; // 'tilde' - case '^': return 'x'; // 'xor' - case '.': return 'z'; // 'zperiod' (the z is silent) - default: - return op; - } -} - -std::string Mangle::translateOperator(StringRef Op) { - std::string Encoded; - for (char ch : Op) { - Encoded.push_back(translateOperatorChar(ch)); - } - return Encoded; -} - -char Mangle::getStandardTypeSubst(StringRef TypeName) { -#define STANDARD_TYPE(KIND, MANGLING, TYPENAME) \ -if (TypeName == #TYPENAME) { \ -return #MANGLING[0]; \ -} - -#include "StandardTypesMangling.def" - - return 0; -} diff --git a/Source/KSCrash/swift/Basic/Punycode.cpp b/Source/KSCrash/swift/Basic/Punycode.cpp deleted file mode 100644 index 1a5df5e41..000000000 --- a/Source/KSCrash/swift/Basic/Punycode.cpp +++ /dev/null @@ -1,354 +0,0 @@ -//===--- Punycode.cpp - Unicode to Punycode transcoding -------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -#include "Punycode.h" -#include "ManglingUtils.h" -#include -#include - -using namespace swift; -using namespace Punycode; - -// RFC 3492 -// Section 5: Parameter values for Punycode - -static const int base = 36; -static const int tmin = 1; -static const int tmax = 26; -static const int skew = 38; -static const int damp = 700; -static const int initial_bias = 72; -static const uint32_t initial_n = 128; - -static const char delimiter = '_'; - -static char digit_value(int digit) { - assert(digit < base && "invalid punycode digit"); - if (digit < 26) - return 'a' + digit; - return 'A' - 26 + digit; -} - -static int digit_index(char value) { - if (value >= 'a' && value <= 'z') - return value - 'a'; - if (value >= 'A' && value <= 'J') - return value - 'A' + 26; - return -1; -} - -static bool isValidUnicodeScalar(uint32_t S) { - // Also accept the range of 0xD800 - 0xD880, which is used for non-symbol - // ASCII characters. - return (S < 0xD880) || (S >= 0xE000 && S <= 0x1FFFFF); -} - -// Section 6.1: Bias adaptation function - -static int adapt(int delta, int numpoints, bool firsttime) { - if (firsttime) - delta = delta / damp; - else - delta = delta / 2; - - delta += delta / numpoints; - int k = 0; - while (delta > ((base - tmin) * tmax) / 2) { - delta /= base - tmin; - k += base; - } - return k + (((base - tmin + 1) * delta) / (delta + skew)); -} - -// Section 6.2: Decoding procedure - -bool Punycode::decodePunycode(StringRef InputPunycode, - std::vector &OutCodePoints) { - OutCodePoints.clear(); - OutCodePoints.reserve(InputPunycode.size()); - - // -- Build the decoded string as UTF32 first because we need random access. - uint32_t n = initial_n; - int i = 0; - int bias = initial_bias; - /// let output = an empty string indexed from 0 - // consume all code points before the last delimiter (if there is one) - // and copy them to output, - size_t lastDelimiter = InputPunycode.find_last_of(delimiter); - if (lastDelimiter != StringRef::npos) { - for (char c : InputPunycode.slice(0, lastDelimiter)) { - // fail on any non-basic code point - if (static_cast(c) > 0x7f) - return true; - OutCodePoints.push_back(c); - } - // if more than zero code points were consumed then consume one more - // (which will be the last delimiter) - InputPunycode = - InputPunycode.slice(lastDelimiter + 1, InputPunycode.size()); - } - - while (!InputPunycode.empty()) { - int oldi = i; - int w = 1; - for (int k = base; ; k += base) { - // consume a code point, or fail if there was none to consume - if (InputPunycode.empty()) - return true; - char codePoint = InputPunycode.front(); - InputPunycode = InputPunycode.slice(1, InputPunycode.size()); - // let digit = the code point's digit-value, fail if it has none - int digit = digit_index(codePoint); - if (digit < 0) - return true; - - i = i + digit * w; - int t = k <= bias ? tmin - : k >= bias + tmax ? tmax - : k - bias; - if (digit < t) - break; - w = w * (base - t); - } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wconversion" - bias = adapt(i - oldi, OutCodePoints.size() + 1, oldi == 0); -#pragma clang diagnostic pop - n = n + i / (OutCodePoints.size() + 1); - i = i % (OutCodePoints.size() + 1); - // if n is a basic code point then fail - if (n < 0x80) - return true; - // insert n into output at position i - OutCodePoints.insert(OutCodePoints.begin() + i, n); - i++; - } - - return true; -} - -// Section 6.3: Encoding procedure - -bool Punycode::encodePunycode(const std::vector &InputCodePoints, - std::string &OutPunycode) { - OutPunycode.clear(); - - uint32_t n = initial_n; - int delta = 0; - int bias = initial_bias; - - // let h = b = the number of basic code points in the input - // copy them to the output in order... - size_t h = 0; - for (auto C : InputCodePoints) { - if (C < 0x80) { - ++h; - OutPunycode.push_back(C); - } - if (!isValidUnicodeScalar(C)) { - OutPunycode.clear(); - return false; - } - } - size_t b = h; - // ...followed by a delimiter if b > 0 - if (b > 0) - OutPunycode.push_back(delimiter); - - while (h < InputCodePoints.size()) { - // let m = the minimum code point >= n in the input - uint32_t m = 0x10FFFF; - for (auto codePoint : InputCodePoints) { - if (codePoint >= n && codePoint < m) - m = codePoint; - } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wconversion" - delta = delta + (m - n) * (h + 1); -#pragma clang diagnostic pop - n = m; - for (auto c : InputCodePoints) { - if (c < n) ++delta; - if (c == n) { - int q = delta; - for (int k = base; ; k += base) { - int t = k <= bias ? tmin - : k >= bias + tmax ? tmax - : k - bias; - - if (q < t) break; - OutPunycode.push_back(digit_value(t + ((q - t) % (base - t)))); - q = (q - t) / (base - t); - } - OutPunycode.push_back(digit_value(q)); -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wconversion" - bias = adapt(delta, h + 1, h == b); -#pragma clang diagnostic pop - delta = 0; - ++h; - } - } - ++delta; ++n; - } - return true; -} - -static bool encodeToUTF8(const std::vector &Scalars, - std::string &OutUTF8) { - for (auto S : Scalars) { - if (!isValidUnicodeScalar(S)) { - OutUTF8.clear(); - return false; - } - if (S >= 0xD800 && S < 0xD880) - S -= 0xD800; - - unsigned Bytes = 0; - if (S < 0x80) - Bytes = 1; - else if (S < 0x800) - Bytes = 2; - else if (S < 0x10000) - Bytes = 3; - else - Bytes = 4; - - switch (Bytes) { - case 1: - OutUTF8.push_back(S); - break; - case 2: { - uint8_t Byte2 = (S | 0x80) & 0xBF; - S >>= 6; - uint8_t Byte1 = S | 0xC0; - OutUTF8.push_back(Byte1); - OutUTF8.push_back(Byte2); - break; - } - case 3: { - uint8_t Byte3 = (S | 0x80) & 0xBF; - S >>= 6; - uint8_t Byte2 = (S | 0x80) & 0xBF; - S >>= 6; - uint8_t Byte1 = S | 0xE0; - OutUTF8.push_back(Byte1); - OutUTF8.push_back(Byte2); - OutUTF8.push_back(Byte3); - break; - } - case 4: { - uint8_t Byte4 = (S | 0x80) & 0xBF; - S >>= 6; - uint8_t Byte3 = (S | 0x80) & 0xBF; - S >>= 6; - uint8_t Byte2 = (S | 0x80) & 0xBF; - S >>= 6; - uint8_t Byte1 = S | 0xF0; - OutUTF8.push_back(Byte1); - OutUTF8.push_back(Byte2); - OutUTF8.push_back(Byte3); - OutUTF8.push_back(Byte4); - break; - } - } - } - return true; -} - -bool Punycode::decodePunycodeUTF8(StringRef InputPunycode, - std::string &OutUTF8) { - std::vector OutCodePoints; - if (!decodePunycode(InputPunycode, OutCodePoints)) - return false; - - return encodeToUTF8(OutCodePoints, OutUTF8); -} - -static bool isContinuationByte(uint8_t unit) { - return (unit & 0xC0) == 0x80; -} - -/// Reencode well-formed UTF-8 as UTF-32. -/// -/// This entry point is only called from compiler-internal entry points, so does -/// only minimal validation. In particular, it does *not* check for overlong -/// encodings. -/// If \p mapNonSymbolChars is true, non-symbol ASCII characters (characters -/// except [$_a-zA-Z0-9]) are also encoded like non-ASCII unicode characters. -/// Returns false if \p InputUTF8 contains surrogate code points. -static bool convertUTF8toUTF32(llvm::StringRef InputUTF8, - std::vector &OutUTF32, - bool mapNonSymbolChars) { - auto ptr = InputUTF8.begin(); - auto end = InputUTF8.end(); - while (ptr < end) { - uint8_t first = *ptr++; - if (first < 0x80) { - if (Mangle::isValidSymbolChar(first) || !mapNonSymbolChars) { - OutUTF32.push_back(first); - } else { - OutUTF32.push_back((uint32_t)first + 0xD800); - } - } else if (first < 0xC0) { - // Invalid continuation byte. - return false; - } else if (first < 0xE0) { - // Two-byte sequence. - if (ptr == end) - return false; - uint8_t second = *ptr++; - if (!isContinuationByte(second)) - return false; - OutUTF32.push_back(((first & 0x1F) << 6) | (second & 0x3F)); - } else if (first < 0xF0) { - // Three-byte sequence. - if (end - ptr < 2) - return false; - uint8_t second = *ptr++; - uint8_t third = *ptr++; - if (!isContinuationByte(second) || !isContinuationByte(third)) - return false; - OutUTF32.push_back(((first & 0xF) << 12) | ((second & 0x3F) << 6) - | ( third & 0x3F )); - } else if (first < 0xF8) { - // Four-byte sequence. - if (end - ptr < 3) - return false; - uint8_t second = *ptr++; - uint8_t third = *ptr++; - uint8_t fourth = *ptr++; - if (!isContinuationByte(second) || !isContinuationByte(third) - || !isContinuationByte(fourth)) - return false; - OutUTF32.push_back(((first & 0x7) << 18) | ((second & 0x3F) << 12) - | ((third & 0x3F) << 6) - | ( fourth & 0x3F )); - } else { - // Unused sequence length. - return false; - } - } - return true; -} - -bool Punycode::encodePunycodeUTF8(StringRef InputUTF8, - std::string &OutPunycode, - bool mapNonSymbolChars) { - std::vector InputCodePoints; - InputCodePoints.reserve(InputUTF8.size()); - - if (!convertUTF8toUTF32(InputUTF8, InputCodePoints, mapNonSymbolChars)) - return false; - - return encodePunycode(InputCodePoints, OutPunycode); -} diff --git a/Source/KSCrash/swift/Basic/Punycode.h b/Source/KSCrash/swift/Basic/Punycode.h deleted file mode 100644 index 794695209..000000000 --- a/Source/KSCrash/swift/Basic/Punycode.h +++ /dev/null @@ -1,64 +0,0 @@ -//===--- Punycode.h - UTF-8 to Punycode transcoding -------------*- C++ -*-===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// -// -// These functions implement a variant of the Punycode algorithm from RFC3492, -// originally designed for encoding international domain names, for the purpose -// of encoding Swift identifiers into mangled symbol names. This version differs -// from RFC3492 in the following respects: -// - '_' is used as the encoding delimiter instead of '-'. -// - Encoding digits are represented using [a-zA-J] instead of [a-z0-9], because -// symbol names are case-sensitive, and Swift mangled identifiers cannot begin -// with a digit. -// - Optionally, non-symbol ASCII characters (characters except [$_a-zA-Z0-9]) -// are mapped to the code range 0xD800 - 0xD880 and are also encoded like -// non-ASCII unicode characters. -// -//===----------------------------------------------------------------------===// - -#ifndef SWIFT_DEMANGLING_PUNYCODE_H -#define SWIFT_DEMANGLING_PUNYCODE_H - -#include "StringRef.h" -#include -#include - -namespace swift { - namespace Punycode { - - using llvm::StringRef; - - /// Encodes a sequence of code points into Punycode. - /// - /// Returns false if input contains surrogate code points. - bool encodePunycode(const std::vector &InputCodePoints, - std::string &OutPunycode); - - /// Decodes a Punycode string into a sequence of Unicode scalars. - /// - /// Returns false if decoding failed. - bool decodePunycode(StringRef InputPunycode, - std::vector &OutCodePoints); - - /// Encodes an UTF8 string into Punycode. - /// - /// If \p mapNonSymbolChars is true, non-symbol ASCII characters (characters - /// except [$_a-zA-Z0-9]) are also encoded like non-ASCII unicode characters. - /// Returns false if \p InputUTF8 contains surrogate code points. - bool encodePunycodeUTF8(StringRef InputUTF8, std::string &OutPunycode, - bool mapNonSymbolChars = false); - - bool decodePunycodeUTF8(StringRef InputPunycode, std::string &OutUTF8); - - } // end namespace Punycode -} // end namespace swift - -#endif // SWIFT_DEMANGLING_PUNYCODE_H diff --git a/iOS/KSCrash-iOS.xcodeproj/project.pbxproj b/iOS/KSCrash-iOS.xcodeproj/project.pbxproj index 5c437a905..98580079f 100644 --- a/iOS/KSCrash-iOS.xcodeproj/project.pbxproj +++ b/iOS/KSCrash-iOS.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -44,14 +44,6 @@ 03DE7C671C84DF9F00F789BA /* Casting.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F101C5AF2B10083A11B /* Casting.h */; settings = {ATTRIBUTES = (Private, ); }; }; 03DE7C681C84DF9F00F789BA /* Compiler.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F111C5AF2B10083A11B /* Compiler.h */; settings = {ATTRIBUTES = (Private, ); }; }; 03DE7C691C84DF9F00F789BA /* type_traits.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F121C5AF2B10083A11B /* type_traits.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 03DE7C6A1C84DFA400F789BA /* Demangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBC43F151C5AF2B10083A11B /* Demangle.cpp */; }; - 03DE7C6B1C84DFA400F789BA /* Demangle.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F161C5AF2B10083A11B /* Demangle.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 03DE7C6C1C84DFA400F789BA /* DemangleNodes.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F171C5AF2B10083A11B /* DemangleNodes.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 03DE7C6D1C84DFA400F789BA /* Fallthrough.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F181C5AF2B10083A11B /* Fallthrough.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 03DE7C6E1C84DFA400F789BA /* LLVM.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F191C5AF2B10083A11B /* LLVM.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 03DE7C6F1C84DFA400F789BA /* Malloc.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1A1C5AF2B10083A11B /* Malloc.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 03DE7C701C84DFA400F789BA /* Punycode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBC43F1B1C5AF2B10083A11B /* Punycode.cpp */; }; - 03DE7C711C84DFA400F789BA /* Punycode.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1C1C5AF2B10083A11B /* Punycode.h */; settings = {ATTRIBUTES = (Private, ); }; }; 03DE7C721C84DFA400F789BA /* SwiftStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1D1C5AF2B10083A11B /* SwiftStrings.h */; settings = {ATTRIBUTES = (Private, ); }; }; 03DE7C791C84DFAB00F789BA /* KSDynamicLinker.c in Sources */ = {isa = PBXBuildFile; fileRef = CB7A6C8E17FB96E800997792 /* KSDynamicLinker.c */; }; 03DE7C7A1C84DFAB00F789BA /* KSDynamicLinker.h in Headers */ = {isa = PBXBuildFile; fileRef = CB7A6C9117FB96FF00997792 /* KSDynamicLinker.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -139,7 +131,6 @@ 3E2D8A7E28BDB4D000CD8F92 /* KSCrashSignalInfo.c in Sources */ = {isa = PBXBuildFile; fileRef = 3E2D8A7C28BDB4D000CD8F92 /* KSCrashSignalInfo.c */; }; 3E2D8A8028BE79F500CD8F92 /* KSCrashSignalHandlerInfo_Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E2D8A7F28BE79F500CD8F92 /* KSCrashSignalHandlerInfo_Test.m */; }; 3E2D8A8128BE7B8000CD8F92 /* KSCrashSignalInfo.c in Sources */ = {isa = PBXBuildFile; fileRef = 3E2D8A7C28BDB4D000CD8F92 /* KSCrashSignalInfo.c */; }; - 3E2D8A8228BE7D5C00CD8F92 /* Demangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBC43F151C5AF2B10083A11B /* Demangle.cpp */; }; 3E2D8A8728BE81F500CD8F92 /* libswiftDemangle.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E2D8A8628BE81F500CD8F92 /* libswiftDemangle.tbd */; }; 632D8DAD1EDFFA6700A9A62E /* KSCrashC.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBF53D1F17EB765C0056DA83 /* KSCrashC.h */; }; 632D8DAE1EDFFA6700A9A62E /* KSCrashCachedData.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBA8A0C41E2561210019B5B9 /* KSCrashCachedData.h */; }; @@ -171,12 +162,6 @@ 632D8DC81EDFFA6700A9A62E /* Casting.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBC43F101C5AF2B10083A11B /* Casting.h */; }; 632D8DC91EDFFA6700A9A62E /* Compiler.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBC43F111C5AF2B10083A11B /* Compiler.h */; }; 632D8DCA1EDFFA6700A9A62E /* type_traits.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBC43F121C5AF2B10083A11B /* type_traits.h */; }; - 632D8DCB1EDFFA6700A9A62E /* Demangle.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBC43F161C5AF2B10083A11B /* Demangle.h */; }; - 632D8DCC1EDFFA6700A9A62E /* DemangleNodes.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBC43F171C5AF2B10083A11B /* DemangleNodes.h */; }; - 632D8DCD1EDFFA6700A9A62E /* Fallthrough.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBC43F181C5AF2B10083A11B /* Fallthrough.h */; }; - 632D8DCE1EDFFA6700A9A62E /* LLVM.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBC43F191C5AF2B10083A11B /* LLVM.h */; }; - 632D8DCF1EDFFA6700A9A62E /* Malloc.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1A1C5AF2B10083A11B /* Malloc.h */; }; - 632D8DD01EDFFA6700A9A62E /* Punycode.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1C1C5AF2B10083A11B /* Punycode.h */; }; 632D8DD11EDFFA6700A9A62E /* SwiftStrings.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1D1C5AF2B10083A11B /* SwiftStrings.h */; }; 632D8DD21EDFFA6700A9A62E /* KSCPU_Apple.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CB25A6051DF23D7300EC2B02 /* KSCPU_Apple.h */; }; 632D8DD31EDFFA6700A9A62E /* KSCPU.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = CB25A5B61DF2182A00EC2B02 /* KSCPU.h */; }; @@ -246,6 +231,8 @@ 6E889AE634130C8F37C2875A /* KSgetsect.c in Sources */ = {isa = PBXBuildFile; fileRef = 6E8894847F02F7B05F31FE4F /* KSgetsect.c */; }; 6E889B651331FD97EEB0C42F /* KSgetsect.c in Sources */ = {isa = PBXBuildFile; fileRef = 6E8894847F02F7B05F31FE4F /* KSgetsect.c */; }; 6E889F76F8DCC4749067A458 /* KSCxaThrowSwapper.c in Sources */ = {isa = PBXBuildFile; fileRef = 6E889A12BAE413442C0DA527 /* KSCxaThrowSwapper.c */; }; + 7B19663B2BC8BB5400F255AC /* AppleSwiftDemangling in Frameworks */ = {isa = PBXBuildFile; productRef = 7B19663A2BC8BB5400F255AC /* AppleSwiftDemangling */; }; + 7B19663D2BC8BB5C00F255AC /* AppleSwiftDemangling in Frameworks */ = {isa = PBXBuildFile; productRef = 7B19663C2BC8BB5C00F255AC /* AppleSwiftDemangling */; }; CB02648017F7CEC5003E0AED /* KSCPU_arm64.c in Sources */ = {isa = PBXBuildFile; fileRef = CB02647E17F7CEC5003E0AED /* KSCPU_arm64.c */; }; CB02648217F8D853003E0AED /* KSCrashMonitor_CPPException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBF53D4F17EB765C0056DA83 /* KSCrashMonitor_CPPException.cpp */; }; CB0264A917FA5B13003E0AED /* Container+DeepSearch_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = CB02648317FA5B12003E0AED /* Container+DeepSearch_Tests.m */; }; @@ -345,7 +332,6 @@ CB41F0781E0C992400A1C9D7 /* KSStackCursor.c in Sources */ = {isa = PBXBuildFile; fileRef = CB41F0771E0C992400A1C9D7 /* KSStackCursor.c */; }; CB41F0791E0C992400A1C9D7 /* KSStackCursor.c in Sources */ = {isa = PBXBuildFile; fileRef = CB41F0771E0C992400A1C9D7 /* KSStackCursor.c */; }; CB41F07A1E0C992400A1C9D7 /* KSStackCursor.c in Sources */ = {isa = PBXBuildFile; fileRef = CB41F0771E0C992400A1C9D7 /* KSStackCursor.c */; }; - CB42F4551C6D180F002FD017 /* DemangleNodes.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F171C5AF2B10083A11B /* DemangleNodes.h */; settings = {ATTRIBUTES = (Private, ); }; }; CB48F6CC1DCD0D490099D264 /* KSDemangle_CPP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB48F6C81DCD0D490099D264 /* KSDemangle_CPP.cpp */; }; CB48F6CD1DCD0D490099D264 /* KSDemangle_CPP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB48F6C81DCD0D490099D264 /* KSDemangle_CPP.cpp */; }; CB48F6CE1DCD0D490099D264 /* KSDemangle_CPP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB48F6C81DCD0D490099D264 /* KSDemangle_CPP.cpp */; }; @@ -436,13 +422,6 @@ CBC43F291C5AF2B10083A11B /* Casting.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F101C5AF2B10083A11B /* Casting.h */; settings = {ATTRIBUTES = (Private, ); }; }; CBC43F2B1C5AF2B10083A11B /* Compiler.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F111C5AF2B10083A11B /* Compiler.h */; settings = {ATTRIBUTES = (Private, ); }; }; CBC43F2D1C5AF2B10083A11B /* type_traits.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F121C5AF2B10083A11B /* type_traits.h */; settings = {ATTRIBUTES = (Private, ); }; }; - CBC43F2F1C5AF2B10083A11B /* Demangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBC43F151C5AF2B10083A11B /* Demangle.cpp */; }; - CBC43F311C5AF2B10083A11B /* Demangle.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F161C5AF2B10083A11B /* Demangle.h */; settings = {ATTRIBUTES = (Private, ); }; }; - CBC43F341C5AF2B10083A11B /* Fallthrough.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F181C5AF2B10083A11B /* Fallthrough.h */; settings = {ATTRIBUTES = (Private, ); }; }; - CBC43F361C5AF2B10083A11B /* LLVM.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F191C5AF2B10083A11B /* LLVM.h */; settings = {ATTRIBUTES = (Private, ); }; }; - CBC43F381C5AF2B10083A11B /* Malloc.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1A1C5AF2B10083A11B /* Malloc.h */; settings = {ATTRIBUTES = (Private, ); }; }; - CBC43F3A1C5AF2B10083A11B /* Punycode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBC43F1B1C5AF2B10083A11B /* Punycode.cpp */; }; - CBC43F3C1C5AF2B10083A11B /* Punycode.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1C1C5AF2B10083A11B /* Punycode.h */; settings = {ATTRIBUTES = (Private, ); }; }; CBC43F3E1C5AF2B10083A11B /* SwiftStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1D1C5AF2B10083A11B /* SwiftStrings.h */; settings = {ATTRIBUTES = (Private, ); }; }; CBEE5C181CB83F4C005EAF61 /* KSSystemCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CBEE5C171CB83F4C005EAF61 /* KSSystemCapabilities.h */; settings = {ATTRIBUTES = (Private, ); }; }; CBEE5C191CB83F4C005EAF61 /* KSSystemCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CBEE5C171CB83F4C005EAF61 /* KSSystemCapabilities.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -559,7 +538,6 @@ EDF2BE7C1CCF15AD004BADF4 /* KSDynamicLinker.c in Sources */ = {isa = PBXBuildFile; fileRef = CB7A6C8E17FB96E800997792 /* KSDynamicLinker.c */; }; EDF2BE7D1CCF15AD004BADF4 /* KSCrashMonitor_Deadlock.m in Sources */ = {isa = PBXBuildFile; fileRef = CBF53D5117EB765C0056DA83 /* KSCrashMonitor_Deadlock.m */; }; EDF2BE7E1CCF15AD004BADF4 /* KSCrashReportSinkEMail.m in Sources */ = {isa = PBXBuildFile; fileRef = CBF53D4417EB765C0056DA83 /* KSCrashReportSinkEMail.m */; }; - EDF2BE7F1CCF15AD004BADF4 /* Demangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBC43F151C5AF2B10083A11B /* Demangle.cpp */; }; EDF2BE801CCF15AD004BADF4 /* KSCrashInstallationEmail.m in Sources */ = {isa = PBXBuildFile; fileRef = CBF53D2917EB765C0056DA83 /* KSCrashInstallationEmail.m */; }; EDF2BE811CCF15AD004BADF4 /* NSError+SimpleConstructor.m in Sources */ = {isa = PBXBuildFile; fileRef = CBF53D8E17EB765C0056DA83 /* NSError+SimpleConstructor.m */; }; EDF2BE831CCF15AD004BADF4 /* KSCPU_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = CBF53D7117EB765C0056DA83 /* KSCPU_x86_64.c */; }; @@ -569,7 +547,6 @@ EDF2BE871CCF15AD004BADF4 /* KSCrashReportFilterStringify.m in Sources */ = {isa = PBXBuildFile; fileRef = CB94D3621CAC190900806679 /* KSCrashReportFilterStringify.m */; }; EDF2BE881CCF15AD004BADF4 /* KSCrashInstallationQuincyHockey.m in Sources */ = {isa = PBXBuildFile; fileRef = CBF53D2B17EB765C0056DA83 /* KSCrashInstallationQuincyHockey.m */; }; EDF2BE891CCF15AD004BADF4 /* KSCPU_arm.c in Sources */ = {isa = PBXBuildFile; fileRef = CBF53D6F17EB765C0056DA83 /* KSCPU_arm.c */; }; - EDF2BE8A1CCF15AD004BADF4 /* Punycode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBC43F1B1C5AF2B10083A11B /* Punycode.cpp */; }; EDF2BE8C1CCF15AD004BADF4 /* KSCrashDoctor.m in Sources */ = {isa = PBXBuildFile; fileRef = CBF53D2417EB765C0056DA83 /* KSCrashDoctor.m */; }; EDF2BE8D1CCF15AD004BADF4 /* KSJSONCodec.c in Sources */ = {isa = PBXBuildFile; fileRef = CBF53D6917EB765C0056DA83 /* KSJSONCodec.c */; }; EDF2BE8E1CCF15AD004BADF4 /* KSCrashC.c in Sources */ = {isa = PBXBuildFile; fileRef = CBF53D1E17EB765C0056DA83 /* KSCrashC.c */; }; @@ -656,16 +633,13 @@ EDF2BEF01CCF15AD004BADF4 /* KSCrashMonitor_CPPException.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D4E17EB765C0056DA83 /* KSCrashMonitor_CPPException.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BEF11CCF15AD004BADF4 /* KSCrashDoctor.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D2317EB765C0056DA83 /* KSCrashDoctor.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BEF21CCF15AD004BADF4 /* KSCrashInstallationConsole.h in Headers */ = {isa = PBXBuildFile; fileRef = CB94D35B1CAC11B000806679 /* KSCrashInstallationConsole.h */; settings = {ATTRIBUTES = (Public, ); }; }; - EDF2BEF31CCF15AD004BADF4 /* Demangle.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F161C5AF2B10083A11B /* Demangle.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BEF51CCF15AD004BADF4 /* type_traits.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F121C5AF2B10083A11B /* type_traits.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BEF61CCF15AD004BADF4 /* KSObjCApple.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D7717EB765C0056DA83 /* KSObjCApple.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BEF71CCF15AD004BADF4 /* KSHTTPRequestSender.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D6717EB765C0056DA83 /* KSHTTPRequestSender.h */; settings = {ATTRIBUTES = (Private, ); }; }; - EDF2BEF81CCF15AD004BADF4 /* DemangleNodes.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F171C5AF2B10083A11B /* DemangleNodes.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BEF91CCF15AD004BADF4 /* KSFileUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D6417EB765C0056DA83 /* KSFileUtils.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BEFA1CCF15AD004BADF4 /* KSCrashInstallation+Alert.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8F1DC41CCADB2A0022CDF0 /* KSCrashInstallation+Alert.h */; settings = {ATTRIBUTES = (Public, ); }; }; EDF2BEFB1CCF15AD004BADF4 /* KSDynamicLinker.h in Headers */ = {isa = PBXBuildFile; fileRef = CB7A6C9117FB96FF00997792 /* KSDynamicLinker.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BEFC1CCF15AD004BADF4 /* KSCrashMonitor_Deadlock.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D5017EB765C0056DA83 /* KSCrashMonitor_Deadlock.h */; settings = {ATTRIBUTES = (Private, ); }; }; - EDF2BEFD1CCF15AD004BADF4 /* Punycode.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1C1C5AF2B10083A11B /* Punycode.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BEFE1CCF15AD004BADF4 /* NSError+SimpleConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D8D17EB765C0056DA83 /* NSError+SimpleConstructor.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BEFF1CCF15AD004BADF4 /* KSCString.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D6117EB765C0056DA83 /* KSCString.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF001CCF15AD004BADF4 /* Casting.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F101C5AF2B10083A11B /* Casting.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -673,16 +647,13 @@ EDF2BF021CCF15AD004BADF4 /* KSJSONCodec.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D6A17EB765C0056DA83 /* KSJSONCodec.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF031CCF15AD004BADF4 /* KSReachabilityKSCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D7817EB765C0056DA83 /* KSReachabilityKSCrash.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF041CCF15AD004BADF4 /* SwiftStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1D1C5AF2B10083A11B /* SwiftStrings.h */; settings = {ATTRIBUTES = (Private, ); }; }; - EDF2BF051CCF15AD004BADF4 /* Malloc.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F1A1C5AF2B10083A11B /* Malloc.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF071CCF15AD004BADF4 /* KSString.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D8017EB765C0056DA83 /* KSString.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF081CCF15AD004BADF4 /* Optional.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F0A1C5AF2B10083A11B /* Optional.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF0C1CCF15AD004BADF4 /* KSHTTPMultipartPostBody.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D6517EB765C0056DA83 /* KSHTTPMultipartPostBody.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF0D1CCF15AD004BADF4 /* KSCrashMonitor_System.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D8317EB765C0056DA83 /* KSCrashMonitor_System.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF0E1CCF15AD004BADF4 /* KSLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D6D17EB765C0056DA83 /* KSLogger.h */; settings = {ATTRIBUTES = (Private, ); }; }; - EDF2BF101CCF15AD004BADF4 /* LLVM.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F191C5AF2B10083A11B /* LLVM.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF111CCF15AD004BADF4 /* KSCrashInstallation+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D2717EB765C0056DA83 /* KSCrashInstallation+Private.h */; settings = {ATTRIBUTES = (Public, ); }; }; EDF2BF121CCF15AD004BADF4 /* KSSignalInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D7D17EB765C0056DA83 /* KSSignalInfo.h */; settings = {ATTRIBUTES = (Private, ); }; }; - EDF2BF131CCF15AD004BADF4 /* Fallthrough.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F181C5AF2B10083A11B /* Fallthrough.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF141CCF15AD004BADF4 /* None.h in Headers */ = {isa = PBXBuildFile; fileRef = CBC43F091C5AF2B10083A11B /* None.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF151CCF15AD004BADF4 /* KSObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D7617EB765C0056DA83 /* KSObjC.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDF2BF171CCF15AD004BADF4 /* Container+DeepSearch.h in Headers */ = {isa = PBXBuildFile; fileRef = CBF53D1317EB765C0056DA83 /* Container+DeepSearch.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -739,12 +710,6 @@ 632D8DC81EDFFA6700A9A62E /* Casting.h in Copy Headers */, 632D8DC91EDFFA6700A9A62E /* Compiler.h in Copy Headers */, 632D8DCA1EDFFA6700A9A62E /* type_traits.h in Copy Headers */, - 632D8DCB1EDFFA6700A9A62E /* Demangle.h in Copy Headers */, - 632D8DCC1EDFFA6700A9A62E /* DemangleNodes.h in Copy Headers */, - 632D8DCD1EDFFA6700A9A62E /* Fallthrough.h in Copy Headers */, - 632D8DCE1EDFFA6700A9A62E /* LLVM.h in Copy Headers */, - 632D8DCF1EDFFA6700A9A62E /* Malloc.h in Copy Headers */, - 632D8DD01EDFFA6700A9A62E /* Punycode.h in Copy Headers */, 632D8DD11EDFFA6700A9A62E /* SwiftStrings.h in Copy Headers */, 632D8DD21EDFFA6700A9A62E /* KSCPU_Apple.h in Copy Headers */, 632D8DD31EDFFA6700A9A62E /* KSCPU.h in Copy Headers */, @@ -941,14 +906,6 @@ CBC43F101C5AF2B10083A11B /* Casting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Casting.h; sourceTree = ""; }; CBC43F111C5AF2B10083A11B /* Compiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Compiler.h; sourceTree = ""; }; CBC43F121C5AF2B10083A11B /* type_traits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = type_traits.h; sourceTree = ""; }; - CBC43F151C5AF2B10083A11B /* Demangle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Demangle.cpp; sourceTree = ""; }; - CBC43F161C5AF2B10083A11B /* Demangle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Demangle.h; sourceTree = ""; }; - CBC43F171C5AF2B10083A11B /* DemangleNodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemangleNodes.h; sourceTree = ""; }; - CBC43F181C5AF2B10083A11B /* Fallthrough.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Fallthrough.h; sourceTree = ""; }; - CBC43F191C5AF2B10083A11B /* LLVM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LLVM.h; sourceTree = ""; }; - CBC43F1A1C5AF2B10083A11B /* Malloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Malloc.h; sourceTree = ""; }; - CBC43F1B1C5AF2B10083A11B /* Punycode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Punycode.cpp; sourceTree = ""; }; - CBC43F1C1C5AF2B10083A11B /* Punycode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Punycode.h; sourceTree = ""; }; CBC43F1D1C5AF2B10083A11B /* SwiftStrings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SwiftStrings.h; sourceTree = ""; }; CBEE5C171CB83F4C005EAF61 /* KSSystemCapabilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KSSystemCapabilities.h; path = ../../Source/KSCrash/Recording/KSSystemCapabilities.h; sourceTree = ""; }; CBEE5DC01CBC197D005EAF61 /* NSString+URLEncode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+URLEncode.h"; path = "../../Source/KSCrash/Reporting/Tools/NSString+URLEncode.h"; sourceTree = ""; }; @@ -1068,6 +1025,7 @@ buildActionMask = 2147483647; files = ( 03DE7CD71C84E1F400F789BA /* libz.tbd in Frameworks */, + 7B19663D2BC8BB5C00F255AC /* AppleSwiftDemangling in Frameworks */, 03DE7CD51C84E02A00F789BA /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1077,6 +1035,7 @@ buildActionMask = 2147483647; files = ( CB6D132717EB749A00BC2C04 /* Foundation.framework in Frameworks */, + 7B19663B2BC8BB5400F255AC /* AppleSwiftDemangling in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1298,14 +1257,6 @@ CBC43F141C5AF2B10083A11B /* Basic */ = { isa = PBXGroup; children = ( - CBC43F151C5AF2B10083A11B /* Demangle.cpp */, - CBC43F161C5AF2B10083A11B /* Demangle.h */, - CBC43F171C5AF2B10083A11B /* DemangleNodes.h */, - CBC43F181C5AF2B10083A11B /* Fallthrough.h */, - CBC43F191C5AF2B10083A11B /* LLVM.h */, - CBC43F1A1C5AF2B10083A11B /* Malloc.h */, - CBC43F1B1C5AF2B10083A11B /* Punycode.cpp */, - CBC43F1C1C5AF2B10083A11B /* Punycode.h */, ); path = Basic; sourceTree = ""; @@ -1606,18 +1557,15 @@ 03DE7C511C84DF8100F789BA /* KSCrashDoctor.h in Headers */, CB25A5BB1DF2182A00EC2B02 /* KSCPU.h in Headers */, CB94D35E1CAC11B000806679 /* KSCrashInstallationConsole.h in Headers */, - 03DE7C6B1C84DFA400F789BA /* Demangle.h in Headers */, 3E2D8A7D28BDB4D000CD8F92 /* KSCrashSignalInfo.h in Headers */, 03DE7C691C84DF9F00F789BA /* type_traits.h in Headers */, 03DE7C8C1C84DFAB00F789BA /* KSObjCApple.h in Headers */, 03DE7CC11C84DFC100F789BA /* KSHTTPRequestSender.h in Headers */, - 03DE7C6C1C84DFA400F789BA /* DemangleNodes.h in Headers */, 03DE7C7C1C84DFAB00F789BA /* KSFileUtils.h in Headers */, CB8F1DC71CCADB2A0022CDF0 /* KSCrashInstallation+Alert.h in Headers */, CB0C19C31DD0F2EE005B2F80 /* KSCrashReportFixer.h in Headers */, 03DE7C7A1C84DFAB00F789BA /* KSDynamicLinker.h in Headers */, 03DE7C571C84DF8600F789BA /* KSCrashMonitor_Deadlock.h in Headers */, - 03DE7C711C84DFA400F789BA /* Punycode.h in Headers */, CB25A6071DF23D7300EC2B02 /* KSCPU_Apple.h in Headers */, 03DE7C9A1C84DFAB00F789BA /* NSError+SimpleConstructor.h in Headers */, 03DE7CBD1C84DFC100F789BA /* KSCString.h in Headers */, @@ -1626,16 +1574,13 @@ 03DE7C7E1C84DFAB00F789BA /* KSJSONCodec.h in Headers */, 03DE7CC31C84DFC100F789BA /* KSReachabilityKSCrash.h in Headers */, 03DE7C721C84DFA400F789BA /* SwiftStrings.h in Headers */, - 03DE7C6F1C84DFA400F789BA /* Malloc.h in Headers */, CB69B8C91DC03FFF002713B1 /* KSDate.h in Headers */, 03DE7C931C84DFAB00F789BA /* KSString.h in Headers */, 03DE7C631C84DF9200F789BA /* Optional.h in Headers */, 03DE7CBF1C84DFC100F789BA /* KSHTTPMultipartPostBody.h in Headers */, CBB61CC51E0035E4000C24A6 /* KSID.h in Headers */, 03DE7C811C84DFAB00F789BA /* KSLogger.h in Headers */, - 03DE7C6E1C84DFA400F789BA /* LLVM.h in Headers */, 03DE7C901C84DFAB00F789BA /* KSSignalInfo.h in Headers */, - 03DE7C6D1C84DFA400F789BA /* Fallthrough.h in Headers */, CB25A5F31DF2396700EC2B02 /* KSDebug.h in Headers */, 03DE7C621C84DF9200F789BA /* None.h in Headers */, 03DE7C8B1C84DFAB00F789BA /* KSObjC.h in Headers */, @@ -1659,7 +1604,6 @@ CBC43F2B1C5AF2B10083A11B /* Compiler.h in Headers */, CB5657EE1E1D8A71005A8302 /* KSStackCursor_SelfThread.h in Headers */, CBF53E9717EB7EA80056DA83 /* KSCrashInstallationStandard.h in Headers */, - CBC43F341C5AF2B10083A11B /* Fallthrough.h in Headers */, CBF53E9817EB7EA80056DA83 /* KSCrashInstallationVictory.h in Headers */, CBF53E7917EB7EA80056DA83 /* KSCrashReportFilter.h in Headers */, CBA8A0C81E2561210019B5B9 /* KSCrashCachedData.h in Headers */, @@ -1675,7 +1619,6 @@ CBF53E8117EB7EA80056DA83 /* KSCrashReportSinkEMail.h in Headers */, CBF53E8217EB7EA80056DA83 /* KSCrashReportSinkQuincyHockey.h in Headers */, CBA997711C9214AD00D12149 /* KSCrashReportVersion.h in Headers */, - CB42F4551C6D180F002FD017 /* DemangleNodes.h in Headers */, CBF53E8317EB7EA80056DA83 /* KSCrashReportSinkStandard.h in Headers */, CB8F1DC61CCADB2A0022CDF0 /* KSCrashInstallation+Alert.h in Headers */, CB5633CC1DD5392A0023CEB6 /* KSCrashMonitorContext.h in Headers */, @@ -1690,7 +1633,6 @@ CBF53E5C17EB7EA80056DA83 /* KSCrashMonitorType.h in Headers */, CB7A6C9317FB96FF00997792 /* KSDynamicLinker.h in Headers */, CBF53E6D17EB7EA80056DA83 /* KSJSONCodecObjC.h in Headers */, - CBC43F361C5AF2B10083A11B /* LLVM.h in Headers */, CBF53E7717EB7EA80056DA83 /* KSCrashMonitor_Zombie.h in Headers */, CBF53E6617EB7EA80056DA83 /* KSCrashMonitor_User.h in Headers */, CBF53E6E17EB7EA80056DA83 /* KSLogger.h in Headers */, @@ -1729,7 +1671,6 @@ CB5657DE1E1CB8CE005A8302 /* KSSymbolicator.h in Headers */, CBF53E7517EB7EA80056DA83 /* KSString.h in Headers */, CBF53E7217EB7EA80056DA83 /* KSObjCApple.h in Headers */, - CBC43F3C1C5AF2B10083A11B /* Punycode.h in Headers */, CBF53E8917EB7EA80056DA83 /* KSCString.h in Headers */, CB41F0741E0C4F8B00A1C9D7 /* KSStackCursor_MachineContext.h in Headers */, CBF53E5917EB7EA80056DA83 /* KSCrashReportFields.h in Headers */, @@ -1744,9 +1685,7 @@ CBF53E6B17EB7EA80056DA83 /* KSFileUtils.h in Headers */, CB25A5F21DF2396700EC2B02 /* KSDebug.h in Headers */, CBF53E8B17EB7EA80056DA83 /* KSHTTPRequestSender.h in Headers */, - CBC43F311C5AF2B10083A11B /* Demangle.h in Headers */, CB9821C31DFB359B00164220 /* KSMach.h in Headers */, - CBC43F381C5AF2B10083A11B /* Malloc.h in Headers */, CBF53E6F17EB7EA80056DA83 /* KSMemory.h in Headers */, 6E889783AAA2CC2831E0FE2D /* KSgetsect.h in Headers */, ); @@ -1813,18 +1752,15 @@ CB25A6171DF25EF100EC2B02 /* KSMachineContext.h in Headers */, CB25A61B1DF278D900EC2B02 /* KSMachineContext_Apple.h in Headers */, EDF2BEF21CCF15AD004BADF4 /* KSCrashInstallationConsole.h in Headers */, - EDF2BEF31CCF15AD004BADF4 /* Demangle.h in Headers */, CB25A5BC1DF2182A00EC2B02 /* KSCPU.h in Headers */, EDF2BEF51CCF15AD004BADF4 /* type_traits.h in Headers */, EDF2BEF61CCF15AD004BADF4 /* KSObjCApple.h in Headers */, EDF2BEF71CCF15AD004BADF4 /* KSHTTPRequestSender.h in Headers */, - EDF2BEF81CCF15AD004BADF4 /* DemangleNodes.h in Headers */, EDF2BEF91CCF15AD004BADF4 /* KSFileUtils.h in Headers */, EDF2BEFA1CCF15AD004BADF4 /* KSCrashInstallation+Alert.h in Headers */, EDF2BEFB1CCF15AD004BADF4 /* KSDynamicLinker.h in Headers */, EDF2BEFC1CCF15AD004BADF4 /* KSCrashMonitor_Deadlock.h in Headers */, CB0C19C41DD0F2EE005B2F80 /* KSCrashReportFixer.h in Headers */, - EDF2BEFD1CCF15AD004BADF4 /* Punycode.h in Headers */, EDF2BEFE1CCF15AD004BADF4 /* NSError+SimpleConstructor.h in Headers */, EDF2BEFF1CCF15AD004BADF4 /* KSCString.h in Headers */, CB25A6081DF23D7300EC2B02 /* KSCPU_Apple.h in Headers */, @@ -1833,7 +1769,6 @@ EDF2BF021CCF15AD004BADF4 /* KSJSONCodec.h in Headers */, EDF2BF031CCF15AD004BADF4 /* KSReachabilityKSCrash.h in Headers */, EDF2BF041CCF15AD004BADF4 /* SwiftStrings.h in Headers */, - EDF2BF051CCF15AD004BADF4 /* Malloc.h in Headers */, EDF2BF071CCF15AD004BADF4 /* KSString.h in Headers */, EDF2BF081CCF15AD004BADF4 /* Optional.h in Headers */, CB69B8CA1DC03FFF002713B1 /* KSDate.h in Headers */, @@ -1841,10 +1776,8 @@ EDF2BF0D1CCF15AD004BADF4 /* KSCrashMonitor_System.h in Headers */, EDF2BF0E1CCF15AD004BADF4 /* KSLogger.h in Headers */, CBB61CC61E0035E4000C24A6 /* KSID.h in Headers */, - EDF2BF101CCF15AD004BADF4 /* LLVM.h in Headers */, EDF2BF111CCF15AD004BADF4 /* KSCrashInstallation+Private.h in Headers */, EDF2BF121CCF15AD004BADF4 /* KSSignalInfo.h in Headers */, - EDF2BF131CCF15AD004BADF4 /* Fallthrough.h in Headers */, CB25A5F41DF2396700EC2B02 /* KSDebug.h in Headers */, EDF2BF141CCF15AD004BADF4 /* None.h in Headers */, EDF2BF151CCF15AD004BADF4 /* KSObjC.h in Headers */, @@ -1874,6 +1807,9 @@ dependencies = ( ); name = KSCrash; + packageProductDependencies = ( + 7B19663C2BC8BB5C00F255AC /* AppleSwiftDemangling */, + ); productName = KSCrashFramework; productReference = 03DE7B6A1C84DEF700F789BA /* KSCrash.framework */; productType = "com.apple.product-type.framework"; @@ -1892,6 +1828,9 @@ dependencies = ( ); name = KSCrashLib; + packageProductDependencies = ( + 7B19663A2BC8BB5400F255AC /* AppleSwiftDemangling */, + ); productName = KSCrashLib; productReference = CB6D132617EB749A00BC2C04 /* libKSCrashLib.a */; productType = "com.apple.product-type.library.static"; @@ -1959,6 +1898,9 @@ Base, ); mainGroup = CB52178317EB735D007CB3C1; + packageReferences = ( + 7B414D712BC6ED0B00DF0CA8 /* XCRemoteSwiftPackageReference "swift-demangler" */, + ); productRefGroup = CB52178D17EB735D007CB3C1 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -2010,7 +1952,6 @@ 03DE7C581C84DF8600F789BA /* KSCrashMonitor_Deadlock.m in Sources */, 03DE7CA31C84DFB100F789BA /* KSCrashReportSinkEMail.m in Sources */, CB25A5D81DF22F4000EC2B02 /* KSThread.c in Sources */, - 03DE7C6A1C84DFA400F789BA /* Demangle.cpp in Sources */, CB0C19C01DD0F2EE005B2F80 /* KSCrashReportFixer.c in Sources */, 03DE7CCB1C84DFCD00F789BA /* KSCrashInstallationEmail.m in Sources */, CB5657DC1E1CB8CE005A8302 /* KSSymbolicator.c in Sources */, @@ -2024,7 +1965,6 @@ CB48F6CD1DCD0D490099D264 /* KSDemangle_CPP.cpp in Sources */, 03DE7C851C84DFAB00F789BA /* KSCPU_arm.c in Sources */, CB41F0721E0C4F8B00A1C9D7 /* KSStackCursor_MachineContext.c in Sources */, - 03DE7C701C84DFA400F789BA /* Punycode.cpp in Sources */, 03DE7C521C84DF8100F789BA /* KSCrashDoctor.m in Sources */, 03DE7C7D1C84DFAB00F789BA /* KSJSONCodec.c in Sources */, 03DE7C411C84DF8100F789BA /* KSCrashC.c in Sources */, @@ -2121,7 +2061,6 @@ CBF53DBB17EB765C0056DA83 /* KSCrashInstallationVictory.m in Sources */, CBF53DEF17EB765C0056DA83 /* KSCrashMonitor_MachException.c in Sources */, CBF53DDA17EB765C0056DA83 /* KSCrashReportSinkEMail.m in Sources */, - CBC43F2F1C5AF2B10083A11B /* Demangle.cpp in Sources */, CB7A6C9017FB96E800997792 /* KSDynamicLinker.c in Sources */, CBF53DD417EB765C0056DA83 /* KSCrashReportFilterSets.m in Sources */, CBF53E3517EB765C0056DA83 /* KSSysCtl.c in Sources */, @@ -2148,7 +2087,6 @@ CBF53E0817EB765C0056DA83 /* KSFileUtils.c in Sources */, CBF53DF917EB765C0056DA83 /* KSCrashMonitor_User.c in Sources */, CBF53DD117EB765C0056DA83 /* KSCrashReportFilterJSON.m in Sources */, - CBC43F3A1C5AF2B10083A11B /* Punycode.cpp in Sources */, CBF53E4A17EB765C0056DA83 /* NSMutableData+AppendUTF8.m in Sources */, CBF53E4717EB765C0056DA83 /* NSError+SimpleConstructor.m in Sources */, CBF53DCB17EB765C0056DA83 /* KSCrashReportFilterBasic.m in Sources */, @@ -2214,7 +2152,6 @@ CB0264CC17FA5B13003E0AED /* XCTestCase+KSCrash.m in Sources */, CBA8A0CC1E2579FE0019B5B9 /* KSCrashCachedData_Tests.m in Sources */, CB0C19C61DD1265B005B2F80 /* KSCrashReportFixer_Tests.m in Sources */, - 3E2D8A8228BE7D5C00CD8F92 /* Demangle.cpp in Sources */, CB0264C317FA5B13003E0AED /* KSString_Tests.m in Sources */, CB0264BD17FA5B13003E0AED /* KSJSONCodec_Tests.m in Sources */, ); @@ -2230,7 +2167,6 @@ EDF2BE7D1CCF15AD004BADF4 /* KSCrashMonitor_Deadlock.m in Sources */, EDF2BE7E1CCF15AD004BADF4 /* KSCrashReportSinkEMail.m in Sources */, CB25A5D91DF22F4000EC2B02 /* KSThread.c in Sources */, - EDF2BE7F1CCF15AD004BADF4 /* Demangle.cpp in Sources */, CB0C19C11DD0F2EE005B2F80 /* KSCrashReportFixer.c in Sources */, EDF2BE801CCF15AD004BADF4 /* KSCrashInstallationEmail.m in Sources */, CB5657DD1E1CB8CE005A8302 /* KSSymbolicator.c in Sources */, @@ -2244,7 +2180,6 @@ CB48F6CE1DCD0D490099D264 /* KSDemangle_CPP.cpp in Sources */, EDF2BE891CCF15AD004BADF4 /* KSCPU_arm.c in Sources */, CB41F0731E0C4F8B00A1C9D7 /* KSStackCursor_MachineContext.c in Sources */, - EDF2BE8A1CCF15AD004BADF4 /* Punycode.cpp in Sources */, EDF2BE8C1CCF15AD004BADF4 /* KSCrashDoctor.m in Sources */, EDF2BE8D1CCF15AD004BADF4 /* KSJSONCodec.c in Sources */, EDF2BE8E1CCF15AD004BADF4 /* KSCrashC.c in Sources */, @@ -2353,8 +2288,12 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = "KSCrash/KSCrash-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MODULEMAP_FILE = ../Source/Framework/module.modulemap; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = org.stenerud.KSCrash; @@ -2386,8 +2325,12 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = "KSCrash/KSCrash-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MODULEMAP_FILE = ../Source/Framework/module.modulemap; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = org.stenerud.KSCrash; @@ -2587,6 +2530,7 @@ "$(inherited)", ); INFOPLIST_FILE = "KSCrashTests/KSCrashTests-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(SDKROOT)/usr/lib/swift", @@ -2608,6 +2552,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "KSCrash/KSCrash-Prefix.pch"; INFOPLIST_FILE = "KSCrashTests/KSCrashTests-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(SDKROOT)/usr/lib/swift", @@ -2637,7 +2582,11 @@ INFOPLIST_FILE = "$(SRCROOT)/KSCrash/KSCrash_static-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MACH_O_TYPE = staticlib; MODULEMAP_FILE = ../Source/Framework/module.modulemap; MTL_ENABLE_DEBUG_INFO = YES; @@ -2671,7 +2620,11 @@ INFOPLIST_FILE = "$(SRCROOT)/KSCrash/KSCrash_static-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MACH_O_TYPE = staticlib; MODULEMAP_FILE = ../Source/Framework/module.modulemap; MTL_ENABLE_DEBUG_INFO = NO; @@ -2733,6 +2686,30 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 7B414D712BC6ED0B00DF0CA8 /* XCRemoteSwiftPackageReference "swift-demangler" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/embrace-io/swift-demangler"; + requirement = { + branch = main; + kind = branch; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 7B19663A2BC8BB5400F255AC /* AppleSwiftDemangling */ = { + isa = XCSwiftPackageProductDependency; + package = 7B414D712BC6ED0B00DF0CA8 /* XCRemoteSwiftPackageReference "swift-demangler" */; + productName = AppleSwiftDemangling; + }; + 7B19663C2BC8BB5C00F255AC /* AppleSwiftDemangling */ = { + isa = XCSwiftPackageProductDependency; + package = 7B414D712BC6ED0B00DF0CA8 /* XCRemoteSwiftPackageReference "swift-demangler" */; + productName = AppleSwiftDemangling; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = CB52178417EB735D007CB3C1 /* Project object */; } diff --git a/iOS/KSCrash-iOS.xcodeproj/xcshareddata/xcschemes/KSCrash-iOS.xcscheme b/iOS/KSCrash-iOS.xcodeproj/xcshareddata/xcschemes/KSCrash-iOS.xcscheme index a60311709..a07e353cd 100644 --- a/iOS/KSCrash-iOS.xcodeproj/xcshareddata/xcschemes/KSCrash-iOS.xcscheme +++ b/iOS/KSCrash-iOS.xcodeproj/xcshareddata/xcschemes/KSCrash-iOS.xcscheme @@ -26,18 +26,14 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> - - - -