Commit Graph

21 Commits

Author SHA1 Message Date
Raj Barik
e215abc3fa Add ExistentialToGeneric mangling and demangling code 2018-05-14 15:26:18 -07:00
Michael Gottesman
afc98b34e9 [func-sig-opts] Add a new mangling for the guaranteed->owned transformation.
I followed the example of the owned->guaranteed transformation.

rdar://38196046
2018-04-26 16:36:41 -07:00
Slava Pestov
902c0d3586 Runtime: Handle symbolic references inside other mangling nodes
Previously we could only handle symbolic references at the
top level, but this is insufficient; for example, you can
have a nested type X.Y where X is defined in the current
translation unit and Y is defined in an extension of X in
a different translation unit. In this case, X.Y mangles as
a tree where the child contains a symbolic reference to X.

Handle this by adding a new form of Demangle::mangleNode()
which takes a callback for resolving symbolic references.

Fixes <rdar://problem/39613190>.
2018-04-20 21:55:45 -07:00
Sho Ikeda
17b833a831 [gardening][Demangling] Replace typedef with using 2018-03-29 13:39:10 +09:00
Mike Ash
03476e919e Merge branch 'master' into remove-reflectionlegacy 2018-02-22 11:44:55 -05:00
Mike Ash
c250a844d0 [Runtime] Add a declaration for swift_demangle to the header file and export it.
rdar://problem/20356017
2018-02-21 17:22:09 -05:00
Davide Italiano
fe43d0bc76 [Demangler] Add convenience functions to ask about types.
And use them in the reflection library (TypeRef). These were
private to `TypeRef.cpp` but can be moved to the demangler as
they can be of general use, and we can use them from lldb (which
has homemade versions of the functions as well). Bonus point,
it probably makes sense for these helpers to live in the demangler
anyway.

<rdar://problem/37710513>
2018-02-20 11:38:13 -08:00
Joe Groff
953dddd5d3 IRGen/Runtime: Allow mangled type refs to embed "symbolic references" to type context descriptors.
This makes resolving mangled names to nominal types in the same module more efficient, and for eventual secrecy improvements, also allows types in the same module to be referenced from mangled typerefs without encoding any source-level name information about them.
2018-02-10 10:43:47 -08:00
Doug Gregor
82140ca811 [Demangle] Add back isSwiftSymbol() entry point for null-terminated strings.
This particular API can be safely used with a null-terminated string,
and is used by some clients (e.g., LLDB), so add back a "const char *"
variant that safely accesses a null-terminated string.
2018-01-10 14:27:37 -08:00
Doug Gregor
e28e856595 [Runtime] Use bare protocol mangling for protocol descriptors.
The mangled name of protocol descriptors was the “protocol composition”
type consisting of a single protocol, which is a little odd. Instead,
use a bare protocol reference (e.g., “6Module5ProtoP”) with the “$S”
prefer to be more in line with nominal type descriptor names while still
making it clear that this is a Swift (not an Objective-C) protocol.
2018-01-09 10:21:55 -08:00
Doug Gregor
5f2a6b82ce [Demangle] StringRef-ify entry points.
isMangledName() was passing the data() pointer to a routine that assumed
it was getting a null-terminated string. Define away this class of error
by using StringRef consistently.
2018-01-09 10:06:51 -08:00
Pavel Yaskevich
25f59f06f2 [Mangler] Support functions with old parameter label mangling scheme
Make function mangling backward compatible based on the prefix
of the mangled symbol, which is used to distinguish between names
with old/new parameter label mangling schemes.

Resolves: rdar://problem/36357120
2018-01-08 18:04:07 -08:00
Erik Eckstein
79c522a49d demangler: Support the future final mangling prefix $S
As it’s not clear if we will need underscores, the demangler accepts $S and _$S.
Note that a double underscore is handled by the demangler client.

rdar://problem/32251811
2017-06-26 11:32:26 -07:00
Erik Eckstein
285addb92d Switch back to the old mangling for ObjC runtime names.
To be backward compatible to existing archives created by the NSKeyedArchiver
2017-05-03 10:52:54 -07:00
practicalswift
7eb7d5b109 [gardening] Fix 100 typos. 2017-04-18 17:01:42 +02:00
Erik Eckstein
8dcdb7a193 Mangler: Classify protocol witnesses as thunks.
Protocol witnesses just call the actual implementation in the conforming type.
2017-04-13 15:41:07 -07:00
Erik Eckstein
789646a15b Demangling: Make demangled names more readable and further reduce the size of the simplified demangled names
The goal here is to make the short demangling as short and readable as possible, also at the cost of omitting some information.
The assumption is that whenever the short demangling is displayed, there is a way for the user to also get the full demangled name if needed.

*) omit <where ...> because it does not give useful information anyway

Deserializer.deserialize<A where ...> () throws -> [A]
--> Deserializer.deserialize<A> () throws -> [A]

*) for multiple specialized functions only emit a single “specialized”

specialized specialized Constructible.create(A.Element) -> Constructible<A>
--> specialized Constructible.create(A.Element) -> Constructible<A>

*) Don’t print function argument types:

foo(Int, Double, named: Int)
--> foo(_:_:named:)

This is a trade-off, because it can lead to ambiguity if there are overloads with different types.

*) make contexts of closures, local functions, etc. more readable by using “<a> in <b>” syntax
This is also done for the full and not only for the simplified demangling.

Renderer.(renderInlines([Inline]) -> String).(closure #1)
--> closure #1 in Renderer.renderInlines

*) change spacing, so that it matches our coding style:

foo <A> (x : A)
--> foo<A>(x: A)
2017-04-13 08:43:28 -07:00
Erik Eckstein
793d0ad12b Demangler: fix a memory problem with the NodeDumper 2017-03-20 16:12:23 -07:00
Erik Eckstein
a408060754 Remove the old re-mangler.
NFC except the swift-demangle does not check for correct old-style re-mangling anymore.
2017-03-17 16:10:36 -07:00
Erik Eckstein
0f87b5efb2 Remove the useNewMangling function
NFC
2017-03-17 16:10:36 -07:00
Erik Eckstein
5e80555c9b demangler: put the demangler into a separate library
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
2017-03-09 13:42:43 -08:00