Commit Graph

316 Commits

Author SHA1 Message Date
Slava Pestov
2c6b9f71b6 AST: Change TypeAliasDecls to store an interface type as their underlying type
- TypeAliasDecl::getAliasType() is gone. Now, getDeclaredInterfaceType()
  always returns the NameAliasType.

- NameAliasTypes now always desugar to the underlying type as an
  interface type.

- The NameAliasType of a generic type alias no longer desugars to an
  UnboundGenericType; call TypeAliasDecl::getUnboundGenericType() if you
  want that.

- The "lazy mapTypeOutOfContext()" hack for deserialized TypeAliasDecls
  is gone.

- The process of constructing a synthesized TypeAliasDecl is much simpler
  now; instead of calling computeType(), setInterfaceType() and then
  setting the recursive properties in the right order, just call
  setUnderlyingType(), passing it either an interface type or a
  contextual type.

  In particular, many places weren't setting the recursive properties,
  such as the ClangImporter and deserialization. This meant that queries
  such as hasArchetype() or hasTypeParameter() would return incorrect
  results on NameAliasTypes, which caused various subtle problems.

- Finally, add some more tests for generic typealiases, most of which
  fail because they're still pretty broken.
2016-12-15 22:46:15 -08:00
Bob Wilson
deddf19aae Merge remote-tracking branch 'origin/master' into master-next 2016-12-13 10:23:03 -08:00
Robert Widmann
fe00dc74ea Get rid of _stdlib_didEnterMain
Process arguments are now fetched per-platform
2016-12-12 23:47:48 -05:00
Hugh Bellamy
d80a2220bd Fix clang-cl error compiling Immediate.cpp on Windows 2016-12-08 13:17:22 +00:00
Hugh Bellamy
c417083e60 Port swift/Immediate to Windows (#5957) 2016-12-07 19:08:41 -08:00
Michael Gottesman
59c6a64f5a [gardening] 0 => nullptr. Fixed with clang-tidy. 2016-12-06 23:14:13 -08:00
Bob Wilson
13da3fa8b1 Merge remote-tracking branch 'origin/master' into master-next 2016-12-04 18:16:09 -08:00
Doug Gregor
51c2cee4d8 [Immediate] Remove a redundant, pessimizing std::move().
Silences a warning on newer Clang versions.
2016-12-01 10:37:28 -08:00
Roman Levenstein
409d146f17 Reduce memory usage by freeing memory occupied by SILModules after IRGen.
There is no need to keep SILModules around after IRGen has generated LLVM IR from them.
This reduces the compiler memory usage during LLVM code-generation and optimization phases roughly by 15%-20%.
2016-11-29 22:11:59 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
David Farler
f450f0ccdf Revert "Preserve whitespace and comments during lexing as Trivia"
This reverts commit d6e2b58382.
2016-11-18 13:23:31 -08:00
Bob Wilson
6ca7872ba5 Merge remote-tracking branch 'origin/master' into master-next 2016-11-16 22:12:23 -08:00
David Farler
d6e2b58382 Preserve whitespace and comments during lexing as Trivia
Store leading a trailing "trivia" around a token, such as whitespace,
comments, doc comments, and escaping backticks. These are syntactically
important for preserving formatting when printing ASTs but don't
semantically affect the program.

Tokens take all trailing trivia up to, but not including, the next
newline. This is important to maintain checks that statements without
semicolon separators start on a new line, among other things.

Trivia are now data attached to the ends of tokens, not tokens
themselves.

Create a new Syntax sublibrary for upcoming immutable, persistent,
thread-safe ASTs, which will contain only the syntactic information
about source structure, as well as for generating new source code, and
structural editing. Proactively move swift::Token into there.

Since this patch is getting a bit large, a token fuzzer which checks
for round-trip equivlence with the workflow:

fuzzer => token stream => file1
  => Lexer => token stream => file 2 => diff(file1, file2)

Will arrive in a subsequent commit.

This patch does not change the grammar.
2016-11-15 16:11:57 -08: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
Michael Gottesman
fa1bb95923 Merge remote-tracking branch 'origin/master' into master-next 2016-08-30 19:50:12 -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
practicalswift
7e89679404 [gardening] Fix recently introduced typos. 2016-07-24 22:32:40 +02: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
Robert Widmann
dc88e51321 Nuke entry-point-based process args
Provides a new fallback for Process arguments for those instances where we do
not own main (e.g. Frameworks, Objective-C owns main.m or main.c, etc.). This
includes a number of platform-specific specializations of argument grabbing
logic and a new thread-safe interface to Process.unsafeArgv.

main()  | _NSGetArgc/_NSGetArgv    | /proc/self/cmdline     | __argc/__argv
--------|--------------------------|------------------------|---------------
Scripts | OS X, iOS, tvOS, watchOS | Linux, FreeBSD, Cygwin | Windows

For interpreted Swift where we must filter out the arguments we now do so by
loading the standard library and calling into new SPI to override the arguments
that would have been grabbed by the runtime. This implementation completely
subsumes the use of the entry point  '_stdlib_didEnterMain' and it will be
removed in a future commit.
2016-07-14 01:06:19 -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
Vedant Kumar
1409a445d9 [stable-merge] Adopt new setUnnamedAddr API 2016-06-27 11:12:28 -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
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
Erica Sadun
1cd06c457d Fixed line continuation error in CMakeLists.txt. Updated REPL warning for compiler and stdlib development use recommendations 2016-05-31 16:38:02 -06:00
Michael Gottesman
0c1f6db23b [upstream-update] Add our own LLVM global context now that llvm::getGlobalContext() was removed upstream.
Swift relies on this for now. So create our own. This makes more sense
than trying to add back in the API (which is dead besides the c api) or
use the c api itself. We should probably consider not using a global
context like this.
2016-04-18 07:29:58 -07:00
Michael Gottesman
505107ebf3 Linker changes final. 2016-02-06 11:22:27 -08:00
Michael Gottesman
c182e692f4 [upstream-update] llvm::Linker::linkModules no longer needs a NoCtx diagnostic handler. It always gets it from the llvm context. 2016-02-06 11:22:26 -08:00
Michael Gottesman
99c6e2ce55 Pass in the actual unique_ptr of the submodule to llvm::Linker::linkModules to deal with an API that was updated upstream.
What is important to note is that the submodule needs to be forwarded via a move
constructor to make sure that we do not destroy the value early.
2016-02-06 11:22:26 -08:00
Michael Gottesman
5f55a47d93 llvm::DiagnosticInfo.h upstream now has its own header llvm/IR/DiagnosticInfo.h. Include it in Immediate.cpp. 2016-02-06 11:22:26 -08:00
Michael Gottesman
248ca3d657 Update for upstream linker changes.
llvm commits:
r254449.
r254777.
2016-02-06 11:22:26 -08:00
practicalswift
ca92efc8e6 Use consistent formatting of header comments.
Correct format:
```
//===--- Name of file - Description ----------------------------*- Lang -*-===//
```

Notes:
* Comment line should be exactly 80 chars.
* Padding: Pad with dashes after "Description" to reach 80 chars.
* "Name of file", "Description" and "Lang" are all optional.
* In case of missing "Lang": drop the "-*-" markers.
* In case of missing space: drop one, two or three dashes before "Name of file".
2016-01-04 23:00:53 +01:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
practicalswift
f91525a10f Consistent placement of "-*- [language] -*-===//" in header. 2016-01-04 09:46:20 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Davide Italiano
7a0ab3257b [lib/Immediate] Enable built-in REPL on FreeBSD. 2015-12-22 23:46:20 +00:00
Jordan Rose
22d6437dfb Fix another -Wpessimizing-move issue.
Use braced initialization to avoid The Most Vexing Parse.
https://en.wikipedia.org/wiki/Most_vexing_parse

No functionality change.
2015-12-17 15:19:09 -08:00
Andrew Trick
739b0e9c56 Reorganize SILOptimizer directories for better discoverability.
(libraries now)

It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.

This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.

Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
2015-12-11 15:14:23 -08:00
Andrew Trick
84450b4c43 Reorganize SILOptimizer directories for better discoverability.
(Headers first)

It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.

This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.

Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
2015-12-11 12:34:51 -08:00
Doug Coleman
86d99cea9b Fix eight Linux warnings.
Fix spurious docs warning that @in and @in_guaranteed should be ``fn``.

Add ``#ifdef SWIFT_OBJC_INTEROP`` to silence a -Wunused-function
on linux since that function is only used from within that #ifdef
elsewhere.

Fix three -Wunused-function warnings on linux.

Fix two -Wunreachable-code warnings on linux dealing with
SWIFT_HAVE_WORKING_STD_REGEX.
2015-12-07 15:29:41 -08:00
Jordan Rose
742c8c844f Point Linux users towards LLDB for their REPL.
The Swift compiler has a bare-bones integrated REPL for testing purposes,
but it hasn't been ported to any platforms besides OS X. The real REPL is
part of LLDB and works on both OS X and Linux.

I've already seen two questions about this error message, so at least
pointing people towards LLDB is probably a good idea.

No functionality change.
2015-12-04 16:01:23 -08:00
Joe Groff
0ad201bb05 REPL: Tear out CF-based async repl loop.
It's unnecessary nonportable complexity now that the out-of-process REPL is the primary user-facing REPL tool.

Swift SVN r32913
2015-10-27 18:02:57 +00:00
Dmitri Hrybenko
8df3dd331e Remove standard library hooks for AppKit apps in the integrated REPL
The REPL code can be simplified now.

Swift SVN r32882
2015-10-25 08:27:42 +00:00
Joe Groff
773eadb9f2 IRGen/Runtime: Populate the runtime protocol conformance table with relative references.
By using relative references, either directly to symbols internal to the current TU, or to the GOT entry for external symbols, we avoid unnecessary runtime relocations, and we save space on 64-bit platforms, since a single image is still <2GB in size. For the 64-bit standard library, this trades 26KB of fake-const data in __DATA,__swift1_proto for 13KB of true-const data in __TEXT,__swift2_proto. Implements rdar://problem/22334380.

Swift SVN r31555
2015-08-28 18:07:22 +00:00
Joe Groff
43d620c7e0 IRGen: Export direct metadata symbols at the address point of the metadata object.
This is more resilient, since we want to be able to add more information behind the address point of type objects. The start of the metadata object is now an internal "full metadata" symbol.

Note that we can't do this for known opaque metadata from the C++ runtime, since clang doesn't have a good way to emit offset symbol aliases, so for non-nominal metadata objects we still emit an adjustment inline. We also aren't able to generate references to aliases within the same module due to an MC bug with alias refs on i386 and armv7 (rdar://problem/22450593).

Swift SVN r31523
2015-08-27 05:18:38 +00:00
Joe Groff
f705c561e3 Revert "IRGen: Export direct metadata symbols at the address point of the metadata object."
This reverts commit r31515. It causes an LLVM error on the release bots.

Swift SVN r31516
2015-08-27 01:44:56 +00:00
Joe Groff
8e2ce60f5b IRGen: Export direct metadata symbols at the address point of the metadata object.
This is more resilient, since we want to be able to add more information behind the address point of type objects, and also makes IR a lot less cluttered. The start of the metadata object is now an internal "full metadata" symbol.

Note that we can't do this for known opaque metadata from the C++ runtime, since clang doesn't have a good way to emit offset symbol aliases, so for non-nominal metadata objects we still emit an adjustment inline.

Swift SVN r31515
2015-08-27 01:34:22 +00:00
Jordan Rose
14e04a95c6 [REPL] Use llvm::outs() instead of printf.
And change the welcome prompt to be less friendly.

Swift SVN r31503
2015-08-26 19:35:33 +00:00
Jordan Rose
38261ce1f3 Pull the integrated REPL out into a separate source file.
No intended functionality change, although this may make it easier to
get the REPL up and running on Linux. This is still useful for compiler
hackers even if it's not an end-user feature.

Swift SVN r31502
2015-08-26 19:35:27 +00:00
Doug Gregor
edbb75eef8 Eliminate the 'Module' variant from UnqualifiedLookupResult.
Make unqualified lookup always provide a declaration for the things it
finds, rather than providing either a module or a declaration. Unify
various code paths in our type checker now that module declarations
come in with the other declarations.

Swift SVN r28286
2015-05-07 21:10:55 +00:00
Doug Gregor
b8995b0aa3 Transform the Module class into ModuleDecl.
Modules occupy a weird space in the AST now: they can be treated like
types (Swift.Int), which is captured by ModuleType. They can be
treated like values for disambiguation (Swift.print), which is
captured by ModuleExpr. And we jump through hoops in various places to
store "either a module or a decl".

Start cleaning this up by transforming Module into ModuleDecl, a
TypeDecl that's implicitly created to describe a module. Subsequent
changes will start folding away the special cases (ModuleExpr ->
DeclRefExpr, name lookup results stop having a separate Module case,
etc.).

Note that the Module -> ModuleDecl typedef is there to limit the
changes needed. Much of this patch is actually dealing with the fact
that Module used to have Ctx and Name public members that now need to
be accessed via getASTContext() and getName(), respectively.

Swift SVN r28284
2015-05-07 21:10:50 +00:00