Commit Graph

1737 Commits

Author SHA1 Message Date
Ted Kremenek
ff5f742c68 Update Swift version to '1.1'. This includes bumping the Swift
ABI version to '2'.

This patch shows that we need to consolidate where we encode
version information in our CMake build; that's for a later patch.

Implements rdar://problem/18238390.

Swift SVN r21850
2014-09-10 20:49: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
Roman Levenstein
97014172b7 [sil-combine] String literal concatenation optimization. Constant-fold concatenation of string literals known at compile-time.
Addresses rdar://17033696.

Swift SVN r21526
2014-08-28 11:33:21 +00:00
Manman Ren
2cb20d4e62 [Mangler] mangle the module where an extension is defined if necessary.
If a method is defined within an extension of a class or struct that is
defined in a different module, we mangle the module where the extension is
defined.

If we define function f in module A, and redefine it again in an extension in
module B, we use different mangling to prevent linking in the wrong
SILFunction.

rdar://18057875


Swift SVN r21488
2014-08-27 19:57:21 +00:00
Dmitri Hrybenko
42b25d939d Update for upstream LLVM changes is MemoryBuffer APIs
Swift SVN r21409
2014-08-22 08:28:03 +00:00
Manman Ren
31dc9957bf [Print QuotedString] print \u{..} instead of \x.
The lexer can't handle "\x08". QuotedString currently is only used in ASTDumper,
SILPrinter and PrettyStackTrace, so changing the print function should not break
other things.

rdar://18020704


Swift SVN r21257
2014-08-18 17:53:20 +00:00
Dmitri Hrybenko
938e7c2676 stdlib: introduce UnicodeScalarLiteralConvertible protocol
This allows UnicodeScalars to be constructed from an integer, rather
then from a string.  Not only this avoids an unnecessary memory
allocation (!) when creating a UnicodeScalar, this also allows the
compiler to statically check that the string contains a single scalar
value (in the same way the compiler checks that Character contains only
a single extended grapheme cluster).

rdar://17966622

Swift SVN r21198
2014-08-14 16:04:39 +00:00
Joe Groff
fb4fe43e3b Handle '?' as an operator character in mangling.
Alphabetize it like the other operator characters are mangled.

Swift SVN r21062
2014-08-06 05:27:29 +00:00
Jordan Rose
43cbe397fb Fix SourceManager::closeVirtualFile when the end loc is the buffer end.
Previously it crashed; now it (correctly) does nothing.

<rdar://problem/17887975>

Swift SVN r20921
2014-08-01 21:56:19 +00:00
Connor Wakamo
a69eb17411 [json] Added a basic JSON serialization class in swiftBasic.
The swift::json namespace now contains an Output class, which largely mirrors
llvm::yaml::Output. It takes the same approach where there are various traits
structs which dictate how a particular type is output in JSON. (This is separate
from llvm::yaml because, while all JSON is valid YAML, not all YAML is valid
JSON, and customization on how scalar types are output as JSON is necessary.)

Unlike llvm::yaml, there is no equivalent Input class. Since JSON is valid YAML,
llvm::yaml::Input can be used instead.

At some point, the traits structs could likely be merged with llvm::yaml (with
some ability to customize how scalars are output if it's outputting JSON instead
of YAML), but this provides enough of a starting point to allow the driver to
generate parseable output in JSON format.

Part of <rdar://problem/15958329>.

Swift SVN r20870
2014-08-01 01:15:35 +00:00
Connor Wakamo
93f7f2ad43 [driver] Fixed a bug in DummyTaskQueue where it would not generate unique ProcessIds.
Since DummyTaskQueue does not actually execute, it keeps a counter of
ProcessIds. This previously was a local variable; it is now static since
multiple instances of DummyTaskQueue may be used, depending on the requested
commands.

No tests for this yet, but this will be required to properly test parseable
output.

Swift SVN r20849
2014-07-31 21:19:57 +00:00
John McCall
584795e505 Replace the typeOf value witness with an
initializeBufferWithTakeOfBuffer value witness.

Attempt to use initializeBufferWithTakeOfBuffer in
some appropriate places.

There are some changes enabled by this which are
coming in a follow-up patch.

Swift SVN r20741
2014-07-30 08:24:12 +00:00
Jordan Rose
0b933acfda [ClangImporter] Use #line when reporting module build errors.
...or at least the same machinery as #line. We add a (referential) mirror
of the Clang buffer to Swift's source manager, then remap that particular
line to whatever Clang currently thinks is the presumed location for that
line. (This means we respect Clang line directives too.)

This also modifies Swift's source manager to be more forgiving about adding
the same virtual file range twice; it will tell you when you try to do it.

<rdar://problem/16596800>

Swift SVN r20572
2014-07-25 23:01:45 +00:00
Jordan Rose
29f8c25d63 Move #line state into the Parser and out of the SourceManager.
As part of this change, allow #line directives to extend to the end of the
file, rather than requiring a reset.

Note that #line regions that start or end within function bodies will not
behave correctly when in delayed parsing modes. This was true before and
after this commit. (#line regions contained entirely within a function and
not within any other #line regions should be fine.)

Swift SVN r20571
2014-07-25 23:01:43 +00:00
John McCall
1ae1f750d0 Move most type metadata lookups into their own readnone
functions, and make those functions memoize the result.

This memoization can be both threadsafe and extremely
fast because of the memory ordering rules of the platforms
we're targeting: x86 is very permissive, and ARM has a
very convenient address-dependence rule which happens to
exactly match the semantics we need.

Swift SVN r20381
2014-07-23 07:38:26 +00:00
Dmitri Hrybenko
df21376444 Punycode: implement a UTF-8 encoder for use in demangler
Swift SVN r20311
2014-07-22 15:37:45 +00:00
Dmitri Hrybenko
e7b4e6c370 Punycode encoder/decoder: separate core and parts that depend on UTF8
encoder/decoder


Swift SVN r20309
2014-07-22 15:01:12 +00:00
Dmitri Hrybenko
734c0a9ba1 Revert "Punycode encoder/decoder: separate core and parts that depend on UTF8"
It broke tests.

Swift SVN r20308
2014-07-22 14:44:20 +00:00
Dmitri Hrybenko
56342b0cfa Punycode encoder/decoder: separate core and parts that depend on UTF8
encoder/decoder


Swift SVN r20307
2014-07-22 14:37:37 +00:00
Dmitri Hrybenko
f24f98b05f Demangler: remove dependencies on llvm::raw_ostream and swift::QuotedString
Swift SVN r20305
2014-07-22 12:59:00 +00:00
Enrico Granata
d8e4b2c468 The Demangler should only use one currency to vend nodes externally, as it makes clients' lives much much easier - I am specifically thinking LLDB here, since the debugger likes to store nodes it gets out of the demangler as it generates types out of them. Since we are storing everything as a shared_ptr<Node>, having some accessors return Node* and some NodePointer is really not buying us much. Fix things here
Swift SVN r20268
2014-07-21 19:05:32 +00:00
Dmitri Hrybenko
d0823e5e59 Demangler: simplify code
Swift SVN r20264
2014-07-21 17:42:07 +00:00
Dmitri Hrybenko
bd92c01f69 Demangler: print fatal errors to stderr
Swift SVN r20263
2014-07-21 17:42:02 +00:00
Dmitri Hrybenko
23ed1c0b40 Demangler: remove dependency on SmallString
Swift SVN r20256
2014-07-21 15:49:55 +00:00
Chris Lattner
bc481f0fe1 implement <rdar://problem/16859927> remove the underscore in "auto_closure"
autoclosure is one work, not two.



Swift SVN r20253
2014-07-21 15:23:50 +00:00
Dmitri Hrybenko
e33bb4c8de Demangler: remove SmallVector from punycode encoder and decoder interface
Swift SVN r20250
2014-07-21 14:37:16 +00:00
Dmitri Hrybenko
26277fc41d Demangler: remove StringRef dependencies in the demangler interface and
PrettyStackTrace dependencies in the implementation


Swift SVN r20248
2014-07-21 12:46:58 +00:00
Dmitri Hrybenko
18c5b7325e Demangler: remove dependency on swift::Optional
Not strictly required, but we are going to make the demangler self-contained
C++11 code for the benefit of users out of the compiler tree.


Swift SVN r20247
2014-07-21 09:23:09 +00:00
Dmitri Hrybenko
96e2e8d50c Demangler: replace llvm::SmallVector with std::vector
Swift SVN r20095
2014-07-17 16:09:42 +00:00
Dmitri Hrybenko
70e0577767 Demangler: replace LLVM reference counting with std::shared_ptr (which is not
actually necessary here, since all tree nodes could be just allocated from a
single pool)

Steps towards rdar://16929868


Swift SVN r20090
2014-07-17 15:35:29 +00:00
Joe Groff
a14a94942d SILGen: Give dynamic thunks a proper mangling.
This lets us make them 'shared' and teach the demangler about them.

Swift SVN r19945
2014-07-14 21:01:45 +00:00
Chris Lattner
8991456ff2 Switch infix/postfix/prefix to be declaration modifiers instead of attributes,
eliminating the @'s from them when used on func's.  This is progress towards
<rdar://problem/17527000> change operator declarations from "operator prefix" to "prefix operator" & make operator a keyword

This also consolidates rejection of custom operator definitions into one
place and makes it consistent, and adds postfix "?" to the list of rejected
operators.

This also changes the demangler to demangle weak/inout/postfix and related things
without the @.



Swift SVN r19929
2014-07-14 15:51:49 +00:00
Jordan Rose
c99b417a59 [ClangImporter] Handle underscore-punctuated enum names (used by CoreMedia).
<rdar://problem/17594425>

Swift SVN r19732
2014-07-09 18:44:43 +00:00
Chris Lattner
02999cac51 Reinstate the @ on the @objc attribute. This is largely a revert of r19555 with a few tweaks.
Swift SVN r19706
2014-07-08 21:50:34 +00:00
Dmitri Hrybenko
b9b7121d5c More updates for '0' being new invalid buffer ID
Swift SVN r19610
2014-07-07 14:57:24 +00:00
Chris Lattner
67aeb2e7c0 adjust to mainline API change (IntrusiveRefCntPtr::getPtr() renamed to get())
Swift SVN r19605
2014-07-07 14:37:16 +00:00
Chris Lattner
7a56499d61 Start making @objc not start with an @ sign:
- Change the parser to accept "objc" without an @ sign as a contextual
   keyword, including the dance to handle the general parenthesized case.
 - Update all comments to refer to "objc" instead of "@objc".
 - Update all diagnostics accordingly.
 - Update all tests that fail due to the diagnostics change.
 - Switch the stdlib to use the new syntax.

This does not switch all tests to use the new syntax, nor does it warn about
the old syntax yet.  That will be forthcoming.  Also, this needs a bit of 
refactoring, which will be coming up.



Swift SVN r19555
2014-07-04 05:57:57 +00:00
Argyrios Kyrtzidis
e64821d268 [IDE] Search all comments for 'FIXME:', 'TODO:', 'MARK:' and report them in the syntax model.
Swift SVN r19423
2014-07-01 19:21:16 +00:00
Adrian Prantl
400f1774e9 Add support for a #line directive.
This patch extends the syntax with a new #line directive that is inspired
by the homonymous CPP directive. It can be specified in all locations a #if
is legal (Stmt, Decl).

Semantics
---------

#line 42 "file.swift"
This makes diagnostics and debug information behave as if the subsequent
lines came from file.swift+42.

#line // without arguments
This switches back to the main source file and the switches back to the
normal line numbering. Any previous #line directives will result in gaps
in the main file.

Rationale
---------

LLDB and the REPL need this for making expressions that are entered into
the expression evaluator or REPL debugable. For more info see
<rdar://problem/17441710> Need #line directive or something similar so we can enhance the debugging of expressions and REPL

Also, I believe the stdlib would benefit from this and it would allow us
to get rid of the line-directive wrapper script.

Swift SVN r19384
2014-06-30 23:50:11 +00:00
Dmitri Hrybenko
4814e00fda stdlib/String: implement Unicode extended grapheme cluster segmentation
algorithm

The implementation uses a specialized trie that has not been tuned to the table
data.  I tried guessing parameter values that should work well, but did not do
any performance measurements.

There is no efficient way to initialize arrays with static data in Swift.  The
required tables are being generated as C++ code in the runtime library.

rdar://16013860


Swift SVN r19340
2014-06-30 14:38:53 +00:00
Doug Gregor
12ad12f1b4 Teach the demangler to print implicitly unwrapped optional sugar.
Just a drive-by noticed while doing dictionary type sugar.


Swift SVN r19257
2014-06-26 21:47:44 +00:00
Doug Gregor
6df8f63913 Teach the demangler to print dictionary type sugar
Swift SVN r19256
2014-06-26 21:43:12 +00:00
Doug Gregor
6a47e4de22 Use type-simple to decide whether to parenthesize a type in the demangler.
Swift SVN r19225
2014-06-26 06:30:26 +00:00
Doug Gregor
acadc936b3 Teach the demangler to print array types as [T] rather than T[]
Swift SVN r19196
2014-06-26 00:03:15 +00:00
Enrico Granata
dd8a5a0063 ImplicitlyUnwrappedOptional is an enum, not a struct. Fix the demangling
Swift SVN r19171
2014-06-25 18:07:24 +00:00
Jordan Rose
574054b8fd Distance SourceManager from llvm::SourceMgr.
...in preparation for non-source locations, i.e. locations that don't come
frome source buffers.

No functionality change, but a fair bit of SourceManager API and idioms have
changed.

Swift SVN r18942
2014-06-17 01:15:47 +00:00
Dmitri Hrybenko
2195fce1b3 Remove unneeded call to handle_gyb_sources() as suggested by Dave in review of
r18928


Swift SVN r18929
2014-06-16 14:43:42 +00:00
Dmitri Hrybenko
7704e19b7d libBasic: implement extended grapheme cluster segmentation algorithm
This is only for the frontend, not for stdlib.  The implementation is very
slow, optimizing it is the next step.

rdar://16755123 rdar://16013860


Swift SVN r18928
2014-06-16 14:20:43 +00:00
Mark Lacey
cd00cfbf8f Fix some build warnings.
DEBUG_TYPE should be defined before the inclusion of LLVM's Support/Debug.h.

Swift SVN r18640
2014-05-26 20:17:54 +00:00
Joe Groff
0de9be20c4 Remove dead function.
Swift SVN r17777
2014-05-09 15:26:58 +00:00