Commit Graph

2428 Commits

Author SHA1 Message Date
Doug Gregor
535d03687b Infer the requires_stored_property_inits attribute for NSManagedObject.
Swift SVN r12316
2014-01-15 05:11:52 +00:00
Doug Gregor
23aeafc195 Finish switching "static" over to "type" in examples, proposals, etc.
Swift SVN r12048
2014-01-08 05:28:59 +00:00
Dave Zarzycki
720052c3fe Clang Importer: Remove gross '6432' constant
Swift SVN r11933
2014-01-06 19:05:13 +00:00
Dave Zarzycki
3abeb338a4 Teach the importer about word-sized types
Swift SVN r11917
2014-01-05 22:58:23 +00:00
Jordan Rose
8a843f3879 [ClangImporter] Protocol instance methods are also class methods on roots.
-respondsToSelector: is declared on the NSObject protocol, which is adopted
by the NSObject root class. The NSObject metaclass also extends NSObject,
so it also needs a respondsToSelector:. This effectively becomes a
+respondsToSelector: method on NSObject-the-class.

Change importMirroredProtocolMembers to actually do this, just like
importObjCMembers was changed in r11614 for instance methods declared
directly within the class.

Finishes <rdar://problem/13371711>.

Swift SVN r11881
2014-01-04 00:56:37 +00:00
Doug Gregor
41b6a42067 Clang importer: whitelist certain Objective-C protocols for renaming.
Rather than append the "Proto" suffix to all imported Objective-C
protocols, which can be confusing, whitelist those protocols that we
do have to rename. Only NSObject falls into this category so far.

Fixes <rdar://problem/15741699>.

Swift SVN r11856
2014-01-03 07:04:44 +00:00
Chris Lattner
2b521ffa46 mark a couple more 'self' decls in functions synthesized by the
importer as 'lets'.  This should produce slightly better code,
but is more useful in that it improves consistency.



Swift SVN r11816
2014-01-02 17:59:04 +00:00
Joe Groff
8bebb084e6 Rename 'RequirementKind::ValueWitnessMarker' to 'WitnessMarker'.
It's witnessing protocol requirements, not values, and "value witness" has a particular meaning in IRGen.

Swift SVN r11814
2014-01-02 17:47:40 +00:00
Doug Gregor
e1d3cbd01d [Clang importer] Synthesize protocol conformances for imported declarations.
This allows us to enable a verifier that ensures that protocol
conformances account for all requirements in the corresponding
protocol.

Swift SVN r11813
2014-01-02 16:04:23 +00:00
Doug Gregor
631b0c361a Don't import the same Objective-C method twice (recursively).
Swift SVN r11812
2014-01-02 16:04:11 +00:00
Chris Lattner
f000a98035 fix a fixme, importing NSOPTIONS methods as non-mutable methods.
Swift SVN r11706
2013-12-28 23:07:25 +00:00
Chris Lattner
d3c91387e9 Substantially simplify the API to LValueType now that nonsettable is gone.
Swift SVN r11703
2013-12-28 22:48:44 +00:00
Jordan Rose
69a51655c7 [ClangImporter] Instance methods on NSObject are also class methods.
More specifically, instance methods on root objects are also class methods,
because the metatype for that class will inherit from the root class.
(That is, NSObject's metatype extends NSObject.)

This is necessary to allow calling, say, -respondsToSelector: on a class.
Unfortunately, it also brings in every other method on NSObject, including
"informal protocol" category methods like -awakeFromNib. We should probably
disprefer these in code completion, especially if they're declared in another
module, but it is perfectly legal to call these methods on Class objects in
Objective-C.

<rdar://problem/13371711>

Swift SVN r11614
2013-12-24 01:34:07 +00:00
Argyrios Kyrtzidis
a4ed3e19d0 [ClangImporter] When creating the member declarations for NS_ENUM/NS_OPTIONS, also associate the
clang declaration that they came from.

rdar://15574386

Swift SVN r11543
2013-12-21 17:40:31 +00:00
Argyrios Kyrtzidis
3882ab6bd4 [ClangImporter] When checking for NS_ENUM/NS_OPTIONS enums, use clang::Preprocessor::getImmediateMacroName()
and check for CF_ENUM/CF_OPTIONS, which NS_ENUM/NS_OPTIONS expand to.

This:
- Simplifies code
- Handles CF_ENUM/CF_OPTIONS enums
- Handles correctly an NS_ENUM/NS_OPTIONS enum that was itself expanded from another macro.

Swift SVN r11542
2013-12-21 17:40:28 +00:00
Doug Gregor
be3463f32d Store a file-level DeclContext* in protocol conformances rather than a module.
We'll need to perform name lookup based on the file-level
DeclContext*, so the module no longer suffices. No functionality
change here yet.


Swift SVN r11523
2013-12-20 22:53:21 +00:00
Chris Lattner
b29748a6be remove the ASTContext argument from Type::transform,
(various) FunctionType::get's, ArrayType::get,
ArraySliceType::get, OptionalType::get, and a few
other places.

There is more to be done here, but this is all I plan to do
for now.


Swift SVN r11497
2013-12-20 02:23:21 +00:00
Chris Lattner
1472e4d914 Remove the ASTContext argument from LValueType::get(). It is already
only two loads away from the type argument passed in.



Swift SVN r11496
2013-12-20 01:28:50 +00:00
Doug Gregor
b9696e1c01 Create protocol conformances and then, separately, fill in the witnesses.
This is a structural baby step toward lazily filling in protocol
conformances. We always build a ProtocolConformance, then mark it
either "complete" (when it's well-formed) or "invalid" (when it's
ill-formed). At present, the only benefit to this is that it slows
diagnostic cascades from invalid conformances.


Swift SVN r11492
2013-12-20 00:29:00 +00:00
Jordan Rose
7a30de2efe Disallow inheritance clauses for concrete typealiases.
typealias MyInt: ForwardIndex = Int

There is no real reason to allow this; it's just a static_assert that Int
conforms to ForwardIndex, which would be better spelled some other way.

This only applies to concrete typealiases, i.e. those that simply alias an
underlying type. Associated types can still have both inheritance clauses
and a (default) underlying type.

Swift SVN r11481
2013-12-19 21:13:54 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
Dmitri Hrybenko
73875c77e0 Clang importer: don't import BOOL and SEL
Swift SVN r11474
2013-12-19 18:37:23 +00:00
Dmitri Hrybenko
0950901b1b Don't import 'id' and 'Class'
rdar://15693821


Swift SVN r11465
2013-12-19 02:42:13 +00:00
Joe Groff
a9570e2004 ClangImporter: Make NS_OPTIONS conform to LogicValue.
Until we can actually do the implementation work necessary to make 'if optionSetValue.Option {}' work, this is a reasonable affordance to allow the C 'if optionSetValue & .Option {}' pattern to work and bring us to parity with ObjC.

Swift SVN r11412
2013-12-18 02:47:06 +00:00
Dmitri Hrybenko
c54c979f95 Clang importer: don't add @objc *attribute* to imported decls, just set the objc bit
AST printer: print @objc attribute only on top-level imported decls to reduce
the amount of noise.


Swift SVN r11365
2013-12-17 00:50:12 +00:00
Joe Groff
44dcc43fa9 ClangImporter: Make NS_OPTIONS imports conform to RawOptionSet.
This makes the bitwise operations &|^~ work with NS_OPTIONS.

Swift SVN r11349
2013-12-16 19:22:27 +00:00
Doug Gregor
11b6d19dd3 Add a location to NormalProtocolConformance.
This will be used for diagnostics in an upcoming refactor.


Swift SVN r11348
2013-12-16 17:24:15 +00:00
Dmitri Hrybenko
531adcbf45 Remove unused variable
Swift SVN r11293
2013-12-14 02:22:48 +00:00
Dmitri Hrybenko
7e56d75a1e Clang importer: don't import superfluous typedefs to tag decls that have the same name
Not only this creates less ASTs, but this makes the resulting AST correct (it
is invalid to have a struct and a typealias with the same name).  But the
primary motivation is AST pretty-printing: we don't want to print those extra
useless typealiases.


Swift SVN r11289
2013-12-14 01:39:03 +00:00
Dmitri Hrybenko
9d45fe97f2 ClangImporter: factor out a routine to search in the cache
Swift SVN r11282
2013-12-14 00:03:02 +00:00
Doug Gregor
b4a739854d Stop using ProtocolConformance::getWitnesses().
It's going away, soon.


Swift SVN r11277
2013-12-13 23:44:42 +00:00
Chris Lattner
698380d6d3 Introduce a new bit in VarDecl, "isLet". Teach Sema that 'isLet' properties
are not settable (like get-only ones).  Set the 'isLet' bit in various 
places, but not the particularly interesting or useful places yet.



Swift SVN r11121
2013-12-11 06:45:40 +00:00
Dmitri Hrybenko
2f02b021df Remove accidentally committed debugging code
Swift SVN r11112
2013-12-11 01:32:30 +00:00
Dmitri Hrybenko
788912da16 Introduce AnyObject and AnyClass (for 'DynamicLookup' and 'DynamicLookup.metatype')
Also stop importing declarations that don't belong to a Clang module.  'id' and
'Class' were the last two that we cared about.


Swift SVN r11107
2013-12-11 01:07:13 +00:00
Dmitri Hrybenko
73c26e7e4c Clang importer: rename importDeclContext -> importDeclContextImpl to emphasize
that it should not be used directly.


Swift SVN r11043
2013-12-09 22:35:10 +00:00
Dmitri Hrybenko
e27001dbc7 Clang importer: determine the module for enums correctly while importing enum's
decl context


Swift SVN r11039
2013-12-09 22:19:47 +00:00
Argyrios Kyrtzidis
345564380c Rename 'ibaction/iboutlet' attributes to 'IBAction/IBOutlet'.
Swift SVN r10953
2013-12-07 00:14:51 +00:00
Doug Gregor
707d04c3d2 Clang importer: always expand out the (Objective-C) protocol list.
Fixes <rdar://problem/15246440>.


Swift SVN r10876
2013-12-05 19:18:57 +00:00
Jordan Rose
be12d86ddd Turn ClangModule into ClangModuleUnit.
Part of the FileUnit restructuring. A Clang module (whether from a framework
or a simple collection of headers) is now imported as a TranslationUnit
containing a single ClangModuleUnit.

One wrinkle in all this is that Swift very much wants to do searches on a
per-module basis, but Clang can only do lookups across the entire
TranslationUnit. Unless and until we get a better way to deal with this,
we're stuck with an inefficiency here. Previously, we used to hack around
this by ignoring the "per-module" bit and only performing one lookup into
all Clang modules, but that's not actually correct with respect to visibility.

Now, we're just taking the filtering hit for looking up a particular name,
and caching the results when we look up everything (for code completion).
This isn't ideal, but it doesn't seem to be costing too much in performance,
at least not right now, and it means we can get visibility correct.

In the future, it might make sense to include a ClangModuleUnit alongside a
SerializedASTFile for adapter modules, rather than having two separate
modules with the same name. I haven't really thought through this yet, though.

Swift SVN r10834
2013-12-05 01:51:11 +00:00
Jordan Rose
8b8cc8ee62 Turn SerializedModule into SerializedASTFile.
Part of the FileUnit restructuring. A serialized module is now represented as
a TranslationUnit containing a single SerializedASTFile.

As part of this change, the FileUnit interface has been made virtual, rather
than switching on the Kind in every accessor. We think the operations
performed on files are sufficiently high-level that this shouldn't affect us.

A nice side effect of all this is that we now properly model the visibility
of modules imported into source files. Previously, we would always consider
the top-level imports of all files within a target, whether re-exported or
not.

We may still end up wanting to distinguish properties of a complete Swift
module file from a partial AST file, but we can do that within
SerializedModuleLoader.

Swift SVN r10832
2013-12-05 01:51:09 +00:00
Dmitri Hrybenko
d076501cca Don't repeat Context.getIdentifier("self") everywhere in the code base
Swift SVN r10786
2013-12-04 18:42:34 +00:00
Joe Groff
111dd0c248 ClangImporter: Use type name to clip prefix from single-element enums.
Single-case enums actually come up a lot for NS_OPTIONS. Jordan suggested this approach, which works well for now.

Swift SVN r10473
2013-11-14 23:41:37 +00:00
Joe Groff
a1f123350f Enable NS_OPTIONS import by default.
Some work needs to be done on static member lookup and bitwise operations, but what's implemented now isn't a regression from what we have (except for an unfortunate case in Foundation.swift where we need to fully qualify a constant in a single-element NS_OPTIONS).

Swift SVN r10471
2013-11-14 23:21:28 +00:00
Joe Groff
fdd858dd21 ClangImporter: Import NS_OPTIONS constants as static properties.
Apply the same prefix-chopping logic as for NS_ENUM to produce static property names to put inside the Swift type we create. For now, continue importing NS_OPTIONS as structs with a single integer field; in the short term it's easy to put a C-like interface over them this way.

Swift SVN r10434
2013-11-13 23:19:32 +00:00
Joe Groff
975382599e ClangImporter: Rename 'EnumKind::Options' to 'Unknown'.
We're going to implement a newer, better path for 'Options'. No functionality change yet.

Swift SVN r10430
2013-11-13 20:58:06 +00:00
Joe Groff
4f2adbe7ed AST: Include 'static' bit in VarDecls.
And track the 'static' SourceLoc in the PatternBindingDecl. This lets isInstanceMember return the right thing for static vars.

Swift SVN r10369
2013-11-12 06:16:48 +00:00
Joe Groff
774db24a8a Enable importing of NS_ENUMs as Swift enums.
A problem with name lookup from Clang module contexts <rdar://problem/15410928> means I have to disable a ~= overload in the ObjectiveC overlay. Other than that, NS_ENUM import should be ready to go.

Swift SVN r10018
2013-11-07 03:49:37 +00:00
Joe Groff
65632a59a4 ClangImporter: Don't register imported case decls.
This keeps the unqualified enum constant name from sneaking back in after the enum has been imported.

Swift SVN r10016
2013-11-07 03:49:27 +00:00
Joe Groff
c16f7778e2 ClangImporter: Don't expose NS_ENUM cases by their unqualified names.
Only import NS_ENUM constants into Swift enum cases as part of the enum itself, not if the original C constant name is referenced by itself through the Clang module.

Swift SVN r10015
2013-11-07 01:16:08 +00:00
Joe Groff
96d1038c8c ClangImporter: Drop enum constant aliases.
Swift enums don't yet support aliasing of enum cases, so if we see multiple constants in an NS_ENUM with the same underlying value, drop all but the first. Hopefully the first one is the "proper" name for the constant.

Swift SVN r10008
2013-11-06 22:40:08 +00:00