Commit Graph

916 Commits

Author SHA1 Message Date
David Ungar
2b5bfa65fe Pull out loadStdlibAndMaybeSwiftOnoneSupport. 2017-09-14 16:25:10 -07:00
David Ungar
ad8343059d Pull out shouldImplicityImportSwiftOnoneSupportModule. 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
d40196d99a Pull out addAdditionalImports in preparation for next step. 2017-09-14 16:22:43 -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
David Ungar
ae3d15cbd0 Remove redundant local variable shadowing instance variable
# Conflicts:
#	lib/Frontend/Frontend.cpp
2017-09-14 16:22:42 -07:00
Xi Ge
34e2aec662 Parser: use parser to generate a refined token stream to help syntax coloring. (#11809)
This patch allows Parser to generate a refined token stream to satisfy tooling's need. For syntax coloring, token stream from lexer is insufficient because (1) we have contextual keywords like get and set; (2) we may allow keywords to be used as argument labels and names; and (3) we need to split tokens like "==<". In this patch, these refinements are directly fulfilled through parsing without additional heuristics. The refined token vector is optionally saved in SourceFile instance.
2017-09-08 10:28:19 -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
David Farler
645aaad551 [index/build] Upstream indexing while building changes
This patch upstreams previously AppleInternal changes for
indexing while building.
2017-06-29 16:20:06 -07:00
Mark Lacey
508d776c28 Adjust the expression type checker timeout to 10 minutes.
The old threshold was sometimes being reached on an ASAN bot.

Also fix a spot where I missed passing in the override value from the
command-line.

rdar://problem/32925008
2017-06-22 10:17:27 -07:00
Mark Lacey
e51e3e4bd4 Update determination of "too complex" expression to take time into account.
By default, end expression type checking after the elapsed process time
is more than 60 seconds for the current expression. This threshold can
be overridden by using -solver-expression-time-threshold=<seconds>.

Resolves rdar://problem/32859654
2017-06-21 16:26:34 -07:00
Roman Levenstein
2a10d8692b Clean-up the code that stored and passes the SILSerializeAll flag around.
- SILSerializeAll flag is now stored in the SILOptions and passed around as part of it
- Explicit SILSerializeAll/wholeModuleSerialized/makeModuleFragile API parameters are removed in many places
2017-06-16 17:50:33 -07:00
Mark Lacey
d26c859222 Add -warn-long-expression-type-checking=<limit> frontend option.
Generates a warning for any expression that takes longer than <limit>
milliseconds to type check. This compliments the existing
-warn-long-function-body=<limit> option.
2017-06-12 17:27:29 -07:00
Argyrios Kyrtzidis
e6f3af8edd [frontend] Fix use-after-free issue found via ASAN 2017-05-05 07:38:49 -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
Mark Lacey
e1d727d76d Fix unused variable warnings in release build. 2017-04-11 10:37:51 -07:00
Huon Wilson
31b92b1b46 Merge pull request #8473 from huonw/symbol-list-2
Remove dependency on IRGenModule of some linkage computations
2017-04-05 16:39:04 -07:00
Huon Wilson
65c6bdca90 [IRGen] Remove IGM argument, factor out conformance fragility logic. 2017-04-05 09:54:19 -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
Huon Wilson
55b2ba2524 [Frontend] Add -emit-imported-modules: listing modules imported by the current one.
This is purely designed to cheaply compute dependency graphs between
modules, and thus only lists the top-level names (i.e. not submodules)
and doesn't do any form of semantic analysis.
2017-03-17 18:44:03 -07:00
Mark Lacey
3903a43f97 Add a command-line option to time expression type-checking. 2017-01-11 00:15:38 -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
Robert Widmann
0febbf0b72 Effectively revert #5778
This reverts the contents of #5778 and replaces it with a far simpler
implementation of condition resolution along with canImport.  When
combined with the optimizations in #6279 we get the best of both worlds
with a performance win and a simpler implementation.
2017-01-06 16:16:39 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Maxwell Swadling
214efbfc3c Added a new AST Walker that instruments the AST to provide callbacks that simulate a program counter
Based off the PlaygroundTransform, this new ASTWalker leaves calls to __builtin_pc_before and __builtin_pc_after before and after a user would expect a program counter to enter a range of source code.
2016-12-19 10:56:40 -08:00
Robert Widmann
cededef0d6 Add condition resolution as a new phrase post-parse
An unfortunately necessary thing to delay defrosting function bodies as
long as we can.
2016-12-14 15:39:19 -05: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
Jordan Rose
18c7592863 Add frontend option "-warn-long-function-bodies=<N>".
This is a /slightly/ more user-friendly option than
-debug-time-function-bodies; pass it a limit in milliseconds and
the compiler will warn whenever a function or multi-statement closure
takes longer than that to type-check.

Since it's a frontend option (and thus usually passed with -Xfrontend),
I went with the "joined" syntax as the common case. The usual "separate"
syntax of "-warn-long-function-bodies <N>" is also available.

As a frontend option, this is UNSUPPORTED and may be removed without
notice at any future date.

Additional caveats:
- Other parts of type-checking not measured by this may also be slow.
- May include first-use penalties (i.e. "this is slow because it's
  the first function that references an imported type, which causes
  many things to be imported")
- Does not report anything whatsoever about other phases of compilation
  (SILGen, optimization, IRGen, assembly emission, whatever).
- Does not catch anything accidentally being type-checked multiple times
  (a known issue for initial value expressions on properties).
2016-05-11 15:08:17 -07:00
David Farler
9317da24f0 Account for the buffer id == NO_SUCH_BUFFER when suppressing warnings
When there is only one source file passed to the frontend, the primary
buffer id can be set to ~0, so this check would fail for some
-parse -verify invocations.
2016-03-30 19:15:52 -07:00
David Farler
fc9e4938e1 Suppress warnings for non-primary inputs
Don't emit warnings if specified at the command line or when working
on a non-primary input file.

https://bugs.swift.org/browse/SR-1012
rdar://problem/25282622
2016-03-30 16:01:30 -07:00
Brian Gesiak
2e5f1649d6 [Frontend] Nicer assert when -dump-parse foo.sil
Invoking the following command to `-dump-parse` a file containing SIL
triggers an assertion from within the Swift compiler frontend:

```
swiftc -dump-parse foo.sil
```

The assertion is not coupled with a description of what went wrong.
It turns out the frontend doesn't support `-dump-parse` for SIL files,
although `swiftc -help` wouldn't inform users of that:

```
-dump-parse      Parse input file(s) and dump AST(s)
```

As a result, a user may invoke `-dump-parse` on a SIL file and not know
what went wrong. Add an assertion message to inform the user that only
Swift code may be parsed. (`IFK_Swift_Library` here is for the case
where `swiftc -parse-as-library -dump-parse foo.swift` is invoked.)
2016-03-30 00:14:08 -04:00
Slava Pestov
1ce1e78951 AST: Record -sil-serialize-all in the ModuleDecl
We want to distinguish the special case of a library built with
-sil-serialize-all, from a SIL function that is [fragile] because
of an explicitly @_transparent or @inline(__always).

For now, NFC.
2016-03-28 14:14:49 -07:00
Slava Pestov
0b320a6d5b Sema: Implement DefaultWitnessChecker
Now that WitnessChecker is separate from ConformanceChecker, implement
a DefaultWitnessChecker subclass which performs default witness
resolution.

This populates the recently-added ProtocolDecl::DefaultWitnesses map.

Unlike ConformanceChecker, the DefaultWitnessChecker looks up the witness
in any protocol extensions of the protocol, matching the context archetypes
of the requirement against the witness.

For now, we infer default witnesses for all protocols, but don't do
anything with that information. An upcoming SILGen patch will start to
emit thunks and add tests.
2016-03-03 06:59:55 -08:00
Roman Levenstein
8dff92ad4d Move pre-specializations of popular types away from the standard library.
Pre-specializations were only used by Onone builds, but were kept inside the standard library dylyb anyways. This commit moves all the pre-specializations into a dedicated Swift module and a dynamic library, which are only used by Onone builds.

This reduces the code size of libswiftCore.dylib by 4%-5%.
2016-02-25 11:23:15 -08:00
Todd Fiala
8ff40a3a22 Revert "Move pre-specializations of popular types away from the standard library."
This reverts commit 4d4c2cdba9.
2016-02-22 21:18:32 -08:00
Roman Levenstein
4d4c2cdba9 Move pre-specializations of popular types away from the standard library.
Pre-specializations were only used by Onone builds, but were kept inside the standard library dylyb anyways. This commit moves all the pre-specializations into a dedicated Swift module and a dynamic library, which are only used by Onone builds.

This reduces the code size of libswiftCore.dylib by 5%.
2016-02-22 07:54:44 -08:00
Slava Pestov
81267ce1db AST: Serialize -enable-resilience flag on the ModuleDecl
Since resilience is a property of the module being compiled,
not decls being accessed, we need to record which types are
resilient as part of the module.

Previously we would only ever look at the @_fixed_layout
attribute on a type. If the flag was not specified, Sema
would slap this attribute on every type that gets validated.

This is wasteful for non-resilient builds, because there
all types get the attribute. It was also apparently wrong,
and I don't fully understand when Sema decides to validate
which decls.

It is much cleaner conceptually to just serialize this flag
with the module, and check for its presence if the
attribute was not found on a type.
2016-01-16 02:23:27 -08:00
Michael Ilseman
dc689e607c [Diagnostics] -suppress-warnings and -warnings-as-errors flags
Exposes the global warning suppression and treatment as errors
functionality to the Swift driver. Introduces the flags
"-suppress-warnings" and "-warnings-as-errors". Test case include.
2016-01-15 14:20:44 -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