Commit Graph

340 Commits

Author SHA1 Message Date
David Ungar
249718e1bd Consolidate performWholeModuleTypeChecking and finishTypeCheckingMainModule into typeCheckMainModule 2017-09-14 16:53:16 -07:00
David Ungar
266007bee3 Don't pass clangImporter 2017-09-14 16:53:16 -07:00
David Ungar
8099209ddc Reify generateOutputForTheWholeModule 2017-09-14 16:53:16 -07:00
David Ungar
7fe7191a54 delete redundant "OnMainModule" from performWholeModuleTypeCheckingOnMainModule 2017-09-14 16:53:16 -07:00
David Ungar
2c08429e27 split up typeCheckTopLevelInputsExcludingMain
because the old name and code were just confusing to me

# Conflicts:
#	lib/Frontend/Frontend.cpp
2017-09-14 16:53:16 -07:00
David Ungar
e3a7857d77 Move comment to function declaration and renamed parseMainAndTypeCheckTopLevelFiles
# Conflicts:
#	lib/Frontend/Frontend.cpp
2017-09-14 16:50:55 -07:00
David Ungar
10b42c26b8 Addressing review suggestions
- Replaced RecursiveSharedTimer w/ SharedTimer in performTypeChecking
- Sorted includes by library name within top-level group
- Removed timer from addAdditionalImportsTo
- Changed comment to doc comment
- Unlinked computation of ImplicitModuleImportKind from creation of SIL module
- Renamed supplyREPLFileWithImports to createREPLFileWIthImports
- Reified tuple of ImplicitImports

# Conflicts:
#	lib/Frontend/Frontend.cpp
2017-09-14 16:49:39 -07:00
David Ungar
4c96b89b87 Fix a bug with DelayedCB 2017-09-14 16:46:37 -07:00
David Ungar
768586b3a0 Bug fix: loadStdlibAndMaybeSwiftOnoneSupport needs to be able to abort the compilation 2017-09-14 16:46:37 -07:00
David Ungar
50e0db551d Ran my changes through git-clang-format.
# Conflicts:
#	lib/Frontend/Frontend.cpp
2017-09-14 16:44:28 -07:00
David Ungar
210cb3c9c1 Pull out supplyREPLFileWithImports.
# Conflicts:
#	lib/Frontend/Frontend.cpp
2017-09-14 16:40:17 -07:00
David Ungar
39771feaef Pulled out parsePartialModulesAndLibraryFiles. 2017-09-14 16:37:44 -07:00
David Ungar
f63cb71196 Pull out parseMainAndTypeCheckTopLevelFiles. 2017-09-14 16:37:44 -07:00
David Ungar
4cc16f4590 Finish replacing “underlying” with “objCModuleUnderlyingMixedFramework” 2017-09-14 16:37:44 -07:00
David Ungar
bff485856b Replace modImpKind w/ implicitModuleImportKind
# Conflicts:
#	lib/Frontend/Frontend.cpp
2017-09-14 16:37:43 -07:00
David Ungar
91bb47e068 Exploit constancy of FrontendOptions and InputFileKind
# Conflicts:
#	lib/Frontend/Frontend.cpp
2017-09-14 16:33:34 -07:00
David Ungar
2b5bfa65fe Pull out loadStdlibAndMaybeSwiftOnoneSupport. 2017-09-14 16:25:10 -07:00
David Ungar
d673df3473 Pull out importUnderlyingModule. 2017-09-14 16:25:10 -07:00
David Ungar
a27a5d9e28 Simplify interface to fillInModulesToImportFromImplicitImportModuleNames. 2017-09-14 16:25:10 -07:00
David Ungar
706c7a336a Pull out importBridgingHeader. 2017-09-14 16:25:10 -07:00
David Ungar
d77f1b2ede Pull out fillInModulesToImportFromImplicitImportModuleNames. 2017-09-14 16:25:09 -07:00
David Ungar
0dd19555d1 Pull out delayed parsing callback compulation. 2017-09-14 16:25:09 -07:00
David Ungar
85a33669a8 Pull out ensureMainFileComesFirst.
# Conflicts:
#	lib/Frontend/Frontend.cpp
2017-09-14 16:25:09 -07:00
David Ungar
3566ad73f4 Pull out createSILModuleIfNecessary so modImpKind can be clearly constant. 2017-09-14 16:24:01 -07:00
David Ungar
02c084ee83 Pull out parseALibraryFile.
# Conflicts:
#	lib/Frontend/Frontend.cpp
2017-09-14 16:24:01 -07:00
David Ungar
0a95f3f725 Pull out computeTypeCheckingOptions. 2017-09-14 16:22:43 -07:00
David Ungar
36a490597f Pull out parseTheMainFile 2017-09-14 16:22:43 -07:00
David Ungar
28e4f0f333 pull out typeCheckTopLevelInputsExcludingMain 2017-09-14 16:22:43 -07:00
David Ungar
168a4bf0cc Pull out performWholeModuleTypeCheckingOnMainModule 2017-09-14 16:22:43 -07:00
David Ungar
3a7cc73043 pull out finishTypeCheckingMainModule 2017-09-14 16:22:43 -07:00
Robert Widmann
75a83da03e Implement SE-0075: CanImport
This implementation required a compromise between parser
performance and AST structuring.  On the one hand, Parse
must be fast in order to keep things in the IDE zippy, on
the other we must hit the disk to properly resolve 'canImport'
conditions and inject members of the active clause into the AST.
Additionally, a Parse-only pass may not provide platform-specific
information to the compiler invocation and so may mistakenly
activate or de-activate branches in the if-configuration decl.

The compromise is to perform condition evaluation only when
continuing on to semantic analysis.  This keeps the parser quick
and avoids the unpacking that parse does for active conditions
while still retaining the ability to see through to an active
condition when we know we're moving on to semantic analysis anyways.
2017-08-28 18:35:06 -04:00
Doug Gregor
f03685b6d0 Introduce a command-line option to limit the # of typo corrections.
Typo correction can be particularly expensive, so introduce a
command-line flag to limit the number of typo corrections we will
perform per type-checker instance. Default this limit to 10.

Addresses rdar://problem/28469270 to some extent.
2017-07-10 11:40:35 -07:00
Argyrios Kyrtzidis
b1fe90cc46 [frontend] Don't destroy the compiler instance object inside performCompile()
This permits continuing to use the diagnostic engine object from the instance.
2017-05-03 16:27:50 -07:00
David Farler
303a3e5824 Start the Migrator library
The Swift 4 Migrator is invoked through either the driver and frontend
with the -update-code flag.

The basic pipeline in the frontend is:

- Perform some list of syntactic fixes (there are currently none).
- Perform N rounds of sema fix-its on the primary input file, currently
  set to 7 based on prior migrator seasons.  Right now, this is just set
  to take any fix-it suggested by the compiler.
- Emit a replacement map file, a JSON file describing replacements to a
  file that Xcode knows how to understand.

Currently, the Migrator maintains a history of migration states along
the way for debugging purposes.

- Add -emit-remap frontend option
  This will indicate the EmitRemap frontend action.
- Don't fork to a separte swift-update binary.
  This is going to be a mode of the compiler, invoked by the same flags.
- Add -disable-migrator-fixits option
  Useful for debugging, this skips the phase in the Migrator that
  automatically applies fix-its suggested by the compiler.
- Add -emit-migrated-file-path option
  This is used for testing/debugging scenarios. This takes the final
  migration state's output text and writes it to the file specified
  by this option.
- Add -dump-migration-states-dir

  This dumps all of the migration states encountered during a migration
  run for a file to the given directory. For example, the compiler
  fix-it migration pass dumps the input file, the output file, and the
  remap file between the two.

  State output has the following naming convention:
  ${Index}-${MigrationPassName}-${What}.${extension}, such as:
  1-FixitMigrationState-Input.swift

rdar://problem/30926261
2017-04-17 16:25:02 -07:00
Maxwell Swadling
93d485e4f7 Changed handleDiagnostic to take a format string and format args instead of the formatted string
This allows diagnostic consumers to modify the way formatting of diagnostics is performed.
rdar://problem/31305854
2017-04-14 11:28:04 -07:00
David Farler
65668c9d82 Cache Code Completion results from PCH files
- Add CompilerInvocation::getPCHHash
  This will be used when creating a unique filename for a persistent
  precompiled bridging header.

- Automatically generate and use a precompiled briding header
  When we're given both -import-objc-header and -pch-output-dir
  arguments, we will try to:
  - Validate what we think the PCH filename should be for the bridging
    header, based on the Swift PCH hash and the clang module hash.
    - If we're successful, we'll just use it.
    - If it's out of date or something else is wrong, we'll try to
      emit it.
  - This gives us a single filename which we can `stat` to check for the
    validity of our code completion cache, which is keyed off of module
    name, module filename, and module file age.

- Cache code completion results from imported modules
  If we just have a single .PCH file imported, we can use that file as
  part of the key used to cache declarations in a module.  Because
  multiple files can contribute to the __ObjC module, we've always given
  it the phony filename "<imports>", which never exists, so `stat`-ing it
  always fails and we never cache declarations in it.

  This is extremely problematic for projects with huge bridging headers.
  In the case where we have a single PCH import, this can bring warm code
  completion times down to about 500ms from over 2-3s, so it can provide a
  nice performance win for IDEs.

- Add a new test that performs two code-completion requests with a bridging header.
- Add some -pch-output-dir flags to existing SourceKit tests that import a bridging
  header.

rdar://problem/31198982
2017-04-04 20:44:33 -07:00
Argyrios Kyrtzidis
ca906d1e99 Add '-Fsystem' framework search option to indicate path for frameworks that should be treated as 'system'
This has the effect of propagating the search path to the clang importer as '-iframework'.
It doesn't affect whether a swift module is treated as system or not, this can be done as follow-up enhancement.
2017-02-14 16:13:25 -08:00
Brian Gesiak
663b92ece9 [AST] Completely replace Module with ModuleDecl
The typedef `swift::Module` was a temporary solution that allowed
`swift::Module` to be renamed to `swift::ModuleDecl` without requiring
every single callsite to be modified.

Modify all the callsites, and get rid of the typedef.
2017-01-08 00:36:08 -05:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Argyrios Kyrtzidis
32a6d7dc2f [IDE] Make sure to disable typo-correction when doing code-completion.
Typo-correction can be expensive and we don't need it for code-completion.
2016-11-28 16:19:33 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
John McCall
95eeabb025 Move the -frontend logic into its own library to allow re-use
and abstraction (to come).
2016-04-20 22:54:00 -07:00
Doug Gregor
be90d63a43 Remove the unused EnableCodeCompletionDelayedEnumConformanceHack; NFC 2016-01-13 16:53:01 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
practicalswift
f91525a10f Consistent placement of "-*- [language] -*-===//" in header. 2016-01-04 09:46:20 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Roman Levenstein
4cef619c19 Revert "Verify SIL modules at the beginning and at the end of the SIL optimization pipelines, if -sil-verify-all is provided"
This reverts commit r31863, which was committed by mistake.

Swift SVN r31864
2015-09-10 22:32:36 +00:00
Roman Levenstein
141b8f814d Verify SIL modules at the beginning and at the end of the SIL optimization pipelines, if -sil-verify-all is provided
Till now, a SIL module would be only verified if an optimization has changed it. But if there were no changes, then no verification would happen and some SIL module format errors would stay unnoticed. This was happening in certain cases when reading a textual SIL module representation, which turned out to be broken, but SIL verifier wouldn't catch it.

Swift SVN r31863
2015-09-10 22:26:37 +00:00
Roman Levenstein
66e13af73e Add support for whole-module optimizations for SIL files.
To invoke the front-end on a SIL with whole-module optimizations enabled, execute:
swiftc -frontend myfile.sil

To invoke the front-end on a SIL without whole-module optimizations enabled, add a -primary-file option:
swiftc -frontend -primary-file myfile.sil

To invoke a sil-opt with whole-module optimizations enabled, use the -wmo option:
sil-opt myfile.sil -wmo

This change was need to be able to write SIL unit tests which should be compiled in the WMO mode.

Swift SVN r31862
2015-09-10 22:26:35 +00:00
Jordan Rose
d609aa461d Always serialize absolute search paths.
...and always serialize -working-directory for Clang. (But allow it to be
overridden by a later -Xcc -working-directory.)

Not having this has caused plenty of headaches for the debugger, which is the
primary client of this information. We can still get into bad situations with
search paths that don't exist at all (say, when a built framework is transferred
to another computer), but at least we won't fall over in multi-project workspaces.

This isn't an actual command-line option for a few reasons:

- SourceKit is still using frontend options directly, and they'll need something
  like this to fix rdar://problem/21912068.
- We might want to be more formal about passing this to Clang.
- I don't actually like the existence of such an option for users.

We can revisit this later if the scales tip. Fixing the debugging issue is the
priority.

rdar://problem/21857902

Swift SVN r30500
2015-07-22 20:20:33 +00:00