Commit Graph

125 Commits

Author SHA1 Message Date
Ben Barham
c54c9c7079 [Gardening] Extract basic source info structs from RawComment.h 2021-04-14 10:05:27 +10:00
Keith Smiley
83d76535b7 [NFC] Remove unused ModuleCacheDir variable 2020-11-20 16:19:22 -08:00
Artem Chikin
a09ae48999 [Dependency Scanner] Always add NonPathCommandLine arguments from Clang scan-deps result
When building a set of command-line options required to build a Clang module, also add `NonPathCommandLine` from Clang's `ModuleDeps`. These flags are mandatory in order to build modules discovered by the scanner.

Resolves rdar://70212660
2020-10-13 11:50:23 -07:00
Artem Chikin
f9d6c6a619 [Dependency Scanner] Refactor ModuleDependencies to represent binary-only Swift modules explicitly
This matches the behavior of the current client (`swift-driver`) and reduces ambiguity in how the nodes in the graph are to be treated. Swift dependencies with a textual interface, for example, must be built into a binary module by clients. Swift dependencies without a textual interface, with only a binary module, are to be used directly, without any up-to-date checks.

Note, this is distinct from Swift dependencies that have a textual interface, for which we also detect potential pre-build binary module candidates. Those are still reported in the `details` field of textual Swift dependencies as `prebuiltModuleCandidates`.
2020-10-12 09:56:03 -07:00
Xi Ge
c403b140e1 ClangImporter: refactor ClangImporterOptions to be ASTContext-owned. NFC
We need ClangImporterOptions to be persistent for several scenarios: (1)
when creating a sub-ASTContext to build Swift modules from interfaces; and
(2) when creating a new Clang instance to invoke Clang dependencies scanner.

This change is NFC.
2020-09-01 14:04:22 -07:00
Artem Chikin
02513b1c11 Merge pull request #33671 from artemcm/BatchScannerTargetExtract
[Dependency Scanner] Batch scanner: extract target triple from the PCMArgs for the batch invocation.
2020-08-28 10:16:14 -07:00
Artem Chikin
5afbddb42b [Dependency Scanner] Ensure that Clang dependency scanner instances inherit the creating invocation's extra clang args.
This ensures that when the dependency scanner is invoked with additional clang (`-Xcc`) options, the Clang scanner is correctly configured using these options.
2020-08-27 19:21:53 -07:00
Artem Chikin
863bca87e8 [Dependency Scanner] Prefix Clang dependency scanner search path arguments with -Xcc
Experimentally, this seems to be required for these paths to actually be picked up by the underlying scanner.
2020-08-27 13:17:12 -07:00
Xi Ge
29c7216c6c DependenciesScanner: include search path options in PCM building commands
Unlike Swift modules, building Clang PCMs requires search path options like -F and -I to
look for transitive header includes because in module maps, we can only find top-level headers.

rdar://67589328
2020-08-26 13:19:49 -07:00
David Zarzycki
1e940c2c7e [NFC] Fix -Wsuggest-override warnings
LLVM, as of 77e0e9e17daf0865620abcd41f692ab0642367c4, now builds with
-Wsuggest-override. Let's clean up the swift sources rather than disable
the warning locally.
2020-08-13 16:17:46 -04:00
Xi Ge
056f00322d DependenciesScanner: refactor cross import overlay resolver to a standalone function. NFC
This change facilitates resolving cross-import overlays from transitive dependencies.
2020-07-23 17:47:47 -07:00
Artem Chikin
9ee4ebf507 [Dependency Scanner] Use pragma clang module import in the hack file used to invoke the clang dependency scanner.
Using `@import` does not woth in C-mode(`-disable-objc-interop`), so C modules cannot be found in this mode.
This also means the dependency scanner is not able to invoke the Clang dependency scanner tool on Linux at all.
2020-06-29 13:44:02 -07:00
Xi Ge
b6a8af599e DependenciesScanner: move -fapinotes-swift-version to extra PCM arguments
Swift interface files may specify the effective language version to use. When building
a PCM loadable for these textual interface files, we should respect the language
version. This patch moves -fapinotes-swift-version from the generic PCM
commands to the extra PCM arguments owned by each loading Swift module.
2020-06-16 11:38:28 -07:00
Xi Ge
00872ba53e DependencyScanner: add a new extraPcmArgs field for each Swift module
Building each Swift module explicitly requires dependency PCMs to be built
with the exactly same deployment target version. This means we may need to
build a Clang module multiple times with different target triples.

This patch removes the -target arguments from the reported PCM build
arguments and inserts extraPcmArgs fields to each Swift module.
swift-driver can combine the generic PCM arguments with these extra arguments
to get the command suitable for building a PCM specifically for
that loading Swift module.
2020-06-16 09:42:59 -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
1ae70a5b26 DependenciesScanner: avoid reporting output file path because build system should specify it 2020-06-02 16:51:45 -07:00
Matt Davis
765c3cedf6 [clangimporter] Fix a StringRef to std::string conversion.
Explictly call StringRef::str, the implicit conversion operator was
removed in an earlier commit:
(See https://github.com/llvm/llvm-project/commit/adcd02683856c)
2020-05-28 08:34:38 -07:00
Xi Ge
38c0452d65 DependenciesScanner: report command-line arguments for building pcm explicitly 2020-05-22 07:50:08 -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
Xi Ge
9bc036c050 DependencyScanner: honor additional compiler flags in interfaces files when collecting imports
Additional flags in interface files may change parsing behavior like #if
statements. We should use a fresh ASTContext with these additional
flags when parsing interface files to collect imports.

rdar://62612027
2020-05-04 22:18:11 -07:00
Michael Forster
4852210fd5 More StringRef->std::string conversion fixes 2020-04-29 17:40:51 +02:00
Doug Gregor
6b5e7efc0e [Dependency scanner] Capture Clang context hash and command-line arguments. 2020-04-24 12:58:45 -07:00
Doug Gregor
fdfadf8363 [Dependency scanner] Get the Clang module file name from Clang. 2020-04-24 12:58:45 -07:00
Doug Gregor
d6484c8280 [Dependency scanning] Scan and record bridging header dependencies.
When there is a bridging header associated with the module, scan and record
its dependencies. Note them in a separate structure to capture the specific
dependencies of the bridging header.
2020-04-24 12:58:45 -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