Skip to content

Commit 6c29541

Browse files
authored
Merge pull request #29652 from slavapestov/fix-selector-conflict-regression
Sema: Fix performance regression by only checking for selector conflicts in primary files
2 parents 37655db + c59bcfa commit 6c29541

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,16 @@ void AttributeChecker::visitObjCAttr(ObjCAttr *attr) {
938938
: diag::objc_name_deinit);
939939
const_cast<ObjCAttr *>(attr)->clearName();
940940
} else {
941+
auto func = cast<AbstractFunctionDecl>(D);
942+
943+
// Trigger lazy loading of any imported members with the same selector.
944+
// This ensures we correctly diagnose selector conflicts.
945+
if (auto *CD = D->getDeclContext()->getSelfClassDecl()) {
946+
(void) CD->lookupDirect(*objcName, !func->isStatic());
947+
}
948+
941949
// We have a function. Make sure that the number of parameters
942950
// matches the "number of colons" in the name.
943-
auto func = cast<AbstractFunctionDecl>(D);
944951
auto params = func->getParameters();
945952
unsigned numParameters = params->size();
946953
if (auto CD = dyn_cast<ConstructorDecl>(func))

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,9 +1619,6 @@ void markAsObjC(ValueDecl *D, ObjCReason reason,
16191619

16201620
// Record the method in the class, if it's a member of one.
16211621
if (auto classDecl = D->getDeclContext()->getSelfClassDecl()) {
1622-
// Trigger lazy loading of any imported members with the same selector.
1623-
(void) classDecl->lookupDirect(selector, !method->isStatic());
1624-
16251622
classDecl->recordObjCMethod(method, selector);
16261623
}
16271624

0 commit comments

Comments
 (0)