Commit Graph

269 Commits

Author SHA1 Message Date
Jordan Rose
c2b00fc2d4 Excise the global TranslationUnit from TypeChecker.
Now that TypeChecker is being used to check all sorts of things (not all
from a single TU), it's not really correct to have a single top-level TU
that gets used everywhere. Instead, we should be using the TU that's
appropriate for whatever's being checked. This is a small correctness win
for order-independent type-checking, but is critical for multi-file
translation units, which is needed for implicit visibility.

This basically involves passing around DeclContexts much more.

Caveat: we aren't smart about, say, filtering extensions based on the
current context, so we're still not 100% correct here.

Swift SVN r9006
2013-10-07 23:47:55 +00:00
Chris Lattner
73ad4dbb6a Completely remove the stacktossa pass, it is dead now.
Swift SVN r8996
2013-10-07 22:11:32 +00:00
Chris Lattner
d6b01a42ad add a new (skeleton) pass for deshadowing inout variables.
Swift SVN r8954
2013-10-07 15:53:40 +00:00
Anna Zaks
a19d7569cc Introduce Builtin.staticReport, which allows compiler diagnostic reporting.
- Introduces the Builtin
- If the first parameter evaluates to '1', the dataflow diagnostics pass produces a diagnostic.
- The Builtin gets cleaned up before IRGen, but not before SIL serialization.

This patch also removes the current, overflow warning and XFAILs one of the tests. The other test is switched to use Builtin.staticReport.

TODO:
 - Utilize the other parameters to the builtin - the Message and IsError flag.
 - Use this Builtin within the stdlib.

Swift SVN r8939
2013-10-05 00:12:23 +00:00
Chris Lattner
767da738bb Change the command line option to sil-opt for the definite initialization
pass to be -definite-init instead of -memory-promotion, rename the
entrypoint for the pass to match, and tidy various and sundry comments.


Swift SVN r8927
2013-10-04 18:45:09 +00:00
Jordan Rose
7055713d36 Remove declaration of nonexistent function swift::performCaptureAnalysis()
I think this is now TypeChecker::computeCaptures() and is only needed in Sema.

Swift SVN r8826
2013-10-01 23:10:22 +00:00
Jordan Rose
15bfc8db2b Don't type-check imported decls unless referenced in the source file.
Instead, pass a LazyResolver down through name lookup, and type-check
things on demand. Most of the churn here is simply passing that extra
LazyResolver parameter through.

This doesn't actually work yet; the later commits will fix this.

Swift SVN r8643
2013-09-25 20:08:14 +00:00
Dmitri Hrybenko
a11f623a47 Code completion: partial type checking of constructor bodies
Swift SVN r8343
2013-09-17 18:45:51 +00:00
Manman Ren
fa0acc9328 SIL Serialiation: add implementation to deserialize SIL and a wrapper class
SerializedSILLoader to hold a list of SIL deserializers.

Also add an intial implementation of a linking pass that is run right after
SILGen to link the declaration of SILFunction to the actual definition in
the serialized module.

We add two blocks to the serialized module: a sil index block that
maps identifier to a function ID and also holds a list of function offsets,
and a sil block for the actual SILFunctions. We can probably use subblock
instead of two top-level blocks.

The serialization/de-serialization of the function hash table and the function
offsets are implemented. But we are missing handling of types (see FIXME in
the code).

ModuleFile::Serialized is made public to be used by SIL deserializer, as well
as ModuleFile::getType.

The SIL deserializer holds a pointer to the ModuleFile, it gets the sil cursor
and the sil index cursor from the ModuleFile. The other option is for SIL
deserializer to find the start of the two sil blocks within itself, thus having
less coupling with ModuleFile.

No testing case yet because we are missing handling of types.


Swift SVN r8206
2013-09-13 17:44:41 +00:00
Dmitri Hrybenko
5975fb71b2 Use FuncDecl in typeCheckFunctionBody() parameters
Swift SVN r8139
2013-09-12 01:23:21 +00:00
Dmitri Hrybenko
37ee3a210c Run AST verifier on modules produced by Clang importer and fix bugs found by it
Fixes two bugs in Clang importer and deserialization code that were found by
the verifier:

(1) FuncExprs were created with a null FuncDecl

(2) BoundGenericType that was created by Clang importer for UnsafePtr<> and
    other magic types did not have substitutions.


Swift SVN r8073
2013-09-10 18:22:12 +00:00
Manman Ren
64ccd88c8c SIL Serialiation: pass in a SILModule to serialize and a few other functions.
Add SerializeSIL.cpp for basic implementation of a SIL serializer.

serialize, serializeToStream, Serializer::writeToStream, and
Serializer::writeTranslationUnit all take an additional SILModule to pass it
to Serializer::writeSILFunctions.

Serializer::writeSILFunctions goes through all SILFunctions in a SILModule, and
serializes all SILFunctions that are transparent.


Swift SVN r7875
2013-09-03 22:57:37 +00:00
Stephen Lin
a0f44d50b2 Update remaining references to [force_inline] to [transparent]
Swift SVN r7627
2013-08-27 18:46:03 +00:00
Jordan Rose
ee2ed392c7 Hack in a -module-link-name option for autolinking.
In Swift, a module is expected to know which libraries it needs, rather than
having this specified by an external module map. While we haven't quite
designed this yet (frameworks get this for free in Clang, for example),
we can at least provide a simple option for the common case of a module
associated with a single library.

This will probably change in the future, so I left in the more general
deserialization code I was working on before simplifying the use case.
A loaded module can in theory specify any arbitrary frameworks or libraries
as dependencies, not just a single dylib.

Swift SVN r7583
2013-08-26 18:57:48 +00:00
Adrian Prantl
661315763a Debug Info: This patch implements the "emit modules when compiling -g"
proposal.
When compiling with debug info, build a swiftmodule that contains all the
type decls referenced by DWARF and emit it into a special __apple_swiftast
section in the .o file.

Swift SVN r7398
2013-08-21 01:07:30 +00:00
Dmitri Hrybenko
cdb1df51a3 Code completion: completion of type-ident in type contexts (like Foo.#^A^#)
This introduces the required code completion callbacks which pass partially
parsed TypeReprs to code completion.  These types can refer to generic function
parameters.  Because we need to typecheck these types, we need to typecheck
generic parameters first.  Because exposing fine-grained typechecker interface
just for code completion is bad, we create a function declaration based on the
limited information we have (i.e., just the function name and generic
parameters) and pass that to the typechecker.  This approach (in theory) should
work uniformly for function decls and nominal type decls, but the nominal type
decl case is not tested yet.  Eventually we will also want to use a similar
approach for normal parser recovery as well.


Swift SVN r7313
2013-08-17 02:35:32 +00:00
Stephen Lin
12e9086893 Initial implementation of mandatory inlining pass; non-recursive inlining, single basic blocks, no diagnosis of circular inlining
Swift SVN r7241
2013-08-14 22:30:20 +00:00
Anna Zaks
342dff1c80 [SIL CCP] Add the early constant propagation pass skeleton.
The pass folds a single operation: int_sadd_with_overflow and issues an
error on detectable overflow.

Swift SVN r7204
2013-08-13 17:36:35 +00:00
Dmitri Hrybenko
8d75dccc84 Code completion: implement partial typechecking of function bodies
This allows us to complete members of local variables and members of
expressions that include local variables.


Swift SVN r7033
2013-08-08 00:59:46 +00:00
Argyrios Kyrtzidis
4e297d044b Move tokenization of interpolated strings in swift::tokenize().
Swift SVN r6941
2013-08-06 14:59:02 +00:00
Chris Lattner
b3fadfc31b Add the outline of a new SIL memory promotion pass. This is what will handle
definite initialization, promoting boxes to stack, building ssa, and doing definite
initialization.

I'll build this in place, then kill off the other two passes when this subsumes them.


Swift SVN r6903
2013-08-05 16:39:26 +00:00
Dmitri Hrybenko
5cea4ebf41 Code completion: put CodeCompletionOffset on SourceManager instead of passing
around everywhere

Fixes:
rdar://14585108 Code completion does not work at the beginning of the file
rdar://14592634 Code completion returns zero results at EOF in a function
                without a closing brace


Swift SVN r6820
2013-08-01 22:08:58 +00:00
Dmitri Hrybenko
e1c4ae3174 Wrap llvm::SourceMgr in swift::SourceManager so that we can add new members
to the source manager.


Swift SVN r6815
2013-08-01 20:39:22 +00:00
Dmitri Hrybenko
e98ab3d83a swift::parseCompletionContextExpr() is dead code now, remove it.
Swift SVN r6794
2013-08-01 01:22:13 +00:00
Anna Zaks
64693183da [DCE] Add a very primitive dead code elimination pass
DCE is added as a separate SIL pass with it's own entry point.

For now, detect and simplify the branch instructions with constant
conditions and delete unreachable basic blocks (for now, we do not even
pay any regards to the basic block arguments).

Swift SVN r6713
2013-07-29 21:55:05 +00:00
Dmitri Hrybenko
497ec93ec9 Code completion: generate a tok::code_complete token during the first pass of
parsing

No functionality change, this will be used by next commits.


Swift SVN r6637
2013-07-26 01:40:47 +00:00
Argyrios Kyrtzidis
2f2eb83b7e Fix comments.
Swift SVN r6595
2013-07-25 14:42:09 +00:00
Chris Lattner
11f5b48a27 Fix a -Wdocumentation warning, and hack out NoFramePointerElimNonLeaf to
fix the build.  This isn't a proper fix (we should start putting out new attributes
on llvm::Function's, but getting the build working again seems important.


Swift SVN r6584
2013-07-25 03:41:57 +00:00
Argyrios Kyrtzidis
66d1e516c8 Refactor how multiple parsing passes and delayed parsing works.
-Introduce PersistentParserState to represent state persistent among multiple parsing passes.
  The advantage is that PersistentParserState is independent of a particular Parser or Lexer object.
-Use PersistentParserState to keep information about delayed function body parsing and eliminate parser-specific
  state from the AST (ParserTokenRange).
-Introduce DelayedParsingCallbacks to abstract out of the parser the logic about which functions should be delayed
  or skipped.

Many thanks to Dmitri for his valuable feedback!

Swift SVN r6580
2013-07-25 01:40:16 +00:00
Chris Lattner
1a75f7c5a3 more renaming to make things consistent-er
Swift SVN r6481
2013-07-22 21:42:25 +00:00
Chris Lattner
e0dbcc40de split memorypromotion into two different passes, split its testcases
in half, and switch them to use sil-opt to test with.


Swift SVN r6469
2013-07-22 20:59:28 +00:00
Anna Zaks
a984d9b24c Move the SIL diagnostic emission entrypoint from SILGen to the top level swift.cpp driver
This addresses Chris’s review of r6151.

Swift SVN r6290
2013-07-16 18:53:23 +00:00
Chris Lattner
ba4c64479c Have -emit-sil[gen] print a couple of import options. This is a hack (the right answer
is to print all referenced decls at the start of a .sil file), but it is a useful hack.



Swift SVN r6251
2013-07-15 15:49:29 +00:00
Chris Lattner
1277ac7e04 Carve out a new lib/SIL/Passes directory to hold future SIL optimizations
and dataflow warnings.  Add a skeletal MemoryPromotion entrypoint as the first
exemplar.


Swift SVN r6247
2013-07-15 14:51:37 +00:00
Dmitri Hrybenko
3c5b12fc0f Code completion: add a lot of infrastructure code
* Added a mode in swift-ide-test to test code completion.  Unlike c-index-test,
  the code completion token in tests is a real token -- we don't need to
  count lines and columns anymore.

* Added support in lexer to produce a code completion token.

* Added a parser interface to code completion.  It is passed down from the
  libFrontend to the parser, but its functions are not called yet.

* Added a sketch of the interface of code completion consumer and code
  completion results.

Note: all this is not doing anything useful yet.


Swift SVN r6128
2013-07-10 20:53:40 +00:00
Dmitri Hrybenko
cb98234d67 Allow the parser to persist after parseIntoTranslationUnit() returns
Swift SVN r6102
2013-07-10 00:25:37 +00:00
Dmitri Hrybenko
7e7409ac2b Use nullptr instead of '0'.
Swift SVN r6069
2013-07-08 22:14:57 +00:00
Argyrios Kyrtzidis
6e7d0490f7 Allow optionally to produce comment tokens when lexing and add a tokenize() utility function.
Swift SVN r6008
2013-07-05 15:02:42 +00:00
Chris Lattner
20229fbf85 Introduce infrastructure for maintaining per-translation unit SIL parser state across
invocations of the parser.



Swift SVN r5906
2013-06-30 18:44:59 +00:00
Chris Lattner
cc3f22839a rework how autoimport happens. Instead of being driven by what the
source file imports in the first few lines, drive it based on the TU
mode.


Swift SVN r5751
2013-06-21 18:45:58 +00:00
Joe Groff
8693c5efaa SIL: Emit String-to-NSString conversions.
If -nsstring-is-string is enabled, lower Strings in cc(c) and cc(objc) function types to NSString, and when calling them, insert calls to StringToNSString/NSStringToString to perform the bridging conversion.

This isn't quite ready for prime-time yet, because we still need to emit the inverse bridging for ObjC method thunks, and I haven't tested the IRGen end of things yet.

Swift SVN r5355
2013-05-26 20:29:09 +00:00
Chris Lattner
8c85a49d2a with the groundwork out of the way, we can now namebind types referenced
by the SIL parser.  Add a test that covers both local types, and types
that require looking through an import decl (Int, from the stdlib).


Swift SVN r5249
2013-05-21 05:34:24 +00:00
Jordan Rose
6a0609d169 Use .swiftmodule instead of .sm for serialized modules.
We can bikeshed on this later, but for now we can use a very explicit
extension that has no chance of stepping on any existing extension.

Swift SVN r5239
2013-05-20 22:50:40 +00:00
Jordan Rose
476c4d4f48 [serialization] -emit-module: write out input file paths.
Eventually this will include both modules and source files that the
emitted module depends on, but for now it's just going to be used for
testing purposes to forward to normal source loaders.

Swift SVN r5108
2013-05-09 00:19:09 +00:00
Jordan Rose
5e5172fcf3 Add a skeleton for the Serialization library and -emit-module driver action.
WIP, doesn't do anything useful yet.

Swift SVN r5106
2013-05-08 23:29:51 +00:00
Chris Lattner
5b4c31dc94 reland r4968, with a bugfix to avoid breaking the lexer measuring token lengths.
Original message:
SIL Parsing: add plumbing to know when we're parsing a .sil file
Enhance the lexer to lex "sil" as a keyword in sil mode.


Swift SVN r4988
2013-04-30 00:28:37 +00:00
Chris Lattner
aafe3bdbdc revert r4968, it apparently breaks the world. I'll recommit it when I have time to investigate.
Swift SVN r4971
2013-04-29 16:58:43 +00:00
Chris Lattner
b503206bec SIL Parsing: add plumbing to know when we're parsing a .sil file
Enhance the lexer to lex "sil" as a keyword in sil mode.


Swift SVN r4970
2013-04-29 05:42:59 +00:00
Chris Lattner
2144140168 really use SIL IRGen for all recursive compilations as well, this exposes a symbol
redefinition (or linkage type) bug that causes two tests to fail.  I filed 
rdar://13670581 to track this and am plowing forward, since they seem minor.


Swift SVN r4761
2013-04-17 03:46:40 +00:00
Joe Groff
1a8b35d383 REPL: Support -sil-irgen.
Add a 'startElem' option to SILModule::constructSIL so that it can be used with REPL input.

Swift SVN r4519
2013-03-28 18:38:29 +00:00