This is an archive of the discontinued LLVM Phabricator instance.

[modules] Fix marking `ObjCMethodDecl::isOverriding` when there a no overrides.
ClosedPublic

Authored by vsapsai on Nov 23 2022, 6:04 PM.

Details

Summary

Incorrect isOverriding flag triggers the assertion
!Overridden.empty() in ObjCMethodDecl::getOverriddenMethods when a
method is marked as overriding but we cannot find any overrides.

When a method is declared in a category and defined in implementation,
we don't treat it as an override because it is the same method with
a separate declaration and a definition. But with modules we can find
a method declaration both in a modular category and a non-modular category
with different memory addresses. Thus we erroneously conclude the method
is overriding. Fix by comparing canonical declarations that are the same
for equal entities coming from different modules.

rdar://92845511

Diff Detail

Event Timeline

vsapsai created this revision.Nov 23 2022, 6:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2022, 6:04 PM
Herald added a subscriber: ributzka. · View Herald Transcript
vsapsai requested review of this revision.Nov 23 2022, 6:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2022, 6:04 PM
This revision is now accepted and ready to land.Nov 24 2022, 3:56 AM

Thanks for the quick review! During the commit I will also fix the typo s/there a no overrides/there are no overrides/

clang/test/Modules/override.m
30–34

Actually, only this interface triggers the assertion. Added the rest for completeness and for better coverage.