Commit Graph

915 Commits

Author SHA1 Message Date
Rintaro Ishizaki
6872f6c0cb Merge pull request #19742 from AnthonyLatsis/class-var-override-compl
[CodeCompletion][Parser] Completions for overridable static members
2019-02-26 09:52:37 -08:00
Argyrios Kyrtzidis
04992a58d1 [CMake] Provide a way to build the minimum things necessary for the syntax parser library
These changes allow to optionally perform a very fast build that is targeted to only produce the syntax parser library.
Part of addressing rdar://48153331
2019-02-23 11:31:31 -08:00
fischertony
bb9482bab5 [CodeCompletion][Parser] Completions for overridable static members 2019-02-16 16:02:06 +03:00
Bob Wilson
b0dd41b8ab [master-next] Use the new AST getBeginLoc API instead of getLocStart
The getLocStart API is deprecated and slated for removal from LLVM
very soon. Switch to use getBeginLoc instead. I did not see any uses
of the corresponding getLocEnd API.
2019-02-07 16:53:03 -08:00
Xi Ge
534ff2ce0a ASTPrinter: explicitly set SkipUnderscoredKeywords to false when printing module interface. 2019-02-06 14:51:39 -08:00
Xi Ge
c0598b9888 ASTPrinter: add an option to skip keywords with a prefix of underscore.
DocSupport will use set this flag to avoid printing __consuming, __owned, and
__shared.

rdar://47777848
2019-02-06 14:51:39 -08:00
Harlan Haskins
a61d1f6476 [ParseableInterfaces] Re-escape multi-line strings in attribute messages
Previously, we would print multi-line string literals with single quotes, which were not re-parseable. Instead, re-escape their contents and print them out escaped.
2019-01-30 17:24:48 -08:00
Harlan Haskins
dd5a6772f4 [ParseableInterfaces] Handle lazy vars
For lazy vars, we need to make public the top-level entry point, and the fact
that the lazy storage contributes to the layout of a type (if it’s fixed
layout, or if the type is not resilient.) We also shouldn’t ever print `lazy`
in a parseable interface.

Since we need to parse these identifiers, give them a new name,
`$__lazy_storage_$_{propname}`, which is parseable only in parseable interfaces
so it doesn’t conflict with other properties.
2019-01-22 11:03:12 -08:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Harlan Haskins
abbe6a8e84 [ParseableInterface] Don't print @_hasInitialValue for resilient variables 2018-12-18 10:43:49 -08:00
Harlan Haskins
917b5003d9 Merge pull request #21269 from harlanhaskins/what-does-pc-load-letter-even-mean
[ParseableInterface] Fix printing for properties with initializers and observers
2018-12-13 18:43:06 -08:00
Harlan Haskins
7fe74b2b26 [ParseableInterface] Go through pattern binding for all variables with storage
Instead of only printing through the pattern binding, and potentially missing stored properties with property observers, defer to the pattern binding for all stored properties, and print accessors if applicable while printing pattern bindings.
2018-12-13 10:15:25 -08:00
Joe Groff
89979137fc Push ArchetypeType's API down to subclasses.
And clean up code that conditionally works only with certain kinds of archetype along the way.
2018-12-12 19:45:40 -08:00
Harlan Haskins
579f0188e0 [ParseableInterface] Clarify call to print accessors for single-entry pattern bindings 2018-12-12 17:14:10 -08:00
Harlan Haskins
7123c5efdb [ParseableInterface] Guard printing var initializers
Don’t print var initializers if `Options.VarInitializers` is false.
2018-12-12 17:12:23 -08:00
Xi Ge
5da65ac704 Merge pull request #21013 from nkcsgexi/doc-support
Sourcekit/DocSupport: include fully annotated generic signatures for extension decls.
2018-12-05 18:31:29 -08:00
swift-ci
39161d5b36 Merge pull request #20600 from adrian-prantl/36032653 2018-12-05 17:01:58 -08:00
Xi Ge
93ec9901bb Sourcekit/DocSupport: avoid substituting generic types when printing where clauses. rdar://43820510
This makes the printed requirements agree with separately reported generic parameters and requirement.
2018-12-05 14:03:56 -08:00
Adrian Prantl
d63debeb60 Experimental: Extend ClangImporter to import clang modules from DWARF
When debugging Objective-C or C++ code on Darwin, the debug info
collected by dsymutil in the .dSYM bundle is entirely
self-contained. It is possible to debug a program, set breakpoints and
print variables even without having the complete original source code
or a matching SDK available. With Swift, this is currently not the
case. Even though .dSYM bundles contain the binary .swiftmodule for
all Swift modules, any Clang modules that the Swift modules depend on,
still need to be imported from source to even get basic LLDB
functionality to work. If ClangImporter fails to import a Clang
module, effectively the entire Swift module depending on it gets
poisoned.

This patch is addressing this issue by introducing a ModuleLoader that
can ask queries about Clang Decls to LLDB, since LLDB knows how to
reconstruct Clang decls from DWARF and clang -gmodules producxes full
debug info for Clang modules that is embedded into the .dSYM budle.

This initial version does not contain any advanced functionality at
all, it merely produces an empty ModuleDecl. Intertestingly, even this
is a considerable improvement over the status quo. LLDB can now print
Swift-only variables in modules with failing Clang depenecies, and
becuase of fallback mechanisms that were implemented earlier, it can
even display the contents of pure Objective-C objects that are
imported into Swift. C structs obviously don't work yet.

rdar://problem/36032653
2018-12-05 13:54:13 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Xi Ge
d620dfae5e Sourcekit/DocSupport: include fully annotated generic signatures for extension decls. rdar://40906297 2018-12-04 14:29:28 -08:00
Harlan Haskins
13453109fe [ASTPrinter] Print property observers/private(set) with @_hasStorage 2018-11-26 18:42:02 -08:00
Harlan Haskins
a1c23be91a [ParseableInterface] Standardize printing for accessors
We want to make sure we are consistent when printing accessors.
@jrose-apple and I landed on the following table for disambiguating all
the possible combinations of accessors:

\### Computed Properties

| Semantics  | Syntax                 |
|------------|------------------------|
| Read-only  | var x: T { get }       |
| Read-write | var x: T { get set }   |

\### Stored Properties

| Semantics                | Syntax                              |
|--------------------------|-------------------------------------|
| Immutable                | let x: T                            |
| Mutable (trivial setter) | var x: T                            |
| Mutable (custom setter)  | @_hasStorage var x: T { get set }   |
| Private(set)             | @_hasStorage var x: T { get }       |

This first commit enables printing @_hasStorage outside of SIL mode.
2018-11-26 18:40:37 -08:00
John McCall
5553224fd4 Support the explicit representation of self-conformances.
Big, but actually NFC because we're never actually creating them.
2018-11-15 16:42:03 -05:00
Harlan Haskins
66a61c5eca Rename @sil_stored to @_hasStorage 2018-11-12 11:32:32 -08:00
Slava Pestov
c7338d06ca AST: Remove owning addressors 2018-11-09 20:49:44 -05:00
swift-ci
4fb4cb058d Merge pull request #19618 from apple/marcrasi-static-assert 2018-11-08 21:33:35 -08:00
Jordan Rose
4d041a360a [ParseableInterface] Print protocols inherited through private protos (#20169)
In this code:

    private protocol MyProto: Hashable {}
    public struct MyStruct: MyProto {}

Being Hashable is part of MyStruct's public API, even though it's not
written explicitly. If we're not going to require people to write it
explicitly, we need to make sure it gets printed.

rdar://problem/44662501
2018-11-08 10:33:42 -08:00
Marc Rasi
bf18697b4f parsing, typechecking, and SILGen for #assert
`#assert` is a new static assertion statement that will let us write
tests for the new constant evaluation infrastructure that we are working
on. `#assert` works by lowering to a `Builtin.poundAssert` SIL
instruction. The constant evaluation infrastructure will look for these
SIL instructions, const-evaluate their conditions, and emit errors if
the conditions are non-constant or false.

This commit implements parsing, typechecking and SILGen for `#assert`.
2018-11-07 16:34:17 -08:00
Jordan Rose
0e2f74a663 [ParseableInterface] Skip extensions with non-public constraints (#20146)
There are still some issues to work out here, but this is more correct
than it was before.

rdar://problem/44662458
2018-11-07 10:41:52 -08:00
John McCall
cf511445e2 Basic support for Builtin.IntegerLiteral. 2018-10-31 18:42:34 -04:00
Mark Lacey
d8c826da15 Fix up AST printing for multiple types specified in operator decl. 2018-10-10 05:03:17 -07:00
Mark Lacey
703341239b Add support for multiple designated types for an operator declaration.
Add parsing, type checking, serialization, and deserialization support
for specifying multiple types as "designated" for operator lookup for
a given operator declaration.

The constraint solver still considers only the first type when
deciding the order to attempt the elements of a disjunction, so this
doesn't really change behavior yet.
2018-10-09 23:54:01 -07:00
Mark Lacey
5094376677 Do not restore the precedencegroup name when deserializing them.
We only need to have the identifier during type checking of operator
declarations, so we do not need to restore it from the
PrecedenceGroupDecl during deserialization. We can just use the
deserialized name from the PrecedenceGroupDecl directly if needed.

This does result in one change in behavior. When printing modules, we
previously didn't print 'DefaultPrecedence' for items that had no
precedence specified, but now we will as seen in the test update for
IDE/print_ast_tc_decls.swift.
2018-10-08 21:19:37 -07:00
Mark Lacey
36284ba377 Extend operator decls to allow any designated nominal type for lookup.
Rather than limiting this to protocols, allow any nominal type.

Rename -enable-operator-designated-protocols to
-enable-operator-designated-types to reflect the change.
2018-10-06 17:02:31 -07:00
Harlan
2c86e3249c [InterfaceGen] Print property initializers in resilient, fixed-layout types (#19619)
Augment the ASTPrinter to print the name and text of initializer expressions if
a property has an initializer and the type is @_fixed_layout and resides in a resilient module, and serialize the text for partial modules.

With this change, all .swiftinterface files in the project (except for SwiftLang) compile to swiftmodules on macOS.

rdar://43774580
rdar://43812188
2018-10-05 18:21:46 -07:00
Jordan Rose
73d5ebaad2 Rename "textual interface" to "parseable interface" (#19713)
We already have something called "module interfaces" -- it's the
generated interface view that you can see in Xcode, the interface
that's meant for developers using a library. Of course, that's also a
textual format. To reduce confusion, rename the new module stability
feature to "parseable [module] interfaces".
2018-10-04 17:49:55 -07:00
Jordan Rose
5898df0e2d [ModuleInterface] Trap when trying to print a null type (#19596)
We want to catch these bugs sooner rather than later, like the one
Harlan fixed in eb75ad8. Trapping deterministically is the best way to
do so, and it's better than generating nonsense.
2018-09-28 13:17:21 -07:00
Jordan Rose
61057b88db [ModuleInterface] Print names for @usableFromInline struct properties (#19465)
Because they weren't 'public' we were treating them as layout-only
properties and printing `var _`, but they get referenced in inlinable
functions. We need the actual name!
2018-09-26 14:57:44 -07:00
Jordan Rose
b29f010510 [ModuleInterface] Don't print extensions of internal types (#19440) 2018-09-26 14:57:23 -07:00
Harlan
2aac8863f6 [InterfaceGen] Only print 'mutating' and 'nonmutating' on accessors (#19459)
* [InterfaceGen] Only print 'mutating' and 'nonmutating' on accessors

* Add SILGen test for usage of dynamic accessors in and out of interfaces

* Add -enable-objc-interop to dynamic_accessors test
2018-09-25 23:10:52 -07:00
Harlan
8ba8222333 [InterfaceGen] Print abstract accessors in protocols (#19379)
* [InterfaceGen] Print abstract accessors in protocols

This patch slightly cleans up printing accessors and ensures we print
accessors abstractly in protocol context for textual interfaces.

It also removes some assuptions around the FunctionBody callback and
makes them more explicit.

* Print getter and setter for didSet decls

* Test _read and _modify

* Fix logic for skipping willSet/didSet

* Update 'final' test for new getter printing behavior
2018-09-20 15:43:01 -07:00
Slava Pestov
ea1ec895a8 AST: Extended types of extensions should be interface types 2018-09-20 01:20:31 -07:00
Harlan
bccca6ad1e [InterfaceGen] Don't print 'final' on accessors (#19399)
We've never allowed overriding specific accessors, and we don't
currently parse this syntax.
2018-09-19 18:53:30 -07:00
Harlan
665db876ea [InterfaceGen] Print bodies of inlinable functions in textual interfaces (#19224)
* Introduce stored inlinable function bodies

* Remove serialization changes

* [InterfaceGen] Print inlinable function bodies

* Clean up a little bit and add test

* Undo changes to InlinableText

* Add serialization and deserialization for inlinable body text

* Allow parser to parse accessor bodies in interfaces

* Fix some tests

* Fix remaining tests

* Add tests for usableFromInline decls

* Add comments

* Clean up function body printing throughout

* Add tests for subscripts

* Remove comment about subscript inlinable text

* Address some comments

* Handle lack of @objc on Linux
2018-09-14 10:23:15 -07:00
Jordan Rose
5fda0f3690 [ModuleInterface] Don't print setter access twice (#19239)
And assert from now on that people don't exclude DAK_AccessControl
without also excluding DAK_SetterAccess.
2018-09-11 09:34:02 -07:00
Mark Lacey
1e7dae3741 Merge pull request #19145 from rudkx/parse-designated-protocol
Add support for parsing designated protocols in operator declarations.
2018-09-06 22:01:02 -07:00
Slava Pestov
8801aa67d3 Merge pull request #19133 from slavapestov/access-level-cleanup
Access level cleanup
2018-09-06 16:46:40 -07:00
Harlan
ad7e1d0e67 [InterfaceGen] Print private/internal properties (#19127)
* [Interface] Print private/internal properties

All properties which contribute to the storage of a type should be
printed, and their names should be hidden from interfaces. Print them
with '_' as their name, and teach the parser to recognize these special
patterns when parsing interface files.

Partially resolves rdar://43810647

* Address review comments

* Disable accessor generation for nameless vars

* Test to ensure interface files preserve type layout

* Ignore attribute differences on Linux
2018-09-06 09:58:33 -07:00
Slava Pestov
840c97d794 AST: Remove hasAccess() checks 2018-09-05 16:45:31 -07:00