Commit Graph

1896 Commits

Author SHA1 Message Date
Nathan Hawes
607e2b8822 Manually merge remote-tracking branch 'upstream/master' into HEAD 2020-08-04 13:47:48 -07:00
Alexis Laferrière
857dce953a Merge pull request #32966 from xymus/mcpu-flag-for-clang
[ClangImporter] Update clang invocation to use the marketing names of CPUs
2020-08-04 10:12:10 -07:00
Robert Widmann
a0af6e5d61 Always Make The Top-Level Module Visible
The Clang Importer currently has a ridiculous re-entrant submodule loading path that winds up doing this anyways. Take Darwin as a prime example.

import Darwin.C.tgmath

In theory, this should load Darwin.C.tgmath and its immediate clang-only dependencies. In practice, namelookup::getAllImports winds up asking for the overlay associated with Darwin.C.tgmath. In order to load the overlay, it walks to the top-level module (Darwin) and tries to load a module with that name. Becuase we're in the middle of loading Darwin while importing tgmath, and because the compiler does not distinguish the act of loading a module from the act of loading an overlay, the Clang Importer would re-enter itself. The net effect is that every submodule import of a clang module *always* loads the top-most module and makes it visible. So

import Darwin.C.tgmath

actually becomes

import Darwin.C.tgmath
import Darwin

As long as we're here, and because this doesn't seem to actually hurt anything, let's optimize for this behavior. If the top-level module is requested, we need not call finishLoadingClangModule twice, just return the wrapper module it gives back.

Eventually, we should tame this implicit behavior with respect to overlay module loading.
2020-08-03 11:31:29 -07:00
Robert Widmann
565478cfe9 [NFC] Drop a boolean in favor of clang::Module::NameVisibilityKind
The intent of the enum class is more immediately readable than a single bit that we're reconstituting into the enum class anyways.
2020-08-03 11:24:15 -07:00
Nathan Hawes
498e767765 Manually merge remote-tracking branch 'upstream/master' into merge-m-to-mr 2020-07-27 22:41:53 -07:00
Nathan Hawes
b0a2230860 Manually merge remote-tracking branch 'upstream/master' into merge-in-master 2020-07-27 09:25:01 -07:00
Varun Gandhi
1ddf4ff790 [Gardening] Use consistent style for referencing notes. 2020-07-25 23:36:17 -07:00
Varun Gandhi
7e34fb040a [ModuleTrace] More precise dependency tracking through ObjC.
We need to traverse the module dependency graph and track which modules expose
which other modules' ABIs, while making sure that we don't hit a loop while
trawling through Clang (sub)modules.

Fixes rdar://64993153.
2020-07-23 19:25:02 -07:00
Nathan Hawes
9d4ed5f39c Manually merge remote-tracking branch 'upstream/master' into manually-merge-master-to-master-rebranch 2020-07-20 16:09:55 -07:00
Alexis Laferrière
5730163f35 [ClangImporter] Update clang invocation to use the marketing names of CPUs
Update the clang invocation to use the marketing name of Apple CPUs.

rdar://problem/64918604
2020-07-19 14:18:08 -07:00
Nathan Hawes
244dc4a768 [AST] Rename PlatformKind::OSX to PlatformKind::macOS
Because the names are coming from a .def file used for printing too, this
simplifies the printing logic as well.
2020-07-08 16:29:31 -07:00
Michael Forster
8ab0f51a3c Merge pull request #32262 from martinboehme/replace-ishidden
Replace clang::Decl::isHidden() with clang::Sema::isVisible()
2020-07-08 19:05:42 +02:00
Argyrios Kyrtzidis
99c29145b2 [Serialization] Refactor subset of ModuleFile into ModuleFileSharedCore
The difference with `ModuleFile` is that `ModuleFileSharedCore` provides immutable data and is independent of a particular ASTContext.
It is designed to be able to be shared across multiple `ModuleFile`s of different `ASTContext`s in a thread-safe manner.
2020-07-06 00:44:36 -07:00
Mishal Shah
ca87af103b Merge pull request #32705 from apple/apple-silicon-master
[master] Apple Silicon support
2020-07-04 21:53:08 -07:00
Michael Forster
26358c4588 Import member operator functions as static members (#32293)
This adds support to `ClangImporter` to import C++ member function operators as static methods into Swift, which is part of SR-12748.

The left-hand-side operand, which gets passed as the `this` pointer to the C++ function is represented as an additional first parameter in the Swift method. It gets mapped back in SILGen.

Two of the tests are disabled on Windows because we can't yet call member functions correctly on Windows (SR-13129).
2020-07-03 11:06:22 +02:00
Mishal Shah
24e8e32f76 [Apple Silicon] [Platform] Default arm64 macOS and arm64 simulators to "vortex" CPU. 2020-07-02 18:26:12 -07:00
swift_jenkins
465eae8559 Merge remote-tracking branch 'origin/master' into master-next 2020-06-30 08:58:09 -07:00
Hamish Knight
7bc5440d17 [Frontend] Internalize createDependencyTracker
Expand the FrontendOptions to allow the enabling
of the dependency tracker for non-system
dependencies, and switch the previous clients of
`createDependencyTracker` over to using this
option. This ensures that the dependency tracker
is now set only during `CompilerInstance::setup`.
2020-06-29 15:26:26 -07:00
swift_jenkins
20ba5d3171 Merge remote-tracking branch 'origin/master' into master-next 2020-06-16 21:38:08 -07:00
Robert Widmann
057097a6c3 [NFC] Hide LoadedModules From Clients of ASTContext
There's no reason clients need to be able to access this data directly.
It obscures where module loading is actually happening, and makes it too
easy to accidentally register a module with the wrong identifier in the
context.

Hide the registration operations behind opaque accessors.
2020-06-16 15:09:19 -07:00
Adrian Prantl
d659ab0b78 Adapt to upstream changes in https://reviews.llvm.org/D81732 2020-06-12 10:13:26 -07:00
David Zarzycki
83966b2feb Track upstream clang API rename
In 2e92b397ae4bd846d34d151749ef09c1a1b81dab, `isHidden` was renamed and
the result polarity was inversed.
2020-06-12 08:47:50 -04:00
Martin Boehme
fc1cf3b203 Replace clang::Decl::isHidden() with clang::Sema::isVisible().
clang::Decl::isHidden() is misleadingly named (see the associated FIXME
comment) and doesn't do what we want when
`-fmodules-local-submodule-visibility` is turned on.

This change alone isn't unfortunately enough to make Swift work with
`-fmodules-local-submodule-visibility`. For one thing, Clang's
Objective-C component  doesn't work correctly with
`-fmodules-local-submodule-visibility`:

https://bugs.llvm.org/show_bug.cgi?id=46248

However, in the meantime, we should still clean up our use of
clang::Decl::isHidden().
2020-06-09 15:17:49 +02:00
Karoy Lorentey
57ea964f2c Merge commit '3eb82c183662945687f48e11c09828f551b34858' into master-next
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:58:37 -07:00
Karoy Lorentey
68351d2110 Revert "Merge remote-tracking branch 'origin/master-next'"
This reverts commit 1c9b0908e6, reversing
changes made to 3eb82c1836.
2020-06-08 16:48:38 -07:00
Karoy Lorentey
1c9b0908e6 Merge remote-tracking branch 'origin/master-next'
# Conflicts:
#	include/swift/Frontend/FrontendInputsAndOutputs.h
2020-06-08 16:43:40 -07:00
Robert Widmann
1d0065d136 Merge pull request #32145 from CodaFi/port-of-call
[NFC] Miscellaneous Cleanups To Clang Module Loading
2020-06-03 00:11:53 -07:00
Xi Ge
9e88549199 ModuleInterface: teach module interface building to use explicitly built PCMs 2020-06-02 16:51:45 -07:00
Xi Ge
3a214d99f6 Frontend: add an argument to disable implicitly built Swift modules 2020-06-02 16:51:45 -07:00
Robert Widmann
d2e1336af7 [NFC] Use getWrapperForModule to Simplify Clang Module Loading 2020-06-02 12:04:47 -07:00
Robert Widmann
c8077e8974 [Gardening] Add a SourceLoc For Cross-Import Overlay Diagnostics 2020-06-02 12:04:47 -07:00
Robert Widmann
a4bcbfab48 [NFC] Remove a Dead Parameter From Clang Module Loading
The only caller consuming the data that resulted from this bit has it
set to false. Additionally, the side effect of force-loading the
overlays is already handled unconditionally by the call to
namelookup::getAllImports.
2020-06-02 12:04:47 -07:00
swift_jenkins
68af9d595b Merge remote-tracking branch 'origin/master' into master-next 2020-05-22 20:18:30 -07:00
Xi Ge
e2b554d8ee Merge pull request #31922 from nkcsgexi/report-pcm-command
DependenciesScanner: report command-line arguments for building pcms explicitly
2020-05-22 20:12:36 -07:00
swift_jenkins
102ab6c4d3 Merge remote-tracking branch 'origin/master' into master-next 2020-05-22 13:40:25 -07:00
Xi Ge
38c0452d65 DependenciesScanner: report command-line arguments for building pcm explicitly 2020-05-22 07:50:08 -07:00
Hamish Knight
bc618a9763 [ClangImporter] Avoid calling into ObjCSelector lookup
The ClangImporter currently calls into
`ObjCSelector`'s `lookupDirect` in a couple of
places, stashing the selector in a DenseMap to try
and avoid re-entrancy problems.

However this will become a problem once
`ObjCSelector`'s `lookupDirect` is both
requestified and starts pulling in members from
the main module, so migrate the ClangImporter off
calling it.

Fortunately most of its uses only care about decls
with associated Clang nodes. For those cases, we
can use the existing member table, making sure to
populate it with any method we import.

In one case, the ClangImporter needs to check to
see if there's a deserialized Swift method with a
matching selector. Instead of calling through to
`lookupDirect`, let's just query the Swift module
loaders directly.
2020-05-21 09:19:02 -07:00
swift_jenkins
10e1981971 Merge remote-tracking branch 'origin/master' into master-next 2020-05-13 13:37:47 -07:00
Robert Widmann
eac92e3df0 [NFC] Const-Qualify LangOptions Accesses Through ASTContext 2020-05-13 09:13:44 -07:00
swift_jenkins
4f45260171 Merge remote-tracking branch 'origin/master' into master-next 2020-05-12 21:38:40 -07:00
Xi Ge
3952fd5bf7 ModuleInterface: refactor compiler instance configuration to a standalone delegate class. NFC
Module interface builder used to maintain a separate compiler instance for
building Swift modules. The configuration of this compiler instance is also
useful for dependencies scanner because it needs to emit front-end compiler invocation
for building Swift modules explicitly.

This patch refactor the configuration out to a delegate class, and the
delegate class is also used by the dependency scanner.
2020-05-12 16:19:27 -07:00
swift_jenkins
e6e25df038 Merge remote-tracking branch 'origin/master' into master-next 2020-05-06 14:35:31 -07:00
Nathan Hawes
709dd35c3f Merge pull request #31589 from nathawes/doc-info-missing-submodule-decls
[IDE][DocSupport] Fix DocInfo missing decls when generated for clang submodules
2020-05-06 12:40:19 -07:00
Nathan Hawes
34098a75f5 [IDE][DocSupport] Fix DocInfo missing decls when generated for clang submodules.
Out handling of clang submodules was handled differently between DocInfo and
InterfaceGen. For InterfaceGen submodules were mapped back to their top-level
clang modules (or their Swift overlay if it had one) before being passed
into printSubmoduleInterface, along with the dot separated name of the submodule.

For DocInfo, they were not, and only the rightmost component of their name was
passed. The call to retrieve the decls from a ModuleDecl doesn't work if the
ModuleDecl wraps a clang submodule, so we were missing these decls.

InterfaceGen for submodules also shouldn't have been mapping the module back to
the overlay of top-level clang module, as that meant we ended up printing
import decls from the Swift overlay in the submodule's interface.

Resolves rdar://problem/57338105
2020-05-06 09:28:00 -07:00
swift_jenkins
4dc2e3c785 Merge remote-tracking branch 'origin/master' into master-next 2020-04-29 17:59:15 -07:00
Robert Widmann
3d144011aa [NFC] Remove Needless Double-Import of Decls
Requestification addressed the bulk of the issues with the re-entrant
Clang Importer. Flush a hack that depended on that old state of affairs.

rdar://60111478
2020-04-29 14:42:39 -07:00
swift_jenkins
ed20b9c058 Merge remote-tracking branch 'origin/master' into master-next 2020-04-24 23:58:13 -07:00
Doug Gregor
172c0472f6 Merge pull request #28515 from DougGregor/fast-dependency-scanning
Fast dependency scanning for Swift
2020-04-24 23:54:06 -07:00
Doug Gregor
33cdd61835 Fast dependency scanning for Swift
Implement a new "fast" dependency scanning option,
`-scan-dependencies`, in the Swift frontend that determines all
of the source file and module dependencies for a given set of
Swift sources. It covers four forms of modules:

1) Swift (serialized) module files, by reading the module header
2) Swift interface files, by parsing the source code to find imports
3) Swift source modules, by parsing the source code to find imports
4) Clang modules, using Clang's fast dependency scanning tool

A single `-scan-dependencies` operation maps out the full
dependency graph for the given Swift source files, including all
of the Swift and Clang modules that may need to be built, such
that all of the work can be scheduled up front by the Swift
driver or any other build system that understands this
option. The dependency graph is emitted as JSON, which can be
consumed by these other tools.
2020-04-24 12:58:41 -07:00
swift_jenkins
71686f9984 Merge remote-tracking branch 'origin/master' into master-next 2020-04-24 12:58:09 -07:00