This is an archive of the discontinued LLVM Phabricator instance.

[modules] Allow parsing a duplicate Obj-C interface if a previous one comes from a hidden [sub]module.
ClosedPublic

Authored by vsapsai on Apr 22 2022, 11:35 AM.

Details

Summary

Instead of emitting a redefinition error, check that definitions are
equivalent and allow such scenario.

A few non-obvious implementation details:

  • to avoid multiple definitions in the redeclaration chain we just drop the new definition after checking for equivalence;
  • for checking definition equivalence use ODR hash instead of ASTStructuralEquivalence because it avoids excessive recursive deserialization. Though after detecting a mismatch we do deserialize multiple entities to provide a better error message.

rdar://82908223

Diff Detail

Event Timeline

vsapsai created this revision.Apr 22 2022, 11:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2022, 11:35 AM
Herald added a subscriber: ributzka. · View Herald Transcript
vsapsai requested review of this revision.Apr 22 2022, 11:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2022, 11:35 AM
vsapsai added a subscriber: Restricted Project.Apr 22 2022, 11:36 AM

I also have a very similar change with ActOnDuplicateDefinition for ObjCProtocolDecl. If anybody is interested in how it compares with ObjCInterfaceDecl, I can publish that but it's not finished yet.

clang/lib/Parse/ParseObjc.cpp
16

I'd like to get feedback on Parser/Sema layering. I'll check myself what can be done but at the first glance accessing pieces of Sema from Parser looks questionable.

This looks good IMO. Let's see if others have more suggestions besides the Parser/Sema layering.

clang/lib/Parse/ParseObjc.cpp
16

Yeah, I think introducing new Sema::ActOnEndClassInterface() and moving the diagnostic logic there might be cleaner.

vsapsai updated this revision to Diff 483047.Dec 14 2022, 5:20 PM

Implement detecting and diagnosing duplicates during parsing based on ODR hash done during deserialization.

bruno accepted this revision.Jan 17 2023, 10:26 AM

Nice new testcase snippets, LGTM

This revision is now accepted and ready to land.Jan 17 2023, 10:26 AM

Thanks for the review, Bruno!

This revision was landed with ongoing or failed builds.Jan 20 2023, 8:18 AM
This revision was automatically updated to reflect the committed changes.