Commit Graph

1737 Commits

Author SHA1 Message Date
Bob Wilson
1caba3e209 Merge remote-tracking branch 'origin/master' into master-next 2016-10-17 11:52:21 -07:00
Bob Wilson
3fd92f82e8 Use StringRef in more places to match recent llvm changes.
llvm r283043 and possibly other recent changes switch to use StringRef
instead of char* pointers. Update Swift to match. In some cases, this is
a clear improvement. It would be good to assess the impact on memory use,
particularly for the Filename component of source locations.

Note that the change to SILLocation::isNull fixes an apparent bug where
the location was treated as null when the filename was *not* null.
2016-10-15 11:02:07 -07:00
Mishal Shah
09cbffb3e4 Initialize CachedVFile with nullptr 2016-10-14 15:29:18 -07:00
Bob Wilson
c08a96a880 Update references to UTF* types and functions to match llvm r282822.
The content of LLVM's "Support/ConvertUTF.h" header was moved into the
"llvm" namespace. Update this code to match.
2016-10-13 17:05:51 -07:00
Graydon Hoare
7183f9cc66 Add conversion operator between version::Version and clang::VersionTuple 2016-10-12 11:20:42 -07:00
Michael Ilseman
12fb0bad7b [swift-version] Allow swift-version 4 and tests
The recent @escaping on variadic argument closures back-compat fix is
the first Swift 3.0 compatibility behavior that we don't want to carry
forwards indefinitely into the future. To address this, we
version-gate the diagnostic suppression.

Makes it an official compatibility check. Creates new test directory
for compatibility testing. Allow -swift-version 4 so that we can test
it both ways.
2016-10-11 17:42:25 -07:00
Slava Pestov
ca28cf6488 AST: Remove special mangling for Self archetype of a protocol
With a bit of work, we can re-purpose the existing
QualifiedArchetype mangling to cover this case.

This allows us to get rid of a usage of
ArchetypeType::getSelfProtocol(), which we want to remove.
2016-10-04 03:54:01 -04:00
Graydon Hoare
8970d44675 Add "-swift-version <n>" that sets LangOpts.EffectiveLanguageVersion.
This flag switches the "effective language version" of the compiler,
at least to any version supported (as of this change: "3" or "3.0").

At the moment nothing uses it except the language version build
configuration statements (#if swift(...)) and various other places
that report, encode, or otherwise check version numbers.

In the future, it's intended as scaffolding for backwards compatibility.

Fixes SR-2582
2016-09-20 15:11:37 -07:00
Erik Eckstein
454b91af61 swift-demangle: don't crash on an old pre-swift-2 mangled name
rdar://problem/27248817
2016-09-19 11:49:46 -07:00
Ben Langmuir
04107ed8b2 Revert "[omit-needless-words] Fix a bug found by -Wunused-result" 2016-09-14 14:27:32 -07:00
Ben Langmuir
7562c10333 [omit-needless-words] Fix a bug found by -Wunused-result
StringRef::drop_back() returns the new string; it doesn't mutate `this`.
2016-09-14 13:52:59 -07:00
Michael Gottesman
fa1bb95923 Merge remote-tracking branch 'origin/master' into master-next 2016-08-30 19:50:12 -07:00
Jordan Rose
5ffb151f77 [ClangImporter] Predefine __swift__ in imported (Obj)C code. (#4510)
This macro expands to a numeric value representing the current Swift
language version; for Swift 3.1.2, it would be 30102.

See discussion in https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20160822/002754.html.

rdar://problem/26921435
2016-08-25 18:26:35 -07:00
Abdou Sarr
3735c914a4 Omitted Dream repetition. (#4355)
"VERB(Dream)" was repeated twice on line 268 and 269. So I removed the type on 268.
2016-08-17 12:19:14 -07:00
Michael Gottesman
b3819c6783 [cmake] Rename COMPONENT_DEPENDS to LLVM_COMPONENT_DEPENDS (#4311)
Now that I am going to be adding an IN_SWIFT_COMPONENT argument, I need to do
this to distinguish the concepts of an LLVM_COMPONENT and a SWIFT_COMPONENT.
2016-08-16 12:13:34 -04:00
Doug Gregor
6b1210ed52 [Omit needless words] Add "unload" as a verb, to go with "load".
Fixes rdar://problem/26866251.
2016-08-01 11:25:23 -07:00
Robert Widmann
9c83e7223e Fixup diagnostics around type(of:) and dynamicType handling
Be laxer about the parsing for type(of:) so as not to get in the way of
other declarations that may use ‘type’ as their base name.
2016-07-30 03:24:05 -07:00
David Farler
0ae7766fb4 Handle extension contexts when demangling bound generic arguments
Local generic types can appear inside functions inside extensions
of other types. When demangling bound generic arguments, the demangler
assumed that a module was the only other kind of context outside
of nominal types.

rdar://problem/27573079
2016-07-27 17:39:16 -07:00
Slava Pestov
57c58176bc AST: Remove noreturn bit from function types 2016-07-24 00:15:34 -07:00
Andrew Trick
a41484ea2b Add UnsafeRawPointer type and API. (#3677)
* Add UnsafeRawPointer type and API.

As proposed in SE-0107:   UnsafeRawPointer.
https://github.com/apple/swift-evolution/blob/master/proposals/0107-unsaferawpointer.md

The fundamental difference between Unsafe[Mutable]RawPointer and
Unsafe[Mutable]Pointer<Pointee> is simply that the former is used for "untyped"
memory access, and the later is used for "typed" memory access. Let's refer to
these as "raw pointers" and "typed pointers". Because operations on raw pointers
access untyped memory, the compiler cannot make assumptions about the underlying
type of memory and must be conservative. With operations on typed pointers, the
compiler may make strict assumptions about the type of the underlying memory,
which allows more aggressive optimization.

Memory can only be accessed by a typed pointer when it is currently
bound to the Pointee type. Memory can be bound to type `T` via:
- `UnsafePointer<T>.allocate(capacity: n)`
- `UnsafePointer<Pointee>.withMemoryRebound(to: T.self, capacity: n) {...}`
- `UnsafeMutableRawPointer.initializeMemory(as: T.self, at: i, count: n, to: x)`
- `UnsafeMutableRawPointer.initializeMemory(as: T.self, from: p, count: n)`
- `UnsafeMutableRawPointer.moveInitializeMemory(as: T.self, from: p, count: n)`
- `UnsafeMutableRawPointer.bindMemory(to: T.self, capacity: n)`

Mangle UnsafeRawPointer as predefined substitution 'Sv' for Swift void
pointer ([urp] are taken).

* UnsafeRawPointer minor improvements.

Incorporate Dmitri's feedback.

Properly use a _memmove helper.

Add load/storeBytes alignment precondition checks.

Reword comments.

Demangler tests.

* Fix name mangling test cases.

* Fix bind_memory specialization.
2016-07-22 13:32:08 -07:00
Joe
3938d5682a [SE-0095] [Runtime], [Demangler], & AST printer updated to new composition syntax
- All parts of the compiler now use ‘P1 & P2’ syntax
- The demangler and AST printer wrap the composition in parens if it is
in a metatype lookup
- IRGen mangles compositions differently
    - “protocol<>” is now “swift.Any”
    - “protocol<_TP1P,_TP1Q>” is now “_TP1P&_TP1Q”
- Tests cases are updated and added to test the new syntax and mangling
2016-07-19 12:01:37 -07:00
Mark Lacey
1c00ac4c6d Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	lib/IRGen/IRGen.cpp
	test/DebugInfo/parent-scope.swift
2016-07-15 19:23:53 -07:00
Han Sangjin
cccfbf4d3c [swiftc/msvc] Compiling with MSVC (#1516)
Some modifications for the ms-extension option of the clang.exe in the Visual Studio 2015 development environment

This patch is only for swiftc.exe. I used the library set of Visual Studio 2015 Update 1 and recent version of swift-clang as the compiler. If you are using the real MSVC compiler, more patch might be required.
2016-07-08 19:06:10 -07:00
Jordan Rose
d6a726e6fe SE-0106: Add "macOS" as an alias of "OSX" for #if.
...by canonicalizing it to the known platform name. This isn't a
wonderful answer, but it preserves the invariant that a platform
condition has at most one value.

A later commit will switch which one is the default.
2016-07-07 14:57:57 -07:00
Saleem Abdulrasool
081097e439 Basic: extract the shared find logic
All of the checks here perform the same operation and use a locally defined
static array.  Create a small helper that performs the contains operation.  NFC.
2016-07-03 18:15:44 -07:00
Michael Gottesman
3c603ab18b Merge remote-tracking branch 'origin/master' into master-next 2016-07-01 18:44:21 -07:00
Saleem Abdulrasool
83901998c9 Port for PS4
Add support for the PS4 OS.  Update the standard library and add a target unit
test.
2016-06-30 20:14:50 -07:00
Slava Pestov
d49d054efd Muffle a warning 2016-06-28 17:58:11 -07:00
Saleem Abdulrasool
0cf0786481 Basic: use switch instead of cascading if's
Rather than have a series of cascading if conditionals, use a switch.  Although
Darwin and android are special, they can be handled just as cleanly in the
switch version.  NFC.
2016-06-27 12:02:45 -07:00
Michael Gottesman
8d00a6cb59 Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	stdlib/public/SDK/GameplayKit/CMakeLists.txt
	test/DebugInfo/bound-namealiastype.swift
	test/DebugInfo/structs.swift
	test/IRGen/c_globals.swift
	test/SourceKit/DocSupport/doc_clang_module.swift
	test/SourceKit/Indexing/index_with_clang_module.swift
	utils/update-checkout
2016-06-25 01:13:50 -07:00
Slava Pestov
8ffa51485a AST: Fix mangling for nested generic types
Change the 'G' mangling to include generic parameters from
all levels of nested nominal types, and not just the innermost.

Note that the raw mangling syntax is something like this for
a nested type 'A<Int>.B<String>':

- bound_generic
  - struct 'B'
    - struct 'A'
      - module 'M'
  - args
    - Int
  - args
    - String

However, the actual mangling tree is more along the lines of:

- bound_generic_struct 'B'
  - bound_generic_struct 'A'
    - module 'M'
    - args
      - Int
  - args
    - String

This arrangement improves the quality of substitutions (we are
more likely to have a substitution for the entire unbound
generic type name 'A.B' around), and simplifies a few other
details.

Unfortunately, the remangling logic becomes slightly grotesque.

A simple SILGen test for nested generics exercises the mangling,
and ensures that Sema and SILGen do not crash with nested generics.

More detailed SILGen tests, as well as IRGen support for nested
generics is next.
2016-06-23 00:01:40 -07:00
Dmitri Gribenko
5dd3ce9195 Merge pull request #3020 from modocache/sr-1738-add-swift-library-shared-static-args
[SR-1738] add_swift_library takes SHARED/STATIC arg
2016-06-18 15:38:57 -07:00
Brian Gesiak
328de9e280 [SR-1738] add_swift_library takes SHARED/STATIC arg
As a first step to allowing the build script to build *only*
static library versions of the stdlib, change `add_swift_library`
such that callers must pass in `SHARED`, `STATIC`, or `OBJECT_LIBRARY`.

Ideally, only these flags would be used to determine whether to
build shared, static, or object libraries, but that is not currently
the case -- `add_swift_library` also checks whether the library
`IS_STDLIB` before performing certain additional actions. This will be
cleaned up in a future commit.
2016-06-16 13:15:58 -04:00
Saleem Abdulrasool
c553628964 Use sizeof for buffer lengths in snprintf
Rather than duplicating the constant value, use the `sizeof` operator to have
the value propogate from the static buffer allocation.  Any standards conforming
implementation of `snprintf` will null-terminate the output unless the buffer is
NULL (a zero-sized buffer is passed to the call).  On Windows, where this is not
the case, the function is named `_snprintf` which ensures that we do not
accidentally end up with the incorrect behaviour.
2016-06-15 17:41:16 -07:00
Doug Gregor
5bea187b0f [Omit needless words] Fix lowercasing of initialisms with two-letter initial words.
Fixes rdar://problem/26643039.
2016-06-13 18:15:43 -07:00
Doug Gregor
7b226ad177 [Omit Needless Words] Don't remove a first argument label when the parameter has as default argument.
Parameters that have default arguments should have argument labels;
don't remove them on import. Fixes rdar://problem/26611977.
2016-06-13 11:58:41 -07:00
Doug Gregor
1d39707311 [Omit needless words] Don't split "PlugIn".
Fixes rdar://problem/26334014.
2016-06-12 23:13:01 -07:00
John McCall
6328f3fe0b Explicitly represent "pseudo-generic" functions in SIL, which do
not have access to their type arguments at runtime.  Use this to
fix the emission of native thunks for imported ObjC-generic
initializers, since they may need to perform bridging.

For now, pseudo-genericity is all-or-nothing, but we may want to
make it apply only to certain type arguments.

Also, clean up some code that was using dead mangling nodes.
2016-06-01 11:41:27 -07:00
Bryan Chan
85fde8b1fb Add support for Linux s390x. LLVM's Swift calling convention support is used to ensure correct operations of C++ code in the runtime. This patch also includes some (incomplete) changes to enum handling to make enums work in most common cases. 2016-05-24 20:03:28 -04:00
Bryan Chan
bb3486df93 Add new _endian() platform condition check; valid values are "little" and "big". 2016-05-24 19:39:15 -04:00
David Farler
ca53873226 Don't show private discriminators in simplified demanglings
These are really long and don't tell you anything interesting
in backtraces. They can also take up quite a bit of valuable
real estate in vertical layouts.

rdar://problem/22982415
2016-05-18 15:16:35 -07:00
Chris Lattner
09269d001c mark a function static instead of putting it into an anon namespace,
following llvm style.
2016-05-08 09:50:58 -07:00
Doug Gregor
c390c97255 [Clang importer] Minor fixes for swift_newtype name adjustments. 2016-05-07 14:44:48 -07:00
Mark Lacey
182b6dfb18 Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	tools/driver/CMakeLists.txt
	tools/swift-reflection-dump/swift-reflection-dump.cpp
2016-05-03 14:23:20 -07:00
Ryan Lovelett
0c0bcbb094 Convert "armv7l" to "armv7" for the architecture component of paths (#2369)
On the Raspberry Pi 2 when trying to import Glibc, without this patch, it will attempt to
find the module map at "/usr/lib/swift/linux/armv7l/glibc.modulemap" and
fail to do so.

With this patch it will attempt to find the module map at
"/usr/lib/swift/linux/armv7/glibc.modulemap" where it will succeed in
finding the module map.

Similar behavior currently happens in the Driver and Frontend. To DRY up
this behavior it has been extracted to the Swift platform.
2016-05-02 15:25:58 -07:00
Jordan Rose
8f820dea2b [serialization] Diagnose loading modules from older Swifts.
...with a better message than the generic "older version of the
compiler" one, when we know it's actually a different version of
Swift proper.

This still uses the same internal module version numbers to check
if the module is compatible; the presentation of language versions
is a diagnostic thing only.

Speaking of module version numbers, this deliberately does NOT
increment VERSION_MINOR; it's implemented in a backwards-compatible
way.

This will only work going forwards, of course; all existing modules
don't have a short version string, and I don't feel comfortable
assuming all older modules we might encounter are "Swift 2.2".

rdar://problem/25680392
2016-04-29 16:25:33 -07:00
Matt Gallagher
008fbcfde2 Fixed an apparent typo.
Changed 'd' to 'D' to match corresponding fix in Demangle.cpp.
2016-04-28 14:08:38 +10:00
Matt Gallagher
093e54f116 Fixed an apparent typo in demangleImplConvention
Fixed an apparent typo where two cases tested for the same lowercase 'd' pattern, resulting in one case never being used. According to the comment block, doc/ABI.rst and lib/AST/Mangle.cpp, the second case should be an uppercase 'D'.
2016-04-28 12:42:02 +10:00
Doug Gregor
ddbecf0852 [Omit needless words] "Preceding" is a preposition.
Fixes rdar://problem/25075516.
2016-04-26 17:27:25 -07:00
Doug Gregor
abaa4dd7ab [Omit needless words] "Gain" is a verb.
Fixes rdar://problem/25017122.
2016-04-26 17:18:20 -07:00