The Swift name lookup tables and the complete Objective-C "container"
to Swift DeclContext mapping code used similar-but-different logic to
determine when to suppress a declaration (e.g., when suppressing the
accessors for a property). Centralize the logic so we get the same
behavior in both places.
When we're omitting needless words and building Swift name lookup
tables, make sure to use the proper Clang
Sema/Preprocessor/ASTContext. This still needs to be properly
detangled, but at least now we can handle omit-needless-words for
builtin Clang types (e.g., SEL) properly.
As part of this, put OmitNeedlessWords and InferDefaultArguments into
the module file extension hash for the Swift name lookup tables, since
those settings will affect the results.
When we're omitting needless words and building Swift name lookup
tables, make sure to use the proper Clang
Sema/Preprocessor/ASTContext. This still needs to be properly
detangled, but at least now we can handle omit-needless-words for
builtin Clang types (e.g., SEL) properly.
As part of this, put OmitNeedlessWords and InferDefaultArguments into
the module file extension hash for the Swift name lookup tables, since
those settings will affect the results.
Most of this is in updating the standard library, SDK overlays, and
piles of test cases to use the new names. No surprises here, although
this shows us some potential heuristic tweaks.
There is one substantive compiler change that needs to be factored out
involving synthesizing calls to copyWithZone()/copy(zone:). Aside from
that, there are four failing tests:
Swift :: ClangModules/objc_parse.swift
Swift :: Interpreter/SDK/Foundation_test.swift
Swift :: Interpreter/SDK/archiving_generic_swift_class.swift
Swift :: Interpreter/SDK/objc_currying.swift
due to two independent remaining compiler bugs:
* We're not getting partial ordering between NSCoder's
encode(AnyObject, forKey: String) and NSKeyedArchiver's version of
that method, and
* Dynamic lookup (into AnyObject) doesn't know how to find the new
names. We need the Swift name lookup tables enabled to address this.
The recently-introduced module file extensions functionality in Clang
allows us to piggy-back the Swift name lookup tables in Clang's module
files. When the Swift name lookup tables are enabled, introduce such a
module file extension, and wire it into the SwiftLookupTable.
The actual contents of the extension block are simple: a single
on-disk hash table mapping base names to "full entries", which store
the context (e.g., a class, protocol, tag, or TU) and the set of
declarations.
Allow lazy resolution of declaration IDs deserialized from the
extension block to Clang declarations, to try to minimize the set of
declarations we must deserialize. Name lookup itself is only used to
dump the Swift name lookup tables and ensure we're round-tripping
properly.
The base name -> full name mapping really isn't interesting; index
based on the base name and filter by context instead. This makes the
lookup table dumper less interesting for testing purposes
(unfortunately), but test coverage will improve greatly once we can
turn on these lookup tables.
Ensures that the Swift lookup tables get transformed name for imported
CF types, including original name (which is still
available). Otherwise, this is an NFC refactoring that gets the last
of the naming tricks into importFullName.
The translation from the Objective-C NSError** convention into Swift
throwing methods alters the names of methods. Move that computation
into importFullName. This should be NFC refactoring for everything
except the Swift name lookup tables, which will now correctly reflect
this name translation.
The getters and setters for Objective-C @property declarations are
never found by name lookup, so don't introduce them into the Swift
lookup tables. Note that we exclude some of the accessibility
declarations for unrelated reasons, as we do elsewhere in the
importer.
Refactoring that lets the Swift lookup tables get the names right for
Objective-C protocols that would conflict with another entity in the
same module (or within the bridging header). It's an NFC cleanup
everywhere else.
Start testing the construction of the Swift lookup tables in the Clang
importer for Objective-C entities. Fix some obvious issues, e.g.,
category and extension entries should be associated with the
corresponding class, and the categories/extensions shouldn't have
entries in the lookup table.