Commit Graph

1889 Commits

Author SHA1 Message Date
Doug Gregor
4130bb15ff Add a whitelist of designated initializers and use it in the Clang importer.
Seed the whitelist with the designated initializers for NSObject,
NSDocument, and UIDocument. We'll grow this list over time.
Fixes <rdar://problem/16521299>.


Swift SVN r16013
2014-04-07 15:06:59 +00:00
Doug Gregor
7e8d5f7cfe Use a different selector encoding in the .def file that allows nullary selectors. NFC.
Swift SVN r16012
2014-04-07 14:17:43 +00:00
Doug Gregor
0364e0b977 Assert that the # of selector pieces matches the # of method arguments.
Swift SVN r15985
2014-04-05 06:54:14 +00:00
Doug Gregor
57d54cacee Clang importer: add a hardwired table mapping selectors to method names.
Regardless of the heuristic we choose when importing Objective-C
selectors into Swift method names, there will be poor cases. Allow us
to bake specific mappings into the compiler so we can address those
cases without having to modify the Objective-C headers.

Part of <rdar://problem/16341485>.


Swift SVN r15984
2014-04-05 06:52:38 +00:00
Doug Gregor
c78a3ecd48 Clang importer: cache the result of the selector -> method mapping.
Swift SVN r15983
2014-04-05 06:04:01 +00:00
Doug Gregor
6baa7eb35c PrintAsObjC: Emit objc_runtime_name attributes for Swift classes.
This makes sure that Clang uses the mangled class names for
Swift-defined classes. Should be last compiler-side piece of
<rdar://problem/15506580>.


Swift SVN r15977
2014-04-05 04:45:21 +00:00
Doug Gregor
7102f1bb0b Clang importer: add a statistic for trailing prepositions in the first selector piece.
Swift SVN r15887
2014-04-03 18:08:01 +00:00
Doug Gregor
104cfe8919 Clang importer: add some statistics related to selector splitting.
Swift SVN r15873
2014-04-03 16:10:13 +00:00
Doug Gregor
08e7797f86 [Selector splitting] Drop non-directional prepositions from the beginning of imported argument names.
Swift SVN r15865
2014-04-03 14:22:20 +00:00
Doug Gregor
87144a8afa Make splitFirstSelectorPiece() static, now that it has just one caller
Swift SVN r15854
2014-04-03 04:20:10 +00:00
Doug Gregor
708bb64c6f Migrate initializer importing over to importMethodType().
We now consistently use the method name to form the types of
Objective-C methods.


Swift SVN r15851
2014-04-03 03:32:09 +00:00
Doug Gregor
e418e93511 Start cleaning up method name importing.
Import a selector into a Swift method name, performing splitting at
that point. Use the resulting method name to determine the argument
names of the parameters, rather than trying to chop up the selector
again. There's more refactoring to do here.

This fixes a longstanding bug where the first argument of an
Objective-C method got the internal parameter name when it should
have gotten no name at all.

Swift SVN r15850
2014-04-03 00:34:40 +00:00
Doug Gregor
527b147ba7 Revert "Allow the first name of a selector-style function declaration to be separated."
This reverts r15140.

Conflicts:
	include/swift/Serialization/ModuleFormat.h
	lib/Parse/ParsePattern.cpp

Swift SVN r15846
2014-04-02 23:27:52 +00:00
Doug Gregor
12d0eeb324 Move more of the Clang importer's camelCase logic to the new utilities.
Swift SVN r15843
2014-04-02 23:06:22 +00:00
Doug Gregor
6496d69cb8 Simplify down to a single command-line option for preposition splitting.
Swift SVN r15835
2014-04-02 21:44:19 +00:00
Argyrios Kyrtzidis
23bd9a1933 [ClangImporter] Add ClangImporter::getClangModuleHash().
Swift SVN r15809
2014-04-02 17:39:10 +00:00
Doug Gregor
d6a173fead Add some utilities for working with camelCase names.
Swift SVN r15802
2014-04-02 15:18:32 +00:00
John McCall
c163b30f1e Enable importing ObjC pointers as UncheckedOptional.
There's no point in maintaining a driver option for this
because of the extent of the library changes required to
make it work.

Swift SVN r15784
2014-04-02 09:37:16 +00:00
Doug Gregor
9189145cc5 Change DeclName over to basename(arg1:arg2:...argN:).
Swift will use the basename + argument names formulation for
names. Update the DeclName interfaces, printing, and __FUNCTION__ to
use the method syntax.

We'll still need to rework the "x.foo:bar:wibble:" syntax; that will
come (significantly) later.

Swift SVN r15763
2014-04-02 00:00:03 +00:00
Dmitri Hrybenko
c2354eb365 USR generation: generate USRs for imported macros
I do feel bad about introducing ClangModuleLoader, but it is better than a
layering violation (using libClangImporter from libAST).


Swift SVN r15679
2014-03-31 15:13:00 +00:00
Dmitri Hrybenko
286b309970 Return macros in visible decl lookup
This affects code completion and module interface printing.


Swift SVN r15577
2014-03-28 11:15:12 +00:00
Dmitri Hrybenko
1d6c76c352 Module interface printing: pass through documentation comments for imported
declarations

rdar://16408910


Swift SVN r15576
2014-03-28 10:54:06 +00:00
Argyrios Kyrtzidis
d084edd951 [ClangImporter] Add ClangImporter::getClangOwningModule() for a ClangNode.
Swift SVN r15549
2014-03-27 05:01:12 +00:00
Ted Kremenek
8162660be6 Wire up basic driver support for App Extension restrictions.
The frontend/driver flag is "-application-extension'.  This
activates a language option which will be used for more restrictive
availability checking.

Operationally, this also passes...
  - "-fapplication-extension" to the clang importer
  - "-application_extension" to ld

Swift SVN r15543
2014-03-27 01:05:43 +00:00
Dmitri Hrybenko
f3faddefb4 Don't return macros in visible decl lookup, this crashes inside Clang while
doing code completion from Cocoa module


Swift SVN r15529
2014-03-26 21:49:18 +00:00
Dmitri Hrybenko
92b29ef045 Revert "Module interface printing: pass through documentation comments for
imported declarations"

rdar://16408910


Swift SVN r15527
2014-03-26 21:28:42 +00:00
Jordan Rose
c2f2e7f3c3 [ClangImporter] Handle categories on partial interfaces.
Make sure to resolve a class's signature (which includes its @objc-ness)
before seeing if we should even try to look it up in Clang.

Swift SVN r15524
2014-03-26 21:08:51 +00:00
Dmitri Hrybenko
30c6eeff16 Module interface printing: pass through documentation comments for imported
declarations

rdar://16408910


Swift SVN r15511
2014-03-26 16:16:02 +00:00
Dmitri Hrybenko
962c924ab1 Clang importer: put macros into correct module and return them in visible decl
lookup


Swift SVN r15500
2014-03-26 10:27:44 +00:00
Jordan Rose
8d35d75ce3 [ClangImporter] Resolve forward class declarations to definitions in Swift.
When we see an unresolved @class in a Clang module, we check the class name
against the classes in the Swift module with the same name.

This unfortunately necessitates putting a reference to the active type checker
into the ClangImporter, because the class in the current Swift module hasn't
been type-checked yet. This is now being used everywhere we do a lookup.

<rdar://problem/16295994>

Swift SVN r15355
2014-03-22 00:19:59 +00:00
Doug Gregor
1a25251ea6 Selector splitting: "scaleXBy" is three words, not two.
Swift SVN r15299
2014-03-20 21:38:04 +00:00
Doug Gregor
024b8d655c When splitting before a preposition, do so even if nothing follows the preposition.
This is more consistent.


Swift SVN r15298
2014-03-20 21:27:12 +00:00
Doug Gregor
5d0abd9849 Another preposition splitting option: directional prepositions.
Swift SVN r15297
2014-03-20 21:24:57 +00:00
Doug Gregor
b71a67616e Add option to split after the last preposition.
Swift SVN r15264
2014-03-20 04:01:40 +00:00
Doug Gregor
e03cb7c0a0 Don't split when the preposition is the last word in the first selector piece.
Swift SVN r15244
2014-03-19 20:15:50 +00:00
Dmitri Hrybenko
52c69d038f Selector splitting: use ASCII-only APIs to process strings, and align detection
of 'init' method family with Clang (it looks like 'init123' would count as init
method in Clang, but not in the initial implementation of selector splitting in
Swift).


Swift SVN r15189
2014-03-18 12:04:49 +00:00
Dmitri Hrybenko
bca2205b29 Try harder at reverting the commit that disallowed importing "new"
Swift SVN r15188
2014-03-18 11:43:22 +00:00
Doug Gregor
730211196c Use escaped identifiers rather than restricting the importer.
I completely forgot about this feature. This tests the previous commit
to make escaped identifiers work.

Swift SVN r15179
2014-03-18 01:05:45 +00:00
Doug Gregor
1f5fce95c1 Preposition splitting: don't name a method "new" due to splitting.
It turns out that "new" is a truly awful reserved word to have in the
land of Cocoa.

Swift SVN r15176
2014-03-18 00:45:02 +00:00
Doug Gregor
e5fff12bf0 Add option to split Objective-C selectors based on the last preposition.
The frontend option -split-objc-selectors splits the first part of an
Objective-C selector into both a function name and the first parameter
name at the last preposition. For example, this Objective-C method:

  - (NSString *)stringByPaddingToLength:(NSUInteger)newLength withString:(NSString *)padString startingAtIndex:(NSUInteger)padIndex

is imported as

  func stringByPadding toLength(newLength: Int) withString(padString: String) startingAtIndex(padIndex: Int) -> String




Swift SVN r15156
2014-03-17 20:34:48 +00:00
Jordan Rose
c7804dc779 When loading a Swift framework module, see if it's also a Clang module.
In a framework containing both Clang headers and a Swift module, the Swift
module gets picked up first, but then automatically imports (and re-exports)
the Clang module as well.

One interesting case here is that it's possible for the Clang side to add
categories to a class declared in Swift. In order to support this, the
Clang importer can now find extensions for Swift classes marked @objc.
(I couldn't think of a way to test this separately; the previous commit
was supposed to do that, but worked without this change.)

<rdar://problem/16295937>

Swift SVN r15084
2014-03-14 22:21:08 +00:00
Jordan Rose
12964f2e27 [ClangImporter] Resolve generated header protocols to native decls as well.
This is the same as the previous commit, but for protocols. To do this I
had to modify the ObjC printer to include a SWIFT_PROTOCOL annotation like
the SWIFT_CLASS annotation already in use. This is probably a good thing
anyway.

Second half of <rdar://problem/16296027>

Swift SVN r14985
2014-03-13 00:19:12 +00:00
Jordan Rose
64debb657d [ClangImporter] Match up classes in generated headers with native classes.
This is necessary to handle Swift code using API defined in Objective-C
that itself uses classes defined in Swift. Protocols coming next.

First half of <rdar://problem/16296027>

Swift SVN r14984
2014-03-13 00:19:10 +00:00
Jordan Rose
949064bb06 [ClangImporter] For now, treat the runtime resources as user headers.
...so that the Clang module machinery will check that the generated pcm
is up-to-date.

We probably want this to be considered a system header in the long run,
but this is a quick fix for those working on the standard library.

<rdar://problem/16285900>

Swift SVN r14926
2014-03-11 21:12:05 +00:00
Joe Groff
8e2521e8c2 SILGen: Emit derived '==' operators from Clang modules with shared linkage.
In Sema, give derived '==' definitions the module's DerivedFileUnit as their decl context instead of the more general Module, and give it a backreference to the nominal type for which it was derived. 
In SILGen, visit the derived global decls associated with Clang-imported enums, and give them shared linkage. Part of fixing <rdar://problem/16264703>.

Swift SVN r14875
2014-03-10 20:33:54 +00:00
Joe Groff
5bb6c6a39c ClangImporter: Import ObjCMethod selector names as Swift DeclNames.
This gets selector references working for imported ObjC methods.

Swift SVN r14797
2014-03-07 22:43:05 +00:00
Jordan Rose
921f93ddf4 [ClangImporter] Allow importing modules even without an SDK.
In these cases, disable the standard system include paths so we don't
accidentally pick up headers in /.

This is going to be used by the runtime team for low-level interfaces with
C and Objective-C in the standard library.

Swift SVN r14789
2014-03-07 20:03:12 +00:00
Joe Groff
96c09d7179 Renovate name lookup to prepare for compound name lookup.
Make the name lookup interfaces all take DeclNames instead of identifiers, and update the lookup caches of the various file units to index their members by both compound name and simple name. Serialized modules are keyed by identifiers, so as a transitional hack, do simple name lookup then filter the results by compound name.

Swift SVN r14768
2014-03-07 03:21:29 +00:00
Jordan Rose
86a4f9998d [ClangImporter] Add ../lib/swift as an implicit import path.
This will allow us to ship headers that are used by the standard library.
They will be treated as system headers.

<rdar://problem/16227202>

Swift SVN r14757
2014-03-06 21:36:54 +00:00
Jordan Rose
a84f939545 [ClangImporter] Import string macros as CStrings.
Also, pass "-std=gnu11" so that we accept UTF-8 strings in these macros.

<rdar://problem/16198953>

Swift SVN r14664
2014-03-05 00:29:43 +00:00