Commit Graph

2184 Commits

Author SHA1 Message Date
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
Jordan Rose
67f319b747 [Driver] Hook up -emit-dependencies option, but don't do anything with it yet.
Part of <rdar://problem/14899639>

Swift SVN r18044
2014-05-14 00:34:07 +00:00
Doug Gregor
73528dc0e0 Enable importing factory methods as initializers by default.
Finishes <rdar://problem/16509024>.

Swift SVN r17972
2014-05-12 23:01:20 +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
Jordan Rose
216d8b9521 fixup
Swift SVN r17794
2014-05-09 19:11:10 +00:00
Doug Gregor
9da6df267a Add -no-implicit-objc-with for when we switch the default <rdar://problem/16795899>.
Swift SVN r17783
2014-05-09 16:36:54 +00:00
Jordan Rose
41700b03da Add a new (hidden) option -autolink-force-load.
This option puts a special symbol into the generated object files that other
object files can reference to force the library to be loaded.

The next commit will modify the way we serialize autolinking information so
that importers of this module will always emit a reference to this symbol.
This means the library will be linked into the final binary even if no other
symbols are used (which happens for some of our overlays that just add
category methods to Objective-C classes).

Part of <rdar://problem/16829587>

Swift SVN r17750
2014-05-09 01:07:07 +00:00
Doug Gregor
a23bafccb6 Introduce -no-strict-keyword-options in the frontend "just in case".
Swift SVN r17742
2014-05-09 00:20:46 +00:00
Arnold Schwaighofer
ce0e6698c5 Add _isFast predicate that is true at Ofast
We want to support three configurations:

* Debug (-Onone, -O0): user assertions, library precondition checks, runtime
  checks enabled and verbose.

* Release (-O): library precondition checks, runtime checks enabled but succinct
  (trap).

* Fast (-Ofast): all checks off.

The _isFast predicate will allow to write standard library functions to support
this plan. This commit changes fatal() to differentiate between the three modes.

Support for rdar://16477198

Swift SVN r17697
2014-05-08 15:30:29 +00:00
Argyrios Kyrtzidis
136284430c [Frontend] Separate parse-only functionality into its own function, CompilerInstance::performParseOnly().
Parse-only is a hot path; keep the semantics for it separate from normal parsing, otherwise it is very
easy to introduce something expensive without checking for Invocation.getParseOnly().

Also cleans up a bit CompilerInstance::performParse() as well.

Swift SVN r17596
2014-05-07 02:13:48 +00:00
John McCall
87bf471e99 Turn on -import-cf-types and fix the standard library.
If this works out, I'll rip out the frontend option.
If this doesn't work out, please just revert this patch.

Swift SVN r17547
2014-05-06 09:34:26 +00:00
Joe Groff
4a09c9f9dd Add a -print-clang-stats frontend flag.
Prints stats from the Clang importer's ASTReader.

Swift SVN r17512
2014-05-06 01:08:09 +00:00
Arnold Schwaighofer
3ba7225aa3 Fix the driver's handling of the AssertConfig option
The driver was not passing the 'AssertConfig' option to the frontend.

rdar://16805810

Swift SVN r17472
2014-05-05 18:21:57 +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
Jordan Rose
cf77de720a Add -import-objc-header option, and wire up the basic infrastructure.
THIS IS NOT READY FOR USE YET.

The new plan for mixed-source non-framework targets is that the Swift
compiler will import an Objective-C header directly, and treat the decls
and imports in that header as explicitly visible to the entire target.
This means users don't have to modularize their headers before bringing
them into Swift.

This commit adds the option and introduces the "imported headers" module
as an implicit import for the source files being compiled. It also directs
the Clang importer to process the given header (using #import, so that it
won't somehow get included twice) and watches for any module imports that
occur as a result of reading that header.

Still to come: import of decls within the header (not within any module),
and proper serialization of cross-references to the header and its imports.

Part of <rdar://problem/16702101>

Swift SVN r17218
2014-05-02 00:55:31 +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
Nadav Rotem
2099cd0988 Add -O as an alias to -O3. rdar://16782554
Swift SVN r17183
2014-05-01 21:18:19 +00:00
Doug Gregor
3d3ff6811a Add a pile of missing #includes exposed by pruning includes in top-of-tree LLVM.
Swift SVN r17157
2014-05-01 14:26:34 +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
Argyrios Kyrtzidis
9418fb9948 [DiagnosticEngine] Mark module import diagnostic errors as 'fatal' errors, and supress subsequent diagnostics
to avoid a cascade of errors that drown out the original failure.

Swift SVN r17141
2014-05-01 05:24:48 +00:00
Jordan Rose
9c6ddc085f [driver] Add -lldb-repl and -integrated-repl modes.
Since LLDB is taking over as the REPL for Swift, we eventually want "swift"
and "swift -repl" to invoke "lldb --repl" rather than the frontend. However,
we only want to do this if the LLDB that's present is related to the Swift
that's present -- we don't want to invoke some random LLDB on the system
or in some other Xcode installation. Therefore, Swift searches for LLDB--
first next to the driver, then in the usr/bin/ outside of a toolchain--
before choosing to use it.

If the user just passes -repl and an LLDB is not found relative to the
driver, the existing "integrated" REPL will be launched instead.*

If the user passes -lldb-repl and an LLDB is not found relative to the
driver, one from the user's PATH will be chosen (like the linker).

The user can also pass -integrated-repl to get the existing behavior.
"swift -frontend -repl" always uses the integrated REPL.

* Since LLDB's not quite ready to be the REPL yet, "swift -repl" still
invokes the integrated REPL. "swift -repl -experimental-prefer-lldb" tests
the new behavior; this option will become the default (and the flag removed)
in <rdar://problem/16776719>.

<rdar://problem/16776705>

Swift SVN r17134
2014-05-01 02:15:53 +00:00
Mark Lacey
35c3799d2a Handle -target-abi as a frontend option and default it to darwinpcs for arm64/Darwin.
Swift SVN r17077
2014-04-30 06:12:54 +00:00
Jordan Rose
8699a3b83f Add -import-underlying-module option.
This option implicitly imports the Clang module with the same name as the
module being built into every source file in the module being built.
This will be used for mixed-source framework targets to give Swift code the
same implicit visibility for Objective-C decls in the same module that it
already has for other Swift decls.

<rdar://problem/16701230>

Swift SVN r17053
2014-04-29 23:13:45 +00:00
Jordan Rose
84f4d3b9fa Sink some triple predicates into swiftBasic.
getPlatformNameForTriple isn't currently being used anywhere elsee, but
this seems more consistent.

No functionality change.

Swift SVN r17002
2014-04-28 23:39:15 +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
Nadav Rotem
ebf73fe8b9 Rename -OFast to -Ofast
Swift SVN r16502
2014-04-18 07:01:17 +00:00
Joe Groff
e65aab4184 Remove unused variable from CompilerInvocation.cpp.
Swift SVN r16486
2014-04-18 01:07:13 +00:00
Joe Groff
b256ccf467 Switch to native blocks codegen.
Swift SVN r16484
2014-04-18 01:07:12 +00:00
Doug Gregor
f56c68386e Start importing factory methods as initializers.
When an Objective-C class method follows the naming convention of a
factory method, i.e., its starting words match the ending words of the
class name, import it as a convenience initializer when it also:
  - Returns instancetype (i.e., dynamic Self in Swift parlance)
  - Has no NSError** parameters, which indicate the potential for failures

This is under a new flag (-enable-objc-factory-method-constructors)
because it is not generally functional. However, this is a step toward
<rdar://problem/16509024>.

Swift SVN r16479
2014-04-17 23:34:00 +00:00
Doug Gregor
5698fd3b8a Don't look in the standard import locations when building the core standard library.
This is a better way to fix the Darwin overlay <-> swift_stdlib_core
inferred circular dependency <rdar://problem/16603168>.

Swift SVN r16476
2014-04-17 22:07:48 +00:00
Doug Gregor
96bc99e3c4 Revert "Add a flag -ignore-overlays to ignore overlays, and use it when building the standard library."
This reverts commit r16383.

Swift SVN r16475
2014-04-17 22:07:47 +00:00
Arnold Schwaighofer
97892b1cfa Frontend: Add OFast flag
The optimization level -OFast disables runtime checks (overflow, type checks)
and assertions.

rdar://16458612

Swift SVN r16474
2014-04-17 22:05:44 +00:00
Arnold Schwaighofer
45ffb41adf Remove AssertDebug hack and fixup make files
When we build the standard libary with -parse-stdlib the frontend sets the
assert configuration to 'DisableReplacement'. Constant replacement does not take
place and the call to the builtin function 'assert_configuration' call stays in
the serialize SIL of the swiftmodule.

IRGen replaces the function call to the assert_configuration builtin function by
the value for Debug (0). The resuling standard library dylib hence contains the
debug version of the standard library assert function.

Frontend optimization flags can now determine whether asserts should be executed
or not.

This commit removes the SWIFT_ASSERTS cmake flag.

rdar://16458612

Swift SVN r16473
2014-04-17 22:05:43 +00:00
Arnold Schwaighofer
989d554a45 Add support for an assert_configuration builtin function
This patch adds support for a builtin function assert_configuration that is
replaced by constant progpagation by an appropriate value dependent on a compile
time setting. This replacement can also be disabled when serializing sil for a
library.

Using this mechanism we implement assertions that can  be disabled (or whose
behavior changes) depending on compile time build settings (Debug, Release,
DisableReplacement).

In the standard library we can now write one assert function that uses this
builtin function to provide different compile time selectable runtime behavior.

Example

Assert.swift:

@transparent
func assert<T : LogicValue>(
  condition: @auto_closure () -> T, message: StaticString = StaticString(),

  // Do not supply these parameters explicitly; they will be filled in
  // by the compiler and aren't even present when asserts are disabled
  file: StaticString = __FILE__, line: UWord = __LINE__
) {
  // Only in debug mode.
  if _isDebug() {
    assert(condition().getLogicValue(), message, file, line)
  }
}

AssertCommon.swift:

@transparent
func _isDebug() -> Bool {
  return Int32(Builtin.assert_configuration()) == 0;
}

rdar://16458612

Swift SVN r16472
2014-04-17 22:05:42 +00:00
Arnold Schwaighofer
527a3149a8 Remove duplicate code accidently introduced by r16447.
Swift SVN r16471
2014-04-17 22:05:41 +00:00
John McCall
3cf3f42e98 When targeting arm64-apple-ios, the target CPU is cyclone,
which provides the Neon feature.  Do all the necessary
plumbing to get this from the driver to the backend.

Also, support -arch arm64, and diagnose bad -arch values
instead of silently ignoring them.  It's not clear to me
that we really want to support -arch as an alternative
to -target, but unless we rip it out or establish some
sort of real policy about it, it really ought to do
something approximating the right thing.

It would be nice if we could abstract enough of clang's
driver that we could re-use some of its basic logic about
tool chains and targets instaed of iteratively
rediscovering everything it does that's actually
critically important.

Swift SVN r16447
2014-04-17 06:36:03 +00:00
Doug Gregor
f384cbfe63 Add a flag -ignore-overlays to ignore overlays, and use it when building the standard library.
Fixes <rdar://problem/16603168>. This was way too much engineering
effort to ban fork() and vfork().

Swift SVN r16383
2014-04-16 00:02:38 +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
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
Jordan Rose
835bfb15a9 [ClangImporter] Add an option (off by default) to infer "implicit properties".
In Objective-C, any method with no arguments can be used with dot syntax, as
can any method that takes one argument whose name starts with "set". This
commit adds a frontend-only flag -enable-objc-implicit-properties to look for
"setter-like" methods that match up with "getter-like" methods to import them
as Swift properties. By default, such methods are just considered unrelated
methods.

Part of <rdar://problem/16215476>

Swift SVN r16025
2014-04-07 21:49:37 +00:00
Doug Gregor
781adc047e Add a *temporary* build configuration option for selector splitting.
Swift SVN r15880
2014-04-03 17:07:38 +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