Commit Graph

1737 Commits

Author SHA1 Message Date
Ted Kremenek
ea80d0473d Fix unreachable code warning by tightening code. No functionality change.
Swift SVN r14055
2014-02-18 22:26:58 +00:00
Dmitri Hrybenko
ecd798b9fd Comment parsing: attaching comments to declarations
We can attach comments to declarations.  Right now we only support comments
that precede the declarations (trailing comments will be supported later).

The implementation approach is different from one we have in Clang.  In Swift
the Lexer attaches the comments to the next token, and parser checks if
comments are present on the first token of the declaration.  This is much
cleaner, and faster than Clang's approach (where we perform a binary search on
source locations and do ad-hoc fixups afterwards).

The comment <-> decl correspondence is modeled as "virtual" attributes that can
not be spelled in the source.  These attributes are not serialized at the
moment -- this will be implemented later.


Swift SVN r14031
2014-02-18 09:04:37 +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
Joe Groff
1bbbcaaf98 Consider @auto_closure when mangling types.
We allow overloads on foo(() -> T) and foo(@auto_closure () -> T) in Sema, so they need distinct manglings. Fixes <rdar://problem/16045566>.

Swift SVN r13856
2014-02-13 03:02:22 +00:00
Joe Groff
bb42bf6617 Demangle dependent types.
Implement the demangling for generic signatures and their requirements, dependent parameters, and member types, now that we actually use these manglings when naming reabstraction thunks.

Swift SVN r13764
2014-02-10 23:37:15 +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
Argyrios Kyrtzidis
778c6cbe37 [Driver] When printing out the version also print out the submission version.
Swift SVN r13756
2014-02-10 19:10:01 +00:00
Connor Wakamo
b7d4e98f70 [driver] Added support for detecting and reporting crashed subprocesses.
Added a TaskSignalledCallback to TaskQueue, which will be called instead of
TaskFinishedCallback if the task exited abnormally.

In Unix/TaskQueue.inc, check WIFSIGNALED if the task did not pass WIFEXITED,
and call the TaskSignalledCallback if necessary. In Default/TaskQueue.inc, check
for a return code of -2; if present, call the TaskSignalledCallback instead of
the TaskFinishedCallback.

Updated Compilation to pass a TaskSignalledCallback.

Added diagnostics to indicate when a command signalled as well as when a command
failed with either poor diagnostics or a non-1 exit code. (These match Clang’s
diagnostics.) Added tests to ensure these diagnostics are emitted when the
frontend crashes or fails an assertion (if assertions are available).

This fixes <rdar://problem/16012199>.

Swift SVN r13654
2014-02-07 22:03:33 +00:00
Joe Groff
6c4136103c Demangle: Demangle specializations.
This time, be sure to reset the demangler state after demangling the
specialization header, because it is a prefix of the demangled symbol
name.

Swift SVN r13378
2014-02-03 22:48:07 +00:00
Joe Groff
f782eeac30 Revert "Demangle: Demangle specializations" until I figure out an assertion failure.
Swift SVN r13376
2014-02-03 22:19:03 +00:00
Joe Groff
0837a32675 Demangle: Demangle specializations.
Swift SVN r13368
2014-02-03 21:17:18 +00:00
Dmitri Hrybenko
4efcbfe47c QuotedString: 'G' is not a hexadecimal digit
Swift SVN r13354
2014-02-03 15:58:17 +00:00
Doug Gregor
cd02337caf Update Demangler to support DynamicSelf
Swift SVN r13297
2014-02-01 06:52:43 +00:00
Greg Parker
b2846b546b Make Int a word-size type.
- Int and UInt are now struct types backed by Builtin.Word. Previously they
were typealiases for Int64; Int and Int64 are now distinct types.
- Mangled names 'i' and 'u' are now Int and UInt. Int64 is mangled longhand.
- Word is a typealias for Int. It is expected to go away in the future.
- Builtin.Word is unchanged.
- CLong and CUnsignedLong are typealiases for Int and UInt.
- FixedPoint.swift is now FixedPoint32.swift and FixedPoint64.swift. 
Reunifying these requires better builtins, especially for checked 
conversions (rdar://15472770).
- Updated many tests, mostly because Int is no longer spelled Int64 in sil.
- One check was removed from test decl/operator/operators.swift 
because it changed behavior when Int became a non-typealias 
type (rdar://15934688).



Swift SVN r13109
2014-01-29 12:21:19 +00:00
John McCall
af032e9300 Demangle the new protocol witness thunk mangling.
Remove the documentation and demangling for the old one.

rdar://15842093

Swift SVN r13066
2014-01-28 22:19:01 +00:00
Chris Lattner
d407bc8fc4 Teach the parser to add the didSet/willSet functions to the enclosing
type, so we emit them.  Add mangler (and demangler) support for these.
Enhance our testcase to check to make sure that stores within these
specifiers are direct, they don't cause recursive infinite loops.

John, I picked w/W for the mangling letters, let me know if this is ok.


Swift SVN r13050
2014-01-28 05:15:56 +00:00
Connor Wakamo
cec27abeb8 Adjust ExecuteInPlace() so that it calls exit() on success on platforms where native re-execution is not implemented.
Swift SVN r12606
2014-01-20 19:26:49 +00:00
Connor Wakamo
ab2172cc97 [driver] Added support for executing a single Command without a TaskQueue.
Added swift::ExecuteInPlace(), which on Unix acts as a wrapper for execv()
and execve(). On other platforms, swift::ExecuteInPlace() is a wrapper for
llvm::sys::ExecuteAndWait(), so callers must be prepared for ExecuteInPlace()
to return in a non-error situation.

Added support in Compilation::performJobs() to detect that the Compilation has
exactly one Command to run. If that's the case, and buffered output isn't
required, execute that Command using swift::ExecuteInPlace() (instead of
creating a TaskQueue, which may unconditionally buffer output).

This change will allow the driver to invoke the frontend's REPL and immediate
modes without buffering output (and, on Unix, without a separate process being
spawned).

Also updated test/Driver/basic.swift to emit output with these changes in place.

Swift SVN r12544
2014-01-18 20:55:18 +00:00
Connor Wakamo
b7aec0e72c [driver] Added a DummyTaskQueue class, which calls TaskBeganCallback/TaskFinishedCallback but does not actually execute subtasks.
While this is not yet used, Compilation will be able to adopt this for easier testing of driver-level task execution (instead of forcing all driver-level tests to invoke the frontend, linker, etc.).

Swift SVN r12349
2014-01-15 21:27:55 +00:00
Connor Wakamo
dd9614e80c [driver] Add TaskQueue::getNumberOfParallelTasks().
For the Unix implementation, this returns NumberOfParallelTasks (unless that value is 0, in which case it returns the default value of 1).
For the Default implementation, this always returns 1, since it does not support parallelism.

Swift SVN r12348
2014-01-15 21:27:50 +00:00
Connor Wakamo
cc00fd1048 [driver] Rework the Unix implementation of TaskQueue::execute() to support reading from pipes as they fill, instead of all at once at the end.
Instead of always calling waitpid() and looking for the termination of a task, call poll() and watch for events on the pipes which are used for buffering subtask output. When we receive a POLLIN or POLLPRI event, ask the corresponding Task to read from the pipe; when we receive a POLLHUP or POLLERR event, wait for the subtask to finish and then ask the Task to perform its post-execution tasks.

Now that the Unix implementation properly handles large amounts of subtask output, re-enable the Unix implementation (if supported).

This fixes <rdar://problem/15795234>.

Swift SVN r12293
2014-01-14 20:39:23 +00:00
John McCall
817e80bde5 Implicit conversions for UncheckedOptional.
rdar://15189000
rdar://15189009

Swift SVN r12260
2014-01-13 23:15:03 +00:00
Doug Gregor
fc7dfb2fae Start emitting .cxx_construct methods for Objective-C-derived classes.
When we're using Objective-C's memory allocation, emit .cxx_construct
methods whenever we have instance variables with in-class
initializers. Presently, these methods are just empty stubs.

Swift SVN r12211
2014-01-12 04:31:52 +00:00
Doug Gregor
3524a79fa0 Emit .cxx_destruct for destruction of ivars in Objective-C-derived classes.
The Objective-C runtime executes the .cxx_destruct method after the
last -dealloc has executed when destroying an object, allowing the
instance variables to remain live even after the subclass's
destructor/-dealloc has executed, which is important for memory
safety. This fixes the majority of <rdar://problem/15136592>.

Note that IRGenModule::getAddrOfIVarDestroyer() contains  an egregious
hack to find the ivar destructor SIL function via a linear
search. We need a better way to find SIL functions that we know exist,
because LinkEntity does not suffice.

Swift SVN r12206
2014-01-12 00:17:42 +00:00
Connor Wakamo
aec43d811a [driver] Disable the Unix implementation of TaskQueue.
The current implementation does not read() from each Task's pipe until execution
finishes. This causes subtasks to block in write() if the pipe is full, which
only happens if there is a large amount of output (such as in -dump-ast mode).

Fixing output buffering and reenabling the Unix TaskQueue implementation is
tracked by <rdar://problem/15795234>.

Swift SVN r12135
2014-01-10 21:56:18 +00:00
Connor Wakamo
ed061a5bfa [driver] Introduced a new TaskQueue class for parallel execution and output buffering.
Due to the nature of this class, there are two implementations of TaskQueue:
a Unix-specific implementation which supports both parallel execution and output
buffering, and a default implementation which supports neither of these features.
(The default implementation uses the functions from llvm/Support/Program.h for execution.)

TaskQueue allows clients to provide a TaskBeganCallback and a TaskFinishedCallback,
each of which will be called when a new task begins or when a task finishes execution,
respectively. Clients may add tasks to the TaskQueue in either of these callbacks,
and clients can stop further execution by returning TaskFinishedResponse::StopExecution
from the TaskFinishedCallback.

Swift SVN r12059
2014-01-08 19:10:41 +00:00
John McCall
aa26b55c1e Variable initializer manglings don't have types.
Fixes rdar://15753317

Note that the mangling we're actually generating here is clearly
wrong.

Swift SVN r11943
2014-01-06 20:05:14 +00:00
John McCall
b30ab409df Prettify crashes in the demangler.
Revert "add a hackaround for rdar://15753317.  I don't unerstand the code enough to tell if this is the right fix."

This reverts commit 416983b0734dde6979c98971948068c7a157e336.

Swift SVN r11942
2014-01-06 20:05:12 +00:00
Chris Lattner
31c328bdcf add a hackaround for rdar://15753317. I don't unerstand the code enough to tell if this is the right fix.
Swift SVN r11927
2014-01-06 16:48:13 +00:00
John McCall
deeb98cb1e Fix trivial bug.
Probably should have waited for those tests to run, no matter
how trivial the refactor seemed.

Swift SVN r11903
2014-01-04 09:52:02 +00:00
John McCall
1d2697f176 More random demangling stylings. Probably done here for now. :)
Swift SVN r11902
2014-01-04 09:49:38 +00:00
John McCall
2b99a66204 Rename toString* to print*.
Swift SVN r11901
2014-01-04 09:49:37 +00:00
John McCall
552c3efad6 Unnest NodePointer::toString.
Swift SVN r11900
2014-01-04 09:49:37 +00:00
John McCall
c5d2d972ee Add an x-macro system for demangling nodes and use it to
generate getNodeKindString automatically.

Swift SVN r11899
2014-01-04 09:49:35 +00:00
John McCall
e9e928d509 Remove the last vestiges of the 'L' local-linkage mangling prefix.
Swift SVN r11896
2014-01-04 09:11:16 +00:00
John McCall
4355a21a62 Mangle closures using their context and discriminator.
Swift SVN r11885
2014-01-04 04:37:57 +00:00
John McCall
ad1e198a3a Recognize unmangled suffixes at the end of a mangling.
Swift SVN r11866
2014-01-03 19:39:08 +00:00
John McCall
5df03ce334 Abstract out a utility for printing strings in quotes.
Swift SVN r11865
2014-01-03 19:39:07 +00:00
John McCall
d5b65b2d7f Improve and test the demangling of local declarations.
Swift SVN r11526
2013-12-20 23:20:15 +00:00
John McCall
186c0243f1 Mangle the discriminator into local declaration names.
Swift SVN r11522
2013-12-20 22:50:51 +00:00
John McCall
4b48c8915c Demangle reabstraction thunks (and impl-function-type generally).
Swift SVN r11493
2013-12-20 00:46:56 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
John McCall
8505c4a00d Further refactoring/simplification of the demangler.
Not NFC: changes some of the demangling tree schemata (in
interest of regularity and expressivity) and, incidentally,
improves support for initializer manglings.

The main schema change is that Path is now gone, and instead
the first child of an entity is its context.  All contexts
are now labelled with their kind (variable/function/etc.)
rather than that being much more obscure or missing.

A secondary change is that the top-level node is now a
single node with the <global> and all its attributes as
children, rather than being weirdly sibling-linked.

Also, the representation has changed so that nodes link
only to their children, not to siblings or parents, which
means that it is no longer necessary to clone nodes when
replacing substitutions.

Finally, dump/print was brought in from swift-demangler
and made part of the core API for debugging purposes.

Swift SVN r11470
2013-12-19 08:57:06 +00:00
John McCall
c9aad99674 Further reduce the API surface area and complexity of demangling nodes.
Swift SVN r11469
2013-12-19 08:57:05 +00:00
John McCall
1d8d2d15ed Remove the need for Node::setKind.
Swift SVN r11468
2013-12-19 08:57:04 +00:00
John McCall
1751c6d3e4 Bring the demangler closer to Swift code style. NFC.
Swift SVN r11443
2013-12-18 22:22:15 +00:00
John McCall
c5aa41ffd1 Change around some manglings to make them carry more
information and be easier to demangle.

Swift SVN r11423
2013-12-18 08:33:52 +00:00
Enrico Granata
0109df6ddd This would not affect the display of the demangled type name, but would cause LLDB to fail to retrieve the type, as it went looking for the wrong kind of thing
Swift SVN r10976
2013-12-07 03:24:50 +00:00
Connor Wakamo
ed2038585f Initial set of changes to add a new 'swift_driver' executable.
- Added a couple of new targets:
  - libswiftDriver, which contains most of the driver implementation
  - swift_driver, which produces the actual executable

- Added centralized version information into libswiftBasic.

- Added a new "Driver Design & Internals" document, which currently describes
  the high-level design of the Swift driver.

- Implemented an early version of the functionality of the driver, including
  versions of the Parse, Pipeline, Bind, Translate, and Execute driver stages.
  Parse, Pipeline, and Bind are largely implemented; Translate and Execute are
  early placeholders. (Translate produces "swift_driver --version" and "ld -v"
  commands, while Execute performs all subtasks sequentially, rather than in
  parallel.)

This is just the starting point for the Swift driver. Tests for the existing
behavior are forthcoming.

Swift SVN r10933
2013-12-06 21:23:01 +00:00
Dave Abrahams
7ab9d369aa [stdlib] Rename Char => UnicodeScalar
Swift SVN r10864
2013-12-05 17:30:37 +00:00