Commit Graph

47 Commits

Author SHA1 Message Date
Joe Groff
08fe138808 Runtime: Generate a human-understandable name for Any.Type.
Expose this in the stdlib as _typeName(Any.Type) -> String, pending API review.

Swift SVN r23254
2014-11-11 23:38:24 +00:00
Dmitri Hrybenko
927222808a Demangle: extract std::string data without going through c_str() API
Swift SVN r22941
2014-10-25 08:20:18 +00:00
Greg Parker
59f3ef1ca1 Print the source and target type names when a dynamic cast fails.
rdar://18223450. Some types do not have friendly output yet (rdar://16392852).


Swift SVN r22938
2014-10-25 01:37:49 +00:00
Dmitri Hrybenko
4a103e459d Include cassert in Demangle.h because it uses assert()
Swift SVN r22313
2014-09-27 22:51:13 +00:00
Enrico Granata
6fc7ef2910 Make it easy to safely get a shared_ptr to a Node given a plain old pointer to it. This is a small step towards getting all Demangler APIs to return Node* but still retain ref-counting
Swift SVN r20330
2014-07-22 20:47:09 +00:00
Enrico Granata
d8e4b2c468 The Demangler should only use one currency to vend nodes externally, as it makes clients' lives much much easier - I am specifically thinking LLDB here, since the debugger likes to store nodes it gets out of the demangler as it generates types out of them. Since we are storing everything as a shared_ptr<Node>, having some accessors return Node* and some NodePointer is really not buying us much. Fix things here
Swift SVN r20268
2014-07-21 19:05:32 +00:00
Dmitri Hrybenko
26277fc41d Demangler: remove StringRef dependencies in the demangler interface and
PrettyStackTrace dependencies in the implementation


Swift SVN r20248
2014-07-21 12:46:58 +00:00
Dmitri Hrybenko
62fcf6ae32 Demangler: remove dependency on swift/Basic/LLVM.h
Swift SVN r20148
2014-07-18 09:15:20 +00:00
Dmitri Hrybenko
96e2e8d50c Demangler: replace llvm::SmallVector with std::vector
Swift SVN r20095
2014-07-17 16:09:42 +00:00
Dmitri Hrybenko
537ac90bcd DemanglerOptions: remove redundant member initializer list
Swift SVN r20092
2014-07-17 15:59:15 +00:00
Dmitri Hrybenko
70e0577767 Demangler: replace LLVM reference counting with std::shared_ptr (which is not
actually necessary here, since all tree nodes could be just allocated from a
single pool)

Steps towards rdar://16929868


Swift SVN r20090
2014-07-17 15:35:29 +00:00
Chris Lattner
67aeb2e7c0 adjust to mainline API change (IntrusiveRefCntPtr::getPtr() renamed to get())
Swift SVN r19605
2014-07-07 14:37:16 +00:00
John McCall
c5d2d972ee Add an x-macro system for demangling nodes and use it to
generate getNodeKindString automatically.

Swift SVN r11899
2014-01-04 09:49:35 +00:00
John McCall
e9e928d509 Remove the last vestiges of the 'L' local-linkage mangling prefix.
Swift SVN r11896
2014-01-04 09:11:16 +00:00
John McCall
4355a21a62 Mangle closures using their context and discriminator.
Swift SVN r11885
2014-01-04 04:37:57 +00:00
John McCall
ad1e198a3a Recognize unmangled suffixes at the end of a mangling.
Swift SVN r11866
2014-01-03 19:39:08 +00:00
John McCall
186c0243f1 Mangle the discriminator into local declaration names.
Swift SVN r11522
2013-12-20 22:50:51 +00:00
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
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
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
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
Joe Groff
3d4c1251f1 Rename 'byref' attribute to 'inout'.
Swift SVN r8661
2013-09-25 20:56:52 +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
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
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
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
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
Chris Lattner
8d1f71deb1 demangle some of the demangler source code.
Swift SVN r7335
2013-08-19 22:37:53 +00:00
Enrico Granata
2d97d22d33 clang-formatted the Demangler
Swift SVN r7334
2013-08-19 22:34:30 +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
Dmitri Hrybenko
de59d8dcd4 Remove unneeded llvm:: qualifier for llvm::StringRef and llvm::SmallVector
Swift SVN r7089
2013-08-09 18:41:46 +00:00
Enrico Granata
c3d42b5f86 Removing the demangleType() API and the --type flag to swift-demangle
Types now have proper mangled names of the form _Tt<...> so they don't need any special treatment



Swift SVN r6816
2013-08-01 21:00:05 +00:00
Enrico Granata
c75fe924a1 Moving the Swift demangler from libSIL to libBasic
Plus, a couple of minor cosmetic changes that I had held off for a couple days now



Swift SVN r6691
2013-07-29 17:42:57 +00:00