Commit Graph

531 Commits

Author SHA1 Message Date
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
cb7e135701 Merge remote-tracking branch 'origin/master' into master-next 2020-04-08 12:00:42 -07:00
Nathan Lanza
ec928352eb Merge pull request #30882 from enferex/fix-include
[clangimporter] Include clang/AST/ASTContext.h to fix master-next build.
2020-04-08 14:44:38 -04:00
Brent Royal-Gordon
4de19e1c3c Merge pull request #30819 from brentdax/a-less-ambitious-crossover-event
Ignore transitive ObjC imports when cross-importing
2020-04-08 11:40:35 -07:00
Matt Davis
792ee14e0c [clangimporter] Include clang/AST/ASTContext.h to fix master-next build. 2020-04-08 08:41:41 -07:00
swift_jenkins
10df680cd6 Merge remote-tracking branch 'origin/master' into master-next 2020-04-06 15:00:42 -07:00
Stephen Canon
248c554524 Add Float16 to stdlib (#30130)
Add Float16 (IEEE 754 binary16) to the standard library, plus assorted runtime support operations.

Swift Evolution thread: https://forums.swift.org/t/se-0277-float16/33546
2020-04-06 17:57:44 -04:00
Brent Royal-Gordon
121fa9a058 Ignore transitive ObjC imports when cross-importing
This behavior change reduces the chance of unexpected and unwanted cross-imports being performed.

Fixes rdar://problem/60554019.
2020-04-05 19:06:59 -07:00
Adrian Prantl
1bd6a0a371 Adapt to upstream header file reshuffling in c915cb957dc37275ce1ca1a0b993239c82f12692. 2020-03-11 15:46:37 -07:00
Hamish Knight
d9182af63d [AST] Introduce ModuleDecl::getTopLevelModule
This can be used to retrieve the Swift module
wrapper for a Clang submodule's top-level module.
2020-02-24 20:10:13 -08:00
Brent Royal-Gordon
e248f82773 Add support for loading cross-import files 2020-02-18 11:06:12 -08:00
John McCall
faee21b626 Implement Swift serialization and deserialization of Clang types.
As part of this, we have to change the type export rules to
prevent `@convention(c)` function types from being used in
exported interfaces if they aren't serializable.  This is a
more conservative version of the original rule I had, which
was to import such function-pointer types as opaque pointers.
That rule would've completely prevented importing function-pointer
types defined in bridging headers and so simply doesn't work,
so we're left trying to catch the unsupportable cases
retroactively.  This has the unfortunate consequence that we
can't necessarily serialize the internal state of the compiler,
but that was already true due to normal type uses of aggregate
types from bridging headers; if we can teach the compiler to
reliably serialize such types, we should be able to use the
same mechanisms for function types.

This PR doesn't flip the switch to use Clang function types
by default, so many of the clang-function-type-serialization
FIXMEs are still in place.
2020-02-06 22:09:00 -05:00
Varun Gandhi
afc6ccdeb5 Re-land parsing and printing for Clang function types.
This reverts commit e805fe486e, which reverted
the change earlier. The problem was caused due to a simultaneous change to some
code by the PR with parsing and printing for Clang function types (#28737)
and the PR which introduced Located<T> (#28643).

This commit also includes a small change to make sure the intersecting region
is fixed: the change is limited to using the fields of Located<T> in the
`tryParseClangType` lambda.
2020-01-07 15:58:32 -08:00
Saleem Abdulrasool
e805fe486e Revert "Clang function types v2: Electric Boogaloo (parsing + printing)" 2020-01-06 16:26:08 -08:00
Varun Gandhi
4a1a17d029 Merge pull request #28737 from varungandhi-apple/vg-v3-clang-types-in-swiftinterface
Clang function types v2: Electric Boogaloo (parsing + printing)
2020-01-06 15:42:30 -08:00
Varun Gandhi
96604470ae [AST] Add printing for Clang function types in the AST. 2020-01-06 13:00:04 -08:00
Varun Gandhi
afc6332289 [Sema] Parse a Clang function type from the cType argument. 2020-01-06 13:00:04 -08:00
Kita, Maksim
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03:00
Adrian Prantl
046c849949 Add an option to disable ClangImporter imports form source.
This is primarily meant to used for testing LLDB's DWARFImporterDelegate,
however, this could become the default option for LLDB once
DWARFImporterDelegate is sufficiently mature.

<rdar://problem/57880844>
2019-12-16 13:40:21 -08:00
Varun Gandhi
196f358dec [AST] Add ClangTypeConverter, computing C types for FunctionTypes.
Note: The change in ASTBuilder::createFunctionType is functionally minor,
but we need the FunctionType::Params computed _before_ the ExtInfo, so we
need to shuffle a bunch of code around.
2019-11-22 12:42:36 -08:00
Tony Allevato
3c45041b17 Add driver modes to emit and dump Clang precompiled modules. 2019-11-11 15:00:51 -08:00
Robert Widmann
56a713f179 Remove LazyResolver! 2019-11-05 14:43:12 -08:00
Jordan Rose
b32e82c720 More idiomatic use of llvm::hash_combine in many places (#27497)
- No need to hash input values first
- Pass many values to a single hash_combine to save on intermediates
- Use hash_combine_range instead of a loop of hash_combines

No functionality change.
2019-10-04 13:08:24 -07:00
Jordan Rose
58833455ac [ClangImporter] Include -Xcc options in the PCH hash (#27482)
While most -Xcc options turn into options that affect the Clang module
cache hash, some, like search paths, do not, and that can have a
drastic effect on PCH contents. When combined with places where Xcode
will modify invocations to add extra -Xcc options (see
rdar://problem/23297285), this can lead to crashes where the
modified-invocation PCH is used to compile source files in incremental
mode, and then the original, non-precompiled bridging header is used
for module merging. Let's just be conservative and include -Xcc
options in the Swift-side PCH uniqueness hash.

rdar://problem/33837253
2019-10-02 11:28:31 -07:00
swift-ci
5d7bd0a29b Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-18 10:24:59 -07:00
Jordan Rose
853caa66d4 [AST] Split FileUnit and its subclasses out of Module.h
Most of AST, Parse, and Sema deal with FileUnits regularly, but SIL
and IRGen certainly don't. Split FileUnit out into its own header to
cut down on recompilation times when something changes.

No functionality change.
2019-09-17 17:54:41 -07:00
swift-ci
d4521dc7a1 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-10 09:24:32 -07:00
Jordan Rose
d4ac04d25e Move access-path filtering into ModuleNameLookup (out of lookupValue) (#27097)
Removes duplicated logic from the implementations of
FileUnit::lookupValue, and simplifies the interface to
ModuleDecl::lookupValue, where everyone was passing an empty
(non-filtering) access path anyway /except/ during actual lookup from
source code. No functionality change.
2019-09-10 09:13:20 -07:00
swift-ci
9bf6d8689d Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-06 14:23:36 -07:00
Slava Pestov
99ea1bb980 ClangImporter: Sink getEffectiveClangNode() down from IDE to the importer and clean up related code 2019-09-06 16:03:51 -04:00
swift-ci
eb52f0c448 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-04 15:23:47 -07:00
Slava Pestov
be84556b9e ClangImporter: Record the error wrapper's struct 'Code' member enum in a side table 2019-09-03 22:53:52 -04:00
swift-ci
274826165b Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-26 11:24:29 -07:00
Jordan Rose
c50113185f Merge pull request #26816 from jrose-apple/cant-stand-the-rain
Fix a pair of leaks related to FileUnit destructors not being run
2019-08-26 11:06:54 -07:00
swift-ci
fbe8e56e8b Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-24 10:03:05 -07:00
Slava Pestov
2ff39d227c AST: Remove some unused LazyResolver usages 2019-08-23 22:13:34 -04:00
Jordan Rose
5c785d42b3 Enforce that FileUnit + LoadedFile have trivial destructors
We already do this for other ASTContext-allocated types (see
Decl.cpp). This will prevent the sort of mistakes in the previous two
commits.

Note that if any particular subclass of FileUnit wants to have its
destructor run, it can opt into that manually using
ASTContext::addDestructorCleanup. SourceFile and BuiltinUnit both do
this. But we generally don't /want/ to do this if we can avoid it
because it adds to compiler teardown time.
2019-08-23 17:40:46 -07:00
swift-ci
ad686b6a7e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-21 16:44:03 -07:00
adrian-prantl
793dbed5ee Merge pull request #26707 from adrian-prantl/filter
DWARFImporter: Allow filtering type lookups by containing module.
2019-08-21 16:30:17 -07:00
swift-ci
d28622d4ac Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-19 21:43:25 -07:00
Slava Pestov
393f376156 ClangImporter: Cache getImportedModulesForLookup() even if empty 2019-08-19 23:00:57 -04:00
Adrian Prantl
d7c63daf82 DWARFImporter: Allow filtering type lookups by containing module. 2019-08-19 17:24:31 -07:00
Jonas Devlieghere
c0feea1da3 [Reproducers] Add FileCollector support to DependencyTracker
For reproducers in LLDB, we need to collect module dependency
information coming from the clang importer. However, we cannot override
the dependency collector, like we do in LLDB, because its interface is
completely hidden in the clang importer. The solution is to pass the
FileCollector through the DependencyTracker.

(cherry picked from commit c624a87bd5)
2019-08-19 16:53:03 -07:00
Jonas Devlieghere
5c5041235b Merge Swift & Clang VFS in the ClangImporter
The clang importer has to deal with two virtual file systems, one coming
from clang, and one coming from swift. Currently, if both are set, we
emit a diagnostic that we'll pick the swift one.

This commit changes that, by merging the two virtual file systems. The
motivation for this change is the reproducer infrastructure in LLDB,
which adds a third virtual file system to the mix.

(cherry picked from commit 94ef5431ff)
2019-08-19 16:53:03 -07:00
adrian-prantl
2d86f23988 Merge pull request #26682 from adrian-prantl/loadmodule
Move ClangImporter::loadModuleClang() into ClangImporter::Implementation
2019-08-16 08:42:53 -07:00
adrian-prantl
2ae84202c4 Merge pull request #26689 from adrian-prantl/dummy-dwarfimporter
Add back the dummy DWARFImporter test to lldb-moduleimport-test.
2019-08-16 08:42:33 -07:00
Slava Pestov
7e788d421a Merge pull request #26684 from slavapestov/is-iuo-request
Introduce IsImplicitlyUnwrappedOptionalRequest
2019-08-15 22:08:00 -04:00
Adrian Prantl
1020d8188a Add back the dummy DWARFImporter test to lldb-moduleimport-test. 2019-08-15 16:35:05 -07:00
adrian-prantl
158dae0b24 Merge pull request #26676 from adrian-prantl/ownership
Move the ownership of DWARFImporterDelegate away from ClangImporter (…
2019-08-15 15:51:55 -07:00
Slava Pestov
1c3ac86796 AST: Banish OptionalTypeKind to ClangImporter.h
The only place this was used in Decl.h was the failability kind of a
constructor.

I decided to replace this with a boolean isFailable() bit. Now that
we have isImplicitlyUnwrappedOptional(), it seems to make more sense
to not have ConstructorDecl represent redundant information which
might not be internally consistent.

Most callers of getFailability() actually only care if the result is
failable or not; the few callers that care about it being IUO can
check isImplicitlyUnwrappedOptional() as well.
2019-08-15 18:41:42 -04:00