[PATCH] D62131: [ASTImporter] Remove NonEquivalentDecls from ASTImporter

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 21 05:36:49 PDT 2019


balazske added a comment.

Example about how to get wrong things into `NonEquivalentDecls`:
We want to compare `class C` for structural equivalence in the following codes:

  class A {}; class B {int i;}; void x(A *); void y(A *); class C { friend void x(A *); friend void y(A *); };

and

  class A {}; class B {int i;}; void x(A *); void y(B *); class C { friend void x(A *); friend void y(B *); };

The result is false for `C` but the `NonEquivalentDecls` will contain after the compare a `void x(A*)`<->`void x(A*)` pair.

The reason is that during the check we encounter first a `A`<->`B` pair (iterating over the friends and friend functions, first `y` is encountered and a check for `A` and `B` follows). The `B` is recorded as "tentative equivalence" to `A`. Then we try to check `A` to `A` (during check of `x`) but because there is a "tentative equivalence" with `B` from `A` the check returns false (not equivalent). This false result is recorded as a (incorrect) non-equivalence of the two `x` functions.
I want to replace the `DeclsToCheck` and `TentativeEquivalences` with a set of `Decl` pairs (like the NonEquivalentDecls) so it will be possible to record the same **from** Decl with multiple **to** values. (Is there a reason for why there is a `NonEquivalentDecls` cache but not a `EquivalentDecls` or simply a cache for result values?)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62131/new/

https://reviews.llvm.org/D62131





More information about the cfe-commits mailing list