Commit Graph

167 Commits

Author SHA1 Message Date
John Hui
b58a908082 [cxx-interop] Add Hashable conformance to imported enums (#76940)
* [cxx-interop] Add Hashable conformance to imported enums

Previously, imported enums only conformed to RawRepresentable and Equatable,
so they could not be used as members of a Set or keys of a Dictionary.
This patch adds Hashable conformance to give them that ability,
as well as some test cases to clarify the expected behavior.
Existing test cases are updated to reflect this new conformance.

rdar://129713687
2024-10-15 20:24:35 -07:00
Rintaro Ishizaki
7b3738d1d0 [SourceKit] Adjust newlines between decls
Previously, Clang modules didn't have empty lines between top-level
decls. This was inconsistent with Swift module.
2024-03-25 22:07:50 +09:00
Karoy Lorentey
4b1477cc2c [test] Update tests for new stdlib 2024-03-18 11:08:32 -07:00
Nate Chandler
367d71d74f Revert "[stdlib] Uncheck pointers' conf to BitwiseCopyable"
This reverts commit 4dc9713a7a.
2024-01-31 17:11:54 -08:00
Nate Chandler
4dc9713a7a [stdlib] Uncheck pointers' conf to BitwiseCopyable
The pitch calls for such types to obstruct inference of _BitwiseCopyable
in aggregates containing them.
2024-01-30 14:38:07 -08:00
QuietMisdreavus
60ef958116 don't break a doc comment with a regular comment (#66136)
rdar://95307936
2023-05-30 08:44:02 -06:00
Ben Barham
46d12f8b51 [InterfaceGen] Print @discardableResult in generated interfaces
Resolves rdar://58805969.
2022-11-11 18:15:35 -08:00
Slava Pestov
79ed990728 AST: Replace TupleTypeRepr's ellipsis with PackExpansionTypeRepr 2022-09-07 12:35:54 -04:00
Alex Hoppen
a7dcd4604e [SourceKit] Add an operator syntax kind
This will allow us to do semantic highlighting for operators in SourceKit-LSP.
2022-07-25 07:19:49 +02:00
Andrew Trick
689e49752b Fix SourceKit test, doc_clang_module. Remove Sendable conformance. 2021-12-06 22:10:40 -08:00
zoecarver
eeeb27d66e [cxx-interop] Add members to the LookupTable where possible.
If possible, add imported members to the StructDecl's LookupTable rather than adding them directly as members. This will fix the issues with ordering that #39436 poorly attempted to solve during IRGen.

This also allows us to break out most of the test changes from #39436.
2021-10-13 11:53:58 -07:00
Rintaro Ishizaki
6e69a44c3d [ASTPrinter] Intorduce 'IntroducerKeyword' name kind
For more fine grained annoations. For now, it's handled as the same as
'Keyword' name kind.

Fix an issue where 'extension' wasn't marked as "keyword".

Also, move 'static' priting out of 'SkipIntroducerKeywords' guard
because 'static' is not an declaration introducer.
2021-07-29 12:50:24 -07:00
Doug Gregor
9579390024 [SE-0304] Rename ConcurrentValue to Sendable 2021-03-18 22:48:20 -07:00
Doug Gregor
1a1f79c0de Introduce safety checkin for ConcurrentValue conformance.
Introduce checking of ConcurrentValue conformances:
- For structs, check that each stored property conforms to ConcurrentValue
- For enums, check that each associated value conforms to ConcurrentValue
- For classes, check that each stored property is immutable and conforms
  to ConcurrentValue

Because all of the stored properties / associated values need to be
visible for this check to work, limit ConcurrentValue conformances to
be in the same source file as the type definition.

This checking can be disabled by conforming to a new marker protocol,
UnsafeConcurrentValue, that refines ConcurrentValue.
UnsafeConcurrentValue otherwise his no specific meaning. This allows
both "I know what I'm doing" for types that manage concurrent access
themselves as well as enabling retroactive conformance, both of which
are fundamentally unsafe but also quite necessary.

The bulk of this change ended up being to the standard library, because
all conformances of standard library types to the ConcurrentValue
protocol needed to be sunk down into the standard library so they
would benefit from the checking above. There were numerous little
mistakes in the initial pass through the stsandard library types that
have now been corrected.
2021-02-04 03:45:09 -08:00
Anthony Latsis
4ce7a2d060 CodeCompletion: Annotate archetypes, generic parameters and dependent members 2020-10-27 14:39:52 +03:00
Nathan Hawes
e68ab1da8e [SourceKit/DocSupport] Don't synthesize extensions for inherited protocol conformances.
The Base class already includes them, so don't duplicate them in its
subclasses. Also stops us including members from extensions of the base class
itself.

Resolves rdar://problem/50960433
2020-07-21 11:53:06 -07:00
Daniel Duan
942893d7a6 ClangImporter: Preserve CChar type (#32692)
Addresses SR-466.
2020-07-08 10:18:58 -07:00
Nathan Hawes
51bace649b [IDE][SourceKit/DocSupport] Add members of underscored protocol extensions in extensions of conforming types.
We would previously hide the protocol, its extensions and members, but the '_'
prefix really just means the protocol itself isn't intended for clients, rather
than its members.

This also adds support for 'fully_annotated_decl' entries in doc-info for
extensions to be consistent with every other decl, and removes the
'fully_annotated_generic_signature' entry we supplied as a fallback.

Also fixes several bugs with the synthesized extensions mechanism:
- The type sustitutions applied to the extension's requirements were computed
  using the extension itself as the decl context rather than the extension's
  nominal. The meant the extension's requirements themselves were assumed to
  hold when determining the substitutions, so equality constraints were always
  met. Because of this extension members were incorrectly merged with the base
  nominal or its extensions despite having additional constraints.
- Types within the requirements weren't being transformed when printed (e.g.
  'Self.Element' was printed rather than 'T') both in the interface output and
  in the requirements list. We were also incorrectly printing requirements
  that were already satisfied once the base type was subsituted in.
- If both the protocol extension and 'enabling' extension of the base nominal
  that added the protocol conformance had conditional requirements, we were
  only printing the protocol extension's requirements in the synthesized
  extension.
- The USR and annotated decl output embedded in the 'key.doc.full_as_xml'
  string for synthesized members were printed to match their original context, rather than
  the synthesized one.

Resolves rdar://problem/57121937
2020-06-02 15:38:34 -07:00
Nathan Hawes
79247b22e2 [SourceKit][InterfaceGen] Don't print clang decls marked with the swift_private attribute.
This attribute is intended to mean there's a replacement declaration that
should be used instead in Swift code. We already filter out decls with this
attribute in code completion, but were still exposing them in generated
interfaces.

Resolves rdar://problem/62464954
2020-05-27 15:23:50 -07:00
Robert Widmann
43d1ba9ed9 [Gardening] Shepherd a Fix To SetAlgebra Docs 2020-05-14 11:50:35 -07:00
Nathan Hawes
a9aba54b42 [ASTPrinter][SourceKit] Print 'Any' as a keyword.
It's treated as a keyword by syntactic highlighting, but wasn't annotated as a
keyword by code completion, cursor info, or doc info.

Resolves rdar://problem/61114942
2020-04-28 13:35:06 -07:00
Argyrios Kyrtzidis
6219e4e8f5 [PrintOptions] Enable EnumRawValueMode::PrintObjCOnly for when generating interfaces for user consumption and for doc-support
rdar://17934156
2019-10-25 17:49:25 -07:00
Xi Ge
b8c4400267 IDE/sourcekitd: avoid printing underscored keywords in module interface view. 2019-03-14 15:33:31 -07:00
Xi Ge
1625bcfbba ASTPrinter: skip underscored keyword when printing for quick helps.
rdar://47777848
2019-03-13 17:53:51 -07:00
Devin Coughlin
b3ff2d8816 [ClangImporter] Update diagnostic to refer to "macOS" instead of "OS X" 2019-03-03 16:42:17 -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
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
Xi Ge
d620dfae5e Sourcekit/DocSupport: include fully annotated generic signatures for extension decls. rdar://40906297 2018-12-04 14:29:28 -08:00
Karoy Lorentey
811d3d710e [test] Update for RawRepresentable hashing changes 2018-11-22 17:16:07 +00:00
Ben Cohen
1c4ca23b7f Update SourceKit tests 2018-09-25 15:25:13 -07:00
Karoy Lorentey
1aaf56d6a3 [test] FooRuncingOptions.init<S>(_:) has grown an __owned modifier 2018-09-24 16:29:42 +01:00
Davide Italiano
ef46ec08fc [AST] Update tests now that we preserve sugar. 2018-09-18 09:23:02 -07:00
Jordan Rose
fa8ac95fd0 Don't print 'convenience' on protocol extension initializers (#18777)
We model them that way in the compiler, but that's not part of the
user-level language.

rdar://problem/32067077
2018-08-17 19:25:40 -07:00
Doug Gregor
e21673df9e [SourceKit] Test case fix-up because we’re not validating quite as eagerly. 2018-08-14 01:05:43 -07:00
Ben Cohen
a6952decab [stdlib] Remove inlineable annotation from transparent functions (#17800)
* Remove inlineable annotation from transparent functions
2018-07-07 08:47:02 -07:00
Doug Gregor
a66df57aaf [Mangling] Update SILGen and IRGen tests for mangling change. 2018-06-19 23:24:38 -07:00
Robert Widmann
7d82e70f2c Excise getInput() from printing
Not NFC because it changes the printing behavior for function type
parameters.  They are no longer reported as types (paren, tuple, or raw),
but as Params.
2018-06-10 19:40:26 -07:00
Slava Pestov
392a5c2bcb AST: @usableFromInline and @inlinable are no longer user inaccessible 2018-04-26 22:58:56 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Doug Gregor
9cfbd30215 Update SourceKit test's expected output for sugaring changes. 2018-03-25 21:35:16 -07:00
Xi Ge
98570550c3 [SourceKit] Report synthesized protocol conformances for DocSupport request. rdar://36882292 (#14248) 2018-01-30 13:32:50 -08:00
Jordan Rose
59b5e2ec0d Mangle an anonymous C enum using its enclosing typedef, like C++ does
Without this, we would fall back to a Swift name even for C types that
we can expect to have stable names for linkage purposes.
2018-01-10 15:38:07 -08:00
Jordan Rose
18689fe223 [Mangling] Uniformly use "So" for imported decls.
...and repurpose "SC" for (C)lang-importer-synthesized decls, instead
of just decls that are C-like instead of ObjC-like. (See next commits.)
2018-01-09 17:55:23 -08:00
Pavel Yaskevich
533171debf [Mangling/ABI] NFC: Fix SourceKit tests to reflect label mangling changes 2017-12-18 15:45:50 -08:00
Argyrios Kyrtzidis
9093dd7528 [test/SourceKit] Re-enable and update tests after recent stdlib changes
rdar://35799113
2017-12-05 10:23:14 -08:00
John Fairhurst
388fffcc35 [SourceKit] XML-escape swift declarations from clang modules 2017-12-04 12:48:20 -08:00
Nathan Hawes
01e538951f [SourceKit][DocInfo] Avoid outputing identifier annotations for ranges already covered by parameter/argument annotations
Resolves rdar://problem/20799943
2017-11-16 18:25:03 -08:00
Nathan Hawes
7403e779ad [ASTWalker|Refactoring] Walk generic params and requirements in source order for subscript decls
Also handle requirements in non-trailing where clauses (for -swift-version 3)
Resolves rdar://problem/34859742
2017-11-16 16:02:12 -08:00
Pavel Yaskevich
8f26fb88d4 [Mangling] Improve handling of the variadic function parameters
Currently when function types like `(_: Int...) -> Void` are mangled
their names are going to include enclosing sugar BoundGenericType(Array),
which is not necessary and doesn’t play well with `AnyFunctionType::Param`
which strips the sugar away.

Resolves: rdar://problem/34941557
2017-10-17 00:16:12 -07:00
Doug Gregor
6e6b6b9837 [Mangler] Only mangle new requirements for constrained extensions.
Rather than mangling the complete generic signature of a constrained
extension, only mangle the requirements not already satisfied by the
nominal type. For example, given:

    extension Dictionary where Value: Equatable {
      // OLD: _T0s10DictionaryV2t3s8HashableRzs9EquatableR_r0_lE3baryyF
      // NEW: _T0s10DictionaryV2t3s9EquatableR_rlE3baryyF
      public func bar() { }
   }

In the existing mangling, we mangle the `Key: Hashable` requirement that’s
part of the generic signature. With this change, we only mangle the new
requirement (`Value: Equatable`).

This is a win for constrained extensions *except* in the case of a
constrained extension of a nominal type with a single, unconstrained
generic parameter:

    extension Array where Element: Equatable {
      // OLD: _T0Sa2t3s9EquatableRzlE3baryyF
      // NEW would be: _T0Sa2t3s9EquatableRzrlE3baryyF
      public func bar() { }
    }

Check explicily for this shortcut mangling and fall back to the old
path, so this change is a strict improvement.
2017-10-11 19:23:58 -07:00