Commit Graph

481 Commits

Author SHA1 Message Date
Slava Pestov
b26ba2dce9 AST: Add utilities to ASTContext for looking up builtin initializers 2019-05-23 10:40:34 -04:00
Joe Groff
2ade303387 IRGen: Weak-link opaque type entry points.
When backward deploying to an OS that may not have these entry points, weak-link them so that they
can be used conditionally in availability contexts that check for them.

rdar://problem/50731151
2019-05-15 20:40:54 -07:00
Rintaro Ishizaki
acd4cb1a9d [ASTContext] Remove unused function and includes 2019-05-08 10:12:29 -07:00
Rintaro Ishizaki
6956089b0b [CodeCompletion] Complete Swift only module name after 'import'
rdar://problem/39392446
2019-05-08 10:11:52 -07:00
Doug Gregor
b8061eab34 Synthesize backing storage property for properties with attached delegates.
When a property has an attached property delegate, a backing storage
property of the corresponding delegate type will be
synthesized. Perform this synthesis, and also synthesize the
getter/setter for the original property to reference the backing
storage property.
2019-04-23 11:31:58 -07:00
Slava Pestov
949fe16da5 AST: Move a bunch of random @objc diagnostics to Sema 2019-04-22 20:42:08 -04:00
Slava Pestov
07ce01d96d AST: Replace ASTContext's ObjCMethodConflicts list with a per-SourceFile list 2019-04-22 20:42:08 -04:00
Slava Pestov
0fae7e8669 AST: Replace ASTContext's ObjCUnsatisfiedOptReqs list with a per-SourceFile list 2019-04-22 20:42:08 -04:00
Slava Pestov
e97fc4e0c2 AST: Replace ASTContext's ObjCMethods list with a per-SourceFile list 2019-04-22 20:42:07 -04:00
Joe Groff
71912bbfd6 AST: Represent OpaqueTypeDecls.
To represent the abstracted interface of an opaque type, we need a generic signature that refines
the outer context generic signature with an additional generic parameter representing the underlying
type and its exposed constraints. Opaque types also need to be keyed by their originating decl, so
that we can treat values of the same opaque type as the same. When we check a FuncDecl with an
opaque type specified as its return type, create an OpaqueTypeDecl and associate it with the
originating decl. (A representation for *types* derived from the opaque decl will come next.)
2019-04-17 14:43:32 -07:00
Azoy
7c75836d77 context cleanup part 1 2019-04-03 20:50:58 -05:00
Doug Gregor
d19d2f2490 [AST] Lazily compute ProtocolDecl::getKnownProtocolKind()
Rather than eagerly doing a bunch of name lookups to establish the known
protocol kind, lazily match the ProtocolDecl to the list of known
protocols as-needed. This eliminates a bunch of up-front unqualified
name lookups when spinning up a type checker.
2019-02-04 21:25:48 -08:00
David Ungar
ec1797659e Cosmetics. 2019-01-20 23:38:47 -08:00
David Ungar
e7882170a7 Use array for the cache. 2019-01-20 23:30:03 -08:00
David Ungar
fe999d9a47 Format. 2019-01-20 22:47:40 -08:00
David Ungar
4ca97abaff Key cache by SourceFile. 2019-01-20 22:46:47 -08:00
David Ungar
5827ffae45 Format 2019-01-20 16:34:48 -08:00
David Ungar
51bb354328 Move cache to ASTContext 2019-01-20 16:34:18 -08:00
Pavel Yaskevich
ddc2fa415e [AST] NFC: introduce ASTContext::isAccessControlDisabled 2019-01-11 17:30:10 -08:00
Pavel Yaskevich
35202ab5b0 [TypeChecker] Always emit a fallback error if type-check failed without producing one
Sometimes constraint solver fails without producing any diagnostics,
it could happen during different phases e.g. pre-check, constraint
generation, or even while attempting to apply solution. Such behavior
leads to crashes down the line in AST Verifier or SILGen which are
hard to diagnose.

Let's guard against that by tracking if solver produced any diagnostics
upon its failure and if no errors were or are scheduled to be produced,
let's produce a fallback fatal error pointing at affected expression.

Resolves: rdar://problem/38885760
2019-01-07 10:42:00 -08:00
Slava Pestov
06c2e980cb Merge pull request #21133 from slavapestov/lazy-implicit-inits
Lazy synthesis of implicit constructors in non-primary files
2018-12-07 22:45:40 -05:00
Slava Pestov
6c012b2aec AST: Remove some unnecessary LazyResolver * parameters from ASTContext methods 2018-12-07 20:39:27 -05:00
Slava Pestov
aa747dcd81 Remove property behaviors 2018-12-07 20:38:33 -05: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
Azoy
65217a71de Cache bool builtin init
remove newline
2018-12-02 22:38:24 -06:00
Azoy
a2dafc3d26 Remove _getBool 2018-12-01 18:51:25 -06:00
John McCall
5553224fd4 Support the explicit representation of self-conformances.
Big, but actually NFC because we're never actually creating them.
2018-11-15 16:42:03 -05:00
John McCall
cf511445e2 Basic support for Builtin.IntegerLiteral. 2018-10-31 18:42:34 -04:00
Slava Pestov
4063124c45 AST: Remove isSwiftVersion3() 2018-10-30 16:46:08 -04: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
Jordan Rose
9e56a8eb8d Make ASTContext::getAllocator private. No functionality change. 2018-09-28 13:43:40 -07:00
Jordan Rose
91d1abf8b0 [Stats] Track NumASTBytesAllocated continuously
...so it can be used with flamegraphs.
2018-09-28 13:43:36 -07:00
Xi Ge
033732b1e5 ASTVerifier: avoid verifying IterableDeclContext if it has unparsed members. 2018-09-12 14:11:41 -07:00
Xi Ge
24b0eac9a4 Parser: parse members in extension decls incrementally. 2018-09-05 17:00:39 -07:00
Alex Hoppen
66374a14ea [libSyntax] Make RawSyntax nodes hold a strong reference to their arena
This allows an elegant design in which we can still allocate RawSyntax
nodes using a bump allocator but are able to automatically free that
buffer once the last RawSyntax node within that buffer is freed.

This also resolves a memory leak of RawSyntax nodes that was caused by
ParserUnit not freeing its underlying ASTContext.
2018-08-24 08:39:54 -07:00
Doug Gregor
197642d37b [Request-evaluator] Track # of evaluations for each request kind.
Using the unified stats reporter, track the # of evaluations for each
type checking request kind.
2018-06-22 00:01:55 -07:00
Doug Gregor
ef337bb8ba [Evaluator] Use the request-evaluator for the superclass of a class.
Wire up the request-evaluator with an instance in ASTContext, and
introduce two request kinds: one to retrieve the superclass of a class
declaration, and one to compute the type of an entry in the
inheritance clause.

Teach ClassDecl::getSuperclass() to go through the request-evaluator,
centralizing the logic to compute and extract the superclass
type.

Fixes the crasher from rdar://problem/26498438.
2018-06-14 15:28:36 -07:00
Slava Pestov
d5ec1827a4 Basic: Change isSwiftVersionAtLeast() to take optional minor version number
I want to be able to do an isSwiftVersionAtLeast(4, 2) check.
2018-06-09 22:02:52 -07:00
Doug Gregor
ef020c74aa Eliminate all vestiges of Substitution and SubstitutionList.
Introduced during the bring-up of the generics system in July, 2012,
Substitution (and SubstitutionList) has been completely superseded by
SubstitutionMap. R.I.P.
2018-05-11 21:43:40 -07:00
David Zarzycki
8404cd73f2 [AST] NFC: Pair AlignedFree with AlignedAlloc (found via ASAN) 2018-05-11 06:08:44 -04:00
David Zarzycki
f0c106c0e3 [AST] NFC: Avoid pointer indirection with ASTContext Impl storage
Most of this change is mechanical: `Impl` -> `getImpl()`.
2018-05-10 05:50:56 -04:00
Doug Gregor
3e2bed119b [AST] Switch SpecializedProtocolConformance over to SubstitutionMap.
Eliminate another common use of SubstitutionList from the AST.
2018-05-02 13:38:15 -07:00
Karoy Lorentey
23c1b24e6a [SE-0206][Sema] Update Hashable synthesizer to support hash(into:)
This removes the default implementation of hash(into:), and replaces it with automatic synthesis built into the compiler. Hashable can now be implemented by defining either hashValue or hash(into:) -- the compiler supplies the missing half automatically, in all cases.

To determine which hash(into:) implementation to generate, the synthesizer resolves hashValue -- if it finds a synthesized definition for it, then the generated hash(into:) body implements hashing from scratch, feeding components into the hasher. Otherwise, the body implements hash(into:) in terms of hashValue.
2018-04-24 17:42:42 +01:00
Slava Pestov
3bcdf1a027 AST: New ASTContext::addSynthesizedDecl() method
This adds the declaration to the external declarations list only
if it was part of an imported declaration, eliminating some
boilerplate.
2018-04-02 23:17:58 -07: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
Mark Lacey
d63bb3fc53 Remove most uses of OptionalTypeKind.
What remains are places where we are conflating optionality with
either nullability or failability.
2018-02-10 16:24:09 -08:00
Mark Lacey
2008674495 Make ImplicitlyUnwrappedOptional<T> an unavailable typealias.
Also remove the decl from the known decls and remove a
bunch of code referencing that decl as well as a bunch of other
random things including deserialization support.

This includes removing some specialized diagnostics code that
matched the identifier ImplicitlyUnwrappedOptional, and tweaking
diagnostics for various modes and various issues.

Fixes most of rdar://problem/37121121, among other things.
2018-02-02 08:35:53 -08:00
Rintaro Ishizaki
057254dbc1 [Syntax] Bump allocate and cache/reuse RawSyntax
Introduced SyntaxArena for managing memory and cache.

SyntaxArena holds BumpPtrAllocator as a allocation storage.
RawSyntax is now able to be constructed with normal heap allocation, or
by SyntaxArena. RawSyntax has ManualMemory flag which indicates it's managed by
SyntaxArena. If the flag is true, its Retain()/Release() is no-op thus it's
never destructed by IntrusiveRefCntPtr.
This speedups the memory allocation for RawSyntax.

Also, in Syntax parsing, "token" RawSyntax is reused if:
a) It's not string literal with >16 length; and
b) It doesn't contain random text trivia (e.g. comment).
This reduces the overall allocation cost.
2018-02-02 01:27:06 +09:00
Xiaodi Wu
30d5e344b1 Rename the combine hashes function and use a common implementation 2017-12-10 02:13:25 -06:00