Commit Graph

761 Commits

Author SHA1 Message Date
Hamish Knight
98522b0b71 Merge pull request #32067 from hamishknight/a-delayed-filing 2020-05-28 18:41:25 -07:00
Hamish Knight
6477cc68eb [Serialization] Delay adding ModuleFiles until they're loaded
Rather than adding a ModuleFile to a parent module
and then removing it afterwards if it fails to
load, let's wait until we've loaded the file before
deciding to add it to the parent module. This then
allows us to get rid of `ModuleDecl::removeFile`.

In addition, push down the calls to `addFile` into
the callers of `loadAST` in preparation for
`addFile` being replaced with a one-time-only call
to a `setFiles` method.
2020-05-28 12:09:10 -07:00
Hamish Knight
f810cfcc45 [Serialization] Remove treatAsPartialModule parameter
This information can be derived from whether we're
installing the module file into the main module.
2020-05-28 12:09:10 -07:00
Hamish Knight
21b733b4a1 [Frontend] Set "failed to load" for failed partial module
If a partial module fails to load, the main module
may be left without files, so let's set the failed
to load bit.
2020-05-28 11:32:12 -07:00
Hamish Knight
898f980a71 [Frontend] Set "failed to load" bit if stdlib fails
Set the "failed to load" flag on the main module
if the stdlib fails to load, as we'll bail without
adding any source files to the module.
2020-05-28 11:32:11 -07:00
Robert Widmann
acbf927b0e [NFC] Delete ReferencedNameTracker 2020-05-21 18:54:14 -07:00
Robert Widmann
4c5d87e07c [Gardening] Move options setup code into argument parsing 2020-05-18 22:49:22 -07:00
Robert Widmann
854d6ee122 [NFC] Remove forEachSourceFileIn
We actually wanted to use forEachFileToTypeCheck, which will restrict
the source files we analyze to just the given primaries in incremental
mode, and the whole module's source files otherwise.
2020-05-18 20:07:38 -07:00
Robert Widmann
921180fff0 [NFC] Remove DelayWholeModuleChecking
While refactoring in 48805b1, I accidentally added the computation of this bit before CompilerInstance::setupInputs is called. This means that the compiler currently does not have any knowledge of any primary input buffers, and thus the check for whole module mode is trivially true. As a consequence, this bit has been true ever since.

Since we seem to have got on just fine without computing this correctly, just inline that truthiness everywhere.

Whoops
2020-05-18 19:43:30 -07:00
Robert Widmann
f8810ab6e8 [Gardening] Remove InImmediateMode
The last reader of this bit was the legacy integrated REPL.
2020-05-18 19:40:43 -07:00
Hamish Knight
851f64095f Lift implementation-only import checking into a request
This diagnostic logic is currently called from
`finishTypeChecking`, however it doesn't need to
be delayed until after all the source files have
been type-checked, only after they have all had
their imports resolved.

It can therefore be lifted into a request that
operates on a ModuleDecl, and be called from
TypeCheckSourceFileRequest. Being a request will
ensure that the pass is only run once across the
module.

Eventually we'll probably want to re-do import
resolution so that it operates on an entire
module. At that point, we'll want to look at
integrating this diagnostic logic into it.
2020-05-18 16:17:37 -07:00
Robert Widmann
a5dcb1d400 [NFC] Add a "Main Module" Bit
The constraint system will need this if it wants to disable debug mode for serialized modules
2020-05-13 09:13:44 -07:00
Robert Widmann
4ff5b90a8b [NFC] Fold performParseOnly into performSemaUpTo 2020-05-11 23:58:27 -07:00
Hamish Knight
98d3a81ede Merge pull request #31609 from hamishknight/ill-sil-you-in-later 2020-05-07 18:02:52 -07:00
Hamish Knight
72bb47ee90 [Frontend] Remove InputFileKind::SwiftREPL 2020-05-07 11:00:02 -07:00
Hamish Knight
dac52cb610 [Frontend] Move initial REPL file creation logic
Move the logic out of the frontend and into its
only client, swift-ide-test.
2020-05-07 11:00:02 -07:00
Slava Pestov
b81c0d63d1 AST: Remove SourceFileKind::REPL 2020-05-07 02:04:05 -04:00
Hamish Knight
70abfd3252 [Frontend] Remove TheSILModule
Now that SIL parsing is handled lazily, the
CompilerInstance no longer needs to hang onto a
SILModule.
2020-05-06 20:11:49 -07:00
Hamish Knight
11d8f70dec Trigger SIL parsing from performSILGeneration
Rather than eagerly parsing an input .sil file
in `performSemaUpTo`, trigger it from
`performSILGeneration`. This will allow us to
remove the SILModule stored on the
CompilerInstance and will eventually allow the
various SIL tools to just call into
`performSILGeneration` without needing to call
`performSema`.
2020-05-06 20:11:48 -07:00
Slava Pestov
60ce308eba Sema: Only run extension binding once
There's no need to walk all imports of all source files, and bind the
extensions defined therein. The only time that a non-main module
contains source files is when using -enable-source-import, and we
can just explicitly call bindExtensions() in the right place.
2020-05-06 19:19:47 -04:00
Hamish Knight
9fe475fa47 [Frontend] Inline parseAndCheckTypesUpTo
`performSemaUpTo` will only shrink from here, so
go ahead and inline `parseAndCheckTypesUpTo` into
it already.
2020-04-28 14:44:18 -07:00
Hamish Knight
b78f47490a Move AST transforms out of the Frontend
Move the playground and debugger transforms out
of the Frontend and into `performTypeChecking`, as
we'd want them to be applied if
`performTypeChecking` was called lazily.
2020-04-28 14:44:17 -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
Hamish Knight
59b228f3fa Don't emit an error for code completion
Now that we no longer perform whole-file type
checking for code completion, the ASTVerifier is
no longer expecting fully semantically valid AST.
As such, we no longer need to emit an error to
force it to be more lax with its checks.
2020-04-24 13:39:33 -07:00
Doug Gregor
71e7d6a913 [Dependency scanning] Add implicit Swift and SwiftOnoneSupport dependencies 2020-04-24 12:58:45 -07:00
Erik Eckstein
53f6fdadc6 SILOptimizer: reorganize the optimization-prepare passpipeline
Don't create a separate pass manager for those passes, just let them run at the beginning of the performance pipeline.
Regarding generated code this is a NFC.

This change fixes a problem with pass-bisecting (for debugging). Having two instances of the pass manager can cause troubles with bisecting, because -sil-opt-pass-count affects both pass managers at the same time.
2020-04-24 15:48:48 +02:00
Hamish Knight
057ca60371 [Frontend] Inline recordPrimarySourceFile
And remove an unnecessary call to
`recordPrimaryInputBuffer`.
2020-04-20 19:48:37 -07:00
Hamish Knight
a6b3236cd1 [Frontend] Remove parseAndTypeCheckMainFileUpTo
Now that we no longer interleave parsing and
type-checking for SIL, the main file doesn't need
to be handled separately. We can now parse it
along with the rest of the input files and
type-check it along with the rest of the primaries.

This commit also updates `performParseOnly` to
match the order in which the files are now parsed.
2020-04-20 19:48:37 -07:00
Hamish Knight
813c0d663f Move import warning silencing logic
Move the warning suppression code from the
frontend and into import resolution. Parsing
already has its own logic for silencing warnings.
2020-04-20 19:48:36 -07:00
Hamish Knight
7f8a0e8a6c Requestify implicit imports
Add ModuleImplicitImportsRequest, which computes
the modules that should be implicitly imported by
each file of a given module. Use this request in
import resolution to add all the necessary
implicit imports.

The request computes the implicit imports by
consulting the ImplicitImportInfo, which ModuleDecl
can now be created with. This allows us to remove
uses of `SourceFile::addImports` in favor of
adding modules needed to be implicitly imported to
the ImplicitImportInfo.
2020-04-20 13:20:35 -07:00
Hamish Knight
453667f659 [Frontend] Validate ImplicitImportModuleNames early
Check whether the user has provided a valid
identifier when parsing the options. Also make
ImplicitImportModuleNames a private member of
FrontendOptions to prevent mutation after being
parsed.
2020-04-20 13:20:35 -07:00
Robert Widmann
37f016b802 [NFC] Formalize isModuleExternallyConsumed
Yank this parameter and document the historical scope creep of this value.
2020-04-19 21:46:59 -07:00
Robert Widmann
58e63f7185 Merge pull request #28313 from owenv/verifier-consumer
[DiagnosticVerifier] Make DiagnosticVerifier a DiagnosticConsumer
2020-03-30 17:46:30 -07:00
Hamish Knight
d2434e1bf7 NFC: Rename NameBinding to ImportResolution 2020-03-29 18:43:58 -07:00
Owen Voorhees
465bab002f [DiagnosticVerifier] Make Diagnostic Verifier a DiagnosticConsumer subclass
Update DiagnosticVerifier to respect color flags

Improve DiagnosticVerifier test coverage

verifier updates to support new llvm stable branch
2020-03-28 12:29:53 -07:00
Owen Voorhees
791312fb74 Turn Educational Notes On-By-Default (#30583)
* [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.
2020-03-27 15:29:48 -07:00
Robert Widmann
6d60d01420 [NFC] Remove the Legacy Semantic Queries Bit
Clients that wish to avoid semantic requests should decline to register
those requests.
2020-03-19 11:04:12 -07:00
Dmitri Gribenko
841eeb05b0 Merge pull request #30403 from MForster/forster/string-fixes
Cherry-pick StringRef->std::string conversion fixes into `master`
2020-03-17 12:09:36 +01:00
Robert Widmann
ecb58a12d7 Merge pull request #30439 from CodaFi/swift-is-an-untyped-languge-now-i-dont-make-the-rules
[NFC] Break TypeChecker Down Into a Namespace
2020-03-16 21:17:45 -07:00
Robert Widmann
70b6bbcb13 Remove swift::createTypeChecker
Replace it with the "legacy semantic queries" bit. The remaining client
of this bit is SourceKit, which appears to require this bit be set
conditionally so certain semantic property wrapper requests return
a sentinel value.

We should migrate these requests to a syntactic interface as soon as
possible.

rdar://60516325
2020-03-16 19:20:22 -07:00
Robert Widmann
52f4aba784 IRGen Requests
Implement the IRGen Request infrastructure and provide the first
request: generating IR from a given SourceFile.
2020-03-16 18:00:33 -07:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Hamish Knight
c26eb11baf Merge pull request #30190 from hamishknight/the-beginning-of-the-pipeline-end
Requestify SourceFile parsing
2020-03-05 11:17:24 -08:00
Hamish Knight
e9a7427712 [SILOptimizer] Add pipeline execution request (#29552)
[SILOptimizer] Add pipeline execution request
2020-03-03 20:24:28 -08:00
Hamish Knight
df34be72e8 [AST] Remove parsing ASTStages
Now that the parsing stage has been
requestified, these are no longer
meaningful.
2020-03-03 15:53:18 -08:00
Hamish Knight
011f4f1584 Requestify SourceFile parsing
Add ParseSourceFileRequest that parses a SourceFile
for its top-level decls.
2020-03-03 15:53:18 -08:00
Hamish Knight
92ba9483b9 Merge pull request #30166 from hamishknight/three-flags
Move parsing flags onto SourceFile
2020-03-03 13:14:21 -08:00
Owen Voorhees
69b513afaf [Diagnostics] Updated (experimental) diagnostic printing style (#30027)
* [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
2020-03-03 08:48:32 -08:00
Hamish Knight
ea16419476 [Parse] Check the SourceFile for warning suppression
Move the logic for warning suppression out of the
frontend and into `parseIntoSourceFile`.
2020-03-02 14:12:37 -08:00
Hamish Knight
f56b061407 [Parse] Check the SourceFile for #if evaluation
Remove the `EvaluateConditionals` flags from the
parser, and instead query the source file.

This commit also changes ParserUnit such that it
doesn't evaluate #if conditions by default, as
none of its clients appear to require it. The
only client that wasn't explicitly disabling #if
evaluation and is processing the resulting AST is
swift-indent, so this commit also adds a test to
ensure it continues to work correctly with #if
decls.
2020-03-02 14:12:37 -08:00