Commit Graph

19 Commits

Author SHA1 Message Date
Doug Gregor
e4331e4ba9 Eliminate non-deterministic behavior when removing duplicate declarations after module lookup.
Big thanks to JoeP for pointing this out! No specific test case here.

Swift SVN r19177
2014-06-25 20:57:13 +00:00
Jordan Rose
a7b563855e Add a mode in which access control is respected for module-scope lookups.
This applies to both qualified and unqualified lookups, and is controlled
by the -enable-access-control and -disable-access-control flags. I've
included both so that -disable-access-control can be put into specific tests
that will eventually need to bypass access control (e.g. stdlib unit tests).
The default is still -disable-access-control.

Swift SVN r19146
2014-06-24 21:32:21 +00:00
Dmitri Hrybenko
7ffc7483bf Remove empty namespace
Swift SVN r16590
2014-04-20 18:02:31 +00:00
Joe Groff
96c09d7179 Renovate name lookup to prepare for compound name lookup.
Make the name lookup interfaces all take DeclNames instead of identifiers, and update the lookup caches of the various file units to index their members by both compound name and simple name. Serialized modules are keyed by identifiers, so as a transitional hack, do simple name lookup then filter the results by compound name.

Swift SVN r14768
2014-03-07 03:21:29 +00:00
Jordan Rose
0b2541b58f Rename the standard library to "Swift" (instead of "swift")
This is more in line with all other modules currently on our system.
If/when we get our final name for the language, we're at least now set
up to rename the library without /too/ much trouble. (This is mostly just
a lot of searching for "import swift", "swift.", "'swift'", and '"swift"'.
The compiler itself is pretty much just using STDLIB_NAME consistently now,
per r13758.)

<rdar://problem/15972383>

Swift SVN r14001
2014-02-17 19:30:47 +00:00
Jordan Rose
7995dde448 Module::getImportedModules can now get public, private, or all imports.
...whereas before the only options were "public" and "all".

No functionality change.

Swift SVN r13849
2014-02-12 23:57:43 +00:00
Jordan Rose
f5eae17dd2 Move VectorDeclConsumer to swift/AST/NameLookup.h.
This started out life as a helper class, but it's been used in multiple places.
Better to just have a single copy.

No functionality change.

Swift SVN r10835
2013-12-05 01:51:12 +00:00
Jordan Rose
be12d86ddd Turn ClangModule into ClangModuleUnit.
Part of the FileUnit restructuring. A Clang module (whether from a framework
or a simple collection of headers) is now imported as a TranslationUnit
containing a single ClangModuleUnit.

One wrinkle in all this is that Swift very much wants to do searches on a
per-module basis, but Clang can only do lookups across the entire
TranslationUnit. Unless and until we get a better way to deal with this,
we're stuck with an inefficiency here. Previously, we used to hack around
this by ignoring the "per-module" bit and only performing one lookup into
all Clang modules, but that's not actually correct with respect to visibility.

Now, we're just taking the filtering hit for looking up a particular name,
and caching the results when we look up everything (for code completion).
This isn't ideal, but it doesn't seem to be costing too much in performance,
at least not right now, and it means we can get visibility correct.

In the future, it might make sense to include a ClangModuleUnit alongside a
SerializedASTFile for adapter modules, rather than having two separate
modules with the same name. I haven't really thought through this yet, though.

Swift SVN r10834
2013-12-05 01:51:11 +00:00
Dmitri Hrybenko
81dc5deee8 Change 'def' keyword back to 'func'
Swift SVN r10522
2013-11-17 07:45:28 +00:00
Dmitri Hrybenko
91ce21666d Change 'func' keyword to 'def'
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few.  If you find something, please
let me know.

rdar://15346654


Swift SVN r9886
2013-11-02 01:00:42 +00:00
Jordan Rose
ec4234bdbc Perform unqualified lookup using the current SourceFile as context.
And, properly treat imports as per-file: when looking up decls through the
TU module, don't pick up every other source file's imports.

This implements our resolution rules:
1. Check the current source file.
2. Check the current module.
3. Check imported modules.

Currently, "import Foo" is treated as a file-private import and
"@reexported import Foo" is treated as a public /and/ module-wide import.
This further suggests that access control is the right tool for re-export
control:

(private) import Foo // current file only
package import Foo   // whole module
public import Foo    // whole world

Swift SVN r9682
2013-10-25 22:21:12 +00:00
Dmitri Hrybenko
8d8b60f973 Code completion: implement result caching per-imported module across muptiple
ASTContexts

This introduces swift::ide::CodeCompletionCache, which is a persistent code
completion result cache.

Right now REPL happens to use it (try importing Cocoa and doing code
completion), and the difference is noticeable.  But completion in REPL is
still slow, because Cocoa goes through the AST Verifier on every completion
(for unknown reasons).

This commit does not implement cache invalidation yet, and it does not use
libcache to evict cache entries under memory pressure.

This commit also introduces two regressions:
- We get fewer Cocoa results that expected.  Module::isModuleVisible in Clang
does not incorrectly reports that that ObjectiveC.NSObject submodule is not
visible from Cocoa.

- We are not implementing the decl hiding rules correctly.  We used to rely on
visible decl lookup to do it for us, but now we have a different data structure
we have real decls from the current module and we have a text-only cache, so we
are forced to reimplement this part of name lookup in code completion.


Swift SVN r9633
2013-10-24 02:13:34 +00:00
Dmitri Hrybenko
6895c34741 Code completion: report "semantic context" for every code completion result
Semantic context describes the origin of the declaration and serves the same
purpose as opaque numeric "priority" in Clang -- to determine the most likely
completion.

This is the initial implementation.  There are a few opportunities to bump the
priority of a certain decl by giving it SemanticContextKind::ExprSpecific
context that are not implemented yet.


Swift SVN r9052
2013-10-09 02:08:05 +00:00
Argyrios Kyrtzidis
3e2f360e45 [AST] In the ModuleKind enum class, shorten enumerators by removing 'Module'. No functionality change.
Swift SVN r8933
2013-10-04 21:29:22 +00:00
Jordan Rose
15bfc8db2b Don't type-check imported decls unless referenced in the source file.
Instead, pass a LazyResolver down through name lookup, and type-check
things on demand. Most of the churn here is simply passing that extra
LazyResolver parameter through.

This doesn't actually work yet; the later commits will fix this.

Swift SVN r8643
2013-09-25 20:08:14 +00:00
Chris Lattner
55200e5274 Now that Module has its own kind field, drop the various module
discriminators from DeclContext.  This is cleaner and should
enable us to drop the alignment of DeclContext (coming next Jordan!)



Swift SVN r8059
2013-09-09 22:43:11 +00:00
Jordan Rose
a09343e519 Lock down on exports from TranslationUnit modules.
Previously, export control (via [exported]) only applied to modules that
had been serialized -- anything imported in a TranslationUnit was
automatically considered exported. This was done to make life easier when
dealing with the main source file, but it turns out we're going to want to
load other source files as imports, and export control should work there too.

Now, the module iteration methods (Module::forAllVisibleModules,
namelookup::lookupInModule, etc.) can consider the module being passed as
"top-level", meaning its private imports are visible as well. Otherwise,
proper export control is observed even for imported TranslationUnits.

This required a number of test changes involving Swift adapter modules that
forgot to re-export their Clang modules.

Swift SVN r7783
2013-08-30 17:05:32 +00:00
Jordan Rose
f1bc7801f4 Rework getReexportedModules to optionally find all imported modules.
...instead of just those that are re-exported. This will be used for
autolinking (and probably few other places).

As part of this, we get two name changes:
  (1) Module::getReexportedModules -> getImportedModules
  (2) TranslationUnit::getImportedModules -> getImports

The latter doesn't just get modules-plus-access-paths; it also includes
whether or not the import is re-exported. Mainly, though, it just didn't
seem like a good idea to overload this name when the two functions aren't
really related.

No tests yet, will come with autolinking.

Swift SVN r7487
2013-08-22 23:20:18 +00:00
Jordan Rose
c4990cfc25 Perform proper shadowing when looking for module-level visible decls.
This makes lookupVisibleDecls use the same code path as qualified and
unqualified lookup. This is more expensive, because it needs to actually
collect a list of /all/ decls in order to properly compute shadowing
information, but this list is not likely to change once the set of imports
has been computed, so we can cache it.

Swift SVN r7168
2013-08-12 18:54:53 +00:00