Commit Graph

1540 Commits

Author SHA1 Message Date
Holly Borla
c1dcb9c6f1 [FrontendOptions] Remove bespoke experimental feature flags for ImplicitSome and
VariadicGenerics in favor of -enable-experimental-feature X.
2022-11-11 10:14:08 -08:00
Alexis Laferrière
e550944826 Merge pull request #61941 from xymus/module-alias-disambiguate
[ModuleInterface] Avoid ambiguities in swiftinterfaces by writing aliases for module names
2022-11-07 08:46:32 -08:00
Alexis Laferrière
66586b5f63 [ModuleInterface] Print alias for module names in swiftinterface files
Ambiguities are introduced in generated swiftinterfaces when a type
shares a name with a module (i.e. XCTest). This workaround uses the
module-alias feature to avoid these ambiguities. Writing module
references with a distinguishable prefix should allow normal
type-checking to avoid the usual ambiguities.

We should still aim for a proper fully-qualified named syntax, but this
may help in the mean time.

rdar://101969500
2022-11-04 12:30:33 -07:00
Zoe Carver
ae7466f699 Merge pull request #61895 from zoecarver/add-flag-for-c-frt
Put C foreign refernece types behind a flag.
2022-11-03 13:54:01 -07:00
zoecarver
bf652b6f31 Put C foreign refernece types behind a flag. 2022-11-02 17:08:31 -07:00
Stephen Canon
33d178cf60 Merge pull request #59623 from rxwei/cherry-42611 (#61793)
* Merge pull request #59623 from rxwei/cherry-42611

* Fixup switch.swift test from bad merge.

Co-authored-by: Richard Wei <rxrwei@gmail.com>
2022-11-02 14:02:16 -04:00
Pavel Yaskevich
bf6d893abe Merge pull request #61844 from xedin/rdar-99884335
[Basic] Make it possible to access some experimental features in production compilers
2022-11-01 14:28:39 -07:00
Pavel Yaskevich
f779f8059f [Basic] Make it possible to access some experimental features in production compilers
Resolves: rdar://99884335
2022-11-01 10:15:51 -07:00
Alexis Laferrière
47b29b68db Merge pull request #61649 from xymus/index-swiftinterfaces
[Index] Force indexing of system modules to read only from swiftinterfaces
2022-10-31 14:18:45 -07:00
Richard Wei
4ce1ebb120 [Macros] Support user-defined macros as compiler plugins (#61734)
Allow user-defined macros to be loaded from dynamic libraries and evaluated.

- Introduce a _CompilerPluginSupport module installed into the toolchain. Its `_CompilerPlugin` protocol acts as a stable interface between the compiler and user-defined macros.
- Introduce a `-load-plugin-library <path>` attribute which allows users to specify dynamic libraries to be loaded into the compiler.

A macro library must declare a public top-level computed property `public var allMacros: [Any.Type]` and be compiled to a dynamic library. The compiler will call the getter of this property to obtain and register all macros.

Known issues:
- We current do not have a way to strip out unnecessary symbols from the plugin dylib, i.e. produce a plugin library that does not contain SwiftSyntax symbols that will collide with the compiler itself.
- `MacroExpansionExpr`'s type is hard-coded as `(Int, String)`. It should instead be specified by the macro via protocol requirements such as `signature` and `genericSignature`. We need more protocol requirements in `_CompilerPlugin` to handle this.
- `dlopen` is not secure and is only for prototyping use here.

Friend PR: apple/swift-syntax#1022
2022-10-31 14:03:25 -07:00
Alexis Laferrière
90feb49d20 [Index] Remark on indexing system modules and use it in tests 2022-10-31 10:58:57 -07:00
Artem Chikin
c51efbed9c Add option to suppress emission of remarks ('-suppress-remarks')
And enforce it especially in downstream contexts such as building interfaces of SDK dependencies, where the remarks are not actionable by the user.
2022-10-28 10:49:27 -07:00
Adrian Prantl
3cc2831608 Don't require a strict revision match in LLDB.
For release-management purposes during development, LLDB's embedded Swift
compiler's version number can sometimes be off-by-one in the last digit
compared to the Swift compiler.

This patch restores the old behavior from before 17183629e4.

rdar://101299168
2022-10-19 09:03:13 -07:00
Dario Rexin
992cae456b [Frontend] Use experimental feature for layout prespecializations (#61451) 2022-10-06 15:21:01 -07:00
Alexis Laferrière
6d5e01ef35 Merge pull request #61184 from xymus/default-require-explicit-avail-reland
[Sema] Require explicit availability on public modules (Landing again after we held it back)
2022-10-03 17:14:52 -07:00
Artem Chikin
bfa63750ce [ClangImporter] Add a mode to create the underlying Clang 'CompilerInvocation' directly from 'cc1' arguments, bypassing the Clang driver, only in the 'emit-pcm' compilation flow.
Controlled with a new flag '-direct-clang-cc1-module-build'

This will allow clients to formulate 'swift-frontend' invocations with fully-specified set of cc1 arguments (using '-Xcc -Xclang -Xcc <FLAG>') required for the PCM build, without having to go through the driver.
2022-09-27 09:59:06 -07:00
Dario Rexin
210c68d8aa [SILOptimizer] Add prespecialization for arbitray reference types (#58846)
* [SILOptimizer] Add prespecialization for arbitray reference types

* Fix benchmark Package.swift

* Move SimpleArray to utils

* Fix multiple indirect result case

* Remove leftover code from previous attempt

* Fix test after rebase

* Move code to compute type replacements to SpecializedFunction

* Fix ownership when OSSA is enabled

* Fixes after rebase

* Changes after rebasing

* Add feature flag for layout pre-specialization

* Fix pre_specialize-macos.swift

* Add compiler flag to benchmark build

* Fix benchmark SwiftPM flags
2022-09-22 16:29:01 -07:00
Angela Laar
5f3191c74e [AST] Teach GenericParamList amd OpaqueReturnType Request to use plain protocols
Originally protocols prefixed with 'some' keyword are considered an opaue return
type representation. In order to understand plain protocols, the GenericParamList
Request must understand how to build a generic parameter list using alternative
type representations: identifier and composition.
2022-09-20 15:25:09 -07:00
Angela Laar
c3ef34b080 Add experimental feature flag for Implement 'some' 2022-09-20 15:25:06 -07:00
Alexis Laferrière
7a7f3ac52f [Sema] Enable require explicit availability by default for public modules
rdar://99929744
2022-09-19 09:04:44 -07:00
Kavon Farvardin
109244caac Merge pull request #61161 from xymus/revert-rea-for-api
[Sema] Revert enabling require-explicit-availability for public modules by default
2022-09-16 14:58:55 -07:00
Max Obermeier
453fd2231b Allow for emission of swift.extension symbols for extensions to external types in swiftSymbolGraphGen (#59047)
This includes:
 - bumping the SWIFT_SYMBOLGRAPH_FORMAT_MINOR version
 - introduction of the "swift.extension" symbol and "extensionTo" relationship
 - adding support for ExtensionDecl to the Symbol class
 - adding a "typeKind" field to the symbol's extension mixin which indicates what kind
   of symbol was extended
 - intoduction of the -emit-extension-block-symbols flag, which enables the behavior
   outlined below
 - adaptions to SymbolGraphASTWalker that ensure a swift.extension symbol is emitted
   for each extension to a type that does not exist in the local symbol graph
 - adaptions to SymbolGraph and SymbolGraphASTWalker that ensure member and conformance
   relationships are correctly associated with the swift.extension symbol instead of
   the original type declaration's (extended nominal's) symbol where applicable
 - adaptions to SymbolGraphASTWalker that ensure swift.extension symbols are connected
   to their respective extended nominal's symbol using an extensionTo relationship

Testing:
- adds SymbolGraph tests that test behavior only relevant in
  -emit-extension-block-symbols mode
- adapts some SymbolGraph tests to additionally test similar behavior for
  extensions to external types in -emit-extension-block-symbols mode
- adapts some SymbolGraph tests to (additionally or exclusively) test the
  behavior with -emit-extension-block-symbols mode enabled

Bugfixes:
- fixes a bug where some conformsTo relationships implicated by the conformances
  declared on an extension to an external type were not emitted
  (see test/SymbolGraph/Relationships/ConformsTo/Indirect.swift)

Further changes:
- documents the strategy for naming and associating children declared in extensions
  to typealiases (see test/SymbolGraph/Relationships/MemberOf/Typealias.swift,
  test/SymbolGraph/Symbols/Names.swift)
2022-09-16 12:02:40 -06:00
Alexis Laferrière
a92e607f77 Revert "[Sema] Enable require explicit availability by default for public modules"
This reverts commit 2175e4e27d.
2022-09-16 09:50:12 -07:00
Alexis Laferrière
1e40db1d4b Merge pull request #61105 from xymus/default-require-explicit-avail
[Sema] Require explicit availability on public modules and customizable diagnostics level
2022-09-15 11:05:12 -07:00
Alexis Laferrière
2175e4e27d [Sema] Enable require explicit availability by default for public modules
rdar://99929744
2022-09-14 16:21:52 -07:00
Alexis Laferrière
dcbef35982 [Sema] Intro flag to promote to an error missing explicit availability 2022-09-14 16:21:52 -07:00
Robert Widmann
18b79ffcfd Resolve a Layering Violation in libBasic
Basic should not be allowed to link Parse, yet it was doing so
to allow Version to provide a constructor that would conveniently
parse a StringRef. This entrypoint also emitted diagnostics, so it
pulled in libAST.

Sink the version parser entrypoint down into Parse where it belongs
and point all the clients to the right place.
2022-09-09 00:21:30 -07:00
Erik Eckstein
3e1ff0a5b7 IRGen: move the EnableStackProtector option from IRGenOptions to SILOptions.
... because we need it in the SIL pass pipeline, too.
Also, add Swift bridging for that option.
2022-09-08 08:42:24 +02:00
Evan Wilde
0d1c33674c Merge pull request #60711 from etcwilde/ewilde/reapply-backdeploy56
Revert reverting the 5.6 backdeploy
2022-09-06 14:58:17 -07:00
Alexis Laferrière
b680084748 [Sema] @_spiOnly needs to be enabled with a flag 2022-09-01 15:16:46 -07:00
Evan Wilde
f7810ada24 Revert "Merge pull request #60459 from etcwilde/ewilde/revert-backdeploy56"
This reverts commit 93387f8a0b, reversing
changes made to 88304c327f.
2022-09-01 10:07:44 -07:00
Artem Chikin
19831bea58 Merge pull request #60585 from artemcm/SeparateUpToDateCheck
[Explicit Modules] On an explicit interface build, early exit if expected output is up-to-date.
2022-08-23 10:24:18 -07:00
Pavel Yaskevich
bca9004ae1 Merge pull request #60707 from xedin/switch-to-string-format-for-locale
[Localization] Switch diagnostics/localization to `.strings` format
2022-08-23 09:49:27 -07:00
Pavel Yaskevich
5a164c5f8a [Frontend] Switch from YAML to .strings based localization 2022-08-22 10:23:06 -07:00
Alexis Laferrière
9e3f5f9cea [ModuleInterface] Print missing imports in swiftinterface
Hack to fix swiftinterfaces in case of missing imports. We can get rid
of this logic when we don't leak the use of non-locally imported things
in API.
2022-08-19 12:32:43 -07:00
Artem Chikin
256c0ff04a [Explicit Modules] On an explicit interface build, early exit if the expected output is up-to-date. 2022-08-16 18:31:13 -07:00
swift-ci
6f56287acf Merge remote-tracking branch 'origin/main' into rebranch 2022-08-09 11:16:06 -07:00
Evan Wilde
15b3659484 Revert "Merge pull request #60368 from etcwilde/ewilde/backdeploy56"
This reverts commit a3941bf215, reversing
changes made to b39302a585.
2022-08-09 07:16:02 -07:00
swift-ci
b5f90f7be8 Merge remote-tracking branch 'origin/main' into rebranch 2022-08-08 10:54:35 -07:00
Evan Wilde
a3941bf215 Merge pull request #60368 from etcwilde/ewilde/backdeploy56
Adding the Backdeploy 5.6 compatibility library
2022-08-08 10:41:39 -07:00
Ben Barham
22d62bb4e0 Merge remote-tracking branch 'origin/main' into rebranch
Trivial conflict caused by the line above the
`IGM.constructInitialFnAttributes` change in `lib/IRGen/GenDecl.cpp`
having an extra argument passed in rebranch (due to the new LLVM API).
2022-08-03 19:12:06 -07:00
Evan Wilde
2ac2249801 Stubbing out backdeploy library
This patch gets everything to the point of building the library, but it
doesn't run yet since I have missing symbols.

Unlike previous compatibility libraries and the concurrency
compatibility library, I'm organizing the headers a bit more. This is
because we're merging the two libraries into one. They share some common
header names, and while I could rename them for namespacing purposes,
it's easier to just use a directory structure for this.

The `include/Runtime` and corresponding `Runtime/` directories are for
backdeployed changes to the stdlib itself.

The `include/Concurrency` and corresponding `Concurrency/` directories
are for backdeployed changes to the concurrency runtimes.
2022-08-02 14:47:26 -07:00
Arnold Schwaighofer
0379719052 IRGen: Add option to enable stack protector
Adds frontend option -enable-stack-protector to enable emission of a
stack protector.

Disabled by default.

When enabled enables LLVM's strong stack protection mode.

rdar://93677524
2022-08-02 09:05:37 -07:00
swift-ci
69e5a83e7d Merge remote-tracking branch 'origin/main' into rebranch 2022-08-02 08:35:16 -07:00
Arnold Schwaighofer
78f5e0b0fd Merge pull request #60231 from aschwaighofer/generic_objc_method_list_section
IRGen: Add a list of class_ro_t referenced from generic class metadata patterns to a section __swift_rodatas
2022-08-02 08:23:52 -07:00
swift-ci
fe778db9fc Merge remote-tracking branch 'origin/main' into rebranch 2022-08-01 14:33:45 -07:00
Allan Shortlidge
34012dbc68 Frontend: Rename -enable-ad-hoc-availability to -weak-link-at-target.
I am separating the concern of weakly linking symbols that are introduced at the deployment target from the concern of type checking this new type of potential unavailability.

Resolves rdar://97925900
2022-08-01 11:57:06 -07:00
Arnold Schwaighofer
6ce452b928 IRGen: Add a list of class_ro_t referenced from generic class metadata patterns to a section __swift_rodatas
Put pointers to class_ro_t referenced from generic class patterns in a section __swift_rodatas such that they are discoverable by the linker.
The linker can then make the method lists contained in the class_ro_t relative like it can for objective c class metadata from non-generic swift classes.

rdar://66634459
2022-07-29 11:38:20 -07:00
Arnold Schwaighofer
9c3691f779 Merge pull request #60199 from aschwaighofer/enable_new_llvm_pass_manager
IRGen: Enable the new llvm pass manager
2022-07-27 17:01:07 -07:00
Arnold Schwaighofer
0475e7368d IRGen: Enable the new llvm pass manager
rdar://96687157
2022-07-26 08:10:10 -07:00