Commit Graph

703 Commits

Author SHA1 Message Date
Rintaro Ishizaki
54f0fab93e [IDE] Add TypeContextInfo callbacks to parser
TypeContextInfo is for new SourceKit request which receives source
location, and returns context type and members which can be referenced
by "implicit member expression" syntax.

Implement that as a code completion callbacks.
2019-01-10 17:52:37 +09:00
Slava Pestov
f49e0ba330 AST: Remove unused DeclContext and GenericEnvironment from mangling 2018-11-09 00:44:29 -05:00
Slava Pestov
0b0d7dcff9 Sema: Remove most of the remaining Swift 3 support 2018-10-08 18:43:52 -07:00
Bruno Rocha
bf84b297f8 [SourceKit] Allow module references to be indexed (#19243)
Module references get indexed as a 'module' symbol; they get USRs similar to how clang would assign a USR for a module reference.

JIRA: https://bugs.swift.org/browse/SR-8677
2018-09-28 12:21:38 -07:00
Xi Ge
c0d52fd70e swift-ide-test: input complete test is for REPL. 2018-09-12 12:42:41 -07:00
Xi Ge
24b0eac9a4 Parser: parse members in extension decls incrementally. 2018-09-05 17:00:39 -07:00
Davide Italiano
1289b49615 [Parse] Store local typealiases, they matter for type reconstruction.
Fixes <rdar://problem/42446693>

(Thanks to Jordan for pointing out the solution)
2018-09-04 17:00:01 -07:00
Jordan Rose
2f6b4cdbe8 Merge pull request #19054 from jrose-apple/nocturnal
Honor #sourceLocation filenames in several more places
2018-08-30 13:02:50 -07:00
Jordan Rose
c06dc63654 [IDE] Honor #sourceLocation in swift-ide-test's comment printing 2018-08-29 11:46:41 -07:00
Xi Ge
30e73ec995 swift-ide-test: teach the test driver to accept RequestEvaluatorGraphVizPath. 2018-08-29 11:13:22 -07:00
Jordan Rose
e4e4f3e4f5 Break Driver's dep on Frontend: make createCompilerInvocation uglier
But not even that much uglier; at all three call sites this will save
an allocation, and for the most important one (SourceKit) we can now
avoid creating a temporary CompilerInvocation just to copy into a
longer-lived one.

With this change, Driver no longer depends on Frontend, which means...
well, slightly faster builds of the compiler itself, but not much
else.
2018-08-27 20:47:58 -07:00
John McCall
b80618fc80 Replace materializeForSet with the modify coroutine.
Most of this patch is just removing special cases for materializeForSet
or other fairly mechanical replacements.  Unfortunately, the rest is
still a fairly big change, and not one that can be easily split apart
because of the quite reasonable reliance on metaprogramming throughout
the compiler.  And, of course, there are a bunch of test updates that
have to be sync'ed with the actual change to code-generation.

This is SR-7134.
2018-08-27 03:24:43 -04:00
Jordan Rose
061204c704 Remove "IFK_" prefix from enum class InputFileKind
I suspect this was converted from a non-scoped enum in the past.
No functionality change.
2018-08-07 08:54:31 -07:00
Alex Hoppen
749a13a6fe [libSyntax] Remove the C++ SyntaxClassifier
The recommended way forward is to use the SyntaxClassifier on the Swift
side.

By removing the C++ SyntaxClassifier, we can also eliminate the
-force-libsyntax-based-processing option that was used to bootstrap
incremental parsing and would generate the syntax map from a syntax
tree.
2018-07-30 09:26:18 -07:00
John McCall
7a4aeed570 Implement generalized accessors using yield-once coroutines.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.

`_read` accessors do not make any effort yet to avoid copying the
value being yielded.  I'll work on it in follow-up patches.

Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.

SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.

rdar://35399664
2018-07-23 18:59:58 -04:00
Alex Hoppen
c8226d1507 [libSyntax] Make a typealias to unsigned to represent SyntaxNodeIds 2018-07-19 13:57:08 -07:00
Alex Hoppen
8430eff670 [libSyntax] Add syntax coloring based on the syntax tree 2018-07-13 17:48:47 -07:00
Doug Gregor
b41e98ef02 [swift-ide-test] Emit a diagnostic if we can't find the module to print.
Fixes rdar://problem/41048812.
2018-06-26 13:35:30 -07:00
John McCall
9022b5152f Rename accessor kinds from IsGetter -> IsGet, etc.
Introduce some metaprogramming of accessors and generally prepare
for storing less-structured accessor lists.

NFC except for a change to the serialization format.
2018-06-14 17:08:55 -04:00
Adrian Prantl
bab3000069 Use depth and index to lookup type metadata artificial variables
instead of using name and decl context.

The advantages of this approach are three-fold:
- This is necessary to support inlined generic functions.
- We can retire the debugger-specific type name manfgling mode for archetypes.
- This saves 270kb of debug information in the x86_64 libSwiftCore.dylib alone.

<rdar://problem/38306256>
2018-06-12 12:48:15 -07:00
Jordan Rose
18162a3ed0 Revert "AST: Simplify ModuleDecl::forAllVisibleModules()"
This reverts commit 0c32c54e36.
2018-05-03 22:40:37 -06:00
Slava Pestov
0c32c54e36 AST: Simplify ModuleDecl::forAllVisibleModules() 2018-04-26 23:37:16 -07:00
Jordan Rose
4c47bd1104 [swift-ide-test] Bail out when a module couldn't be loaded (#15563)
The importer in particular depends on the stdlib and the Foundation
overlay being successfully loaded, so if anything /can't/ be loaded
we have to assume that trying to walk a module's decls will result
in a crash.

rdar://problem/37540394
2018-03-28 10:09:52 -07:00
Jordan Rose
3cd9f166bc Don't spend time initializing LLVM when running the driver (#14896)
Tiny start-up time optimization noticed while looking at how we do
PrettyStackTraceProgram. Also add PrettyStackTraceProgram to a few
more of our testing tools, via the new PROGRAM_START macro.
2018-02-28 19:56:19 -08:00
John Fairhurst
677491fc9b [SourceKit] Add syntaxtype for #error/#warning (#14742) 2018-02-21 14:48:18 -08:00
Joe Groff
eb316818c5 Demangler: Fill in places we need to handle symbolic references and OtherNominalTypes when demangling bound generic types. 2018-02-20 18:20:09 -08: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
Huon Wilson
cb60dbeee2 [IDE] Teach type checker about conditional conformance extensions.
Before conditional conformances, the archetypes in conformance
extensions (i.e. extension Foo: SomeProtocol) were equivalent to those
in the type decl, with the same protocol bounds and so on. The code for
printing "synthesized" members relied on this fact. This commit teaches
that code to deal with archetypes in the conditional conformance
extension when required.

Fixes rdar://problem/36553066 and SR-6930.
2018-02-13 17:37:15 +11:00
David Ungar
a9819b6e60 Renaming FrontendInputs -> FrontendInputsAndOutputs
Fix comment in ArtsToFrontendOptionsConverter re getOutputFilenamesFromCommandLineOrFilelist
2018-01-30 18:54:38 -08:00
Argyrios Kyrtzidis
f0c0405353 Merge pull request #13916 from akyrtzi/fix-clang-headers-order
[ClangImporter] Make sure that headers from the bridging header are considered 'isBeforeInTranslationUnit' compared to headers imported from swift code
2018-01-12 22:38:28 -08:00
Argyrios Kyrtzidis
18dfb2810a [swift-ide-test] Provide option '-code-completion-comments' for swift-ide-test to print documentation comments for the completion results 2018-01-12 16:09:03 -08:00
John McCall
7f0f8830cd Split AccessorDecl out from FuncDecl. NFC.
This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
2018-01-12 14:20:27 -05:00
Jordan Rose
4a73f0daef Merge pull request #13519 from jrose-apple/mangle-imports-using-c-name
Mangle imported declarations using their C names

rdar://problem/24688918
2018-01-10 18:12:17 -08:00
Jordan Rose
d05073adbe swift-ide-test: Correctly infer -enable-objc-interop from a target (#13853)
Note that this /still/ isn't correct when there /isn't/ an explicit
target, because LangOptions doesn't set up platform conditions when no
target is explicitly set. But it's a step forward.
2018-01-10 14:27:15 -08:00
Jordan Rose
b7ff0d49ef Type reconstruction: look for Clang types directly, like RemoteAST
ClangImporter::lookupTypeDecl allows a Clang type declaration to be
imported by Clang name instead of by Swift name. Now that we're using
Clang names in mangled names, that's exactly what we need to
reconstruct an AST type from a mangled name.

Also:

- Handle @compatibility_alias in ClangImporter::lookupTypeDecl

- Print errors when type reconstruction fails in swift-ide-test

- Add an extra test for RemoteAST
2018-01-09 17:55:24 -08:00
Marcelo Fabri
94465a38c0 [SourceKit] Add GenericTypeParam to structure (SR-5474) (#13616) 2018-01-09 17:28:52 -08:00
Marcelo Fabri
b6ecf9c6d4 [SourceKit] Introduce "source.lang.swift.expr.closure" in structure (SR-6116) (#13617) 2018-01-04 10:45:29 -08:00
Ben Langmuir
93956eb34b [code-complete] Put call-pattern heuristics under a flag
The original hope was we could make these heuristics really good, but
since that is not currently in sight (and may never be), we want to be
able to turn them off.  For now, just plumb through an internal flag to
control the behaviour.  A future change will customize the behaviour in
SourceKit.

rdar://31113161
2017-12-15 13:23:44 -08:00
David Ungar
28b206008f FrontendInputs data structure redo.
- Outlaw duplicate input files, fix driver, fix tests, and add test.
- Reflect that no buffer is present without a (possibly pseudo) named file.
- Reflect fact that every input has a (possible pseudo) name.
- Break up CompilerInstance::setup.

Don't bail on dups.
2017-12-05 17:28:03 -08:00
David Ungar
83ee8cb7f0 Merge pull request #12920 from davidungar/Move-input-conversion
Move input conversion
2017-11-27 17:13:48 -08:00
David Ungar
6a860e38f0 Don’t clearPrimaryInputs for swift-ide-test, set primary to first file. 2017-11-15 13:13:35 -08:00
Francis Ricci
71477f0dda Merge pull request #12702 from fjricci/objc_interop
Objc interop
2017-11-15 14:45:22 -05:00
David Ungar
3f3d784144 Factor code from tools & move input conversion. 2017-11-14 20:48:59 -08:00
Slava Pestov
a70a1f0d36 IDE: Fix bug in SourceEntityWalker subscript handling
We weren't passing the lvalue access kind to the subscript.
This was causing a test to fail with the next patch.
2017-11-13 22:19:25 -08:00
Slava Pestov
0715eaeaed AST: Move SourceEntityWalker to IDE 2017-11-13 22:10:41 -08:00
Francis Ricci
3c417d531e swift-ide-test: Allow objc-interop to be configured
This adds a -disable-objc-interop flag to allow objc-interop
to be disabled, and an -enable-objc-interop flag to
allow objc-interop to be enabled.

Objc interop will default to enabled on darwin, and disabled on
other platforms.
2017-11-06 13:30:37 -08:00
Xi Ge
6af5d3c0bf libSyntax: rename KeepTokensInSourceFile to KeepSyntaxInfoInSourceFile. 2017-11-03 18:39:01 -07:00
Xi Ge
4ee32a125e [test] Always enable libSyntax creation in swift-ide-test to get some free test coverage. NFC 2017-11-03 18:39:01 -07:00
David Ungar
c1821755de NFC: First step (refactoring) towards speeding up compilation by having multiple primary files: Creates new class, FrontendInputs, to encapsulate InputFilenames, InputBuffers, and PrimaryInput, which were formerly in FrontendOptions. Add new instance variable, Inputs, to FrontendOptions in order to hold FrontendInputs.
Encapsulate uses of the variables in FrontendInputs with intention-describing functions. Move some code that sets these variables into FrontendInputs and FrontendOptions classes.

Create new FrontendInputs class to encapsulate InputFilenames, InputBuffers and PrimaryInput, which were formerly in Frontend.

Includes one change in SwiftEditor.cpp to resolve a merge conflict.
2017-10-08 10:20:37 -07:00
Marcelo Fabri
95383df793 [SourceKit] Introduce "source.lang.swift.expr.tuple" (SR-5977) (#12089) 2017-09-27 10:08:27 -07:00