Commit Graph

827 Commits

Author SHA1 Message Date
Jordan Rose
960a4f164a Add LangOptions::EnableTargetOSChecking, so that LLDB can ignore OS mismatches.
In particular, this is problematic when libraries are loaded dynamically, and
may have newer deployment targets than the main executable.

Swift SVN r26786
2015-04-01 01:12:29 +00:00
Jordan Rose
8a3fcf621e Add -disable-testable-attr-requires-testable-module.
...which allows "@testable import" to work with modules not compiled for
testing. This isn't generally safe, but should be fine for clients like
SourceKit which just need to have the API available and might not be able
to properly rebuild the original target for testing.

We may revisit this in the future.

Swift SVN r26629
2015-03-27 16:36:41 +00:00
Devin Coughlin
bdc7475d6b Sema: Add temporary flag to stage in availability checking in implicit functions
This flag enables checking of availability (deprecation, explicit unavailability,
and potential unavailability) in synthesized functions. The flag will go away once this
checking is fully staged in.

Swift SVN r26624
2015-03-27 06:48:50 +00:00
Doug Gregor
af4aa6db65 Opt-in diagnostic for extensions of generic types without generic parameters.
This warning is temporarily going being a flag so that, once it is safe to place generic parameters on extensions of generic types, we can opt-in to update our code when it is convenient.

Swift SVN r26416
2015-03-22 12:35:27 +00:00
David Farler
544ef4002d Merge tvOS and watchOS Support
- Add frontend and standard library build support for tvOS.
- Add frontend support for watchOS.

watchOS standard library builds are still disabled during SDK bring-up.

To build for TVOS, specify --tvos to build-script.
To build for watchOS, specify --watchos to build-script (not yet supported).

This patch does not include turning on full tests for TVOS or watchOS, and
will be included in a follow-up patch.

Swift SVN r26278
2015-03-18 21:35:07 +00:00
Jordan Rose
c9eeed3e2d Remove staging option -enable-private-discriminators.
Private discriminators for everybody!

Swift SVN r25997
2015-03-11 23:07:44 +00:00
Argyrios Kyrtzidis
3e1390fe70 [LangOptions] Enable dollar identifiers under a separate language option.
I intend to use such identifiers for placeholder replacements.

Swift SVN r25896
2015-03-09 23:02:55 +00:00
Joe Groff
b5b65b83e9 Remove the -enable-union-import staging flag.
Swift SVN r25809
2015-03-06 23:08:11 +00:00
Dave Abrahams
1bc5f0eb29 ReST hacks: "handle" code blocks
This is at the expense of blockquotes, which we don't actually need at
the moment.  All blockquotes get interpreted as preformatted code.

Swift SVN r25459
2015-02-21 04:02:54 +00:00
Joe Groff
94be8424ff Sema: Type checking for C function pointers.
Since a function pointer doesn't carry any context, we can only form a C function pointer from a static reference to a global function or a context-free local function or closure. (Or maybe a static function applied to its metatype, but that's not handled here yet.) As a placeholder for a to-be-bikeshedded surface syntax, let the existing @cc(cdecl) attribute appear in source text when the -enable-c-function-pointers frontend flag is passed.

Swift SVN r25308
2015-02-16 00:41:53 +00:00
Dmitri Hrybenko
f6faf8ad81 sil-opt: implement partial AST verification
... and use it to parallelize the parse_stdlib.sil test, which was
taking too long.

Swift SVN r25295
2015-02-14 11:48:11 +00:00
Jordan Rose
a3a6c2695b Put the current target into LangOptions.
This has been long in coming. We always had it in IRGenOpts (in string form).
We had the version number in LangOpts for availability purposes. We had to
pass IRGenOpts to the ClangImporter to actually create the right target.
Some of our semantic checks tested the current OS by looking at the "os"
target configuration! And we're about to need to serialize the target for
debugging purposes.

Swift SVN r24468
2015-01-16 02:48:54 +00:00
Denis Vnukov
2528d52436 Add LangOptions::getBuildConfigOptions().
Swift SVN r24447
2015-01-15 16:33:42 +00:00
Joe Groff
e20a315d42 Enable union import by default.
So we can start shaking out the latent issues here.

Swift SVN r23537
2014-11-21 22:01:53 +00:00
Graham Batty
63a429f16e Changes to code generation to support non-objc targets
Swift SVN r23118
2014-11-05 18:05:55 +00:00
Doug Gregor
91ddaf59eb Archetype builder: start tracking the locations and reasons for specific requirements.
Whenever we add a requirement, we now know

  (1) Why we added the requirement, e.g., whether it was explicitly written, inferred from a signature, or introduced by an outer scope.
  (2) Where in the source code that requirement originated.

Also add a debugging flag for dumping the archetype builder information, so we can write tests against it.

This is effectively NFC, but it's infrastructure to help a number of requirements-related tasks.

Swift SVN r22638
2014-10-09 21:52:28 +00:00
Graham Batty
7676c8240d Add compile time config flag for detecting objc-interop.
Swift SVN r22605
2014-10-08 17:09:34 +00:00
Devin Coughlin
b727b6d932 Treat potentially unavailable global variable references as optional.
This patch adds the ability (-enable-experimental-unavailable-as-optional) to
treat potentially unavailable declarations as if they had optional types. For
the moment, this is only implemented for global variables.

The high-level approach is to (1) record the potential unavailability of a
declaration reference in the overload choice during constraint generation; (2)
treat the declaration as if it had an optional type during overload resolution
(this is similar to how optional protocol members are treated); and (3) add an
implicit conversion (UnavailableToOptionalExpr) during constraint application
to represent the run-time availability check and optional injection.

This patch does not implement SILGen for UnavailableToOptionalExpr.


Swift SVN r22245
2014-09-24 00:07:46 +00:00
Argyrios Kyrtzidis
374bf23f2b [TypeChecker] Introduce frontend option '-debug-forbid-typecheck-prefix' to protect against unnecessary typechecking,
for testing purposes.

When enabled, if the typechecker tries to typecheck a decl or unresolved identifier with the provided
prefix, then an llvm fatal_error will get triggered.

This approach has the advantage that it is very easy to write tests for unnecessary typechecking for a wide range of functionality,
for the compiler or SourceKit, for code-completion, indexing, etc.

Swift SVN r22003
2014-09-17 04:17:49 +00:00
Devin Coughlin
d33876ec5c Add option to enable experimental API availability checking
Swift SVN r21884
2014-09-11 18:46:56 +00:00
Jordan Rose
af5af53f94 Turn on private-discriminator mangling by default.
...thus supporting "private var x: Int" in two different source files in the
same module.

This marks the completion of the bulk of the work for rdar://problem/17632175.
Remaining work is to make sure debugging does the right thing when processing
expressions in a particular source context.

Swift SVN r21851
2014-09-10 21:09:33 +00:00
Joe Groff
19b470b454 Remove '-emit-NSApplicationMain' staging option.
Swift SVN r21698
2014-09-04 05:52:31 +00:00
Jordan Rose
adc25c8b9f Staging: Guard private discriminators under -enable-primary-discriminators.
...rather than let this series of out-of-tree commits get any bigger.

Swift SVN r21601
2014-08-30 00:17:23 +00:00
Joe Groff
8f52302f8e SILGen: Implement artificial main for NSApplicationMain.
We're not sure how to trigger this from source code yet, so trigger it with a hidden -emit-NSApplicationMain frontend flag for now.

Swift SVN r21563
2014-08-29 04:45:47 +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
7c69056659 Remove the always-on ImportCFTypes language option.
Swift SVN r21355
2014-08-21 15:24:32 +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
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
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
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
Joe Groff
7ff5de5f34 Enable lvalue '?' chaining.
Swift SVN r20649
2014-07-28 22:24:18 +00:00
Joe Groff
e527571264 Sema: Propagate lvalue-ness through optional chains.
When -enable-optional-lvalues is active, type-check '?' operations like '!' operations, using an OptionalObject constraint to match the optional subexpression type to the non-optional result type of equivalent lvalue-ness.

Swift SVN r20610
2014-07-28 01:56:00 +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
Joe Groff
3ac89dc4eb Enable 'dynamic'.
And spot-update tests that appear to rely on ObjC dispatch (review please!)

Swift SVN r20285
2014-07-22 00:23:37 +00:00
Joe Groff
4ce7d0f3ad Enable optional lvalues.
This causes a regression in error reporting where there are potential fixes: <rdar://problem/17741575> Other than that, everything works.

Swift SVN r20230
2014-07-20 18:16:42 +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
Doug Gregor
bd9ead4371 Remove -[no-]strict-keyword-arguments.
Swift SVN r19850
2014-07-11 16:58:35 +00:00
Joe Groff
06c6379577 Add -enable-dynamic staging option.
Swift SVN r19816
2014-07-10 18:22:57 +00:00
Chris Lattner
02999cac51 Reinstate the @ on the @objc attribute. This is largely a revert of r19555 with a few tweaks.
Swift SVN r19706
2014-07-08 21:50:34 +00:00
Jordan Rose
3db1a54701 [Accessibility] Turn on access control for everyone.
Swift SVN r19663
2014-07-08 00:59:08 +00:00
Chris Lattner
7a56499d61 Start making @objc not start with an @ sign:
- Change the parser to accept "objc" without an @ sign as a contextual
   keyword, including the dance to handle the general parenthesized case.
 - Update all comments to refer to "objc" instead of "@objc".
 - Update all diagnostics accordingly.
 - Update all tests that fail due to the diagnostics change.
 - Switch the stdlib to use the new syntax.

This does not switch all tests to use the new syntax, nor does it warn about
the old syntax yet.  That will be forthcoming.  Also, this needs a bit of 
refactoring, which will be coming up.



Swift SVN r19555
2014-07-04 05:57:57 +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
Joe Groff
10fae3e228 Remove -enable-string-pointer-conversion staging flag.
Swift SVN r19524
2014-07-03 18:43:20 +00:00
Joe Groff
c34b4f6a9e Enable string-to-pointer conversions and remove CString.
There is some follow-up work remaining:

- test/stdlib/UnicodeTrie test kills the type checker without manual type annotations. <rdar://problem/17539704>
- test/Sema/availability test raises a type error on 'a: String == nil', which we want, but probably not as a side effect of string-to-pointer conversions. I'll fix this next.

Swift SVN r19477
2014-07-02 19:15:10 +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
Joe Groff
cb48fbd24b Enable pointer conversions.
Swift SVN r19274
2014-06-26 23:26:31 +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