Commit Graph

735 Commits

Author SHA1 Message Date
Xi Ge
5430ad50fa Frontend: change return type of CompilerInstance::getInputBuffersIfPresent to be Optional. NFC 2019-10-09 15:29:52 -07:00
Xi Ge
e9dfdea6fd SerializeLoc: serialize basic decl source location information to .swiftsourceinfo file
After setting up the .swiftsourceinfo file, this patch starts to actually serialize
and de-serialize source locations for declaration. The binary format of .swiftsourceinfo
currently contains these three records:

BasicDeclLocs: a hash table mapping from a USR ID to a list of basic source locations. The USR id
could be retrieved from the following DeclUSRs record using an actual decl USR. The basic source locations
include a file ID and the results from Decl::getLoc(), ValueDecl::getNameLoc(), Decl::getStartLoc() and Decl::getEndLoc().
The file ID could be used to retrieve the actual file name from the following SourceFilePaths record.
Each location is encoded as a line:column pair.

DeclUSRS: a hash table mapping from USR to a USR ID used by location records.

SourceFilePaths: a hash table mapping from a file ID to actual file name.

BasicDeclLocs should be sufficient for most diagnostic cases. If additional source locations
are needed, we could always add new source location records without breaking the backward compatibility.
When de-serializing the source location from a module-imported decl, we calculate its USR, retrieve the USR ID
from the DeclUSRS record, and use the USR ID to look up the basic location list in the BasicDeclLocs record.

For more details about .swiftsourceinfo file: https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation
2019-10-09 15:29:51 -07:00
swift-ci
c006f6dc07 Merge remote-tracking branch 'origin/master' into master-next 2019-10-04 13:09:32 -07:00
Jordan Rose
b32e82c720 More idiomatic use of llvm::hash_combine in many places (#27497)
- No need to hash input values first
- Pass many values to a single hash_combine to save on intermediates
- Use hash_combine_range instead of a loop of hash_combines

No functionality change.
2019-10-04 13:08:24 -07:00
swift-ci
7fd05165cd Merge remote-tracking branch 'origin/master' into master-next 2019-09-26 12:50:17 -07:00
swift-ci
349d6b073e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-26 12:44:18 -07:00
Harlan Haskins
b904133c42 [Modules] Add flag to skip non-inlinable function bodies
This flag, currently staged in as `-experimental-skip-non-inlinable-function-bodies`, will cause the typechecker to skip typechecking bodies of functions that will not be serialized in the resulting `.swiftmodule`. This patch also includes a SIL verifier that ensures that we don’t accidentally include a body that we should have skipped.

There is still some work left to make sure the emitted .swiftmodule is exactly the same as what’s emitted without the flag, which is what’s causing the benchmark noise above. I’ll be committing follow-up patches to address those, but for now I’m going to land the implementation behind a flag.
2019-09-26 10:40:11 -07:00
swift-ci
76e7b1d2eb Merge remote-tracking branch 'origin/master' into master-next 2019-09-24 20:50:21 -07:00
swift-ci
e010cb4cd4 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-24 20:43:47 -07:00
Xi Ge
3103b5cec1 Frontend: set up output file .swiftsourceinfo
This patch will focus on teaching driver and frontend to emit this file.
The actual content and de-serialization parts will come later.

More details: https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation/28794
2019-09-24 13:52:17 -07:00
swift-ci
a9e39bdb21 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-13 21:03:33 -07:00
swift-ci
0c440ff5ef Merge remote-tracking branch 'origin/master' into master-next 2019-09-13 20:49:32 -07:00
Harlan Haskins
c82c9b8210 [ModuleInterfaces] Remove references to 'parseable' interfaces everywhere
Now that we've settled on Module Interface as the name, let's remove the
vestiges of "Parseable Interfaces"
2019-09-13 14:55:48 -07:00
Harlan Haskins
fafc5832fe [ModuleInterfaces] ParseableInterfaceModuleLoader -> ModuleInterfaceLoader
Rename this class to better fit the user-facing name.
2019-09-13 13:40:01 -07:00
Mike Ash
f5e7ab866c Merge branch 'master' into master-next 2019-09-09 12:11:25 -04:00
swift-ci
397ff4ce05 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-06 23:23:36 -07:00
Slava Pestov
01e65e18c4 SIL: Share TypeConverter between SILModules in batch mode 2019-09-06 21:50:15 -04:00
Erik Eckstein
56ecda51fa Merge remote-tracking branch 'origin/master' into master-next 2019-09-03 20:42:28 +02:00
swift-ci
0e4feadfbc Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-03 10:23:48 -07:00
Doug Gregor
d7f6768a9d Eliminate DelayedParsingCallbacks.
DelayedParsingCallbacks only had one implementation, for code
completion, which is only used to determine which bodies to skip and
which to delay. Inline that logic into the parser's delay logic and
remove DelayedParsingCallbacks entirely.
2019-09-02 19:03:07 -07:00
Erik Eckstein
34c88a95f6 Merge remote-tracking branch 'origin/master' into master-next 2019-09-01 10:08:17 +02:00
swift-ci
0591c81677 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-31 19:24:16 -07:00
Doug Gregor
9249966b8c [Source loader] Delay parsing and type checking for source imports.
Use the delayed parsing of function bodies for source imports, and
switch source imports over to lazy type checking. There's no point in
doing a full type check for them.
2019-08-31 16:27:45 -07:00
swift-ci
8f203f3930 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-30 14:44:12 -07:00
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
swift-ci
f1318a890a Merge remote-tracking branch 'origin/master' into master-next 2019-08-29 14:10:41 -07:00
swift-ci
86bdfeb467 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-29 14:04:23 -07:00
Doug Gregor
d8f7c9e72c [Parser] Introduce a request for parsing type and extension members.
Ensure that lazy parsing of the members of nominal type definitions
and extensions is handled through a request. Most of the effort here
is in establishing a new request zone for parser requests.
2019-08-28 21:39:56 -07:00
Arnold Schwaighofer
02b908dca3 Merge remote-tracking branch 'origin/master' into master-next 2019-08-28 06:51:13 -07:00
swift-ci
ce527a1b3c Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-27 21:24:26 -07:00
Xi Ge
1e656662d9 Frontend: add a front-end option to specify module names for which we prefer to loading via interfaces
ABI checker imports Swift frameworks by using Swift interfaces for various
reasons. The existing way of controlling preferred importing mechanism is by
setting an environment variable (SWIFT_FORCE_MODULE_LOADING), which may lead
to performance issues because the stdlib could also be loaded in this way.

This patch adds a new front-end option to specify module names for
which we prefer to importing via Swift interface. The option currently is only
accessible via swift-api-digester.

rdar://54559888
2019-08-27 19:40:58 -07:00
Jonas Devlieghere
5c5041235b Merge Swift & Clang VFS in the ClangImporter
The clang importer has to deal with two virtual file systems, one coming
from clang, and one coming from swift. Currently, if both are set, we
emit a diagnostic that we'll pick the swift one.

This commit changes that, by merging the two virtual file systems. The
motivation for this change is the reproducer infrastructure in LLDB,
which adds a third virtual file system to the mix.

(cherry picked from commit 94ef5431ff)
2019-08-19 16:53:03 -07:00
Jonas Devlieghere
b4d268e9e1 Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances in the swift repo.
2019-08-15 11:32:39 -07:00
swift-ci
032def3316 Merge remote-tracking branch 'origin/master' into master-next 2019-08-14 11:50:24 -07:00
Adrian Prantl
c08a62764a Move DWARFImporterDelegate into ClangImporter and remove DWARFImporter.
This refactors DWARFImporter to become a part of ClangImporter, since
it needs access to many of its implementation details anyway. The
DWARFImporterDelegate is just another mechanism for deserializing
Clang ASTs and once we have a Clang AST, the processing is effectively
the same.
2019-08-14 10:28:50 -07:00
swift-ci
4c74733cfc Merge remote-tracking branch 'origin/master' into master-next 2019-08-13 10:10:24 -07:00
Slava Pestov
39cf99c13b Frontend: PersistentParserState needs to outlive performSema()
We want SILGen and IRGen to also be able to trigger delayed parsing if
necessary, so tweak things here a bit. For now this is NFC, since name
lookup triggers delayed parsing of all types and extensions the first
time a name lookup is performed -- but that is about to change.
2019-08-12 17:15:51 -04:00
swift-ci
45a68771f4 Merge remote-tracking branch 'origin/master' into master-next 2019-08-09 15:50:33 -07:00
Harlan Haskins
7f07db5466 Merge pull request #26481 from owenv/print_diag_names
Add -debug-diagnostic-names frontend flag
2019-08-09 15:44:26 -07:00
Jonas Devlieghere
2b5d641a81 Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	lib/ClangImporter/ClangImporter.cpp
2019-08-07 10:39:10 -07:00
Adrian Prantl
9b045d555b Introduce a DWARFImporter delegate that can look up clang::Decls by name.
Traditionally a serialized binary Swift module (as used in debug info)
can only be imported if all of its Clang dependencies can be imported
*from source*.

- Swift's ClangImporter imports Clang modules by converting Clang AST
  types into Swift AST types.

- LLDB knows how to find Clang types in DWARF or other debug info and
  can synthesize a Clang AST from that information.

This patch introduces a DWARFImporter delegate that is implemented by
LLDB to connect these two components. With this, a Clang type can be
found (by name) in the debug info and handed over to ClangImporter to
create a Swift type from it.  This path has lower fidelity than
importing the Clang modules from source, since it is missing out on
Swiftication annotations and other metadata that is not serialized in
DWARF, but it's invaluable as a fallback mechanism for the debugger
when source code for the Clang modules isn't available or the modules
are otherwise not buildable.

rdar://problem/49233932
2019-08-06 18:05:46 -07:00
Owen Voorhees
e7a1a1cc3d Add -debug-diagnostic-names frontend flag
This flag adds diagnostic names to the end of their messages, e.g. 'error: cannot convert value of type '[Any]' to specified type '[Int]' [cannot_convert_initializer_value]'. It's intended to be used for debugging purposes when working on the compiler.
2019-08-05 18:54:21 -07:00
swift-ci
a8387dab9e Merge remote-tracking branch 'origin/master' into master-next 2019-08-04 20:10:01 -07:00
Davide Italiano
d441798b32 [IDE/CodeCompletion] Register the request evaluator. 2019-08-02 15:57:57 -07:00
swift-ci
9cbb87abb2 Merge remote-tracking branch 'origin/master' into master-next 2019-07-22 14:09:39 -07:00
Xi Ge
77ba3a21b4 IDE+Evaluator: refactor the implementation of two type checker utilities to evaluator requests. NFC
IDE functionality needs some internal type checking logics, e.g. checking
whether an extension is applicable to a concrete type. We used to directly
expose an header from sema called IDETypeChecking.h so that IDE functionalities
could invoke these APIs. The goal of the commit and following commits is to
expose evaluator requests instead of directly exposing function entry points from
sema so that we could later move IDETypeChecking.h to libIDE and implement these functions
by internally evaluating these requests.
2019-07-22 12:49:36 -07:00
swift-ci
2608be787b Merge remote-tracking branch 'origin/master' into master-next 2019-07-19 14:29:42 -07:00
Xi Ge
4d57590fa9 IDE+Evaluator: refactor the implementation of two common IDE utilities to the evaluator model
These APIs are 'canDeclProvideDefaultImplementationFor' and 'collectAllOverriddenDecls'.
2019-07-19 11:14:21 -07:00
Jonas Devlieghere
94ef5431ff Merge Swift & Clang VFS in the ClangImporter
The clang importer has to deal with two virtual file systems, one coming
from clang, and one coming from swift. Currently, if both are set, we
emit a diagnostic that we'll pick the swift one.

This commit changes that, by merging the two virtual file systems. The
motivation for this change is the reproducer infrastructure in LLDB,
which adds a third virtual file system to the mix.
2019-07-18 16:29:08 -07:00
marcrasi
eb8f384c01 fix SourceKit injected VFS with .swiftinterface files
Use `.setFileSystem()` instead of new `setup` method.
2019-07-16 10:19:24 -07:00