This is an archive of the discontinued LLVM Phabricator instance.

[modules] Fix tracking ObjCInterfaceType decl when there are multiple definitions.
ClosedPublic

Authored by vsapsai on Sep 24 2021, 3:59 PM.

Details

Summary

With the old approach we were updating ObjCInterfaceType.Decl to the
last encountered definition. But during loading modules
ASTDeclReader::VisitObjCInterfaceDecl keeps the *first* encountered
definition. So with multiple definitions imported there would be a
disagreement between expected definition in ObjCInterfaceType.Decl and
actual definition ObjCInterfaceDecl::getDefinition which can lead to
incorrect diagnostic.

Fix by not tracking definition in ObjCInterfaceType explicitly but by
getting it from redeclaration chain.

Partially reverted 919fc50034b44c48aae8b80283f253ec2ee17f45 keeping the
modified test case as the correct behavior is achieved in a different
way.

Diff Detail

Event Timeline

vsapsai created this revision.Sep 24 2021, 3:59 PM
vsapsai requested review of this revision.Sep 24 2021, 3:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 24 2021, 3:59 PM

This is a clean-up before https://reviews.llvm.org/D110453

clang/lib/AST/DeclObjC.cpp
608

Tracking a type per decl is complementary to tracking decl per type and it looks potentially bug-prone. But I haven't noticed any problems with it and haven't tried to remove TypeForDecl. If anybody has any extra information on it, we can schedule subsequent fixes.

Ping. Failing ORC tests seem to be unrelated, seen the same failed tests in other code reviews.

rsmith accepted this revision.Oct 19 2021, 6:41 PM
This revision is now accepted and ready to land.Oct 19 2021, 6:41 PM
vsapsai updated this revision to Diff 381130.Oct 20 2021, 6:52 PM

Rebase and trigger a new round of pre-merge checks.

vsapsai updated this revision to Diff 381313.Oct 21 2021, 10:25 AM

Another rebase and pre-merge checks.