@@ -137,7 +137,7 @@ namespace {
137
137
using DelayedMemberSet = llvm::SmallSetVector<const ValueDecl *, 32 >;
138
138
139
139
class ObjCPrinter : private DeclVisitor <ObjCPrinter>,
140
- private TypeVisitor<ObjCPrinter, void ,
140
+ private TypeVisitor<ObjCPrinter, void ,
141
141
Optional<OptionalTypeKind>>
142
142
{
143
143
friend ASTVisitor;
@@ -528,7 +528,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
528
528
return sel.getNumArgs () == 0 &&
529
529
sel.getSelectorPieces ().front ().str () == " init" ;
530
530
}
531
-
531
+
532
532
void printAbstractFunctionAsMethod (AbstractFunctionDecl *AFD,
533
533
bool isClassMethod,
534
534
bool isNSUIntegerSubscript = false ) {
@@ -553,7 +553,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
553
553
auto resultTy = getForeignResultType (AFD, methodTy, errorConvention);
554
554
555
555
// Constructors and methods returning DynamicSelf return
556
- // instancetype.
556
+ // instancetype.
557
557
if (isa<ConstructorDecl>(AFD) ||
558
558
(isa<FuncDecl>(AFD) && cast<FuncDecl>(AFD)->hasDynamicSelf ())) {
559
559
if (errorConvention && errorConvention->stripsResultOptionality ()) {
@@ -774,8 +774,8 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
774
774
No = false ,
775
775
Yes = true
776
776
};
777
-
778
- // / Returns \c true if anything was printed.
777
+
778
+ // / Returns \c true if anything was printed.
779
779
bool printAvailability (const Decl *D, PrintLeadingSpace printLeadingSpace =
780
780
PrintLeadingSpace::Yes) {
781
781
bool hasPrintedAnything = false ;
@@ -928,14 +928,15 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
928
928
UnqualifiedLookup::Flags::TypeLookup);
929
929
return lookup.getSingleTypeResult ();
930
930
}
931
-
931
+
932
932
TypeDecl *typeDecl = declContext->getSelfNominalTypeDecl ();
933
-
933
+
934
934
const ValueDecl *renamedDecl = nullptr ;
935
935
SmallVector<ValueDecl *, 4 > lookupResults;
936
- declContext->lookupQualified (typeDecl->getDeclaredInterfaceType (), renamedDeclName,
937
- NL_QualifiedDefault, nullptr , lookupResults);
938
-
936
+ declContext->lookupQualified (typeDecl->getDeclaredInterfaceType (),
937
+ renamedDeclName, NL_QualifiedDefault, nullptr ,
938
+ lookupResults);
939
+
939
940
if (lookupResults.size () == 1 ) {
940
941
auto candidate = lookupResults[0 ];
941
942
if (!shouldInclude (candidate))
@@ -944,40 +945,41 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
944
945
(candidate->isInstanceMember () !=
945
946
cast<ValueDecl>(D)->isInstanceMember ()))
946
947
return nullptr ;
947
-
948
+
948
949
renamedDecl = candidate;
949
950
} else {
950
951
for (auto candidate : lookupResults) {
951
952
if (!shouldInclude (candidate))
952
953
continue ;
953
-
954
+
954
955
if (candidate->getKind () != D->getKind () ||
955
956
(candidate->isInstanceMember () !=
956
957
cast<ValueDecl>(D)->isInstanceMember ()))
957
958
continue ;
958
-
959
+
959
960
if (isa<AbstractFunctionDecl>(candidate)) {
960
961
auto cParams = cast<AbstractFunctionDecl>(candidate)->getParameters ();
961
962
auto dParams = cast<AbstractFunctionDecl>(D)->getParameters ();
962
-
963
+
963
964
if (cParams->size () != dParams->size ())
964
965
continue ;
965
-
966
+
966
967
bool hasSameParameterTypes = true ;
967
968
for (auto index : indices (*cParams)) {
968
969
auto cParamsType = cParams->get (index)->getType ();
969
970
auto dParamsType = dParams->get (index)->getType ();
970
- if (!cParamsType->matchesParameter (dParamsType, TypeMatchOptions ())) {
971
+ if (!cParamsType->matchesParameter (dParamsType,
972
+ TypeMatchOptions ())) {
971
973
hasSameParameterTypes = false ;
972
974
break ;
973
975
}
974
976
}
975
-
977
+
976
978
if (!hasSameParameterTypes) {
977
979
continue ;
978
980
}
979
981
}
980
-
982
+
981
983
if (renamedDecl) {
982
984
// If we found a duplicated candidate then we would silently fail.
983
985
renamedDecl = nullptr ;
@@ -993,7 +995,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
993
995
bool includeQuotes) {
994
996
assert (!AvAttr->Rename .empty ());
995
997
996
- const swift:: ValueDecl *renamedDecl =
998
+ const ValueDecl *renamedDecl =
997
999
getRenameDecl (D, parseDeclName (AvAttr->Rename ));
998
1000
999
1001
if (renamedDecl) {
@@ -1005,7 +1007,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
1005
1007
printEncodedString (AvAttr->Rename , includeQuotes);
1006
1008
}
1007
1009
}
1008
-
1010
+
1009
1011
void printSwift3ObjCDeprecatedInference (ValueDecl *VD) {
1010
1012
const LangOptions &langOpts = M.getASTContext ().LangOpts ;
1011
1013
if (!langOpts.EnableSwift3ObjCInference ||
@@ -1514,9 +1516,9 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
1514
1516
MAP (UnsafeMutableRawPointer, " void *" , true );
1515
1517
1516
1518
Identifier ID_ObjectiveC = ctx.Id_ObjectiveC ;
1517
- specialNames[{ID_ObjectiveC, ctx.getIdentifier (" ObjCBool" )}]
1519
+ specialNames[{ID_ObjectiveC, ctx.getIdentifier (" ObjCBool" )}]
1518
1520
= { " BOOL" , false };
1519
- specialNames[{ID_ObjectiveC, ctx.getIdentifier (" Selector" )}]
1521
+ specialNames[{ID_ObjectiveC, ctx.getIdentifier (" Selector" )}]
1520
1522
= { " SEL" , true };
1521
1523
specialNames[{ID_ObjectiveC,
1522
1524
ctx.getIdentifier (
@@ -1643,7 +1645,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
1643
1645
os << clangDecl->getKindName () << " " ;
1644
1646
}
1645
1647
1646
- void visitStructType (StructType *ST,
1648
+ void visitStructType (StructType *ST,
1647
1649
Optional<OptionalTypeKind> optionalKind) {
1648
1650
const StructDecl *SD = ST->getStructOrBoundGenericStruct ();
1649
1651
@@ -1867,7 +1869,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
1867
1869
visitExistentialType (PT, optionalKind, /* isMetatype=*/ false );
1868
1870
}
1869
1871
1870
- void visitProtocolCompositionType (ProtocolCompositionType *PCT,
1872
+ void visitProtocolCompositionType (ProtocolCompositionType *PCT,
1871
1873
Optional<OptionalTypeKind> optionalKind) {
1872
1874
visitExistentialType (PCT, optionalKind, /* isMetatype=*/ false );
1873
1875
}
@@ -1878,7 +1880,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
1878
1880
visitExistentialType (instanceTy, optionalKind, /* isMetatype=*/ true );
1879
1881
}
1880
1882
1881
- void visitMetatypeType (MetatypeType *MT,
1883
+ void visitMetatypeType (MetatypeType *MT,
1882
1884
Optional<OptionalTypeKind> optionalKind) {
1883
1885
Type instanceTy = MT->getInstanceType ();
1884
1886
if (auto classTy = instanceTy->getAs <ClassType>()) {
@@ -1913,7 +1915,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
1913
1915
os << cast<clang::ObjCTypeParamDecl>(decl->getClangDecl ())->getName ();
1914
1916
printNullability (optionalKind);
1915
1917
}
1916
-
1918
+
1917
1919
void printFunctionType (FunctionType *FT, char pointerSigil,
1918
1920
Optional<OptionalTypeKind> optionalKind) {
1919
1921
visitPart (FT->getResult (), OTK_None);
@@ -1922,7 +1924,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
1922
1924
openFunctionTypes.push_back (FT);
1923
1925
}
1924
1926
1925
- void visitFunctionType (FunctionType *FT,
1927
+ void visitFunctionType (FunctionType *FT,
1926
1928
Optional<OptionalTypeKind> optionalKind) {
1927
1929
switch (FT->getRepresentation ()) {
1928
1930
case AnyFunctionType::Representation::Thin:
@@ -1966,18 +1968,18 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
1966
1968
visitPart (PT->getSinglyDesugaredType (), optionalKind);
1967
1969
}
1968
1970
1969
- void visitSyntaxSugarType (SyntaxSugarType *SST,
1971
+ void visitSyntaxSugarType (SyntaxSugarType *SST,
1970
1972
Optional<OptionalTypeKind> optionalKind) {
1971
1973
visitPart (SST->getSinglyDesugaredType (), optionalKind);
1972
1974
}
1973
1975
1974
- void visitDynamicSelfType (DynamicSelfType *DST,
1976
+ void visitDynamicSelfType (DynamicSelfType *DST,
1975
1977
Optional<OptionalTypeKind> optionalKind) {
1976
1978
printNullability (optionalKind, NullabilityPrintKind::ContextSensitive);
1977
1979
os << " instancetype" ;
1978
1980
}
1979
1981
1980
- void visitReferenceStorageType (ReferenceStorageType *RST,
1982
+ void visitReferenceStorageType (ReferenceStorageType *RST,
1981
1983
Optional<OptionalTypeKind> optionalKind) {
1982
1984
visitPart (RST->getReferentType (), optionalKind);
1983
1985
}
@@ -2015,7 +2017,7 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
2015
2017
// / finishFunctionType()). If only a part of a type is being printed, use
2016
2018
// / visitPart().
2017
2019
public:
2018
- void print (Type ty, Optional<OptionalTypeKind> optionalKind,
2020
+ void print (Type ty, Optional<OptionalTypeKind> optionalKind,
2019
2021
Identifier name = Identifier(),
2020
2022
IsFunctionParam_t isFuncParam = IsNotFunctionParam) {
2021
2023
PrettyStackTraceType trace (M.getASTContext (), " printing" , ty);
@@ -2867,9 +2869,9 @@ class ModuleWriter {
2867
2869
// FIXME: This will end up taking linear time.
2868
2870
auto lhsMembers = cast<ExtensionDecl>(*lhs)->getMembers ();
2869
2871
auto rhsMembers = cast<ExtensionDecl>(*rhs)->getMembers ();
2870
- unsigned numLHSMembers = std::distance (lhsMembers.begin (),
2872
+ unsigned numLHSMembers = std::distance (lhsMembers.begin (),
2871
2873
lhsMembers.end ());
2872
- unsigned numRHSMembers = std::distance (rhsMembers.begin (),
2874
+ unsigned numRHSMembers = std::distance (rhsMembers.begin (),
2873
2875
rhsMembers.end ());
2874
2876
if (numLHSMembers != numRHSMembers)
2875
2877
return numLHSMembers < numRHSMembers ? Descending : Ascending;
0 commit comments