Commit Graph

817 Commits

Author SHA1 Message Date
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
John McCall
b095a5efd8 Add -debugger-support to permit the inevitable series of exceptions
and special-cases that we want to permit when parsing for the debugger.

Swift SVN r13754
2014-02-10 18:47:00 +00:00
Chris Lattner
2792e55be4 remove the -enable-new-objc-properties staging option, and
simplify some code.


Swift SVN r12976
2014-01-26 23:24:35 +00:00
Chris Lattner
38698af3cc This is a WIP implementation of a major change to how ObjC properties are
represented: they should have an explicit getter and setter synthesized by
Sema, instead of by silgen and tenuously tied in by IRGen.

There is more work to be done on this (e.g. I need to figure out how to get
the bodies properly type checked), so it is hidden behind a new
-enable-new-objc-properties flag.



Swift SVN r12907
2014-01-24 07:04:42 +00:00
Joe Groff
5b7e9ee279 Hide NominalTypePatterns behind a compiler switch.
These aren't fully baked and probably won't be soon.

Swift SVN r12628
2014-01-21 00:49:28 +00:00
Chris Lattner
cc31c6edb5 remove the '-enable-let-arguments' staging option.
Swift SVN r12374
2014-01-16 01:29:14 +00:00
Chris Lattner
b0b5a8f774 Switch constructor arguments, curried arguments and selector arguments to be
'let' values (so they are immutable and don't get a box, etc).  Add a flag to
the swift compiler that turns the bulk of function arguments into lets, but 
don't set it yet.


Swift SVN r12274
2014-01-14 03:53:11 +00:00
Chris Lattner
cb2010f780 remove the -enable-mutable-methods langopt, it isn't doing anything anymore.
Swift SVN r11695
2013-12-28 16:06:41 +00:00
Joe Groff
e06ee37dca Enable SIL protocol witnesses.
We should be able to cut out another layer of IRGen grime now.

This does XFAIL one test, test/Prototypes/TextFormatting.swift, which fails because of a weird archetype ordering in a nested substitution list. This should get sorted out by switching to interface types, so I'm going to let it go until then.

Swift SVN r11618
2013-12-24 04:36:03 +00:00
Chris Lattner
01be26cd4b Add a new command line option that turns on by-value self arguments for structs
when a method is not declared @inout.


Swift SVN r11386
2013-12-17 17:25:42 +00:00
Joe Groff
6547c69b33 Turn on lazy global initializers.
Swift SVN r11136
2013-12-11 18:59:56 +00:00
Joe Groff
e9deb9e75f Add an -emit-sil-protocol-witness-tables flag.
So we can break stuff while it's turned on.

Swift SVN r10922
2013-12-06 15:58:00 +00:00
Doug Gregor
0428eeaebf Introduce --debug-constraints-attempt=N to debug a specific constraint system.
The constraint solver statistics now tell us which of the constraint
systems we are solving were the largest. This lets us look at what the
solver does with that constraint system without piling on the
debugging spew.


Swift SVN r10638
2013-11-21 18:53:00 +00:00
Joe Groff
a049ee9d38 SILGen: (Optionally) emit lazy initializers and accessor fns for globals.
For every global pattern binding, emit a lazy initializer token and function that initializes the global variables in that binding. For each of those vars, create an accessor that Builtin.once's the lazy initializer before producing the address. Hide this all behind a switch till the surrounding serialization and IRGen infrastructure catches up.

Swift SVN r10511
2013-11-16 00:50:19 +00:00
Joe Groff
a1f123350f Enable NS_OPTIONS import by default.
Some work needs to be done on static member lookup and bitwise operations, but what's implemented now isn't a regression from what we have (except for an unfortunate case in Foundation.swift where we need to fully qualify a constant in a single-element NS_OPTIONS).

Swift SVN r10471
2013-11-14 23:21:28 +00:00
Joe Groff
fdd858dd21 ClangImporter: Import NS_OPTIONS constants as static properties.
Apply the same prefix-chopping logic as for NS_ENUM to produce static property names to put inside the Swift type we create. For now, continue importing NS_OPTIONS as structs with a single integer field; in the short term it's easy to put a C-like interface over them this way.

Swift SVN r10434
2013-11-13 23:19:32 +00:00
Joe Groff
774db24a8a Enable importing of NS_ENUMs as Swift enums.
A problem with name lookup from Clang module contexts <rdar://problem/15410928> means I have to disable a ~= overload in the ObjectiveC overlay. Other than that, NS_ENUM import should be ready to go.

Swift SVN r10018
2013-11-07 03:49:37 +00:00
Joe Groff
16c5d69e17 ClangImporter: Recognize NS_ENUM declarations and import as Swift enums.
When we see an enum declaration in the Clang importer, look at its source location to see if it was produced as part of an NS_ENUM macro expansion. If so, take the 'Enum' route through the Clang importer and import it as a Swift enum. This will break things until we have end-to-end support for Clang-imported enums, so hide it behind an -import-ns-enum switch for now.

Swift SVN r9951
2013-11-05 01:38:00 +00:00
Joe Groff
1616276923 SILGen: Remove 'SILGenLValuePeepholes' flag.
r9931 fixes the crashes this exposes, so we can enable it by default now.

Swift SVN r9935
2013-11-04 22:54:54 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Joe Groff
cd74f49434 Revert "SILGen: Enable lvalue-to-lvalue copy_addr initialization peephole by default."
This reverts commit r9347. The copy_addr peephole still crashes the
Demo-2012-07/uniq.swift test on the buildbot.

Swift SVN r9358
2013-10-15 18:18:29 +00:00
Joe Groff
47dd733c3f SILGen: Enable lvalue-to-lvalue copy_addr initialization peephole by default.
The Interpreter crashes this introduced in the end-to-end pipeline seem to have subsided, now that DI is prepared for it.

Swift SVN r9349
2013-10-15 16:56:15 +00:00
Joe Groff
2ffd735255 SILGen: Peephole lvalue-to-lvalue initializations as copy_addrs.
If we're using emitExprInto to emit a LoadExpr, we can handle that by emitting a copy_addr from the underlying lvalue to the initialization instead of building and storing the rvalue, which plays better with the direction we're taking for value semantics optimizations.

This is currently guarded behind a flag -enable-silgen-lvalue-peepholes because it introduces a miscompile in the stdlib that crashes some tests; requires further investigation before making live.

Swift SVN r9027
2013-10-08 20:44:09 +00:00