Commit Graph

50 Commits

Author SHA1 Message Date
Erik Eckstein
a8a18c01ad swift-demangler: Add an option -strip-specialization to get the symbol name of the origin of a specialized function. 2019-03-25 14:57:03 -07:00
Erik Eckstein
8997a0e831 swift-demangle: Also accept $s symbols without the $ prefix.
This makes it easier to copy-paste $s symbols with a double-click.
We already had this for $S, now it also works for the new mangling prefix $s.
2018-10-04 12:53:58 -07:00
Rintaro Ishizaki
ad3e6b9471 [SourceKit] Make sourcekitd-test -req=demangle STDIN mode actually work
This didn't work at all because it didn't advance cursor after regex
matching.
Align regex with swift-demangle.
2018-04-11 20:08:52 +09:00
Erik Eckstein
99b925651e swift-demangle: Also accept symbol names without the $ prefix.
This makes it easier to copy-paste $S symbol names with a double-click.

rdar://problem/38546308
2018-03-24 19:28:38 -07:00
Erik Eckstein
f0ef4007b6 Demangler: support the final mangling prefix _$s
rdar://problem/37681432
2018-03-24 19:28:38 -07:00
Erik Eckstein
d21b4a35d5 swift-demangle: Add an option to test the ObjC runtime name mangling scheme.
This is basically the old mangling scheme. The option -remangle-objc-rt remangles a new mangled name to the old scheme.
This is useful to test the old remangler, which is used in the swift runtime to create the ObjC runtime names.
2018-01-29 16:25:38 -08:00
Doug Gregor
6d1e668c86 [Demangler] Eliminate more rogue ".c_str()" and ".data()". 2018-01-10 08:53:49 -08:00
Erik Eckstein
ecd177fa17 Demangler: handle suffixes in the form '.<n>'.
Demangle such suffixes as "unmangled suffix"
IRGen still uses '.<n>' to disambiguate partial apply thunks and outlined copy functions.

rdar://problem/32934962
2017-06-26 15:19:20 -07: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
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
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
Erik Eckstein
a41312288d demangler: add an API function to get the target of a thunk symbol.
rdar://problem/30820093
2017-03-02 17:21:45 -08:00
Erik Eckstein
f8f172a46b demangler: also support the future mangling prefix ‘_S’ 2017-03-01 14:16:38 -08:00
Erik Eckstein
be986d753c demangler: add an API to check if a function has the swiftcc calling convention 2017-03-01 14:16:38 -08:00
Erik Eckstein
7d7dc5aaac Demangler: Use a bump-pointer allocator for node allocation.
This makes the demangler about 10 times faster.
It also changes the lifetimes of nodes. Previously nodes were reference-counted.
Now the returned demangle  node-tree is owned by the Demangler class and it’s lifetime ends with the lifetime of the Demangler.

Therefore the old (and already deprecated) global functions demangleSymbolAsNode and demangleTypeAsNode are no longer available.

Another change is that the demangling for reflection now only supports the new mangling (which should be no problem because
we are generating only new mangled names for reflection).
2017-02-24 19:04:13 -08:00
Erik Eckstein
2d127e4192 Reinstate ”Use the new mangling for reflection."
It also uses the new mangling for type names in meta-data (except for top-level non-generic classes).
lldb has now support for new mangled metadata type names.

This reinstates commit 21ba292943.
2017-02-15 09:47:22 -08:00
Erik Eckstein
ebe19757e1 Demangler: add a new API for the demangler which enables bump-pointer allocation of demangling nodes.
Instead of a global demangleSymbolAsNode, which returns a reference-counted NodePointer, there is now a Context class which owns the nodes.
So now demangleSymbolAsNode is a member of Context and the returned NodePointer is alive as long as the Context is alive.

This is still a NFC: the new ABI still maps to the old functions.
The purpose of this change is to let lldb adapt to the new API and then we can switch to the new implementation.
2017-02-10 12:25:58 -08:00
Erik Eckstein
479237b9ac Mangling: isSwiftSymbol should get a null terminated string rather than a char pointer + length
This avoids doing a strlen in lldb when calling this function.

rdar://problem/30062026
2017-02-09 14:05:00 -08:00
Erik Eckstein
254f36aba5 Revert "Use the new mangling for reflection."
This needs some changes in lldb.
Disabled for now until lldb supports the new mangling.

This reverts commit 21ba292943.
2017-02-08 09:01:51 -08:00
Erik Eckstein
21ba292943 Use the new mangling for reflection.
For this we are linking the new re-mangler instead of the old one into the swift runtime library.
Also we are linking the new de-mangling into the swift runtime library.

It also switches to the new mangling for class names of generic swift classes in the metadata.
Note that for non-generic class we still have to use the old mangling, because the ObjC runtime in the OS depends on it (it de-mangles the class names).
But names of generic classes are not handled by the ObjC runtime anyway, so there should be no problem to change the mangling for those.
The reason for this change is that it avoids linking the old re-mangler into the runtime library.
2017-02-07 08:36:21 -08:00
Erik Eckstein
81384b6f82 demangler: Add API functions for classifying symbols.
To be used by lldb.
Also add a -classify option in swift-demangler to test those new API functions.
2017-01-31 17:27:10 -08:00
Erik Eckstein
e266466609 swift-demangle: add -remangle-new option
It can be used to convert an old mangling to the new mangling.
2017-01-20 09:50:58 -08:00
Hugh Bellamy
31af706d14 Port swift-demangle to Windows 2017-01-19 16:23:37 +00:00
Hugh Bellamy
e32985d406 Restrict <cstdlib> import to CYGWIN 2017-01-19 09:34:45 +00:00
swift-ci
294359bd69 Merge pull request #4804 from kstaring/master 2017-01-10 00:01:46 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Erik Eckstein
ea7f27e4cb swift-demangle: don’t hardcode the mangling prefix when processing the -test-remangle option 2016-12-14 16:39:00 -08:00
practicalswift
76f0fdd670 [gardening] NULL → nullptr 2016-12-09 23:17:54 +01:00
Erik Eckstein
16d1befd53 swift-demangle: Abort with an error if the demangling-test fails for a symbol. 2016-12-09 08:44:18 -08:00
Erik Eckstein
5e6c5a70d7 Mangling: Let the demangler handle the new mangling scheme 2016-12-02 15:55:30 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
K Staring
4c84a33233 remove extraneous extern getline 2016-09-15 19:08:27 +02:00
K Staring
014963fdcf add define for FreeBSD getline() compat 2016-09-13 09:23:57 +02:00
Keith Smiley
55aa9096e1 Update swift-demangle to interactively demangle (#4412)
This changes the swift-demangle interactive STDIN mode to immediately
print the demangled symbol on return as opposed to printing them all at
the end.
2016-08-23 10:31:48 -07:00
Han Sangjin
e06c7136cb Porting to Cygwin. rebased and squashed 2016-02-22 13:20:21 +09:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
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
Jordan Rose
f866e56388 [swift-demangle] Filter mode: '$' is a valid mangled name character.
rdar://problem/21001459

Swift SVN r32229
2015-09-25 17:53:43 +00:00
Jordan Rose
bc91897806 Remove LLVM_INITIALIZE from swift-demangle.
There were dependencies missing, but it turns out it doesn't actually need
any of it.

Swift SVN r31860
2015-09-10 21:15:31 +00:00
Michael Gottesman
e864f02690 In all executables make sure to completely initialize LLVM.
I also added a macro called INITIALIZE_LLVM(argc, argv) which moves this logic
into one place and should be used at the beginning of *all* binaries. It
initializes an LLVM shutdown object, sets up the pretty stack trace, and then
initializes all of the parts of LLVM. This will make it easy to update this in
the future.

The reason why a macro was required was because of llvm_shutdown_obj, an RAII
object that cleans up LLVM. It has to be at the function level scope of the main
function.

Swift SVN r31815
2015-09-09 04: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
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
John McCall
a0d3214e4c Test that the remangler round-trips successfully.
To get this to work, delay some "cleanup" work in the
demangler.  For example, we now preserve in the tree
whether something was mangled as an allocating
initializer, and we only special-case the class vs.
non-class cases in the pretty printer.

Also fixes a number of remangling bugs, of course.

Swift SVN r24534
2015-01-19 23:12:58 +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
Enrico Granata
bd81003632 The --tree-only option to swift-demangle was not doing what it promised to do, instead refusing to print anything. Fix it
Swift SVN r20862
2014-08-01 00:14:16 +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
Jordan Rose
270cf80a6c [swift-demangle] Teach swift-demangle to filter stdin if given no arguments.
That is, teach swift-demangle to also be swift-filt.

Swift SVN r20231
2014-07-20 18:24:06 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Enrico Granata
efcd17f604 This commit implements the Demangler API in C++ and de facto deprecates the existing Demangle.swift
The new demangler is in the "swift/SIL/Demangle.{h|cpp}" files, and in the swift::Demangle namespace, which has two public entry points:

std::string demangleSymbol(llvm::StringRef mangled);
std::string demangleType(llvm::StringRef mangled);

This was necessary to support the need for LLDB to demangle Swift symbol (and type) names

Test case is included



Swift SVN r6547
2013-07-24 17:52:27 +00:00