Commit Graph

888 Commits

Author SHA1 Message Date
Jordan Rose
82fa3627a8 Merge pull request #11867 from jrose-apple/ClangImporter-episode-V
[ClangImporter] Support Swift 5 API notes
2017-09-15 16:34:27 -07:00
Doug Gregor
fc20debc36 Jump through hoops to avoid adding a new Serialization -> clang::Module dependency. 2017-09-15 14:42:36 -07:00
Jordan Rose
9a04bee421 [ClangImporter] Turn ImportNameVersion into a struct.
...so that we don't have to keep coming back to update it every major
release. And also so we can actually put methods on it instead of
using free functions.

No intended behavior change (yet).
2017-09-15 14:30:24 -07:00
Jordan Rose
90f728a68e [ClangImporter] Check for failure in forEachDistinctName
forEachDistinctName might produce the same name for Swift 4 and Swift
5, but it's possible that for some reason the name will only work in
one mode or the other. In that case, even though we're trying the
"same" name again, we still want to invoke the callback once more.
Add a boolean return to the callback to support this.

Tests to come at the end of this patch series -- this shows up when in
Swift 3 mode and the canonical version for types is set to Swift 5.
2017-09-15 14:30:24 -07:00
Doug Gregor
21e34d78d8 const'ify an API's parameters. NFC 2017-09-15 13:52:13 -07:00
Doug Gregor
e5ebb5854f Treat entities from (private) modules as members of the re-exported module.
A public C module can be expressed as the combination of several
private modules at build time, where that structure is "collapsed"
into a single public module for client use. In such cases, the symbols
associated with the public module can actually be seen as coming from
the private module (e.g. at the time the Swift overlay is built),
which fools our overlay-specific hacks. When a module states that it
is re-exported via another, public module, teach semantic analysis to
treat the entity "as if" it came from the re-exporting public module.

Part of rdar://problem/34438586.
2017-09-14 15:09:18 -07:00
Doug Gregor
583a9c42ea [AST] Factor out the "is this in an overlay" check. 2017-09-14 15:09:18 -07:00
Jordan Rose
264ac94c44 [ClangImporter] Update for Clang-side removal of the API notes cache. (#11793)
No need to pass -fapinotes-cache-path anymore.

Non-critical follow-up for rdar://problem/31745420.
2017-09-06 17:42:33 -07:00
Jordan Rose
f8b7db4e76 Excise the terms "blacklist" and "whitelist" from Swift source. (#11687)
The etymology of these terms isn't about race, but "black" = "blocked"
and "white" = "allowed" isn't really a good look these days. In most
cases we weren't using these terms particularly precisely anyway, so
the rephrasing is actually an improvement.
2017-08-30 09:28:00 -07:00
Jordan Rose
61746b39ab [ClangImporter] Stop abusing a Clang API to avoid a use-after-free. (#11377)
In order to allow LLDB to debug an app as it was written (in theory),
we stuff a semi-preprocessed version of the bridging header into the
generated swiftmodule file, so that we can fall back on it if the
original bridging header is deleted. The specific functionality we
want is in Clang's -rewrite-includes option, but we need to write to
an in-memory buffer instead of a file.

The existing code took the meat of clang::RewriteIncludesAction and
recreated it manually. We got away with this in the past, but upstream
Clang has changed how clang::RewriteIncludesAction works, and now what
we were doing before results in the (unused) file output stream being
deallocated before the (also unused) buffering stream wrapped around
it. Rather than continue trying to half-use an existing Clang
FrontendAction, just make a new one that does the thing we want and
nothing else.

I'd like to revisit this whole idea in the future -- it doesn't
actually preserve debuggability in the case where the bridging header
may have changed, because we don't check for modifications in all the
things it includes. But for now this should preserve the existing
functionality.

rdar://problem/33693128
2017-08-07 19:10:52 -07:00
Jordan Rose
5d053d95a4 [ClangImporter] Restore proper macro shadowing rules.
Last follow-up to c3d6be64ab. Already covered by
test/ClangImporter/macros_redef.swift.

rdar://problem/32199805
2017-07-26 15:42:31 -07:00
swift-ci
6d7415e0da Merge remote-tracking branch 'origin/master' into master-next 2017-07-25 22:09:00 -07:00
John McCall
c893e955aa Propagate "-O" to Clang (as "-Os").
It affects Clang IRGen, among other things.
2017-07-26 00:32:08 -04:00
swift-ci
b4016dde18 Merge remote-tracking branch 'origin/master' into master-next 2017-07-25 06:08:49 -07:00
Kosuke Ogawa
ba12f51315 [Gardening] Fix typo: necesary -> necessary 2017-07-25 18:09:24 +09:00
swift-ci
5b15da4b32 Merge remote-tracking branch 'origin/master' into master-next 2017-07-17 14:08:49 -07:00
Jordan Rose
bc460a2321 [ClangImporter] Add fast-path lookup for error code enums as well.
These are also imported as local types, so they can have the same
issues as the previous commit.
2017-07-17 11:52:48 -07:00
Jordan Rose
925f2913f8 [ClangImporter] Add direct access for import-as-member types.
This avoids having to bring in all members (and extensions!) for an
outer type just to look up a nested type. In the test case attached
(reduced from the project in SR-5284), this actually led to a circular
dependency between deserialization and the importer, which resulted in
a compiler crash.

This is not a new problem, but it's more important with the release of
Swift 4, where a number of Apple SDK types are now newly imported as
member types. (The one in the original bug was
NSView.AutoresizingMask, formerly NSAutoresizingMaskOptions.) Since we
always use the Swift 4 name for cross-references, this affected
everyone, even those still compiling in Swift 3 mode.

https://bugs.swift.org/browse/SR-5284
2017-07-13 17:56:40 -07:00
swift-ci
58f59b23c5 Merge remote-tracking branch 'origin/master' into master-next 2017-07-13 12:08:58 -07:00
Vivian Kong
7fe35b4d78 Set default CPU for s390x to support conversion between unsigned integers and floating point numbers (#9647) 2017-07-13 11:20:25 -07:00
Bob Wilson
583613607e master-next: update rdar://problem/30287833 fix to work with clang r301992 2017-07-12 09:40:54 -07:00
swift-ci
e0782d0448 Merge remote-tracking branch 'origin/master' into master-next 2017-07-11 13:29:16 -07:00
swift-ci
e98182387b Merge remote-tracking branch 'origin/master' into master-next 2017-07-11 12:23:35 -07:00
Alex Hoppen
f8c2692f79 Introduce special decl names
Special DeclNames represent names that do not have an identifier in the
surface language. This implies serializing the information about whether
a name is special together with its identifier (if it is not special)
in both the module file and the swift lookup table.
2017-07-11 19:04:13 +02:00
Jordan Rose
d30d4bc8f1 [ClangImporter] Honor -show-diagnostics-after-fatal. (#10808)
Clang's equivalent of this is mapping fatal errors to non-fatal errors.
This isn't something we really care about for users since it's so rare,
but we do use it in our tests, like this one that's been disabled for
a long time.

rdar://problem/30287833
2017-07-07 07:33:03 -07:00
Bob Wilson
a77cfdf3b2 Update ASTReader argument to match Clang r306760. 2017-07-05 11:56:00 -07:00
Michael Gottesman
78713ce07f Merge pull request #10519 from jrose-apple/ModuleMacro-master-next
WIP getting master-next up and running with clang::ModuleMacro
2017-06-30 14:52:09 -07:00
Arnold Schwaighofer
a72b685927 Merge remote-tracking branch 'origin/master' into master-next 2017-06-30 12:21:33 -07:00
David Farler
645aaad551 [index/build] Upstream indexing while building changes
This patch upstreams previously AppleInternal changes for
indexing while building.
2017-06-29 16:20:06 -07:00
Greg Parker
7b009eccde Merge remote-tracking branch 'origin/master' into master-next 2017-06-28 15:25:17 -07:00
Doug Gregor
6a26f5f044 [Clang importer/module printing] Correctly print NS_ERROR_ENUMs.
Ever since we stopped associating the top-level struct of an imported
NS_ERROR_ENUM with the Clang enum declaration, we've been unable to
print imported NS_ERROR_ENUMs. The module-printing infrastructure
would drop them thinking they aren't imported declarations.

This also affected NS_ERROR_ENUMs that were imported as members of
another type, as well as other types imported as members.

Fixes rdar://problem/32497693.
2017-06-27 17:01:29 -07:00
Alex Hoppen
949968a182 Adjust printing to take into account special DeclNames
Print DeclBaseNames using a new userFacingStr() method to prepare for
DeclBaseNames that are not backed by Identifiers
2017-06-24 11:39:09 +02:00
Jordan Rose
c3d6be64ab WIP Update to use clang::ModuleMacro instead of clang::MacroInfo.
Untested and still missing a few pieces.
2017-06-23 16:04:24 -07:00
Arnold Schwaighofer
318be46e6b We also need to pass a min-vers string to the ClangImporter when running under the embed-bitcode mode
Otherwise, it will return the wrong triple when queried.

rdar://32863670
2017-06-22 13:22:04 -07:00
Jordan Rose
65391ccac5 [ClangImporter] Don't pass API notes options when compiling bitcode. (#10422)
Avoids a bogus "argument unused" warning, since bitcode compilation
doesn't bother to set up much of a Clang AST context. (-embed-bitcode
compiles in two steps: source -> bitcode, then bitcode -> object
file. This is about the second step.)

Patch by Bob Wilson, who's currently on vacation but wanted this to
get in sooner rather than later.

rdar://problem/31372950
2017-06-20 16:02:34 -07:00
Bob Wilson
e108c568db Remove Filename parameter from BeginSourceFileAction to match clang r305045. 2017-06-12 10:53:06 -07:00
swift-ci
336787e622 Merge remote-tracking branch 'origin/master' into master-next 2017-05-28 19:48:35 -07:00
Alex Hoppen
6871a76965 [ClangImporter] Preparations for removal of getName on ValueDecl
With the introduction of special decl names, `Identifier getName()` on
`ValueDecl` will be removed and pushed down to nominal declarations
whose name is guaranteed not to be special. Prepare for this by calling
to `DeclBaseName getBaseName()` instead where appropriate.
2017-05-28 19:13:24 -07:00
swift-ci
3ccbd4bae8 Merge remote-tracking branch 'origin/master' into master-next 2017-05-28 18:08:53 -07:00
Jordan Rose
c0ccdb1626 Change getBaseName to return DeclBaseName instead of Identifier (#9968)
This changes `getBaseName()` on `DeclName` to return a `DeclBaseName`
instead of an `Identifier`. All places that will continue to be
expecting an `Identifier` are changed to call `getBaseIdentifier` which
will later assert that the `DeclName` is actually backed by an
identifier and not a special name.

For transitional purposes, a conversion operator from `DeclBaseName` to
`Identifier` has been added that will be removed again once migration
to DeclBaseName has been completed in other parts of the compiler.

Unify approach to printing declaration names

Printing a declaration's name using `<<` and `getBaseName()` is be
independent of the return type of `getBaseName()` which will change in
the future from `Identifier` to `DeclBaseName`
2017-05-28 17:55:03 -07:00
swift-ci
d55ac42101 Merge remote-tracking branch 'origin/master' into master-next 2017-05-16 10:28:39 -07:00
Jordan Rose
ec23dcaaac [ClangImporter] Find Swift 3 / 4 names via dynamic lookup too.
Finishes rdar://problem/29170671
2017-05-13 14:53:18 -07:00
swift-ci
4e305bf9ce Merge remote-tracking branch 'origin/master' into master-next 2017-05-12 20:28:32 -07:00
David Farler
b9dfbf45d8 [ClangImporter] API reaction to clang::CompilerInstance::getModuleHash
getModuleHash in clang now takes a diagnostic engine to get more
information for uniquing the hash - this change was only needed
for swift-4.0-branch, so we're making the API adjustment here.

rdar://problem/32145037
2017-05-12 17:03:35 -07:00
swift-ci
4c56317e58 Merge remote-tracking branch 'origin/master' into master-next 2017-05-12 07:48:34 -07:00
Argyrios Kyrtzidis
c4b5b60d00 [Driver/ClangImporter] Changes for the driver to recognize -pch-output-dir and propagate to the frontend invocations
For the multiple-files mode -emit-pch is still invoked in separate frontend invocation but with using a persistent PCH.
Subsequent frontend invocations use the persistent PCH but they don't need to validate it.

For all-files mode (e.g. WMO) the frontend invocation uses a persistent PCH that it also validates.
2017-05-11 11:44:12 -07:00
swift-ci
4ebe4afe2a Merge remote-tracking branch 'origin/master' into master-next 2017-05-09 13:28:49 -07:00
Argyrios Kyrtzidis
8df20d7bab [ClangImporter] For ClangImporter::getOrCreatePCH() don't verify/update the PCH if it is explicit
If the PCH is explicit use it directly; do the verify+update only for when we create an 'implicit' PCH via the -pch-output-dir option.
2017-05-09 08:18:09 -07:00
Argyrios Kyrtzidis
7e7a6300ea "[ClangImporter] For ClangImporter::canReadPCH(), reuse the existing clang::HeaderSearch object and create a main FileID for the new clang::SourceManager 2017-05-09 07:44:27 -07:00
Argyrios Kyrtzidis
398cdf0de0 [ClangImporter] For ClangImporter::canReadPCH() do a ReadAST invocation to verify if the PCH is up-to-date or not
isAcceptableASTFile() was only doing a configuration check and did not do a full check, e.g. if the dependencies are out-of-date.
2017-05-08 23:11:06 -07:00