Commit Graph

1007 Commits

Author SHA1 Message Date
Slava Pestov
af309026b9 Merge pull request #26865 from slavapestov/faster-module-name-lookup
Faster module name lookup
2019-08-29 19:46:05 -04:00
Doug Gregor
2c9def8e74 Merge pull request #26925 from DougGregor/parse-members-request
[Parser] Introduce a request for parsing type and extension members.
2019-08-29 13:56:33 -07:00
Slava Pestov
2256b1fcc2 AST: Introduce namelookup::getAllImports() to replace forAllVisibleModules() 2019-08-29 15:57:38 -04:00
Doug Gregor
d8f7c9e72c [Parser] Introduce a request for parsing type and extension members.
Ensure that lazy parsing of the members of nominal type definitions
and extensions is handled through a request. Most of the effort here
is in establishing a new request zone for parser requests.
2019-08-28 21:39:56 -07:00
Slava Pestov
37f308b8d3 AST: Change lookupInModule() to take a DeclContext instead of a module and extra imports
Also get rid of the 'accessPath' parameter.
2019-08-28 21:09:23 -04:00
Slava Pestov
61a4a48e21 AST: Add scoped import shadowing rule to removeShadowedDecls()
This simulates the shadowing done by ModuleNameLookup, which is about to be
removed.

The basic idea is that top-level declarations found via scoped imports
take precedence over unscoped imports.
2019-08-28 20:54:22 -04:00
Slava Pestov
f567b8ff42 AST: Use new module shadowing rule for qualified lookups too 2019-08-28 20:54:22 -04:00
Slava Pestov
1c28684441 AST: Add module visibility shadowing rule to removeShadowedDecls()
This simulates the shadowing done by ModuleNameLookup, which is about to be
removed.

The basic idea is that if a module A imports a module B, and B imports C,
then from A's point of view, top-level declarations from B will shadow
top-level declarations from C.
2019-08-28 16:29:50 -04:00
Slava Pestov
962f358e68 AST: Don't compute overload signature unless needed in removeShadowedDecls() 2019-08-28 16:29:50 -04:00
Slava Pestov
dcefd7f085 AST: Qualified lookup doesn't need to prune duplicate results 2019-08-28 16:29:50 -04:00
Slava Pestov
665cff1172 AST: Use ImportCache to simplify DeclContext::lookupQualified() 2019-08-28 16:29:50 -04:00
Slava Pestov
b3d95d7968 AST: removeShadowedDecls() takes a DeclContext instead of a ModuleDecl
This allows shadowing rules to depend on the current SourceFile and
not just the current ModuleDecl. For now, this isn't actually
taken advantage of.
2019-08-28 15:41:03 -04:00
Suyash Srijan
094869555e Merge branch 'master' into fix/SR-11288 2019-08-28 02:27:44 +01:00
Robert Widmann
8d22702a22 Use Integrated Caching
Replumb the TypeLoc for the extended type as a TypeRepr instead. Fixup
the myriad callsites this touches in the process.
2019-08-26 11:48:29 -07:00
Slava Pestov
9e18f2a1fe AST: Use ResolutionKind::TypesOnly for qualified lookup too 2019-08-24 22:35:51 -04:00
Slava Pestov
d13353f43a AST: Split off ModuleNameLookup.h from NameLookup.h 2019-08-23 23:35:25 -04:00
Suyash Srijan
357c7ef11b [AST] CustomAttrNominalRequest should look into protocol members as well
When performing unqualified lookup via directReferencesForUnqualifiedTypeLookup(), we should look into protocol members as well, as it's possible that the user has defined a typealias
2019-08-22 23:40:20 +01:00
Slava Pestov
80ccbe5116 AST: Stop passing around a LazyResolver in name lookup
Note that in all cases it was either nullptr or ctx.getLazyResolver().
While passing in nullptr might appear at first glance to mean something
("don't type check anything"), in practice we would check for a nullptr
value and pull out ctx.getLazyResolver() instead. Furthermore, with
the lazy resolver going away (at least for resolveDeclSignature() calls),
it won't make sense to do that anymore anyway.
2019-08-19 23:00:57 -04:00
Slava Pestov
94c5a35bf2 AST: Add some counters related to name lookup 2019-08-19 23:00:57 -04:00
Slava Pestov
bbdc7ae8e5 AST: Force parsing unparsed extensions of lazy-member (deserialized or imported) nominals
There was a bit of a misunderstanding between the 'lazy member' code
and the 'delayed member parsing' code. We have to explicitly parse
extensions of a 'lazy member' type when incrementally building the
lookup table, otherwise we'll never revisit the parsed extension
members later.

No test case because this can't happen right now; we force all delayed
parsing before any qualified lookups are performed. However everything
breaks badly without this change once delayed member parsing actually
occurs.
2019-08-12 17:15:51 -04:00
Slava Pestov
0063f158be AST: Request-ify synthesis of the implicit destructor 2019-08-09 19:08:47 -04:00
Doug Gregor
4b1fff980d [Name lookup] Deduplicate nominal declarations found via resolveTypeDeclsToNominal.
Perform basic deduplication of the nominal type declarations found via
resolveTypeDeclsToNominal(). Fixes rdar://problem/53164203
2019-07-16 16:54:55 -07:00
Slava Pestov
4c499fd4ac AST: Stop passing around LazyResolvers in various places 2019-07-06 00:43:22 -04:00
Harlan Haskins
d23101d337 [Sema] Compute superclass of deserialized protocols via generic signature
We don't need to serialize the protocol's superclass, we can compute it from the
generic signature. Previously, we would drop the superclass while
serializing because we didn't check the generic signature in
SuperclassTypeRequest, which would cause us to cache `NULL` when we
called `setSuperclass` for a protocol with a superclass constraint.

Fixes rdar://50526401
2019-06-18 16:38:09 -07:00
David Ungar
663760e3b7 ASTOOScope ontology 2019-05-28 10:48:22 -07:00
Ben Langmuir
34da079aa6 Pass DynamicLookupInfo through VisibleDeclConsumers NFC
This commit adds a new type DynamicLookupInfo that provides information
about how a dynamic member lookup found a particular Decl. This is
needed to correctly handle KeyPath dynamic member lookups, but for now
just plumb it through everywhere.
2019-05-06 10:02:39 -07: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
e97fc4e0c2 AST: Replace ASTContext's ObjCMethods list with a per-SourceFile list 2019-04-22 20:42:07 -04:00
Joe Groff
5e1497967a Parse opaque types. 2019-04-17 14:43:32 -07:00
Gogul Balakrishnan
1fa3846224 Add more hooks for overriding name lookup in the DebuggerClient (#23031) 2019-04-08 15:19:31 -07:00
Michael Gottesman
564b4fc11a [silgenpattern] Fix some stack-use-after-free errors caused by iterating over an Optional<ArrayRef<T>>.
Specifically the bad pattern was:

```
   for (auto *vd : *caseStmt->getCaseBodyVariables()) { ... }
```

The problem is that the optional is not lifetime extended over the for loop. To
work around this, I changed the API of CaseStmt's getCaseBodyVariable methods to
never return the inner Optional<MutableArrayRef<T>>. Now we have the following 3
methods (ignoring const differences):

1. CaseStmt::hasCaseBodyVariables().

2. CaseStmt::getCaseBodyVariables(). Asserts if the case body variable array was
   never specified.

3. CaseStmt::getCaseBodyVariablesOrEmptyArray(). Returns either the case body
   variables array or an empty array if we were never given any case body
   variable array.

This should prevent anyone else in the future from hitting this type of bug.

radar://49609717
2019-04-04 13:34:36 -07:00
Michael Gottesman
7b0d8455ca [ast][silgen] Wire up the case body var decls and use them in SILGenPattern emission to fix the evil fallthrough bug.
rdar://47467128
2019-04-03 23:51:06 -07:00
Doug Gregor
a848d12665 Parse unknown attributes as "custom" attributes.
Parse custom attributes with the grammar:

```
'@' type-identifier expr-paren?
```
2019-03-29 23:10:36 -07:00
Doug Gregor
9e5d8ee222 Merge pull request #22977 from DougGregor/constraint-solver-common-result-type
[Constraint solver] Compute common apply result type in the solver.
2019-02-28 23:48:17 -08:00
Doug Gregor
0ea6536b95 [Name shadowing] Extend Objective-C initializer shadowing to imported inits.
There are multiple ways in which the Clang importer can produce an
initializer, and we have existing name shadowing rules to decide on
the best. Extend those rules to cover the case where a
Clang-importer-synthesized initializer collides with a C function
imported as an initializer. There's technically no reason to do the
latter because the former already exists, but some frameworks
currently depend on this.

Prior to this, the constraint solver was preferring the synthesized
initializer already (which is the right thing to do), for the wrong
reasons.
2019-02-28 09:13:32 -08:00
David Ungar
6982e66ddf Refactor filterForDiscriminator and call of addLocalVariableResults. 2019-02-22 12:41:03 -07:00
David Ungar
5d49b3bb3d Minor cleanumps 2019-02-20 14:41:23 -07:00
David Ungar
cd48cd6eb3 Format 2019-02-20 14:35:52 -07:00
David Ungar
1595efe5e2 Split the file, unfmt 2019-02-20 14:34:11 -07:00
David Ungar
80a234a2ef Use a struct instead of a pair 2019-02-20 11:08:06 -07:00
David Ungar
e9277469fb Unify two cases 2019-02-20 10:38:55 -07:00
David Ungar
1ce86b9def Minor fixes 2019-02-20 10:30:51 -07:00
David Ungar
8e7ff01caa WIP 2019-02-19 15:09:46 -07:00
David Ungar
d776cf5996 Some reordering 2019-02-19 15:03:42 -07:00
David Ungar
edaec2aea5 Move searchPlacesToSearch into PlacesToSearch 2019-02-19 11:24:51 -07:00
David Ungar
ef9f99e37c Rename ExpUnqalifiedLookup to UnqualifiedLookup, UnqualifiedLookup to LegacyUnqualifiedLookup 2019-02-19 10:55:44 -07:00
David Ungar
65f8f73992 Todo editing 2019-02-19 10:22:11 -07:00
David Ungar
0aee0dba4b 1st cut finish redo, unfmt 2019-02-18 15:30:18 -07:00
David Ungar
272df9f3b7 Minor return cleanup. 2019-02-17 23:23:27 -07:00
David Ungar
b52b85b884 Factor isCascadingUse resolution. 2019-02-17 23:07:01 -07:00