Commit Graph

23 Commits

Author SHA1 Message Date
Becca Royal-Gordon
da07ff577c [PrintAsClang] Warn about unstable decl order
PrintAsClang is supposed to emit declarations in the same order regardless of the compiler’s internal state, but we have repeatedly found that our current criteria are inadequate, resulting in non-functionality-affecting changes to generated header content. Add a diagnostic that’s emitted when this happens soliciting a bug report.

Since there *should* be no cases where the compiler fails to order declarations, this diagnostic is never actually emitted. Instead, we test this change by enabling `-verify` on nearly all PrintAsClang tests to make sure they are unaffected.

This did demonstrate a missing criterion that only mattered in C++ mode: extensions that varied only in their generic signature were not sorted stably. Add a sort criterion for this.
2025-02-14 21:41:36 -08:00
Becca Royal-Gordon
0ef9b7952a [PrintAsObjC] Use NSUInteger if protocol requires
When printing an ObjC member into a header with an `Int` parameter or result, PrintAsClang would look up any imported Objective-C member it overrode to see if ClangImporter imported `NSUInteger` as `Int`, and if so, would print `NSUInteger` instead of `NSInteger`. However, it did not do the same for protocol requirements the member witnessed. Correct this oversight.

Fixes rdar://124300674.
2024-03-08 16:26:10 -08:00
Ethan Smith
d9dcf06b64 Desugar ElabroatedType in isNSUInteger if present.
Re-enable PrintAsObjC/availability-real-sdk and PrintAsObjC/override, they are now passing.
2023-05-18 15:53:47 -07:00
Erik Eckstein
286295023a tests: temporarily disable PrintAsObjC tests which are failing in rebranch
rdar://102629628
2022-12-01 15:28:14 +01: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
Dmitri Gribenko
486cab447d tests: replace 'rm -rf %t && mkdir -p %t' with '%empty-directory(%t)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Huon Wilson
1c82b7d3f5 [ClangImporter] Don't resugar NSPointer for the error out parameter of throws functions.
This breaks a cycle with a function in Foundation, but isn't a complete
fix: it will be similarly problematic if a function that can't have the
throws conversion is added.
2017-05-18 17:51:03 -07:00
Jordan Rose
33ed767933 [ClangImporter] Preserve the names of imported ObjC properties. (#6182)
This is necessary for proper working of #keyPath, as well as improving
the experience of PrintAsObjC.

rdar://problem/28543037
2017-01-10 13:37:12 -08:00
Tim Bodeit
96c964ee0d [test/PrintAsObjc] Adjust existing test cases for SWIFT_WARN_UNUSED_RESULT 2016-12-10 01:48:49 +01:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Dmitri Gribenko
55864d10cb Tests: use 'mkdir -p' 2016-09-02 21:36:45 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Joe Groff
d2e1c4a662 Update PrintAsObjC, NameBinding, attr, decl, expr tests for id-as-Any. 2016-07-25 06:40:35 -07:00
Jordan Rose
c349f35fa6 [test] More fixups for the separate overlay build, like 6d5120b.
rdar://problem/25693696
2016-04-12 19:59:56 -07: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
Kevin Ballard
66369468aa Use new-style _Nullable keywords in obj-c header
Use the keywords `_Nullable`, `_Nonnull`, and `_Null_unspecified`
instead of the older compatibility forms `__nullable`, `__nonnull`, and
`__null_unspecified`.

Part of rdar://problem/23614638
2015-12-05 19:54:27 -08:00
Jordan Rose
c8c5c643bd [ClangImporter] Also strip "WithError" like we do "AndReturnError".
A few APIs in our frameworks use "WithError" instead, even though it's not
the recommended pattern.

rdar://problem/21212613

Swift SVN r29577
2015-06-23 20:39:53 +00:00
Doug Gregor
b8ad66eb18 PrintAsObjC: Print property getter/setter names when they differ from the defaults.
We were printing getter/setter names when the property came from
Objective-C initially, which is incorrect: we should print them when
the names differ from what Objective-C would compute by default. This
finishes rdar://problem/19408726, which was mostly in place a while
ago.

Swift SVN r28783
2015-05-19 20:38:48 +00:00
Doug Gregor
75617df37d PrintAsObjC: Stop printing SWIFT_NULLABILITY(keyword).
Everyone's Clang should support nullability qualifiers now.

Swift SVN r28649
2015-05-15 23:46:46 +00:00
Doug Gregor
5de47e93dd Remove uses of getProtocols() from serialization.
NFC except for having to work around the brokenness of
-enable-source-import in more places.

Swift SVN r27979
2015-04-30 16:13:45 +00:00
Dmitri Hrybenko
f43843f25c tests: use the new substitution for the mock SDK
This is required to correctly use the mock SDK when the SDK overlay is
built and tested separately.  (Otherwise, the mock SDK might not get
used, because the overlay SDK options would expand from the
%-substitution, appear first on the command line, and shadow the mock
SDK in the search path).

Swift SVN r25185
2015-02-11 18:57:29 +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
Jordan Rose
82c8d9b3dc [PrintAsObjC] Preserve NSUInteger in overridden decls when easy to do.
If a property, method, or subscript overrides an imported property, method,
or subscript that was originally declared using NSUInteger as a property,
parameter, or return type, print the subclass's member using "NSUInteger"
in the generated header to prevent override warnings.

This doesn't handle all cases--in particular, it doesn't handle the
NSUInteger being nested inside a larger type--but it does get the easy
ones correct. I think the easiest way to be more correct would be to mark
NSUInteger-as-Int somehow using a distinct type. (Hidden attribute?
Another typealias? Not sure.)

rdar://problem/19321126

Swift SVN r24771
2015-01-28 01:37:04 +00:00