Commit Graph

1871 Commits

Author SHA1 Message Date
Graham Batty
a1e0b0fbf7 Driver: More stubbing for Linux support
Swift SVN r22362
2014-09-29 21:14:32 +00:00
Anna Zaks
317f809bcd API Notes: Fix several bugs that effect availability info propagation.
- Merge availability info by merging CommonEntityInfo as part of ObjCContextInfo.
 - Don't try to add Absent nullability to property setters (since it cannot be
   represented by ObjCMethodInfo).
 - Factor out lookupObjCContext and make sure we always look up in both
   class and protocol.

This will be tested by API notes drop, which will get committed separately.

Swift SVN r22089
2014-09-18 18:51:47 +00:00
Jordan Rose
ff59af1e69 Only test that all SourceManager buffers are valid when actually still valid.
Some of the buffers are owned by the ClangImporter, so after the
ClangImporter's been deallocated, the SourceManager isn't going to be fully
valid any more.

Should fix issues from r21958.

Swift SVN r21989
2014-09-16 22:41:27 +00:00
Doug Gregor
c1399cf229 Allow SDK overlays to add 'required' initializers.
Removes the initWithBool: hack from the Clang importer. We can now
express NSNumber's conformance to the BooleanLiteralConvertible
protocol in the overlay.

Swift SVN r21976
2014-09-16 17:09:58 +00:00
Doug Gregor
d93eaed9f7 Switch BooleanLiteralConvertible over to an initializer requirement.
Conforming to BooleanLiteralConvertible now requires

  init(booleanLiteral: Bool)

rather than

  static func convertFromBooleanLiteral(value: Bool) -> Self

This posed a problem for NSNumber's conformance to
BooleanLiteralConvertible. A class needs a required initializer to
satisfy an initializer requirement, but one cannot add a required
initializer via an extension. To that end, we hack the Clang importer
to import NSNumber's initWithBool with the name

  init(booleanLiteral:)

and add back the expected init(bool:) initializer in the
overlay. These tricks make NSNumber even harder to subclass, but we
don't really care: it's nearly impossible to do well anyway, and is
generally a Bad Idea.

Part of rdar://problem/18154091.

Swift SVN r21961
2014-09-15 23:59:30 +00:00
Argyrios Kyrtzidis
0b4df546a4 Revert "[ClangImporter] Use a constant for the name of the module created for the imported header."
Once can use ClangModuleLoader::getImportedHeaderModule() to check if the module is the importer-header module.

This reverts commit r21949.

Swift SVN r21955
2014-09-15 21:25:13 +00:00
Argyrios Kyrtzidis
c3757ae582 [ClangImporer] Expose ClangImporter::getImportedHeaderModule() via the ClangModuleLoader interface.
Swift SVN r21953
2014-09-15 21:22:37 +00:00
Argyrios Kyrtzidis
8ec13a169d [ClangImporter] Use a constant for the name of the module created for the imported header.
Swift SVN r21949
2014-09-15 19:51:07 +00:00
Jordan Rose
167d2f4bbb Include extensions in ClangModuleUnit::getTopLevelDecls.
We don't do this very efficiently, but it does work. And now that it's working,
drop some special cases in module interface printing -- just always print
Clang decls in Clang source order.

Swift SVN r21901
2014-09-12 02:54:50 +00:00
Adrian Prantl
fb1fb614d2 Update for upstream LLVM API change (unique_ptr).
Swift SVN r21843
2014-09-10 17:26:38 +00:00
Joe Groff
487f9a96ca Quell warning.
Swift SVN r21831
2014-09-10 05:56:39 +00:00
Jordan Rose
7b6a0dd185 [ClangImporter] Add a mode where @class decls are imported as empty classes.
This can be used by SourceKit's interface printer to display modules with
forward declarations of classes in dependent modules, e.g. ObjectiveC
forward-declaring Foundation's NSString for use in NSObject. We can consider
doing something similar for C tag types (structs and enums).

Part of rdar://problem/18273845

Swift SVN r21828
2014-09-10 02:32:53 +00:00
Jordan Rose
3710933f3d [ClangImporter] Decls deprecated in OS X 11.0 are not implicitly unavailable.
Noticed by chance. Doesn't affect anything now.

Swift SVN r21826
2014-09-10 02:32:48 +00:00
Argyrios Kyrtzidis
da95aadb4b [ClangImporter] Make sure we don't crash if clang emits diagnostics because of the provided clang compiler arguments.
rdar://18068354

Swift SVN r21823
2014-09-10 01:18:32 +00:00
Anna Zaks
c3c8576ecc Add special handling of accessibility APIs.
This is a hack that allows us to support accessibility APIs in Swift.
It addresses radar://17509751.

A class might conform to both NSAccessibility (containing accessibility
properties) and individual accessibility protocols (containing
accessibility methods with the same names as the properties). This should
not compile (but currently happens to compile). To avoid the problem down
the road, we import setters and getters instead of the accessibility
properties from NSAccessibility.

Swift SVN r21757
2014-09-06 00:46:17 +00:00
Doug Gregor
b6248c8342 Remove the -enable-objc-failable-initializers option.
As part of this, failable initializers get enabled by default for
swift-ide-test.


Swift SVN r21704
2014-09-04 15:31:02 +00:00
Adrian Prantl
cb41e95bb7 Update for upstream LLVM unique_ptrification.
Swift SVN r21589
2014-08-29 20:10:30 +00:00
Jordan Rose
c3660d5ad6 [Serialization] Ensure that a cached bridging header is null-terminated.
I'm not quite sure how to tickle this one, but the next commit adds more
data after the cached header, at which point existing tests break. This
could have already caused problems if no padding was needed in the bitstream.

Swift SVN r21543
2014-08-28 21:36:00 +00:00
Dmitri Hrybenko
f5299e1108 Update for upstream LLVM API changes
Swift SVN r21527
2014-08-28 12:44:23 +00:00
Doug Gregor
fe8213eec3 Cope with leading acronyms when turning factory methods into initializers.
This allows us to properly import, e.g., +[NSURL URLWithString] as the
initializer init(string:). Fixes <rdar://problem/16906469>.

Swift SVN r21366
2014-08-21 17:41:25 +00:00
Doug Gregor
7c69056659 Remove the always-on ImportCFTypes language option.
Swift SVN r21355
2014-08-21 15:24:32 +00:00
Doug Gregor
5709a86f2f Start importing Objective-C initializers and factory methods using failable initializers.
In this mode, use nullability information on the result type of the
initializer or factory method to determine failability of the
initializer. This is behind the flag
-enable-objc-failable-initializers until we have the SILGen support in
place.



Swift SVN r21341
2014-08-21 04:50:20 +00:00
Jordan Rose
a36be37c4f [ClangImporter] Check for the existence of a submodule before loading it.
This regresses a bit on the diagnostic when a submodule is missing, as well
as missing out on Clang's automatic typo correction, but it does avoid putting
the Clang CompilerInstance into an error state, which is important for the
REPL. It's also not entirely clear that Clang had the right behavior in this
case either---we'd get a module back, but if the particular submodule we
asked for didn't exist we might get its parent. We can revisit this later.

Prerequisite for <rdar://problem/17994094>.

Swift SVN r21333
2014-08-21 01:54:22 +00:00
Jordan Rose
a6c5547c81 [ClangImporter] When importing attributes for a class, use the @interface.
i.e. don't look for attributes on an @class somewhere.

Also do this for tag decls, whose attributes propagate forwards until there's
a definition.

<rdar://problem/17986861>

Swift SVN r21223
2014-08-15 03:26:24 +00:00
Jordan Rose
a44a16b6b3 [ClangImporter] Test for a module's presence before trying to load it.
This makes sure that the Clang CompilerInstance doesn't think that we've seen
an error just because we were checking for the existence of a module, and
therefore will not break the world when the module is absent.

This fixes an issue where loading PlaygroundLogger broke static inline
functions because PlaygroundLogger has no Objective-C module.
<rdar://problem/18007508>

It also lays groundwork for not treating a missing module as a fatal error
in REPL modes. To do that properly, however, we should figure out how to do
this for submodules as well. <rdar://problem/17994094>

Swift SVN r21187
2014-08-13 23:22:02 +00:00
Chris Lattner
3f0e430abf fix the build: clang gets more and more unique.
Swift SVN r21132
2014-08-11 15:52:39 +00:00
Jordan Rose
ee22004b84 [IRGen] Walk inlineable Clang functions and emit their dependencies.
This handles things like NSSwapHostLongLongToBig and MKMapRectMake that
are static inline functions that themselves call other static inline
functions.

<rdar://problem/17227237>

Swift SVN r21080
2014-08-06 23:21:17 +00:00
Anna Zaks
782ecab50a API Notes: Teach Clang Importer about nullability of globals and functions
Swift SVN r20941
2014-08-02 01:55:18 +00:00
Jordan Rose
2b73716dd2 [ClangImporter] When a submodule is imported, so is the top-level module.
Background: if a Clang module /only/ imports submodules from another module,
we would lose all re-exports from that other module, because we're treating
all decls as part of the top-level module. This actually shows up with UIKit
and QuartzCore due to some weirdness in how the QuartzCore module is set up
(see <rdar://problem/17888079>), resulting in 'CALayer' not being visible
with just 'import UIKit'.

Workaround (this patch): treat Clang imports just like Swift imports: if the
submodule is referenced, so is the top-level module. This isn't great, but
it's not really any more awful than the rest of our Clang modules story.

<rdar://problem/17607060>

Swift SVN r20920
2014-08-01 21:44:41 +00:00
Jordan Rose
b682e0cf3d [ClangImporter] Don't try to recover if an Objective-C module can't be loaded.
This is already a fatal error, so it doesn't matter how many diagnostics we
dump after that. It's better not to lie to the rest of the compiler about
whether the load succeeds.

No immediate Radar, but this fixes a crash in the test case I'm about to
commit, and possibly some other mystery "dependency missing" crashes in
XREF resolution.

Swift SVN r20919
2014-08-01 21:44:36 +00:00
Jordan Rose
4eebcb9853 Change ASTContext's LoadedModules map to be keyed by Identifiers, not strings.
No intended functionality change, but there's no reason to be performing
string lookups here.

Swift SVN r20902
2014-08-01 18:03:47 +00:00
Jordan Rose
c485690a07 [ClangImporter] s/OSX/OS X/ in the deprecation error message.
Swift SVN r20842
2014-07-31 18:58:15 +00:00
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