@@ -155,6 +155,25 @@ class DeclAndTypePrinter::Implementation
155
155
return owningPrinter.shouldInclude (VD);
156
156
}
157
157
158
+ bool isEmptyExtensionDecl (const ExtensionDecl *ED) {
159
+ auto members = ED->getMembers ();
160
+ auto hasMembers = std::any_of (members.begin (), members.end (),
161
+ [this ](const Decl *D) -> bool {
162
+ if (auto VD = dyn_cast<ValueDecl>(D))
163
+ if (shouldInclude (VD))
164
+ return true ;
165
+ return false ;
166
+ });
167
+
168
+ auto protocols = ED->getLocalProtocols (ConformanceLookupKind::OnlyExplicit);
169
+ auto hasProtocols = std::any_of (protocols.begin (), protocols.end (),
170
+ [this ](const ProtocolDecl *PD) -> bool {
171
+ return shouldInclude (PD);
172
+ });
173
+
174
+ return (!hasMembers && !hasProtocols);
175
+ }
176
+
158
177
private:
159
178
// / Prints a protocol adoption list: <code><NSCoding, NSCopying></code>
160
179
// /
@@ -311,25 +330,6 @@ class DeclAndTypePrinter::Implementation
311
330
os << " @end\n " ;
312
331
}
313
332
314
- bool isEmptyExtensionDecl (ExtensionDecl *ED) {
315
- auto members = ED->getMembers ();
316
- auto hasMembers = std::any_of (members.begin (), members.end (),
317
- [this ](const Decl *D) -> bool {
318
- if (auto VD = dyn_cast<ValueDecl>(D))
319
- if (shouldInclude (VD))
320
- return true ;
321
- return false ;
322
- });
323
-
324
- auto protocols = ED->getLocalProtocols (ConformanceLookupKind::OnlyExplicit);
325
- auto hasProtocols = std::any_of (protocols.begin (), protocols.end (),
326
- [this ](const ProtocolDecl *PD) -> bool {
327
- return shouldInclude (PD);
328
- });
329
-
330
- return (!hasMembers && !hasProtocols);
331
- }
332
-
333
333
void visitExtensionDecl (ExtensionDecl *ED) {
334
334
if (isEmptyExtensionDecl (ED))
335
335
return ;
@@ -2063,6 +2063,10 @@ void DeclAndTypePrinter::printAdHocCategory(
2063
2063
getImpl ().printAdHocCategory (members);
2064
2064
}
2065
2065
2066
+ bool DeclAndTypePrinter::isEmptyExtensionDecl (const ExtensionDecl *ED) {
2067
+ return getImpl ().isEmptyExtensionDecl (ED);
2068
+ }
2069
+
2066
2070
StringRef
2067
2071
DeclAndTypePrinter::maybeGetOSObjectBaseName (const clang::NamedDecl *decl) {
2068
2072
StringRef name = decl->getName ();
0 commit comments