Commit Graph

111 Commits

Author SHA1 Message Date
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
Devin Coughlin
082421048a [AST/Sema] Add availability attributes for macCatalyst
Add a platform kind and availability attributes for macCatalyst. macCatalyst
uses iOS version numbers and inherits availability from iOS attributes unless
a macCatalyst attribute is explicitly provided.
2020-01-21 20:27:14 -08:00
Kita, Maksim
c88ac85b3f SR-11889: Fixed code review issues
1. Removed two braces {{ usage of Located initialization
2. Wrapped documentation into 80 characters
2019-12-20 17:18:59 +03:00
Kita, Maksim
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03:00
Owen Voorhees
8a6711769e [Diagnostics] Refactor DiagnosticConsumer interface
DiagnosticInfo now holds all the information needed to consume
a diagnostic, so remove unneeded parameters from handleDiagnostic.
2019-10-29 13:52:12 -07:00
Robert Widmann
060cbb293f [NFC] Downgrade The TypeLoc in VarDecl to a TypeRepr
TypeCheckPattern used to splat the interface type into this, and
different parts of the compiler would check one or the other.   There is
now one source of truth: The interface type.  The type repr is now just
a signal that the user has written an explicit type annotation on
a parameter.  For variables, we will eventually be able to just grab
this information from the parent pattern.
2019-10-11 11:15:51 -07:00
Robert Widmann
5a8d0744c3 [NFC] Adopt TypeBase-isms for GenericSignature
Structurally prevent a number of common anti-patterns involving generic
signatures by separating the interface into GenericSignature and the
implementation into GenericSignatureBase.  In particular, this allows
the comparison operators to be deleted which forces callers to
canonicalize the signature or ask to compare pointers explicitly.
2019-09-30 14:04:36 -07:00
Jordan Rose
8ff1dac381 [AST] Break some header dependencies for faster rebuilds (#27374)
DiagnosticEngine.h no longer depends on Attr.h.
Expr.h no longer depends on TypeRepr.h.

No functionality change.
2019-09-26 09:17:10 -07:00
Robert Widmann
1233cdf596 Update SourceKit for getInterfaceType() changes 2019-09-23 17:24:18 -07:00
Harlan Haskins
2893d96927 [ModuleInterfaces] Escape Type and Protocol when module-qualifying
If we see `MyModule.Type`, the parser thinks this is a metatype type.
Escape the name `Type` so the parser can recognize it's a type name.

Fixes [SR-11422](https://bugs.swift.org/browse/SR-11422) rdar://55094784
2019-09-09 17:20:27 -07:00
Xi Ge
b6e6f69e80 IDE+Evaluator: converge multiple type relation checks into a single sema request, NFC
From libIDE, the utility functions will invoke the request in the implementation.
2019-07-24 12:53:10 -07:00
Ben Langmuir
205371c886 Move storage for VFS into editor document
The invocation options are not an appropriate place to put this state,
since it can change between requests. This moves it to the editor
document, allowing us to change the specific VFS instance without
causing a rebuild (unless the contents/timestamps for a dependency
change).
2019-07-16 10:19:24 -07:00
David Goldman
cb14b8b535 RequestResult class and Pass*InfoForDecl fixes 2019-05-28 04:35:16 -04:00
Joe Groff
7d54810b92 Revert "[SourceKit] Fail requests when an error occurs" 2019-05-22 15:18:28 -07:00
Argyrios Kyrtzidis
729a9558e8 Merge pull request #24124 from DavidGoldman/master
[SourceKit] Fail requests when an error occurs
2019-05-22 10:49:42 -07:00
Xi Ge
1ca8e83aa3 Sourcekit/DocSupport: fix an assertion when generating documentation for extensions with attributes
When sanitizing the documentation comments for synthesized extensions,
we expect some text like "<declaration>extension". This isn't the case
when use-facing attributes are present.

rdar://50913510
2019-05-20 17:43:29 -07:00
Jordan Rose
c622f6b8dd Simplify swift::getInheritedForPrinting to take a PrintOptions
This lets us make some more assumptions in the next commit, but I
think it's also just a nice cleanup to /not/ allow random predicates
here.

There were three callers of this API:

- PrintAST, which was using PrintOptions::shouldPrint but /also/
  incorrectly notifying listeners that a declaration would be skipped.

- (IDE) Interface generation, which uses PrintOptions::shouldPrint to
  count how many "inherits" there will be.

- SwiftDocSupport's reportRelated, which does no filtering at all.
  Creating a PrintOptions here is a little more expensive, but still.

No intended functionality change.
2019-05-14 16:16:28 -07:00
David Goldman
00d771ca6b RequestResult class and Pass*InfoForDecl fixes 2019-05-03 15:17:40 -04:00
Ben Langmuir
effab8c522 Handle dynamic member lookup in annotation and cursor info
Ensure the various entity walkers handle the implicit subscript
reference correctly (usually by ignoring it) and fall through to the
underlying declarations.

rdar://49028895
2019-04-16 15:37:32 -07:00
Ben Langmuir
6af24d083c [index] Fix dynamicMemberLookup subscript reference implicit role
When building the implicit subscript expression, set the "implicit" bit
correctly and pass it through in the indexer so that we get implicit
refernces to the subscript. This would be useful for e.g. searching for
all uses of the dynamic subscript.
2019-04-16 15:37:32 -07:00
David Ungar
44daa88ebd Format 2019-04-03 12:53:31 -07:00
David Ungar
9cc3a4a9d8 Rename defaultDiagnosticLoc to bufferIndirectlyCausingDiagnostic. 2019-04-03 12:52:49 -07:00
David Ungar
c139c5909a Pass defaultDiagnosticLoc to handleDiagnostic, not currentPrimaryInput. 2019-04-02 22:27:55 -07:00
David Ungar
c90d9e69b6 Format 2019-04-02 00:43:59 -07:00
David Ungar
7a0e0ffc8a Store current primary in diagnostic engine, pass it down via handleDiagnostic. Unformmated. 2019-04-02 00:43:28 -07:00
Robert Widmann
c5b7230d22 [NFC] Upgrade EnumElementDecl to a DeclContext
Pure plumbing for the sake of default arguments.
2019-01-16 18:39:30 -05:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Xi Ge
d620dfae5e Sourcekit/DocSupport: include fully annotated generic signatures for extension decls. rdar://40906297 2018-12-04 14:29:28 -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
37ec248823 Add ModuleDecl::ReverseFullNameIterator
Package up the logic that generates a full Clang module name, so that
(a) we don't have to deal with clang::Module in quite as many places
in the /Swift/ compiler, and (b) we can avoid the cost of a temporary
string in a few places.

The main places where this is /not/ adopted is where we don't just
want to know the parent module name, but actually the module itself.
This is mostly indexing-related queries, which use the very similar
ModuleEntity class also defined in Module.h. I didn't quite see an
obvious way to unify these, but that might be where we want to go.

No functionality change.
2018-09-06 19:53:59 -07:00
Jordan Rose
537954fb93 [AST] Rename several DeclContext methods to be clearer and shorter (#18798)
- getAsDeclOrDeclExtensionContext -> getAsDecl

This is basically the same as a dyn_cast, so it should use a 'getAs'
name like TypeBase does.

- getAsNominalTypeOrNominalTypeExtensionContext -> getSelfNominalTypeDecl
- getAsClassOrClassExtensionContext -> getSelfClassDecl
- getAsEnumOrEnumExtensionContext -> getSelfEnumDecl
- getAsStructOrStructExtensionContext -> getSelfStructDecl
- getAsProtocolOrProtocolExtensionContext -> getSelfProtocolDecl
- getAsTypeOrTypeExtensionContext -> getSelfTypeDecl (private)

These do /not/ return some form of 'this'; instead, they get the
extended types when 'this' is an extension. They started off life with
'is' names, which makes sense, but changed to this at some point.  The
names I went with match up with getSelfInterfaceType and
getSelfTypeInContext, even though strictly speaking they're closer to
what getDeclaredInterfaceType does. But it didn't seem right to claim
that an extension "declares" the ClassDecl here.

- getAsProtocolExtensionContext -> getExtendedProtocolDecl

Like the above, this didn't return the ExtensionDecl; it returned its
extended type.

This entire commit is a mechanical change: find-and-replace, followed
by manual reformatted but no code changes.
2018-08-17 14:05:24 -07: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
Doug Gregor
bd5f5d80e4 [AST] Add ExtensionDecl::getExtendedNominal().
Introduce ExtensionDecl::getExtendedNominal() to provide the nominal
type declaration that the extension declaration extends. Move most
of the existing callers of the callers to getExtendedType() over to
getExtendedNominal(), because they don’t need the full type information.

ExtensionDecl::getExtendedNominal() is itself not very interesting yet,
because it depends on getExtendedType().
2018-08-03 11:26:48 -07:00
Slava Pestov
5213f80e7e IDE: Remove uses of AbstractFunctionDecl::getParameterLists() 2018-07-22 20:56:56 -07:00
Xi Ge
714775eb0a DocSupport: don't assume we've printed the first extension when merging several together. rdar://39887195
When printing the content of several extensions into a
synthesized one, we shouldn't assume the first extension in the
group always gets printed.
2018-05-02 17:46:41 -07:00
Doug Gregor
b2b69e8abf Rename BoundNameAliasType to NameAliasType.
NameAliasType is dead! Long live NameAliasType!
2018-03-25 21:35:17 -07:00
Doug Gregor
c43f96a855 [AST] Remove now-unused NameAliasType. 2018-03-25 21:35:16 -07:00
Doug Gregor
253bd10bd3 Cope with BoundNameAliasType in more places that handle NameAliasType. 2018-03-21 23:49:33 -07:00
John Fairhurst
677491fc9b [SourceKit] Add syntaxtype for #error/#warning (#14742) 2018-02-21 14:48:18 -08:00
Huon Wilson
56cf07752d Merge pull request #14554 from huonw/doc-conditional-conformances
[IDE] Teach type checker about conditional conformance extensions.
2018-02-14 07:21:11 +11: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
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
354a76ac4e Merge pull request #14198 from davidungar/PR-18-3c-exp2
[Batch mode] Move frontend main output files to FrontendInputsAndOutputs. (1)
2018-02-01 16:42:10 -08:00
David Ungar
a9819b6e60 Renaming FrontendInputs -> FrontendInputsAndOutputs
Fix comment in ArtsToFrontendOptionsConverter re getOutputFilenamesFromCommandLineOrFilelist
2018-01-30 18:54:38 -08:00
Xi Ge
98570550c3 [SourceKit] Report synthesized protocol conformances for DocSupport request. rdar://36882292 (#14248) 2018-01-30 13:32:50 -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
Davide Italiano
cd80f8369a [SourceKit] Make explicitly we're casting away a qualifier.
This fixes a clang warning introduced with this code. NFCI.
2017-12-01 13:19:45 -08:00