Commit Graph

289 Commits

Author SHA1 Message Date
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
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
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
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
Doug Gregor
77ca640d42 Add -objc-bridge-array option to import NSArray* as (AnyObject[])!
This should be the last of the compiler-side functionality for
<rdar://problem/16535097>; we lack any real testing of this.


Swift SVN r17871
2014-05-11 06:29:13 +00:00
Jordan Rose
db872f666e [Frontend] Make CompilerInvocation::parseArgs additive.
No options should be changed because of the absence of a flag. This is
necessary for clients like LLDB which may have an initial set of options
that differs from the usual set.

Part of <rdar://problem/16776705>

Swift SVN r17819
2014-05-10 01:17:36 +00:00
Doug Gregor
59d545d6e8 Add frontend option -objc-bridge-dictionary.
Swift SVN r17804
2014-05-09 21:36:58 +00:00
Doug Gregor
d1e8be50be Turn -implicit-objc-with on by default <rdar://problem/16795899>.
Swift SVN r17796
2014-05-09 20:17:42 +00:00
Doug Gregor
6deba37f0a Enable strict keyword argument checking by default <rdar://problem/14462349>.
Swift SVN r17743
2014-05-09 00:20:47 +00:00
Joe Pamer
006158ff56 Always emit detailed type check diagnostics, update unit tests to reflect this.
Swift SVN r17334
2014-05-03 23:03:47 +00:00
Doug Gregor
4996efbfba Implement support for making "with" implicit on the first argument of an initializer.
When importing an Objective-C init method or factory method into an
initializer, if the first camelCase word of the first argument name
starts with "with", drop the "with". This means that

  -initWithRed:green:blue:alpha:

will get imported into Swift as

  init(red:green:blue:alpha:)

as will

  +colorWithRed:green:blue:alpha:

This is <rdar://problem/16795899>, hidden behind the
-implicit-objc-with flag.

Swift SVN r17271
2014-05-02 21:13:04 +00:00
John McCall
0bc8309ff6 Add a -import-cf-types frontend option to enable
the CF type-import logic.

Swift SVN r17205
2014-05-01 23:29:23 +00:00
Doug Gregor
667d90c1f4 Start diagnosing scalar-to-tuple conversions that are missing a keyword argument.
Another baby step toward <rdar://problem/14462349>, made even more
tepid by the fact that I've quarantined this behind a new flag,
-strict-keyword-arguments. Enforcing this breaks a lot of code, so I'd
like to bring up the new model on the side (with good diagnostics that
include Fix-Its) before trolling through the entire standard library
and testsuite to fix violations of these new rules.


Swift SVN r17143
2014-05-01 06:15:30 +00:00
Joe Pamer
47628dbfb6 A couple more simple tweaks to improve type-check error reporting.
Swift SVN r17099
2014-04-30 17:54:56 +00:00
Joe Pamer
4cae5e82e8 Add a "detailed-diagnostics" flag to control emission of more detailed diagnostics for expression type-check failures.
Swift SVN r16988
2014-04-28 19:13:07 +00:00
Joe Groff
b256ccf467 Switch to native blocks codegen.
Swift SVN r16484
2014-04-18 01:07:12 +00:00
Joe Groff
920aa60570 Add a frontend option -enable-native-blocks to stage native block generation.
Swift SVN r16372
2014-04-15 17:51:08 +00:00
Doug Gregor
2d28d70bf8 Remove the language/driver/frontend options to enable/disable mangled names for the ObjC runtime.
Burn the bridges!


Swift SVN r16277
2014-04-13 05:36:08 +00:00
Doug Gregor
8d4964bc98 Turn on namespacing of Objective-C class names.
The actual logic to do this is simple; the vast majority of this
commit is just a pile of changes to test cases to reflect the fact
that Objective-C metadata now includes the module name for each class
and the mangling of Swift-defined @objc classes no longer goes into
the "So" namespace for Objective-C classes. Finishes
<rdar://problem/15506580>.


Swift SVN r16274
2014-04-13 04:48:53 +00:00
Joe Groff
42a942925b Enable block bridging.
Swift SVN r16248
2014-04-12 05:13:45 +00:00
Ted Kremenek
2d4342b87a Give an error if “@obj” is used without importing ObjectiveC.
The standard library is exemptmpt (-parse-stdlib) from this checking.

Implements <rdar://problem/16559137>.

Swift SVN r16155
2014-04-10 09:08:09 +00:00
Joe Groff
4e789a09f7 Add an -enable-block-bridging frontend option we can hide disruptive changes to block bridging behind.
Swift SVN r16043
2014-04-08 02:43:19 +00:00
Argyrios Kyrtzidis
b941c8640f [Basic] Introduce LangOptions::getTargetConfigOptions().
Swift SVN r15841
2014-04-02 22:55:05 +00:00
Doug Gregor
6496d69cb8 Simplify down to a single command-line option for preposition splitting.
Swift SVN r15835
2014-04-02 21:44:19 +00:00
John McCall
c163b30f1e Enable importing ObjC pointers as UncheckedOptional.
There's no point in maintaining a driver option for this
because of the extent of the library changes required to
make it work.

Swift SVN r15784
2014-04-02 09:37:16 +00:00
Doug Gregor
9400e890d3 Emit @objc classes using namespaced names under a new flag -enable-objc-mangling.
Centralize the logic for figuring out what name to use for a class or
protocol in the Objective-C runtime. When the flag is enabled (it's
still disabled by default), use mangled names for all Swift-defined
classes, including those that are @objc. Note that the naming is
determined in the AST, because we're also going to use this logic when
printing an Objective-C header for Clang's consumption. The mangled
names will always start with _Tt, so they're easy to recognize and
demangle in various tools or, eventually, in the Objective-C runtime.

The new test (test/IRGen/objc_mangling.sil) is the only test of this
behavior at the moment. The other test changes are due to the
centralized logic tweaking the names of internal constants (_DATA_*,
_CATEGORY_*, etc.).

This is the majority of <rdar://problem/15506580>.



Swift SVN r15588
2014-03-28 23:00:08 +00:00
Ted Kremenek
8162660be6 Wire up basic driver support for App Extension restrictions.
The frontend/driver flag is "-application-extension'.  This
activates a language option which will be used for more restrictive
availability checking.

Operationally, this also passes...
  - "-fapplication-extension" to the clang importer
  - "-application_extension" to ld

Swift SVN r15543
2014-03-27 01:05:43 +00:00
Argyrios Kyrtzidis
f1d14c0911 [Basic/LangOptions] Remove std::unordered_map/unordered_set from LangOptions and use SmallVector instead.
The config options are so few that a map is not worth it currently.

Swift SVN r15476
2014-03-26 00:26:17 +00:00
Argyrios Kyrtzidis
c5f8821410 [Basic/LangOptions] Use unordered_map/unordered_set for the build configuration options.
Swift SVN r15445
2014-03-25 03:55:30 +00:00
Doug Gregor
5d0abd9849 Another preposition splitting option: directional prepositions.
Swift SVN r15297
2014-03-20 21:24:57 +00:00
Doug Gregor
b71a67616e Add option to split after the last preposition.
Swift SVN r15264
2014-03-20 04:01:40 +00:00
Doug Gregor
e5fff12bf0 Add option to split Objective-C selectors based on the last preposition.
The frontend option -split-objc-selectors splits the first part of an
Objective-C selector into both a function name and the first parameter
name at the last preposition. For example, this Objective-C method:

  - (NSString *)stringByPaddingToLength:(NSUInteger)newLength withString:(NSString *)padString startingAtIndex:(NSUInteger)padIndex

is imported as

  func stringByPadding toLength(newLength: Int) withString(padString: String) startingAtIndex(padIndex: Int) -> String




Swift SVN r15156
2014-03-17 20:34:48 +00:00
Jordan Rose
cadd6edb9d Move EnableObjCOptional to LangOptions (from ClangImporterOptions).
This is a staging option, and I'm about to use it for type-checker changes.

No functionality change.

Swift SVN r14415
2014-02-26 22:15:53 +00:00
Joe Pamer
988a5877f2 Some updates:
- Respond to Doug's code review feedback
   - Stop hacking around with scopes and use "emplace" to work around RAII in the inactive config case
   - Limit use of StringRef on the front-end, in favor of std::string
   - Use ArrayRef rather than SmallVector within IfConfigDecl
   - Reorder new property declarations on BraceStmt to prevent unnecessary alignment issues
- Update ParseBraceItems to better capture top-level declarations, rather than using token lookahead

Swift SVN r14306
2014-02-24 18:16:49 +00:00
Joe Pamer
f83f94d9d8 Support build and target configurations
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.

Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.

Swift SVN r14305
2014-02-24 18:16:48 +00:00
Dmitri Hrybenko
ecd798b9fd Comment parsing: attaching comments to declarations
We can attach comments to declarations.  Right now we only support comments
that precede the declarations (trailing comments will be supported later).

The implementation approach is different from one we have in Clang.  In Swift
the Lexer attaches the comments to the next token, and parser checks if
comments are present on the first token of the declaration.  This is much
cleaner, and faster than Clang's approach (where we perform a binary search on
source locations and do ad-hoc fixups afterwards).

The comment <-> decl correspondence is modeled as "virtual" attributes that can
not be spelled in the source.  These attributes are not serialized at the
moment -- this will be implemented later.


Swift SVN r14031
2014-02-18 09:04:37 +00:00