- Allow them to use substitutions.
- Consistently use 'a' as a mangling operator.
- For generic typealiases, include the alias as context for any generic
parameters.
Typealiases don't show up in symbol names, which always refer to
canonical types, but they are mangled for debug info and for USRs
(unique identifiers used by SourceKit), so it's good to get this
right.
I /think/ this can only come up in invalid code like
class Outer {
let _ = { class Inner {} }
}
but we still try to generate USRs for this. Just use the enclosing
context as the current context so that we still generate /some/ valid
mangling.
This can show up when trying to generate USRs for a document with
errors in it. This isn't a great answer because the names it generates
aren't unique (there may be more than one nameless entity with the
same type), but it at least generates valid mangled names.
When generating mangled names for purposes other than USRs, nameless
entities are now checked for by an assertion.
This lets the mangling preserve the invariant that functions always
structurally have function types. Error types don't show up in mangled
names often anyway, but it can occur when you ask for the USR of a
function with an invalid type.
A protocol composition with an explicit 'AnyObject' member is
now mangled as <protocol list> 'Xl'. For subclass existentials,
I changed the mangling from <protocol list> <class> 'XE' to
<protocol list> <class> 'Xl'.
Not used for anything just yet.
This fixes a crash while building the Swift standard library when
partial specializations are enabled.
Eventually we should get rid of needing the DeclContext in the mangled
typename at all, and this is one step towards that goal.
rdar://problem/31253373
Simply mangling the derived method is no longer sufficient. Now also
mangle the base method, so that eventually we handle this sort of
scenario:
class Base {
// introduces: Base.method
func method(_: Int, _: Int) {}
}
class First : Base {
// overrides: Base.method
// introduces: First.method
override func method(_: Int?, _: Int) {}
}
class Second : First {
// overrides: Base.method, First.method
// introduces: Second.method
override func method(_: Int?, _: Int?) {}
}
Here, the override of Base.method by Second.method and the
override of First.method by Second.method require distinct
manglings even though the derived method (Second.method) is
the same in both cases.
Note that while the new mangling is longer, vtable thunks are
always emitted with private linkage, so with the exception of
the standard library which is built with -sil-serialize-all
they will not affect the size of dylibs.
The standard library itself has very few classes so it doesn't
matter there either.
This patch doesn't actually add any support to introduce new
vtable entries for methods that override; this is coming up
next.
Parameter defs with a separate external argument label are marked with the 'Local' symbol property.
This ensures the indexer has enough information for clients to match up a function's argument labels with its child parameter definitions.
Resolves rdar://problem/31039915.
Previously it was part of swiftBasic.
The demangler library does not depend on llvm (except some header-only utilities like StringRef). Putting it into its own library makes sure that no llvm stuff will be linked into clients which use the demangler library.
This change also contains other refactoring, like moving demangler code into different files. This makes it easier to remove the old demangler from the runtime library when we switch to the new symbol mangling.
Also in this commit: remove some unused API functions from the demangler Context.
fixes rdar://problem/30503344
Instead of appending a character for each substitution, we now prefix the substitution with the repeat count, e.g.
AbbbbB -> A5B
The same is done for known-type substitutions, e.g.
SiSiSi -> S3i
This significantly shrinks mangled names which contain large lists of the same type, like
func foo(_ x: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int))
rdar://problem/30707433
In the following example, the two declarations should have
the same mangled type:
protocol P {
associatedtype P
}
func f1<T : P>(_: T) -> T.P where T.P == Int {}
func f2<T : P>(_: T) -> Int where T.P == Int {}
To ensure this is the case, canonicalize the entire
GenericFunctionType before taking it apart, instead of
canonicalizing structural components of it.
Only those types can be de-mangled by the ObjC runtime anyway.
Also move this mangling logic into the ASTMangler class. This avoids keeping the old mangler around just for that purpose.
Separate formal lowered types from SIL types.
The SIL type of an argument will depend on the SIL module's conventions.
The module conventions are determined by the SIL stage and LangOpts.
Almost NFC, but specialized manglings are broken incidentally as a result of
fixes to the way passes handle book-keeping of aruments. The mangler is fixed in
the subsequent commit.
Otherwise, NFC is intended, but quite possible do to rewriting the logic in many
places.