Commit Graph

1889 Commits

Author SHA1 Message Date
Jordan Rose
8410a9bdea [ClangImporter] Teach lookupValue to find top-level swift_private declarations.
Essentially, if we see a name that starts with "__", start the whole process
again.

Part of rdar://problem/20070465

Swift SVN r29428
2015-06-17 01:46:15 +00:00
Jordan Rose
615a32ae11 [ClangImporter] Handle swift_private renaming for a variety of imported decls.
...including structs and struct fields, enums and enum cases, typedefs,
protocols, classes, and properties.

The main problem is that this /doesn't/ handle top-level /lookup/, so you
can't actually find any of these renamed types. This is fixed in the next
commit.

This does not handle methods, subscripts, or initializers.

Part of rdar://problem/20070465

Swift SVN r29427
2015-06-17 01:46:14 +00:00
Jordan Rose
7cc910b39a [ClangImporter] Add a version of importName that takes a clang::NamedDecl.
At this point this is just for convenience, but see next commit.

Swift SVN r29426
2015-06-17 01:46:13 +00:00
Jordan Rose
a696730061 [ClangImporter] Remove suffix appending from importName.
This isn't used anymore. No functionality change.

Swift SVN r29425
2015-06-17 01:46:12 +00:00
Jordan Rose
6658c94988 [ClangImporter] Consistently name Swift->Clang helpers "export*".
If Clang->Swift functions are named "import*" ("importDecl", "importName",
etc.), then clearly Swift->Clang functions should be called "export*".
(Originally we called both directions "import", but recent additions have
used "export" for Swift->Clang instead.)

No functionality change.

Swift SVN r29424
2015-06-17 01:46:06 +00:00
Jordan Rose
cb2ca7d997 [ClangImporter] Remap factory methods according to the swift_name attr.
On a factory method, swift_name can have two effects:

- If the custom name has a base name of "init", import the method as an
  initializer, even if it doesn't follow the usual naming conventions.
- Otherwise, import the method as a method, even if it /would have/ been
  imported as an initializer.

There's a bit of trickiness around NSError**: currently you have to specify
the name of the error parameter on the Clang side even if it's going to be
deleted on the Swift side. We may want to change this later.

The test cases here exposed the issues in the previous two commits,
so this effectively depends on those for passing tests.

More of rdar://problem/19240897.

Swift SVN r28979
2015-05-24 01:48:24 +00:00
Argyrios Kyrtzidis
d9032c0e39 [IDE] Make sure that ClangImporter::lookupDeclsFromHeader forwards to the passed in filter
function and that filter receives macros as well.

Swift SVN r28971
2015-05-23 20:20:27 +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
Dmitri Hrybenko
8c41d4d4ca SDK overlay: actually request new APIs from CoreImage
Swift SVN r28831
2015-05-20 17:36:07 +00:00
Dmitri Hrybenko
ea17483633 Add CMake options and #ifs to hide tvOS
Swift SVN r28752
2015-05-19 05:15:52 +00:00
Adrian Prantl
70279d192f Disable module debug info generation when -detailed-preprocessing-record
is enabled.

rdar://problem/20898265

This reapplies r28503 with a testcase and a corrected condition.

Swift SVN r28624
2015-05-15 16:15:01 +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
Jordan Rose
6786158edb [ClangImporter] Always sort top-level value lookups from Clang.
The order of lookups affects the order of imports, which can sadly end up
causing different behavior down the line.

The sort is by Clang TU source order, which isn't wonderful but should be
consistent. There are generally fewer decls without source locations that
come from Clang.

Swift SVN r28578
2015-05-14 20:10:59 +00:00
Devin Coughlin
4b23d4a219 Update clang importer and target platform detection for watchOS.
For the moment, we do not consider APIs deprecated earlier than watchOS 2.0 as
unavailable. rdar://problem/20948019 track changing this once the ultimate
decision on this policy has been made.

This addresses the compile-time components of rdar://problem/20774229

Swift SVN r28559
2015-05-14 04:20:43 +00:00
Adrian Prantl
f8c52caa37 Revert "Disable module debug info generation when -detailed-preprocessing-record"
This reverts commit r28503 while investigating Linux buildbot breakage.

Swift SVN r28535
2015-05-13 21:48:28 +00:00
Adrian Prantl
5a20c4d026 Disable module debug info generation when -detailed-preprocessing-record
is enabled.

rdar://problem/20898265

Swift SVN r28503
2015-05-13 03:13:49 +00:00
Ted Kremenek
9be9444242 Adjust overlay to CoreImage nullability changes.
Implements rdar://problem/20645743.

Swift SVN r28490
2015-05-12 22:15:03 +00:00
Argyrios Kyrtzidis
f000fcd383 [IDE] For header interface printing, include macros and module imports.
Swift SVN r28413
2015-05-11 06:48:28 +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
Dmitri Hrybenko
0453656f31 Adapt to Foundation API modernization: NSRectEdge is now an enum
This commit adds the initializers requested in rdar://20169260.

Swift SVN r28185
2015-05-05 22:50:59 +00:00
Dmitri Hrybenko
3c30738fc1 Adjust to SpriteKit nullability annotations in the new SDKs
Swift SVN r28136
2015-05-04 23:18:14 +00:00
Devin Coughlin
4f366b1ff6 Do not treat iOS as active on tvOS.
Change the active-platform availability logic to not consider iOS as active on
tvOS. We want all of the messiness of the fact that tvOS was branched
from iOS to be handled in clang, which "transcribes" iOS availability attributes
to their corresponding tvOS counterparts as long as there is not an
existing explicit tvOS availability attribute on the declaration.

This change exposed several places where I needed to add explicit handling of
of tvOS and where we will need to handle watchOS as well.
rdar://problem/20774229 tracks adding logic and tests to handle watchOS in these
places.

It is also unfortunately the case that llvm::triple returns true when isiOS()
is called on tvOS. This means that to test whether an llvm:triple target is
really iOS, we need to check for iOS then check explicitly that it is not
tvOS. We will eventually change llvm's behavior here so that the double
check is not needed.

Swift SVN r28013
2015-05-01 01:54:24 +00:00
Dmitri Hrybenko
dbf1daeb0a Finish the SceneKit overlay for -[SCNSceneSource entryWithIdentifier:withClass:]
rdar://20384835

Swift SVN r27899
2015-04-29 02:22:31 +00:00
John McCall
a00b7f01e4 Strip "AndReturnError" from method base names when removing
an initial error out-parameter.

rdar://20722195

Swift SVN r27865
2015-04-28 08:53:24 +00:00
Doug Gregor
2c909b4d36 Remove Objective-C selector splitting options.
We're not going this way.

Swift SVN r27717
2015-04-25 03:59:00 +00:00
Jordan Rose
9ac30474e3 [ClangImporter] Avoid doing import work after type checking is done.
I haven't been able to come up with a small reduced test case, and I don't
think I'm likely to in the near future, so I'd like to commit this for now.
This fixes the particular crash reported in rdar://problem/19975256, but
not the general problem. I have a heavier solution for that too, but don't
want to commit it just yet when I don't even have a test for this commit.

rdar://problem/19975256

Swift SVN r27196
2015-04-10 01:31:27 +00:00
John McCall
d62a154e29 Import ObjC method error-handling conventions. WIP.
Swift SVN r27193
2015-04-10 00:32:54 +00:00
Jordan Rose
b94f7a249e [Importer] Update CF_ENUM detection for changes in Foundation.
...and bump our "Foundation epoch" guard to 3 to match.

Long-term we should switch to an attribute for "yes, this is really a set
of enumerated constants" (and "this is a set of related bitmask options"),
but this unblocks things for now, and doesn't cause any issue if we end
up doing something else.

rdar://problem/20418505

Swift SVN r26944
2015-04-03 18:43:53 +00:00
Dmitri Hrybenko
ab408d4dc3 Update the compiler and SDK overlay for nullability and generics in Foundation
We have an SPI between the Swift compiler and Foundation based on the
SWIFT_SDK_OVERLAY_FOUNDATION_EPOCH preprocessor macro that allows us to
request the new API.  rdar://20270080 tracks removing it.

Swift SVN r26475
2015-03-24 02:18:06 +00:00
Argyrios Kyrtzidis
2931543a2f Revert "XFAIL failing IDE tests while BenL investigates. rdar://20245658."
This reverts commits r26369 & r26381.
After upstream clang changes, reverted r25843 which was compensating for a previous upstream clang change.

But keep test/IDE/complete_from_clang_framework.swift disabled for further investigation, because it
seems to have some duplications in a code-completion test.

rdar://20245658&20247922

Swift SVN r26430
2015-03-23 07:24:27 +00:00
David Farler
544ef4002d Merge tvOS and watchOS Support
- Add frontend and standard library build support for tvOS.
- Add frontend support for watchOS.

watchOS standard library builds are still disabled during SDK bring-up.

To build for TVOS, specify --tvos to build-script.
To build for watchOS, specify --watchos to build-script (not yet supported).

This patch does not include turning on full tests for TVOS or watchOS, and
will be included in a follow-up patch.

Swift SVN r26278
2015-03-18 21:35:07 +00:00
Jordan Rose
edf3bb460d [ClangImporter] Ignore deprecated enum constants when computing prefixes.
This fixes the import of enums like NSCalendarUnit, which changed from
NSXXXCalendarUnit to NSCalendarUnitXXX, as has been the guideline in
recent years. Now even when the old names are present, we can still
prefix-strip based on the new names. If /all/ options are deprecated,
though, we'll prefix-strip as we did before.

Note that we /don't/ check the current deployment target for this,
because we want to use the "nice" names as soon as we have an SDK where
they're available, not when the deployment target matches such an SDK.

rdar://problem/17686122

Swift SVN r26184
2015-03-16 18:01:45 +00:00
Graham Batty
0c281d5a23 Use --sysroot instead of -isysroot on non-Darwin
Clang does not properly set up the include root on non-darwin
platforms with -isysroot, so use --sysroot on those platforms
instead.

Swift SVN r26102
2015-03-13 16:32:09 +00:00
Adrian Prantl
9d14113bf3 Adapt for Mach-O clang module container format transition.
NOTE: This may require deleting the Module Cache that build-script
       creates in the swift build dir.

rdar://problem/19104245

Swift SVN r26021
2015-03-12 02:00:56 +00:00
Adrian Prantl
83fce2670e Revert "Adapt for Mach-O clang module container format transition."
This reverts commit 25995 (this commit was missing a few LLVM libraries).

Swift SVN r26020
2015-03-12 02:00:55 +00:00
Adrian Prantl
ae3d758fa8 Adapt for Mach-O clang module container format transition.
NOTE: This may require deleting the Module Cache that build-script
       creates in the swift build dir.

Swift SVN r25995
2015-03-11 22:55:37 +00:00
Argyrios Kyrtzidis
e813673dc3 [ClangImporter] Make sure that we are not importing re-declarations, after upstream
Clang change in r231424.

Also re-enable the disabled IDE tests.
rdar://20064024

Swift SVN r25843
2015-03-07 07:14:33 +00:00
Jordan Rose
5554cec143 [ClangImporter] Don't inherit initializers as designated...
...even if they were designated in the base class. (Unless they're required,
in which case they're still required.)

This led to Swift subclasses treating convenience initializers as
designated initializers, which (if synthesized) led to properties being
initialized twice.

rdar://problem/19730160

Swift SVN r25410
2015-02-20 02:26:55 +00:00
Doug Gregor
5e3d50f92c Stop defining CF_ENABLE_BRIDGED_TYPES[_SO_YOU_CAN_FIX_BUILD_FAILURES].
These macros are dead in the SDKs we care about.

Swift SVN r25325
2015-02-16 21:59:58 +00:00
Jordan Rose
c51004bf04 [ClangImporter] Don't try to load things if there's been a fatal Clang error.
This should help us avoid crashes like rdar://problem/19798049 in the future.
Of course, since fatal errors are so rare, I don't have a way to test this,
but it isn't breaking any of the paths we currently use.

rdar://problem/19827938

Swift SVN r25285
2015-02-13 22:43:12 +00:00
Ben Langmuir
518e6dc870 Remove unnecessary calculation of Clang's default module cache
Now that we use the Clang driver instead of cc1 we can make clang figure
out its own default module cache path if one isn't provided.

Swift SVN r24924
2015-02-03 20:34:41 +00:00
Denis Vnukov
cd0fe7192d Fix for rdar://18898671, Xcode 6.4-6D94: SourceKit crash in swift::ClangModuleUnit::getFilename()
Minor: ClangModuleUnit::getFilename() used to crash if clangModule->getASTFile() is nullptr



Swift SVN r24922
2015-02-03 20:31:05 +00:00
Ben Langmuir
791f2ff549 Utilize 'requires' feature of module maps to exclude frameworks from Swift
Adds a module feature 'swift' to the Clang arguments so that we can make
modules unavailable if they contain
  requires !swift

Swift SVN r24913
2015-02-03 01:49:05 +00:00
Dmitri Hrybenko
9ac070a545 Install Clang builtin headers in the Clang resource dir
Also, stop installing Clang builtin headers in Apple B&I builds.  We
will rely on real Clang headers.

Swift SVN r24675
2015-01-23 03:09:56 +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
Jordan Rose
a3a6c2695b Put the current target into LangOptions.
This has been long in coming. We always had it in IRGenOpts (in string form).
We had the version number in LangOpts for availability purposes. We had to
pass IRGenOpts to the ClangImporter to actually create the right target.
Some of our semantic checks tested the current OS by looking at the "os"
target configuration! And we're about to need to serialize the target for
debugging purposes.

Swift SVN r24468
2015-01-16 02:48:54 +00:00
Jordan Rose
93a89467b8 [ClangImporter] Hide old API from the Carbon days.
This affects the MacTypes.h header in the Darwin module as well as the
CarbonCore and OSServices sub-frameworks of the CoreServices framework.
API hidden in this way can still be accessed through qualified lookup
in case it's really needed, but will not appear in the module interface
or in code completion.

This is a hack, and it would be nice to remove it if/when all of this API
is officially marked as deprecated. I did check with Nick for MacTypes.h
and Chris Linn from CoreServices that this was a reasonable action to take.

rdar://problem/16806148

Swift SVN r24424
2015-01-14 19:27:45 +00:00
Dmitri Hrybenko
d9ffea1604 Update for upstream changes in ObjCMethodList API
Swift SVN r24160
2014-12-28 07:36:05 +00:00
Joe Groff
6e74b5c21b IRGen: Base our clang::CodeGenOptions on those from the Clang instance.
Use the CodeGenOptions the Clang frontend determined for the compiler instance instead of starting from scratch, so that we pick up important settings like '-mstackrealign'. Fixes the GLKit test on iOS. rdar://problem/19180367

Swift SVN r23792
2014-12-08 23:29:27 +00:00