Commit Graph

6605 Commits

Author SHA1 Message Date
Dmitri Hrybenko
e4b44a6bbb Add a 'current module' parameter to lookupVisibleDecls() so that it can do what
is documented: look up members of a type that are visible from a specific
module.  It does not matter much now, but when we have access control, it will.

Before this change, lookupVisibleDecls() tried to guess the *defining* module
of the type, and gave up if it could not.  It forced us to duplicate some
lookup logic for some types (archetypes and protocol compositions).  Also add a
test that lookup finds members of archetype's superclass, which the original
(duplicated) code did not handle.


Swift SVN r6363
2013-07-18 23:32:16 +00:00
Jordan Rose
9156e805f5 Don't crash when looking for imports in a loaded module.
At some point this will change because of re-exported modules, but for now
just don't crash when performing unqualified lookup on a loaded module.

Also, auto-load our adapter libraries for loaded modules, not just TUs.
Include "POSIX" in this list. (We really need autolinking.)

Swift SVN r6303
2013-07-16 23:10:49 +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
Joe Groff
b9aca28a27 REPL: Outdent 'case' labels on entry.
Swift SVN r6165
2013-07-11 18:32:28 +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
e62a251701 Move PrintingDiagnosticConsumer to libFrontend so that it can be resued in
swift-ide-test.


Swift SVN r6120
2013-07-10 18:20:41 +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
2a4dfc1d00 Rename swift-index-test -> swift-ide-test per Doug's suggestion
Swift SVN r6042
2013-07-06 00:52:11 +00:00
Dmitri Hrybenko
08dc2c8d84 Add a makefile for swift-index-test
Swift SVN r6037
2013-07-06 00:35:33 +00:00
Joe Groff
aa19b4297e frontend: Perform capture analysis before SILGen in -i mode.
Doing it after SILGen is useless, and worse, it causes -i to act on different IR from -emit- modes, making debugging harder.

Swift SVN r6002
2013-07-05 06:25:52 +00:00
Adrian Prantl
17827e9121 Disable debug information by default when in REPL mode.
Swift SVN r5981
2013-07-03 23:15:03 +00:00
Dmitri Hrybenko
3bc4e26a01 Add a (currently empty) swift-index-test utility
Swift SVN r5979
2013-07-03 22:43:08 +00:00
Dmitri Hrybenko
7e466d8961 Rename HAVE_MODULES_SDK to HAVE_DARWIN_MODULES_SDK
Swift requires a modules SDK on Darwin for ObjectiveC and Foundation modules.
On other OSes these modules don't exist.  New name makes it clear that it
guards the darwin-specific stuff.


Swift SVN r5976
2013-07-03 21:16:43 +00:00
Dmitri Hrybenko
70246e8b89 Move swift::buildSingleTranslationUnit to a new library, libFrontend
It should be split and/or generalized in order to become reusable.


Swift SVN r5974
2013-07-03 20:50:21 +00:00
Doug Gregor
90ddbfd46a Complain if we can't dlopen() a library in immediate mode
Swift SVN r5970
2013-07-03 17:16:11 +00:00
Dave Abrahams
096ffc6eaf Silence warnings in the release build
Swift SVN r5950
2013-07-01 21:42:16 +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
e64e30542d more minor cleanups, no functionality change.
Swift SVN r5905
2013-06-30 18:29:21 +00:00
Chris Lattner
51975715df clean up the top level parser loop a bit: there are two scenarios here
that were (incorrectly) folded on top of each other: 1) multiple file mode,
and 2) parser pumping mode.  These modes were incompatible with each other
(and don't make sense together) so have the compiler reject attempts to make
use of them, and detangle the two cases from each other so that the flow is
more clear.



Swift SVN r5904
2013-06-30 18:25:47 +00:00
Chris Lattner
1c0a1c4953 Every client that does type checking also does name binding. Doug wants to pull the later into
the former anyway, so simplify the clients by not exposing name binding to them.


Swift SVN r5903
2013-06-30 18:05:21 +00:00
Dmitri Hrybenko
2d9233862a Splitting the standard library: rename swift_stdlib.dylib ->
swift_stdlib_core.dylib according to the directory name.


Swift SVN r5881
2013-06-28 21:47:12 +00:00
Dmitri Hrybenko
c103a6122f Use multiple argument form of sys::path::append()
Swift SVN r5870
2013-06-28 17:17:38 +00:00
Dmitri Hrybenko
cb8a9f9954 Fix handling of unmatched right parens in the REPL
Fixes rdar://14247238 Interpreter hangs and consumes memory on an unmatched right paren


Swift SVN r5849
2013-06-27 22:32:07 +00:00
Dmitri Hrybenko
27abcf4311 Don't use PathV1.h in swift! It is gone in LLVM now.
Swift SVN r5816
2013-06-26 18:02:20 +00:00
Chris Lattner
27009ac5bd rework handling of -parse-stdlib to make it orthogonal from the mode we're in,
with the specific goal of making it work with -i.


Swift SVN r5807
2013-06-26 04:17:56 +00:00
Chris Lattner
1040bfec6a In the REPL, allow access to the Builtin module if explicitly imported,
there is no reason to deny it and it could be theoretically useful.


Swift SVN r5779
2013-06-24 16:07:56 +00:00
Chris Lattner
95163ff152 introduce a new TranslationUnit kind for .sil files, and use this to
guard access to the Builtin module (on one path), reducing the number
of ways non-stdlib and non-sil files have access to the builtin module.


Swift SVN r5767
2013-06-22 17:14:18 +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
Chris Lattner
ae2053b411 rename TU_Kind -> TUKind
Swift SVN r5741
2013-06-21 17:47:28 +00:00
Chris Lattner
e8bf1dd6f5 expand the TranslationUnit kind to handle "standard library", and
plumb it through the compiler a bit.  This simplifies some code
in the driver, but should not induce any behavior change (yet).


Swift SVN r5740
2013-06-21 17:42:37 +00:00
Chris Lattner
a5c7c65ee7 Move around the logic for handling autoimport of the swift standard
library.  We use the same (somewhat broken heuristics), they are
just implemented in another way.

The major functionality change is that previously, .sil files would
auto import "swift" if they started with a non-sil decl.  Now they
never do.



Swift SVN r5731
2013-06-20 23:39:27 +00:00
Dmitri Hrybenko
044d40fd2d Fix the build after Clang r183989: now clangDriver depends on LLVMOption.
Swift SVN r5592
2013-06-15 02:28:06 +00:00
Dmitri Hrybenko
f7cc014820 Explicitly include PathV1.h where it is used
Swift SVN r5577
2013-06-13 22:16:30 +00:00
Doug Gregor
720cb9348d LLVM's PathV2.h has become Path.h. Update includes appropriately
Swift SVN r5574
2013-06-13 14:53:52 +00:00
Ted Kremenek
f00baafc27 Add serialized diagnostic support for FixIts and Notes.
Still testing, but c-index-test results look good and I will
add test cases shortly.

Swift SVN r5536
2013-06-08 00:57:48 +00:00
Ted Kremenek
09b4b95748 Get serialized diagnostics breathing.
Still validating, then will add tests.

$ cat test.swift
This is invalid code.

$ swift -serialize-diagnostics test.dia test.swift
test.swift:1:1: error: expected expression
This is invalid code.
^
test.swift:1:21: error: postfix '.' is reserved
This is invalid code.
                    ^
test.swift:1:22: warning: missing newline at end of file
This is invalid code.
                     ^

$ llvm-bcanalyzer -dump test.dia
<BLOCKINFO_BLOCK/>
<Meta NumWords=2 BlockCodeSize=3>
  <Version abbrevid=4 op0=1/>
</Meta>
<Diag NumWords=18 BlockCodeSize=4>
  <FileName abbrevid=8 op0=1 op1=0 op2=0 op3=10/> blob data = 'test.swift'
  <DiagInfo abbrevid=4 op0=3 op1=1 op2=1 op3=1 op4=0 op5=0 op6=0 op7=19/> blob data = 'expected expression'
</Diag>
<Diag NumWords=19 BlockCodeSize=4>
  <FileName abbrevid=8 op0=2 op1=0 op2=0 op3=10/> blob data = 'test.swift'
  <DiagInfo abbrevid=4 op0=3 op1=2 op2=1 op3=21 op4=0 op5=0 op6=0 op7=23/> blob data = 'postfix '.' is reserved'
</Diag>
<Diag NumWords=21 BlockCodeSize=4>
  <FileName abbrevid=8 op0=3 op1=0 op2=0 op3=10/> blob data = 'test.swift'
  <DiagInfo abbrevid=4 op0=2 op1=3 op2=1 op3=22 op4=0 op5=0 op6=0 op7=30/> blob data = 'missing newline at end of file'
</Diag>


Summary of test.dia:
         Total size: 3808b/476.00B/119W
        Stream type: unknown
  # Toplevel Blocks: 5
...

$ c-index-test -read-diagnostics test.dia
test.swift:1:1: error: expected expression [] []
Number FIXITs = 0
test.swift:1:21: error: postfix '.' is reserved [] []
Number FIXITs = 0
test.swift:1:22: warning: missing newline at end of file [] []
Number FIXITs = 0
Number of diagnostics: 3

Swift SVN r5515
2013-06-07 19:41:38 +00:00
Ted Kremenek
51c239e01d Hack-and-slash porting parts of Clang's serialized diagnostic printer over to Swift.
This is still total WIP.  There's a bunch of copy-paste, both from other
parts of Swift and Clang.  I want to see the end-to-end vision
first and then refactor.  There's a bunch of subtle changes between
Clang's diagnostics and Swift's that require some care to handle,
as the serialized diagnostics were developed with Clang's in mind.
That should be fine, since Clang' will be more complicated, but the
differences are still there to be dealt with.

It's not clear if we will need the SharedState, as we do with Clang.
We'll keep it now since it isn't doing any harm.

Swift SVN r5507
2013-06-07 06:33:39 +00:00
Ted Kremenek
63fdb43a04 Wire up driver support for -serialized-diagnostics and make the consumer implementation private.
Swift SVN r5506
2013-06-07 05:17:03 +00:00
Ted Kremenek
b4ef714588 Update stale comment.
Swift SVN r5503
2013-06-06 22:41:46 +00:00
Ted Kremenek
746cbd6195 Start wiring up boilerplate for serialized diagnostics.
This does absolutely nothing yet.

Serialized diagnostics provide a binary format that can be
read by libclang, and used to import diagnostics into clients
such as Xcode.

Swift SVN r5501
2013-06-06 22:27:15 +00:00
Joe Groff
49dfa58f37 REPL: Create a new MemoryBuffer for each input.
Instead of reusing a fixed-size buffer, which causes problems when error messages refer back to previous inputs and corrupts AST references in *LiteralExpr that point back into source buffers, allocate each REPL input into its own buffer with its own SourceMgr entry. Fixes <rdar://problem/13387167>, crashes when using :dump_ast on expressions containing integer/float literal expr nodes, and hopefully sporadic buildbot failures running the Interpreter/repl test.

Swift SVN r5470
2013-06-04 18:02:44 +00:00
Doug Gregor
17e788e04f Open literal types as binding types, to provide [] sugar for arrays.
Swift SVN r5436
2013-06-03 19:43:02 +00:00
Joe Groff
ccc28d3253 Add some more DEBUG() noise to -i mode.
Dump the module IR just prior to instantiating the execution engine, and log the start of module initializers, static constructors, and main().

Swift SVN r5430
2013-06-01 00:40:38 +00:00
Doug Gregor
c038ab92e6 Remove -no-constraint-checker/-constraint-checker and the corresponding language option.
Swift SVN r5387
2013-05-29 22:16:34 +00:00
Jordan Rose
878cc5f0e1 Hack: ignore loaded modules in immediate mode SILGen/IRGen.
This matches the behavior for compilation, and lets us test modules that
don't need any extra codegen.

With this, typealiases of builtins can be used end-to-end in modules!

Swift SVN r5326
2013-05-25 01:34:59 +00:00
Chris Lattner
f2e3af3cf6 Eliminate the "global" list of unresolved identifier types maintained
by TranslationUnit.  This list existed solely to allow name lookup of
an unbound IdentifierType to know its DeclContext.  Instead of indirecting
through this list, just store the DeclContext in the IdentifierType in its
uninitialized state.

This eliminates a really terrible performance fixme about scanning the list,
eliminates the management fiddling around with this list in the parser, and
is generally much cleaner.


Swift SVN r5246
2013-05-21 05:27:37 +00:00
Doug Gregor
dbdc9db90a Keep track of the extensions associated with a nominal type declaration.
Switch the REPL's printing of extensions to use this mechanism, mostly
as a sanity check.



Swift SVN r5221
2013-05-20 15:23:16 +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
Jordan Rose
77ce3f31cb Add a DeclContextKind for Swift modules.
Swift SVN r5095
2013-05-08 18:33:34 +00:00
Jordan Rose
ccae995f61 Use a list of module loaders instead of a single Clang importer.
This paves the way for having a Swift module importer. The eventual goal
here is to eliminate all explicit uses of the Clang module loader, but
I'm not going to push too hard on that for now.

Swift SVN r5092
2013-05-08 18:09:33 +00:00