Commit Graph

104 Commits

Author SHA1 Message Date
Alex Hoppen
63c31033fc [Frontend] Load standard libarary in CompilerInstance::setup
Instead of checking that the stdlib can be loaded in a variety of places, check it when setting up the compiler instance. This required a couple more checks to avoid loading the stdlib in cases where it’s not needed.

To be able to differentiate stdlib loading failures from other setup errors, make `CompilerInstance::setup` return an error message on failure via an inout parameter. Consume that error on the call side, replacing a previous, more generic error message, adding error handling where appropriate or ignoring the error message, depending on the context.
2021-12-13 15:32:08 +01:00
Michael Gottesman
06cb5c0047 [cmake] Move a bunch of test binaries from install component 'tools' -> 'testsuite-tools'.
All of these are tools that are only meant to be used when testing swift. Thus
it doesn't make sense to include them in the catch all 'tools' install component
that distributions use to build all the tools.

I verified that all of the mac/linux presets in tree that have tools also has
testsuite-tools so this should be NFC. On Windows, I needed to add
testsuite-tools to build-windows.bat so should be NFC there as well.
2021-11-09 12:51:58 -08:00
Evan Wilde
0aafd09835 F_None was renamed OF_None
This patch updates usages of F_None to OF_None, as LLVM changed that in
commit 3302af9d4c39642bebe64dd60a3aa162fefc44b2.
2021-06-23 10:36:39 -07:00
Ben Barham
299df93a7f Merge pull request #36807 from bnbarham/use-original-locs
Replace uses of presumed locations where they do not make sense
2021-04-13 08:48:23 +10:00
Ben Barham
20f45ec284 Replace uses of presumed locations where they do not make sense
Various uses of `getPresumedLineAndColumnForLoc` were likely added when
that function was the very misleading name `getLineAndColumn`. Change
these to use `getLineAndColumnForBuffer` instead where appropriate, ie.
we want the underlying file rather than the location to display to the
user.

There were also some cases where the buffer identifier had been swapped
to use the display name instead, under the assumption that the presumed
location was needed. Updated those as well.

SingleRawComment: Lines are only used when merging comments, where the
original location is fine to use.

Index: Doesn't store the file set in #sourceLocation, so using the
presumed line would end up pointing to a location that makes no sense.

Editor functionality: Formatting and refactoring are on the current
file. Using the presumed location would result in incorrect
replacements.
2021-04-10 09:49:31 +10:00
Alex Hoppen
294977534c [libSyntax] Remove incremental JSON transfer option
We were only keeping track of `RawSyntax` node IDs to incrementally transfer a syntax tree via JSON. However, AFAICT the incremental JSON transfer option has been superceeded by `SyntaxParseActions`, which are more efficient.

So, let’s clean up and remove the `RawSyntax` node ID and JSON incremental transfer option.

In places that still need a notion of `RawSyntax` identity (like determining the reused syntax regions), use the `RawSyntax`’s pointer instead of the manually created ID.

In `incr_transfer_round_trip.py` always use the code path that uses the `SyntaxParseActions` and remove the transitional code that was still using the incremental JSON transfer but was never called.
2021-04-07 10:01:34 +02:00
Alex Hoppen
96cb75608c Merge pull request #36165 from ahoppen/pr/dont-ref-count-rawsyntax
[libSyntax] Don't reference count RawSyntax
2021-03-02 17:40:17 +01:00
Alex Hoppen
28f5f79bb7 [libSyntax] Don't reference count RawSyntax
Instead, only reference count the SyntaxArena that the RawSyntax nodes
live in. The user of RawSyntax nodes must guarantee that the SyntaxArena
stays alive as long as the RawSyntax nodes are being accessed.

During parse time, the SyntaxTreeCreator holds on to the SyntaxArena
in which it creates RawSyntax nodes. When inspecting a syntax tree,
the root SyntaxData node keeps the SyntaxArena alive. The change should
be mostly invisible to the users of the public libSyntax API.

This change significantly decreases the overall reference-counting
overhead. Since we were not able to free individual RawSyntax nodes
anyway, performing the reference-counting on the level of the
SyntaxArena feels natural.
2021-03-01 09:43:54 +01:00
Arnold Schwaighofer
084db0d38f Revert "Merge pull request #34848 from aschwaighofer/make_prespecialization_experimental"
This reverts commit 3aec862e62, reversing
changes made to 158427bd5b.
2021-02-12 10:12:01 -08:00
Alex Hoppen
8bb1167e21 [libSyntax] Restructure RawSyntax to more closely resemble the SwiftSyntax implementation 2021-01-29 13:08:12 +01:00
Alex Hoppen
bfe0a00551 Merge pull request #35429 from ahoppen/remove-bytetree
Remove ByteTree serialization format
2021-01-15 09:28:19 +01:00
Alex Hoppen
8ec8516893 Remove ByteTree serialization format
It was originally designed for faster trasmission of syntax trees from
C++ to SwiftSyntax, but superceded by the CLibParseActions. There's no
deserializer for it anymore, so let's just remove it.
2021-01-14 20:37:49 +01:00
Slava Pestov
28e7ed03d0 AST: Remove the 'legacy' request dependency graph implementation 2021-01-08 23:17:12 -05:00
Arnold Schwaighofer
8346bf7e90 Pre-specialization: This is an experimental feature
Only enable if explicitly required.
2020-11-20 09:13:16 -08:00
Robert Widmann
9fd5918786 Swap InputFileKind for ParseInputMode
Tying InputFile to this option meant that every input that was not one of the explictly-blessed kinds was modeled as a Swift file.

With the new InputFile that infers file kinds, we no longer need CompilerInvocation::setInputKind
2020-09-11 22:28:58 -06:00
Tony Allevato
db2dd20ce6 Parse concurrency syntax when parsing for syntax-tree-only mode.
This allows the syntax parser library and SwiftSyntax to successfully
parse code using this experimental feature without requiring an API
to pass compiler flags into the parser.
2020-08-11 20:13:15 -07:00
Doug Gregor
b1802fa2eb [Concurrency] Minor fixes for parsing and syntax of 'async' 2020-07-28 22:06:18 -07:00
Hamish Knight
1ed810653c [Frontend] Remove performParseOnly
Most clients were only using it to populate the
main module with files, which is now done by
`getMainModule`. Instead, they can now just rely
on parsing happening lazily.
2020-06-08 12:44:15 -07:00
Hamish Knight
5d72c464eb [Frontend] Remove parsing option params from performParseOnly
Lift the `DisablePoundIfEvaluation` parsing option
into `LangOptions` to subsume the need for the
`EvaluateConditionals` parameter, and sink the
computation of `CanDelayBodies` down into
`createSourceFileForMainModule`.
2020-06-08 12:44:13 -07:00
Owen Voorhees
45bc578ae5 [SourceManager] Rename line and column APIs for clarity 2020-05-21 12:54:07 -05:00
Argyrios Kyrtzidis
791309155d [Parse] Fix issue with incremental re-parsing for SwiftSyntax emitting bogus parsing error
rdar://60232712
2020-03-18 16:00:04 -07:00
Argyrios Kyrtzidis
1882b50555 [libSyntax] Enhance incremental re-parsing testing to also check whether unexpected diagnostics were emitted
Enhances `swift-syntax-test` to output the parser diagnostics so we can verify that
if the incremental parse resulted in parser diagnostics, those diagnostics were also emitted during the full parse.
2020-03-18 11:52:21 -07:00
Jonas Devlieghere
b4d268e9e1 Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances in the swift repo.
2019-08-15 11:32:39 -07:00
Michael Munday
ce3aff12da [Basic] Always serialize integers in little-endian byte order
This change fixes the ExponentialGrowthAppendingBinaryByteStream
tests on big endian machines.

Force ExponentialGrowthAppendingBinaryByteStreams to use little-
endian byte order. We always used little-endian byte order anyway
and it seems very unlikely we'll need the flexibility to make the
stream big-endian in the future. The benefit of this is that we
can use portable APIs while still allowing the compiler to remove
conditional byte swaps.

Also replace writeRaw with writeInteger and make it explicitly
little-endian to make the API cleaner and more portable.
2019-07-02 11:36:58 -04:00
Saleem Abdulrasool
218b37e1bb build: rename LLVM_COMPONENT_DEPENDS
This is not a target dependency but a target link.  Name the parameter
to be less misleading.  This also makes the name identical to the LLVM
parameter.
2019-05-04 19:58:28 -07:00
Nathan Hawes
1e1025291d Add test for the SwiftSyntax tree produced when parsing '= super' in a module interface 2019-04-16 15:21:26 -07:00
Saleem Abdulrasool
dd85d79105 tools: use target_link_libraries like clang (NFC)
Rather than using the `LINK_LIBRARIES` option, use target_link_libraries
like clang does.  Because these are all host tools, there is no name
mangling done for the libraries making this a no-op change.
2018-11-16 17:43:06 -08:00
Nathan Hawes
9003d83ffe [gardening] convert ByteBasedSourceRange to CharSourceRange rather than SourceRange
The only client of the 'toSourceRange' method immediately constructs a
CharSourceRange from it, and ByteBasedSourceRange's EndLoc isn't the start of
the last token in the range (as SourceRange expects).
2018-10-11 14:36:09 -07:00
Alex Hoppen
9d9bb5377a [incrParse] Fix issue that did not report the first reparsed character as reparsed 2018-10-11 17:54:35 +02:00
Alex Hoppen
5f341999e5 Merge pull request #18905 from ahoppen/semantic-version-number
[libSyntax] Make the ByteTree protocol version consist of a major and minor component
2018-08-29 16:40:08 -07:00
Alex Hoppen
49d0d5b7a3 [libSyntax] Make the ByteTree protocol version consist of a major and minor component 2018-08-29 13:40:50 -07:00
Xi Ge
9f7e2f7610 swift-syntax-test: teach the test driver to accept RequestEvaluatorGraphVizPath. 2018-08-29 11:13:42 -07:00
Alex Hoppen
33d86d5cb6 [byteTree] Write fixed sized data using an optimized form
If we know the size of a type at compile time (like we do for all the
integer types), it is cheaper to assign the data buffer directly instead
of using a memcpy.
2018-08-24 15:27:23 -07:00
Alex Hoppen
34a89d45e2 [libSyntax] Make the ByteTree format forwards-compatible 2018-08-22 12:07:57 -07:00
Alex Hoppen
da7cdbb122 [libSyntax] Add test cases for ByteTree serialization and deserialization 2018-08-21 10:55:15 -07:00
Alex Hoppen
e9e7d5cf68 [libSyntax] Generate TokenKinds.def from gyb_syntax_support 2018-08-15 11:11:27 -07:00
swift-ci
7a25818d82 Merge remote-tracking branch 'origin/master' into master-next 2018-07-31 13:49:49 -07:00
Alex Hoppen
775beece65 [libSyntax] Add a swift token classifier for syntax highlighting 2018-07-30 14:54:43 -07:00
swift-ci
4b684e97ef Merge remote-tracking branch 'origin/master' into master-next 2018-07-25 19:29:15 -07:00
Rintaro Ishizaki
6346e9b437 [libSyntax] Fix compiler error (#18243)
Another instance of 7ad81a88b9.
2018-07-26 11:12:24 +09:00
swift-ci
879a10aa57 Merge remote-tracking branch 'origin/master' into master-next 2018-07-25 15:29:05 -07:00
Alex Hoppen
57196f8902 [libSyntax] Enable serialization of syntax trees for incremental transfer 2018-07-23 12:32:49 -07:00
swift-ci
7b5e5028b7 Merge remote-tracking branch 'origin/master' into master-next 2018-07-20 13:49:10 -07:00
swift-ci
770b29634b Merge remote-tracking branch 'origin/master' into master-next 2018-07-19 14:50:16 -07:00
Alex Hoppen
d9d5afd15a [incrParse] Refactor the test utility to be more modular
This way we can use the same core of the test utility to verify
round-tripness of incrementally transferring the syntax tree to
swiftSyntax.
2018-07-19 14:47:58 -07:00
Alex Hoppen
419ba044f1 [libSyntax] Record reused node IDs
This is cheaper than recording reused region offsets and the reused node
IDs will later be used to incrementally transfer the syntax to
SwiftSyntax.
2018-07-19 13:55:57 -07:00
swift-ci
3e0444534b Merge remote-tracking branch 'origin/master' into master-next 2018-07-19 10:49:42 -07:00
Alex Hoppen
705f5b79a2 [libSyntax] Rename getAbsolutePosition-related methods for more clarity 2018-07-19 09:15:53 -07:00
swift-ci
c4feb3611d Merge remote-tracking branch 'origin/master' into master-next 2018-07-18 17:09:20 -07:00
Alex Hoppen
7a750bf024 [libSyntax] Allow syntax cache reuse info to be passed back via SourceKit 2018-07-18 13:35:10 -07:00