Commit Graph

55 Commits

Author SHA1 Message Date
Meghana Gupta
637f8ef03e [6.2] Fix deserialization of lifetime dependencies on ast function types 2025-06-02 17:36:22 -07:00
Alexis Laferrière
461561595d Serialization: Update test that doesn't crash anymore 2025-03-19 16:25:48 -07:00
Hamish Knight
bbb04aaa20 [test] Disable bridging PCH in a few tests
The new driver builds a PCH by default, which the
old driver didn't do. These tests don't expect a
PCH, so avoid building it.
2024-09-22 21:15:45 +01:00
Anthony Latsis
1e2f6bbbfa Gardening: Migrate test suite to GH issues: validation-test/Serialization (2/2) 2022-09-20 02:32:18 +03:00
Anthony Latsis
456a8debee Gardening: Migrate test suite to GH issues: validation-test/Serialization (1/2) 2022-09-20 02:31:46 +03:00
Xi Ge
36f25c3130 ClangImporter: teach clang importer to import Clang SPI symbols and model them similarly as Swift SPIs
For clang symbols marked with SPI_AVAILABLE, we add SPIAccessControlAttr to them so they will be
considered as SPIs in the AST. To be able to use all these symbols, we also add an implicit SPI import
statement for all clang modules. All clang SPIs belong to the same SPI group named "OBJC_DEFUALT_SPI_GROUP" because clang
currently doesn't support custom SPI group.

rdar://73902734
2021-08-28 11:11:09 -07:00
Ben Barham
3afb498896 [Deserialization] Do not assert on a missing witness if allowing errors
When allowing errors we may have serialized a requirement without a
witness, do not assert when deserializing.

Resolves rdar://81884767
2021-08-13 17:15:21 +10:00
Ben Barham
69a5a3d3e8 [Serialization] Check for anchoring VarDecl when serializing PDB
An invalid PDB may have no anchoring VarDecl when allowing errors, make
sure not to crash in that case.
2021-08-06 17:55:02 +10:00
Ben Barham
462ce0584d [Serialization] Properly skip invalid destructors when allowing errors
7856f2d83d only partially skipped writing
out destructors when they were invalid, ie. it skipped writing the decl
itself but not the records common to all decls. This would cause any
records on the destructor to be applied on the next serialized decl.

Make sure to skip serializing anything to do with the destructor when
it's invalid and does not have a class context.
2021-08-06 13:45:32 +10:00
David Ungar
fc0eca5f20 add a regression test 2021-07-18 20:11:51 -07:00
Ben Barham
1fea98cbad [Serialization] Allow conformances with no witness if allowing errors
Note that deserialization already handles this case when recovery is
enabled.
2021-06-02 11:45:29 +10:00
Ben Barham
6d038c86bc [Serialization] Skip deserializing invalid attributes if allowing errors
Most invalid attributes are skipped from serialization entirely, but
custom attributes don't have their invalid bit set - the particular
custom attribute (eg. a property wrapper) is requested when needed and
skipped if invalid. Those checks can't set the invalid bit since the
attribute could be a different custom attribute (eg. a result builder).
2021-06-02 11:45:29 +10:00
Ben Barham
c490f928cb [Serialization] Serialize unresolved types as errors if allowing errors 2021-06-02 11:45:29 +10:00
Ben Barham
073a5828a2 [Serialization] Skip verifying attributes when allowing errors
When allowing errors any attribute could be on any decl, so don't verify
whether an attribute can appear on a decl. Note that these attributes
aren't serialized anyway since they'll be set to invalid during
typechecking and hence skipped.
2021-06-02 11:44:53 +10:00
Ben Barham
7856f2d83d [Serialization] Skip serializing invalid destructors if allowing errors 2021-06-02 11:39:14 +10:00
Holly Borla
df43914406 [Property Wrappers] Return early from computing the backing property type
if the wrapped property came from a module file.
2021-05-13 09:16:38 -07:00
Argyrios Kyrtzidis
053aaaca61 Fix crash in merge-modules involving a file with extension of nested type
rdar://74062542
2021-02-06 12:01:14 -08:00
David Zarzycki
5dcc32f98f Remove all uses of -force-single-frontend-invocation
The `-force-single-frontend-invocation` flag predates WMO and is now an
alias for `-whole-module-optimization`. We should use the latter and let
the former fade into history.
2020-05-08 06:37:41 -04:00
David Ungar
bbffc0959b Tests for type fingerprints are enabled. 2020-01-28 20:06:44 -08:00
David Ungar
84fa03f757 Added -disable-type-fingerprints to tests. 2020-01-27 15:14:46 -08:00
Slava Pestov
39f392c39d Add regression test for https://bugs.swift.org/browse/SR-4211 2019-12-05 08:45:55 -05:00
Varun Gandhi
c85eae1efb Get rid of the second call to setType() in validateExtension().
This means that we no longer have the invariant that the extendedType always
contains the generic parameters. So we need to fix the assertions/test cases
for it.
2019-08-19 11:37:18 -07:00
Jordan Rose
ff7c6f6702 [Serialization] Drop a class if the superclass can't be found
...instead of crashing. Also drop the class if its generic
requirements depend on a type that can't be loaded (instead of
crashing).

rdar://problem/50125674
2019-05-17 10:25:01 -07:00
Jordan Rose
c506747a9c [Serialization] Drop inherited conformances on classes (#23347)
These can be recreated if needed in a client library. To do this, I've
added a new ConformanceLookupKind::NonInherited, which can also be
used elsewhere in the project where we're already filtering out
inherited conformances some other way.

Note that this doesn't drop inherited conformances from the entire
serialized interface, just from the list that a class explicitly
declares. They still get referenced sometimes.

rdar://problem/50541451 and possibly others
2019-05-13 13:41:10 -07:00
Argyrios Kyrtzidis
1b2cb9c723 [Serialization] Fix bad tagging of deserialized decls that can result in failed member lookups
The issue was introduced in ec95e68ab9 which changed the behavior of `ModuleFile::getDeclChecked()` slightly.

rdar://49336277
2019-03-28 12:18:25 -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
b2f0327516 IDE: Remove getTypeFromMangledSymbolname()
There was only one remaining usage other than in testing tools.

Note that when a declaration mangling was passed in, the old entry
point would (try to) return the type of the declaration.

The new entry point no longer has this behavior. I changed the
bridging-header-first test to run lldb-moduleimport-test with
-decl-from-mangled instead of -type-from-mangled-old to preserve
the behavior of the test.

Also, I removed test/DebugInfo/DumpTypeFromMangledName.swift
completely. This test only covered a handful of cases, and a bunch
of them were declaration manglings rather than type manglings.
The new tests in test/TypeDecoder/ are much more comprehensive.
2019-02-08 02:56:05 -05:00
Slava Pestov
a14f345c82 lldb-moduleimport-test: Add support for testing Demangle::getTypeForMangling()
The -type-from-mangled flag now uses the new API. The -type-from-mangled-old flag
uses the old API, ide::getTypeFromMangledSymbolname().

For now, just change all existing tests to use the -type-from-mangled-old flag;
I'll be adding new tests for the new API shortly.
2019-01-25 21:44:02 -05:00
Jordan Rose
4017416d5e [Serialization] Only allow loading modules during import resolution (#21218)
Very early groundwork for private imports. Should not affect anything
today.
2018-12-12 10:50:20 -08:00
Saleem Abdulrasool
41d9c2cc59 stdlib: restructure for OS family layout of SDK overlay
The SDK directory is now confusing as the Windows target also has a SDK
overlay.  In order to make this more uniform, move the SDK directory to
Darwin which covers the fact that this covers the XNU family of OSes.
The Windows directory contains the SDK overlay for the Windows target.
2018-12-06 11:32:05 -08:00
Jordan Rose
f1b347c0cc Handle non-deserializable SIL functions referenced in witness tables
This is enough to let the test case in rdar://problem/40899824 pass,
and any callers of this function already need to be able to handle a
nullptr result. There's a lot more work to do in this area, but it's
nice to get the simple things working again.
2018-06-27 17:24:22 -07:00
Jordan Rose
8ea96e95c6 [test] Add minimized test case from SR-7337 (#17524)
Because we've changed how conformances represent associated types
since Swift 4.2 branched, the error described there no longer occurs.
But we still want to make sure we don't regress.

https://bugs.swift.org/browse/SR-7337
2018-06-26 14:31:01 -07:00
Jordan Rose
15c0ca5642 [test] Work around an issue with Apple's internal bots (#17397)
rdar://problem/41332918
2018-06-21 11:33:12 -07:00
Jordan Rose
8abaaea2c9 Keep more ParenType parameter flags when canonicalizing function types (#17369)
This will also preserve @escaping and @autoclosure, which were previously
dropped. This could lead to mismatches between expected and actual
canonical types for serialization cross-references.

https://bugs.swift.org/browse/SR-8045, likely others
2018-06-20 16:35:55 -07:00
Jordan Rose
6b894154d3 [Serialization] Track whether a cross-reference came from Clang (#17333)
Cross-references are identified by their containing module, with the
assumption that two modules will never have the same name. However, an
overlay has the same name as its underlying Clang module, which means
that there can be two declarations with the same name, the same type,
and the same module name. This is the underlying cause of the
'UIEdgeInsetsZero' problem, but it also affects the CloudKit overlay.

By tracking a bit that just says "this came from Clang", we're able
to resolve otherwise ambiguous cross-references.

(Why didn't we do it this way all along? Because if a declaration
moves from Clang to Swift or vice versa, that would break the
cross-reference. But that's only interesting if the swiftmodule format
is meant to be persistent across changing dependencies, and it looks
like we're moving away from that anyway. It's also a little weird for
SerializedModuleLoader to have special cases for Clang, but this isn't
the first.)

Note that I'm not reverting the UIEdgeInsetsZero workaround here; the
end state will have that coming just from UIKit as originally
described.

rdar://problem/40839486
2018-06-20 14:51:17 -07:00
Jordan Rose
6dcda937f0 [Serialization] Always list the bridging header before any imports
This mirrors how a bridging header is processed when compiling source
files: before any of the imports. This is important for LLDB to
recreate the source environment as closely as possible to how the
compiler does it; in the test case being added involving a non-modular
header file, failure to do so resulted in a deserialization
cross-reference crash.

Note that Serialization still sorts imports, which normal resolution
of imports in source does not do. So we're still not consistent. But
this is less important than handling textual includes (bridging
headers) before modular imports.

rdar://problem/40471329
2018-06-13 16:20:31 -07:00
Jordan Rose
a6ae2d7742 Hack: Force UIEdgeInsets.zero to always come from the SDK (#17122)
...instead of relying on the one in the overlay in pre-4.2 versions of
Swift. This caused crashes in deserialization, which (deliberately)
doesn't respect availability.

There are three changes here:

- Remove UIEdgeInsets.zero and UIOffset.zero from the UIKit overlay.
- Always use the 4.2 name for UIEdgeInsetsZero and UIOffsetZero from
  the underlying UIKit framework. (This is the nested name.)
- Ignore the unavailability messages for those two constants in
  pre-4.2 Swift, since we're now relying on them being present.

The latter two, the compiler changes, can go away once UIKit's API
notes no longer specify different pre-4.2 behavior, but meanwhile we
need to keep compatibility with the SDKs released in Xcode 10b1.

https://bugs.swift.org/browse/SR-7879
2018-06-12 13:40:23 -07:00
Jordan Rose
7567a15921 [test] Add test for deserialization of generic protocol witnesses (#17141)
This failed in Swift 4.1 because of a problem with Substitutions,
but that whole model's been ripped out and redone in Swift 4.2.

https://bugs.swift.org/browse/SR-7978
2018-06-12 11:53:20 -07:00
Doug Gregor
0c9fb6206c Update one last test for extensions of generic typealiases. 2018-03-23 12:46:36 -07:00
Kuba (Brecka) Mracek
3e87cf4bd1 Remove "%T" expansions (#11612) 2017-11-28 15:47:14 -08:00
Jordan Rose
f5a6ac96cb [test] Add a test for the tricky circularity in SR-5191. (#11685)
This was fixed by 897effe, which I had originally thought would be a
no-functionality-change commit because it just made things lazier.
Turns out requirement signature deserialization can result in
circularity with sufficiently cross-referential conformances.

This isn't exactly a reduced test case because it still depends on
subclassing NSObject, which probably means there are hidden
dependencies on conforming to standard library protocols. But it's
better than nothing.

https://bugs.swift.org/browse/SR-5191
2017-08-29 16:51:51 -07:00
Robert Widmann
71bf312a25 Migrate the rest of the tests to %empty-directory 2017-06-04 11:08:39 -07:00
Dmitri Gribenko
486cab447d tests: replace 'rm -rf %t && mkdir -p %t' with '%empty-directory(%t)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Philippe Hausler
6c26b80e6e [Foundation] Rework the backing storage for CharacterSet to be more performant and bridge correctly to objective-c and CF
Some cases of using isSuperset can cause crashes, this was caused by improper subclassing callouts; this pr resolves those failures (and provides unit tests for that case)
The cases where the bridge was traversed too much now only causes a single bridge out call (without needing to reallocate or thrash retain/release)
String.components(separatedBy: CharacterSet) should be considerably faster now not only for more apporpriate bridging calls but also no longer needing to bridge arrays back and forth.

Resolves the following issues:
rdar://problem/17281998
rdar://problem/26611771
rdar://problem/29738989
2017-03-31 11:06:38 -07:00
Jordan Rose
c86f8e7089 [Serialization] Improve extensions of nested types with the same name (#7397)
Previously looking up an extension would result in all extensions for
types with the same name (nested or not) being deserialized; this
could even bring in base types that had not been deserialized yet. Add
in a string to distinguish an extension's base type; in the top-level
case this is just a module name, but for nested types it's a full
mangled name.

This is a little heavier than I'd like it to be, since it means we
mangle names and then throw them away, and since it means there's a
whole bunch of extra string data in the module just for uniquely
identifying a declaration. But it's correct, and does less work than
before, and fixes a circularity issue with a nested type A.B.A that
apparently used to work.

https://bugs.swift.org/browse/SR-3915
2017-02-13 12:42:12 -08:00
Jordan Rose
97b06445e3 Always desugar the base type of an extension when serializing. (#6336)
This "fixes" two issues:

- The name of a non-public typealias would leak into the public
  interface if the extension had any public members.

- A common pattern of defining a platform-specific typealias for an
  imported class and then extending that type would lead to
  circularity when trying to deserialize the typealias. We /shouldn't/
  be loading the extension at that point, but fixing that would be
  much harder.

The "right" answer is to (a) check that the typealias is public if the
extension has any public members, and (b) somehow ensure there is no
circularity issue (either by not importing the extension as a result
of importing the typealias, or by the extension being able to set its
sugared base type later).

rdar://problem/29694978
2016-12-19 16:44:35 -08:00
Jordan Rose
b61e04f3c0 [test] Fix and re-enable test that tries to build the Foundation overlay.
Checking determinism is important, so it's okay that the test is a little
brittle. Still better on than off.

rdar://problem/28450391
2016-12-16 10:35:54 -08:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Jordan Rose
9dd6308cfb Improve PrettyStackTrace entries, especially around serialization. (#5079)
Two of them are user-facing, with the following sort of message:

    If you're seeing a crash here, check that your SDK and
    dependencies match the versions used to build 'SwiftLib'

Prompted by rdar://problem/28282310, which took a while to figure out.
The added test case is a simplified version of the issue. (Obviously
we'd prefer to not crash here, but that's hard---there's an inherited
conformance that's no longer valid, and there may be generic types
depending on that conformance.)
2016-10-04 16:22:58 -07:00
Joe Groff
9b1f238e5b SE-0139: Bridge all standard number types to NSNumber.
Extend NSNumber bridging to cover not only `Int`, `UInt`, `Double`, and `Bool`, but all of the standard types as well. Extend the `TypePreservingNSNumber` subclass to accommodate all of these types, so that we preserve type identity for `AnyHashable` and dynamic casting of Swift-bridged NSNumbers. If a pure Cocoa NSNumber is cast, just trust that the user knows what they're doing.

This XFAILs a couple of serialization tests that attempt to build the Foundation overlay, but which don't properly handle `gyb` files.
2016-09-23 10:34:22 -07:00