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
* [Diagnostics] Experimental diagnostic printing updates
This new style directly annotates small snippets of code with
error messages, highlights and fix-its. It also uses color more
effectively to highlight important segments.
* [Diagnostics] Stage educational notes and experimental formatting behind separate frontend flags
educational notes -> -enable-educational-notes
formatting -> -enable-experimental-diagnostic-formatting
* [Diagnostics] Refactor expensive line lookups in diag formatting
* [Diagnostics] Refactor some PrintingDiagnosticConsumer code into a flush method
* [Diag-Experimental-Formatting] Custom formatting for Xcode editor placeholders
* [Diag-Experimental-Formatting] Better and more consistent textual description of fix its
* [Diags-Experimental-Formatting] Handle lines with tab characters correctly when rendering highlights and messages
Tabs are converted to 2 spaces for display purposes.
* [Diag-Experimental-Formatting] Refactor byte-to-column mapping for efficiency
* [Diag-Experimental-Formatting] Fix line number indent calculation
* [Diag-Experimental-Formatting] Include indicators of insertions and deletions in the highlight line
Inserts are underlined by green '+' chars, deletions by red '-' chars.
* [Diag-Experimental-Formatting] Change color of indicator arrow for non-ASCII anchored messages
* [Diag-experimental-formatting] Make tests less sensitive to line numbering
* [Diag-Experimental-Formatting] Update tests to allow windows path separators
* [Diag-Experimental-Formatting] Bug fixes for the integrated REPL
This allows the usage of the whole remark infrastructure developed in
LLVM, which includes a new binary format, metadata in object files, etc.
This gets rid of the YAMLTraits-based remark serialization and does the
plumbing for hooking to LLVM's main remark streamer.
For more about the idea behind LLVM's main remark streamer, see the
docs/Remarks.rst changes in https://reviews.llvm.org/D73676.
The flags are now:
* -save-optimization-record: enable remarks, defaults to YAML
* -save-optimization-record=<format>: enable remarks, use <format> for
serialization
* -save-optimization-record-passes <regex>: only serialize passes that
match <regex>.
The YAMLTraits in swift had a different `flow` setting for the debug
location, resulting in some test changes.
The DependencyVerifier is a DiagnosticVerifier-alike utility that takes annotations in user code and transforms them into a set of expectations. Those expectations are met by corresponding "obligations", which are constructed by reading the contents of the referenced name tracker associated with the source files for each of the primary inputs to a frontend job. The verifier will then pair off expectations and obligations, and ensure that any remaining unpaired obligations are diagnosed as failures.
This tool will not only ensure the correctness of the referenced name tracker's output, it will provide us with tests that ensure its output is stable, and give us the confidence to replace it with an evaluator-based tracking scheme in the future.
Resolves rdar://59773883
When enabled at the driver level, the frontends will inherit the flag. For each frontend that recieves this option, all primaries will have their reference dependencies validated.
Centralize part of the routine that selects which resources to free. Then, add an additional condition for -dump-api-path.
Before, if this option were specified along with -emit-llvm or -c, the compiler would try to rebuild the torn-down ModuleDecl and crash trying to access the torn-down ASTContext.