@@ -776,26 +776,26 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
776
776
};
777
777
778
778
// / Returns \c true if anything was printed.
779
- bool printAvailability (
780
- const Decl *D,
781
- PrintLeadingSpace printLeadingSpace = PrintLeadingSpace::Yes) {
779
+ bool printAvailability (const Decl *D, PrintLeadingSpace printLeadingSpace =
780
+ PrintLeadingSpace::Yes) {
782
781
bool hasPrintedAnything = false ;
783
782
auto maybePrintLeadingSpace = [&] {
784
783
if (printLeadingSpace == PrintLeadingSpace::Yes || hasPrintedAnything)
785
784
os << " " ;
786
785
hasPrintedAnything = true ;
787
786
};
788
-
787
+
789
788
for (auto AvAttr : D->getAttrs ().getAttributes <AvailableAttr>()) {
790
789
if (AvAttr->Platform == PlatformKind::none) {
791
- if (AvAttr->PlatformAgnostic == PlatformAgnosticAvailabilityKind::Unavailable) {
790
+ if (AvAttr->PlatformAgnostic ==
791
+ PlatformAgnosticAvailabilityKind::Unavailable) {
792
792
// Availability for *
793
793
if (!AvAttr->Rename .empty () && isa<ValueDecl>(D)) {
794
794
// rename
795
795
maybePrintLeadingSpace ();
796
796
os << " SWIFT_UNAVAILABLE_MSG(\" '"
797
- << cast<ValueDecl>(D)->getBaseName ()
798
- << " ' has been renamed to '" ;
797
+ << cast<ValueDecl>(D)->getBaseName ()
798
+ << " ' has been renamed to '" ;
799
799
printRenameForDecl (AvAttr, cast<ValueDecl>(D), false );
800
800
os << ' \' ' ;
801
801
if (!AvAttr->Message .empty ()) {
@@ -831,46 +831,45 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
831
831
}
832
832
continue ;
833
833
}
834
-
834
+
835
835
// Availability for a specific platform
836
- if (!AvAttr->Introduced .hasValue ()
837
- && !AvAttr->Deprecated .hasValue ()
838
- && !AvAttr->Obsoleted .hasValue ()
839
- && !AvAttr->isUnconditionallyDeprecated ()
840
- && !AvAttr->isUnconditionallyUnavailable ()) {
836
+ if (!AvAttr->Introduced .hasValue () && !AvAttr->Deprecated .hasValue () &&
837
+ !AvAttr->Obsoleted .hasValue () &&
838
+ !AvAttr->isUnconditionallyDeprecated () &&
839
+ !AvAttr->isUnconditionallyUnavailable ()) {
841
840
continue ;
842
841
}
843
-
842
+
844
843
const char *plat;
845
844
switch (AvAttr->Platform ) {
846
- case PlatformKind::OSX:
847
- plat = " macos" ;
848
- break ;
849
- case PlatformKind::iOS:
850
- plat = " ios" ;
851
- break ;
852
- case PlatformKind::tvOS:
853
- plat = " tvos" ;
854
- break ;
855
- case PlatformKind::watchOS:
856
- plat = " watchos" ;
857
- break ;
858
- case PlatformKind::OSXApplicationExtension:
859
- plat = " macos_app_extension" ;
860
- break ;
861
- case PlatformKind::iOSApplicationExtension:
862
- plat = " ios_app_extension" ;
863
- break ;
864
- case PlatformKind::tvOSApplicationExtension:
865
- plat = " tvos_app_extension" ;
866
- break ;
867
- case PlatformKind::watchOSApplicationExtension:
868
- plat = " watchos_app_extension" ;
869
- break ;
870
- case PlatformKind::none:
871
- llvm_unreachable (" handled above" );
845
+ case PlatformKind::OSX:
846
+ plat = " macos" ;
847
+ break ;
848
+ case PlatformKind::iOS:
849
+ plat = " ios" ;
850
+ break ;
851
+ case PlatformKind::tvOS:
852
+ plat = " tvos" ;
853
+ break ;
854
+ case PlatformKind::watchOS:
855
+ plat = " watchos" ;
856
+ break ;
857
+ case PlatformKind::OSXApplicationExtension:
858
+ plat = " macos_app_extension" ;
859
+ break ;
860
+ case PlatformKind::iOSApplicationExtension:
861
+ plat = " ios_app_extension" ;
862
+ break ;
863
+ case PlatformKind::tvOSApplicationExtension:
864
+ plat = " tvos_app_extension" ;
865
+ break ;
866
+ case PlatformKind::watchOSApplicationExtension:
867
+ plat = " watchos_app_extension" ;
868
+ break ;
869
+ case PlatformKind::none:
870
+ llvm_unreachable (" handled above" );
872
871
}
873
-
872
+
874
873
maybePrintLeadingSpace ();
875
874
os << " SWIFT_AVAILABILITY(" << plat;
876
875
if (AvAttr->isUnconditionallyUnavailable ()) {
@@ -896,7 +895,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
896
895
}
897
896
if (!AvAttr->Rename .empty () && isa<ValueDecl>(D)) {
898
897
os << " ,message=\" '" << cast<ValueDecl>(D)->getBaseName ()
899
- << " ' has been renamed to '" ;
898
+ << " ' has been renamed to '" ;
900
899
printRenameForDecl (AvAttr, cast<ValueDecl>(D), false );
901
900
os << ' \' ' ;
902
901
if (!AvAttr->Message .empty ()) {
@@ -913,46 +912,52 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
913
912
return hasPrintedAnything;
914
913
}
915
914
916
- const ValueDecl *getRenameDecl (const ValueDecl *D, const ParsedDeclName renamedParsedDeclName) {
915
+ const ValueDecl *getRenameDecl (const ValueDecl *D,
916
+ const ParsedDeclName renamedParsedDeclName) {
917
917
auto declContext = D->getDeclContext ();
918
918
ASTContext &astContext = D->getASTContext ();
919
919
auto renamedDeclName = renamedParsedDeclName.formDeclName (astContext);
920
920
921
921
if (isa<ClassDecl>(D) || isa<ProtocolDecl>(D)) {
922
922
UnqualifiedLookup lookup (renamedDeclName.getBaseIdentifier (),
923
- declContext->getModuleScopeContext (),
924
- nullptr ,
923
+ declContext->getModuleScopeContext (), nullptr ,
925
924
SourceLoc (),
926
925
UnqualifiedLookup::Flags::TypeLookup);
927
926
return lookup.getSingleTypeResult ();
928
927
} else {
929
928
TypeDecl *typeDecl = declContext->getSelfNominalTypeDecl ();
930
929
931
930
if (!renamedParsedDeclName.ContextName .empty ()) {
932
- auto contextIdentifier = astContext.getIdentifier (renamedParsedDeclName.ContextName );
933
- UnqualifiedLookup specificTypeLookup (contextIdentifier,
934
- declContext->getModuleScopeContext (),
935
- nullptr ,
936
- SourceLoc (),
937
- UnqualifiedLookup::Flags::TypeLookup);
931
+ auto contextIdentifier =
932
+ astContext.getIdentifier (renamedParsedDeclName.ContextName );
933
+ UnqualifiedLookup specificTypeLookup (
934
+ contextIdentifier, declContext->getModuleScopeContext (), nullptr ,
935
+ SourceLoc (), UnqualifiedLookup::Flags::TypeLookup);
938
936
if (!specificTypeLookup.getSingleTypeResult ()) {
939
937
return nullptr ;
940
938
}
941
939
942
- if (typeDecl->getDeclaredInterfaceType ()->matches (specificTypeLookup.getSingleTypeResult ()->getDeclaredInterfaceType (), TypeMatchFlags::AllowOverride)) {
943
- // If the Context Name contain the name of the subclass then we would find the renamed in the superclass instead
940
+ if (typeDecl->getDeclaredInterfaceType ()->matches (
941
+ specificTypeLookup.getSingleTypeResult ()
942
+ ->getDeclaredInterfaceType (),
943
+ TypeMatchFlags::AllowOverride)) {
944
+ // If the Context Name contain the name of the subclass then we would
945
+ // find the renamed in the superclass instead
944
946
typeDecl = specificTypeLookup.getSingleTypeResult ();
945
- } else if (!specificTypeLookup.getSingleTypeResult ()->getDeclaredInterfaceType ()->matches (typeDecl->getDeclaredInterfaceType (), TypeMatchFlags::AllowOverride)) {
946
- // Failed and print the raw renamed attributed when there is no relationship between those 2 types
947
- return nullptr ;
948
- }
947
+ } else if (!specificTypeLookup.getSingleTypeResult ()
948
+ ->getDeclaredInterfaceType ()
949
+ ->matches (typeDecl->getDeclaredInterfaceType (),
950
+ TypeMatchFlags::AllowOverride)) {
951
+ // Failed and print the raw renamed attributed when there is no
952
+ // relationship between those 2 types
953
+ return nullptr ;
954
+ }
949
955
}
950
956
951
957
const ValueDecl *renamedDecl = nullptr ;
952
958
SmallVector<ValueDecl *, 4 > lookupResults;
953
- declContext->lookupQualified (
954
- typeDecl,
955
- renamedDeclName, NL_QualifiedDefault, lookupResults);
959
+ declContext->lookupQualified (typeDecl, renamedDeclName,
960
+ NL_QualifiedDefault, lookupResults);
956
961
for (auto candidate : lookupResults) {
957
962
if (!shouldInclude (candidate))
958
963
continue ;
@@ -973,7 +978,8 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
973
978
for (auto index : indices (*cParams)) {
974
979
auto cParamsType = cParams->get (index)->getType ();
975
980
auto dParamsType = dParams->get (index)->getType ();
976
- if (!cParamsType->matchesParameter (dParamsType, TypeMatchFlags::AllowOverride)) {
981
+ if (!cParamsType->matchesParameter (dParamsType,
982
+ TypeMatchFlags::AllowOverride)) {
977
983
hasSameParameterTypes = false ;
978
984
break ;
979
985
}
@@ -999,12 +1005,13 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
999
1005
bool includeQuotes) {
1000
1006
assert (!AvAttr->Rename .empty ());
1001
1007
1002
- const swift::ValueDecl * renamedDecl = getRenameDecl (D, parseDeclName (AvAttr->Rename ));
1008
+ const swift::ValueDecl *renamedDecl =
1009
+ getRenameDecl (D, parseDeclName (AvAttr->Rename ));
1003
1010
1004
1011
if (renamedDecl) {
1005
1012
SmallString<128 > scratch;
1006
- auto renamedObjCRuntimeName = renamedDecl-> getObjCRuntimeName ()
1007
- ->getString (scratch);
1013
+ auto renamedObjCRuntimeName =
1014
+ renamedDecl-> getObjCRuntimeName () ->getString (scratch);
1008
1015
printEncodedString (renamedObjCRuntimeName, includeQuotes);
1009
1016
} else {
1010
1017
printEncodedString (AvAttr->Rename , includeQuotes);
0 commit comments