Commit Graph

162 Commits

Author SHA1 Message Date
Max Moiseev
3a3984877a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-15 15:43:34 -08:00
Xi Ge
9ff84e145d [CodeCompletion] For submodules, also use ASTContext to collect their visibility. 2016-02-10 13:03:17 -08:00
Max Moiseev
61c837209b Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-04 16:13:39 -08:00
Doug Gregor
74d4ccbf4f Bring back ClangImporter::shouldIgnoreMacro() 2016-02-03 20:06:32 -08:00
Doug Gregor
8e000fb738 [Clang importer] Factor mapping of macro names into a single location. NFC 2016-02-03 16:11:59 -08:00
Doug Gregor
1a830fa541 SE-0022: Deprecate string-literal-as-selector in favor of #selector.
Introduce Fix-Its to aid migration from selectors spelled as string
literals ("foo:bar:", which is deprecated), as well as from
construction of Selector instances from string literals
(Selector("foo:bar"), which is still acceptable but not recommended),
to the #selector syntax. Jump through some hoops to disambiguate
method references if there are overloads:

    fixits.swift:51:7: warning: use of string literal for Objective-C
         selectors is deprecated; use '#selector' instead
      _ = "overloadedWithInt:" as Selector
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          #selector(Bar.overloaded(_:) as (Bar) -> (Int) -> ())

In the cases where we cannot provide a Fix-It to a #selector
expression, we wrap the string literal in a Selector(...) construction
to suppress the deprecation warning. These are also easily searchable
in the code base.

This also means we're doing more validation of the string literals
that go into Selector, i.e., that they are well-formed selectors and
that we know about some method that is @objc and has that
selector. We'll warn if either is untrue.
2016-01-28 10:58:27 -08:00
Doug Gregor
8674f9d318 [Clang importer] Enable inference of default arguments by default 2016-01-06 16:36:36 -08:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
practicalswift
f91525a10f Consistent placement of "-*- [language] -*-===//" in header. 2016-01-04 09:46:20 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Max Moiseev
a7339e67ac Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-22 11:36:07 -08:00
Doug Gregor
3932797480 Implement Clang module's "getTopLevelDecls" using the Swift lookup tables.
Various interface-printing facilities use getTopLevelDecls to
enumerate the top-level declarations of a given module. For modules
imported from Clang, this walked a giant cached list of all
declarations known from Clang, then filtered out those that didn't
fit. Instead, just use the information provided by the Swift name
lookup tables, which is inherently module-specific and complete.
2015-12-21 16:01:21 -08:00
Max Moiseev
2f7b64e475 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-21 12:02:13 -08:00
Doug Gregor
68e819069f Clang importer: bring back lookupValue() for LLDB's sake.
... but implemented in terms of the lookup tables.
2015-12-21 11:31:17 -08:00
Doug Gregor
19894754d4 Clang importer: delete most of the old name lookup path. NFC
We now use the Swift name lookup tables for all of these lookups, so
start deleting the older, more ad hoc paths.
2015-12-21 10:30:38 -08:00
Doug Gregor
ae6b41dc37 Clang importer: enable the Swift name lookup tables by default.
Fixes rdar://problem/14776565 (AnyObject lookup for Objective-C
properties with custom getters) and rdar://problem/17184411 (allowing
__attribute__((swift_name("foo"))) to work on anything).
2015-12-21 09:55:21 -08:00
practicalswift
cd7d8dfaff Fix alignment as requested by @gribozavr in #692 2015-12-21 08:54:24 +01:00
practicalswift
176f487d76 Fix incorrect filenames in headers. 2015-12-20 23:59:05 +01:00
Doug Gregor
e05ca0560f Omit needless words requires the use of Swift name lookup tables.
Only the Swift name lookup tables can handle the remapping produced by
the "omit needless words" flag.
2015-12-18 15:10:25 -08:00
Doug Gregor
2f5f94a12c Merge remote-tracking branch 'origin/swift-3-api-guidelines' into swift-3-omit-needless-words 2015-12-15 17:11:37 -08:00
Doug Gregor
563bdb9156 Clang importer: remove support for implicit properties.
We decided not to support "implicit" properties, where we import
getter/setter pairs as properties. Rather, we only import a property
when there is an explicit "@property" in Objective-C. Remove the flag
and supporting code for implicit properties.
2015-12-14 14:33:07 -08:00
Doug Gregor
06c5e9cd5b Enable "omit needless words" by default.
Most of this is in updating the standard library, SDK overlays, and
piles of test cases to use the new names. No surprises here, although
this shows us some potential heuristic tweaks.

There is one substantive compiler change that needs to be factored out
involving synthesizing calls to copyWithZone()/copy(zone:). Aside from
that, there are four failing tests:

    Swift :: ClangModules/objc_parse.swift
    Swift :: Interpreter/SDK/Foundation_test.swift
    Swift :: Interpreter/SDK/archiving_generic_swift_class.swift
    Swift :: Interpreter/SDK/objc_currying.swift

due to two independent remaining compiler bugs:
  * We're not getting partial ordering between NSCoder's
  encode(AnyObject, forKey: String) and NSKeyedArchiver's version of
  that method, and
  * Dynamic lookup (into AnyObject) doesn't know how to find the new
  names. We need the Swift name lookup tables enabled to address this.
2015-12-11 14:46:50 -08:00
Doug Gregor
c2bf16c0a9 Clang importer: start building a Swift name -> Clang declarations table.
When we parse a bridging header, start building a mapping from Swift
names (both base names and full names) to the Clang declarations that
have those names in particular Clang contexts. For now, just provide
the ability to build the table (barely) and dump it out; we'll grow
it's contents in time.
2015-12-03 11:50:39 -08:00
Xi Ge
280124fcf8 [CodeComplete] Hold a local copy of module names instead of referencing them. 2015-11-10 13:19:26 -08:00
Xi Ge
827ea69fd3 [CodeComplete] Mark already-imported modules as not-recommended. rdar://23209864
When auto-completing import decls, we should prioritize not-yet imported modules
over already-imported modules. To do so, we mark the latter with not-recommended tag.
2015-11-10 11:57:29 -08:00
Xi Ge
0f881f5ad7 [CodeComplete] Add code completion for Clang sub-modules at import decls. rdar://23244877
e.g. completing at "import Foundation.<HERE>" should give the list of the submodules of Foundation.

Swift SVN r32852
2015-10-24 00:22:25 +00:00
Doug Gregor
44b8d45288 Clean up inference of default arguments from imported APIs (mostly).
My temporary hackery around inferring default arguments from imported
APIs was too horrible. Make it slightly more sane by:

1) Actually marking these as default arguments in the type system,
rather than doing everything outside of the type system. This is a
step closer to what we would really do, if we go in this
direction. Put it behind the new -frontend flag
-enable-infer-default-arguments.

2) Only inferring a default argument from option sets and from
explicitly "nullable" parameters, as stated in the (Objective-)C API
or API notes. This eliminates a pile of spurious, non-sensical "=
nil"'s in the resulting output.

Note that there is one ugly tweak to the overloading rules to prefer
declarations with fewer defaulted arguments. This is a bad
implementation of what is probably a reasonable rule (prefer to bind
fewer default arguments), which intentionally only kicks in when we're
dealing with imported APIs that have default arguments.

Swift SVN r32078
2015-09-18 21:50:59 +00:00
Michael Gottesman
59099b627f [ClangImporter] Make DetailedPreprocessingRecord a first-class option.
...though not one we set from the command line.

Swift SVN r31806
2015-09-09 04:37:23 +00:00
Jordan Rose
a1ad2908b4 Use Clang's mangler for __attribute__((overloadable)) functions.
At some point we should probably just use Clang's mangler for all imported
functions, but I didn't want to rock the boat.

Swift SVN r31249
2015-08-14 19:50:28 +00:00
Doug Gregor
284d8e52cf Introduce an option to omit needless words when importing from Clang.
The -enable-omit-needless-words option attempts to omit needless words
from method names imported from Clang. Broadly speaking, a word is
needless if it merely restates the type of the corresponding parameter,
using reverse camel-case matching of the type name to the
function/parameter name. The word "With" is also considered needless
if whether follows it is needless, e.g.,

  func copyWithZone(zone: NSZone)

gets reduced to

  func copy(zone: NSZone)

because "Zone" merely restates type information and the remaining,
trailing "With" is also needless.

There are some special type naming rules for builtin Objective-C types,
e.g.,

  id -> "Object"
  SEL -> "Selector"
  Block pointer types -> "Block"

as well as some very-Cocoa-specific matching rules, e.g., the type
"IndexSet" matches the name "Indexes" or "Indices".

Expect a lot of churn with these heuristics; this is part of
rdar://problem/22232287.

Swift SVN r31178
2015-08-12 18:21:45 +00:00
Doug Gregor
a92cb576c4 Remove the ErrorHandling option from the Clang importer.
It was always-on; this was just for staging.

Swift SVN r31145
2015-08-11 20:24:12 +00:00
Jordan Rose
3028dc8f44 Failure to load a bridging header -> failure to load a module.
This is important for both test targets and for debugging.

rdar://problem/20616099

Swift SVN r30784
2015-07-30 00:39:35 +00:00
Xi Ge
af589ebaa7 [InterfacePrinting] Print missing import decls from Swift module instance. rdar://20695897
Swift SVN r30588
2015-07-24 20:44:21 +00:00
Jordan Rose
0e3e08f0c6 [ClangImporter] Use Clang's -fembed-bitcode mode when under -embed-bitcode.
This should have no functionality change, but is supposed to keep us from
accidentally relying on the "full" Clang importer when in a backend job.
I tested it by archiving a little iOS app from a developer.

Unfortunately, part of the motivation here was that we'd get error messages when
we pass something Clang doesn't like, and that doesn't seem to be happening.

rdar://problem/21389553

Swift SVN r30407
2015-07-20 17:23:51 +00:00
Jordan Rose
b1c4ae4287 [ClangImporter] Expose getEnumConstantName for use in the debugger.
rdar://problem/21640482

Swift SVN r29892
2015-07-02 17:29:30 +00:00
Argyrios Kyrtzidis
9917e74533 [IDE] Support printing the header interface for a header, that belongs to a clang module
that the clang invocation is importing.

Fully addresses rdar://21067984

Swift SVN r28962
2015-05-23 08:14:59 +00:00
Jordan Rose
c129637bf6 Name lookup: avoid even calling lookup code on Clang submodules.
This is a hack.

We currently don't put anything in Clang submodules; they're just wrappers
to track what is and isn't visible. All lookups happen through the top-
level module.

This commit adds a new API getImportedModulesForLookup, which is ONLY used
by top-level name lookup and forAllVisibleModules. It is identical to
getImportedModules for everything but ClangModuleUnits, which instead
compute and cache a list of their transitively imported top-level modules.

This speeds up building Foundation.swiftmodule with a release compiler by
a bit more than 5%, and makes a previously lookup-bound test case compile
a third faster than before.

This is a hack.

rdar://problem/20813240

Swift SVN r28598
2015-05-15 01:26:05 +00:00
Joe Groff
cef754de45 Update ClangImporter to map SIMD types to their C-like Swift counterparts.
Swift SVN r28386
2015-05-09 23:03:39 +00:00
Joe Groff
95d1cf5e6d Revert "ClangImporter etc.: Remap C vector types to nested BaseType.VectorN types."
Reverts r28087. We're going back to the C++ interface for SIMD, and the changes in this patch are needless complication for that design.

Swift SVN r28384
2015-05-09 23:03:33 +00:00
Argyrios Kyrtzidis
3df7a35683 [IDE] Speed up header interface printing.
Instead of importing everything and filtering later (so all of clang modules get deserialized and associated Swift decls get created),
lazily import as Swift decls only the Clang decls that we need from a particular header.

This also fixes printing ObjC categories in the header as Swift extensions.

Swift SVN r28358
2015-05-09 02:03:51 +00:00
Doug Gregor
b8995b0aa3 Transform the Module class into ModuleDecl.
Modules occupy a weird space in the AST now: they can be treated like
types (Swift.Int), which is captured by ModuleType. They can be
treated like values for disambiguation (Swift.print), which is
captured by ModuleExpr. And we jump through hoops in various places to
store "either a module or a decl".

Start cleaning this up by transforming Module into ModuleDecl, a
TypeDecl that's implicitly created to describe a module. Subsequent
changes will start folding away the special cases (ModuleExpr ->
DeclRefExpr, name lookup results stop having a separate Module case,
etc.).

Note that the Module -> ModuleDecl typedef is there to limit the
changes needed. Much of this patch is actually dealing with the fact
that Module used to have Ctx and Name public members that now need to
be accessed via getASTContext() and getName(), respectively.

Swift SVN r28284
2015-05-07 21:10:50 +00:00
Joe Groff
d0473756ec ClangImporter etc.: Remap C vector types to nested BaseType.VectorN types.
The design we landed on for SIMD is to define the vector types as nested types of their element, e.g. Float.Vector4, Int32.Vector2, etc. Update the Clang importer and other mapping facilities to match.

Swift SVN r28087
2015-05-02 15:04:43 +00:00
John McCall
5a153b60d6 Remove the affirmative -import-error-handling option.
We may want to add a -no-import-error-handling option for
project staging, but there's no need for the positive form.

Swift SVN r28049
2015-05-01 20:41:41 +00:00
Joe Groff
58660ec6ba PrintAsObjC: Support for SIMD types.
Splat out a bunch of typedefs for the small vector types we want to support, and map the SIMD.* types to them.

Swift SVN r27385
2015-04-16 22:07:09 +00:00
Joe Groff
47eedc3c08 Sema: Consider SIMD types as representable in ObjC.
Corresponding PrintAsObjC and GenClangType parts to follow.

Swift SVN r27384
2015-04-16 22:07:03 +00:00
John McCall
f2cb782451 Add the -import-error-handling option (and ignore it for now).
Swift SVN r27192
2015-04-10 00:32:50 +00:00
Jordan Rose
f0d529719c Deduplicate search paths.
Now that we can pick up search paths from frameworks (necessary to debug
them properly), we can end up with exponential explosions leading to the
same search path coming up thousands of times, which destroys compilation
time /and/ debugger responsiveness. This is already hitting people with
frameworks compiled for app extensions (due to a mistaken approximation
of whether or not something is a framework), but we're turning this on for
all frameworks in the immediate future.

rdar://problem/20291720

Swift SVN r27087
2015-04-07 18:24:12 +00:00
Dmitri Hrybenko
61286f0260 Fix warnings produced by a newer version of Clang
Swift SVN r25257
2015-02-12 23:50:47 +00:00
Jordan Rose
8ee17a4d0d Serialize search paths when building an app, for a better debugging experience.
There's also a testing option, -serialize-debugging-options, to force this
extra info to be serialized even for library targets. In the long run we'll
probably write out this information for all targets, but strip it out of
the "public module" when a framework is built. (That way it ends up in the
debug info's copy of the module.)

Incidentally, this commit includes the ability to add search paths to the
Clang importer on the fly, which is most of rdar://problem/16347147.
Unfortunately there's no centralized way to add search paths to both Clang
/and/ Swift at the moment.

Part of rdar://problem/17670778

Swift SVN r24545
2015-01-20 03:02:54 +00:00