Commit Graph

25 Commits

Author SHA1 Message Date
Joe Groff
0be95f56bd Merge pull request #24798 from jckarter/opaque-type-check-availability
Opaque types require a newer Swift runtime.
2019-05-15 18:05:40 -07:00
Joe Groff
cec9e9e33a Opaque types require a newer Swift runtime.
Check the availability of decls that declare an opaque return type to ensure they deploy to a
runtime that supports opaque types.

rdar://problem/50731151
2019-05-15 11:39:53 -07:00
Brent Royal-Gordon
affcefc1ae [ASTMangler] Mangle nested imported error structs correctly
Error structs synthesized by ClangImporter can be renamed using SWIFT_NAME() to syntactically appear anywhere in the type hierarchy with any name, but they should always be mangled as `__C_Synthesized.related decl ‘e’ of <Objective-C enum name>`. Unforunately, when SWIFT_NAME() was used to nest the error struct inside another type, an ASTMangler bug would cause it to be mangled as `<parent type>.related decl ‘e’ of <Objective-C enum name>`, and an ASTDemangler bug would also require a valid parent type. This created a mismatch between the compiler’s and runtime’s manglings which caused crashes when you tried to match the imported error struct in a `catch`.

This PR corrects the compiler bugs so that it generates the mangling the runtime expects. This is theoretically ABI-breaking, but as far as I can determine nobody has shipped the incorrectly mangled names, presumably because they crash when you try to use them.

Fixes <rdar://problem/48040880>.
2019-05-15 11:28:24 -07:00
Joe Groff
edd30153fa Add TypeDecoder test 2019-05-02 17:28:08 -07:00
Slava Pestov
d0d5fbdf39 ASTDemangler: Introduce new getTypeDeclForMangling()
This will replace getDeclFromMangledSymbolName().

Progress on <rdar://problem/47819208>.
2019-02-22 16:13:02 -05:00
Slava Pestov
d0c7b1547e ASTMangler: Mangle sugared types for the debugger
Fixes <rdar://problem/48004306>.
2019-02-13 19:17:25 -05:00
Slava Pestov
0ddf475a7e ASTDemangler: Propagate @escaping from function type to function parameter 2019-02-04 16:00:12 -05:00
Slava Pestov
1731a482e4 ASTDemangler: Imported typedefs can be nested inside other types 2019-02-04 16:00:12 -05:00
Slava Pestov
161eba721a ASTDemangler: Fix demangling of SILFunctionTypes with @in_constant parameters 2019-01-30 01:28:48 -05:00
Slava Pestov
36d3f47388 ASTDemangler: Preserve generic arguments for bound generic Objective-C classes
MetadataLookup gives special treatment to imported Objective-C classes,
since there's no nominal type descriptor and metadata is obtained
directly by calling into the Objective-C runtime.

Remote reflection also gives special treatment to imported Objective-C
classes; they don't have field descriptors.

However, the ASTDemangler needs to treat them like ordinary classes,
in particular it wants to preserve the generic arguments here so that
we can round-trip debug info.
2019-01-30 01:28:48 -05:00
Slava Pestov
9c8a5b599e ASTDemangler: Fix demangling of weak/unowned/unowned(unsafe)
The check here was incorrect because we might have an optional of a
reference type as well. Just remove the check to keep things simple.
2019-01-29 21:57:06 -05:00
Slava Pestov
4a74bf4ba1 ASTDemangler: Add support for lowered function types 2019-01-29 21:55:57 -05:00
Slava Pestov
13a50c2d2d ASTDemangler: Add support for lowered metatypes 2019-01-29 19:15:17 -05:00
Slava Pestov
fce933910d ASTDemangler: Implement types in generic local context
If we nest a type inside a local context inside a generic type,
we have to look through the local context(s) to find the outer
generic type when stripping off generic arguments.

We don't support nominal types inside generic local context
right now, but this can happen with type aliases.
2019-01-29 19:15:17 -05:00
Slava Pestov
81aad59644 ASTDemangler: Add test for private type in extension of foreign type
This was one of the cases that TypeReconstruction did not support;
let's make sure its covered by a test.
2019-01-29 19:15:17 -05:00
Slava Pestov
80b225d6e8 Fix test/TypeDecoder/foreign_types.swift for 32-bit
NSSize is not always aliased to CGSize; on 32-bit platforms it is its own type.
Instead, let's just define our own type.
2019-01-28 15:29:12 -05:00
Slava Pestov
b6951932b4 ASTDemangler: Implement type alias types
Debug info uses a special mangling where type aliases can be
represented without being desugared; attempt to reconstruct
the TypeAliasType in this case.
2019-01-25 21:59:48 -05:00
Slava Pestov
d80caceec3 ASTDemangler: Fix local type lookup 2019-01-25 21:45:17 -05:00
Slava Pestov
0f5233dad1 ASTDemangler: Implement extension lookup 2019-01-25 21:44:02 -05:00
Slava Pestov
55605ceab9 ASTDemangler: Implement DynamicSelfType 2019-01-25 21:44:02 -05:00
Slava Pestov
9516575d1c ASTDemangler: Simplify createBoundGenericType()
It's clever how it leverages the type checker to check generic arguments,
but calling checkGenericArguments() would have been simpler, and it doesn't
work for interface types anyway, so we would fail to demangle those.

Let's just cut this all out for now and build a BoundGenericType directly.
2019-01-25 21:44:02 -05:00
Slava Pestov
bbe6a56e22 ASTDemangler: Implement builtin types 2019-01-25 21:44:02 -05:00
Slava Pestov
2d21233378 ASTDemangler: Implement unresolved DependentMemberType
The debug mangling emits these when the type parameter only
conforms to one protocol having an associated type with this
name.
2019-01-25 21:44:02 -05:00
Slava Pestov
8df0d8ea63 ASTDemangler: Fix import-as-member types
When an enum is imported as an error, the imported type itself becomes
a nested type 'Code' of its wrapper type, so you get a type like
'MyError.Code'. However in the mangling grammar the type is a
child of a module and not another type.

This was tripping up TypeDecoder, which would check parent types for
validity and throw out the demangling since it looked invalid.

However since this case really is valid, just skip the whole parent
type mess when the type is imported and non-generic.
2019-01-25 21:44:02 -05:00
Slava Pestov
21f37d73b6 Add some preliminary tests for TypeDecoder/ASTDemangler 2019-01-25 21:44:02 -05:00