martong added a comment. Ok.
I like this patch because it eliminates the need for checking the redeclaration chains. Seems like it handles cycles and the simple `f(A,B)` vs `f(A,A)` cases properly too. (Not talking about caching now, probably we must remove the `NonEquivalentDecls` cache.) I've added two new test cases, could you please add them to the patch (maybe with modifications if you find something)? TEST_F(StructuralEquivalenceCacheTest, Cycle) { auto Decls = makeTuDecls( R"( class C; class A { C *c; }; class B { int i; }; void x(A *); void y(A *); class C { friend void x(A *); friend void y(A *); }; )", R"( class C; class A { C *c; }; class B { int i; }; void x(A *); void y(A *); class C { friend void x(A *); friend void y(A *); }; )", Lang_CXX); TranslationUnitDecl *TU1 = get<0>(Decls); TranslationUnitDecl *TU2 = get<1>(Decls); auto *C1 = LastDeclMatcher<CXXRecordDecl>().match( TU1, cxxRecordDecl(hasName("C"), unless(isImplicit()))); auto *C2 = LastDeclMatcher<CXXRecordDecl>().match( TU2, cxxRecordDecl(hasName("C"), unless(isImplicit()))); llvm::DenseSet<std::pair<Decl *, Decl *>> NonEquivalentDecls; StructuralEquivalenceContext Ctx( C1->getASTContext(), C2->getASTContext(), NonEquivalentDecls, StructuralEquivalenceKind::Default, false, false); bool Eq = Ctx.IsEquivalent(C1, C2); EXPECT_TRUE(Eq); } TEST_F(StructuralEquivalenceCacheTest, SimpleNonEq) { auto Decls = makeTuDecls( R"( class A {}; class B {}; void x(A, A); )", R"( class A {}; class B {}; void x(A, B); )", Lang_CXX); TranslationUnitDecl *TU1 = get<0>(Decls); TranslationUnitDecl *TU2 = get<1>(Decls); auto *x1 = FirstDeclMatcher<FunctionDecl>().match(TU1, functionDecl(hasName("x"))); auto *x2 = FirstDeclMatcher<FunctionDecl>().match(TU2, functionDecl(hasName("x"))); llvm::DenseSet<std::pair<Decl *, Decl *>> NonEquivalentDecls; StructuralEquivalenceContext Ctx( x1->getASTContext(), x2->getASTContext(), NonEquivalentDecls, StructuralEquivalenceKind::Default, false, false); bool Eq = Ctx.IsEquivalent(x1, x2); EXPECT_FALSE(Eq); } Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66538/new/ https://reviews.llvm.org/D66538 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits