Commit Graph

107 Commits

Author SHA1 Message Date
John McCall
4b48c8915c Demangle reabstraction thunks (and impl-function-type generally).
Swift SVN r11493
2013-12-20 00:46:56 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
John McCall
8505c4a00d Further refactoring/simplification of the demangler.
Not NFC: changes some of the demangling tree schemata (in
interest of regularity and expressivity) and, incidentally,
improves support for initializer manglings.

The main schema change is that Path is now gone, and instead
the first child of an entity is its context.  All contexts
are now labelled with their kind (variable/function/etc.)
rather than that being much more obscure or missing.

A secondary change is that the top-level node is now a
single node with the <global> and all its attributes as
children, rather than being weirdly sibling-linked.

Also, the representation has changed so that nodes link
only to their children, not to siblings or parents, which
means that it is no longer necessary to clone nodes when
replacing substitutions.

Finally, dump/print was brought in from swift-demangler
and made part of the core API for debugging purposes.

Swift SVN r11470
2013-12-19 08:57:06 +00:00
John McCall
c9aad99674 Further reduce the API surface area and complexity of demangling nodes.
Swift SVN r11469
2013-12-19 08:57:05 +00:00
John McCall
1d8d2d15ed Remove the need for Node::setKind.
Swift SVN r11468
2013-12-19 08:57:04 +00:00
John McCall
1751c6d3e4 Bring the demangler closer to Swift code style. NFC.
Swift SVN r11443
2013-12-18 22:22:15 +00:00
John McCall
c5aa41ffd1 Change around some manglings to make them carry more
information and be easier to demangle.

Swift SVN r11423
2013-12-18 08:33:52 +00:00
Enrico Granata
0109df6ddd This would not affect the display of the demangled type name, but would cause LLDB to fail to retrieve the type, as it went looking for the wrong kind of thing
Swift SVN r10976
2013-12-07 03:24:50 +00:00
Dave Abrahams
7ab9d369aa [stdlib] Rename Char => UnicodeScalar
Swift SVN r10864
2013-12-05 17:30:37 +00:00
Adrian Prantl
7e3cfd48e8 demangler: don't consume the same character twice
Swift SVN r10793
2013-12-04 21:45:18 +00:00
Enrico Granata
627488fe04 Add an option to the Demangler to not show the type of ivars when displaying their "field offset" symbols
iVars of a given type should be unique by name and so in certain cases, their types will not actually add information to a consumer of the demangled string
This mode is mostly useful for LLDB. When searching for a field offset by name in a generic scenario, the search can succeed or fail depending on whether archetypes are
obtained through the Demangler ("A","B","C") or through the module (which will vend proper archetype names when poked the right way)
This mode removes that ambiguity



Swift SVN r10761
2013-12-03 22:37:43 +00:00
Adrian Prantl
41e92af7ae Mangler: Add a DWARF-only mangling for type aliases that includes the
decl context of the type alias.
This implements <rdar://problem/15290346> "typealias sugar needs to be
mangled into debug info mangled type names".

Swift SVN r10749
2013-12-03 17:15:18 +00:00
Dave Zarzycki
8bd3582d3e 15242776 stdlib: rename Slice to Array
The "HArray" name is temporary.

Swift SVN r10707
2013-12-01 08:16:30 +00:00
Adrian Prantl
4fc5c9637b Mangler: Eliminate an ambiguity in the mangling of contexts.
<rdar://problem/15444866> Mangling is ambiguous -- may want prefix for functions

Swift SVN r10669
2013-11-23 00:56:16 +00:00
Enrico Granata
1d46859477 This is a temporary Demangler change to allow demangling of function decl-contexts when part of a qualified archetype
This "greedy" demangling should not be necessary anymore once <rdar://problem/15444866> goes in
As of now, this extension should help LLDB support generics in functions



Swift SVN r10493
2013-11-15 18:27:05 +00:00
Joe Groff
cdb6e7b8bd Handle 'Bw' -> 'Builtin.Word' mangling in the demangler.
Swift SVN r10485
2013-11-15 01:22:11 +00:00
Enrico Granata
aa0bc1f697 Start demangling the new Qq production that Adrian introduced in r10470
Swift SVN r10478
2013-11-15 00:18:45 +00:00
Enrico Granata
dc1c1104bc Don't let the demangler crash when presented an incomplete generic type
Fixes <rdar://problem/15444832>



Swift SVN r10390
2013-11-13 00:14:15 +00:00
Enrico Granata
5c8c45624b Removing a few unused Demangler node kinds
Swift SVN r10379
2013-11-12 22:24:20 +00:00
Enrico Granata
6e666c7c22 <rdar://problem/15321132>
Demangle nominal type descriptor _TMn correctly



Swift SVN r9675
2013-10-25 18:02:46 +00:00
Enrico Granata
ef9a1b32d4 <rdar://problem/15213551>
This checkin extends the Demangler to allow printing sugar on demangled types
Namely, it introduces a DemanglerOptions class with just one field SynthesizeSugarOnTypes which has the same functionality as PrintOptions::SynthesizeSugarOnTypes
This changes outputs like _TtGSqC5sugar7MyClass_ ---> swift.Optional<sugar.MyClass> into _TtGSqC5sugar7MyClass_ ---> sugar.MyClass?

By default this flag is false, so that existing clients of the Demangler API do not break

OTOH, the command-line tool swift-demangle flags sets the flag to true, unless the -no-sugar option is passed on the command-line

Test cases included



Swift SVN r9502
2013-10-18 22:05:08 +00:00
Chris Lattner
a476f65471 Abolish the old attribute syntax for type attributes (and SIL type attrs)
- Change type attribute printing logic (in astprinter and the demangler) 
  to print in the new syntax
- Change the swift parser to only accept type attributes in the new syntax.
- Update canParseTypeTupleBody to lookahead over new-syntax type attributes.
- Update the testsuite to use the new syntax.



Swift SVN r9273
2013-10-13 05:39:46 +00:00
Joe Groff
3d4c1251f1 Rename 'byref' attribute to 'inout'.
Swift SVN r8661
2013-09-25 20:56:52 +00:00
Enrico Granata
d967efd2d2 Give the same love to swift.Bool which is also an enum that we were vending as a struct
Swift SVN r8610
2013-09-24 22:20:53 +00:00
Enrico Granata
44ec002ffb Fixing up the demangling for swift.Optional<T> to be an Enum instead of a struct
(Optional is an hardcoded substitution, so even if its definition changes, the mangling won't change, and the demangler has to keep up!)



Swift SVN r8609
2013-09-24 22:17:32 +00:00
Argyrios Kyrtzidis
9e0cfb811d [AST] Allow the mangler to handle declarations with error types in them.
This is only useful for unique-identification uses of the mangler, like in SourceKit,
which has to deal with invalid code.
Since this is not related to ABI, we can change the encoding anytime we want.

Swift SVN r8557
2013-09-23 16:11:26 +00:00
Doug Gregor
bc3f655105 s/constructor/init in a few more places.
Swift SVN r8504
2013-09-20 18:37:15 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
Enrico Granata
d33691a051 <rdar://problem/15013536>
Fixing the demangler to correctly deal with weak/unowned refs
Also, enhancing the node structure



Swift SVN r8454
2013-09-19 18:29:39 +00:00
Enrico Granata
60f5503c9d Making ProtocolList have a TypeList child
This makes it easier for the LLDB side to obtain a ProtocolCompositionType from a demangled tree



Swift SVN r8294
2013-09-16 20:53:39 +00:00
Joe Groff
c65f4c3f43 Rework archetype mangling to follow parent hierarchy.
Use the ordinal archetype manglings only for the primary archetypes of a generic context, and define a mangling for associated types relative to their parent archetype. This will make the archetype mangling resilient in the face of our planned improvements to associated type and protocol conformance ABI. It also correctly mangles self and associated types of protocols, which my previous attempt utterly failed to accomplish.

Swift SVN r8174
2013-09-13 01:16:27 +00:00
Enrico Granata
a1ac2dd16f <rdar://problem/14971418>
This one-liner fixes an issue where protocol contexts were demangling incorrectly, essentially stripping out the protocol



Swift SVN r8170
2013-09-12 23:14:06 +00:00
Joe Groff
6dbc1a8835 Add manglings for associated types.
This should allow declarations inside protocols to mangle successfully, which is needed by SourceKit to be able to use mangled names as unique decl identifiers. I'm also planning to use mangled protocol decls to name generic curry thunk symbols.

This only introduces a mangling for independent associated types. I think we will eventually want to mangle dependent associated types (such as T.AssocType for an archetype T : SomeProtocol) with a non-indexed mangling too, but this doesn't do that yet.

Swift SVN r8148
2013-09-12 15:29:08 +00:00
Enrico Granata
b3576d8599 Replacing the GenericTypeApplication node with more specific BoundGeneric{Class|Structure|Union} nodes
Removing the TypeList node underneath a TypeList, a TypeList just needs to wrap a list of Type nodes



Swift SVN r7990
2013-09-06 17:47:06 +00:00
Enrico Granata
80278dfedc Simplifying the demangling for UncurriedFunctionType objects, from:
k = UncurriedFunctionType
  k = UncurriedFunctionMetaType
    k = Type
      k = MetaType

to:
k = UncurriedFunctionType
  k = MetaType

This should help Greg parse uncurried functions with greater ease



Swift SVN r7964
2013-09-05 23:09:10 +00:00
Enrico Granata
60163b464e Removing the : between name and type for function declarations, since that does not exist in the language.
A function will now be demangled as:

module.function (args) -> retType vs. module.function : (args) -> retType

Also clearing out a couple warnings that Greg pointed out



Swift SVN r7725
2013-08-29 18:39:25 +00:00
Enrico Granata
389c867551 Making the Demangler work properly with nested types, in the sense that Paths that represent nested types need to come out flat instead of hierarchical
Adding a couple test cases for this



Swift SVN r7724
2013-08-29 18:20:09 +00:00
Enrico Granata
72112bf575 More demangler changes - these introduce a new structure to the demangling that is better suited to Greg\'s need to produce types and decls out of demangled trees
Swift SVN r7714
2013-08-29 01:52:58 +00:00
Enrico Granata
a199242321 Sending 7641 again + a fix for the inf loop that Dmitri found
I also added that one as a test case



Swift SVN r7656
2013-08-28 01:02:01 +00:00
Dmitri Hrybenko
6eb5bc58d2 Revert r7641. It causes an infloop while demangling a name in test/SILGen/class_bound_protocols.swift
Swift SVN r7647
2013-08-27 23:36:35 +00:00
Enrico Granata
ff3ea6e3ce <rdar://problem/14830080> & <rdar://problem/14822344>
The previous implementation of the tree structure for the demangler had a bug in the low-level tree management code which caused the tree structure to diverge depending on whether
nodes were added as siblings or children. This checkin fixes the issue by making sure that the tree of nodes is kept coherent at all times.
Some adjustments are necessary to ensure the nodes were still generated properly and correctly turned into strings
Added a new test case



Swift SVN r7643
2013-08-27 22:56:48 +00:00
Enrico Granata
f2ba4c8c59 This commit changes the way the Demangler handles substitutions
Previously, substitutions were treated as unstructured text chunks, but this was causing problems when using the demangler as a source of structured type information
This patch ensures that substitutions are properly stored as the type they represent for later semantic reconstruction



Swift SVN r7494
2013-08-23 00:21:26 +00:00
Joe Groff
80bec3d955 Give swift.Option a standard mangling substitution.
Swift SVN r7455
2013-08-22 17:36:58 +00:00
Enrico Granata
687b142101 Undoing the damage of clang-format + first round of demangler cleanup
Swift SVN r7342
2013-08-19 23:15:51 +00:00
Enrico Granata
2d97d22d33 clang-formatted the Demangler
Swift SVN r7334
2013-08-19 22:34:30 +00:00
Enrico Granata
74f111d310 The space here was needed
Swift SVN r7333
2013-08-19 22:26:19 +00:00
Enrico Granata
de0e9c7f6f Fixing a crasher where the demangler was not checking a substitution for NULL
Swift SVN r7331
2013-08-19 21:38:29 +00:00
Enrico Granata
c127e98f1c Removing non doxygen-kosher comments
Swift SVN r7298
2013-08-16 22:46:39 +00:00
Enrico Granata
47d1a137b5 Major demangler changes.
This commit changes the Swift demangler to produce a tree-like list of tokens instead of a string.
This is mostly useful for LLDB since we can use the inherent structure in a Swift mangled name to make more informed decisions about matters such as type information extraction from modules
The ability to convert the tokenized output into a plain string for viewing purposes is of course preserved



Swift SVN r7297
2013-08-16 22:30:58 +00:00
Joe Groff
a94489473c IRGen: Add ValueWitness enumerators for union layout and access.
These value witness table entries will be conditionally available for types that support specialized union representation through extra inhabitants and/or spare bits and for union value witnesses:

- storeExtraInhabitant, to store an extra inhabitant representation;
- getExtraInhabitantIndex, to recognize an extra inhabitant representation;
- getUnionTag, to get a union's discriminator; and
- inplaceProjectUnionData, to extract the value in place from a union.

This just sets up the enumerators and related IR types and mangling; nothing emits these witnesses yet.

Swift SVN r7234
2013-08-14 21:01:21 +00:00