Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions docs/ABI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ Entities
entity-spec ::= decl-name type 'i' // subscript ('i'ndex) itself (not the individual accessors)
entity-spec ::= decl-name type 'v' // variable
entity-spec ::= decl-name type 'f' ACCESSOR
entity-spec ::= decl-name type 'fp' // generic type parameter (not used?)
entity-spec ::= decl-name type 'fp' // generic type parameter
entity-spec ::= decl-name type 'fo' // enum element (currently not used)

ACCESSOR ::= 'm' // materializeForSet
Expand Down Expand Up @@ -958,14 +958,15 @@ Types

::

nominal-type ::= substitution
nominal-type ::= context decl-name 'C' // nominal class type
nominal-type ::= context decl-name 'O' // nominal enum type
nominal-type ::= context decl-name 'V' // nominal struct type
nominal-type ::= protocol 'P' // nominal protocol type
any-generic-type ::= substitution
any-generic-type ::= context decl-name 'C' // nominal class type
any-generic-type ::= context decl-name 'O' // nominal enum type
any-generic-type ::= context decl-name 'V' // nominal struct type
any-generic-type ::= protocol 'P' // nominal protocol type
any-generic-type ::= context decl-name 'a' // typealias type (used in DWARF and USRs)

nominal-type ::= 'S' KNOWN-TYPE-KIND // known nominal type substitution
nominal-type ::= 'S' NATURAL KNOWN-TYPE-KIND // repeated known type substitutions of the same kind
any-generic-type ::= 'S' KNOWN-TYPE-KIND // known nominal type substitution
any-generic-type ::= 'S' NATURAL KNOWN-TYPE-KIND // repeated known type substitutions of the same kind

KNOWN-TYPE-KIND ::= 'a' // Swift.Array
KNOWN-TYPE-KIND ::= 'b' // Swift.Bool
Expand Down Expand Up @@ -995,7 +996,6 @@ Types
type ::= 'Bp' // Builtin.RawPointer
type ::= type 'Bv' NATURAL '_' // Builtin.Vec<n>x<type>
type ::= 'Bw' // Builtin.Word
type ::= context decl-name 'a' // Type alias (DWARF only)
type ::= function-signature 'c' // function type
type ::= function-signature 'X' FUNCTION-KIND // special function type
type ::= bound-generic-type
Expand Down Expand Up @@ -1042,7 +1042,7 @@ Types

type ::= archetype
type ::= associated-type
type ::= nominal-type
type ::= any-generic-type
type ::= protocol-list 'p' // existential type
type ::= protocol-list superclass 'Xc' // existential type with superclass
type ::= protocol-list 'Xl' // existential type with AnyObject
Expand Down
11 changes: 8 additions & 3 deletions include/swift/AST/ASTMangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class ASTMangler : public Mangler {
/// If enabled, Arche- and Alias types are mangled with context.
bool DWARFMangling;

/// If enabled, entities that ought to have names but don't get a placeholder.
///
/// If disabled, it is an error to try to mangle such an entity.
bool AllowNamelessEntities = false;

public:
enum class SymbolKind {
Default,
Expand Down Expand Up @@ -122,7 +127,7 @@ class ASTMangler : public Mangler {

std::string mangleTypeAsContextUSR(const NominalTypeDecl *type);

std::string mangleDeclAsUSR(ValueDecl *Decl, StringRef USRPrefix);
std::string mangleDeclAsUSR(const ValueDecl *Decl, StringRef USRPrefix);

std::string mangleAccessorEntityAsUSR(AccessorKind kind,
AddressorKind addressorKind,
Expand Down Expand Up @@ -167,7 +172,7 @@ class ASTMangler : public Mangler {

void appendProtocolName(const ProtocolDecl *protocol);

void appendNominalType(const NominalTypeDecl *decl);
void appendAnyGenericType(const GenericTypeDecl *decl);

void appendFunctionType(AnyFunctionType *fn, bool forceSingleParam);

Expand Down Expand Up @@ -207,7 +212,7 @@ class ASTMangler : public Mangler {

void appendDeclType(const ValueDecl *decl, bool isFunctionMangling = false);

bool tryAppendStandardSubstitution(const NominalTypeDecl *type);
bool tryAppendStandardSubstitution(const GenericTypeDecl *type);

void appendConstructorEntity(const ConstructorDecl *ctor, bool isAllocating);

Expand Down
9 changes: 4 additions & 5 deletions include/swift/Basic/Mangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
#define SWIFT_BASIC_MANGLER_H

#include "swift/Demangling/ManglingUtils.h"
#include "swift/Basic/LLVM.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/raw_ostream.h"

using llvm::StringRef;
using llvm::ArrayRef;

namespace swift {
namespace Mangle {

Expand All @@ -39,7 +38,7 @@ class Mangler {
friend class SubstitutionMerging;

/// The storage for the mangled symbol.
llvm::SmallVector<char, 128> Storage;
llvm::SmallString<128> Storage;

/// The output stream for the mangled symbol.
llvm::raw_svector_ostream Buffer;
Expand Down Expand Up @@ -106,7 +105,7 @@ class Mangler {
void finalize(llvm::raw_ostream &stream);

/// Verify that demangling and remangling works.
void verify(const std::string &mangledName);
static void verify(StringRef mangledName);

/// Appends a mangled identifier string.
void appendIdentifier(StringRef ident);
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Demangling/DemangleNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ NODE(Tuple)
NODE(TupleElement)
NODE(TupleElementName)
NODE(Type)
NODE(TypeAlias)
CONTEXT_NODE(TypeAlias)
NODE(TypeList)
NODE(TypeMangling)
NODE(TypeMetadata)
Expand Down
3 changes: 1 addition & 2 deletions include/swift/Demangling/Demangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ class Demangler : public NodeFactory {
NodePointer popTypeAndGetChild();
NodePointer popTypeAndGetNominal();
NodePointer demangleBuiltinType();
NodePointer demangleNominalType(Node::Kind kind);
NodePointer demangleTypeAlias();
NodePointer demangleAnyGenericType(Node::Kind kind);
NodePointer demangleExtensionContext();
NodePointer demanglePlainFunction();
NodePointer popFunctionType(Node::Kind kind);
Expand Down
Loading