[PATCH] D157114: [clang][ASTImporter] Improve StructuralEquivalence algorithm on repeated friends

Ding Fei via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 4 08:56:30 PDT 2023


danix800 created this revision.
danix800 added reviewers: balazske, steakhal, aaron.ballman, shafik, martong.
Herald added a reviewer: a.sidorin.
Herald added a project: All.
danix800 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repeated friends are deduplicated when imported, but StructuralEquivalence checks friends by exact matching.
If `ToContext` is empty (not containing the class to be imported), the imported friends are deduplicated, any
further importing of the class would be rejected at the structure equivalence checking, i.e:

  struct foo { friend class X; friend class X; }; // FromContext

only one friend is imported, similar to the following:

  struct foo { friend class X; }; // ToContext

but when imported again, `struct foo` in FromContext is reported as not equivalent to `struct foo` in `ToContext`,
thus rejected.

The structural equivalence checking algorithm is improved by applying similar deduplication as Importer does.
Thus from StructuralEquivalence's point of view, the above two `RecordDecl`s are equivalent.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157114

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157114.547230.patch
Type: text/x-patch
Size: 14962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230804/d057465b/attachment.bin>


More information about the cfe-commits mailing list