Commit Graph

94 Commits

Author SHA1 Message Date
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
a55094ab81 [CodeCompletion] Update IDE tests for clang importer changes
rdar://problem/58495781
2020-01-13 13:50:51 -08:00
Xi Ge
cc395e792c SourceKit/InterfaceGen: sanitize Clang-specific doc-comment style when printing headers as Swift interface
rdar://47985888
2019-03-11 14:16:45 -07:00
Saleem Abdulrasool
0a4bce94ea test: improve IDE test coverage for Windows
This improves the test pass rate for the IDE tests on Windows.  Some
failures remain.  Tests which expect the compiler to be built with
libxml2 cause 2 failures.  Another set of tests fail due to `stdint.h`
not being accessible to Windows due to include path ordering.  Some
other failures seem to stem from incomplete processing of sources.
2019-01-17 16:58:10 -08:00
Doug Gregor
f39fe1a755 [Tests] Put NSObject Equatable/Hashable back in the ObjectiveC module.
Technically, these operations belong in the ObjectiveC module, where NSObject
is defined. Keep them there. However, we need to build the mock ObjectiveC
overlay with `-disable-objc-attr-requires-foundation-module` now.
2018-08-01 09:25:28 -07:00
Saleem Abdulrasool
8b21fdee96 SILGen: enable additional tests globally
Enable a number of SILGen tests to run on all targets.  This improves
coverage on non-Darwin targets.
2018-06-11 09:23:22 -07:00
Doug Gregor
b0fc56d8ff [Clang importer] Honor swift_bridged_typedef attribute.
When the swift_bridged_typedef attribute is present on a typedef,
import the underlying type as bridged (e.g., String) rather than as
its unbridged type (e.g., NSString).

Fixes rdar://problem/39497900.
2018-04-27 17:02:58 -07:00
Davide Italiano
64dfc22fb1 [IDE] XFAIL some tests on FreeBSD. They're broken on non-mac OS. 2017-11-19 15:24:16 -08:00
Slava Pestov
405b641246 ClangImporter: Synthesize typealiases instead of relying on associated type inference
Right now the ClangImporter relies on Sema to synthesize typealiases
in some cases, which doesn't work if a Sema instance is not available,
for example when the ClangImporter is asked to import a declaration
while deserializing SIL during optimization.

Begin addressing this by synthesizing typealiases for the following
conformances:

- ExpressibleByArrayLiteral.ArrayLiteralElement while importing
  OptionSets.

- RawRepresentable.RawValue while importing raw-valued enums.

- ObjectiveCBridgeable._ObjectiveCType while importing bridged
  newtypes.

Until further changes land, this is mostly NFC, except for a change
in generated interface printing where the new typealiases are now
explicitly shown.

Note that non-bridged newtypes whose raw type is ObjectiveCBridgeable
still rely on associated type inference, because the ClangImporter
cannot safely "copy" the _ObjectiveCType typealias from the raw type
to the newtype, for various reasons mostly having to do with
circularity. Subsequent patches will address this, in a rather novel
fashion that will shock you.
2017-09-07 00:30:44 -07:00
Doug Gregor
6a26f5f044 [Clang importer/module printing] Correctly print NS_ERROR_ENUMs.
Ever since we stopped associating the top-level struct of an imported
NS_ERROR_ENUM with the Clang enum declaration, we've been unable to
print imported NS_ERROR_ENUMs. The module-printing infrastructure
would drop them thinking they aren't imported declarations.

This also affected NS_ERROR_ENUMs that were imported as members of
another type, as well as other types imported as members.

Fixes rdar://problem/32497693.
2017-06-27 17:01:29 -07:00
Dmitri Gribenko
984210aa53 tests: replace '// RUN: rm -rf' '// RUN: mkdir' pairs with '%empty-directory(...)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Doug Gregor
940af98e4a [Clang importer] Synthesize Element typealias for OptionSet types.
Rather than requiring associated type witness inference to go and
figure out the Element type from the other witnesses for imported
OptionSet types, synthesize the typealias directly in the
importer. This is a simplification and a performance optimization.
2017-04-13 15:49:34 -07:00
Doug Gregor
3e5b191ad9 [Clang importer] Synthesize RawValue typealias for RawRepresentable.
Rather than requiring associated type witness inference to go and
figure out the RawValue type from the rawValue witnesses for imported,
RawRepresentable types, synthesize the typealias directly in the
importer. This is a simplification and a performance optimization.
2017-04-13 15:49:34 -07:00
Jordan Rose
1432f84929 [ASTPrinter] Stop skipping unavailable-in-Swift-version decls. (#8181)
We already have an option to skip /all/ unavailable decls. Singling
out the ones that are specifically unavailable-in-Swift just makes
testing harder.

This will not affect interface generation in Xcode, which sets that
option to skip all unavailable decls.
2017-03-20 11:48:50 -07:00
Michael Ilseman
8923a12585 [ASTPrinter] Switch to new ParameterTypeFlags
Switch printing off of using Function's ExtInfo for autoclosure and
escaping, and onto the ParameterTypeFlags, which let us do precise and
accurate context-sensitive printing of these parameter type
attributes. This fixes a huge list of issues where we were printing
@escaping for things like optional ObjC completion handlers, among
many others. We now correctly print @escaping in more places, and
don't print it when it's not correct.

Also updates the dumper to be consistent and give a good view of the
AST as represented in memory. Tests updated, more involved testing
coming soon.
2016-09-22 12:24:02 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Jordan Rose
b5aca663bc [ClangImporter] Remove importer-based NS stripping. (#3880)
* [ClangImporter] Remove importer-based NS stripping.

As Tony puts it, in the end we wound up with more Foundation
declarations imported as members or keeping "NS" than those that
dropped it, and any further decisions will be made on a case-by-case
basis. Move all of the existing cases of prefix-stripping into
Foundation's API notes and drop the logic from the compiler.

Tested by dumping the generated interface for Foundation and its
submodules for both macOS and the iOS simulator, and comparing the
results. A few cases did slip through here because of the interaction
between "SwiftName" and "Availability: nonswift".

The next commit will re-add "NS" to some stragglers that we missed.

rdar://problem/26880017

* APINotes: Add "NS" back to a few types.

NSKeyedUnarchiverDelegate
NSKeyedArchiverDelegate
NSTextCheckingTypes
NSBinarySearchingOptions
NSEnumerationOptions
NSSortOptions

More rdar://problem/26880017

* Remove now-redundant SwiftNames from API notes.

No change observed in the generated interface of Foundation and its
submodules.

Finishes rdar://problem/26880017.
2016-08-01 20:54:26 -07:00
Michael Ilseman
c37751ae96 [noescape by defaul] make noescape the default
This flips the switch to have @noescape be the default semantics for
function types in argument positions, for everything except property
setters. Property setters are naturally escaping, so they keep their
escaping-by-default behavior.

Adds contentual printing, and updates the test cases.

There is some further (non-source-breaking) work to be done for
SE-0103:

- We need the withoutActuallyEscaping function
- Improve diagnostics and QoI to at least @noescape's standards
- Deprecate / drop @noescape, right now we allow it
- Update internal code completion printing to be contextual
- Add more tests to explore tricky corner cases
- Small regressions in fixits in attr/attr_availability.swift
2016-07-29 13:49:08 -07:00
Joe Groff
5cef9eacca Update IDE tests for id-as-Any. 2016-07-25 06:40:34 -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
Doug Gregor
2477206ed4 [Clang importer] Mark discardableResult attribute "implicit".
The Clang importer implicitly synthesizes @discardableResult for
nearly all imported functions. Printing this attribute in the
generated interface leads to a lot of noise. Mark it as implicit so we
don't print it.
2016-04-26 14:48:39 -07:00
Trent Nadeau
8a55e428f4 Imported C decls w/o warn_unused_result get @discardableResult 2016-04-13 00:39:07 +00:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Doug Gregor
de7c559d16 [Clang importer] Don't form types that refer to unavailable typealiases.
If a particular typealias is unavailable in Swift, don't form types
that reference that typealias. Use the underlying type instead.
Fixes rdar://problem/25450337.
2016-03-30 23:37:58 -07:00
Xi Ge
56673bdaf2 [Test] Update test due to recent Clang option set change. 2016-03-25 15:05:35 -07:00
Daniel Duan
7cabf3555b [Parser] update test for SE-0040 changes 2016-03-11 16:01:37 -08:00
Max Moiseev
3a3984877a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-15 15:43:34 -08:00
Doug Gregor
8674f9d318 [Clang importer] Enable inference of default arguments by default 2016-01-06 16:36:36 -08:00
Maxim Moiseev
0e0191380a OptionSetType => OptionSet 2015-12-10 14:58:24 -08:00
Xi Ge
1d973cc615 [test] Make sure member completion recognizes useful '@' commands. 2015-11-12 10:53:43 -08:00
Xi Ge
22ba61bea1 Reapply "[CodeComplete] Teach code completion engine to recognize and manifest @recommended and @recommendedover." after fixing a linux failure. (thanks, Dmitri) 2015-11-09 16:36:25 -08:00
Xi Ge
0a82a6fa41 Revert "[CodeComplete] Teach code completion engine to recognize and manifest @recommended and @recommendedover."
This reverts commit 448a23c9af for failing linux bots.
2015-11-06 19:06:45 -08:00
Xi Ge
448a23c9af [CodeComplete] Teach code completion engine to recognize and manifest @recommended and @recommendedover.
Similar with @keyword, manifesting @recommended and @recommendedover content in code
completion results can help IDE users to choose the right API in the long candidate list.
This commit extract these two attributes from Clang doc comments and insert/cache them in
code completion results.

rdar://23101030 and rdar://23101029
2015-11-06 18:11:17 -08:00
Xi Ge
c022c9925c [CodeComplete] Start to support keyword-based code completion. rdar://23101032
Conventionally, code completion results are matched with user input solely by
names. However, names are limited in expressiveness. From this comments, we start to
decorate code completion results with @keywords fields extracted from Clang doc comments.
These fields are added by API authors to comment the decl with information that
is not manifested clear enough through names. Code completion users' typing of the
keyword leads to the corresponding code completion results being selected as well.
Keywords can be arbitrarily long and can be multiple.

For instance, a function called "index()" has "@keyword find" in its doc comment.
Users' typing of "find" leads to "index()" being selected in the code completion list.
2015-11-05 15:36:55 -08:00
Dmitri Hrybenko
89a87c3c65 Revert "[test] Disable/remove tests that rely on iterating over all Clang macros."
...and add one extra check for invalid macro info.

This reinstates the tests that were disabled in my previous commit, now that the
Clang issue has been fixed.

Finishes rdar://problem/21480635.

Patch by Jordan Rose.

Swift SVN r29705
2015-06-25 22:01:44 +00:00
Dmitri Hrybenko
30bedf8d6f [test] Disable/remove tests that rely on iterating over all Clang macros.
This was broken in upstream Clang (LLVM PR23929). When it's fixed, this commit
should be reverted to restore all the disabled tests. See rdar://problem/21480635.

Patch by Jordan Rose.

Swift SVN r29704
2015-06-25 22:01:43 +00:00
Jordan Rose
5619b5dd44 [apinotes] Remove information that has been migrated into the SDKs.
I'll be filing Radars for the rest of these. (Some of them already have them.)

rdar://problem/19003559&19756368&20276854

Swift SVN r29324
2015-06-05 23:02:17 +00:00
Joe Groff
32fb006386 Clang Importer: Enable OptionSetType import.
Update the tests to match.

Swift SVN r28906
2015-05-22 05:47:37 +00:00
Ted Kremenek
62feb5c949 Change @availability to @available.
This came out of today's language review meeting.
The intent is to match #available with the attribute
that describes availability.

This is a divergence from Objective-C.

Swift SVN r28484
2015-05-12 20:06:13 +00:00
Doug Gregor
793b3326af Implement the new rules for argument label defaults.
The rule changes are as follows:
  * All functions (introduced with the 'func' keyword) have argument
  labels for arguments beyond the first, by default. Methods are no
  longer special in this regard.
  * The presence of a default argument no longer implies an argument
  label.

The actual changes to the parser and printer are fairly simple; the
rest of the noise is updating the standard library, overlays, tests,
etc.

With the standard library, this change is intended to be API neutral:
I've added/removed #'s and _'s as appropriate to keep the user
interface the same. If we want to separately consider using argument
labels for more free functions now that the defaults in the language
have shifted, we can tackle that separately.

Fixes rdar://problem/17218256.

Swift SVN r27704
2015-04-24 19:03:30 +00:00
Argyrios Kyrtzidis
2931543a2f Revert "XFAIL failing IDE tests while BenL investigates. rdar://20245658."
This reverts commits r26369 & r26381.
After upstream clang changes, reverted r25843 which was compensating for a previous upstream clang change.

But keep test/IDE/complete_from_clang_framework.swift disabled for further investigation, because it
seems to have some duplications in a code-completion test.

rdar://20245658&20247922

Swift SVN r26430
2015-03-23 07:24:27 +00:00
Michael Gottesman
60b02a5c46 XFAIL failing IDE tests while BenL investigates. rdar://20245658.
Swift SVN r26369
2015-03-20 22:38:47 +00:00
Argyrios Kyrtzidis
e813673dc3 [ClangImporter] Make sure that we are not importing re-declarations, after upstream
Clang change in r231424.

Also re-enable the disabled IDE tests.
rdar://20064024

Swift SVN r25843
2015-03-07 07:14:33 +00:00
Andrew Trick
4d097902bc Disable swift IDE tests pending rdar:20064024
Swift SVN r25801
2015-03-06 08:59:27 +00:00
Dmitri Hrybenko
6058d291ca CMake: allow the SDK overlay to be built separately from the compiler
and the stdandard library

rdar://19703353

Swift SVN r25139
2015-02-10 21:57:03 +00:00
Devin Coughlin
8389ca03cc [Tests] Move OS X specific availability printing tests to different file
Move the availability printing tests from IDE/print_clang_decls.swift to
IDE/print_clang_framework.swift (which is only run on OS X). This commit should unbreak
the iOS build bots, which I broke in r24973.

This commit does not address Jordan's concerns with the tests. I will do that in a latter
commit.

Swift SVN r24985
2015-02-05 01:14:58 +00:00
Devin Coughlin
af1f02e247 clang-importer: Import attributes on enum elements.
This commit updates the clang importer to import attributes on enum elements. We also
now print these attributes in ASTPrinter.

Swift SVN r24973
2015-02-04 21:17:14 +00:00
Graham Batty
83b4384fac Update test flags for linux failures and support.
Also removed the sdk 'feature' in favour of the more specific
objc_interop.

Swift SVN r24856
2015-01-30 21:31:48 +00:00
Doug Gregor
c362f5962d Add a test for the weird form of __attribute__((nonnull(indices...))).
Test from rdar://problem/19522038, which is actually about something
entirely different.

Swift SVN r24751
2015-01-27 17:06:46 +00:00
Doug Gregor
f0eec4d9d5 Don't rely on overriding nullability in Objective-C; it's banned now.
Fixes rdar://problem/19610107.

Swift SVN r24750
2015-01-27 16:52:03 +00:00