Skip to content

Commit 1d87524

Browse files
committed
[swift-ide-test] Make -skip-overrides more aggressive in its pruning.
Cope with imported protocol members as well, which pares down the size of Swift API projections considerably. Fixes rdar://problem/25223995.
1 parent e039795 commit 1d87524

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "swift/Strings.h"
4141
#include "clang/AST/ASTContext.h"
4242
#include "clang/AST/Decl.h"
43+
#include "clang/AST/DeclObjC.h"
4344
#include "clang/Basic/Module.h"
4445
#include "llvm/ADT/StringSwitch.h"
4546
#include "llvm/Support/ConvertUTF.h"
@@ -1549,6 +1550,28 @@ bool swift::shouldPrint(const Decl *D, PrintOptions &Options) {
15491550
if (auto *VD = dyn_cast<ValueDecl>(D)) {
15501551
if (VD->getOverriddenDecl()) return false;
15511552
if (!VD->getSatisfiedProtocolRequirements().empty()) return false;
1553+
1554+
if (auto clangDecl = VD->getClangDecl()) {
1555+
// If the Clang declaration is from a protocol but was mirrored into
1556+
// class or extension thereof, treat it as an override.
1557+
if (isa<clang::ObjCProtocolDecl>(clangDecl->getDeclContext()) &&
1558+
VD->getDeclContext()->getAsClassOrClassExtensionContext())
1559+
return false;
1560+
1561+
// Check whether Clang considers it an override.
1562+
if (auto objcMethod = dyn_cast<clang::ObjCMethodDecl>(clangDecl)) {
1563+
SmallVector<const clang::ObjCMethodDecl *, 4> overriddenMethods;
1564+
objcMethod->getOverriddenMethods(overriddenMethods);
1565+
if (!overriddenMethods.empty()) return false;
1566+
} else if (auto objcProperty
1567+
= dyn_cast<clang::ObjCPropertyDecl>(clangDecl)) {
1568+
if (auto getter = objcProperty->getGetterMethodDecl()) {
1569+
SmallVector<const clang::ObjCMethodDecl *, 4> overriddenMethods;
1570+
getter->getOverriddenMethods(overriddenMethods);
1571+
if (!overriddenMethods.empty()) return false;
1572+
}
1573+
}
1574+
}
15521575
}
15531576
}
15541577

0 commit comments

Comments
 (0)