Commit Graph

83 Commits

Author SHA1 Message Date
Doug Gregor
11969847c4 Simplify lazy parsing of nominal and extension members.
Lazy parsing for the members of nominal types and extensions depends
only on information already present in
`IterableDeclContext`. Eliminate the use of PersistentParserState as
an intermediary and have the member-parsing request construct a new
`Parser` instance itself to handle parsing. Make this possible even
for ill-formed nominal types/extensions to simplify the code path.

Eliminate `LazyMemberParser` and all of its uses, because it was only
present for lazy member parsing, which no longer needs it.
2019-08-30 08:29:43 -07:00
Rintaro Ishizaki
6956089b0b [CodeCompletion] Complete Swift only module name after 'import'
rdar://problem/39392446
2019-05-08 10:11:52 -07:00
Slava Pestov
1159af50d9 Rename -enable-resilience to -enable-library-evolution and make it a driver flag
Fixes <rdar://problem/47679085>.
2019-03-14 22:24:26 -04:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Graydon Hoare
74dc5a1558 [ModuleInterface] Remove protected helper, redundant with visible dependencyTracker member. 2018-11-13 13:53:46 -08:00
Xi Ge
24b0eac9a4 Parser: parse members in extension decls incrementally. 2018-09-05 17:00:39 -07:00
Robert Widmann
0e58b7fd14 Plumbing for a Virtual File System
Adds the -vfsoverlay frontend option that enables the user to pass
VFS overlay YAML files to Swift. These files define a (potentially
many-layered) virtual mapping on which we predicate a VFS.

Switch all input-based memory buffer reads in the Frontend to the new
FileSystem-based approach.
2018-07-31 13:16:14 -07:00
Jordan Rose
df2e63d07d Diagnose modules with circular dependencies (#16075)
This can't arise from a clean build, but it can happen if you have
products lingering in a search path and then either rebuild one of
the modules in the cycle, or change the search paths.

The way this is implemented is for each module to track whether its
imports have all been resolved. If, when loading a module, one of its
dependencies hasn't resolved all of its imports yet, then we know
there's a cycle.

This doesn't produce the best diagnostics, but it's hard to get into
this state in the first place, so that's probably okay.

https://bugs.swift.org/browse/SR-7483
2018-05-02 15:01:09 -07:00
Slava Pestov
175b40919f AST: Fewer headers include Expr.h, Module.h, Stmt.h 2018-04-26 22:55:26 -07:00
Xi Ge
37f352fe41 sourcekitd: build Swift syntax tree more lazily than collecting parsed tokens. (#14578)
Before this patch, we have one flag (KeepSyntaxInfo) to turn on two syntax
functionalities of parser: (1) collecting parsed tokens for coloring and
(2) building syntax trees. Since sourcekitd is the only consumer of either of these
functionalities, sourcekitd by default always enables such flag.
However, empirical results show (2) is both heavier and less-frequently
needed than (1). Therefore, separating the flag to two flags makes more
sense, where CollectParsedToken controls (1) and BuildSyntaxTree
controls (2).

CollectingParsedToken is always enabled by sourcekitd because
formatting and syntax-coloring need it; however BuildSyntaxTree should
be explicitly switched on by sourcekitd clients.

resolves: rdar://problem/37483076
2018-02-13 16:27:12 -08:00
Xi Ge
6af5d3c0bf libSyntax: rename KeepTokensInSourceFile to KeepSyntaxInfoInSourceFile. 2017-11-03 18:39:01 -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
Slava Pestov
162b2d252e AST: Include gardening to minimize dependencies on Expr.h
A lot of files transitively include Expr.h, because it was
included from SILInstruction.h, SILLocation.h and SILDeclRef.h.

However in reality most of these files don't do anything
with Exprs, especially not anything in IRGen or the SILOptimizer.

Now we're down to 171 files in the frontend which depend on
Expr.h, which is still a lot but much better than before.
2017-03-12 22:26:56 -07: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
Robert Widmann
dfa41d625b Optimize Condition Resolution (#6279)
* Pack the bits for IfConfigDecls into Decl

* Don't open symbols into a module when evaluating canImport statements

The module loaders now have API to check whether a given module can be
imported without importing the referenced module.  This provides a
significant speed boost to condition resolution and no longer
introduces symbols from the referenced module into the current context
without the user explicitly requesting it.

The definition of ‘canImport’ does not necessarily mean that a full
import without error is possible, merely that the path to the import is
visible to the compiler and the module is loadable in some form or
another.

Note that this means this check is insufficient to guarantee that you
are on one platform or another.  For those kinds of checks, use
‘os(OSNAME)’.
2017-01-05 12:08:54 -07: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
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
practicalswift
8efa5f587e [gardening] Remove "-*- C++ -*-" tag from .cpp files
Emacs assumes .h files are C files by default which is why the
tag "-*- C++ -*-" is needed.

.cpp files do not have this problem.
2016-01-23 12:09:32 +01: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
practicalswift
199c4eae2e Consistent use of programming language indicator in top of file comment. 2016-01-04 09:20:19 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Doug Gregor
b3badc601a Handle consistency checking that requires the entire module.
Objective-C method unintended override checking is one such case where
properly checking unintended overrides requires us to essentially look
at the whole module, because one translation unit may declare
something that produces an Objective-C method "setFoo:" in a
superclass while another translation unit declares something with a
distinct name that produces an Objective-C method "setFoo:". So, when
we don't have a primary file (e.g., when we're doing the merge-module
step), delay such checks until after all the source files for the
module have been type-checked. When there is a primary file, we
perform the checking that we can based on type checking that primary
file (and whatever got touched along the way), so we get a subset of
the proper diagnostics.

Swift SVN r23179
2014-11-08 06:20:57 +00:00
Jordan Rose
9ddf57f7ba Don't treat missing imports as a fatal error in REPL mode.
We don't want typos in import statements to take down the whole REPL, but we
/do/ want the REPL to be honoring fatal errors that effectively take down the
ASTContext.

This doesn't (yet) apply to the real LLDB REPL, which does not use
SourceFileKind::REPL for its input. The right option to test there is
LangOpts.DebuggerSupport, but that's currently being set for Playgrounds as
well. I've filed <rdar://problem/18090611> for LLDB to adjust their input.

Part of <rdar://problem/17994094>

Swift SVN r21383
2014-08-21 22:36:22 +00:00
Jordan Rose
4eebcb9853 Change ASTContext's LoadedModules map to be keyed by Identifiers, not strings.
No intended functionality change, but there's no reason to be performing
string lookups here.

Swift SVN r20902
2014-08-01 18:03:47 +00:00
Chris Lattner
2825b9f5f8 move @transparent and @requires_stored_property_inits to the new attribute model.
All that is left is unowned(unsafe) & weak.



Swift SVN r20012
2014-07-16 06:14:19 +00:00
Pete Cooper
0d0defff9a Update which matches clang r212408, ie, using ErrorOr for file loading
Swift SVN r19607
2014-07-07 14:49:01 +00:00
Mark Lacey
dccd703315 Use <system_error> rather than llvm/Support/system_error.h.
Rafael removed the latter in r210803.

Swift SVN r18842
2014-06-12 21:53:16 +00:00
Bob Wilson
9ab1136ba8 Update error_code usage to match llvm trunk.
LLVM's system_error.h has been changed to forward to the standard
version of the same. Update usage for the minor API changes that this
entails.

Based in part on a patch by Justin Bogner.

Swift SVN r18832
2014-06-12 19:48:39 +00:00
Jordan Rose
e022a97386 [Frontend] Check in advance that we can load the standard library.
This doesn't really affect anyone in real life, but it will catch cases
where someone's trying to compile for iOS without the iOS stdlib around.

Swift SVN r18796
2014-06-11 00:02:00 +00:00
Jordan Rose
2877bd0854 Add support for dependency file generation with -emit-dependencies.
This performs very conservative dependency generation for each compile task
within a full compilation. Any source file, swiftmodule, or Objective-C
header file that is /touched/ gets added to the dependencies list, which
is written out on a per-input basis at the end of compilation.

This does /not/ handle dependencies for the aggregated swiftmodule, swiftdoc,
generated header, or linked binary. This is just the minimum needed to get
Xcode to recognize what needs to be rebuilt when a header or Swift source
file changes. We can revisit this later.

This finishes <rdar://problem/14899639> for now.

Swift SVN r18045
2014-05-14 00:34:11 +00:00
Argyrios Kyrtzidis
9afa0333db [Frontend] Make sure we don't do any module imports during parse-only pass.
Fixes performance regression of rdar://16816861

Swift SVN r17600
2014-05-07 02:37:49 +00:00
Dmitri Hrybenko
f232267f23 Replace llvm::OwningPtr with std::unique_ptr
It looks like llvm::OwningPtr is going to be removed soon.


Swift SVN r14729
2014-03-06 09:47:17 +00:00
Jordan Rose
cbcf17f9bd Stop leaking memory from Module and FileUnit.
Also, disallow creating Modules and FileUnits on the stack. They must always
live as long as the ASTContext.

<rdar://problem/15596964>

Swift SVN r13671
2014-02-08 02:12:57 +00:00
Jordan Rose
7d01643444 Don't automatically put the current directory in the include path.
Also, don't allow file-relative imports (i.e. don't consider a /source file's/
location as an include path). Both of these should be requested by the user,
at least at this point.

Swift SVN r13249
2014-01-31 23:01:08 +00:00
Jordan Rose
d0d4286d21 Put modules for 32-bit iOS builds in lib/swift/iphone{os,simulator}/32.
This keeps us from having to deal with fat swiftmodules for now.
In the long run we're hoping to solve this problem with build configurations,
so that a single module file can support multiple architectures.
(See <rdar://problem/15056323>)

<rdar://problem/15204953>

Swift SVN r13135
2014-01-30 03:26:50 +00:00
Jordan Rose
130ebe4fd4 Revert "Special-case the standard library to always live relative to the compiler."
This reverts r12932; it breaks the iOS simulator build.

Swift SVN r12944
2014-01-24 23:12:24 +00:00
Jordan Rose
4844f22475 Special-case the standard library to always live relative to the compiler.
Import "swift" will now only find "swift.swiftmodule", and only in the
runtime import path.

<rdar://problem/15898866>

Swift SVN r12932
2014-01-24 20:10:26 +00:00
Jordan Rose
11008f0ed1 Split diagnostics out into separate files.
Thanks to the way we've set up our diagnostics engine, there's not actually
a reason for /everything/ to get rebuilt when /one/ diagnostic changes.
I've split them up into five categories for now: Parse, Sema, SIL, IRGen,
and Frontend, plus a set of "Common" diagnostics that are used in multiple
areas of the compiler. We can massage this later.

No functionality change, but should speed up compile times!

Swift SVN r12438
2014-01-17 00:15:12 +00:00
Greg Parker
0e360cb26e Install stdlib into /usr/lib/swift/<OS name>/.
This reinstates r11411 with fixes for the autoconf+make build.


Swift SVN r11494
2013-12-20 01:01:35 +00:00
Chris Lattner
073974dca4 revert r11411, which completely broke the makefile build.
Swift SVN r11414
2013-12-18 04:33:58 +00:00
Greg Parker
9032632299 Install stdlib into /usr/lib/swift/<OS name>/.
Swift SVN r11411
2013-12-18 02:19:29 +00:00
John McCall
7173cec9db Thread contextual information about parsing the top-level
through various bits and use that to globally discriminate.

Swift SVN r11379
2013-12-17 04:31:40 +00:00
Connor Wakamo
1ecc5cc3e6 [frontend] Moved ImportSearchPaths out of CompilerInvocation/ASTContext and into SearchPathOptions.
Also updated findModule() in SourceLoader.cpp and SerializedModuleLoader.cpp to get the ImportSearchPaths from the ASTContext’s SearchPathOpts, instead of directly from the ASTContext.

Swift SVN r11214
2013-12-12 22:15:58 +00:00
Connor Wakamo
86b4a3b049 [frontend] Begin moving search path-related options into SearchPathOptions.
Added a new SearchPathOptions class to swiftAST, which will contain options like import search paths and the SDK path.
Moved the RuntimeIncludePath from CompilerInvocation into SearchPathOptions. For now, at least, the RuntimeIncludePath is handled separately from other ImportSearchPaths, since we can’t yet guarantee that RuntimeIncludePath is set up before we parse the ImportSearchPaths.
Added a SearchPathOptions member to ASTContext.
Updated findModule() in SourceLoader.cpp and SerializedModuleLoader.cpp to check RuntimeIncludePath after everything else if no module was found. (This matches existing behavior, which had RuntimeIncludedPath at the end of ImportSearchPaths.)

Swift SVN r11213
2013-12-12 21:38:11 +00:00
Jordan Rose
417b5d3982 Merge TranslationUnit into Module, and eliminate the term "translation unit".
This completes the FileUnit refactoring. A module consists of multiple
FileUnits, which provide decls from various file-like sources. I say
"file-like" because the Builtin module is implemented with a single
BuiltinUnit, and imported Clang modules are just a single FileUnit source
within a module.

Most modules, therefore, contain a single file unit; only the main module
will contain multiple source files (and eventually partial AST files).

The term "translation unit" has been scrubbed from the project. To refer
to the context of declarations outside of any other declarations, use
"top-level" or "module scope". To refer to a .swift file or its DeclContext,
use "source file". To refer to a single unit of compilation, use "module",
since the model is that an entire module will be compiled with a single
driver call. (It will still be possible to compile a single source file
through the direct-to-frontend interface, but only in the context of the
whole module.)

Swift SVN r10837
2013-12-05 01:51:15 +00:00
Jordan Rose
8b8cc8ee62 Turn SerializedModule into SerializedASTFile.
Part of the FileUnit restructuring. A serialized module is now represented as
a TranslationUnit containing a single SerializedASTFile.

As part of this change, the FileUnit interface has been made virtual, rather
than switching on the Kind in every accessor. We think the operations
performed on files are sufficiently high-level that this shouldn't affect us.

A nice side effect of all this is that we now properly model the visibility
of modules imported into source files. Previously, we would always consider
the top-level imports of all files within a target, whether re-exported or
not.

We may still end up wanting to distinguish properties of a complete Swift
module file from a partial AST file, but we can do that within
SerializedModuleLoader.

Swift SVN r10832
2013-12-05 01:51:09 +00:00
Argyrios Kyrtzidis
ddd47be812 [SourceLoader] When importing a source file, check if the source file has already been added
to the SourceManager.

Swift SVN r10328
2013-11-10 23:49:36 +00:00