Commit Graph

1889 Commits

Author SHA1 Message Date
Jordan Rose
06d370067a [ClangImporter] Use adapter modules for imports in a bridging header.
The signature of the function was all set up for this, but it didn't actually
do anything with the flag.

<rdar://problem/17783624>

Swift SVN r20665
2014-07-29 01:34:02 +00:00
Jordan Rose
798814e1d9 [ClangImporter] Import typedefs of other CF types as typealiases.
...rather than distinct classes. This is a bit more complicated than just
making a second typealias because we still want to strip off the "Ref".

<rdar://problem/17686069>

Swift SVN r20652
2014-07-28 22:43:29 +00:00
Jordan Rose
aae4a3d731 [ClangImporter] Pass through diagnostic locations for imports.
If importing a Clang module fails, we should report that at the location of
the import statement. This doesn't do that fully because it isn't transitive
(if Swift module Foo imports Swift module Bar, which fails to import Clang
module Baz, we don't get an error in user source), but it's a step forward
for the simple cases.

Swift SVN r20575
2014-07-25 23:01:51 +00:00
Jordan Rose
d8077fc540 [ClangImporter] Print notes for macro expansions and include locations.
(for errors in the bridging header or in modules)

<rdar://problem/17573187>

Swift SVN r20573
2014-07-25 23:01:47 +00:00
Anna Zaks
071291003b APINotes: Use the property's notes to set the accessor's types.
Fixes the crashes due to the property and its setter and getter being out of sync.

Swift SVN r20570
2014-07-25 22:49:36 +00:00
Doug Gregor
ff92b5f007 Remove -[no]implicit-objc-with.
Toggling this option causes funny things to happen, and there's no
point in keeping it.

Swift SVN r20565
2014-07-25 22:13:46 +00:00
Doug Gregor
5b3a3bdbaa An imported initializer is required if it is used to conform to a protocol requirement.
This replaces my egregious -initWithCoder:-specific hack with a more
reasonable general solution.

Replace my initWithCoder: hack with a proper

Swift SVN r20562
2014-07-25 21:01:36 +00:00
Doug Gregor
ec6016040e Clang importer: try harder to mark initializers from protocols as required.
There is an egregious hack here that special-cases -initWithCoder:. We
need to completely revisit how we handle 'required' checking.

Swift SVN r20516
2014-07-24 21:29:05 +00:00
Doug Gregor
0ad6ad65c8 API notes: add a "Required" field for Objective-C methods.
This allows us to express required initializers in the API notes. Use
it to smooth over NSString differences in the various SDKs even more.

Swift SVN r20511
2014-07-24 20:14:48 +00:00
Jordan Rose
e92c81dbe3 [ClangImporter] Treat shims.h as a system header in NDEBUG builds.
If a warning does sneak in here some day, it'll be visible to us but not to
end users.

<rdar://problem/16292896>

Swift SVN r20458
2014-07-24 02:36:24 +00:00
Anna Zaks
dfa97a11eb API Notes: yaml-to-binary: fix nullability mapping inconsistencies.
We choose not to model "OptionalTypeAdjustment(1, OTK_Optional)" in yaml, so update the known methods to use what we can model.

Introduce the absence of nullability info and use it to set NullabilityAudited and NumAdjustedNullable. (Maybe, after the .def file is gone and we have more testing, we could change the KnownObjCMethod API to better reflect the yaml format..)

Swift SVN r20367
2014-07-23 02:54:23 +00:00
Jordan Rose
58befc46e2 [ClangImporter] Handle submodule imports.
Specifically, handle them by also importing the top-level module. This is
unfortunate, but at least lets people /access/ things in explicit submodules,
even if it doesn't let them limit their import to a specific submodule.

    (swift) import OpenGL.GL3
    (swift) glGetString
    // r0 : (GLenum) -> ConstUnsafePointer<GLubyte> = (Function)
    (swift) OpenGL.glGetString
    // r1 : (GLenum) -> ConstUnsafePointer<GLubyte> = (Function)

One unfortunate side effect of having a single Clang ASTContext is that if
one Swift module imports a Clang submodule, every Swift module can now see
it. That means /mixing/ incompatible submodules, such as OpenGL.GL and
OpenGL.GL3, still won't work. Filed <rdar://problem/17756745> for that.

<rdar://problem/13140302>

Swift SVN r20288
2014-07-22 01:31:17 +00:00
Doug Gregor
ec32bc044d API notes: separate classes from protocols in the binary representation.
Swift SVN r20277
2014-07-21 20:23:55 +00:00
Doug Gregor
2faeb84e0c Rename ObjCClassInfo to ObjCContextInfo, to also cover protocols.
Swift SVN r20262
2014-07-21 17:30:16 +00:00
Jordan Rose
a419138a7a [PrintAsObjC] Print 'struct Foo' or 'enum Foo' instead of 'Foo' when necessary.
To do this, we keep track of decls with superfluous typedefs (rather than
just the typedefs), and check for that. Tag decls without typedefs are
printed with the tag.

<rdar://problem/17569385>

Swift SVN r20221
2014-07-20 17:26:20 +00:00
Chris Lattner
48687380b7 now that DeclAttributes is a single word, there is no reason to deal with
it indirectly through another pointer from Decl, just embed DeclAttributes
directly into Decl and get rid of the "getMutableAttrs" nonsense.



Swift SVN r20216
2014-07-20 04:09:42 +00:00
Doug Gregor
076d310132 Remove -import-tighter-objc-types option; we're turning it on by default.
Swift SVN r20191
2014-07-18 23:25:38 +00:00
Doug Gregor
fb9beed4cd Clang importer: clean up handling of Objective-C property API notes.
What we had was specific to optionality and had a different flow than
for methods; simplify the approach to match methods.

Swift SVN r20172
2014-07-18 18:48:10 +00:00
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