Commit Graph

37 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
893a30ebbb Update availability attribute printing
The new clang implements “P2361 Unevaluated string literals”, which means it rejects numeric escapes in string literals in attributes (most notably for Swift, availability attributes). Update PrintAsClang to follow these new rules when it prints availability attributes. In the case of control characters which cannot be otherwise represented, this means Swift will print a hex code for the user to read.

Fixes rdar://127263671.
2024-07-24 13:40:39 -07:00
Josh Soref
b2c6da3acb spelling: replaceable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-11-07 07:52:30 -05:00
Josh Soref
31b4c9b14c spelling: difference
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-11-07 07:52:30 -05:00
Pitiphong Phongpattranont
08204efd5b Losen the test for the initizlier in the Subclass since it’s unavailable on some platforms and won’t be printed 2018-12-18 23:56:10 +07:00
Pitiphong Phongpattranont
7a9bca939e Added: Overloaded initializer test cases 2018-12-14 15:00:22 +07:00
Pitiphong Phongpattranont
25d74fefe3 Remove duplicated test case 2018-12-13 12:16:58 +07:00
Pitiphong Phongpattranont
7b76115788 Remove the parent/sub type lookup logic 2018-12-13 12:16:58 +07:00
Pitiphong Phongpattranont
4f88e31d63 Add more test case for the case of renamed methods have a parameter which is a superclass of itself 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
c23230c1e7 Revert part of the Follow the base type to follow only in its own superclasses 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
293d3d1033 Find the renamed overloading method by looking at the type of method parameters 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
a505202e6d Follow the base type if the renamed attribute is point to another type 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
0a29962d51 Added: Test cases for the platform deprecation, unavailable and platform unavailable PrintAsObjC 2018-07-27 00:13:37 +07:00
Pitiphong Phongpattranont
1cdbe33892 Added: renaming to a method that does not have a custom Objective-C name test case 2018-07-24 14:14:36 +07:00
Pitiphong Phongpattranont
c71a34019f Added: Test case for the renamed to one of the overload methods which have a differnce ObjC names case 2018-07-24 14:03:11 +07:00
Pitiphong Phongpattranont
f99027db3b Added: Renames of deprecated methods to properties or properties to methods and vice versa 2018-07-24 10:58:29 +07:00
Pitiphong Phongpattranont
18d71d5424 Added: renaming to a method that is not exposed to Objective-C 2018-07-24 10:50:03 +07:00
Pitiphong Phongpattranont
2067935b00 Use the CHECK-SAME where appropriate and update some ObjC names 2018-07-24 08:56:29 +07:00
Pitiphong Phongpattranont
db0eafe93f Added: Test case for the case where the renamed method is class method not instance method and vice versa 2018-07-22 00:08:56 +07:00
Pitiphong Phongpattranont
59b39bce02 Added: Test case for the case where the renamed method is class method not instance method 2018-07-21 22:48:50 +07:00
Pitiphong Phongpattranont
8837ca0dd2 Added: Test case for the renamed to one of the initializer case 2018-07-21 22:40:48 +07:00
Pitiphong Phongpattranont
b6cd6bf24e Added: Test case for the renamed to one of the overload methods case 2018-07-21 22:14:21 +07:00
Pitiphong Phongpattranont
dc3b7804bb Added: Test for the class and protocol cases for the PrintAsObjC availability 2018-07-21 17:40:41 +07:00
Pitiphong Phongpattranont
12d0024188 Reserve the white spaces 2018-07-21 17:40:41 +07:00
Pitiphong Phongpattranont
5b247c78b3 Added: More test cases for the PrintAsObjC availability 2018-07-21 17:40:41 +07:00
Pitiphong Phongpattranont
d0801890ec Use the custom @objc name in the Availablity attributes when generates the ObjC header 2018-07-21 17:40:41 +07:00
Slava Pestov
5964c00091 Migrate PrintAsObjC tests to Swift 4
I didn't migrate test/PrintAsObjC/versioned.swift, because it
explicitly checks the Swift 3 projection of some APIs.
2018-06-26 16:57:04 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Saleem Abdulrasool
b67d5f0cf7 test: convert rm -rf && mkdir -p into %empty-directory
This converts the instances of the pattern for which we have a proper
substitution in lit.  This will make it easier to replace it
appropriately with Windows equivalents.
2018-03-06 14:30:54 -08:00
Tapan Thaker
bb6db49f80 [PrintAsObjC] Fixes [SR-6884]. Prints availability information for properties. (#14561) 2018-02-13 18:09:29 -08:00
Jordan Rose
9a9ea6915f [PrintAsObjC] Downgrade +new unavailability to deprecation in Swift 4
The general policy has been that even if something crashes at run
time, we don't make it a hard error in Swift 4 mode (or Swift 3 mode!)
if it wasn't a hard error in Swift 4.0 (3.0). In this case, we thought
we could get away with it, and then it turns out it actually caused
some problems. (And as 2bc010681 shows, we can still make mistakes.)

This change isn't perfect because the diagnostic appears in /clients/
rather than in the module that's being compiled as Swift 4 (instead of
Swift 5). But it still means that someone who hasn't changed
/anything/ from a valid Swift 4.0 project will be able to compile
without any changes, even if they were relying on being able to call
+new when -init was unavailable for some reason.

More rdar://problem/35942058
2017-12-13 17:59:55 -08:00
Jordan Rose
7493eccaa9 [PrintAsObjC] Include a message when making +new unavailable
Another follow-up to 49c65facc9. We've seen a few people run into
this and not know what changed.

rdar://problem/35942058
2017-12-13 17:59:55 -08:00
Javier Soto
49c65facc9 [PrintAsObjC] Attempt at fixing SR-5018: marking +new unavailable when -init is unavailable.
Currently a loop-hole exists by which one could end up invoking an unavailable -init initializer from Obj-C
when it is unavailable by using +new (which itself calls -init)

https://bugs.swift.org/browse/SR-5018
2017-10-05 16:54:55 -07:00
Jordan Rose
0a2e8eb452 [PrintAsObjC] Include messages for platform always-unavailable decls.
A misplaced brace left the messages in empty space. Noticed by
inspection.
2017-08-08 17:25:04 -07:00
Jordan Rose
191e2767ab [PrintAsObjC] Print availability on classes, protocols, and categories
Now that Clang has availability diagnostics too
(-Wpartial-availability and friends) we need to get this correct, or
people will get warnings in the generated header!

rdar://problem/33313703
2017-08-08 17:25:04 -07:00
Doug Gregor
80e9491fe3 Make Swift-3-inferred @objc explicit in test cases 2017-03-31 21:22:15 -07:00
Kevin Ballard
0aa751d228 [PrintAsObjC] Add availability attributes to Obj-C declarations 2017-01-04 11:43:00 -08:00