@@ -49,81 +49,6 @@ static bool usesTypeMatching(Decl *decl, llvm::function_ref<bool(Type)> fn) {
4949#define UNINTERESTING_FEATURE (FeatureName ) \
5050 static bool usesFeature##FeatureName(Decl *decl) { return false ; }
5151
52- static bool usesFeatureRethrowsProtocol (Decl *decl,
53- SmallPtrSet<Decl *, 16 > &checked) {
54- // Make sure we don't recurse.
55- if (!checked.insert (decl).second )
56- return false ;
57-
58- // Check an inheritance clause for a marker protocol.
59- auto checkInherited = [&](InheritedTypes inherited) -> bool {
60- for (unsigned i : inherited.getIndices ()) {
61- if (auto inheritedType = inherited.getResolvedType (i)) {
62- if (inheritedType->isExistentialType ()) {
63- auto layout = inheritedType->getExistentialLayout ();
64- for (ProtocolDecl *proto : layout.getProtocols ()) {
65- if (usesFeatureRethrowsProtocol (proto, checked))
66- return true ;
67- }
68- }
69- }
70- }
71-
72- return false ;
73- };
74-
75- if (auto nominal = dyn_cast<NominalTypeDecl>(decl)) {
76- if (checkInherited (nominal->getInherited ()))
77- return true ;
78- }
79-
80- if (auto proto = dyn_cast<ProtocolDecl>(decl)) {
81- if (proto->getAttrs ().hasAttribute <AtRethrowsAttr>())
82- return true ;
83- }
84-
85- if (auto ext = dyn_cast<ExtensionDecl>(decl)) {
86- if (auto nominal = ext->getSelfNominalTypeDecl ())
87- if (usesFeatureRethrowsProtocol (nominal, checked))
88- return true ;
89-
90- if (checkInherited (ext->getInherited ()))
91- return true ;
92- }
93-
94- if (auto genericSig =
95- decl->getInnermostDeclContext ()->getGenericSignatureOfContext ()) {
96- for (const auto &req : genericSig.getRequirements ()) {
97- if (req.getKind () == RequirementKind::Conformance &&
98- usesFeatureRethrowsProtocol (req.getProtocolDecl (), checked))
99- return true ;
100- }
101- }
102-
103- if (auto value = dyn_cast<ValueDecl>(decl)) {
104- if (Type type = value->getInterfaceType ()) {
105- bool hasRethrowsProtocol = type.findIf ([&](Type type) {
106- if (auto nominal = type->getAnyNominal ()) {
107- if (usesFeatureRethrowsProtocol (nominal, checked))
108- return true ;
109- }
110-
111- return false ;
112- });
113-
114- if (hasRethrowsProtocol)
115- return true ;
116- }
117- }
118-
119- return false ;
120- }
121-
122- static bool usesFeatureRethrowsProtocol (Decl *decl) {
123- SmallPtrSet<Decl *, 16 > checked;
124- return usesFeatureRethrowsProtocol (decl, checked);
125- }
126-
12752static bool usesFeatureNewCxxMethodSafetyHeuristics (Decl *decl) {
12853 return decl->hasClangNode ();
12954}
0 commit comments