[modules] Fix tracking ObjCInterfaceType decl when there are multiple definitions.
authorVolodymyr Sapsai <vsapsai@apple.com>
Fri, 24 Sep 2021 20:57:23 +0000 (13:57 -0700)
committerVolodymyr Sapsai <vsapsai@apple.com>
Thu, 21 Oct 2021 19:08:06 +0000 (12:08 -0700)
commitd9eca3320a4d8db11ad65229ef6f564d134fc894
treef0557ee64374b55c6ef446a92311db41241d0236
parent52f4922ebb7bfe5f9a6c32cf7d637b84e491526a
[modules] Fix tracking ObjCInterfaceType decl when there are multiple definitions.

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.

Differential Revision: https://reviews.llvm.org/D110452
clang/include/clang/AST/Type.h
clang/lib/AST/DeclObjC.cpp
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaLookup.cpp
clang/test/Modules/decldef.mm
clang/test/Modules/interface-diagnose-missing-import.m