Commit Graph

253 Commits

Author SHA1 Message Date
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
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
9ddf57f7ba Don't treat missing imports as a fatal error in REPL mode.
We don't want typos in import statements to take down the whole REPL, but we
/do/ want the REPL to be honoring fatal errors that effectively take down the
ASTContext.

This doesn't (yet) apply to the real LLDB REPL, which does not use
SourceFileKind::REPL for its input. The right option to test there is
LangOpts.DebuggerSupport, but that's currently being set for Playgrounds as
well. I've filed <rdar://problem/18090611> for LLDB to adjust their input.

Part of <rdar://problem/17994094>

Swift SVN r21383
2014-08-21 22:36:22 +00:00
Jordan Rose
4eebcb9853 Change ASTContext's LoadedModules map to be keyed by Identifiers, not strings.
No intended functionality change, but there's no reason to be performing
string lookups here.

Swift SVN r20902
2014-08-01 18:03:47 +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
Doug Gregor
a885d1b3bd Transfer the buffer for the module documentation file only when it exists.
More fallout from LLVM r212408.

Swift SVN r19613
2014-07-07 15:31:55 +00:00
Pete Cooper
0d0defff9a Update which matches clang r212408, ie, using ErrorOr for file loading
Swift SVN r19607
2014-07-07 14:49:01 +00:00
Mark Lacey
dccd703315 Use <system_error> rather than llvm/Support/system_error.h.
Rafael removed the latter in r210803.

Swift SVN r18842
2014-06-12 21:53:16 +00:00
John McCall
8a6ee4c8e7 Fix harder for LLVM/Clang trunk.
Swift SVN r18839
2014-06-12 21:11:11 +00:00
Bob Wilson
9ab1136ba8 Update error_code usage to match llvm trunk.
LLVM's system_error.h has been changed to forward to the standard
version of the same. Update usage for the minor API changes that this
entails.

Based in part on a patch by Justin Bogner.

Swift SVN r18832
2014-06-12 19:48:39 +00:00
Jordan Rose
2877bd0854 Add support for dependency file generation with -emit-dependencies.
This performs very conservative dependency generation for each compile task
within a full compilation. Any source file, swiftmodule, or Objective-C
header file that is /touched/ gets added to the dependencies list, which
is written out on a per-input basis at the end of compilation.

This does /not/ handle dependencies for the aggregated swiftmodule, swiftdoc,
generated header, or linked binary. This is just the minimum needed to get
Xcode to recognize what needs to be rebuilt when a header or Swift source
file changes. We can revisit this later.

This finishes <rdar://problem/14899639> for now.

Swift SVN r18045
2014-05-14 00:34:11 +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
Jordan Rose
7a975e6fad Accept directory-style swiftmodules outside of frameworks as well.
This is needed for unit tests to import app modules, but could also be used
to get rid of the "/32" used for the standard libraries.

This is the rest of <rdar://problem/16776466>

Swift SVN r17177
2014-05-01 20:40:11 +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
Doug Gregor
5698fd3b8a Don't look in the standard import locations when building the core standard library.
This is a better way to fix the Darwin overlay <-> swift_stdlib_core
inferred circular dependency <rdar://problem/16603168>.

Swift SVN r16476
2014-04-17 22:07:48 +00:00
Argyrios Kyrtzidis
f1d14c0911 [Basic/LangOptions] Remove std::unordered_map/unordered_set from LangOptions and use SmallVector instead.
The config options are so few that a map is not worth it currently.

Swift SVN r15476
2014-03-26 00:26:17 +00:00
Dmitri Hrybenko
c1d96e579e Comment parsing: allow parsing comments with invalid source locations -- these
come from serialized modules


Swift SVN r15104
2014-03-15 14:58:29 +00:00
Jordan Rose
c8d9e94f85 [serialization] Disable swiftdoc loading for the standard library modules.
This is causing crashes in the IDE tests. Filed <rdar://problem/16329990>.

Swift SVN r15075
2014-03-14 20:51:19 +00:00
Jordan Rose
27d31c3672 [serialization] Framework modules live in Foo.framework/Modules/Foo.swiftmodule.
...due to a code signing issue. See <rdar://problem/16328065> for details.

Also, fix an error where the wrong file name was being used for framework
docs.

No release note because no one is using Swift frameworks yet (besides LLDB).

Swift SVN r15074
2014-03-14 20:51:19 +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
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
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
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
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
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
0de8d19514 Define globals for the names of the stdlib, ObjectiveC, and Foundation modules.
This is mostly useful for the standard library, whose name is going to
change to "Swift" soon. (See <rdar://problem/15972383>.) But it's good DRY.

Swift SVN r13758
2014-02-10 22:40:42 +00:00
Jordan Rose
cbcf17f9bd Stop leaking memory from Module and FileUnit.
Also, disallow creating Modules and FileUnits on the stack. They must always
live as long as the ASTContext.

<rdar://problem/15596964>

Swift SVN r13671
2014-02-08 02:12:57 +00:00
Jordan Rose
1d0d9ed070 Include the xcrun incantation to print the SDK path in the "no SDK" error.
Per DaveA's suggestion.

Swift SVN r13250
2014-01-31 23:01:08 +00:00
Jordan Rose
7d01643444 Don't automatically put the current directory in the include path.
Also, don't allow file-relative imports (i.e. don't consider a /source file's/
location as an include path). Both of these should be requested by the user,
at least at this point.

Swift SVN r13249
2014-01-31 23:01:08 +00:00
Jordan Rose
d0d4286d21 Put modules for 32-bit iOS builds in lib/swift/iphone{os,simulator}/32.
This keeps us from having to deal with fat swiftmodules for now.
In the long run we're hoping to solve this problem with build configurations,
so that a single module file can support multiple architectures.
(See <rdar://problem/15056323>)

<rdar://problem/15204953>

Swift SVN r13135
2014-01-30 03:26:50 +00:00
Jordan Rose
130ebe4fd4 Revert "Special-case the standard library to always live relative to the compiler."
This reverts r12932; it breaks the iOS simulator build.

Swift SVN r12944
2014-01-24 23:12:24 +00:00
Jordan Rose
4844f22475 Special-case the standard library to always live relative to the compiler.
Import "swift" will now only find "swift.swiftmodule", and only in the
runtime import path.

<rdar://problem/15898866>

Swift SVN r12932
2014-01-24 20:10:26 +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
11008f0ed1 Split diagnostics out into separate files.
Thanks to the way we've set up our diagnostics engine, there's not actually
a reason for /everything/ to get rebuilt when /one/ diagnostic changes.
I've split them up into five categories for now: Parse, Sema, SIL, IRGen,
and Frontend, plus a set of "Common" diagnostics that are used in multiple
areas of the compiler. We can massage this later.

No functionality change, but should speed up compile times!

Swift SVN r12438
2014-01-17 00:15:12 +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
Greg Parker
0e360cb26e Install stdlib into /usr/lib/swift/<OS name>/.
This reinstates r11411 with fixes for the autoconf+make build.


Swift SVN r11494
2013-12-20 01:01:35 +00:00
Chris Lattner
073974dca4 revert r11411, which completely broke the makefile build.
Swift SVN r11414
2013-12-18 04:33:58 +00:00
Greg Parker
9032632299 Install stdlib into /usr/lib/swift/<OS name>/.
Swift SVN r11411
2013-12-18 02:19:29 +00:00
Connor Wakamo
1ecc5cc3e6 [frontend] Moved ImportSearchPaths out of CompilerInvocation/ASTContext and into SearchPathOptions.
Also updated findModule() in SourceLoader.cpp and SerializedModuleLoader.cpp to get the ImportSearchPaths from the ASTContext’s SearchPathOpts, instead of directly from the ASTContext.

Swift SVN r11214
2013-12-12 22:15:58 +00:00
Connor Wakamo
86b4a3b049 [frontend] Begin moving search path-related options into SearchPathOptions.
Added a new SearchPathOptions class to swiftAST, which will contain options like import search paths and the SDK path.
Moved the RuntimeIncludePath from CompilerInvocation into SearchPathOptions. For now, at least, the RuntimeIncludePath is handled separately from other ImportSearchPaths, since we can’t yet guarantee that RuntimeIncludePath is set up before we parse the ImportSearchPaths.
Added a SearchPathOptions member to ASTContext.
Updated findModule() in SourceLoader.cpp and SerializedModuleLoader.cpp to check RuntimeIncludePath after everything else if no module was found. (This matches existing behavior, which had RuntimeIncludedPath at the end of ImportSearchPaths.)

Swift SVN r11213
2013-12-12 21:38:11 +00:00
Dmitri Hrybenko
11ccb38e06 AST printer: use getDisplayDecls() to find a list of decls to print.
We are still not completely correct in determining which extensions to print,
will fix in future patches.


Swift SVN r10960
2013-12-07 00:54:05 +00:00
Jordan Rose
439ba3e624 Accept swiftmodule files on the command line as partial AST inputs.
Each loaded file gets added to the main module, rather than being a standalone
separate module. In theory, this will be used to assemble several partial
ASTs into a complete module. In practice, there's still a ways to go...but
this can already round-trip a single module file.

This also factors out the FileUnit-creating part of SerializedModuleLoader,
which should help clients like SourceKit that don't need to search for a
swiftmodule file associated with a particular import.

Swift SVN r10952
2013-12-07 00:14:01 +00:00
Jordan Rose
417b5d3982 Merge TranslationUnit into Module, and eliminate the term "translation unit".
This completes the FileUnit refactoring. A module consists of multiple
FileUnits, which provide decls from various file-like sources. I say
"file-like" because the Builtin module is implemented with a single
BuiltinUnit, and imported Clang modules are just a single FileUnit source
within a module.

Most modules, therefore, contain a single file unit; only the main module
will contain multiple source files (and eventually partial AST files).

The term "translation unit" has been scrubbed from the project. To refer
to the context of declarations outside of any other declarations, use
"top-level" or "module scope". To refer to a .swift file or its DeclContext,
use "source file". To refer to a single unit of compilation, use "module",
since the model is that an entire module will be compiled with a single
driver call. (It will still be possible to compile a single source file
through the direct-to-frontend interface, but only in the context of the
whole module.)

Swift SVN r10837
2013-12-05 01:51:15 +00:00