Commit Graph

849 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
b3f470ad16 [ClangImporter] Make getting the ClangNode from a swift Decl more efficient by
allocating extra memory and storing it directly before the swift AST object.

Reduces code-completion time for Cocoa by -25%.

Swift SVN r16615
2014-04-21 07:18:50 +00:00
Doug Gregor
825e5be3d2 Default-initialize optional variables/properties to 'nil'.
Addresses <rdar://problem/16342813>.


Swift SVN r16222
2014-04-11 17:59:14 +00:00
Doug Gregor
1ce86d16f8 Validate @IBOutlet specifically.
Finishes the @IBOutlet portion of <rdar://problem/16281474>.

Swift SVN r16167
2014-04-10 18:22:24 +00:00
Dmitri Hrybenko
fb2a6499cd Move @class_protocol to use the new attribute infrastructure
... and fix a few other bugs:

* always set the inherited protocols on the ProtocolDecl in the type checker,
  so that we can remove a hack in ProtocolDecl::requiresClassSlow();

* diagnose DeclAttributes that are inverted when this is not allowed.


Swift SVN r15992
2014-04-06 01:24:08 +00:00
Dmitri Hrybenko
c2354eb365 USR generation: generate USRs for imported macros
I do feel bad about introducing ClangModuleLoader, but it is better than a
layering violation (using libClangImporter from libAST).


Swift SVN r15679
2014-03-31 15:13:00 +00:00
Ted Kremenek
39dc97738b For "unknown declared type" errors involving remapped types, suggest the remapped type as a fixit.
For example:

  func foo(a: id)

now gets a fixit to turn 'id' into 'AnyObject'.

This relies on the ClangImporter recording the translation as it
processes declarations whose types are remapped.

Swift SVN r15668
2014-03-31 07:10:32 +00:00
Dmitri Hrybenko
a52b747c03 Don't forward-declare BumpPtrAllocator to be compatible with older and newer
clangs

(BumpPtrAllocator was changed to a class template upstream.)



Swift SVN r15650
2014-03-30 18:56:19 +00:00
Jordan Rose
608fee70f1 Replace ASTMutationListener with a new LazyResolver callback.
..."resolveExternalDeclImplicitMembers".

Now that the ClangImporter has direct access to the type-checker (through
a LazyResolver), there's no reason to bounce through an obtusely generic
interface on ASTContext. Just call through directly to handle the implicit
members and conformances of external decls.

There's no actual functionality change here, though we can probably do
further cleanup in this area.

Swift SVN r15356
2014-03-22 00:20:00 +00:00
Doug Gregor
f94a5e5df4 Call a standard library entry point from initializer stubs.
Rather than simply trapping with no output, have the initializer stubs
call into a new standard library function _unimplemented_initializer
that emits a more reasonable diagnostic, containing the name of the
class, the name of the initializer, and the file/line/column where the
class itself is defined. This finishes <rdar://problem/16156996>.



Swift SVN r15049
2014-03-14 15:04:49 +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
Dmitri Hrybenko
328c4b6528 Use the C++11 spelling of alignof()
Swift SVN r14683
2014-03-05 15:53:34 +00:00
Dmitri Hrybenko
c0cb085870 Comment parsing: add APIs to get brief comments
These return placeholder text at the moment, but this enables us to can build
infrastructure that passes them around before the ReST parser is working.


Swift SVN r14650
2014-03-04 18:18:43 +00:00
Chris Lattner
11bedff2f3 the swift.Slice type got removed a long time ago, being replaced with
what is now Swift.Array.  Update various internal stuff to refer to
Array instead of Slice.  NFC.


Swift SVN r14567
2014-03-02 06:21:37 +00:00
Joe Groff
8e6b353542 Derive conformances of Equatable and Hashable for simple enums.
If an enum has no cases with payloads, make it implicitly Equatable and Hashable, and derive default implementations of '==' and 'hashValue'. Insert the derived '==' into module context wrapped in a new DerivedFileUnit kind, and arrange for it to be codegenned with the deriving EnumDecl by adding a 'DerivedOperatorDecls' array to NominalTypeDecls that gets visited at SILGen time.

Swift SVN r14471
2014-02-27 20:28:38 +00:00
Dmitri Hrybenko
b4bf794551 ASTContext: make RawComment APIs private. One should use Decl's APIs instead.
Swift SVN r14085
2014-02-19 16:35:22 +00:00
Dmitri Hrybenko
34df7b494e Comment parsing: recognize documentation and non-documentation comments, merge
consecutive documentation comments and form 'RawComment's.


Swift SVN r14084
2014-02-19 16:20:38 +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
Dmitri Hrybenko
b8817ae5f6 Move two operators to KnownIdentifiers.def
Swift SVN r13866
2014-02-13 10:37:31 +00:00
Dmitri Hrybenko
5fa3e49b91 AST printer: don't print module qualification on declarations from 'ObjectiveC'
module

rdar://16015774


Swift SVN r13838
2014-02-12 20:53:36 +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
Doug Gregor
a28a17250d Allow type substitutions to look up a member type of a type variable.
Use the just-introduced functionality to track the member types of a
type variable to allow type substitution to look up a member type of a
type variable, rather than failing to substitute. NFC yet.

Swift SVN r12972
2014-01-26 22:38:42 +00:00
Doug Gregor
159dd088d8 Move the "type conforms to protocol" cache into the ASTContext arena.
This fixes an awful nondeterministic memory smasher involving cases
where the type checker checks whether a type involving type variables
conforms to a given protocol. The checks were cached in an
ASTContext-level data structure, but the keys involved
constraint-checker-allocated types. Stale entries in the cache caused
all manners of unreproducible weirdness, almost surely including
<rdar://problem/15715339>, <rdar://problem/15736793>,
<rdar://problem/15768325>, and probably others.

Swift SVN r12898
2014-01-24 04:13:15 +00:00
Doug Gregor
d52cec4b20 Eliminate a pile of literal identifiers for self, init, destructor, etc.
... because I can't stomach adding another one of these.


Swift SVN r12687
2014-01-22 01:09:49 +00:00
John McCall
817e80bde5 Implicit conversions for UncheckedOptional.
rdar://15189000
rdar://15189009

Swift SVN r12260
2014-01-13 23:15:03 +00:00
John McCall
1bc1c669a2 Add the '@unchecked T?' syntactic sugar for UncheckedOptional<T>.
Swift SVN r12128
2014-01-10 19:13:51 +00:00
Joe Groff
ba2f1c6b16 Give the compiler special knowledge of Optional's enum layout.
This will let us phase out the optional intrinsics now that the enum implementation is mature.

Swift SVN r11808
2014-01-02 01:42:41 +00:00
Doug Gregor
be3463f32d Store a file-level DeclContext* in protocol conformances rather than a module.
We'll need to perform name lookup based on the file-level
DeclContext*, so the module no longer suffices. No functionality
change here yet.


Swift SVN r11523
2013-12-20 22:53:21 +00:00
Doug Gregor
b9696e1c01 Create protocol conformances and then, separately, fill in the witnesses.
This is a structural baby step toward lazily filling in protocol
conformances. We always build a ProtocolConformance, then mark it
either "complete" (when it's well-formed) or "invalid" (when it's
ill-formed). At present, the only benefit to this is that it slows
diagnostic cascades from invalid conformances.


Swift SVN r11492
2013-12-20 00:29:00 +00:00
Jordan Rose
308c6139f9 Change ASTContext::allocate(unsigned) to return a MutableArrayRef.
...rather than a raw pointer that points to a buffer with space for N
elements. Just because we *can* get N from context doesn't mean it's
convenient/safe.

No functionality change.

Swift SVN r11488
2013-12-19 23:25:04 +00:00
Doug Gregor
11b6d19dd3 Add a location to NormalProtocolConformance.
This will be used for diagnostics in an upcoming refactor.


Swift SVN r11348
2013-12-16 17:24:15 +00:00
Doug Gregor
07c0793e30 Construct the type witnesses of SpecializedProtocolConformance lazily.
A SpecializedProtocolConformance intentionally contains all of the
information we need to synthesize the type witnesses from the
underlying (generic) conformance. Do so lazily rather than eagerly,
because we won't always need all of them.

As a nice side effect, we no longer need to serialize the witnesses of
these specialized protocol conformances, so we can save some space in
the Swift module file.


Swift SVN r11303
2013-12-14 06:20:44 +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
John McCall
342a8b35db Parse default-argument expressions in an initializer context.
Swift SVN r11178
2013-12-12 03:36:27 +00:00
Argyrios Kyrtzidis
c28d460307 [AST] Make ClangNode a class.
Swift SVN r10993
2013-12-08 18:36:06 +00:00
Joe Groff
5a08bfae70 Extend SubstitutableType::getName() to handle dependent substitutable types.
And factor the code that produces the canonical '$T_n_n' names into it.

Swift SVN r10986
2013-12-07 23:56:28 +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
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
Jordan Rose
eede5ec4f9 Begin refactoring for mixed file kinds within a single module.
The goal of this series of commits is to allow the main module to consist
of both source files and AST files, where the AST files represent files
that were already built and don't need to be rebuilt, or of Swift source
files and imported Clang headers that share a module (because they are in
the same target).

Currently modules are divided into different kinds, and that defines how
decls are looked up, how imports are managed, etc. In order to achieve the
goal above, that polymorphism should be pushed down to the individual units
within a module, so that instead of TranslationUnit, BuiltinModule,
SerializedModule, and ClangModule, we have SourceFile, BuiltinUnit,
SerializedFile, and ClangUnit. (Better names welcome.) At that point we can
hopefully collapse TranslationUnit into Module and make Module non-polymorphic.

This commit makes SourceFile the subclass of an abstract FileUnit, and
makes TranslationUnit hold an array of FileUnits instead of SourceFiles.
To demonstrate that this is actually working, the Builtin module has also
been converted to FileUnit: it is now a TranslationUnit containing a single
BuiltinUnit.

Swift SVN r10830
2013-12-05 01:51:03 +00:00
Dmitri Hrybenko
d076501cca Don't repeat Context.getIdentifier("self") everywhere in the code base
Swift SVN r10786
2013-12-04 18:42:34 +00:00
John McCall
555b57ca00 The constant types on ASTContexts are all canonical.
Swift SVN r10065
2013-11-09 01:41:11 +00:00
Dmitri Hrybenko
2e53423e33 ASTContext: add "the one true way" to get the stdlib module
Swift SVN r9952
2013-11-05 01:40:24 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Jordan Rose
64e0b2200a Make sure to resolve library intrinsics before using them.
Otherwise, compiling the standard library will try to use, say,
_getOptionalValue() before that function has any type.

Swift SVN r9671
2013-10-25 17:30:41 +00:00
Dmitri Hrybenko
f9382f8d01 Remove ModuleLoadListener, it is not used anymore
Swift SVN r9638
2013-10-24 04:50:31 +00:00
Dmitri Hrybenko
c6f1bec10d Add an API ASTContext::getLoadedModule() to return the module only if it was
loaded already, without trying to load it.


Swift SVN r9601
2013-10-22 22:03:28 +00:00
Argyrios Kyrtzidis
549dfb882a [AST] Record and report the protocol requirement decls that a ValueDecl conforms to.
Swift SVN r9587
2013-10-22 15:47:37 +00:00
Dmitri Hrybenko
acdd5b120a Make type checker debug output redirectable
Introduce a replaceable TypeCheckerDebugConsumer for this.


Swift SVN r9555
2013-10-21 20:26:32 +00:00
Mon Ping Wang
00467ba953 Reintroduce "Add support for Axle library." from 9292. Added an dependency to prevent building the
core and axle core at the same time.


Swift SVN r9309
2013-10-14 07:51:19 +00:00
Joe Groff
cf457d2210 Revert "Add support for Axle library." It breaks the build.
This reverts commit r9292.

Swift SVN r9296
2013-10-13 22:38:22 +00:00