Commit Graph

71 Commits

Author SHA1 Message Date
practicalswift
50baf2e53b Use consistent formatting in top of file headers. 2016-01-04 02:17:48 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Slava Pestov
36ddea64ae Merge pull request #729 from ken0nek/fix-can-not
Convert [Cc]an not -> [Cc]annot
2015-12-22 16:06:20 -08:00
Nadav Rotem
b0b9b5de05 Replace the magic ascii value with something less cryptic. 2015-12-22 16:05:21 -08:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
Joe Groff
e55a3e1538 AllocBoxToStack: Update for box-only captures.
Change the logic to handle transforming @box T parameters into @inout_aliased T indirect parameters, instead of just dead-stripping boxes.
2015-12-08 14:35:48 -08:00
Joe Groff
172aee7f51 CapturePromotion: Update to handle lone box arguments.
Match the new SILGen pattern, where only the box parameter is partially applied to the closure, and the address of the value is projected on the callee side.
2015-12-08 14:35:47 -08:00
Joe Groff
9ea30d00fe Runtime: Remove custom operator new(InPlace).
C++ no longer imposes a null check requirement on placement 'new', and clang no longer emits the null check. This hack is no longer needed.
2015-11-18 12:31:24 -08:00
Joe Groff
7c68fc14c4 Add a comment for why Demangler::isDigit isn't just std::isdigit. 2015-11-18 12:01:00 -08:00
Joe Groff
a3b6bef4e5 Runtime: Use new(InPlace) in more places to avoid unwanted null checks. 2015-11-17 14:13:48 -08:00
Joe Groff
385f4cc38c Demangle: Use our own isDigit instead of isdigit.
Darwin's isdigit is strangely heavy, looking up traits in _DefaultRuneLocale instead of a simple comparison pair.
2015-11-17 14:13:48 -08:00
Joe Groff
86fab4a8f7 Demangler/Remangler: Purge iostreams. 2015-11-16 13:05:19 -08:00
David Farler
8d441c0391 Simplified demangling: continue to print context names
The demangler recently regressed to not printing any context
names, including nominal type contexts. This means that symbols
like Optional.init where only printed as init. Continue printing
contexts but not modules (per the original simplified demangling
design).

rdar://problem/19312992

Swift SVN r31066
2015-08-07 05:37:38 +00:00
David Farler
b460aa0c86 Further shorten demangled names in simplified mode
Break up "Simplified" demangling mode (shortened demangled descriptions
for the sake of displaying in UI with small areas) into more
fine-grained options instead of an opaque "Simplified" option and
provide a static preset of options for displaying stack traces in
Xcode UI and other tools, for example.

- Don't print unmangled suffixes
- Don't print module names
- Shorten various generic specialization descriptions as just
  "specialized"
- Don't display long protocol conformances
- Truncate where clauses
- Don't display so-called "entity" types
- Shorten "partial apply *"
- Shorten thunk phrases
- Shorten value witness phrases
- Truncate archetype references

rdar://problem/21753651

Swift SVN r30247
2015-07-16 03:35:46 +00:00
Slava Pestov
cdd5a4121c IRGen: Generate value witnesses to get enum tag and project payload
These will be used for reflection, and eventually to speed up generic
operations on single payload enums as well.

Progress on <rdar://problem/21739870>.

Swift SVN r30214
2015-07-15 06:03:18 +00:00
Joe Groff
db0fea590e stdlib: Use unqualified names in 'print'.
Leave the qualification off of enum cases and type names when 'print'-ing them, but keep them on 'debugPrint'. (At least, at the outermost level; since ad-hoc printing of structs and tuples uses debugPrint, we'll still get qualification at depth, which kind of sucks but needs more invasive state management in print to make possible.) Implements rdar://problem/21788604.

Swift SVN r30166
2015-07-13 21:42:11 +00:00
Michael Gottesman
7ac6831bc6 [func-sig-opts] Eliminate dead arguments that are dead besides an @owned release.
This enables dead argument elimination to be paired with @owned -> @guaranteed
optimization. It has the additional advantage of allowing us to potentially
eliminate additional retains, releases since the fact that the use is dead
implies that the lifetime of the value no longer needs to be live across the
function call.

Since dead argument elimination can be composed with @owned -> @guaranteed, I
had to modify the mangler, remangler, demangler, to be able to handle a mangling
that combines the two.

I just saw noise in the perf test suite.

rdar://21114206

Swift SVN r29966
2015-07-08 06:26:25 +00:00
Joe Groff
2bf783dfe8 Runtime: Generate a mangled name as the ObjC runtime name of generic class instances.
Our hack to generate a unique name by appending the class pointer doesn't produce a stable class name that can persist in NSKeyedArchiver, or eventually be used as a key for dynamic runtime instantiation. Generate a proper mangled name for the class instance by building a demangling AST from the metadata nodes and feeding it into the remangler. Should fix rdar://problem/18884563, though I need to try using an archiver with a generic class to verify.

Swift SVN r29316
2015-06-05 14:27:58 +00:00
Enrico Granata
8a5726d966 Revert 28997
The consensus is against this change and we're going for a much more targeted fix in PlaygroundLogger only



Swift SVN r28999
2015-05-24 23:16:57 +00:00
Enrico Granata
05a038e818 Make it so that the runtime demangler does not print the Swift standard library module name
This changes things like Swift.Dictionary<Swift.Int, Swift.AnyObject> to Dictionary<Int, AnyObject>

It has been suggested that playgrounds would benefit from not showing the fully qualified name.
Playgrounds use the runtime demangler to obtain type names, and honestly, I do not see enough value in those qualifiers being printed out to justify hackery in PlaygroundLogger or separate demangling logic



Swift SVN r28997
2015-05-24 22:25:12 +00:00
David Farler
4d71001aa4 Provide 'Simplified' demangling mode
To support UI applications displaying demangled names in a limited
amount of screen space, provide a new SwiftDemangle API and Demangler
option to do the following:

- Skip all module name prefixes when printing contexts
- Don't print implicit self/metatype parameters when printing
function types

Add a '-simplified' flag to swift-demangle to support testing at the
command line.

Swift SVN r28727
2015-05-18 22:48:30 +00:00
Enrico Granata
3386d89af4 When demangling as string type names that come from module names of the form __lldb_expr_<something> in a Swift program, hide the module
The __lldb_expr modules are special as in they are autogenerated by LLDB and meant to not be user-accessible, so showing them adds visual noise for no user benefit

I am open to the notion of adding a flag to swift-demangle to the same effect, but that seems much lower priority



Swift SVN r28195
2015-05-06 02:49:08 +00:00
Michael Gottesman
c4e6fb5f5f [demangler] Teach the remangler how to handle funcsig nodes and print out values when performing string demangling.
Swift SVN r24507
2015-01-19 09:53:12 +00:00
John McCall
bb675b6ac9 Add a basic "re-mangler", which turns a parsed
demangling tree back into a mangled string.

Also, extend the demangling API in a few obvious
ways, and simplify testing for failure in the
node-returning APIs by having them simply return
null instead of a spurious Failure node.

Also, preserve slightly more information in the
demangling tree.  The goal here is eventually to
always allow a perfect round-trip through the
demangler parse tree.  This patch gets us close,
but we're not quite there yet.

Tests to follow.

Swift SVN r24473
2015-01-16 06:33:08 +00:00
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