Commit Graph

533 Commits

Author SHA1 Message Date
Roman Levenstein
2a10d8692b Clean-up the code that stored and passes the SILSerializeAll flag around.
- SILSerializeAll flag is now stored in the SILOptions and passed around as part of it
- Explicit SILSerializeAll/wholeModuleSerialized/makeModuleFragile API parameters are removed in many places
2017-06-16 17:50:33 -07:00
Mark Lacey
d26c859222 Add -warn-long-expression-type-checking=<limit> frontend option.
Generates a warning for any expression that takes longer than <limit>
milliseconds to type check. This compliments the existing
-warn-long-function-body=<limit> option.
2017-06-12 17:27:29 -07:00
Arnold Schwaighofer
ca63326e1b Delete unused existential value witnesses from the old existential
implementation

And remove the SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS flag.
2017-06-02 14:34:41 -07:00
Andrew Trick
25d17e9933 Enable enforce-exclusivity=checked at -Onone.
This enables dynamic checking at -Onone.

Static checking is enabled by default regardless of optimizations.

SILGen only emits dynamic markers at -Onone, or when explicitly requested with
-enforce-exclusivity=checked|dynamic.

All access markers are stripped at the start of the optimization pipeline
regardless of optimization level or command line flags.
2017-05-31 21:43:00 -07:00
Huon Wilson
a6e1734bcb Merge pull request #9884 from huonw/symbol-list-8
Improve TBD validation logic
2017-05-24 11:38:24 -07:00
Joe Shajrawi
501fcf5a33 Merge pull request #9841 from shajrawi/flag_large_loadable
Add a flag (false by default) for large loadable types pass
2017-05-22 15:31:34 -07:00
Joe Shajrawi
edea7d04b3 Add a flag (false by default) for large loadable types pass 2017-05-22 14:25:25 -07:00
Jordan Rose
4a46d47a05 Disable diagnostics about problem NSCoding-conforming classes for now. (#9808)
Adoption so far shows that the criteria we set up here are too broad.
This is particularly problematic for subclasses of NS/UIView and the
like that might never be encoded at all.

rdar://problem/32306355
2017-05-20 14:26:30 -07:00
Huon Wilson
40ba18615b [Frontend] -validate-tbd-against-ir has 3 levels of validation.
It can now:

- not validate (=none)
- validate that all symbols in the IR are also in the TBD (=missing),
- validate the above, and also that all in the TBD are in the IR (=all).

The first and last were switched between with the old boolean flag, the
second is new.
2017-05-19 18:36:48 -07:00
Devin Coughlin
f239ae2ad7 [Exclusivity] Suggest Fix-Its to replace swap() with swapAt()
Extend the static diagnostics for exclusivity violations to suggest replacing

  swap(&collection[index1], &collection[index2]

with

  collection.swapAt(index1, index2).

when 'collection' is a MutableCollection.

To do so, repurpose some vestigial code that was previously used to suppress all
exclusivity diagnostics for calls to swap() and add some additional syntactic,
semantic,  and textual pattern matching.

rdar://problem/31916085
2017-05-17 17:48:58 -07:00
Joe Groff
faa6bc72f0 Sema: Reject unimplemented key path components during resolveKeyPathExpr.
This is a bit more robust and user-friendly than hoping more brittle recovery in SILGen or IRGen for unsupported components kicks in. rdar://problem/32200714
2017-05-15 16:10:59 -07:00
Argyrios Kyrtzidis
12b94441ec Merge pull request #9509 from akyrtzi/persistent-pch-for-build
[Driver/ClangImporter] Changes for the driver to recognize -pch-output-dir and propagate to the frontend invocations
2017-05-12 07:46:09 -07:00
Argyrios Kyrtzidis
c4b5b60d00 [Driver/ClangImporter] Changes for the driver to recognize -pch-output-dir and propagate to the frontend invocations
For the multiple-files mode -emit-pch is still invoked in separate frontend invocation but with using a persistent PCH.
Subsequent frontend invocations use the persistent PCH but they don't need to validate it.

For all-files mode (e.g. WMO) the frontend invocation uses a persistent PCH that it also validates.
2017-05-11 11:44:12 -07:00
Jordan Rose
e0c248c932 Turn on deserialization recovery by default. (#9486)
I'm still leaving a -disable-deserialization-recovery flag in there
just in case.
2017-05-11 08:47:59 -07:00
Xi Ge
fb77682b5a [Migrator] Add a stub for authored API change list to handle API changes that are not detected automatically. (#9477) 2017-05-10 21:51:25 -07:00
Adrian Prantl
e2784cbb87 Represent Clang macro definitions from -Xcc options in the debug info.
Currently -Xcc options are serialized in Swift modules, but they are
not saved as attributes to the DW_TAG_module representing the imported
clang module. This patch saves all *user-specified* -D macros there,
but it does not save any macros that are added by the ClangImporter
itself.

<rdar://problem/31990102>
2017-05-09 16:46:22 -07:00
David Farler
be86bcac1d [Migrator] Suggest String <-> Substring conversions
Some APIs that expected a String now expect a Substring and vice
versa. To ease the transition, emit fix-its on conversion errors
between these types that the migrator can pick up.

When converting from Substring -> String, suggest wrapping in
`String.init`.

When converting from String -> Substring, suggest appending the
void subscript `[]`. (This isn't implemented yet so this is
hidden behind a flag).

This can possibly be generalized later when converting between
some sequence and its subsequence, such as Array and ArraySlice,
for example.

rdar://problem/31665649
rdar://problem/31666638
2017-05-04 16:40:56 -07:00
Xi Ge
89d50e366f [Sema] -serialize-diagnostics-path should imply -diagnostics-editor-mode so that live issues and editor builds can have the consistent behavior. (#9166) 2017-05-02 10:53:38 -07:00
Doug Gregor
66b11cbc3d [SE-0160] Make deprecated @objc inference warnings opt-in.
The warnings about deprecated @objc inference in Swift 3 mode can be a
bit annoying; and are mostly relevant to the migration workflow. Make
the warning emission a three-state switch:

* None (the default): don't warn about these issues.
* Minimal (-warn-swift3-objc-inference-minimal): warn about direct
  uses of @objc entrypoints and provide "@objc" Fix-Its for them.
* Complete (-warn-swift3-objc-inference-complete): warn about all
  cases where Swift 3 infers @objc but Swift 4 will not.

Fixes rdar://problem/31922278.
2017-05-01 16:25:50 -07:00
David Farler
0ecf8a98bb Merge pull request #9116 from bitjammer/rdar-31876357-migrator-objc-inference-workflows
[Migrator] Conservative and Minimal @objc inference workflows
2017-04-28 22:37:43 -07:00
Andrew Trick
2336a87866 [Exclusivity] Enable access markers for the entire -Onone pipeline.
Dynamic markers are still conditional on the command line option.
2017-04-28 21:33:09 -07:00
David Farler
bf52ff032a [Migrator] Conservative and Minimal @objc inference workflows
Based on recommendations in SE-0160, there are two migration workflows:

- Conservative: Maintain @objc visibility that was inferred in Swift 3
  by adding @objc to all declarations that were implicitily visible to
  the Objective-C runtime. This is invoked in the migrator by adding the
  -migrate-keep-objc-visibility flag.
- Minimal: Only declarations that must be visible to Objective-C based
  on their uses (or in cases like dynamic vars) are migrated.

rdar://problem/31876357
2017-04-28 18:28:34 -07:00
Slava Pestov
e3b68e7bdd Remove -enable-experimental-subclass-existentials staging flag 2017-04-27 20:46:37 -07:00
David Farler
63776b507b When converting some of the old Migrator automation to the new Migrator,
I had set up the driver to invoke a separate frontend invocation with
the "update code" mode. We sort of did this last release, except we
forked to the swift-update binary instead. This is causing problems with
testing in Xcode.

Instead, let's perform a single compile and add the remap file as an
additional output during normal compiles. The driver, seeing
-update-code, will add -emit-remap-file-path $PATH to the -c frontend
invocation.

rdar://problem/31857580
2017-04-27 01:03:00 -07:00
Xi Ge
2a2731a797 migrator: add a flag to print incoming usrs to the API diff data store to facilitate testing. NFC (#8969) 2017-04-24 13:53:55 -07:00
Joe Groff
3d178be169 Merge pull request #8875 from jckarter/keypaths
Keypaths
2017-04-21 17:51:17 -07:00
Huon Wilson
d0739294ed Merge pull request #8887 from huonw/emit-loaded-module-trace
[Frontend] -frontend -emit-loaded-module-trace.
2017-04-21 13:25:52 -07:00
Huon Wilson
87aa3e6935 [Frontend] -frontend -emit-loaded-module-trace.
The -frontend jobs can output a JSON file summarizing the
swiftmodules (etc.) they load during compilation.
2017-04-21 11:14:29 -07:00
Joe Groff
cdb54ccadf Put keypaths behind a flag. 2017-04-19 20:39:11 -07:00
swift-ci
6eb7c0dbf5 Merge pull request #8853 from devincoughlin/swap-suppression-flag 2017-04-18 18:10:30 -07:00
Devin Coughlin
ae3b13ed2d [Exclusivity] Put suppression for free function swap() behind a flag
And leave suppression off by default for now. We'll use this to evaluate
how often swap() causes exclusivity conflicts to be reported.
2017-04-18 17:21:53 -07:00
Xi Ge
acf4f6e27e [Migrator] Add stubs for API change data files. (#8844)
These data files are installed into runtime resource directory so that migrator can pick them automatically according to specific platforms. To support testing, a front-end option -api-diff-data-file can be used to specify the data file to use and it will overwrite the default ones from resource directory.
2017-04-18 15:20:57 -07:00
practicalswift
eab6a01b7b [gardening] Fix incorrect spacing 2017-04-18 19:15:25 +02:00
David Farler
303a3e5824 Start the Migrator library
The Swift 4 Migrator is invoked through either the driver and frontend
with the -update-code flag.

The basic pipeline in the frontend is:

- Perform some list of syntactic fixes (there are currently none).
- Perform N rounds of sema fix-its on the primary input file, currently
  set to 7 based on prior migrator seasons.  Right now, this is just set
  to take any fix-it suggested by the compiler.
- Emit a replacement map file, a JSON file describing replacements to a
  file that Xcode knows how to understand.

Currently, the Migrator maintains a history of migration states along
the way for debugging purposes.

- Add -emit-remap frontend option
  This will indicate the EmitRemap frontend action.
- Don't fork to a separte swift-update binary.
  This is going to be a mode of the compiler, invoked by the same flags.
- Add -disable-migrator-fixits option
  Useful for debugging, this skips the phase in the Migrator that
  automatically applies fix-its suggested by the compiler.
- Add -emit-migrated-file-path option
  This is used for testing/debugging scenarios. This takes the final
  migration state's output text and writes it to the file specified
  by this option.
- Add -dump-migration-states-dir

  This dumps all of the migration states encountered during a migration
  run for a file to the given directory. For example, the compiler
  fix-it migration pass dumps the input file, the output file, and the
  remap file between the two.

  State output has the following naming convention:
  ${Index}-${MigrationPassName}-${What}.${extension}, such as:
  1-FixitMigrationState-Input.swift

rdar://problem/30926261
2017-04-17 16:25:02 -07:00
John McCall
b233e872dc Fix the type-checker's recursive value type checking.
Track the types we've seen instead of the type declarations we've
passed through, which eliminates some holes relating to generic types.
Detect infinite expansions by imposing an arbitrary limit.

Fixes rdar://30355804
2017-04-12 15:55:45 -04:00
Slava Pestov
de323b5bef Sema: Update resolveType() for subclass existentials
If the -enable-experimental-subclass-existentials staging flag
is on, resolveType() now allows protocol compositions to contain
class types. It also diagnoses if a composition has more than one
superclass requirement.

Also, change diagnostics that talked about 'protocol composition'
to 'protocol-constrained type'.

Since such types can now contain a superclass constraint, it's not
correct to call them protocol composition.

"Protocol-constrained type" isn't quite accurate either because
'Any' has no protocols, and 'AnyObject' will have no protocols but
a general class constraint; but those are edge cases which won't
come up in these diagnostics.
2017-04-10 17:11:07 -07:00
Jordan Rose
e7d1027e8a Merge pull request #8580 from jrose-apple/enable-experimental-deserialization-recovery
[Serialization] Proof-of-concept: drop overriding methods if the base is missing
2017-04-10 13:57:33 -07:00
Jordan Rose
6fdb076c5e Add a staging flag -enable-experimental-deserialization-recovery.
No promises that this is stable yet!
2017-04-05 18:31:46 -07:00
Michael Gottesman
e2a6a6233e [semantic-sil] Enable the mandatory semantic arc optimizer by default.
rdar://29870610
2017-04-05 17:30:17 -07:00
Michael Gottesman
5e278fdf67 [semantic-arc-opts] Create a new pass called semantic arc opts.
I am going to run it very early and use it to ensure that extra copies due to my
refactoring of SILGenPattern do not cause COW copies to be introduced.

For now, it does a very simple optimization, namely, it eliminates a copy_value,
with only a destroy_value user on a guaranteed parameter.

It is now disabled behind a flag.
2017-04-05 16:16:57 -07:00
David Farler
65668c9d82 Cache Code Completion results from PCH files
- Add CompilerInvocation::getPCHHash
  This will be used when creating a unique filename for a persistent
  precompiled bridging header.

- Automatically generate and use a precompiled briding header
  When we're given both -import-objc-header and -pch-output-dir
  arguments, we will try to:
  - Validate what we think the PCH filename should be for the bridging
    header, based on the Swift PCH hash and the clang module hash.
    - If we're successful, we'll just use it.
    - If it's out of date or something else is wrong, we'll try to
      emit it.
  - This gives us a single filename which we can `stat` to check for the
    validity of our code completion cache, which is keyed off of module
    name, module filename, and module file age.

- Cache code completion results from imported modules
  If we just have a single .PCH file imported, we can use that file as
  part of the key used to cache declarations in a module.  Because
  multiple files can contribute to the __ObjC module, we've always given
  it the phony filename "<imports>", which never exists, so `stat`-ing it
  always fails and we never cache declarations in it.

  This is extremely problematic for projects with huge bridging headers.
  In the case where we have a single PCH import, this can bring warm code
  completion times down to about 500ms from over 2-3s, so it can provide a
  nice performance win for IDEs.

- Add a new test that performs two code-completion requests with a bridging header.
- Add some -pch-output-dir flags to existing SourceKit tests that import a bridging
  header.

rdar://problem/31198982
2017-04-04 20:44:33 -07:00
Slava Pestov
00d5b45733 Frontend: Add a new -sil-merge-partial-modules flag
Previously we would drop all serialized SIL from partial swiftmodule
files generated while compiling source in non-WMO mode; all that was
missing was linking it in.

This adds a frontend flag, and a test; driver change is coming up
next.

Progress on <rdar://problem/18913977>.
2017-04-03 21:28:40 -07:00
swift-ci
c39ffda2b8 Merge pull request #8477 from graydon/rdar-30961871-metrics-mark-2 2017-04-03 20:39:16 -07:00
Graydon Hoare
0245c83c4b [Stats] Add -stats-output-dir, wire UnifiedStatsReporter into place. 2017-04-03 18:08:59 -07:00
Doug Gregor
ebdfb40ebb [SE-0160] Allow one to enable/disable Swift 3 @objc inference rules.
Introduce flags `-enable-swift3-objc-inference` and
`-disable-swift3-objc-inference` to enable/disable the Swift 3 `@objc`
inference rules. Under `-swift-version 3`, default to the former;
under `-swift-version 4`, default to the latter. For testing purposes,
one can provide either flag in eiher language mode.
2017-03-31 21:22:16 -07:00
Doug Gregor
2c1981fe9d [SE-0160] Add an opt-in warning about deprecated @objc inference.
Introduce an opt-in warning (enabled by the frontend option
-warn-swift3-objc-inference) for each declaration for which @objc is
inferred based on Swift 3 rules that no longer apply after SE-0160.
2017-03-31 21:22:15 -07:00
Huon Wilson
fba2ab49dc Merge pull request #8301 from huonw/symbol-list
Initial TBD push: list of (some) public symbols
2017-03-29 12:48:22 -07:00
Huon Wilson
4eff6f1374 [FrontendTool] -emit-tbd and -validate-tbd-against-ir flags.
These, respectively, write a list of symbols to a file, and compare what
that list would be against the "true" list (the symbol names in the IR).
2017-03-28 16:31:09 -07:00
Devin Coughlin
b4b59b424d [Driver] Add command-line flags for enforcement of law of exclusivity
Add an -enforce-exclusivity=... flag to control enforcement of the law of
exclusivity. The flag takes one of four options:

"checked": Perform both static (compile-time) and dynamic (run-time) checks.
"unchecked": Perform only static enforcement. This is analogous to -Ounchecked.
"dynamic-only": Perform only dynamic checks. This is for staging purposes.
"none": Perform no checks at all. This is also for staging purposes.

The default, for now, is "none".

The intent is that in the fullness of time, "checked" and "unchecked" will
be the only legal options with "checked" the default. That is, static
enforcement will always be enabled and dynamic enforcement will be enabled
by default.
2017-03-28 10:54:37 -07:00
Devin Coughlin
70fbfea397 TSan: Enable treating inout accesses as Thread Sanitizer writes by default
Flip the polarity of the frontend flag controlling whether TSan treats inout
accesses as conceptual writes. It is now on by default. This lets TSan detect
racing mutating methods even when those methods are not themselves instrumented
(such as methods on Standard Library collections).

This behavior can be disabled by passing:

  -Xfrontend -disable-tsan-inout-instrumentation

when compiling under TSan.

rdar://problem/31069963
2017-03-22 16:44:47 -07:00