Commit Graph

6196 Commits

Author SHA1 Message Date
John McCall
f416dd81a8 Track whether a PatternBindingDecl theoretically
declares storage or not.

Swift SVN r12942
2014-01-24 22:46:22 +00:00
Jordan Rose
4844f22475 Special-case the standard library to always live relative to the compiler.
Import "swift" will now only find "swift.swiftmodule", and only in the
runtime import path.

<rdar://problem/15898866>

Swift SVN r12932
2014-01-24 20:10:26 +00:00
Dave Zarzycki
6eba6ceeeb Zap accumlated unused variable warnings in non-assert builds
Swift SVN r12861
2014-01-23 08:11:37 +00:00
Dave Abrahams
d58caea0cd Revert "Zap accumlated warnings in non-assert builds"
This reverts r12850, which broke the build for me.

Swift SVN r12856
2014-01-23 06:47:29 +00:00
Greg Parker
2b6bee7fb8 Add an importer mapping for C va_list.
This is necessary on 32-bit arm, where va_list's canonical type is void*. 
Without a typedef-based mapping the importer would drop declarations used 
by the NSStringAPI bridge because they appear to have void* parameters.

This mapping does not work on x86_64. SwiftTypeConverter::VisitTypedefType() 
never sees va_list on that architecture only, perhaps due to that 
architecture's unusual definition of __builtin_va_list. The default mapping 
to COpaquePointer plus the conversion CVaListPointer=>COpaquePointer 
is still in place for that architecture. 


Swift SVN r12853
2014-01-23 06:17:15 +00:00
Dave Zarzycki
17eb84d9c6 Zap accumlated warnings in non-assert builds
Swift SVN r12850
2014-01-23 05:45:24 +00:00
Jordan Rose
d6281b74f8 [ClangImporter] For now, don't import properties with custom accessor names.
Instead, just import them as a pair of methods. This is obviously suboptimal,
but better than the alternative in which you can see the property, but
attempting to use the accessor with the customized name results in a crash
at runtime.

Swift SVN r12755
2014-01-22 18:27:58 +00:00
Argyrios Kyrtzidis
79be625ff7 For ClangImporter::verifyAllModules() be defensive and avoid verifying while
iterating the map of imported decls.

Swift SVN r12720
2014-01-22 07:10:35 +00:00
Jordan Rose
d1a68b5bf7 [ClangImporter] When importing members, don't use a forward declaration.
The canonical Clang decl is often not the same as the definition decl.
Fixes a bug introduced in r12685.

Swift SVN r12689
2014-01-22 02:43:28 +00:00
Doug Gregor
d52cec4b20 Eliminate a pile of literal identifiers for self, init, destructor, etc.
... because I can't stomach adding another one of these.


Swift SVN r12687
2014-01-22 01:09:49 +00:00
Jordan Rose
5299a502d0 [ClangImporter] Import class, protocol, and category members lazily.
This still isn't /that/ lazy because a lot of things can force member
deserialization (such as the type-checker generating a DestructorDecl for
every imported class), and we don't do this in a member-granular way just
yet. I don't see any change in testing time, for example.

But besides just being a good thing in general, this perturbs the order
of imported decls enough to fix <rdar://problem/15799697>: we can now
reliably see that there is a -URL:something: function on NSObject that
blocks any properties named 'URL' from being imported as properties.

(Which we don't actually want; see <rdar://problem/15456130>.)

Swift SVN r12685
2014-01-22 00:54:47 +00:00
Doug Gregor
d9515a506a Rename NSObjectProto -> NSObjectProtocol <rdar://problem/15775859>
Swift SVN r12660
2014-01-21 21:44:45 +00:00
Doug Gregor
e4854c320a Update use of Clang APIs for Clang r199686.
Swift SVN r12631
2014-01-21 01:34:52 +00:00
Doug Gregor
d6523742af Fix typo in comment. NFC
Swift SVN r12610
2014-01-20 21:13:10 +00:00
Jordan Rose
b49b91eee0 Don't import Objective-C ivars at all.
Direct access to ivars is very rare in our frameworks, and they can conflict
with property names (which we should prefer). On top of that, we weren't
even emitting the right code to access them correctly.

<rdar://problem/15818047>

Swift SVN r12604
2014-01-20 19:06:07 +00:00
Doug Gregor
7cd716227f Import non-prototyped functions as if they have no parameters <rdar://problem/15084122>.
Swift SVN r12598
2014-01-20 18:42:50 +00:00
Chris Lattner
f5b85341a1 Expand out the "isComputed" property in AbstractStorageDecl to be an enum
with two kinds, and some more specific predicates that clients can use.

The notion of 'computed or not' isn't specific enough for how properties
are accessed.  We already have problems with ObjC properties that are 
stored but usually accessed through getters and setters, and a bool here
isn't helping matters.

NFC.



Swift SVN r12593
2014-01-20 18:16:30 +00:00
Chris Lattner
7e67fdb30a decls always can get to an ASTContext, remove the unneeded
ASTContext argument from VarDecl::setComputedAccessors.


Swift SVN r12538
2014-01-18 20:04:05 +00:00
Argyrios Kyrtzidis
90fa27f1b6 [AST] Introduce Module::isSystemModule() which is rather self-explanatory.
Swift SVN r12474
2014-01-17 07:33:49 +00:00
Doug Gregor
1bd15b7b17 Clean up handling of getter/setter thunks. <rdar://problem/14109713>
Swift SVN r12461
2014-01-17 04:23:11 +00:00
Jordan Rose
d53863b3a3 Don't provide an SDK by default.
Hardcoding a path to a particular SDK is definitely the wrong thing to do.
Let's see how far we can get without setting a default SDK.

See discussion in <rdar://problem/14395800>

Swift SVN r12414
2014-01-16 20:08:07 +00:00
Jordan Rose
ae3feb845a [ClangImporter] Fix the visible decls cache to handle new modules being loaded.
This can happen when importing a decl causes a new Swift module to be loaded
(because it uses one of our bridged types), which then brings in a new Clang
module. In this case we have no choice but to throw out the existing cache
and start over. We do keep a map of everything we've imported already, though,
so at least we don't have to do that part again.

This appears to make r12309 unnecessary for correctness, but it probably still
makes performance more consistent.

<rdar://problem/15785883>

Swift SVN r12336
2014-01-15 19:13:38 +00:00
Doug Gregor
535d03687b Infer the requires_stored_property_inits attribute for NSManagedObject.
Swift SVN r12316
2014-01-15 05:11:52 +00:00
Jordan Rose
f03e4a6f7e [ClangImporter] Make lookupVisibleDecls deterministic.
Clang's LookupVisibleDecls is implemented by iterating over the map of lookups,
which clearly isn't deterministic. This *shouldn't* be a problem, but it
seems our importer has non-determinism based on the order it sees decls.
For now, at least, let's make this deterministic up front so that we don't get
weird results from :print_module.

See <rdar://problem/15785883> and <rdar://problem/15799697>.

Swift SVN r12309
2014-01-15 01:39:31 +00:00
Jordan Rose
d68721f89c [ClangImporter] Put enums in their canonical module as well.
Swift SVN r12262
2014-01-14 00:30:44 +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
46fb1e8db9 More clang importer feedback from Doug and John
"long" isn't sufficiently portable C but "ptrdiff_t" and "{int,uint}ptr_t" are close enough.

Swift SVN r11951
2014-01-06 21:03:27 +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
Jordan Rose
b1b50a134e Autolinking: include all imported modules.
Although Cocoa.framework re-exports AppKit, Foundation, and CoreData, an
arbitrary library does not re-export most of its imports. Normally this
would be fine, but the Clang importer can pull in types too eagerly and
then generate thunks and wrappers for things we don't care about. At least
for now, return to the behavior of autolinking /anything/ that gets visibly
imported.

<rdar://problem/15705923>

Swift SVN r11844
2014-01-03 01:21:11 +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
9ae289de46 Drive the semantic wedge harder into lvalues. Now, instead of having one LValueType
with qualifiers on it, we have two distinct types:
 - LValueType(T) aka @lvalue T, which is used for mutable values on the LHS of an
   assignment in the typechecker.
 - InOutType(T) aka @inout T, which is used for @inout arguments, and the implicit
   @inout self argument of mutable methods on value types.  This type is also used
   at the SIL level for address types.

While I detangled a number of cases that were checking for LValueType (without checking
qualifiers) and only meant @inout or @lvalue, there is more to be done here.  Notably,
getRValueType() still strips @inout, which is totally and unbearably wrong.



Swift SVN r11727
2013-12-29 22:23: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
Dmitri Hrybenko
ed8521f34a Rename ObjCSel -> Selector
Swift SVN r11476
2013-12-19 18:44:12 +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