Commit Graph

1018 Commits

Author SHA1 Message Date
Jordan Rose
cefb0b62ba Replace old DEBUG macro with new LLVM_DEBUG
...using a sed command provided by Vedant:

$ find . -name \*.cpp -print -exec sed -i "" -E "s/ DEBUG\(/ LLVM_DEBUG(/g" {} \;
2018-07-20 14:37:26 -07:00
Slava Pestov
585b06e647 AST: Remove uses of AbstractFunctionDecl::getParameterLists() 2018-07-19 12:28:26 -07:00
Doug Gregor
b70466dc63 [Type Checker] Add a request kind for computing 'ValueDecl::isObjC()'.
Still a WIP
2018-07-18 14:50:39 -07:00
Doug Gregor
b07dd059a6 [Type Checker] Remove TypeChecker/LazyResolver parameters from name lookup.
Make the TypeChecker’s name-lookup routines static, so they don’t depend
on the TypeCheck instance… except for one pesky place where we jump back
into protocol conformance checking. This is part of teasing apart the type
checker.
2018-07-18 14:50:38 -07:00
Mark Lacey
b2da48a294 Remove a few Swift 3 compat changes for in name lookup. 2018-07-16 12:54:05 -07:00
Slava Pestov
e34c409b48 Merge pull request #17816 from slavapestov/protocol-superclass-part-3
Protocols with superclass constraints - part 3
2018-07-07 21:19:53 -07:00
Slava Pestov
19de53f6cf Sema: Remove dead code from access level computation rework 2018-07-06 23:50:36 -07:00
Slava Pestov
66e6a6a2c5 AST: Fix name lookup for protocols with superclasses
Also, start adding some tests now that basic things seem to work.
2018-07-06 23:39:39 -07:00
swift-ci
1b91f00914 Merge pull request #17733 from DougGregor/refactor-override-checking 2018-07-03 22:04:01 -07:00
Doug Gregor
d5bd991e52 [AST] Prune unnecessary calls to LazyResolver::resolveOverriddenDecl().
ValueDecl::getOverriddenDecl(s)() does this for us automagically.
2018-07-03 15:45:03 -07:00
Slava Pestov
45fb11ce3c AST: Add ExistentialLayout::getSuperclass(), rename superclass to explicitSuperclass
More groundwork for protocols with superclass constraints.
In several places we need to distinguish between existential
types that have a superclass term (MyClass & Proto) and
existential types containing a protocol with a superclass
constraint.

This is similar to how I can write 'AnyObject & Proto', or
write 'Proto1 & Proto2' where Proto1 has an ': AnyObject'
in its inheritance clause.

Note that some of the usages will be revisited later as
I do more refactoring and testing. This is just a first pass.
2018-07-02 22:06:33 -07:00
Doug Gregor
bc0445d1f7 Narrow a few LazyResolver::resolveDeclSignature() calls to what they really need.
Specifically, introduce entrypoints for "resolve overridden decl" and "is @objc". These can
be computed cheaply in many more cases.
2018-06-04 18:15:39 -07:00
Doug Gregor
c3ed2decc4 [AST] Eliminate LazyResolver::resolveDeclSignature() call from the core of name lookup. 2018-06-04 17:34:33 -07:00
Doug Gregor
e1ce0a9f56 [AST/ClangImporter] Eliminate layering violation with isInOverlayModuleForImportedModule.
https://github.com/apple/swift/pull/16951 introduced a layering violation between the
AST and ClangImporter libraries; break the layering violation by moving the function
isInOverlayModuleForImportedModule() to ClangModuleLoader.
2018-06-04 16:40:45 -07:00
Doug Gregor
248ca75b8f [Type checking] A declaration in an overlay can shadow an imported declaration.
If a declaration provided in a Swift overlay has the same signature as
a declaration imported from the Clang module it overlays, or some
private framework that re-exports its interface through that Clang
module, the declaration provided in the Swift overlay shadows the one
imported from Clang.

To make this work for unqualified lookup, allow the shadowing rules to
kick in there as well. Make this a very narrow fix, because the
underlying problems that prevented us from doing this shadowing still
persist.

Fixes rdar://problem/35691030 and its several dupes.
2018-06-01 11:43:52 -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
Huon Wilson
9b68eb8a80 [AST] Allow unqualified name lookup to return results from outer scopes.
This is necessary for disambiguating calls to functions like `min` and
`max`.
2018-04-19 11:07:48 +10:00
Huon Wilson
fe00f53e48 [AST] Use flags instead of booleans for UnqualifiedLookup. 2018-04-09 10:58:49 +10:00
Slava Pestov
a5579d1cff AST: Plug a hole in access control checking
A protocol extension of a private protocol can define internal
or public members. We should not be able to find these members
from another file or module if an internal or public type
conforms to the protocol.

Fixes <rdar://problem/21380336>.
2018-04-05 23:24:48 -07:00
Slava Pestov
df9e0a76e0 AST: Fix for name lookup not finding initializers in protocols
If a generic parameter has both a class and protocol constraint,
walking up to the class's superclass would cause us to subsequently
ignore any initializer requirements in the protocol.

Fixes <https://bugs.swift.org/browse/SR-1663>, <rdar://problem/22722738>.
2018-03-16 21:49:02 -07:00
Slava Pestov
34fd4ae512 AST: Use DeclBaseName::Kind::Constructor
Fixes <rdar://problem/35852727>, <https://bugs.swift.org/browse/SR-1660>,
<https://bugs.swift.org/browse/SR-6557>.
2018-03-16 00:25:56 -07:00
Graydon Hoare
819275945d [Stats] Replace RecursiveSharedTimer with FrontendStatsTracer. 2018-02-21 14:49:24 -08:00
Joe Groff
d4e03f2ba3 SIL: Add an 'external' KeyPathPatternComponent kind.
This will allow key paths to resiliently reference public properties from other binaries by referencing a descriptor vended by the originating binary. NFC yet, this just provides printing/parsing/verification of the new component.
2018-02-14 10:48:24 -08:00
Doug Gregor
05478455f7 [Name lookup] Fix an issue with lazy named member lookup.
Fix an issue with lazy named member lookup where a sequence of lookups
into a class based on full names (e.g., constraint(equalTo:constant:))
could prevent us from adding candidates with the same based name but
different argument labels.

Fixes SR-6834 / rdar://problem/36851018
2018-02-08 14:33:49 -08:00
Slava Pestov
1ed2cf09df AST: Don't find non-objc members with dynamic lookup
This can come up when we use import-as-member to turn top-level functions
into methods in an @objc class. Previously dynamic lookup would find
these, causing a SILGen crash.

Fixes <rdar://problem/36492980>.
2018-01-18 22:52:54 -08:00
Doug Gregor
8b58b0dbb4 [Type checker] Make redeclaration checking validate fewer declarations.
Redeclaration checking was validating all declarations with the same
base name as the given declaration (and in the same general nominal
type), even when it was trivial to determine that the declarations
could not be conflicting. Separate out the easy structural checks
(based on kind, full name, instance vs. non-instance member, etc.) and
perform those first, before validation.

Fixes SR-6558, a case where redeclaration checking caused some
unnecessary recursion in the type checker.
2017-12-30 23:27:04 -08:00
Doug Gregor
7d4956d37e [Name lookup] Remove debugging cruft 2017-12-16 14:03:28 -08:00
Doug Gregor
8c05278ef3 [Clang importer] Lazily load all named members with a matching base name.
When loading the named members for a given name, we want to load all
of the members with that base name... not only the ones that match the
full name, because the lookup table is indexed by base name and
filtering too early drops candidates.

Fixes rdar://problem/36085994.
2017-12-15 23:54:36 -08:00
David Zarzycki
97541e0d1e [Basic] NFC: Standardize and simplify inline bitfields
Inline bitfields are a common design pattern in LLVM and derived
projects, but the associated boilerplate can be demotivating and
brittle. This new header makes it easier to define and use inline
bitfields in Swift.

This also reorders some fields for better code generation.
2017-12-15 14:14:59 -05:00
Graydon Hoare
c51bb7c842 [NamedLazyMemberLoading] Expand logging a little. 2017-12-02 02:19:51 -08:00
Graydon Hoare
c6ce01280d [NamedLazyMemberLoading] Handle partial population from extensions better. 2017-12-02 02:19:29 -08:00
Graydon Hoare
7a9bc26fd9 [NamedLazyMemberLoading] Handle nominals with mix of added/lazy members. 2017-12-01 16:52:26 -08:00
Graydon Hoare
ce28efbf5e [NamedLazyMemberLoading] Tolerate mid-flight getMembers() calls better. 2017-12-01 16:52:25 -08:00
Graydon Hoare
3e76aebee1 [NamedLazyMemberLoading] Support named loading from ObjC categories. 2017-12-01 16:52:25 -08:00
Graydon Hoare
464dc1bcc1 [NamedLazyMemberLoading] Use per-IDC recursion-breaking flag, not sentinel.
The empty sentinel in the lookup table caused recursion-breaking to bottom
out in slightly different order than the old eager code, making certain
order-sensitive tests fail.
2017-12-01 16:52:25 -08:00
Graydon Hoare
a6701a8cce [NamedLazyMemberLoading] Give up trying to break recursion on clang-imported init for now. 2017-12-01 16:52:25 -08:00
Arnold Schwaighofer
eba12a7c3e Revert "Finish and default-enable named lazy member loading" 2017-12-01 07:25:54 -08:00
Graydon Hoare
094ee2fd27 [NamedLazyMemberLoading] Tolerate mid-flight getMembers() calls better. 2017-11-30 22:29:12 -08:00
Graydon Hoare
a967f8c6ea [NamedLazyMemberLoading] Support named loading from ObjC categories. 2017-11-30 22:27:58 -08:00
Graydon Hoare
9e1859469c [NamedLazyMemberLoading] Use per-IDC recursion-breaking flag, not sentinel.
The empty sentinel in the lookup table caused recursion-breaking to bottom
out in slightly different order than the old eager code, making certain
order-sensitive tests fail.
2017-11-30 22:18:25 -08:00
Graydon Hoare
dfc67d6b93 [NamedLazyMemberLoading] Give up trying to break recursion on clang-imported init for now. 2017-11-30 22:02:42 -08:00
Graydon Hoare
bfde4f564c [NamedLazyMemberLoading] Don't self-add extn members to partial tables. 2017-11-10 15:55:34 -08:00
Graydon Hoare
bbeec57182 [NamedLazyMemberLoading] Handle case of source extension on deserialized type. 2017-11-03 00:35:03 -07:00
Graydon Hoare
ed0b43cbce [NamedLazyMemberLoading] Move SerialID to IDC, get extensions working. 2017-11-01 17:35:46 -07:00
Graydon Hoare
f96c0d9b63 [NamedLazyMemberLoading] Address review comments. 2017-11-01 17:35:46 -07:00
Graydon Hoare
e9fbd2ce53 [NamedLazyMemberLoading] Add diagram + comment of IDC + MemberLookupTable. 2017-11-01 17:34:56 -07:00
Graydon Hoare
2d36f5cdae [NamedLazyMemberLoading] Use NominalTypeDecl::LookupTable as proper cache. 2017-11-01 17:34:56 -07:00
Graydon Hoare
30b6fdce83 Merge pull request #12429 from graydon/named-lazy-member-loading
Named lazy member loading 1/N
2017-10-24 14:27:04 -07:00
Slava Pestov
28efca5785 AST: Short-circuit isSetterAccessibleFrom() for ParamDecls 2017-10-22 20:05:00 -07:00