Commit Graph

542 Commits

Author SHA1 Message Date
Jordan Rose
042569a3be Optional: Replace uses of Nothing with None.
llvm::Optional (like Swift.Optional!) uses None as its placeholder value,
not Nothing.

Swift SVN r22476
2014-10-02 18:51:42 +00:00
Jordan Rose
9aed764daa Re-apply "Verify deserialized Swift decls as well as imported Clang decls."
Swift SVN r22248
2014-09-24 00:53:36 +00:00
Dmitri Hrybenko
fec622de0a Revert "Verify deserialized Swift decls as well as imported Clang decls."
This reverts commit 22200.  It broke building PerfTestSuite:
<rdar://problem/18423171> crash in type checking

Swift SVN r22209
2014-09-23 10:13:03 +00:00
Jordan Rose
a49874afb5 Verify deserialized Swift decls as well as imported Clang decls.
Like the Clang decls, this happens at the end of the type-checking, just as
a simple walk through the loaded decls of the loaded modules. This caught
all of the issues in this commit series and will hopefully keep us honest in
the future.

(By the way, we don't verify right when we return a deserialized decl for the
same reason we don't verify right when we return an imported decl: parts of
the decl may be delayed, and (a) we don't want to force things to be imported
or deserialized sooner than necessary, yet (b) we want to verify as much as
possible.)

rdar://problem/16968891

Swift SVN r22200
2014-09-23 02:06:27 +00:00
Doug Gregor
3119e6d345 Remove the tables that track the types that conform to "known" protocols.
The type checker no longer needs them.


Swift SVN r22137
2014-09-19 16:41:26 +00:00
Jordan Rose
1b51b60e72 [Serialization] Preserve private discriminators through serialization.
Part of rdar://problem/17632175

Swift SVN r21611
2014-08-30 17:27:02 +00:00
Jordan Rose
fcfd44c756 Use actual Identifiers for private discriminators, rather than strings.
This is useful both for caching purposes and for comparison of discriminators
(something the debugger will need to do when looking up a particular decl).

No observable functionality change.

Swift SVN r21610
2014-08-30 17:26:59 +00:00
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
6d7d141b09 [Serialization] Sanity-check alignment of AST data.
Somewhere--and I forget where--either the LLVM bitcode system or the
OnDiskHashTable implementation depends on 32-bit alignment being preserved.
We had thought that only alignment /from the start of the stream/ mattered,
but it looks like the whole data section has to be 32-bit-aligned.

<rdar://problem/17814086>

Swift SVN r20599
2014-07-27 00:47:39 +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
ed8f1c578e Handle scoped imports for Clang submodules.
"import func Darwin.C.math.hypot" will now work to just import "hypot".
(Since 'Darwin.C.math' is an implicit submodule of 'Darwin',
 "import func Darwin.hypot" also works. That's okay.)

<rdar://problem/17272311>

Swift SVN r20356
2014-07-23 01:12:39 +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
Chris Lattner
48687380b7 now that DeclAttributes is a single word, there is no reason to deal with
it indirectly through another pointer from Decl, just embed DeclAttributes
directly into Decl and get rid of the "getMutableAttrs" nonsense.



Swift SVN r20216
2014-07-20 04:09:42 +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
Argyrios Kyrtzidis
9a060c0de8 In ModuleFile::lookupVisibleDecls(), if the caller requested scoped decls, don't return the all the top-level ones as well.
Swift SVN r18327
2014-05-18 16:08:40 +00:00
Jordan Rose
dde2a8b06b Serialize and honor whether a particular library should be force-loaded.
When a module built with -autolink-force-load is imported, add a reference
to a special symbol in the corresponding library so that ld is forced to
link it.

This means the library will be linked into the final binary even if no other
symbols are used (which happens for some of our overlays that just add
category methods to Objective-C classes).

Second part of <rdar://problem/16829587>

Swift SVN r17751
2014-05-09 01:20:32 +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
Dmitri Hrybenko
28b05c99b4 Rework r16878. Now we refuse to generate a USR for 'self' in destructors
Filed rdar://16734962 to investigate the real bug.


Swift SVN r16881
2014-04-26 14:12:31 +00:00
Argyrios Kyrtzidis
936bf6238f [Serialization] In ModuleFile::getCommentForDecl, we don't need to lookup comments attached to ParamDecls.
Fixes assertion hit in rdar://16720741.

Swift SVN r16878
2014-04-26 07:21:37 +00:00
Dmitri Hrybenko
9928be1030 Comment parsing: keep the column number of the first character to strip ASCII
art correctly when indentation is present


Swift SVN r16656
2014-04-22 16:34:00 +00:00
Jordan Rose
4a36db7835 [serialization] Print the path to a too-new, too-old, or malformed module file.
<rdar://problem/16680615>

Swift SVN r16637
2014-04-22 01:51:19 +00:00
Justin Bogner
c7070b0ac2 Teach more users of OnDiskHashTable to define hash_value and offset types
I'd missed a few of these on the first pass. This should get the
builds going again.

Swift SVN r16570
2014-04-19 18:36:45 +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
110f85bc16 Move @exported to use new attribute infrastructure
Swift SVN r16158
2014-04-10 13:35:35 +00:00
Doug Gregor
9189145cc5 Change DeclName over to basename(arg1:arg2:...argN:).
Swift will use the basename + argument names formulation for
names. Update the DeclName interfaces, printing, and __FUNCTION__ to
use the method syntax.

We'll still need to rework the "x.foo:bar:wibble:" syntax; that will
come (significantly) later.

Swift SVN r15763
2014-04-02 00:00:03 +00:00
Doug Gregor
323b1829b3 Adapt to upstream changes in LLVM and Clang.
Swift SVN r15622
2014-03-29 17:08:09 +00:00
Jordan Rose
fd1f276804 Clean up logic from previous commit.
No functionality change.

Swift SVN r15085
2014-03-14 22:24:23 +00:00
Jordan Rose
c7804dc779 When loading a Swift framework module, see if it's also a Clang module.
In a framework containing both Clang headers and a Swift module, the Swift
module gets picked up first, but then automatically imports (and re-exports)
the Clang module as well.

One interesting case here is that it's possible for the Clang side to add
categories to a class declared in Swift. In order to support this, the
Clang importer can now find extensions for Swift classes marked @objc.
(I couldn't think of a way to test this separately; the previous commit
was supposed to do that, but worked without this change.)

<rdar://problem/16295937>

Swift SVN r15084
2014-03-14 22:21:08 +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
ed80c68cb5 [serialization] Don't assert when a module file's length is not 32-bit-aligned.
This won't ever happen naturally, but by either messing with the module file
or asking the compiler to load something that isn't a module at all we could
end up hitting the assert.

<rdar://problem/16274875>

Swift SVN r14902
2014-03-11 01:27:34 +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
ba6548b072 Track uptstream LLVM API change: llvm::tie() was removed, use std::tie() instead
Swift SVN r14573
2014-03-02 13:53:19 +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
Michael Gottesman
79df4dd8b4 Remove trailing whitespace and unneeded -*- c++ -*- from .cpp files.
Swift SVN r14350
2014-02-25 19:17:05 +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
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
f7977e6807 [serialization] Reject modules with a different version number.
From now on, /any/ changes to SIL or AST serialization must increment
VERSION_MINOR in ModuleFormat.h.

The original intent of VERSION_MAJOR/VERSION_MINOR was that VERSION_MAJOR
would only increment when backwards-incompatible changes are introduced,
and VERSION_MINOR merely indicates whether to expect additional information.
However, the module infrastructure currently isn't forgiving enough to accept
even backwards-compatible changes to the record schemas, and the SIL
serialization design might not be compatible with that at all.

So for now, treat any version number 0.x as incompatible with any other 0.y.
We can bump to 1 when we hit stability.

<rdar://problem/15494343>

Swift SVN r13841
2014-02-12 21:33:45 +00:00
Jordan Rose
cc3119be51 Teach the Mach-O-based AST importer to accept bare serialized ASTs.
This necessitated adding a new function to validate a serialized AST, so
that we can get the same information that used to be extracted from the
section header.

For now, we'll continue accepting the wrapped ASTs as well, since we
haven't changed the existing debug info generator.

Swift SVN r12922
2014-01-24 18:42:07 +00:00
Jordan Rose
af700a1912 [serialization] Include the module name in the serialized AST data.
We don't currently use this for anything, but if we have the module name
available and easy to access in the bitstream, we can drop the wrapper
around the serialized AST that's put into the binary itself for use by LLDB.

Swift SVN r12921
2014-01-24 18:42:06 +00:00
Jordan Rose
f214e2f185 [serialization] Include the module name in the serialized AST data.
We don't currently use this for anything, but if we have the module name
available and easy to access in the bitstream, we can drop the wrapper
around the serialized AST that's put into the binary itself for use by LLDB.

Swift SVN r12919
2014-01-24 18:42:03 +00:00
Jordan Rose
5f9c652ff9 Don't blow up when an adapter's underlying module is missing.
Instead, emit a specific error, along with the same "SDK is missing" note
from the last commit.

Swift SVN r12416
2014-01-16 20:08:09 +00:00
Doug Gregor
1482256a04 Make operator methods to module-scope name lookup.
Fixes the operator name lookup issue in <rdar://problem/15715996>.

Swift SVN r11724
2013-12-29 20:41:07 +00:00
Chris Lattner
af96933ced remove a dead function.
Swift SVN r11229
2013-12-13 01:42:59 +00:00
Jordan Rose
a9e90b61e7 [serialization] Don't eagerly load extensions for deserialized nominals.
The only reason to do this was in case an extension adopted a compiler-known
protocol, but that has long ben taken care of by
ModuleFile::loadDeclsConformingTo.

Swift SVN r11224
2013-12-13 00:26:11 +00:00
Jordan Rose
f29f083fcb [serialization] Stop eagerly deserializing decls with conversion functions.
There shouldn't ever be a reason to do this: if a conversion function is
ever selected by the type-checker, it's because the type the conversion
lives on was suggested by another constraint, which means we can do a
normal lookup for the conversion function.

This is actually the only thing being eagerly deserialized, so remove the
notion of eager deserialization altogether.

Swift SVN r11220
2013-12-12 23:31:16 +00:00
Dmitri Hrybenko
a768ea8ef3 AST printing / getDisplayDecls: correctly form the access path to the module
Removes (harmless) stderr output in tests like:

error: no submodule named 'fooFunc1' in module 'FooClangModule'


Swift SVN r11200
2013-12-12 19:19:14 +00:00