Commit Graph

2033 Commits

Author SHA1 Message Date
Sean Callanan
2c50b0ca48 swift -frontend "" shouldn't enter the REPL by default.
This patch fixes a problem where a CompilerInvocation
with no arguments would set the LangaugeOpts etc. up for
the deprecated-integrated-repl, including setting the
module name etc.  Now this only happens if you explicitly
invoke swift -frontend -repl.

Updated testcases that care, and added a new testcase to
ensure that an error is properly generated.

<rdar://problem/17918172>


Swift SVN r21537
2014-08-28 18:38:13 +00:00
Jordan Rose
9b0d643029 Move 'Playground' into LangOptions and out of FrontendOptions and IRGenOptions.
Also, use 'Playground' to control the behavior of ignored expressions
(which are not an error because they are displayed in the playground log).

This is preparation for LLDB no longer passing 'DebuggerSupport' for a
playground <rdar://problem/18090611>. 'DebuggerSupport' now only applies
to REPL-like contexts and enables identifiers beginning with $, special
rules for parsing top-level code, ignored expressions (like playgrounds),
and the @LLDBDebuggerSupport attribute.

Besides ignored expressions, 'Playground' enables the playground transformation
and provides an entry point for debugger initialization.

Note that this is a bit insincere---many of the options controlled by both
'Playground' and 'DebuggerSupport' really only apply to the main source file
or main module. If/when we add back support for source file imports, we'll
need to revisit all of LangOptions and see which of them should /really/
apply to /everything/ in the ASTContext.

Swift SVN r21384
2014-08-21 22:36:24 +00:00
Doug Gregor
1a8f5e1eec Remove -enable-optional-lvalues and its language option; they're always on anyway.
Swift SVN r21356
2014-08-21 15:53:31 +00:00
Doug Gregor
7cae0cfc8e Remove -enable-dynamic and its language option; it's always on anyway.
Swift SVN r21354
2014-08-21 15:15:12 +00:00
Doug Gregor
5709a86f2f Start importing Objective-C initializers and factory methods using failable initializers.
In this mode, use nullability information on the result type of the
initializer or factory method to determine failability of the
initializer. This is behind the flag
-enable-objc-failable-initializers until we have the SILGen support in
place.



Swift SVN r21341
2014-08-21 04:50:20 +00:00
Argyrios Kyrtzidis
c454acefdf [Frontend] Rename EnableObjCAttrRequiresObjCModule -> EnableObjCAttrRequiresFoundation and enable it by default.
This is enabled by default because SILGen can crash when @objc is used without importing Foundation, but
it gets disabled when compiling the Swift stdlib.

Addresses rdar://17931250.
Related test case on the SourceKit side.

Swift SVN r21319
2014-08-20 21:19:56 +00:00
Ted Kremenek
acd30c9d4b Rename '-enable-objc-attr-requires-objc-module' to '-enable-objc-attr-requires-foundation-module' to accurately reflect its behavior.
Swift SVN r21304
2014-08-20 06:34:48 +00:00
Mark Lacey
e76a6c7333 Add -sil-print-pass-name option.
Prints the pass number and name along with the function being
processed. This can be handy when bisecting by pass number.

Swift SVN r21219
2014-08-14 22:38:30 +00:00
Joe Pamer
71cf758055 Mitigate exponential solver behavior (rdar://problem/17162690)
While we work out the remaining performance improvements in the type checker, we can improve the user experience for some "runaway solver" bugs by setting a limit on the amount of temporary memory allocated for type variables when solving over a single expression.

Exponential behavior usually manifests itself while recursively attempting bindings over opened type variables in an expression. Each one of these bindings may result in one or more fresh type variables being created. On average, memory consumption by type variables is fairly light, but in some exponential cases it can quickly grow to many hundreds of megabytes or even gigabytes. (This memory is managed by a distinct arena in the AST context, so it's easy to track.) This problem is the source of many of the "freezing" compiler and SourceKit bugs we've been seeing.

These changes set a limit on the amount of memory that can be allocated for type variables while solving for a single expression. If the memory threshold is exceeded, we can surface a type error and suggest that the user decompose the expression into distinct, less-complex sub-expressions.

I've set the current threshold to 15MB which, experimentally, avoids false positives but doesn't let things carry on so long that the user feels compelled to kill the process before they can see an error message. (As a point of comparison, the largest allocation of type variable data while solving for a single expression in the standard library is 592,472 bytes.) I've also added a new hidden front-end flag, "solver-memory-threshold", that will allow users to set their own limit, in bytes.

Swift SVN r20986
2014-08-03 23:10:42 +00:00
Doug Gregor
f52c6789db Track the minimum deployment target and use it for 'unavailable' computations.
Swift SVN r20955
2014-08-02 18:05:45 +00:00
Ben Langmuir
d197964680 Rename -integrated-repl to -deprecated-integrated-repl
Swift SVN r20781
2014-07-30 22:09:37 +00:00
Jordan Rose
0481b87ba5 Move target configuration setup into CompilerInvocation.
Without this, clients that don't use a CompilerInstance (like LLDB) won't
have target configuration options available.

Also, move minimum OS checking into the driver. This makes sure the check
happens early (and only once), and in general fits the philosophy of
allowing the frontend to use configurations that might be banned for users.

<rdar://problem/17688913>

Swift SVN r20701
2014-07-29 21:48:59 +00:00
Sean Callanan
f22ad4c631 Enabled IRGen testcases to enable UseJIT, which
is typically disabled when compiling normally,
and thereby emit and check for class initialization
without interfering with PlaygroundTransform
testcases that use classes.


Swift SVN r20659
2014-07-29 00:02:18 +00:00
Michael Gottesman
e9a7f91667 Revert "Add the frontend option -disable-sil-perf-optzns."
Revert "For debugging purposes allow passes to stop any more passes from running by calling PassManager::stopRunning()."

This reverts commit r20604.
This reverts commit r20606.

This was some debugging code that snuck in.

Swift SVN r20615
2014-07-28 06:21:30 +00:00
Michael Gottesman
112269fb33 Add the frontend option -disable-sil-perf-optzns.
Swift SVN r20604
2014-07-27 18:37:11 +00:00
Doug Gregor
ff92b5f007 Remove -[no]implicit-objc-with.
Toggling this option causes funny things to happen, and there's no
point in keeping it.

Swift SVN r20565
2014-07-25 22:13:46 +00:00
Jordan Rose
b6818046a8 Eliminate optimization levels 0-3 in favor of -Onone/-O/-Ofast.
We were already effectively doing this everywhere /except/ when building
the standard library (which used -O2), so just use the model we want going
forward.

Swift SVN r20455
2014-07-24 01:12:59 +00:00
Jordan Rose
836c9d6eb4 Rename -Ofast to -Ounchecked.
<rdar://problem/17202004>

Swift SVN r20454
2014-07-24 01:12:56 +00:00
Doug Gregor
076d310132 Remove -import-tighter-objc-types option; we're turning it on by default.
Swift SVN r20191
2014-07-18 23:25:38 +00:00
Joe Groff
9f5c1a5b20 Add an -enable-optional-lvalues flag to stage in optional lvalues.
Swift SVN r20138
2014-07-18 04:36:54 +00:00
Jordan Rose
fce31decdc Serialize bridging headers into the merged module file.
We do this so that the swiftmodule file contains all info necessary to
reconstruct the AST for debugging purposes. If the swiftmodule file is copied
into a dSYM bundle, it can (in theory) be used to debug a built app months
later. The header is processed with -frewrite-includes so that it includes
any non-modular content; the user will not have to recreate their project
structure and header maps to reload the AST.

There is some extra complexity here: a target with a bridging header
(such as a unit test target) may depend on another target with a bridging
header (such as an app target). This is a rare case, but one we'd like to
still keep working. However, if both bridging headers import some common.h,
we have a problem, because -frewrite-includes will lose the once-ness
of #import. Therefore, we /also/ store the path, size, and mtime of a
bridging header in the swiftmodule, and prefer to use a regular parse from
the original file if it can be located and hasn't been changed.

<rdar://problem/17688408>

Swift SVN r20128
2014-07-18 00:22:53 +00:00
Joe Groff
a31c2ab4f7 Make it easier to tweak the EnableDynamic and ImportUnion flags in testing.
Follow the convention of setting them with |= so we can turn them on by default directly from LangOptions.

Swift SVN r19991
2014-07-15 23:36:49 +00:00
Doug Gregor
bd9ead4371 Remove -[no-]strict-keyword-arguments.
Swift SVN r19850
2014-07-11 16:58:35 +00:00
Jordan Rose
0e8021b7f3 [ClangImporter] Add frontend option -dump-clang-diagnostics for debugging.
This option dumps Clang diagnostics to stderr as well as passing them along
to Swift's diagnostic machinery.

Swift SVN r19841
2014-07-11 00:36:55 +00:00
Connor Wakamo
0fe539f579 Renamed swift::createDriverOptTable() to swift::createSwiftOptTable().
Swift SVN r19827
2014-07-10 20:51:54 +00:00
Connor Wakamo
465eeb9d17 Moved everything in swift/Option/Options.h into the swift namespace (from swift::driver).
The options themselves are now in swift::options (from swift::driver::options).
The soon-to-be-renamed createDriverOptTable() is now directly in the swift namespace.

Swift SVN r19825
2014-07-10 20:51:51 +00:00
Connor Wakamo
2d6c9e9062 Moved Swift's option table from swiftDriver into a new swiftOption library.
This allows swiftFrontend to drop its dependency on swiftDriver, and could
someday allow us to move the integrated frontend's option parsing out of
swiftFrontend (which would allow other tools which use swiftFrontend to
exclude the option table entirely).

Swift SVN r19824
2014-07-10 20:51:50 +00:00
Connor Wakamo
cf14fefd3c Removed an unnecessary #include from CompilerInvocation.cpp.
At this point, the only dependency swiftFrontend has on swiftDriver is on
swift/Driver/Options.h for the options table.

Swift SVN r19823
2014-07-10 20:51:45 +00:00
Joe Groff
06c6379577 Add -enable-dynamic staging option.
Swift SVN r19816
2014-07-10 18:22:57 +00:00
Ben Langmuir
8b7cc4f619 Make -i compatible with shebangs and forward arguments correctly
The driver option -i now requires an input file as argument, and any
options after the input file will be treated as arguments to the
interpretted file.

This also renames the frontend option to -interpret, since it is parsed
as a flag, unlike -i. We could support -interpret in the driver if we
wanted, which would allow us to use --, but wouldn't work with shebang
scripts. For now, it's frontend-only.

Swift SVN r19718
2014-07-09 02:37:42 +00:00
Ben Langmuir
f6645eb39a Fix argv when using -i in the frontend
In the frontend, only arguments after '--' will be passed as arguments
to the new process.  Also, add the input filename as argv[0], to follow
the usual conventions.

Still to come is fixing swift -i from the driver.

Swift SVN r19690
2014-07-08 19:38:29 +00:00
Anna Zaks
37c3ec4ed1 Rename the -import-tighter-objc-types option and add it to the frontend.
Swift SVN r19535
2014-07-03 21:46:38 +00:00
Joe Groff
0a00691453 Add a staging option to enable import of unions and other partially-importable structs.
Exposing these types without John's Clang ABI work would cause awful miscompiles, so hide them behind a flag till that lands.

Swift SVN r19528
2014-07-03 21:15:28 +00:00
Ben Langmuir
2658e6293b Rename modules named 'Swift' in the frontend
This is already done in the driver, but code-completion and indexing
have the same issue, sometimes crashing SourceKit.

Swift SVN r19527
2014-07-03 21:10:08 +00:00
Joe Groff
10fae3e228 Remove -enable-string-pointer-conversion staging flag.
Swift SVN r19524
2014-07-03 18:43:20 +00:00
Dmitri Hrybenko
6f814ded6b Remove the '-disable-all-runtime-checks' option that predates current SIL-level
optimization/inlining scheme.

It was actually used while building a release version of stdlib, and
effectively disabled safety checks in debug builds.


Swift SVN r19461
2014-07-02 14:47:29 +00:00
Joe Groff
a796c76ae4 Sema: Allow string-to-pointer argument conversions.
Allow a String value to be implicitly converted to ConstUnsafePointer<{UInt8,Int8,Void}> by string-to-pointer conversion, when enabled by a staging flag.

Swift SVN r19366
2014-06-30 20:46:04 +00:00
Joe Groff
22f0e39ef2 Remove the -enable-pointer-conversions flag and dead code.
Swift SVN r19278
2014-06-26 23:56:59 +00:00
Jordan Rose
a7b563855e Add a mode in which access control is respected for module-scope lookups.
This applies to both qualified and unqualified lookups, and is controlled
by the -enable-access-control and -disable-access-control flags. I've
included both so that -disable-access-control can be put into specific tests
that will eventually need to bypass access control (e.g. stdlib unit tests).
The default is still -disable-access-control.

Swift SVN r19146
2014-06-24 21:32:21 +00:00
Joe Groff
08a48565fb Sema: Introduce intrinsic pointer argument conversions.
Add primitive type-checker rules for pointer arguments. An UnsafePointer argument accepts:

- an UnsafePointer value of matching element type, or of any type if the argument is UnsafePointer<Void>,
- an inout parameter of matching element type, or of any type if the argument is UnsafePointer<Void>, or
- an inout Array parameter of matching element type, or of any type if the argument is UnsafePointer<Void>.

A ConstUnsafePointer argument accepts:

- an UnsafePointer, ConstUnsafePointer, or AutoreleasingUnsafePointer value of matching element type, or of any type if the argument is ConstUnsafePointer<Void>,
- an inout parameter of matching element type, or of any type if the argument is ConstUnsafePointer<Void>, or
- an inout or non-inout Array parameter of matching element type, or of any type if the argument is ConstUnsafePointer<Void>.

An AutoreleasingUnsafePointer argument accepts:

- an AutoreleasingUnsafePointer value of matching element type, or
- an inout parameter of matching element type.

This disrupts some error messages in unrelated tests, which is tracked by <rdar://problem/17380520>.

Swift SVN r19008
2014-06-19 18:03:10 +00:00
Michael Gottesman
a0f7d9c3fd Add an option to run the inst-count pass after performing optimizations.
This will enable via the -print-stats function the ability to quickly
find out the final count of various forms of instructions. My intention
is to use this to count retains and releases.

Swift SVN r18946
2014-06-17 02:30:34 +00:00
Doug Gregor
dd8c668aa8 Import NSDictionary as Dictionary<NSObject, AnyObject>
Fixes <rdar://problem/16870626>.


Swift SVN r18907
2014-06-15 10:44:23 +00:00
Joe Groff
ca42a7b377 Turn on metatype-to-object conversions.
Swift SVN r18850
2014-06-13 01:01:38 +00:00
Joe Groff
cf9e0d2624 Sema: Introduce metatype-to-object conversions.
Allow class metatypes (including class-constrained existential metatypes) to be treated as subtypes of AnyObject, and single-@objc protocol metatypes to be treated as subtypes of the Protocol class from objc. No codegen support yet, so this is hidden behind a frontend flag for now.

Swift SVN r18810
2014-06-11 23:06:23 +00:00
Michael Gottesman
3ba4ca1b31 Add support for printing SIL with SIL entities sorted by name behind the flag -sil-sort-by-output-names.
This significantly reduces the diff size when diffing the standard
library.

Swift SVN r18700
2014-06-04 05:22:52 +00:00
Jordan Rose
2d004856cf Don't try to autolink the underlying module in a mixed-source framework.
Doing so causes the linker to list the framework itself as one of its
dependencies, which confuses tools that depend on the linker's dependency
output.

<rdar://problem/17006845>

Swift SVN r18578
2014-05-22 23:50:38 +00:00
Jordan Rose
7cd4341cd6 Force color diagnostics when using the driver from the command line.
Previously, the frontend detected that its output was being piped into the
driver and buffered, and decided that that wasn't a color-friendly output
stream. Now, the driver passes -color-diagnostics to the frontend to force
color output if the driver itself is in a color-output context.

<rdar://problem/16697713>

Swift SVN r18506
2014-05-21 19:45:47 +00:00
Joe Groff
6c280e27e2 IRGen: Emit runtime initialization into top_level_code for playgrounds.
To help with the playground's transition to top level code, hand the -playground frontend flag down to IRGenOptions, so that IRGen knows to emit runtime initializer code for classes and categories into top_level_code rather than an attributed function.

Swift SVN r18479
2014-05-21 02:11:09 +00:00
Doug Gregor
ad18ed81fb Start importing NSArray* as (AnyObject[])! by default <rdar://problem/16535097>.
Swift SVN r18157
2014-05-16 01:10:13 +00:00
Ted Kremenek
7da31bdfdd Disable parsing of single quoted character literals, enabling under a flag.
I didn't want to rip this logic out wholesale.  There is a possibility
the character lexing can be reborn/revisited later, and
disabling it in the parser was easy.

Swift SVN r18102
2014-05-15 07:05:59 +00:00