Commit Graph

190 Commits

Author SHA1 Message Date
Hamish Knight
6abfea9312 [CS] NFC: Remove CTP_CalleeResult
This has been unused since the removal of CSDiag.
2025-11-16 18:29:37 +00:00
Alexis Laferrière
11c448d954 Tests: Use a local cache for many tests importing AppKit
Tests importing AppKit have a tendency to be flaky if they share a
module cache with other builds using a different set of framework search
flags. Make sure they use a local cache to avoid picking incompatible
cached modules.

Alternatively, we could align all builds using the same cache to have
exactly the same framework search paths or enable explicit module
builds. I picked the module cache as it's the most reliable solution in
the short and long term.

The 5 tests below import AppKit and have been known to be flaky.
Adapting them to use a custom cache with require more care. For now,
let's use them as control group to validate that the fix works. If these
5 fail without the fixed ones, we should extend the same corresponding
fix to them.

- Interpreter/SDK/GLKit.swift
- Interpreter/SDK/cf_extensions.swift
- Interpreter/SDK/cf_type_bridging.swift
- Interpreter/SDK/mapkit_header_static.swift
- Interpreter/SDK/objc_ns_enum.swift

rdar://142296731
2025-01-09 12:22:02 -08:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Michael Spencer
b2640e15e4 [test] Rename all module.map files to module.modulemap
`module.map` as a module map name has been discouraged since 2014, and
Clang will soon warn on its usage. This patch renames all instances of
`module.map` in the Swift tests to `module.modulemap` in preparation
for this change to Clang.

rdar://106123303
2023-08-21 15:58:59 -07:00
Allan Shortlidge
7dc313f1be NFC: Fix tests that mistakenly rely on unavailable stored properties.
Preparation for rdar://107449845
2023-04-04 08:52:39 -07:00
Josh Soref
0c060f7ae3 spelling: dummy
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-05-01 04:02:09 -04:00
Michael Gottesman
af25b6764c [swift-stage2] Point the API migrator at the correct directory when building/testing against a host toolchain.
This involved adding a new substitution called %api_diff_data_dir that when
building against a host toolchain, looks in the host toolchain (next to swiftc)
rather than in the resource dir. The reason why I need to do this is this allows
me to perform a stdlib stage2 build without needing to build swift itself.

The only interesting changes here are that I had to add %api_diff_data_dir to
a bunch of normal/expected tests and also add %api_diff_data_dir's length to the
offsets in rdar31892850.swift.
2021-08-12 11:50:04 -07:00
Luciano Almeida
d55eed46e8 [Sema][CSApply] Moving some checked cast diagnostics to a fix format (#34980)
* [Sema] Implementing is runtime check always true diagnostic as a fix

* [AST] Implement getWithoutThrows on function type

* [CSSimplify] Detect that checked cast types conversion is always true and record warning fix

* [test] Some additional test cases for SR-13789

* [Sema] Fixing typo on fix name

* [Sema] Move and adjust the ConditionalCast diagnostics to the fix format

* [Sema] Remove some checked cast diagnostics from check constraints and move to fix

* [Sema] Renaming checked cast coercible types fix

* [Sema] Some adjustments and rewrite on the logic for downcast record fix

* [Sema] Move logic of runtime function type to AllowUnsupportedRuntimeCheckedCast::attempt

* [Sema] Abstract checked cast fix logic to static function and minor adjustments

* [Sema] Renamings from review
2021-02-10 08:31:06 -03:00
3405691582
88167e74d1 [test] diff --strip-trailing-cr is non-standard.
This flag is a GNU extension, and would cause misleading test failures
on other platforms where this extension is not available. However, the
necessity to switch line endings is only required on Windows when
testing. We could use sed to canonicalize line endings before comparing,
but that may cause higher amounts of filesystem traffic on Windows which
would slow down testing.

Instead, move the substitution for diff in SourceKit's lit.local.cfg up
to the top level, and conditionalize the substitution which has the flag
on Windows, but not on other platforms (where it should not be required).
2020-09-13 13:50:15 -04:00
Robert Widmann
50159d15b7 [Gardening] Use Vendor=apple Where Possible
This simplifies the usual bundle of OS checks

OS=macosx || OS=ios || OS=tvos || OS=watchos

into

VENDOR=apple

which was added in apple/swift#27307
2020-06-30 23:03:01 -07:00
Pavel Yaskevich
f048652a2b [ConstraintSystem] Do more checking before suggesting to explicitly contruct raw representable
Introduce `repairByExplicitRawRepresentativeUse` which is used for
assignment, argument-to-parameter conversions and contextual mismatches.

It checks whether `to` side is a raw representable type and tries
to match `from` side to its `rawValue`.
2020-05-29 12:14:07 -07:00
Varun Gandhi
a1716fe2a6 [Diagnostics] Update compiler diagnostics to use less jargon. (#31315)
Fixes rdar://problem/62375243.
2020-04-28 14:11:39 -07:00
Saleem Abdulrasool
f12f0ccd01 test: adjust Migrator tests (NFCI)
This adjusts the test diffing to ignore the whitespace changes across
different platforms.  `raw_fd_ostream` will write out `OF_Text` files
with the platform's line endings, which may differ from the source
file's.
2020-01-13 18:45:45 -08:00
Slava Pestov
9626340d4b Sema: Remove unused -fix-string-to-substring-conversion flag 2019-03-14 22:08:43 -04:00
Xi Ge
2be1ca0c8a migrator: add ! to property access whose definition changes from nonnull to nullable. rdar://48090648 2019-02-14 15:28:52 -08:00
Karoy Lorentey
6af814d76c [test] Test new fix-it for NSObject.hashValue overrides 2019-01-23 19:44:01 -08:00
Argyrios Kyrtzidis
c472c90df2 Merge pull request #21888 from akyrtzi/migrate-index-where
[migrator] Migrate '.index(where:)' to '.firstIndex(where:)'
2019-01-15 15:36:45 -08:00
Argyrios Kyrtzidis
90f2207b70 [migrator] Migrate '.index(where:)' to '.firstIndex(where:)'
rdar://47296913
2019-01-15 14:32:51 -08:00
Xi Ge
f8dd31b8fa migrator/test: disable fixits while testing rename migration pass.
The migration under testing is entirely driven by migration scripts. Having
fixits enabled may cause red herring.
2019-01-15 11:42:54 -08:00
Xi Ge
c6a64a9a21 migrator: handle function's return type changes from nonnull to nullable. rdar://47265255
Adding exclamation brings an optional type back to its original nonnull
version.
2019-01-14 14:15:07 -08:00
Nathan Hawes
43c2f27783 [Refactoring][Migrator] Fix rename of callsites with a trailing closure argument
A label range of 0 length was being reported as the label of trailing closure
arguments, just before the opening '{'.

For the rename refactoring, this meant that if the corresponding parameter had
an external label (e.g. 'a') the occurrence would be treated as not matching the
expected symbol name, and so not be updated at all.

For the migrator, when renaming a function with an unlabelled closure for its
last parameter to have a label, it would incorrectly insert the new label in
front of the opening '{' on all of that function's callsites with trailing
closures.

Resolves rdar://problem/42162571
2018-12-19 16:24:14 -08:00
swift-ci
fad03f690f Merge pull request #21437 from nkcsgexi/mig-enhance 2018-12-19 13:44:16 -08:00
Xi Ge
83382c5f94 migrator: rename a property declaration if the framework property it overrides has been renamed. 2018-12-19 11:58:22 -08:00
Xi Ge
4164600bed migrator: set up placeholder migration scripts for swift 4.2 2018-12-18 11:49:14 -08:00
Xi Ge
97257c5d16 migrator: rename index(of:) to firstIndex(of:) for swift 5. 2018-12-17 15:38:16 -08:00
Mark Lacey
018498fb2f Merge pull request #16942 from bjhomer/bjhomer/optional-try-flattening
Flatten nested optionals resulting from try? and optional sub-expressions
2018-11-16 11:14:05 -08:00
BJ Homer
f166b0da3d Make the try? migration simpler and more reliable.
We were trying to get fancy rewriting cases where multiple 'if let' clauses were
used to unwrap a double optional, but in testing that turned out to be too
unreliable. Now we simply detect any 'try?' expressions whose behavior will change,
and add an explicit 'as OldType' to the expression, in order to preserve the original
behavior.
2018-11-14 01:10:00 -07:00
BJ Homer
c371c06450 Add basic tests for 'try?' migration. 2018-11-12 09:43:15 -07:00
Ted Kremenek
46510a5eba Bump compiler version to Swift 5.
Main pieces:

- Bump swift-version to 5
- Remove -swift-version 3 support
2018-11-06 14:38:55 -08:00
Xi Ge
87ed4b4488 [test] Remove Swift 3 flags from various tests. 2018-10-09 16:09:41 -07:00
Rintaro Ishizaki
203a253687 [Parse/Migrator] Drop Swift3 migration support for type(of:) (#17932)
In Swift3, shadowning type(of:) was impossible, because it was a parser
magic. In Swift4, type(of:) is resolved as normal function in stdlib so
it can be shadowed. 'TypeOfMigratorPass' was a targeted migrator pass
that prepend 'Swift.' to 'type(of:)' so that it refers Swift.type(of:)
stdlib builtin function.
2018-08-01 08:22:28 -07:00
Argyrios Kyrtzidis
7d1d0950cb [migrator] Handle AppKit protocol migrations
This is https://github.com/apple/swift/pull/18226 but with a fix for the test to be macos specific.
rdar://42480588
2018-07-27 15:43:29 -07:00
Karoy Lorentey
aff1b03b82 [migrator] Fix offset in no_duplicate_aarch64_use_tbi test
A recent commit caused an offset drift.

rdar://problem/42631862
2018-07-27 15:43:49 +01:00
Pavel Yaskevich
f0d1f0bc66 Revert "migrator: handle AppKit protocol migrations. rdar://42480588" 2018-07-27 00:04:23 -07:00
Xi Ge
a8d43cc344 migrator: handle AppKit protocol migrations. rdar://42480588 2018-07-26 16:57:48 -07:00
swift-ci
d684dacc1a Merge pull request #18197 from nkcsgexi/mig-test-mig-2 2018-07-24 17:18:47 -07:00
Xi Ge
d668d4d1fa migrator/test: remove swift 3 flag for several tests. 2018-07-24 16:28:44 -07:00
Xi Ge
fedf531b2a migrator/test: remove -swift-version=3 flag from the test. 2018-07-23 16:09:07 -07:00
Xi Ge
c738e90a5b migrator: ensure we collect post-migration fixits from the compiler. rdar://40925061 2018-07-18 13:11:17 -07:00
Doug Gregor
945c09b1cc [Type checker] Improve diagnostics when an optional value is not unwrapped.
When we determine that an optional value needs to be unwrapped to make
an expression type check, use notes to provide several different
Fix-It options (with descriptions) rather than always pushing users
toward '!'. Specifically, the errors + Fix-Its now looks like this:

    error: value of optional type 'X?' must be unwrapped to a value of
        type 'X'
      f(x)
        ^
    note: coalesce using '??' to provide a default when the optional
        value contains 'nil'
      f(x)
        ^
          ?? <#default value#>
    note: force-unwrap using '!' to abort execution if the optional
        value contains 'nil'
      f(x)
         ^
         !

Fixes rdar://problem/42081852.
2018-07-13 11:02:04 -07:00
Xi Ge
f83ccd6438 migrator: handle changed parameter declarations by introducing bridging local variables.
When users override a SDK function whose parameter types have been changed,
we should introduce a local variable in the body of the function definition
to shadow the changed parameter. Also, a proper conversion function should
be applied to bridge the parameter to the local variable.

rdar://41828411
2018-07-11 13:41:37 -07:00
Mark Lacey
5e75b1ad3b Remove -swift-version 3 from a handful of tests and update them appropriately.
These are all tests that would otherwise fail if the expression type
checker support for Swift 3 is removed.

I've moved some of the code from deleted Migrator tests into new
Constraints tests that verify that we do not support the constructs.
2018-07-04 20:58:21 -07:00
Xi Ge
c40ebd1d2d migrator: support migration of raw representable initializer calls without explicit labels. rdar://41740103
Some raw representable struct from SDK can be initialized without
explicit labels (rawValue:). When their types have been changed to type
alias, we should migrate the initializer calls to the argument alone.
2018-07-03 11:44:21 -07:00
Xi Ge
8e0e779cc2 migrator: handle the composite change of updating type alias to raw-representable and rename the referenced variables simultaneously. rdar://41732485 2018-07-02 12:13:20 -07:00
Xi Ge
46a1142b7f Merge pull request #17644 from nkcsgexi/global-name
migrator: handle member variables change to global ones. rdar://41658300
2018-07-02 09:25:44 -07:00
Xi Ge
c23d1a89a4 migrator: ensure we update unresolved member access correctly to global names. rdar://41658300 2018-06-29 17:29:53 -07:00
Xi Ge
4ed9f9a9a6 migrator: support the migration from member variables to global ones. rdar://41658300 2018-06-29 16:35:51 -07:00
Nathan Hawes
50f9c94ac8 [migrator] Migrate UIApplicationMain
In Swift 4.2 the second parameter of UIApplicationMain exactly matches the type
of CommandLine.unsafeArgv so it can be called as below:

UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, ...)

This is how it was intended to be in Swift 4 as well, but the types had
optionality differences, so callers instead had to do something like the below
example from the Firefox-iOS project:

let pointer = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(
    to: UnsafeMutablePointer<Int8>.self, capacity: Int(CommandLine.argc))
UIApplicationMain(CommandLine.argc, pointer, ...)

This migration simply replaces the the second argument with
CommandLine.unsafeArgv if the first argument is CommandLine.argc.

There is an open issue for providing a deprecated version with the old type so
we simply leave as is any callers that don't pass argc for the first argument.

Resolves rdar://problem/40045693.
2018-06-28 18:46:41 -07:00
Xi Ge
9a0196e991 migrator: avoid adding conversion functions when expression types change as well.
When inserting conversion functions around expressions, we should check
whether the type of the expression is a recognized name alias that is
known to be changed to raw-value representable type. We should avoid
inserting conversion functions in this case because doing so causes
build errors.

resolves: rdar://40463990
2018-06-25 14:44:58 -07:00
Nathan Hawes
f76c87acf8 [migrator] Upstream overlay3/4.json and associated tests.
These being downstream only made them easy to break (and they did).

Resolves rdar://problem/41353459
2018-06-22 18:36:31 -07:00