Commit Graph

340 Commits

Author SHA1 Message Date
Hamish Knight
1bc028ece3 Merge pull request #32091 from hamishknight/standard-error 2020-06-02 14:17:05 -07:00
Hamish Knight
e60c7fe547 Add request to query primary files
Remove the `PrimarySourceFiles` vector from the
frontend and replace it with a request on
ModuleDecl that retrieves the primary files for
the main module.

This is in preparation for having
`CompilerInstance::getMainModule` automatically
populate the main module with files when queried.
2020-06-02 09:10:35 -07:00
Hamish Knight
ab6c15f4b3 [Frontend] Bail early if the stdlib is missing
Rather than trying to continue the compilation
with an empty main module, let's bail out early if
we expect an implicit stdlib import and fail to
load in the stdlib.
2020-05-29 16:13:42 -07:00
Robert Widmann
4ff5b90a8b [NFC] Fold performParseOnly into performSemaUpTo 2020-05-11 23:58:27 -07: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
f34964bc8e [Frontend] NFC: Remove a mutable SILOptions accessor
We shouldn't expose the ability to mutate the
SILOptions through the CompilerInstance.
2020-04-29 18:58:47 -07: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
Doug Gregor
71e7d6a913 [Dependency scanning] Add implicit Swift and SwiftOnoneSupport dependencies 2020-04-24 12:58:45 -07: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
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
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
7fb81eabee [Gardening] Const-qualify CompilerInstance::getInvocation() 2020-04-19 21:45:32 -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
Robert Widmann
92c8a65f09 Drop references to name binding as a phase
A lot of places appear to mean "name lookup".  A few places meant "import resolution".
2020-03-29 18:51:09 -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
Ashley Garland
8f96f67581 [SymbolGraph] Add macCatalyst compatibility
- Add `setDefaultPrebuiltCacheIfNecessary` a `CompilerInvocation` method
- Call that while setting up the invocation in `swift-symbolgraph-extract`
- Add `Fsystem` argument to add iOSSupport directory to the search paths
- Add `resource-dir` argument for local builds

rdar://59262057
2020-03-12 10:51:11 -07:00
Hamish Knight
2ec619caf7 [AST] Add a few parsing flags to SourceFile
Add flags for whether delayed body parsing or #if
condition evaluation is disabled, as well as
whether warnings should be suppressed. Then pass
down these flags from the frontend.

This is in preparation for the requestification of
source file parsing where the SourceFile will need
to be able to parse itself on demand.
2020-03-02 14:12:37 -08:00
Hamish Knight
a9870ac787 Merge pull request #29741 from hamishknight/moving-states
Move PersistentParserState onto SourceFile
2020-03-02 14:11:06 -08:00
Hamish Knight
d77cae6720 Move PersistentParserState onto SourceFile
Move the global PersistentParserState from
the CompilerInstance to the source file that code
completion is operating on, only hooking up the
state when it's needed. This will help make it
easier to requestify source file parsing.
2020-03-02 11:22:44 -08:00
Robert Widmann
b9ebc96cdb [Gardening] Squelch a missing parameter warning 2020-02-28 13:09:57 -08:00
Robert Widmann
a6651a920d Generalize and fix compiler resource freeing before LLVM
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.
2020-02-27 17:12:58 -08:00
Robert Widmann
535bb9bf8f [NFC] UnifiedStatsReporter is owned by CompilerInstance
The lifetime of the UnifiedStatsReporter was not entirely clear from context. Stick it in the CompilerInstance instead so it can live as long as the compile job.

It is critical that its lifetime be extended beyond that of the ASTContext, as the context may be torn down by the time code generation happens, but additional statistics are recorded during LLVM codegen.
2020-02-27 17:12:57 -08:00
Rintaro Ishizaki
0a0cde92a4 [CodeCompletion] Fast completion for top-level code in single file script
e.g. Playground.
A single file script is like a single function body; the interface of
the file does not affect any other files.
So when a completion happens in a single file script, re-parse the whole
file. But we are still be able to reuse imported modules.

rdar://problem/58378157
2020-02-25 15:56:28 -08:00
Alexis Laferrière
901392896d [Frontend] Output the private module interface with the SPI info 2020-02-19 14:17:14 -08:00
swift-ci
ac3ce0d3c4 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-06 13:43:41 -08:00
Hamish Knight
e5946227da Always mark the initial REPL file as typechecked
We were previously doing this for the REPL, but
not for swift-ide-test. Move the assignment into
the frontend to make sure its always applied, and
inline `createREPLFile` while we're here.
2020-02-05 14:01:20 -08:00
Erik Eckstein
1b312a85bd Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-16 10:39:20 +01:00
Robert Widmann
2af598fb52 [Gardening] Const-qualify Many Usages of CompilerInstance
For those operations that do not need to emit diagnostics or manipulate modules, there's no reason to mutate the passed instance.
2020-01-14 09:02:10 -08:00
Robert Widmann
8fe25f7530 [NFC] Remove CompilerInstance::setSILModule
The REPL was using the CompilerInstance to stash this parameter, then it would immediately move it into IRGen.  Drop the setter and pass this data directly.
2020-01-13 22:01:41 -08:00
Robert Widmann
d4976caa4e [Gardening] Const-qualify some logically const functions 2020-01-13 22:01:41 -08:00
Arnold Schwaighofer
0c99cd9734 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-10 08:00:41 -08:00
Hamish Knight
86cc73d278 [Frontend] NFC: Remove an outdated comment
`performParseOnly` has been able to handle
multiple input files for a while now.
2020-01-08 11:31:46 -08:00
Hamish Knight
6b87dce845 Remove DelayedDeclLists from PersistentParserState
Rather than parsing all delayed bodies for
`-dump-parse` once we finish parsing, tell the
parser not to delay any bodies. This then allows
us to remove `DelayedDeclLists` from
PersistentParserState.
2020-01-08 10:54:11 -08:00
swift_jenkins
29b0fb925e Merge remote-tracking branch 'origin/master' into master-next 2019-12-19 14:40:17 -08:00
Rintaro Ishizaki
62c44126b6 [SourceKit] Reuse compiler instance between multiple completion
- Introduce ide::CompletionInstance to manage CompilerInstance
- `CompletionInstance` vends the cached CompilerInstance when:
-- The compiler arguments (i.e. CompilerInvocation) has has not changed
-- The primary file is the same
-- The completion happens inside function bodies in both previous and
   current completion
-- The interface hash of the primary file has not changed
- Otherwise, it vends a fresh CompilerInstance and cache it for the next
  completion

rdar://problem/20787086
2019-12-18 21:52:20 -08:00
swift_jenkins
a812971ee5 Merge remote-tracking branch 'origin/master' into master-next 2019-12-17 15:00:16 -08:00
Xi Ge
3a55c3c96e Front-end: teach the compiler to generate a .c file for $ld$add$os symbols.
When symbols are moved to this module, this module declares them as HIDE
for the OS versions prior to when the move happened. On the other hand, the
original module should declare ADD them for these OS versions. An executable
can choose the right library to link against depending on the deployment target.
This is a walk-around that linker directives cannot specify other install
name per symbol, we should eventually remove this.
2019-12-13 17:22:00 -08:00
Joe Groff
fb34044408 Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 12:46:41 -08:00
David Ungar
62ae2bfd2f Merge pull request #28164 from davidungar/WIP-custom-diff
[Incremental compilation] Source-range-based dependencies
2019-11-21 23:47:52 -08:00
swift_jenkins
b9f998ffa4 Merge remote-tracking branch 'origin/master' into master-next 2019-11-15 15:56:48 -08:00
Doug Gregor
ec70b62d5e Merge pull request #28107 from allevato/emit-pcm
Add driver flag to precompile Swift-compatible explicit Clang modules.
2019-11-14 10:25:53 -08:00
David Ungar
742c3985bd Source-range-based dependencies
Frontend outputs source-as-compiled, and source-ranges file with function body ranges and ranges that were unparsed in secondaries.
Driver computes diffs for each source file. If diffs are in function bodies, only recompiles that one file. Else if diffs are in what another file did not parse, then the other file need not be rebuilt.
2019-11-12 20:41:02 -08:00
swift-ci
d9223a7d16 Merge remote-tracking branch 'origin/master' into master-next 2019-11-12 13:30:45 -08:00
Robert Widmann
422bb372d3 Teach the frontend how to parse TypeCheckerOptions 2019-11-12 09:54:06 -08:00
Tony Allevato
2c7b518460 Consolidate code that computes resource dir relative to swift executable. 2019-11-11 15:00:51 -08:00
Xi Ge
64c0680686 Merge remote-tracking branch 'apple/master' into master-next 2019-10-28 10:19:36 -07:00
Xi Ge
0abcc1db40 SerializeLoc: address Jordan's previous code review comments 2019-10-22 18:35:55 -07:00
swift-ci
84f192ddce Merge remote-tracking branch 'origin/master' into master-next 2019-10-10 13:50:08 -07:00
Xi Ge
5430ad50fa Frontend: change return type of CompilerInstance::getInputBuffersIfPresent to be Optional. NFC 2019-10-09 15:29:52 -07:00