Commit Graph

60 Commits

Author SHA1 Message Date
Bruno Rocha
f000639cce Improve tests and generate the rest of the output 2020-05-29 18:59:25 +02:00
Bruno Rocha
2a48e19ff0 [SourceKit] Add Effective Scope to Index 2020-05-29 18:59:25 +02:00
Hamish Knight
6477cc68eb [Serialization] Delay adding ModuleFiles until they're loaded
Rather than adding a ModuleFile to a parent module
and then removing it afterwards if it fails to
load, let's wait until we've loaded the file before
deciding to add it to the parent module. This then
allows us to get rid of `ModuleDecl::removeFile`.

In addition, push down the calls to `addFile` into
the callers of `loadAST` in preparation for
`addFile` being replaced with a one-time-only call
to a `setFiles` method.
2020-05-28 12:09:10 -07:00
Hamish Knight
f810cfcc45 [Serialization] Remove treatAsPartialModule parameter
This information can be derived from whether we're
installing the module file into the main module.
2020-05-28 12:09:10 -07:00
Robert Widmann
6d60d01420 [NFC] Remove the Legacy Semantic Queries Bit
Clients that wish to avoid semantic requests should decline to register
those requests.
2020-03-19 11:04:12 -07:00
Dmitri Gribenko
841eeb05b0 Merge pull request #30403 from MForster/forster/string-fixes
Cherry-pick StringRef->std::string conversion fixes into `master`
2020-03-17 12:09:36 +01:00
Robert Widmann
70b6bbcb13 Remove swift::createTypeChecker
Replace it with the "legacy semantic queries" bit. The remaining client
of this bit is SourceKit, which appears to require this bit be set
conditionally so certain semantic property wrapper requests return
a sentinel value.

We should migrate these requests to a syntactic interface as soon as
possible.

rdar://60516325
2020-03-16 19:20:22 -07:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Varun Gandhi
903add2c3f [Frontend] Make the module trace emission more robust.
✔ More informative error messages in case of crashes.
✔ Handling and documenting different cases.
✔ Test cases for different cases.
✔ Make SDKDependencies.swift pass again.
2019-10-15 15:44:26 -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
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
Argyrios Kyrtzidis
3332b37d00 [Index/SourceKit] Remove the code related to calculating a module hash from the indexing walker
This has been an unnecessary code path for a long time now and should be removed particularly because it triggers wasteful `stat` calls.

rdar://51523161
2019-06-21 17:09:12 -07:00
Jordan Rose
526ea54f43 [Serialization] Preserve @_implementationOnly through module merging
When we build incrementally, we produce "partial swiftmodules" for
each input source file, then merge them together into the final
compiled module that, among other things, gets used for debugging.
Without this, we'd drop @_implementationOnly imports and any types
from the modules that were imported during the module-merging step
and then be unable to debug those types
2019-03-28 16:04:35 -07:00
Nathan Hawes
7680cc6b16 [sourcekitd] Report entities that are implicitly objc as objc in the index request responses for compatibility
Members of an @objcMembers context previous had implicit @objc attributes, but
now don't (possibly because of the request evaluator changes?). This updates the
output of sourcekitd's 'index' request to act as if they still had implicit
@objc attributes on them for compatibility.

Resolves rdar://problem/48140265
2019-02-22 16:35:30 -08:00
Nathan Hawes
e5e9dc6c05 [sourcekitd] Expose the 'implicit' symbol role in the 'index' request response
Resolves rdar://problem/48148270.
2019-02-20 17:12:23 -08:00
Doug Gregor
599e07e5d9 [Type checker] Keep the type checker alive as long as the ASTContext is.
It is possible for the SIL optimizers, IRGen, etc. to request information
from the AST that only the type checker can provide, but the type checker
is typically torn down after the “type checking” phase. This can lead to
various crashes late in the compilation cycle.

Keep the type checker instance around as long as the ASTContext is alive
or until someone asks for it to be destroyed.

Fixes SR-285 / rdar://problem/23677338.
2018-10-10 16:44:42 -07:00
Ben Langmuir
b04ffcca86 [sourcekit] Change getASTManager() to return shared_ptr
Addressing review feedback: this avoids calling shared_from_this() from
outside the implementation.  Note: it is not possible to use private
inheritance of enable_shared_from_this to prevent this issue in general,
because enabled_shared_from_this relies on the shared_ptr constructor
being able to detect that the type has this inheritance, which means it
must be public.
2018-09-25 16:42:41 -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
Ben Langmuir
23ab43c941 [sourcekitd] Change compile notifications to pass a single args string
... instead of an array of compiler arguments. This is good enough
for seeing what's going on, and it saves significant time for long
argument strings, because it doesn't create and destroy so many
xpc strings, and more of the string copying that happens is on a large
contiguous string instead of many small strings.

rdar://39538847
2018-04-19 13:59:27 -07:00
Ben Langmuir
31eae3675b [sourcekitd] Remove XPCTracing
This code was an experiment in how to collect information after a crash,
that did not end up being used.  It's unclear how much it has bitrotted
at this point, since it has no tests and was not designed with automated
testing in mind.  Parts of it interfere with some changes I want to make
to the underlying tracing mechanism, so I am finally removing it.  This
also lets us remove the buffer copying in the parts of tracing used by
the compile notifications, improving performance.

For rdar://39538847
2018-04-19 11:52:38 -07:00
Ben Langmuir
79d641d89b [sourcekit] Add optional compile notifications
When enabled, send a notification before/after every "compilation",
which for now means `performSema`. This piggy-backs and modifies some
existing code that we had for "tracing" operations in sourcekitd that
unfortunately was untested.  At least now some of the basic parts are
tested via the new notifications.

Part of rdar://38438512
2018-03-29 14:59:30 -07:00
Ben Langmuir
38963ce883 [sourcekit] Tweak traced operation to be single-operator per RAII object
This is how it was used in all but one place anyway, and makes it easier
to understand.  It also aligns better with some further refactoring I
want to do...
2018-03-29 14:05:57 -07:00
Ben Langmuir
72bde687e4 [sourcekit] Use the driver to parse command line arguments
Stop parsing frontend arguments directly and use the driver instead. The
most intersting part of this change is that it forces us to consider
whether our compiler invocation will have inputs or not.  We have
several kinds of requests that need to create a compiler instance, but
not parse any inputs (interface-generation, doc-info, and indexing when
operating on a module instead of source files).

Incidentally, add an error when trying to do doc-info on multiple source
files. This was already very broken (assertion failures and bogus source
locations), so add an error for it.

rdar://problem/17897287
2018-02-05 15:49:17 -08:00
David Ungar
a9819b6e60 Renaming FrontendInputs -> FrontendInputsAndOutputs
Fix comment in ArtsToFrontendOptionsConverter re getOutputFilenamesFromCommandLineOrFilelist
2018-01-30 18:54:38 -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
04c16cdebd Incorperate advice from review.
Change “have” routines to “has”.
Use more consistent casing.
Remove spurious “DelayedFunctionParsing” option.
Move debugFail routines to top lexical level.
Rename and reorder declaration of functions in FrontendArgsToOptionsConverter.
Move, reword, and doxygenate comments for some of those functions.
Fix casing on some more setUp* functions.
Return NoneAction instead of existing RequestedAction in FrontendArgsToOptionsConverter::determineRequestedAction.
Remove test names and put in FIXME’s.
Remove “Jordan” from comments & reword.
Reorder if-then arms of FrontendArgsToOptionsConverter::computeOutputFilenames for readability.
Test for empty string instead of equality with “”.
Use hasUnusedModuleDocOutputPath.
Remove optionality from return type of getOutputFilenamesFromCommandLineOrFilelist.
Rename isPrimaryInputAFileAt to isThereAPrimaryInputWithAFilenameAt.
Added a FIXME in doesActionProduceOutput to reflect that some actions actually do not produce output.
2017-11-30 17:28:15 -08:00
Arnold Schwaighofer
1a0443040e Revert "Merge pull request #12952 from davidungar/move-in-to-next"
This reverts commit 911140c7e1, reversing
changes made to 5590a2ff91.

This broke the incremental bot.

rdar://35746584
2017-11-29 08:09:42 -08:00
David Ungar
b4681b154d Incorperate advice from review.
Change “have” routines to “has”.
Use more consistent casing.
Remove spurious “DelayedFunctionParsing” option.
Move debugFail routines to top lexical level.
Rename and reorder declaration of functions in FrontendArgsToOptionsConverter.
Move, reword, and doxygenate comments for some of those functions.
Fix casing on some more setUp* functions.
Return NoneAction instead of existing RequestedAction in FrontendArgsToOptionsConverter::determineRequestedAction.
Remove test names and put in FIXME’s.
Remove “Jordan” from comments & reword.
Reorder if-then arms of FrontendArgsToOptionsConverter::computeOutputFilenames for readability.
Test for empty string instead of equality with “”.
Use hasUnusedModuleDocOutputPath.
Remove optionality from return type of getOutputFilenamesFromCommandLineOrFilelist.
Rename isPrimaryInputAFileAt to isThereAPrimaryInputWithAFilenameAt.
Added a FIXME in doesActionProduceOutput to reflect that some actions actually do not produce output.
2017-11-28 09:21:35 -08:00
David Ungar
26537ea26c Address Jordan’s comments:
- Also be consistent about has vs have for Input predicates

Fix bug.
2017-11-18 14:00:32 -08: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
practicalswift
40cf4d183d [gardening] Use consistent spacing after if, for and while 2017-04-14 17:35:36 +02:00
Nathan Hawes
2684564590 [indexer] report defs/refs of parameters without a separate external name 2017-02-28 11:55:34 -08:00
Argyrios Kyrtzidis
db8ec19f55 [index] Use the index symbol types and APIs from the clang header.
This avoids duplication and centralizes handling of symbols.
2017-01-10 14:49:07 -08:00
Nathan Hawes
563bc04da1 Merge pull request #6677 from nathawes/swift-indexing
Add roles and relations for Swift indexing
2017-01-09 14:48:35 -08:00
Nathan Hawes
32ba5f24cb [indexer] Don't output implicit symbol names in order to maintain the existing swift index responses 2017-01-09 13:48:47 -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
Nathan Hawes
8c45e20d3f [indexer] Add relations to IndexSymbol add a -print-indexed-symbols option to swift-ide-test for testing 2017-01-05 15:01:53 -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
Ben Langmuir
c8f53ff8c4 [index] Disable typo-correction when indexing
The errors won't be captured in the response, and it can be expensive to
do typo-correction when there are many errors, which is common in
indexing.

rdar://problem/28963058
2016-11-09 10:53:26 -08:00
Argyrios Kyrtzidis
ec042460fe [SourceKit] Report attributes of decls for the indexing request. 2016-05-05 16:44:34 -07:00
Ben Langmuir
ad34f89d5b [index] Add UnitTest SymbolSubKind and collapse the IndexSymbol inheritance
Fold UnitTest into the subkind, now that it's a bitself, and then remove
the unnecessary inheritance for IndexSymbol and its SourceKit indexing
equivalent.
2016-04-29 19:04:27 -07:00
Ben Langmuir
6096b8b93c [index] Make IndexSymbol's subkind into a bitset
This follows a similar change to clang indexing, and will allow us to
add overlapping sub kinds such as "UnitTest", etc.
2016-04-29 19:04:26 -07:00
Ben Langmuir
ef4e84b8d6 [index] Subsume CallRefIndexSymbol into IndexSymbol
Eventually we should just have one IndexSymbol, with all the
information. Once we kill FuncDeclIndexSymbol and can get rid of the
enum,  we will regain most of the bytes we lost by inlining receiverUSR.
2016-04-29 19:04:26 -07:00
Ben Langmuir
50eeeb7430 [index] Add 'call' and 'isDynamic' roles 2016-04-29 19:04:25 -07:00
Ben Langmuir
1b1320b9f1 [index] Thread through SymbolRoleSet as a generalization of "bool isRef"
As a first step toward having more detailed "role" information, thread
through a SymbolRole bitset.  For now it just contains the existing ref
vs. definition status.
2016-04-29 19:04:24 -07:00
Ben Langmuir
e977d4bd54 [index] Remove import.sourcefile kind from indexing
We don't support importing source files in source code, and they only
showed up in the index under failure conditions.
2016-04-28 16:51:01 -07:00
Ben Langmuir
8dad7f7803 [index] Split the indexModule entry point for indexSourceFile NFC
Having a single interface for source files and modules and having to
pass in a buffer id was a crappy API. This splits the interface to take
either a Module or a SourceFile and handles the buffer id stuff
internally.
2016-04-15 16:27:30 -07:00
Ben Langmuir
ad269b0e1f [index] Move core indexing code out of SourceKit
Leaving only the SourceKit-specific code (e.g. UID generation) behind in
SourceKit.

rdar://problem/22348041
2016-04-14 13:13:54 -07:00
Ben Langmuir
bfa5a1f67f [index] Factor out the dependency between the core indexing walker and SourceKit
The goal is to be able to move the core IndexSwiftASTWalker code out of
SourceKit, leaving only the serialization bits behind.

Mostly this replaces some direct uses of UIdent strings with explicit
enums, and then adds the translation code to produce those enums and to
convert them into UIdents in SourceKit.

rdar://problem/22348041
2016-04-14 13:13:49 -07:00