Commit Graph

94 Commits

Author SHA1 Message Date
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
Chris Lattner
5b49d59c57 Remove the @ from @final and @lazy, the last major piece of
rdar://17168115.

Also, reinstate the ARM driver change and testcase that I removed
in my last patch.


Swift SVN r19790
2014-07-10 06:23:27 +00:00
Chris Lattner
fe95f81397 introduce a new 'DeclModifier' flag on attributes, which mark that the
attribute is a "modifier" of a decl, not an "attribute" and thus shouldn't
be spelt with an @ sign.  Teach the parser to parse "@foo" but reject it with
a nice diagnostic and a fixit if "foo" is a decl modifier.

Move 'dynamic' over to this (since it simplifies some code), and switch the
@optional and @required attributes to be declmodifiers (eliminating their @'s).



Swift SVN r19787
2014-07-10 05:49:10 +00:00
Argyrios Kyrtzidis
8dba1a0b7e [Driver] Set the '-target-cpu' for non-64 arm as well.
Depends on clang r212666.
Fixes rdar://17603166

Swift SVN r19774
2014-07-10 01:29:47 +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
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
Adam Nemet
fb3cb3fbd9 Enable TBI for Swift
<rdar://problem/17243596>


Swift SVN r19094
2014-06-23 18:13:47 +00:00
Jordan Rose
e715940241 [Driver] Teach "swift -i" and "swift -repl" to default to the current OS X SDK.
This only works when swift is packaged with Xcode or installed as a command
line tool, but those are the important cases.

<rdar://problem/14395800>, again.

Swift SVN r18757
2014-06-09 21:29:08 +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
Mark Lacey
a052c9d6bb Imported static inline functions should not use AAPCS on 32-bit ARM.
As with ARM64, we need to be specific about the -target-abi or we end up
defaulting to something that is not appropriate for our platforms.

Fixes <rdar://problem/16821282>.

Swift SVN r18163
2014-05-16 02:42:21 +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
Jordan Rose
359779d228 [Driver] Fix use-after-free caught by buildbot.
Swift SVN r17990
2014-05-13 02:11:53 +00:00
Jordan Rose
c6c6c6ef0f [Driver] Preserve .o files when compiling with debug info.
Since we don't generate dSYMs yet, this is the only way to create debuggable
binaries.

Thanks, Jim.

Swift SVN r17853
2014-05-10 22:34:35 +00:00
Jordan Rose
257ee03c5c [driver] Use the target triple's OS version as the linker's min OS version.
This only affects binaries built from the command line. Xcode isn't using
the driver to invoke ld.

Swift SVN r17822
2014-05-10 01:53:35 +00:00
Jordan Rose
3bebef4d29 Pass options to LLDB's REPL.
This is the rest of <rdar://problem/16776705>

Swift SVN r17820
2014-05-10 01:17:39 +00:00
Doug Gregor
d8a27c65df Use AddLastArg properly.
Swift SVN r17797
2014-05-09 20:54:37 +00:00
Doug Gregor
06f18b3b4d Drive-by: pass along -no-strict-keyword-arguments.
Swift SVN r17784
2014-05-09 16:36:55 +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
dde2a8b06b Serialize and honor whether a particular library should be force-loaded.
When a module built with -autolink-force-load is imported, add a reference
to a special symbol in the corresponding library so that ld is forced to
link it.

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).

Second part of <rdar://problem/16829587>

Swift SVN r17751
2014-05-09 01:20:32 +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
Jordan Rose
465b083ba9 [serialization] Serialize the header path used by -import-objc-header.
This doesn't handle cross-references to decls /loaded/ from the header
just yet, so all that's testable right now is whether the header's imports
are visible from the secondary target (after being imported in response
to loading the serialized module).

More of <rdar://problem/16702101>

Swift SVN r17638
2014-05-07 19:03:21 +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
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
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
Greg Parker
4c9c52fb81 <rdar://15931346> Fix KVO.
* Temporarily turn on -link-objc-runtime by default. This will be 
  removed again in rdar://16753644.
* Symlink XcodeDefault.xctoolchain's copies of arclite into the Swift build's 
  resource directory so tests can see it.
* Enable the KVO test.


Swift SVN r17132
2014-05-01 01:39:23 +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
8f80f43e72 Add -[no-]link-objc-runtime option that controls the linking of arclite.
Currently arclite is never linked into a binary unless you pass the option.
See <rdar://problem/16679045> for more information.

Swift SVN r17003
2014-04-28 23:39:16 +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
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
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
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
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
Doug Gregor
2424200990 Thread -split-objc-selectors through the driver.
Swift SVN r15879
2014-04-03 17:07:36 +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
Jordan Rose
1fec0510f7 [driver] Pass -Xcc options down to frontend tools.
These options are supposed to go to the Clang importer, but we were just
dropping them on the floor.

Swift SVN r15300
2014-03-20 21:53:48 +00:00
Dmitri Hrybenko
e50b52fa02 Serializer/Driver: serialize comments to separate .swiftdoc files
The driver infers the filename from the module file by replacing the extension,
and passes the explicit path to the swiftdoc file to the frontend.  But there
is no option in the driver to control emission of swiftdoc (it is always
emitted, and name is always inferred from the swiftmodule name).

The swiftdoc file consists of a single table that maps USRs to {brief comment,
raw comment}.  In order to look up a comment for decl we generate the USR
first.  We hope that the performance hit will not be that bad, because most
declarations come from Clang.  The advantage of this design is that the
swiftdoc file is not locked to the swiftmodule file, and can be updated,
replaced, and even localized.


Swift SVN r14914
2014-03-11 10:42:26 +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
Jordan Rose
11e9ec50c8 [driver] Pass -module-cache-path and -F to both compilation and module merging.
Previously we only passed -module-cache-path to the compilation jobs, which
meant the module merging jobs would default to using the system module cache
(which means double the Clang work if the module cache had been set, and
strange errors during development when Clang's serialized format changes).

We hadn't been passing -F to either job because we hadn't been worrying
about non-system frameworks, but that's likely to change soon.

I also consolidated the forwarding of -Xfrontend args in this commit.
I've convinced myself that this will pretty much always be necessary for the
merge-module step, and that we should have something else if we really
need to differentiate the two.

<rdar://problem/16113207>

Swift SVN r14114
2014-02-19 23:31:21 +00:00
Greg Parker
9a1cf1af16 Work around linker confusion by the Swift marker in ObjC metadata (rdar://16107696).
Swift SVN r14078
2014-02-19 09:22:38 +00:00
Jordan Rose
93b87edcbe Add -resource-dir option to find lib/swift directory.
This is equivalent to Clang's -fresource-dir; it provides the location of
compiler modules and libraries.

No end-user-visible changes, but the iOS build will no longer have to use
-I to build and test its own standard libraries.

Swift SVN r13888
2014-02-14 01:27:15 +00:00
Jordan Rose
798e13d15c Wire up -emit-objc-header[-path] options that don't do anything yet.
These options piggyback on the "merge module" phase of the driver
because the header we output needs an entire complete module.

Swift SVN r13800
2014-02-12 01:19:13 +00:00
Michael Gottesman
f88bc1ed3e Teach the frontend how to pass through -Xllvm commands.
This patch allows you to pass through commands to llvm from the driver so now
one can when compiling swift files get debug messages!

Swift SVN r13761
2014-02-10 22:49:56 +00:00