This is an archive of the discontinued LLVM Phabricator instance.

[Modules] Incorrect ODR detection for unresolved using type
ClosedPublic

Authored by ChuanqiXu on Dec 15 2021, 3:21 AM.

Details

Summary

See https://github.com/llvm/llvm-project/issues/52713.
This patch is a attempt to fix bug52713.

The key reason for the bug is that isSameEntity couldn't recognize void bar(Ty) in imported module and current module as the same entity. Since the compiler thinks the Ty type in the argument in imported module and the current are different type.

I found the reason is that the isSameEntity would judge if two types are the same by comparing the addressed of their canonical type. But the Ty type in this example is UnresolvedUsingType and the canonical type of UnresolvedUsingType is always null. So that the compare result would be different always.

My solution in this patch is to not create a new UnresolvedUsingType when deserialization if there is already a canonical type in canonical declaration. I am not sure if this is proper but it runs well currently.

Diff Detail

Event Timeline

ChuanqiXu requested review of this revision.Dec 15 2021, 3:21 AM
ChuanqiXu created this revision.
ChuanqiXu edited the summary of this revision. (Show Details)Dec 15 2021, 3:22 AM
ChuanqiXu added a reviewer: rjmccall.

This seems reasonable, but I think it's probably better to just doing it in the ASTContext code (getTypeDeclTypeSlow) the same way it's done for e.g. RecordDecls with previous declarations.

ChuanqiXu updated this revision to Diff 394786.Dec 16 2021, 1:44 AM

Address comments.

rjmccall accepted this revision.Dec 16 2021, 12:06 PM

LGTM, thanks.

This revision is now accepted and ready to land.Dec 16 2021, 12:06 PM
This revision was landed with ongoing or failed builds.Dec 16 2021, 6:38 PM
This revision was automatically updated to reflect the committed changes.