Commit Graph

221 Commits

Author SHA1 Message Date
Dave Abrahams
90a34d86fa Mangle names of globalinit_{token,func} like other private entities.
This allows making global addressors fragile (They use globalinit_{token,func} for initialization of globals).

It has no noticable performance impact on our benchmarks, but it removes an ugly hack which explicitly
prevented addressors from being fragile.

Swift SVN r22812
2014-10-17 06:02:22 +00:00
Dave Abrahams
e4588e4896 Revert "Mangle names of globalinit_{token,func} like other private entities."
This reverts r22795, because it broke my RelWithDebInfo,
SWIFT_OPTIMIZED=NO build.

Swift SVN r22802
2014-10-16 21:12:11 +00:00
Erik Eckstein
b5cfd00f74 Mangle names of globalinit_{token,func} like other private entities.
This allows making global addressors fragile (They use globalinit_{token,func} for initialization of globals).

It has no noticable performance impact on our benchmarks, but it removes an ugly hack which explicitly
prevented addressors from being fragile.



Swift SVN r22795
2014-10-16 08:24:18 +00:00
Dmitri Hrybenko
8fdd6aca87 Fix warnings about falling off the end of a function without a return
Swift SVN r22317
2014-09-27 23:34:22 +00:00
John McCall
16cb523c3a AST support for accessors.
Swift SVN r22228
2014-09-23 20:34:19 +00:00
Jordan Rose
09664184be Move mangling logic for type metadata and field offset into Mangler.
...so that the debugger can use it too. We may end up needing to move more
things from LinkEntity to Mangler in this way, but this is the baseline for
what's needed to properly display private types.

The suffix "Full" here is intended to represent that the Swift prefix "_T"
is included already; if there's a better name for this I'd be glad to change
it.

rdar://problem/18353463

Swift SVN r22031
2014-09-17 19:27:11 +00:00
John McCall
75050f8166 Generate an implicit 'materializeForSet' accessor
along with getters and setters.

Just generate it for now.

Swift SVN r22011
2014-09-17 08:08:03 +00:00
Jordan Rose
af5af53f94 Turn on private-discriminator mangling by default.
...thus supporting "private var x: Int" in two different source files in the
same module.

This marks the completion of the bulk of the work for rdar://problem/17632175.
Remaining work is to make sure debugging does the right thing when processing
expressions in a particular source context.

Swift SVN r21851
2014-09-10 21:09:33 +00:00
Jordan Rose
4b94208eca Use extension mangling for all members of cross-module extensions.
If an entity is declared in an extension, and the extension is declared in a
different module from the type it extends, we include the extension's module
name in the mangling in addition to the extended type. We were already doing
this for functions and subscripts because of rdar://problem/18057875, but
this extends it to all declarations.

This is necessary to handle
(1) debugging private members of cross-module extensions
(2) the same member being declared in two different modules, each of which
    extends a type in a third module

rdar://problem/14884749

Swift SVN r21846
2014-09-10 19:10:48 +00:00
Argyrios Kyrtzidis
d37855e5c5 [IDE] Fix crash when code-completing inside a closure initializer of a member.
rdar://18246941

Swift SVN r21809
2014-09-09 19:29:19 +00:00
Adrian Prantl
ecc5016094 Fix an assertion when mangling anonymous closures with generic arguments
by setting the Mangler's DeclContext to that of the closure, if necessary.

rdar://problem/18204938

Swift SVN r21661
2014-09-02 23:44:37 +00:00
Jordan Rose
fcfd44c756 Use actual Identifiers for private discriminators, rather than strings.
This is useful both for caching purposes and for comparison of discriminators
(something the debugger will need to do when looking up a particular decl).

No observable functionality change.

Swift SVN r21610
2014-08-30 17:26:59 +00:00
Jordan Rose
adc25c8b9f Staging: Guard private discriminators under -enable-primary-discriminators.
...rather than let this series of out-of-tree commits get any bigger.

Swift SVN r21601
2014-08-30 00:17:23 +00:00
Jordan Rose
e842dd048a Don't use a private discriminator for methods in extensions to private types.
Minor symbol length / clarity optimization.

Swift SVN r21600
2014-08-30 00:17:22 +00:00
Jordan Rose
77daee9036 Hash the basename of a source file to use as a discriminator for 'private'.
Now we can test the mangling rules set up in the previous commit: include
the discriminator for the top-most 'private' decl, but not anything nested
within it.

Part of rdar://problem/17632175

Swift SVN r21599
2014-08-30 00:17:21 +00:00
Jordan Rose
47658c87eb Start mangling names of private declarations specially.
We currently mangle private declarations exactly like public declarations,
which means that private entities with the same name and same type will
have the same symbol even if defined in separate files.

This commit introduces a new mangling production, private-decl-name, which
includes a discriminator string to identify the file a decl came from.
Actually producing a unique string has not yet been implemented, nor
serialization, nor lookup using such a discriminator.

Part of rdar://problem/17632175.

Swift SVN r21598
2014-08-30 00:17:18 +00:00
Manman Ren
2cb20d4e62 [Mangler] mangle the module where an extension is defined if necessary.
If a method is defined within an extension of a class or struct that is
defined in a different module, we mangle the module where the extension is
defined.

If we define function f in module A, and redefine it again in an extension in
module B, we use different mangling to prevent linking in the wrong
SILFunction.

rdar://18057875


Swift SVN r21488
2014-08-27 19:57:21 +00:00
Joe Groff
fb4fe43e3b Handle '?' as an operator character in mangling.
Alphabetize it like the other operator characters are mangled.

Swift SVN r21062
2014-08-06 05:27:29 +00:00
Dmitri Hrybenko
0b280083cb Fix a use-after free introduced in r20886
Swift SVN r20961
2014-08-02 23:15:33 +00:00
Greg Parker
c5b71e9e42 Don't use punycode when mangling names for Objective-C metadata.
Swift SVN r20886
2014-08-01 05:19:28 +00:00
Doug Gregor
18c6f52b2a When mangling a type within an extension, pass down the extension’s generic parameters.
Swift SVN r20854
2014-07-31 21:59:27 +00:00
Dmitri Hrybenko
e7b4e6c370 Punycode encoder/decoder: separate core and parts that depend on UTF8
encoder/decoder


Swift SVN r20309
2014-07-22 15:01:12 +00:00
Dmitri Hrybenko
734c0a9ba1 Revert "Punycode encoder/decoder: separate core and parts that depend on UTF8"
It broke tests.

Swift SVN r20308
2014-07-22 14:44:20 +00:00
Dmitri Hrybenko
56342b0cfa Punycode encoder/decoder: separate core and parts that depend on UTF8
encoder/decoder


Swift SVN r20307
2014-07-22 14:37:37 +00:00
Dmitri Hrybenko
e33bb4c8de Demangler: remove SmallVector from punycode encoder and decoder interface
Swift SVN r20250
2014-07-21 14:37:16 +00:00
Joe Groff
45eec9a2e9 Remove 'interface' from the method names of SILFunctionType.
SILFunctionTypes are always interface types now. NFC.

Swift SVN r19952
2014-07-14 22:03:46 +00:00
Chris Lattner
a3c17dc166 move the @infix/@postfix/@prefix attributes onto the modern attribute infrastructure, NFC.
Swift SVN r19927
2014-07-14 14:30:26 +00:00
Adrian Prantl
7ca6571fe7 Mangler: mangle entities with their own DeclContext if none is given.
<rdar://problem/17458442> Assertion failed: (DC && "empty decl context"), function mangleType

Swift SVN r19216
2014-06-26 02:33:36 +00:00
Adrian Prantl
e274b8d9e2 Mangler: Set up the DeclContext also when mangling an alias type.
rdar://problem/17457346

Swift SVN r19211
2014-06-26 01:34:05 +00:00
Adrian Prantl
d087a24bf5 Don't crash in release mode if the Mangler encounters an Archetype without
DeclContext.

Swift SVN r19210
2014-06-26 01:34:03 +00:00
Adrian Prantl
fd4c8a495c Don't crash when mangling polymorphic function types for debug info.
Swift SVN r18277
2014-05-17 21:49:55 +00:00
Michael Gottesman
39841c3889 [mangler][specializer] When mangling ExistentialMetatypes or Metatypes, mangle in the representation of the metatype.
rdar://16937175

Swift SVN r18219
2014-05-16 22:28:30 +00:00
Dmitri Hrybenko
86cc0b937f stdlib/FloatingPoint: make Float and Double real struct names, and
Float32 and Float64 typealiases

This works around a defect in the type checker, where it loses sugar
from FloatLiteralType while performing type inference for more complex
expressions involving floating point types.

rdar://16770279

Swift SVN r17241
2014-05-02 09:33:01 +00:00
Ted Kremenek
050fd53af7 Rename UncheckedOptional to ImplicitlyUnwrappedOptional.
Swift SVN r17232
2014-05-02 06:13:57 +00:00
John McCall
e1bd429cf7 Under -import-cf-types, import
typedef struct __foo *FooRef;
as an Unmanaged<Foo>, where Foo is a class type.

Swift SVN r17206
2014-05-01 23:29:27 +00:00
Chris Lattner
a7012f23ef Remove swift::ArrayType. It is dead and vestigial code for supporting fixed size
arrays, which never got baked.  Remove it until we have time to do things right.


Swift SVN r16995
2014-04-28 21:18:27 +00:00
Argyrios Kyrtzidis
301391755e [AST] Recover if trying to mangle a closure without a type.
Test case on the SourceKit side.
rdar://16706082

Swift SVN r16747
2014-04-24 07:50:15 +00:00
John McCall
b38a63950d Implement @unowned(unsafe).
This was part of the original weak design that
there was never any particular reason to rush the
implementation for.  It's convenient to do this now
so that we can use it to implement Unmanaged<T> for
importing CF types.

Swift SVN r16693
2014-04-23 08:51:23 +00:00
John McCall
8681963bcb A couple of long-overdue renames.
Builtin.ObjectPointer -> Builtin.NativeObject
Builtin.ObjCPointer -> Builtin.UnknownObject

Swift SVN r16634
2014-04-22 00:17:08 +00:00
Joe Groff
c73acc67f2 SIL: Add an "UnownedInnerPointer" result convention.
This will represent the return convention of imported __attribute__((objc_returns_inner_pointer)) methods. Leave it unimplemented for now until we can autorelease things sanely.

Swift SVN r16628
2014-04-21 21:57:13 +00:00
Doug Gregor
09797f7f99 Introduce a new declaration node, ParamDecl, for function parameters.
Use this node to capture the argument name and its source location in
the AST. We're only building these in one place at the moment; the
rest will be updated soon.


Swift SVN r16581
2014-04-20 05:23:35 +00:00
Joe Groff
ebe5f4620c Don't include the module in protocol conformance manglings.
The cost of hacks to swift_conformsToProtocol is starting to outweigh any benefit to being principled here. We'll get a linker error now if multiple modules declare a conformance for the same type to the same protocol, but that's arguably a good thing for 1.0 anyway, since we aren't set up to get that right in other ways.

Swift SVN r16554
2014-04-18 23:13:40 +00:00
Argyrios Kyrtzidis
2c88bb3f59 [AST] Modify mangleObjCRuntimeName to allow getting the ObjC runtime name of a class or protocol
without needing a fully typechecked AST.

Part of rdar://16521245

Swift SVN r16503
2014-04-18 07:07:11 +00:00
Joe Groff
f7cf592777 Add a SIL-only '@block_storage T' type to represent on-stack storage for blocks.
Blocks need to be born on the stack, so we need a way to represent that on-stack storage. @block_storage T will represent the layout of a block that contains storage for a capture of type T.

Swift SVN r16355
2014-04-15 03:56:09 +00:00
Doug Gregor
2d28d70bf8 Remove the language/driver/frontend options to enable/disable mangled names for the ObjC runtime.
Burn the bridges!


Swift SVN r16277
2014-04-13 05:36:08 +00:00
Joe Groff
8adaab0233 Fold ExtInfo::isThin and ::isBlock into a "Representation" enum.
These bits are orthogonal to each other, so combine them into one, and diagnose attempts to produce a type that's both. Spot-fix a bunch of places this revealed by inspection that we would have crashed in SILGen or IRGen if blocks were be handled.

Swift SVN r16088
2014-04-09 00:37:26 +00:00
Doug Gregor
845eafa7d0 Revert unwanted mangling change I introduced in r15850.
Thanks, Dmitri!

Swift SVN r15883
2014-04-03 17:21:33 +00:00
Dmitri Hrybenko
f370da96b1 ReST: make data in a LineList be owned by ReSTContext, so that users don't have
to carry all LineLists along with a ReSTContext.


Swift SVN r15863
2014-04-03 11:03:09 +00:00
Doug Gregor
e418e93511 Start cleaning up method name importing.
Import a selector into a Swift method name, performing splitting at
that point. Use the resulting method name to determine the argument
names of the parameters, rather than trying to chop up the selector
again. There's more refactoring to do here.

This fixes a longstanding bug where the first argument of an
Objective-C method got the internal parameter name when it should
have gotten no name at all.

Swift SVN r15850
2014-04-03 00:34:40 +00:00
John McCall
f1180f5e6d in order to work correctly for non-@objc protocols.
Language features like erasing concrete metatype
values are also left for the future.  Still, baby steps.

The singleton ordinary metatype for existential types
is still potentially useful; we allow it to be written
as P.Protocol.

I've been somewhat cavalier in making code accept
AnyMetatypeType instead of a more specific type, and
it's likely that a number of these places can and
should be more restrictive.
When T is an existential type, parse T.Type as an
ExistentialMetatypeType instead of a MetatypeType.

An existential metatype is the formal type
 \exists t:P . (t.Type)
whereas the ordinary metatype is the formal type
 (\exists t:P . t).Type
which is singleton.  Our inability to express that
difference was leading to an ever-increasing cascade
of hacks where information is shadily passed behind
the scenes in order to make various operations with
static members of protocols work correctly.

This patch takes the first step towards fixing that
by splitting out existential metatypes and giving
them a pointer representation.  Eventually, we will
need them to be able to carry protocol witness tables

Swift SVN r15716
2014-04-01 00:38:28 +00:00