Commit Graph

127 Commits

Author SHA1 Message Date
Jordan Rose
47658c87eb Start mangling names of private declarations specially.
We currently mangle private declarations exactly like public declarations,
which means that private entities with the same name and same type will
have the same symbol even if defined in separate files.

This commit introduces a new mangling production, private-decl-name, which
includes a discriminator string to identify the file a decl came from.
Actually producing a unique string has not yet been implemented, nor
serialization, nor lookup using such a discriminator.

Part of rdar://problem/17632175.

Swift SVN r21598
2014-08-30 00:17:18 +00:00
Jordan Rose
422565100e [Serialization] Keep track of whether a module has an underlying Clang module.
Previously, we depended on whether or not a serialized module was located
within a framework bundle to consider whether or not it may have a "Clang
half". However, LLDB loads serialized modules from dSYM bundles. Rather
than try to figure out if such a module is "really" a framework, just track
whether the original module was built with -import-underlying-module. If so,
consider the underlying Clang module to be re-exported.

rdar://problem/18099523

Swift SVN r21544
2014-08-28 21:36:02 +00:00
Jordan Rose
0e99a88798 [Serialization] Mark deserialized decls as early-attr-validated.
This should not have any observable effect, but it means the compiler won't
waste time validating the attributes of deserialized declarations.

Swift SVN r21499
2014-08-28 00:32:34 +00:00
Jordan Rose
aae4a3d731 [ClangImporter] Pass through diagnostic locations for imports.
If importing a Clang module fails, we should report that at the location of
the import statement. This doesn't do that fully because it isn't transitive
(if Swift module Foo imports Swift module Bar, which fails to import Clang
module Baz, we don't get an error in user source), but it's a step forward
for the simple cases.

Swift SVN r20575
2014-07-25 23:01:51 +00:00
Jordan Rose
6ee53ff75f [Serialization] Preserve submodule import paths through serialization.
This is a bit of a hack, but Clang submodules are the only case we have to
support.

Part of <rdar://problem/13140302>

Swift SVN r20287
2014-07-22 01:31:15 +00:00
Jordan Rose
fce31decdc Serialize bridging headers into the merged module file.
We do this so that the swiftmodule file contains all info necessary to
reconstruct the AST for debugging purposes. If the swiftmodule file is copied
into a dSYM bundle, it can (in theory) be used to debug a built app months
later. The header is processed with -frewrite-includes so that it includes
any non-modular content; the user will not have to recreate their project
structure and header maps to reload the AST.

There is some extra complexity here: a target with a bridging header
(such as a unit test target) may depend on another target with a bridging
header (such as an app target). This is a rare case, but one we'd like to
still keep working. However, if both bridging headers import some common.h,
we have a problem, because -frewrite-includes will lose the once-ness
of #import. Therefore, we /also/ store the path, size, and mtime of a
bridging header in the swiftmodule, and prefer to use a regular parse from
the original file if it can be located and hasn't been changed.

<rdar://problem/17688408>

Swift SVN r20128
2014-07-18 00:22:53 +00:00
Jordan Rose
db3914e94b Disallow conforming to ObjC protocols with requirements that can't be imported.
For example, variadic ObjC method requirements.

<rdar://problem/17366999>

Swift SVN r19121
2014-06-24 01:23:06 +00:00
Manman Ren
b3e72be9d9 Remove unused deserialized SILFunctions.
The deserializer holds a reference to the deserialized SILFunction, which
prevents Dead Function Elimination from erasing them. 

We have a tradeoff on how often we should clean up the unused deserialized
SILFunctions. If we clean up at every optimization iteration, we may
end up deserializing the same SILFunction multiple times. For now, we clean
up only after we are done with the optimization iteration.

rdar://17046033


Swift SVN r18697
2014-06-04 00:30:34 +00:00
Jordan Rose
465b083ba9 [serialization] Serialize the header path used by -import-objc-header.
This doesn't handle cross-references to decls /loaded/ from the header
just yet, so all that's testable right now is whether the header's imports
are visible from the secondary target (after being imported in response
to loading the serialized module).

More of <rdar://problem/16702101>

Swift SVN r17638
2014-05-07 19:03:21 +00:00
Manman Ren
a28a08d1ba [SILSerializer] Fix issues in deserializing SILFunction with generic outer parameter.
Before this fix, we can't deserialize any SILFunction with generic outer
parameters.

We do not have the decl associated with the generic parameter list at SIL level,
so instead of using a nullptr decl, we serialize the outer generic parameters
directly.

rdar://16630493


Swift SVN r16562
2014-04-19 01:53:12 +00:00
Justin Bogner
64c572e0d2 Serialization: Updates to use llvm/Support/OnDiskHashTable.h
The on-disk hashtable is moving from clang to llvm. This updates some
consumers for the new path and namespace. I've also shortened the
make_range(data_begin(), data_end()) calls on the hash table to just
use data().

Swift SVN r16537
2014-04-18 18:05:35 +00:00
Adrian Prantl
50d130cb23 Reapplying: [clang update] Update uses of OnDiskChainedHashTable to the
OnDiskIterableChainedHashTable interface introduced in CFE 206189.

Thanks to Justin for guiding me through this!
The test-failures I was worried about after I originally committed this
turned out to be unrelated.

Swift SVN r16340
2014-04-14 23:29:47 +00:00
Adrian Prantl
2ebd5c743f Revert "[CLANG UPDATE!] Update uses of OnDiskChainedHashTable to the"
This reverts commit 7cb76d7defd3ca5c808d7f8952b6068c10cbce92.

I missed a ClangModuleImporter test failure.

Swift SVN r16338
2014-04-14 22:37:00 +00:00
Adrian Prantl
ada9ebb7a9 [CLANG UPDATE!] Update uses of OnDiskChainedHashTable to the
OnDiskIterableChainedHashTable interface introduced in CFE 206189.

Thanks to Justin for guiding me through this!

Swift SVN r16337
2014-04-14 22:33:12 +00:00
Dmitri Hrybenko
68b609d7af Remove a kludge from deserialization that does not seem to be needed anymore
Swift SVN r16113
2014-04-09 13:42:17 +00:00
Jordan Rose
646952defd [serialization] Write substitution conformances as references when possible.
More importantly, when writing substitution conformances /within the same
module/, use an "incomplete" form of the NormalProtocolConformance layout
that doesn't include any of the substitutions or defaulted definitions.
This avoids a serialization cycle when the witness for a protocol itself
ends up conforming to the protocol.

I couldn't come up with a reduced test cases, but both cases filed by Dave
now work.

<rdar://problem/16468715>

Swift SVN r15912
2014-04-04 01:17:55 +00:00
Jordan Rose
aa6aa72ba1 Add lazy conformances to nominals and extensions.
...and deserialize conformances lazily.

No intended user-visible change.

Swift SVN r15911
2014-04-04 01:17:54 +00:00
Dmitri Hrybenko
e50b52fa02 Serializer/Driver: serialize comments to separate .swiftdoc files
The driver infers the filename from the module file by replacing the extension,
and passes the explicit path to the swiftdoc file to the frontend.  But there
is no option in the driver to control emission of swiftdoc (it is always
emitted, and name is always inferred from the swiftmodule name).

The swiftdoc file consists of a single table that maps USRs to {brief comment,
raw comment}.  In order to look up a comment for decl we generate the USR
first.  We hope that the performance hit will not be that bad, because most
declarations come from Clang.  The advantage of this design is that the
swiftdoc file is not locked to the swiftmodule file, and can be updated,
replaced, and even localized.


Swift SVN r14914
2014-03-11 10:42:26 +00:00
Jordan Rose
b9d1e14dd6 [serialization] Break a cyclic dependency involving associated types.
The standard library likes to have default definitions for associated types,
which is good. Often the /choice/ of default type, however, is a type that
(indirectly) conforms to the very protocol containing the associated type.
Rather than try to make sure everything is present all at once, just delay
the deserialization of the default definition until it's actually requested.

This does swell the size of AssociatedTypeDecl by two words. I've filed
<rdar://problem/16266669> to remind myself to try to reduce this.

Part of <rdar://problem/16257259>

Swift SVN r14809
2014-03-08 00:07:29 +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
Dmitri Hrybenko
f232267f23 Replace llvm::OwningPtr with std::unique_ptr
It looks like llvm::OwningPtr is going to be removed soon.


Swift SVN r14729
2014-03-06 09:47:17 +00:00
Michael Gottesman
2aa197f636 [deserialization] Expose ModuleFile::error and use the method in SILDeserializer to mark a module as being malformed when invalid SIL is encountered.
Swift SVN r14703
2014-03-06 00:08:35 +00:00
John McCall
a8ed3dae12 Deserialize generic contexts by mapping their archetypes
to the archetypes of their generic parameter declarations.

This was a major inconsistency that was causing a lot of
problems with deserialized generic functions in the presence
of chained module files.  In particular, what would happen is
that all the deserialized uses of the archetype would be
mapped to a freshly-created archetype, but the GenericParamList
would refer to GenericTypeParamDecls deserialized from
(potentially) a different ModuleFile and therefore using a
different archetype (since the deserializer assumes that
different modules never share archetypes).

The fix relies on processing a generic parameter list before
any references to the archetypes.  Unfortunately, we have
bogus references to archetypes in substitution lists scattered
everywhere in SIL and the AST.  I've introduced a really
gross hack where we allow archetypes to be created in that
way but just drop them (in favor of the parameter's archetype)
after processing the generic parameter list; this should
work as long as all the decontextualized references are
basically pointless, but like I said, it's gross, and I've
filed rdar://16240384 to clean it up.

Swift SVN r14694
2014-03-05 22:41:28 +00:00
Michael Gottesman
0aebf1f4a5 [sil-deserialization] Teach SIL how to deserialize generic outer parameters.
With this commit, we can deserialize the stdlib. Still running into
issues related to linking that requires a consultation with John. That
will come in a later commit.

Swift SVN r14365
2014-02-26 01:14:08 +00:00
Jordan Rose
9a45a563ea Load Swift modules from framework bundles.
Swift can now find modules inside framework bundles matching this layout:

Foo.framework/
  Foo.swiftmodule/
    ARCH.swiftmodule

Currently, ARCH is the architecture name used by build configurations (#if),
but this was more done out of convenience than anything else (there's
currently no access to the current target from the ASTContext). We'll need
to revisit this if/when we decide to support architecture subtypes (armv7s
vs. armv7 vs. arm), at which point we'll also have to deal with fallback
architectures.

Framework search paths are specified using -F. Like bare import paths, there
are currently no "built-in framework search paths".

The master plan for Swift frameworks is in <rdar://problem/16062602>.

<rdar://problem/16155907>

Swift SVN r14363
2014-02-26 01:12:18 +00:00
Argyrios Kyrtzidis
9873694a88 [Serialization] A module that shadows a system module, should be considered a system one as well.
Fixes rdar://16092932

Swift SVN r14263
2014-02-22 18:56:04 +00:00
Michael Gottesman
9311672c33 Move ModuleFile.h, ModuleFormat.h, and DeclTypeRecordNodes.def to include/swift/Serialization.
This allows for a secondary tool to access the deserialized Module inside the SerializedASTFile's ModuleFile.

Swift SVN r14173
2014-02-20 22:03:55 +00:00