Commit Graph

1871 Commits

Author SHA1 Message Date
Doug Gregor
0095221dc5 API notes: simplify our handling of method merging.
Make the "merging class-wide information into method information"
operation part of ObjCMethodInfo. It doesn't belong in the Clang
importer.

Swift SVN r20171
2014-07-18 18:48:09 +00:00
Doug Gregor
d1cfab0943 Remove redundant FactoryAsInitKind definition. NFC
Swift SVN r20170
2014-07-18 18:48:05 +00:00
Jordan Rose
904d1b21c6 [ClangImporter] Drop the "current import" tracking for bridging headers.
Now that bridging headers from ASTs are always present and bridging headers
from the command line are checked in advance, we no longer need to worry
about the Clang instance failing to find the bridging header. That's good,
because this wasn't implemented correctly anyway: if a bridging header
imported a module, we could get an error.

Swift SVN r20129
2014-07-18 00:22:55 +00:00
Jordan Rose
fce31decdc Serialize bridging headers into the merged module file.
We do this so that the swiftmodule file contains all info necessary to
reconstruct the AST for debugging purposes. If the swiftmodule file is copied
into a dSYM bundle, it can (in theory) be used to debug a built app months
later. The header is processed with -frewrite-includes so that it includes
any non-modular content; the user will not have to recreate their project
structure and header maps to reload the AST.

There is some extra complexity here: a target with a bridging header
(such as a unit test target) may depend on another target with a bridging
header (such as an app target). This is a rare case, but one we'd like to
still keep working. However, if both bridging headers import some common.h,
we have a problem, because -frewrite-includes will lose the once-ness
of #import. Therefore, we /also/ store the path, size, and mtime of a
bridging header in the swiftmodule, and prefer to use a regular parse from
the original file if it can be located and hasn't been changed.

<rdar://problem/17688408>

Swift SVN r20128
2014-07-18 00:22:53 +00:00
Doug Gregor
dab7ece3bf API notes: which the Clang importer over to API notes completely.
The Clang importer no longer depends on built-in knowledge from
KnownObjCMethods.def.

Swift SVN r20120
2014-07-17 23:16:42 +00:00
Doug Gregor
533a94a5a0 Use API notes for Objective-C class/protocol nullability defaults.
Swift SVN r20113
2014-07-17 21:08:06 +00:00
Doug Gregor
b2220fc503 API notes: use API notes for property nullability information.
Swift SVN r20100
2014-07-17 17:00:19 +00:00
Doug Gregor
08db87ca35 Clang importer: load API notes whenever we load a Clang module.
We're not using this for anything, yet, so there aren't any checked-in
tests. Also note that I'm using ".apinotesc" for the binary form of
API notes.

Swift SVN r20096
2014-07-17 16:11:39 +00:00
Jordan Rose
0e8021b7f3 [ClangImporter] Add frontend option -dump-clang-diagnostics for debugging.
This option dumps Clang diagnostics to stderr as well as passing them along
to Swift's diagnostic machinery.

Swift SVN r19841
2014-07-11 00:36:55 +00:00
Jordan Rose
5a861b3515 [ClangImporter] Define header guards for <iso646.h> so it's never present.
This is a hack to work around two issues:
- <iso646.h>, which defines macros for "and", "or", and "not" (among other
  things) is an implicit submodule of Darwin.
- Macros even in explicit submodules are leaking out when the parent module
  is imported <rdar://problem/14870036>.

There's no actual reason to require <iso646.h> in SDK header files -- it
should be a user-level choice whether or not to use those names. And
selectors with "and", "or", and "not" in them should not be mangled by this.

So, as a hack, we define the header guards that <iso646.h> uses ahead of
time, so that the file will be ignored. We do this for /both/ variants of
<iso646.h> on our system (Clang's and /usr/include's) just to be safe.

<rdar://problem/17110619>

Swift SVN r19822
2014-07-10 20:19:33 +00:00
Pete Cooper
151d34dc4b Update for r212388 which uses non-intrusive refcounting for TargetOptions
Swift SVN r19606
2014-07-07 14:48:50 +00:00
Ted Kremenek
5ecbad667a Instead of defining __swift__, rely on the 'annotate' attribute to define custom unavailability in Swift (v1).
Swift SVN r19482
2014-07-02 20:59:14 +00:00
Ted Kremenek
148756e39a Predefine macro "__swift__" when importing Clang modules.
Implements <rdar://problem/17502039>.

Swift SVN r19327
2014-06-30 05:44:08 +00:00
Doug Gregor
afe74373ba Eliminate nondeterminism when getting imported modules from the Clang importer.
Swift SVN r19220
2014-06-26 04:42:54 +00:00
Ted Kremenek
a3b704ec42 Mark all imported APIs deprecated in iOS 7 (or earlier) or OS 10.9 (or earlier) as unavailable.
This patch takes care that synthesized initializers are created
when overriding unavailable initializers (thanks Doug).

Swift SVN r19202
2014-06-26 00:50:46 +00:00
Jordan Rose
347f330d15 Don't import the ObjC representation of Swift extensions in frameworks.
Because extensions don't have any identity we can check against, we can't
tell when we see an Objective-C category if it came from a Swift extension.
Change PrintAsObjC to mark all such categories with SWIFT_EXTENSION, and
just skip them unilaterally when importing Objective-C code.

Also, actually give Swift extensions a name when writing them as Objective-C
categories. Previously, they were nameless categories ("class extensions"),
but methods in a class extension are supposed to be implemented in the class's
main @implementation, so people were getting unexpected warnings about missing
implementations.

<rdar://problem/17342287>

Swift SVN r19116
2014-06-24 01:23:00 +00:00
Jordan Rose
b841308822 [ClangImporter] Pass an appropriate -fobjc-runtime= option to Clang.
Not doing this led to Objective-C headers being rejected when they contained
"__weak".

<rdar://problem/17402386>

Swift SVN r19115
2014-06-24 01:22:54 +00:00
Anna Zaks
a7fefdb561 Known ObjC types sidecar: add ability to annotate properties.
Add a simple option that allows to pass along information about properties.

Swift SVN r19110
2014-06-23 23:53:37 +00:00
Anna Zaks
5f61494928 Add OBJC_CONTEXT(ClassName, Options) to KnownObjCMethods.
This allows to specify the method options most common for the methods in a
given audited class or protocol.

Swift SVN r19108
2014-06-23 23:53:34 +00:00
Anna Zaks
9f122e56b7 Add initial support for importing with tighter Objective C pointer types.
Add the ability to store optionality of the ObjC method parameters and return
type in a sidecar. This hardcoded info is then used to import Objective C
object pointer types as either optional or none, instead of implicitly
unwrapped optionals.

The feature is enabled with -import-with-tighter-objc-types=true.

Swift SVN r19048
2014-06-20 19:19:43 +00:00
John McCall
8a6ee4c8e7 Fix harder for LLVM/Clang trunk.
Swift SVN r18839
2014-06-12 21:11:11 +00:00
Bob Wilson
751301a72b Update diag::Mapping to diag::Severity to match clang r210518.
Swift SVN r18833
2014-06-12 19:48:40 +00:00
Bob Wilson
97ab82ea23 ClangImporter: Update for clang API change in r209002.
Patch by Justin Bogner

Swift SVN r18831
2014-06-12 19:48:38 +00:00
Jordan Rose
a4ea927426 [ClangImporter] If a protocol and a class have the same name, add "Protocol".
.../if/ the protocol and the class are from the same top-level Clang module.
If not, the protocol is /not/ renamed, and users will have to disambiguate
with module qualification.

This kills our hardcoded "RenamedProtocols" list; it turns out this pattern
is more common than we thought /and/ leads to cross-referencing issues.

<rdar://problem/16206627>

Swift SVN r18809
2014-06-11 23:00:00 +00:00
Doug Gregor
1d99cdaf63 Add a defensive assertion to make sure the Clang importer doesn't return null imported modules
Swift SVN r18687
2014-06-01 02:01:46 +00:00
Jordan Rose
88a64eb54a Revert "ClangImporter: Update for clang API change"
Until we can build against LLVM and Clang master completely, we should hold
off on any changes that take us out of sync with the wwdc-master tags.

This reverts r18661.

Swift SVN r18662
2014-05-29 20:51:16 +00:00
Justin Bogner
df0b230fb2 ClangImporter: Update for clang API change
Swift SVN r18661
2014-05-29 20:07:13 +00:00
Jordan Rose
5bee45b776 [ClangImporter] Treat non-modular content imported via framework as an error.
This is -Werror=non-modular-include-in-framework-module for Clang, and
prevents the same content from being treated as part of two different
modules. It's mostly just a sanity check to keep from having problems later.

<rdar://problem/16966705>

Swift SVN r18525
2014-05-21 22:21:50 +00:00
Jordan Rose
6d376f9627 [ClangImporter] Make a missing bridging header a fatal error.
<rdar://problem/16920163>

Swift SVN r18442
2014-05-20 02:13:32 +00:00
John McCall
ef90a920f9 Update for macosx SDK change. The iOS SDK still uses the
old macro for now.

Swift SVN r18385
2014-05-19 04:00:44 +00:00
Doug Gregor
f338c9f9bf Extend ObjC methods whitelist to support adding an "unavailable" attribute.
Use this for -class and +class, to make them less ad hoc. More to follow.

As part of this, actually mark imported unavailable declarations in a
protocol as "optional", because nobody should have to implement an
unavailable declaration.

Swift SVN r18262
2014-05-17 19:18:02 +00:00
Doug Gregor
b345aa4827 Revert "Reinstate Jordan's r18233 now that our branches have caught up with the Clang API change."
This reverts commit r18251.

Swift SVN r18257
2014-05-17 17:11:56 +00:00
Doug Gregor
53bf4ead80 Reinstate Jordan's r18233 now that our branches have caught up with the Clang API change.
Swift SVN r18251
2014-05-17 16:36:32 +00:00
Jordan Rose
af3c3b358d Revert "[ClangImporter] Update for Clang API change in r209002."
We still have an outstanding incompatibility with LLVM trunk, so let's
just get in a state where we can build against known commits for now.

This reverts r18233.

Swift SVN r18234
2014-05-17 01:40:57 +00:00
Jordan Rose
d7c6bbf760 [ClangImporter] Update for Clang API change in r209002.
If you haven't picked up that commit in Clang yet, it should be safe to
revert this patch.

Swift SVN r18233
2014-05-17 00:50:13 +00:00
Jordan Rose
b581365785 [ClangImporter] If a Clang module fails to build, it's not missing.
...so don't report a second "module missing" error from Swift itself.

We do still treat the Clang module failing to build as a fatal error.

<rdar://problem/16175035>

Swift SVN r18231
2014-05-17 00:23:46 +00:00
Jordan Rose
a012602f62 [ClangImporter] Pass diagnostics through to Swift's diagnostic consumer.
We're not mapping source locations over correctly yet, so the file name
where an error occurs gets shoved into the diagnostic text, but that's
fine for now.

This also silences the "module 'Blah' not found" error coming from the
importer whenever Swift itself can be responsible for importing the module.

Still to do: if we can't build a Clang module, we shouldn't report that
error and then say it can't be found.

<rdar://problem/14509389>

Swift SVN r18230
2014-05-17 00:23:44 +00:00
Jordan Rose
bfa7566aec [ClangImporter] Put implicit properties into the list of all class members.
This allows "obj.description!" to work on iOS when 'obj' is an AnyObject,
even though 'description' is an implicit property created by the importer.

Swift SVN r18149
2014-05-16 00:30:55 +00:00
Jordan Rose
869508db2c [ClangImporter] Make sure the imported header module can see the stdlib.
Otherwise, it can't find the appropriate ~= to use for synthesized NS_ENUM
RawRepresentable conformances, leading to bizarre errors about the
underlying type (usually Int) not being able to convert to NSObject.

<rdar://problem/16923405>

Swift SVN r18131
2014-05-15 22:03:31 +00:00
Doug Gregor
d640eb4083 Introduce support for blacklisting factory-methods-as-inits.
Some fcactory methods shouldn't come in as initializers, per
<rdar://problem/16908950>.


Swift SVN r18101
2014-05-15 07:04:46 +00:00
Doug Gregor
3210f19411 Clang importer: replace the designated-initializer whitelist with a general method whitelist.
... which only handles designated initializers, for now at least.


Swift SVN r18100
2014-05-15 06:22:44 +00:00
John McCall
a3fb501114 Recognize the objc_bridge and objc_bridge_mutable
attributes and create implicit conversions for them.

Also, when generating Clang modules for import, set the
appropriate macro to make CoreFoundation actually apply
those attributes to its typedefs.

Also, give shared linkage to imported class method
definitions.

The net effect is that CFString now automatically
converts to NSString and vice-versa.

Depends on Clang r208756 in order to preserve attributes
applied to tag types in multiple typedef declarations.

Swift SVN r18069
2014-05-14 08:19:39 +00:00
Jordan Rose
2877bd0854 Add support for dependency file generation with -emit-dependencies.
This performs very conservative dependency generation for each compile task
within a full compilation. Any source file, swiftmodule, or Objective-C
header file that is /touched/ gets added to the dependencies list, which
is written out on a per-input basis at the end of compilation.

This does /not/ handle dependencies for the aggregated swiftmodule, swiftdoc,
generated header, or linked binary. This is just the minimum needed to get
Xcode to recognize what needs to be rebuilt when a header or Swift source
file changes. We can revisit this later.

This finishes <rdar://problem/14899639> for now.

Swift SVN r18045
2014-05-14 00:34:11 +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
Argyrios Kyrtzidis
63ebd0ef8d [ClangImporter] When creating the FileID for the header import buffer, set the main FileID as include location.
SourceManager expects that SourceLocations have the main FileID as parent, except for the predefines buffer.
Fixes assertion hit in a SourceKit test.

Swift SVN r17851
2014-05-10 22:31:29 +00:00
John McCall
c03b705dd0 Recognize CF "subclasses" and require CFTypeRef to specifically
be 'const void *', not just any 'void*'.

Swift SVN r17659
2014-05-08 00:51:27 +00:00
Jordan Rose
3e917be738 Use full DeclNames for dynamic lookup of calls.
Previously, we were just using the base name, which resulted in massive
inefficiency when dealing with Clang (we basically had to check every
selector in the system to see if it had the same first selector piece).
I've hacked ConstraintSystem a bit to carry a map from UnresolvedDotExpr
to the ApplyExpr that consumes it, so that we can use the full DeclName
and look up methods by full selector.

Now that dynamic lookup is fast, re-enable it for the
Foundation_bridge.swift test. (r17520 actually provided most of the benefit.)

This does break selector lookup on AnyObject when doing selector splitting,
and slightly regresses diagnostics when you try to call a method on AnyObject
and forget a parameter name.

<rdar://problem/16808651>. Part of the Playground performance efforts.

Swift SVN r17524
2014-05-06 02:35:08 +00:00
Jordan Rose
ed4ad291c5 [ClangImporter] Don't bother running lookups on submodules.
We're only using Clang submodules for their imports and link dependencies;
they don't contain decls right now.

Swift SVN r17520
2014-05-06 02:06:06 +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
Jordan Rose
0c46eb821e [ClangImporter] Handle decls declared in imported headers.
This improves the -import-objc-header option to read decls from the header
as well. Any declaration that is not from a module will be considered to be
part of the "header module". Conversely, forward-declarations appearing in
the header will be resolved by looking through all modules responsible for
importing a header.

More of <rdar://problem/16702101>

Swift SVN r17492
2014-05-05 22:52:17 +00:00