[PATCH] D66538: [AST] AST structural equivalence to work internally with pairs.

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 23 07:38:03 PDT 2019


martong added a comment.

There is a third test which could be useful to test whether there is no faulty cache entries there:

  +TEST_F(StructuralEquivalenceCacheTest, DISABLED_NonEq) {
  +  auto Decls =
  +      makeTuDecls(
  +          R"(
  +            class A {};
  +            class B {
  +              int i;
  +            };
  +            void x(A *);
  +            void y(A *);
  +            class C {
  +              friend void x(A *);
  +              friend void y(A *);
  +            };
  +          )",
  +          R"(
  +            class A {};
  +            class B {
  +              int i;
  +            };
  +            void x(A *);
  +            void y(B *);
  +            class C {
  +              friend void x(A *);
  +              friend void y(B *);
  +            };
  +          )", 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())));
  +  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(
  +        C1->getASTContext(), C2->getASTContext(), NonEquivalentDecls,
  +        StructuralEquivalenceKind::Default, false, false);
  +    EXPECT_FALSE(Ctx.IsEquivalent(C1, C2));
  +  }
  +
  +  // Reuse the cache.
  +  {
  +    StructuralEquivalenceContext Ctx(
  +        C1->getASTContext(), C2->getASTContext(), NonEquivalentDecls,
  +        StructuralEquivalenceKind::Default, false, false);
  +    EXPECT_TRUE(Ctx.IsEquivalent(x1, x2));
  +  }
  +}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66538





More information about the cfe-commits mailing list