Commit Graph

1889 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
d9813b1bf5 [sdk-analyzer] Check if a clang decl was associated with a swift one from stdlib.
rdar://19063509

Swift SVN r23560
2014-11-23 05:51:26 +00:00
Argyrios Kyrtzidis
a72c0e50c2 [ClangImporter] Expose a couple of functions in ClangImporter.
- getClangSema()
- shouldIgnoreMacro() which returns true if it is expected that a clang macro is ignored.

Swift SVN r23468
2014-11-20 05:08:36 +00:00
Ben Langmuir
e9e1666ab0 Update for upstream LLVM changes
* removal of StringMap's GetOrCreateValue
* SmallSet::insert now returns a pair like std::set

Swift SVN r23435
2014-11-19 16:49:30 +00:00
Joe Groff
8aba14a353 ClangImporter: Learn about SWIFT_ENUM and Swift-originated ObjC enums.
This allows @objc enums to work in mixed-source frameworks.

Swift SVN r23426
2014-11-19 04:03:12 +00:00
Doug Gregor
9effe201f0 Adjust to api_notes::NullableKind -> clang::NullabilityKind renaming.
Synchronized with the Clang renaming of NullableKind.

Swift SVN r23315
2014-11-14 01:07:42 +00:00
Doug Gregor
420cf73385 Adjust to removal of NullableKind::Absent; it's captured by Optionals now.
Synchronized with Clang.

Swift SVN r23314
2014-11-14 01:07:38 +00:00
Doug Gregor
aa41a5ce1b Revert "Update uses of Clang's NullableKind -> Nullability."
This reverts commit ad91cc5b7f0482938397a40f81c4fafcd6718d2a.

Swift SVN r23290
2014-11-12 23:18:43 +00:00
Doug Gregor
f204351e7e Implement Clang importer support for finding Objective-C methods by selector.
This functionality doesn’t really change what we accept right now, because we eagerly import all of the methods of a class when we do *any* kind of lookup into the class. However, when we manage to stop doing that, this operation will become more important.

Swift SVN r23289
2014-11-12 23:18:42 +00:00
Doug Gregor
5c245f8a5a Update uses of Clang's NullableKind -> Nullability.
Synchronized with a Clang commit; please update your Clang along with Swift.

Swift SVN r23279
2014-11-12 18:15:55 +00:00
Chris Willmore
f723b05672 Don't remove 'with' from ObjC method arg name if resulting name is keyword.
Also, remove calls to isSwiftReservedName in
ClangImporter::Implementation::importName(), since 'true' and 'false'
are now keywords and rdar://problem/13187570 is no longer a problem.

rdar://problem/18797808

Swift SVN r23244
2014-11-11 19:34:53 +00:00
Jordan Rose
5aa60308a6 [ClangImporter] Don't mistake a module being built for our dummy buffer.
The ClangDiagnosticConsumer forwards diagnostics from Clang's diagnostic machinery
to Swift's. It deliberately filters out things that happen in our top-level dummy
buffer (usually trivial things like "module imported here"). Unfortunately, it was
doing so by checking against the current SourceManager's "main file". When building
Clang modules (compiling PCM files), we're dealing with a new SourceManager, whose
main file is the module map file.

Instead, just check against the (very unlikely) name of our dummy input file,
like we do for imported headers.

rdar://problem/18867749

Swift SVN r23121
2014-11-05 23:10:19 +00:00
Jordan Rose
39649f6eee [ClangImporter] Handle empty selector pieces for AnyObject method lookup.
Previously this resulted in a crash.

rdar://problem/18746476

Swift SVN r22981
2014-10-28 02:46:18 +00:00
Argyrios Kyrtzidis
bc26ff6c85 [ClangImporter] Since we can handle them now, enable clang diagnostic warnings in the importer.
Swift SVN r22728
2014-10-14 15:03:08 +00:00
Dmitri Hrybenko
d2d12d9932 ClangImporter: refactor construction of the Clang argument list
according to review comments

Swift SVN r22483
2014-10-02 22:25:39 +00:00
Jordan Rose
042569a3be Optional: Replace uses of Nothing with None.
llvm::Optional (like Swift.Optional!) uses None as its placeholder value,
not Nothing.

Swift SVN r22476
2014-10-02 18:51:42 +00:00
Dmitri Hrybenko
27601ff089 ClangImporter: use GNU11 C language mode on non-Darwin
Other platforms are assumed not to have an Objective-C runtime now.

Swift SVN r22460
2014-10-02 09:28:14 +00:00
Jordan Rose
49a6c8eb7b Do all target info management in Clang, and drop -target-abi / -target-feature.
Previously we hardcoded a few important default CPUs, ABIs, and features into
Swift's driver, duplicating work in Clang. Now that we're using Clang's
driver to create the Clang "sub-compiler", we can delegate this work to Clang.

As part of this, I've dropped the options for -target-abi (which was a
frontend-only option anyway) and -target-feature (which was a hidden driver
option and is a frontend-only option in /Clang/). We can revisit this later
if it becomes interesting. I left in -target-cpu, which is now mapped
directly to Clang's -mcpu=.

Swift SVN r22449
2014-10-01 23:55:40 +00:00
Jordan Rose
30c65eff7e [ClangImporter] Use Clang's driver to handle options, not its frontend.
This is most important for -Xcc options, which shouldn't be dependent on
the underlying Clang version, but it also affects things like target features
that Clang knows how to compute correctly and Swift, well, doesn't.

rdar://problem/17687572

Swift SVN r22448
2014-10-01 23:55:35 +00:00
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