Commit Graph

1938 Commits

Author SHA1 Message Date
Mingsheng Hong
61b20c8071 Also added DenseMapInfo specialization for SourceLoc, so that call-site can
decide whether to use a map key based on SourceLoc or SourceRange.
2018-08-02 16:04:43 -07:00
swift-ci
df3895a653 Merge remote-tracking branch 'origin/master' into master-next 2018-08-02 12:29:14 -07:00
Daniel Martín
e66095b10a [Parser] Support "<" unary operator in #if swift() expressions
Until now, only ">=" was supported in #if swift() expressions, for example:

```#if swift(>=2.1)
```#endif

This means that if we want to evaluate code only when the language version is
less than a particular version we need to do the following:

```#if !swift(>=2.1)
```#endif

An alernative to make this more readable (the "!" can be easily missed in a code
review) is to introduce another supported unary operator, "<". The previous
example could be rewritten like this:

```#if swift(<2.1)
```#endif

This commit adds support for that unary operator, along with some tests.
2018-08-02 20:35:58 +02:00
Michael Gottesman
7e70389b80 [upstream-update] Do not specify OpenFlags since it was removed upstream.
This was removed upstream in https://reviews.llvm.org/D47789 since the only
place this flag was used was in the windows implementation where the behavior
triggered by this could be hidden in the implementation instead of being an
argument. As such, this code doesn't compile on master-next.

Since this has an acceptable default argument given the current stable, we can
just fix this on master and everything will work.

rdar://42862352
2018-08-02 11:34:54 -07:00
swift-ci
19cb223a66 Merge remote-tracking branch 'origin/master' into master-next 2018-08-01 18:49:02 -07:00
Jordan Rose
0204561269 [Frontend] Factor out textual interface generation into its own file
No functionality change.
2018-08-01 16:41:21 -07:00
Jordan Rose
1dd415ae68 Add a new helper, atomicallyWritingToFile, and use it
This replaces the use of a Clang utility function that was
inexplicably a non-static member function of CompilerInstance. It
would be nice to sink this all the way to LLVM and share the
implementation across both projects, but the Clang implementation does
a handful of things we don't need, and it's hard to justify including
them in an LLVM-level interface. (I stared at
llvm/Support/FileSystem.h for a long time before giving up.)

Anyway, Serialization and FrontendTool both get their atomic writes
now without depending on Clang, and without duplicating the
scaffolding around the Clang API. We should probably adopt this for
all our output files.

No functionality change.
2018-08-01 16:41:21 -07:00
swift-ci
fe2b1bbd3a Merge remote-tracking branch 'origin/master' into master-next 2018-07-31 19:29:10 -07:00
swift-ci
ae0b5a0d8f Merge pull request #18328 from CodaFi/virtual-insanity 2018-07-31 19:21:40 -07:00
Mingsheng Hong
0a09541bcb Make swift::SourceRange usable as a key type for DenseSet/DenseMap.
One use case is using DenseSet to manage a set of source locations, so that we
emit at most one compiler diagnostic per location (see
https://github.com/apple/swift/pull/18402).
2018-07-31 14:31:10 -07:00
swift-ci
5830e237ff Merge remote-tracking branch 'origin/master' into master-next 2018-07-31 13:29:50 -07:00
Robert Widmann
917e94d11c Introduce SourceManager::getDisplayNameForLoc
Add an abstraction to retrieve a name suitable for display for a given
source location for use with diagnostics, debug locations, and magic
file literals.
2018-07-31 13:16:14 -07:00
Robert Widmann
0e58b7fd14 Plumbing for a Virtual File System
Adds the -vfsoverlay frontend option that enables the user to pass
VFS overlay YAML files to Swift. These files define a (potentially
many-layered) virtual mapping on which we predicate a VFS.

Switch all input-based memory buffer reads in the Frontend to the new
FileSystem-based approach.
2018-07-31 13:16:14 -07:00
Doug Gregor
cb7c2b4fce [Name lookup] Introduce requests for several name lookup operations.
Introduce three new requests for name lookup operations that avoid performing
type checking/semantic analysis. They work using syntactic information
(e.g., TypeReprs) and AST-level name lookup operations that will (eventually)
avoid and calls back into type checking. The new requests are:

* Retrieve the superclass declaration of a protocol or class declaration. Use
this request for ClassDecl::getSuperclassDecl() and
ProtocolDecl::getSuperclassDecl().
* Retrieve the types “directly referenced” by a particular location in
an inheritance clause. This query is based on looking at the TypeReprs
and performing fairly-minimal lookup, so it does not involve any Type
computations.
* Retrieve the types “directly referenced” by the underlying type of
a typealias. This query allows us to desugar a typealias without forming
a type.

Along with these is a core operation to transform a set of TypeDecl*s
into a set of NominalTypeDecl*s, looking through typealiases, and
without involving Type at all. The superclass-decl request does this
to find a ClassDecl; other requests will eventually do this to (e.g.)
find all of the protocols mentioned in an inheritance clause.
2018-07-31 10:14:44 -07:00
swift-ci
8247c2ba15 Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 13:09:54 -07:00
Joe Groff
f8e5ebe873 Merge pull request #18299 from jckarter/enable-key-path-resilience
Enable key path resilience.
2018-07-30 13:00:43 -07:00
swift-ci
cfc685f7cb Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 08:48:53 -07:00
Alex Hoppen
88937f93c4 Merge pull request #18295 from ahoppen/json-serialization-improvements
[libSyntax] JSON serialization improvements
2018-07-30 08:46:16 -07:00
Alex Hoppen
7593682c98 [JSONSerialization] Make key a StringRef
Most keys are string literals and if they are converted directly to
StringRef, the string length can be computed at compile time, increasing
performance.
2018-07-27 16:20:34 -07:00
Alex Hoppen
07b449bbd5 [JSONSerialization] Introduce ScalarReferenceTraits
For ScalarTraits, a buffer was always created on the heap to which the
scalar string value was written just to be copied to the output buffer
again. In case the value already exists in a memory buffer it is way
cheaper to avoid the heap allocation and copy it straight to the output
buffer.
2018-07-27 16:20:34 -07:00
Joe Groff
7604dd5abc Enable key path resilience. 2018-07-27 13:16:32 -07:00
swift-ci
9711455ad8 Merge remote-tracking branch 'origin/master' into master-next 2018-07-26 14:49:10 -07:00
Jordan Rose
a5899ee93a Minor improvements to file_types
No intended functionality change.
2018-07-25 22:23:00 -07:00
Jordan Rose
97b152d71e Consistently get extensions from swift/Basic/FileTypes.h (part 2)
Remove the last few literal extension strings from Strings.h in favor
of the file_types APIs, and use those APIs in a few more places.
2018-07-25 22:23:01 -07:00
Jordan Rose
67a6a4ff18 Move swift/Frontend/FileTypes.h down to Basic
The next commit will take advantage of this, but this is just a
mechanical change.
2018-07-25 22:23:00 -07:00
swift-ci
3e314229fc Merge remote-tracking branch 'origin/master' into master-next 2018-07-25 08:49:14 -07:00
Jordan Rose
e3ccde3d09 Briefly describe all of the formats in SupplementaryOutputPaths.h. (#18187) 2018-07-25 08:42:40 -07:00
swift-ci
36ead37964 Merge remote-tracking branch 'origin/master' into master-next 2018-07-24 17:49:02 -07:00
Jordan Rose
de30596ccd Merge pull request #17665 from allevato/debug-prefix-map-wip
Implement -debug-prefix-map flag.
2018-07-24 17:34:42 -07:00
swift-ci
d7c334c1e7 Merge remote-tracking branch 'origin/master' into master-next 2018-07-24 12:49:50 -07:00
Tony Allevato
aade5fb1e4 Remove redundant "private" 2018-07-24 12:48:48 -07:00
Jordan Rose
b9ae66d768 [Frontend] Add a new -emit-interface-path option
...but don't hook it up to anything yet.

This is the very very start of the module stability / textual
interfaces feature described at

  https://forums.swift.org/t/plan-for-module-stability/14551/

For now I've just made it a frontend option (not a driver option),
which is good enough for testing.
2018-07-20 16:40:51 -07:00
swift-ci
c4feb3611d Merge remote-tracking branch 'origin/master' into master-next 2018-07-18 17:09:20 -07:00
Alex Hoppen
1df1dc71b7 Merge pull request #18016 from ahoppen/003-incremental-syntax-coloring
[libSyntax] Incremental syntax colouring
2018-07-18 17:08:02 -07:00
Alex Hoppen
6635be10ea [libSyntax] Add UserInfo to json::Output
This will allow us to customize the serialization of a syntax tree like
not serializing the node's IDs.
2018-07-18 13:35:10 -07:00
Alex Hoppen
60feeac01c [libSyntax] Copy the text of a syntax node
Since we are reusing syntax nodes as part of incremental parsing, we
cannot rely on the buffer always outliving the syntax nodes.
2018-07-18 13:35:10 -07:00
swift-ci
9b12d01fc2 Merge remote-tracking branch 'origin/master' into master-next 2018-07-17 09:09:17 -07:00
Alex Hoppen
3bf94abbfc Merge pull request #17621 from ahoppen/002-sytnax-tree-based-coloring
[libSyntax] Syntax colouring based on the syntax tree
2018-07-17 08:54:51 -07:00
Alex Hoppen
dfad6f787f [Basic] Extract isEditorPlaceholder from Identifier to standalone function 2018-07-13 16:56:03 -07:00
swift-ci
f1db8dec9f Merge remote-tracking branch 'origin/master' into master-next 2018-07-11 17:49:17 -07:00
Jordan Rose
d11704bcc9 Add swift::getNonSimulatorPlatform for DarwinPlatformKind
And use it in getDarwinLibraryNameSuffixForTriple, making the logic
there clearer.

Suggested by David U!
2018-07-11 15:09:53 -07:00
Tony Allevato
346e1c3317 Apply review feedback. 2018-07-06 21:00:06 -07:00
swift-ci
2a7d47c722 Merge remote-tracking branch 'origin/master' into master-next 2018-07-05 16:49:26 -07:00
Graydon Hoare
465ca073f8 [Sema] Move AccessLevel calculation to AST-level requests. 2018-07-04 16:56:26 -07:00
swift-ci
a93ce92de1 Merge remote-tracking branch 'origin/master' into master-next 2018-07-02 20:29:09 -07:00
Doug Gregor
730cf6ccce Add a helper form of ArrayRefView to create a cast<> projection. 2018-07-02 13:32:40 -07:00
Tony Allevato
78edd30ddf Implement -debug-prefix-map flag.
This flag is based on Clang's -fdebug-prefix-map, which lets the user remap absolute paths in debug info. This is necessary for reproducible builds and allows debugging to work on a different machine than the one that built the code when paths to the source may be different.
2018-07-01 18:22:15 -07:00
swift-ci
4d15dc1dad Merge remote-tracking branch 'origin/master' into master-next 2018-06-29 17:29:11 -07:00
Doug Gregor
9e95a93125 [Evaluator] Sink type checker requests into the AST library.
Sink the type checker request classes into the AST library, so that
various functions in the AST library can form type-checking requests.
The actual evaluator functions for these requests continue to live
in the Sema library, called via indirection through the function
pointer tables registered with the request-evaluator.
2018-06-29 15:58:57 -07:00
Doug Gregor
a6f46584ec [Evaluator] Indirect evaluation of uncached requests through a separate table.
The bundling of the form of a request (e.g., the storage that makes up a request)
with the function that evaluates the request value requires us to perform
ad hoc indirection to address the AST —> Sema layering violation. For
example, ClassDecl::getSuperclass() calls through the LazyResolver (when
available) to form the appropriate request. This means that we cannot
use the the request-evaluator’s cache when LazyResolver is null, forcing
all cached state into the AST.

Provide the evaluator with a zone-based registration system, where each
request “zone” (e.g., the type checker’s requests) registers
callbacks to evaluate each kind of request within that zone. The
evaluator indirects through this table of function pointers, allowing
the request classes themselves to be available at a lower level (AST)
than the functions that perform the computation when the value isn’t
in the cache (e.g., Sema).

We are not taking advantage of the indirection yet; that’ll come in a
follow-up commit.
2018-06-29 15:41:55 -07:00