Commit Graph

1896 Commits

Author SHA1 Message Date
Graydon Hoare
0cab561a7f [NamedLazyMemberLoading] Enable all clang::ObjCContainerDecl types. 2017-11-01 17:34:56 -07:00
Graydon Hoare
30b6fdce83 Merge pull request #12429 from graydon/named-lazy-member-loading
Named lazy member loading 1/N
2017-10-24 14:27:04 -07:00
Jordan Rose
d09669b0df Merge pull request #12169 from jrose-apple/dance-dance-deduplication
[ClangImporter] Don't add duplicate search paths
2017-10-24 11:43:13 -07:00
Graydon Hoare
cb1c8526c8 [NamedLazyMemberLoading] Address further review comments. 2017-10-20 22:48:45 -07:00
Graydon Hoare
ca3101c2af [NamedLazyMemberLoading] Sketch implementation of named protocol-member loading. 2017-10-20 22:48:43 -07:00
Jordan Rose
b53967fd19 [ClangImporter] Handle macros that are undefined and then redefined (#12413)
This includes 'LONG_MAX' in the Darwin module, which is defined by the
system and then immediately redefined by Clang's copy of limits.h.

The general strategy here is that if two definitions of a macro in the
same module are in separate explicit submodules, we need to keep track
of both of them, but if they're in the same explicit submodule then
one is probably deliberately redefining the other. This isn't fully
correct because one explicit submodule could include another explicit
submodule, but it's a good first approximation, which we can refine if
we come across problem cases in practice.

Swift /also/ has the ability to distinguish between ModuleA.MACRO and
ModuleB.MACRO if you've imported both modules, although there's an
issue that the two of them end up getting the same mangled name if you
try to use both in the same compilation unit. (Filed
rdar://problem/34968281.) That ability is preserved with this change.

All of this will likely change if/when we switch to Clang's "local
submodule visibility" mode, which is needed for the C++ Modules TS but
is also incompatible with Apple's SDKs at the moment. In that case,
macros in two separate explicit submodules will no longer have an
'override' relationship just because they're mentioned sequentially in
the module map.

rdar://problem/34413934
2017-10-13 15:08:51 -07:00
Jordan Rose
f331060ba7 [ClangImporter] Don't add duplicate search paths
Besides saving some calls to stat(), this also causes problems when
the user specifies a search path that Clang already adds by default,
like $SDKROOT/Library/Frameworks/. Why? Because Swift adds its search
paths after Clang has already configured its defaults, but Clang
reconfigures its search paths from scratch when compiling a module to
a PCM file to cache. This led to system search paths being found
sooner in the primary Clang instance than in the PCM files, which in
turn resulted in the PCM files being considered out of date.

This isn't likely to affect people much in practice, but it's better
to get right. (We ran into this during Doug's experiments in making
/System/Library/PrivateFrameworks a default search path in Clang
r313317; turns out that's problematic for other reasons as well.)

rdar://problem/34664596
2017-09-29 10:00:02 -07:00
Doug Gregor
bdc5afd69f Merge pull request #11955 from DougGregor/rexported-module-cleanup
Minor cleanups for the work to handle re-exported modules
2017-09-18 11:36:28 -07:00
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