As part of eliminating cascading dependencies, we need to make sure to
capture any dependencies discovered during SILGen and IRGen.
This is a little bit tricky because we exit early in various places in
the pipeline, so we want to do it after performCompileStepsPostSema()
returns, but we can't do it too late, because the ASTContext might
already have been deallocated.
So emit the dependencies manually before freeing the ASTContext if we
decide to do that, or just do it before returning from performCompile()
using a SWIFT_DEFER otherwise.
This should have no observable effect until we start recording dependencies
for lookups done on behalf of declarations in secondary files.
Add a mode bit to the dependency collector that respects the frontend flag in the previous commit.
Notably, we now write over the dependency files at the end of the compiler pipeline when this flag is on so that dependency from SILGen and IRGen are properly written to disk.
MSVC does not realize that the switch is exhaustive and requires that
the path is explicitly marked as unreachable. This silences the C4715
warning ("not all control paths return a value").
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.
Inline the conditions for the astGuaranteedToCorrespondToSIL parameter and clean up the logic here to be more const-friendly. Also try to centralize and document the reasons we skip TBD validation.
The Remarks Streamer's installation seemed a bit overly complex, so simplify it in a few places:
* Refactor sil-opt to install the remarks options into the SILOptions for the SILModule
This reduces the parameter bloat in createSILRemarkStreamer. All of this data is freely derivable from the SILModule alone.
* Refactor createSILRemarkStreamer into SILRemarkStreamer::create
With the new reduction in parameters, we can hide the internal constructor and introduce a smart constructor that vends a unique pointer to clients.
* setSILRemarkStreamer -> installSILRemarkStreamer
Since the information to create a streamer is now entirely derivable from a module, remove a layer of abstraction and have the module directly construct a streamer for itself.
* Give SILRemarkStreamer its own LLVMContext
The remarks streamer just needs scratch space. It's not actually "installed" in a given context. There no reason to use Swift's Global Context here.
* Give the SILRemarkStreamer ownership of the underlying file stream
The SILModule didn't actually use this member, and it seems like somebody needs to own it, so just give it to the remarks streamer directly.
This simplifies fixing the master-next build. Upstream LLVM already
has a copy of this function, so on master-next we only need to delete
the Swift copy, reducing the potential for merge conflicts.
swift::GeneratedModule encapsulates an llvm::Module, llvm::LLVMContext
pair that must live and die together. It has convenient accessors for
projecting the module and context components. The meat of this type is
the two conversion functions, which transfer ownership of either the
module component to the caller or the module and context to ORCJIT.
This is because ORC enforces an ownership contract that is distinct from
LLVM's rather wild ownership story for modules and their associated
contexts. See http://llvm.org/docs/ORCv2.html#how-to-use-threadsafemodule-and-threadsafecontext
Request-based incremental dependencies are enabled by default. For the time being, add a flag that will turn them off and switch back to manual dependency tracking.
* [Diagnostics] Turn educational notes on-by-default
* [Diagnostics] Only include educational notes in printed output if -print-educational-notes is passed
* Make -print-educational-notes a driver option
* [Diagnostics] Issue a printed remark if educational notes are available, but disabled
* [docs] Update educational notes documentation and add a contributing guide
* [Diagnostics] Cleanup PrintingDiagnosticConsumer handling of edu notes
* Revert "[Diagnostics] Issue a printed remark if educational notes are available, but disabled"
For now, don't notify users if edu notes are available but disabled. This decision can be reevaluated later.
Query the SourceLookupCache for the operator decls,
and use ModuleDecl::getOperatorDecls for both
frontend stats and to clean up some code
completion logic.
In addition, this commit switches getPrecedenceGroups
over to querying SourceLookupCache.
Several tests related to indexing system modules were taking a considerable
amount of time (100+ seconds in the worst case) indexing the standard library.
This adds a frontend option to skip it and updates those tests to pass it.
Compatibility header may #import bridging header if specified with -import-underlying-module.
How these two headers are relative to each other is subject to project setting. To accommodate
this, we should allow users to specify bridging header directory for header generating purposes.
rdar://59110975