Commit Graph

519 Commits

Author SHA1 Message Date
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
5dbc33f8ac Don't crash the frontend if a bad target is given
Provide a chance to emit a diagnostic instead.

rdar://problem/20931800

Swift SVN r28940
2015-05-23 00:58:05 +00:00
Devin Coughlin
6374588f3d [IRGen] Mark Objective-C Watch simulator images as simulated in IRGen setModuleFlags().
We already do for the iOS simulator and the tvOS simulator. This fixes
the 'unrecognized selector sent to instance’ bridging crashes in the stdlib
watch simulator tests.

Greg Parker did the hard work of tracking this down and suggested the fix.

<rdar://problem/20932146>

Swift SVN r28846
2015-05-20 20:39:42 +00:00
John McCall
30149ca3fc Fix some demangling bugs with curried and throwing functions.
As part of this, I've made the demangler base the colon-vs.-not
decision on the entity kind instead of assuming that anything
with a function type must be a function.  It also looks through
new-style generics when it didn't before.

Swift SVN r28814
2015-05-20 01:56:18 +00:00
Dmitri Hrybenko
ea17483633 Add CMake options and #ifs to hide tvOS
Swift SVN r28752
2015-05-19 05:15:52 +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
Joe Groff
22e34ab4e1 AST: Interface type mangling for protocol conformances.
Mangle the generic signature and interface type of the conforming type signature. Fix the demangler to reset the generic context between mangling a witness's conformance and requirement; they have independent generic contexts, and the bookkeeping for generic signatures notes the discrepancy.

Swift SVN r28377
2015-05-09 22:20:40 +00:00
Joe Groff
c8078cbcdb Demangle: Tweak how dependent types are demangled to make them look more like archetypes.
Share the logic we use to map archetype depth-index pairs to friendly unique names like 'A', 'B', so that demangle generic signatures are still somewhat readable, and so that archetype references into outer contexts with interface type manglings still make sense. Change the remangler to mangle archetypes and dependent generic params using nested index nodes instead of trying to parse the depth and index from the arbitrary names we give them.

Swift SVN r28343
2015-05-08 23:57:25 +00:00
Joe Groff
9f8fd4e43c AST: Compress the mangling for generic signatures a bit.
Single generic parameters are common, as are a lack of requirements, so tweak things so that generic parameter counts are mangled as (count - 1), with a special mangling for zero, and give a single generic parameter at depth zero the empty-string mangling. Most requirements are protocol constraints, so use a better mangling for them that doesn't require the 'P..._' wrapping of the general type mangling. On the other hand, dependent member types ought to mangle in the protocol of the associated type, which adds some length, but isn't too bad since the protocol will almost definitely have a substitution introduced by a preceding protocol constraint.

Swift SVN r28296
2015-05-07 22:26:34 +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
Jordan Rose
60c3154d95 Add swift::moveFileIfDifferent.
Equivalent to llvm::sys::fs::rename, except that if the destination file
exists and has the same contents as the source file, the source file is
simply deleted and the destination file is not touched.

Used in next commit.

Swift SVN r28041
2015-05-01 17:40:28 +00:00
Doug Gregor
2c909b4d36 Remove Objective-C selector splitting options.
We're not going this way.

Swift SVN r27717
2015-04-25 03:59:00 +00:00
Joe Groff
3f38d75006 SILGen: Currying of 'super.method' calls.
Keep track of a second set of "direct method reference" curry thunks that don't end in a dynamic dispatch in order to properly implement a partial application such as 'let foo = super.foo'. Fixes rdar://problem/20598526.

Swift SVN r27538
2015-04-21 22:56:03 +00:00
Joe Groff
c0a2994564 AST: Start printing function types with @convention instead of old attributes.
And update tests to match.

Swift SVN r27262
2015-04-13 22:51:34 +00:00
Doug Gregor
f4d98da668 Support the use of members of protocol extensions on existential types.
To use members of protocol extensions on existential types, we
introduce an OpenExistentialExpr expression to open up the existential
type (into a local archetype) and perform the operations on that local
archetype.

Unlike with uses of initializers or dynamic-Self-producing
methods of protocols, which produce similar ASTs, we have the type
checker perform the "open" operation and then track it through
constraint application. This scheme is better (because it's more
direct), but it's still using a simplistic approach to deciding where
the actual OpenExistentialExpr goes that needs improvement.

Swift SVN r26964
2015-04-04 00:00:14 +00:00
Joe Pamer
eee40fc53f Add basic parsing, sema and mangling support for throwing function types. Next up, metadata and serialization support, as well as more tests.
Swift SVN r26767
2015-03-31 18:55:19 +00:00
Ben Langmuir
eb7e352690 Don't require UUID on Darwin
It doesn't exist in all SDKs, which could lead to a bare -I option, or
pulling in a search path outside the sysroot/sdk.

Swift SVN r26539
2015-03-25 16:05:44 +00:00
Dave Abrahams
51637bb411 New capabilities for CharSourceRange
dump(), overlaps(other), widen(other), and construction from a
SourceRange.

(Pair-programmed with Dmitri Hrybenko)

Swift SVN r26465
2015-03-24 00:50:42 +00:00
Arnold Schwaighofer
3cbb7d3210 Add a now missing include file
Yay for upstream header cleanup

Swift SVN r26442
2015-03-23 20:32:34 +00:00
David Farler
1d9b0af93b os(iOS) shouldn't imply os(tvOS)
rdar://problem/20213434

Swift SVN r26285
2015-03-18 23:22:27 +00:00
David Farler
544ef4002d Merge tvOS and watchOS Support
- Add frontend and standard library build support for tvOS.
- Add frontend support for watchOS.

watchOS standard library builds are still disabled during SDK bring-up.

To build for TVOS, specify --tvos to build-script.
To build for watchOS, specify --watchos to build-script (not yet supported).

This patch does not include turning on full tests for TVOS or watchOS, and
will be included in a follow-up patch.

Swift SVN r26278
2015-03-18 21:35:07 +00:00
Ted Kremenek
b314e80ad0 Add defensive check for nullptr returned by demangleModule().
Should fix crash reported in rdar://problem/20155515.

Swift SVN r26234
2015-03-17 21:10:12 +00:00
Argyrios Kyrtzidis
f389529584 [Basic] Allow a shorter typed placeholder format when the display string and type string are the same.
Swift SVN r26229
2015-03-17 17:30:06 +00:00
Argyrios Kyrtzidis
0eac473455 [Basic] Add a utility function for parsing an editor placeholder.
Swift SVN r26214
2015-03-17 01:53:01 +00:00
Michael Gottesman
3c2216b115 [+0 self] Add the deallocating parameter convention.
The deallocating parameter convention is a new convention put on a
non-trivial parameter if the caller function guarantees to the callee
that the parameter has the deallocating bit set in its object header.

This means that retains and releases do not need to be emitted on these
parameters even though they are non-trivial. This helps to solve a bug
in +0 self and makes it trivial for the optimizer to perform
optimizations based on this property.

It is not emitted yet by SILGen and will only be put on the self
argument of Deallocator functions.

Swift SVN r26179
2015-03-16 07:51:11 +00:00
Jordan Rose
a4599cfc5d Normalize "darwin" target triples to "macosx" in LangOptions.
Clang does this in the driver. Why not Swift? Because (a) this is an
implementation detail that really only affects IRGen, and even then
somewhat incorrectly, and (b) Swift has a good handful of clients that
don't go through the driver to create an ASTContext (specifically, LLDB,
along with many of our testing tools).

rdar://problem/19779274

Swift SVN r25909
2015-03-10 02:24:06 +00:00
Joe Groff
7b6c41055f Add mangling for C function pointer types.
Swift SVN r25498
2015-02-24 04:46:07 +00:00
Dmitri Hrybenko
157e193403 CMake: move user-configurable variables to the top-level CMakeLists.txt
Swift SVN r25138
2015-02-10 21:56:59 +00:00
Joe Groff
0b1e8ec6ab Remangler: Properly handle "static" as a context node.
Should bring the test/Demangle/remangle.swift test case back online.

Swift SVN r25120
2015-02-10 05:51:36 +00:00
Joe Groff
63463f54ac SIL: Mangle the static-ness of declarations.
This lets us disambiguate the symbols for static and instance properties, and enables us to eventually leave the useless "self" type mangling out of method symbols. Fixes rdar://19012022 and dupes thereof, including crasher #1341.

Swift SVN r25111
2015-02-10 02:37:35 +00:00
Argyrios Kyrtzidis
7fd2ca6fc9 [driver] Introduce 'continue-after-building' functionality in the driver.
The '-update-code' mode is taking advantage of it to go through all the swift files, even though they have errors.

Swift SVN r24902
2015-02-02 21:57:04 +00:00
Joe Groff
a449948275 SILGen: Emit vtable thunks to handle optional variance.
If a subclass overrides methods with variance in the optionality of non-class-type members, emit a thunk to handle wrapping more optional parameters or results and force-unwrapping any IUO parameters made non-optional in the derived. For this to be useful, we need IRGen to finally pay attention to SILVTables, but this is a step on the way to fixing rdar://problem/19321484.

Swift SVN r24705
2015-01-24 05:21:26 +00:00
Dmitri Hrybenko
31f995a95d CMake: change SWIFT_REPOSITORY_STRING to STRING type, as originally
intended

Swift SVN r24597
2015-01-21 08:19:09 +00:00
Dmitri Hrybenko
41cd10e3f1 build-script/libSwiftBasic: properly propagate the Swift version down to
Version.cpp

rdar://19166288 rdar://19445760

Swift SVN r24592
2015-01-21 05:01:42 +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
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
Sonny Falk
b39859f5c0 Fix compile error for 32-bit builds.
This fixes a compile error with int vs. unsigned long in the call to std::min(), similar to a few lines below.

Swift SVN r24480
2015-01-16 22:02:26 +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
Jordan Rose
a3a6c2695b Put the current target into LangOptions.
This has been long in coming. We always had it in IRGenOpts (in string form).
We had the version number in LangOpts for availability purposes. We had to
pass IRGenOpts to the ClangImporter to actually create the right target.
Some of our semantic checks tested the current OS by looking at the "os"
target configuration! And we're about to need to serialize the target for
debugging purposes.

Swift SVN r24468
2015-01-16 02:48:54 +00:00
David Farler
cad9f99929 Revert "Serialize local types and provide a lookup API"
Changing the design of this to maintain more local context
information and changing the lookup API.

This reverts commit 4f2ff1819064dc61c20e31c7c308ae6b3e6615d0.

Swift SVN r24432
2015-01-15 00:33:10 +00:00
David Farler
fab3d491d9 Serialize local types and provide a lookup API
rdar://problem/18295292

Locally scoped type declarations were previously not serialized into the
module, which meant that the debugger couldn't reason about the
structure of instances of those types.

Introduce a new mangling for local types:
[file basename MD5][counter][identifier]
This allows the demangle node's data to be used directly for lookup
without having to backtrack in the debugger.

Local decls are now serialized into a LOCAL_TYPE_DECLS table in the
module, which acts as the backing hash table for looking up
[file basename MD5][counter][identifier] -> DeclID mappings.

New tests:
* swift-ide-test mode for testing the demangle/lookup/mangle lifecycle
of a module that contains local decls
* mangling
* module merging with local decls

Swift SVN r24426
2015-01-14 22:08:47 +00:00
John McCall
cae0f6e3db Add the ability for a owning addressor to return
a non-native owner.  This is required by Slice, which
will use an ObjC immutable array object as the owner
as long as all the elements are contiguous.

As part of this, I decided it was best to encode the
native requirement in the accessor names.  This makes
some of these accessors really long; we can revisit this
if we productize this feature.

Note that pinning addressors still require a native
owner, since pinning as a feature is specific to swift
refcounting.

Swift SVN r24420
2015-01-14 19:14:20 +00:00
John McCall
dc4431ebff Split addressors into unsafe, owning, and pinning variants.
Change all the existing addressors to the unsafe variant.

Update the addressor mangling to include the variant.

The addressor and mutable-addressor may be any of the
variants, independent of the choice for the other.

SILGen and code synthesis for the new variants is still
untested.

Swift SVN r24387
2015-01-13 03:09:16 +00:00
John McCall
f3dc58667d Improve the typing of materializeForSet callbacks to
use a thin function type.

We still need thin-function-to-RawPointer conversions
for generic code, but that's fixable with some sort of
partial_apply_thin_recoverable instruction.

Swift SVN r24364
2015-01-11 21:13:35 +00:00
John McCall
6a91f7a172 Various improvements to the function-type ABI.
Teach IRGen and the runtime about the extra inhabitants
of function pointers, and take advantage of that in
thin and thick function types.

Also add runtime entrypoints for thin function type
metadata.

Swift SVN r24346
2015-01-10 01:45:37 +00:00
John McCall
a7e2bb241b Fix some bit-vector bugs that weren't covered by my
random test generator and flesh out the API.

Swift SVN r24304
2015-01-09 10:05:43 +00:00
John McCall
05c67279fb Add a new bit-vector implementation optimized for
IRGen's needs.

Swift SVN r24295
2015-01-09 03:02:39 +00:00
Michael Gottesman
01d7f6ca20 [demangle] Teach the demangler how to demangle metatype representations and document the mangling of metatype representations in ABI.rst.
<rdar://problem/19138619>

Swift SVN r24209
2015-01-06 04:51:33 +00:00
Dmitri Hrybenko
eac3669a9c CMake: record that libswiftBasic depends on LLVMSupport
Swift SVN r24173
2015-01-05 07:18:09 +00:00
Dmitri Hrybenko
6670bb76ec Rewrite the CMake build system
Swift SVN r24124
2014-12-23 22:15:30 +00:00