Commit Graph

1419 Commits

Author SHA1 Message Date
Ben Langmuir
15cf72be20 [sourcekit] Fix use-after-free of block inside libsourcekitdInProc sync_request
In sourcekitdInProc, we were doing a by-ref capture of a block that
didn't live as long as the asyncronous callback. Fix it by capturing
by-copy.

Found by ASan!
2016-07-19 12:59:04 -07:00
Brian Gesiak
183cb54838 [SourceKit] Document source.request.demangle (#3603) 2016-07-19 10:45:56 -07:00
JP Simard
d3d211b154 link libswiftCore when building SourceKit on Linux
since libdispatch now includes a Swift overlay
2016-07-19 10:11:11 -07:00
Xi Ge
2a860100a5 [SourceKit] Implement a new SourceKit request to generate the interface for a given type. rdar://27306890 (#3586)
This patch allows SourceKit to generate the interface for a given type specified by its mangled name.
Type interface is refined decl printing with type parameters localized and unusable members hidden.

Required field:
   "key.request": "source.request.editor.open.interface.swifttype"
   "key.usr": the mangled name of the given type.
2016-07-18 18:05:47 -07:00
Brian Croom
d1d7525497 [SourceKit] Rename Concurrency-Mac.cpp to Concurrency-libdispatch.cpp
This file builds fine as long as libdispatch is available, even on
non-Darwin platforms.
2016-07-18 16:17:49 -07:00
Brian Croom
e109cb8285 [SourceKit] Add libdispatch as a dependency for some SourceKit products
sourcekitdInProc, sourcekitd-test, and complete-test need to be explicitly
linked with libdispatch on Linux to build properly.
2016-07-18 16:17:49 -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
Ben Langmuir
18be066651 [sourcekit] Synchronize cursor-info requests on generated interfaces
Cursor info requires access to the underlying AST, which is not
thread-safe. This manifest as crashes when performing concurrent
cursor-info requests on the same generated interface. We already
prevented concurrent cursor-infos on regular Swift files by using the
ASTManager, but generated interfaces use the InterfaceGenContext which
may use either an ASTUnit or its own internal CompilerInstance.

rdar://problem/27311624
2016-07-13 16:35:23 -07:00
Ben Langmuir
8e0ff518d1 [sourcekitd-test] Add -async flag to request options
This enables testing asyncronous requests on platforms that support it
(currently you need blocks support to call sourcekitd_send_request).
The implementation performs all -async requests and then at the end
handles all the responses in the order they were performed (possibly
blocking until they complete).

Also add a -dont-print-request flag to avoid printing request objects;
printing is fairly slow and makes it much harder to hit timing-sensitive
races, etc.
2016-07-13 16:35:22 -07:00
Xi Ge
a7e4cfd042 [SourceKit] Report container type USRs in the response to cursor-info request.
Typically, users jump to type-specific interface from a member of that type, for
instance, a.getSomething(). To generate the interface, we need to report the USR
of the container type of "getSomething()", which is the USR for the type of a,
 when cursor info is requested for this function call.
2016-07-12 15:50:18 -07:00
Xi Ge
a5e51a3494 [SourceKit] In CursorInfo response, include the mangle name of the type of the underlying decl.
The mangled name of the type is identical to those for debugger. These
mangled names allow us to reconstruct the type from AST and generate interface
specifically for that type.

Related rdar://27306890
2016-07-12 13:10:58 -07:00
Michael Gottesman
224d76391c [cmake] Follow LLVM/Clang's example and use add_llvm_subdirectory and invoke add_llvm_subdirectory when adding tools/libs. This allows us to selectively disable the building of tools by setting the variable SWIFT_{TOOL,LIB}_XXX_BUILD=OFF.
This is done by introducing the macros: add_swift_{lib,tool}_subdirectory.
2016-07-09 21:24:20 -07:00
Xi Ge
09a19bb230 [SourceKit] Avoid expanding the last argument as trailing closure if there are other closures in the tuple. rdar://23428366 (#3408)
SourceKit invariantly expands the last argument in a function call as trailing closure,
if it is of function type. However, there are situations when inline closures
are preferred; for example, when the last argument is not the only closure in the function
call. This patch modifies SourceKit so that when the argument contains multiple closures,
the last argument is expanded as inline closure.
2016-07-07 18:25:55 -07:00
Xi Ge
64efa48c65 [SourceKit][DocInfo] When the underlying type of a type alias decl exists, report the conformances of the underlying type. rdar://26408167 (#3394)
Showing only the conforming associated types provides
little information to doc viewers. This patch digs the
underlying type of an associated type to report the
conformance info of those.
2016-07-07 16:24:01 -07:00
Michael Gottesman
e25e0e4d39 Revert "[cmake] Do not set CMAKE_INCLUDE_CURRENT_DIR."
This reverts commit 3168df8c11.
2016-07-01 19:18:27 -07:00
Michael Gottesman
3c603ab18b Merge remote-tracking branch 'origin/master' into master-next 2016-07-01 18:44:21 -07:00
Harlan
1625d97976 Switch to llvm-profdata's pooled profdata merge (#3281) 2016-07-01 16:45:21 -07:00
Ben Langmuir
c8f7da4de1 [CodeCompletion] Support a narrow case for producing trailing closures directly
This adds a narrow special case in code-completion for control-flow-like
methods such as DispatchQueue().sync that are () -> (), to add a new
completion where the trailing closure is immediately expanded rather
than having to invoke placeholder expansion as a second step.

rdar://problem/26628804
2016-07-01 14:16:57 -07:00
shotat
4cead9bf7e Fix typos 2016-06-26 19:31:05 +09:00
Michael Gottesman
e90ae448c8 [upstream-update] Fix one last usage of llvm::sys::PrintStackTraceOnErrorSignal. 2016-06-25 02:24:48 -07:00
Michael Gottesman
d3467b40ca Merge pull request #3008 from compnerd/stack-trace
[master-next] update invocation of PrintStackTraceOnError
2016-06-25 02:15:22 -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
Michael Gottesman
3168df8c11 [cmake] Do not set CMAKE_INCLUDE_CURRENT_DIR.
Setting this value is equivalent to setting:

include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})

in all subdirectories. Since these are all macros, this means that we are adding to the configuration
path the root swift directory. There is no reason to do this and will result in
confusion/bugs in the future.

rdar://26154980
2016-06-24 19:14:34 -07:00
Michael Gottesman
5d984de9ec [cmake] Instead of setting LLVM_TABLEGEN_EXE, use our own SWIFT_TABLEGEN_EXE variable.
This eliminates us setting an LLVM_ prefixed variable in a situation where there is
a viable alternative.

We want to eliminate as many of these as possible since they can cause conflicts
with variables set in LLVMConfig.cmake.

I also added some convenience tablegen functions in AddSwiftTableGen.cmake and
changed all tblgen users to use that instead.

rdar://26154980
2016-06-24 17:18:45 -07:00
Brian Croom
2c4eb846fd [SourceKit] Add an in-proc implementation of sourcekitd API functions.
Darwin can use the XPC implementation of this even for the in-proc library
build, this alternative implementation is need for Linux where XPC services
are not available.

This implementation is derived from the existing XPC one but replaces XPC
services' object model with a basic class hierarchy providing
reference-counted objects for the value types and collections that
compose the sourcekitd API's request and response types.
2016-06-24 17:43:54 -04:00
swift-ci
3ea89df9d0 Merge pull request #3163 from briancroom/sourcekit-shared-object-printer 2016-06-23 20:55:51 -07:00
Brian Croom
5a300033f5 [SourceKit] Share common object printer code
This is an attempt to clean up code duplication around printing SourceKit
request and response objects.
2016-06-23 18:37:18 -04:00
practicalswift
e78e7e4c3c [gardening] Fix recently introduced typos. 2016-06-23 16:42:48 +02:00
Brian Croom
af0fd68a6e [SourceKit] Clean up clang dependency ordering 2016-06-22 21:00:12 -04:00
swift-ci
202e991e99 Merge pull request #3101 from briancroom/sourcekit-break-circular-dependency 2016-06-22 13:25:32 -07:00
Brian Croom
fac744067c [SourceKit] Remove dependency of SwiftLang on Core 2016-06-22 13:04:37 -04:00
Saleem Abdulrasool
0dfeee7871 SourceKit: use _WIN32 instead of LLVM_ON_WIN32
`_WIN32` indicates if we are targeting Windows or not.  Directly use that macro
rather than `LLVM_ON_WIN32` used by LLVM.  This makes it easier to port the
code.
2016-06-22 06:32:46 -07:00
Ben Langmuir
f72bd5453f [CodeCompletion] Fix a crash when completing typealiases for protocol conformance
The index may be at the end of the ArrayRef of chunks if the completion
ends with a simple parameter with no type annotation.  Check that the
index is in-bounds before adding text.

rdar://problem/26273906
2016-06-21 16:56:29 -07:00
Ben Langmuir
3c9c52010b [CodeCompletion] Add image and color literals to results
Surface these results in the codecomplete code path (they're already
there in the codecomplete.open code path) so we can use them from IDEs.
For now, just use ad-hoc filtering to show them when the type matches
(or there is no expected type).  Ideally we would make this filtering
configurable like we do in the codecomplete.open code path.

rdar://problem/25836544
2016-06-21 11:41:15 -07:00
Brian Croom
67edb44990 Merge pull request #3085 from briancroom/sourcekit-semaphore
[SourceKit] Add Semaphore to SourceKitSupport's concurrency module
2016-06-21 13:56:23 -04:00
Brian Croom
479584109c [SourceKit] Add Semaphore to SourceKitSupport's concurrency module
Includes a libdispatch-based implementation.
2016-06-21 13:54:41 -04:00
Brian Croom
a406858e38 Merge pull request #3096 from briancroom/sourcekitd-api-common
[SourceKit] Move some functions into sourcekitdAPI-Common.
2016-06-21 04:48:11 -04:00
Brian Croom
194a583ac7 [SourceKit] Move some functions into sourcekitdAPI-Common.
These functions are not XPC-specific and can be treated as part of the
common implementation.
2016-06-20 10:39:52 -04:00
Brian Croom
6c1f8dd6d6 [SourceKit] Only build sourcekitd-repl if a unicode-aware libedit is present 2016-06-20 10:35:51 -04:00
Saleem Abdulrasool
e3c2c863d1 stdlib: define WIN32_LEAN_AND_MEAN and NOMINMAX
`WIN32_LEAN_AND_MEAN` prevents "rarely-used" headers from being pulled in.  This
significantly reduced preprocessor pressure, speeding up compile.  It also
reduces the amount of cruft pulled in by the Windows.h.

`NOMINMAX` ensures that the `min` and `max` macros are not defined.  These
macros collide with the use of `min` and `max` from C++ in certain cases: e.g.
`std::limits<T>`.
2016-06-16 07:34:17 -07:00
Dmitri Gribenko
e15861a66e Merge pull request #3017 from practicalswift/python
[gardening] Use consistent capitalization for "Python".
2016-06-14 21:29:05 -07:00
Mishal Shah
87b7bcfd3e Update master to build with Xcode 8 beta 1, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-06-14 14:53:55 -07:00
practicalswift
db6890fd26 [gardening] Use consistent capitalization for "Python". 2016-06-14 23:18:00 +02:00
Saleem Abdulrasool
9846299697 update invocation of PrintStackTraceOnError
SVN r272232 added an additional parameter to PrintStackTraceOnError.  Update the
use of the API to add the executable name.  We can assume that argv[0] will
always be provided as that is the name of the binary itself.
2016-06-13 14:49:53 -07:00
Brian Gesiak
3dc42d77a9 Merge pull request #2789 from modocache/sourcekitd-test-missing-request-types
[SourceKit] Update sourcekitd-test request types
2016-06-13 13:16:57 -04:00
Brian Gesiak
227fab9ee6 Merge pull request #2766 from modocache/sourcekit-linux-link-swiftlang
[SR-1639][SourceKit] Link SwiftLang libraries to sourcekitd
2016-06-13 13:05:57 -04:00
Michael Gottesman
61df461e88 [lto][cmake] Add LTO support to SourceKit.
rdar://24717107
2016-06-10 13:33:49 -07:00
swift-ci
2ae71e9297 Merge pull request #2763 from modocache/sourcekitd-repl-in-proc 2016-06-07 11:42:55 -07:00
Ben Langmuir
4600b1dd12 [CodeCompletion] Fix incorrect upper bound for assertion
This assertion was bogus if there were fewer results than N.
2016-06-04 18:22:18 -07:00
therealbnut
2f4aed7bb2 Fix some CMakeLists syntax 2016-06-04 06:44:10 +10:00