Index: unittests/ASTMatchers/ASTMatchersTest.h =================================================================== --- unittests/ASTMatchers/ASTMatchersTest.h +++ unittests/ASTMatchers/ASTMatchersTest.h @@ -37,8 +37,8 @@ // If 'FindResultVerifier' is NULL, sets *Verified to true when Run is called. class VerifyMatch : public MatchFinder::MatchCallback { public: - VerifyMatch(BoundNodesCallback *FindResultVerifier, bool *Verified) - : Verified(Verified), FindResultReviewer(FindResultVerifier) {} + VerifyMatch(std::unique_ptr FindResultVerifier, bool *Verified) + : Verified(Verified), FindResultReviewer(std::move(FindResultVerifier)) {} void run(const MatchFinder::MatchResult &Result) override { if (FindResultReviewer != nullptr) { @@ -55,7 +55,7 @@ private: bool *const Verified; - BoundNodesCallback *const FindResultReviewer; + const std::unique_ptr FindResultReviewer; }; template @@ -222,12 +222,11 @@ template testing::AssertionResult matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher, - BoundNodesCallback *FindResultVerifier, + std::unique_ptr FindResultVerifier, bool ExpectResult) { - std::unique_ptr ScopedVerifier(FindResultVerifier); bool VerifiedResult = false; MatchFinder Finder; - VerifyMatch VerifyVerifiedResult(FindResultVerifier, &VerifiedResult); + VerifyMatch VerifyVerifiedResult(std::move(FindResultVerifier), &VerifiedResult); Finder.addMatcher(AMatcher, &VerifyVerifiedResult); std::unique_ptr Factory( newFrontendActionFactory(&Finder)); @@ -266,17 +265,17 @@ template testing::AssertionResult matchAndVerifyResultTrue(const std::string &Code, const T &AMatcher, - BoundNodesCallback *FindResultVerifier) { + std::unique_ptr FindResultVerifier) { return matchAndVerifyResultConditionally( - Code, AMatcher, FindResultVerifier, true); + Code, AMatcher, std::move(FindResultVerifier), true); } template testing::AssertionResult matchAndVerifyResultFalse(const std::string &Code, const T &AMatcher, - BoundNodesCallback *FindResultVerifier) { + std::unique_ptr FindResultVerifier) { return matchAndVerifyResultConditionally( - Code, AMatcher, FindResultVerifier, false); + Code, AMatcher, std::move(FindResultVerifier), false); } } // end namespace ast_matchers Index: unittests/ASTMatchers/ASTMatchersTest.cpp =================================================================== --- unittests/ASTMatchers/ASTMatchersTest.cpp +++ unittests/ASTMatchers/ASTMatchersTest.cpp @@ -817,7 +817,7 @@ "void f() { int a; float c; int d; int e; }", functionDecl(forEachDescendant( varDecl(hasDescendant(isInteger())).bind("x"))), - new VerifyIdIsBoundTo("x", 3))); + llvm::make_unique>("x", 3))); } TEST(HasDescendant, MatchesDescendantsOfTypes) { @@ -832,7 +832,7 @@ EXPECT_TRUE(matchAndVerifyResultTrue( "void f() { int*** i; }", qualType(asString("int ***"), forEachDescendant(pointerType().bind("x"))), - new VerifyIdIsBoundTo("x", 2))); + llvm::make_unique>("x", 2))); } TEST(Has, MatchesChildrenOfTypes) { @@ -843,7 +843,7 @@ EXPECT_TRUE(matchAndVerifyResultTrue( "int (*f)(float, int);", qualType(functionType(), forEach(qualType(isInteger()).bind("x"))), - new VerifyIdIsBoundTo("x", 2))); + llvm::make_unique>("x", 2))); } TEST(Has, MatchesChildTypes) { @@ -976,24 +976,24 @@ DeclarationMatcher ClassX = has(recordDecl(hasName("::X")).bind("x")); EXPECT_TRUE(matchAndVerifyResultTrue("class X {};", - ClassX, new VerifyIdIsBoundTo("x"))); + ClassX, llvm::make_unique>("x"))); EXPECT_TRUE(matchAndVerifyResultFalse("class X {};", - ClassX, new VerifyIdIsBoundTo("other-id"))); + ClassX, llvm::make_unique>("other-id"))); TypeMatcher TypeAHasClassB = hasDeclaration( recordDecl(hasName("A"), has(recordDecl(hasName("B")).bind("b")))); EXPECT_TRUE(matchAndVerifyResultTrue("class A { public: A *a; class B {}; };", TypeAHasClassB, - new VerifyIdIsBoundTo("b"))); + llvm::make_unique>("b"))); StatementMatcher MethodX = callExpr(callee(cxxMethodDecl(hasName("x")))).bind("x"); EXPECT_TRUE(matchAndVerifyResultTrue("class A { void x() { x(); } };", MethodX, - new VerifyIdIsBoundTo("x"))); + llvm::make_unique>("x"))); } TEST(Matcher, BindTheSameNameInAlternatives) { @@ -1010,7 +1010,7 @@ // The second branch binds x to f() and succeeds. "int f() { return 0 + f(); }", matcher, - new VerifyIdIsBoundTo("x"))); + llvm::make_unique>("x"))); } TEST(Matcher, BindsIDForMemoizedResults) { @@ -1022,7 +1022,7 @@ DeclarationMatcher(anyOf( recordDecl(hasName("A"), hasDescendant(ClassX)), recordDecl(hasName("B"), hasDescendant(ClassX)))), - new VerifyIdIsBoundTo("x", 2))); + llvm::make_unique>("x", 2))); } TEST(HasDeclaration, HasDeclarationOfEnumType) { @@ -1300,7 +1300,7 @@ "Y& operator&&(Y& x, Y& y) { return x; }; " "Y a; Y b; Y c; Y d = a && b && c;", cxxOperatorCallExpr(hasOverloadedOperatorName("&&")).bind("x"), - new VerifyIdIsBoundTo("x", 2))); + llvm::make_unique>("x", 2))); EXPECT_TRUE(matches("class Y { }; " "Y& operator&&(Y& x, Y& y) { return x; }; " "Y a; Y b; Y c; Y d = a && b && c;", @@ -1681,7 +1681,7 @@ " int y = 1;" " S1[y];" "}", - CallExpr, new VerifyIdIsBoundTo("param", 1))); + CallExpr, llvm::make_unique>("param", 1))); StatementMatcher CallExpr2 = callExpr(forEachArgumentWithParam(ArgumentY, IntParam)); @@ -1693,7 +1693,7 @@ " int y = 1;" " S::g(y);" "}", - CallExpr2, new VerifyIdIsBoundTo("param", 1))); + CallExpr2, llvm::make_unique>("param", 1))); } TEST(ForEachArgumentWithParam, MatchesCallExpr) { @@ -1705,17 +1705,19 @@ EXPECT_TRUE( matchAndVerifyResultTrue("void f(int i) { int y; f(y); }", CallExpr, - new VerifyIdIsBoundTo("param"))); + llvm::make_unique>( + "param"))); EXPECT_TRUE( matchAndVerifyResultTrue("void f(int i) { int y; f(y); }", CallExpr, - new VerifyIdIsBoundTo("arg"))); + llvm::make_unique>( + "arg"))); EXPECT_TRUE(matchAndVerifyResultTrue( "void f(int i, int j) { int y; f(y, y); }", CallExpr, - new VerifyIdIsBoundTo("param", 2))); + llvm::make_unique>("param", 2))); EXPECT_TRUE(matchAndVerifyResultTrue( "void f(int i, int j) { int y; f(y, y); }", CallExpr, - new VerifyIdIsBoundTo("arg", 2))); + llvm::make_unique>("arg", 2))); } TEST(ForEachArgumentWithParam, MatchesConstructExpr) { @@ -1731,7 +1733,8 @@ "};" "int y = 0;" "C Obj(y);", - ConstructExpr, new VerifyIdIsBoundTo("param"))); + ConstructExpr, + llvm::make_unique>("param"))); } TEST(ForEachArgumentWithParam, HandlesBoundNodesForNonMatches) { @@ -1748,7 +1751,7 @@ forEachDescendant(varDecl().bind("v")), forEachDescendant(callExpr(forEachArgumentWithParam( declRefExpr(to(decl(equalsBoundNode("v")))), parmVarDecl())))), - new VerifyIdIsBoundTo("v", 4))); + llvm::make_unique>("v", 4))); } TEST(Matcher, ArgumentCount) { @@ -3133,13 +3136,13 @@ DeclarationMatcher HasClassB = just(has(recordDecl(hasName("B")).bind("b"))); EXPECT_TRUE(matchAndVerifyResultTrue("class A { class B {}; };", - HasClassB, new VerifyIdIsBoundTo("b"))); + HasClassB, llvm::make_unique>("b"))); EXPECT_TRUE(matchAndVerifyResultFalse("class A { class B {}; };", - HasClassB, new VerifyIdIsBoundTo("a"))); + HasClassB, llvm::make_unique>("a"))); EXPECT_TRUE(matchAndVerifyResultFalse("class A { class C {}; };", - HasClassB, new VerifyIdIsBoundTo("b"))); + HasClassB, llvm::make_unique>("b"))); } AST_POLYMORPHIC_MATCHER_P(polymorphicHas, @@ -3156,13 +3159,13 @@ polymorphicHas(recordDecl(hasName("B")).bind("b")); EXPECT_TRUE(matchAndVerifyResultTrue("class A { class B {}; };", - HasClassB, new VerifyIdIsBoundTo("b"))); + HasClassB, llvm::make_unique>("b"))); EXPECT_TRUE(matchAndVerifyResultFalse("class A { class B {}; };", - HasClassB, new VerifyIdIsBoundTo("a"))); + HasClassB, llvm::make_unique>("a"))); EXPECT_TRUE(matchAndVerifyResultFalse("class A { class C {}; };", - HasClassB, new VerifyIdIsBoundTo("b"))); + HasClassB, llvm::make_unique>("b"))); StatementMatcher StatementHasClassB = polymorphicHas(recordDecl(hasName("B"))); @@ -3901,7 +3904,7 @@ EXPECT_TRUE(matchAndVerifyResultTrue( "void x() { switch (42) { case 1: case 2: case 3: default:; } }", switchStmt(forEachSwitchCase(caseStmt().bind("x"))), - new VerifyIdIsBoundTo("x", 3))); + llvm::make_unique>("x", 3))); } TEST(ForEachConstructorInitializer, MatchesInitializers) { @@ -3955,13 +3958,13 @@ TEST(ForEach, BindsOneNode) { EXPECT_TRUE(matchAndVerifyResultTrue("class C { int x; };", recordDecl(hasName("C"), forEach(fieldDecl(hasName("x")).bind("x"))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); } TEST(ForEach, BindsMultipleNodes) { EXPECT_TRUE(matchAndVerifyResultTrue("class C { int x; int y; int z; };", recordDecl(hasName("C"), forEach(fieldDecl().bind("f"))), - new VerifyIdIsBoundTo("f", 3))); + llvm::make_unique>("f", 3))); } TEST(ForEach, BindsRecursiveCombinations) { @@ -3969,14 +3972,14 @@ "class C { class D { int x; int y; }; class E { int y; int z; }; };", recordDecl(hasName("C"), forEach(recordDecl(forEach(fieldDecl().bind("f"))))), - new VerifyIdIsBoundTo("f", 4))); + llvm::make_unique>("f", 4))); } TEST(ForEachDescendant, BindsOneNode) { EXPECT_TRUE(matchAndVerifyResultTrue("class C { class D { int x; }; };", recordDecl(hasName("C"), forEachDescendant(fieldDecl(hasName("x")).bind("x"))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); } TEST(ForEachDescendant, NestedForEachDescendant) { @@ -3985,7 +3988,7 @@ EXPECT_TRUE(matchAndVerifyResultTrue( "class A { class B { class C {}; }; };", recordDecl(hasName("A"), anyOf(m, forEachDescendant(m))), - new VerifyIdIsBoundTo("x", "C"))); + llvm::make_unique>("x", "C"))); // Check that a partial match of 'm' that binds 'x' in the // first part of anyOf(m, anything()) will not overwrite the @@ -3993,7 +3996,7 @@ EXPECT_TRUE(matchAndVerifyResultTrue( "class A { class B { class C {}; }; };", recordDecl(hasName("A"), allOf(hasDescendant(m), anyOf(m, anything()))), - new VerifyIdIsBoundTo("x", "C"))); + llvm::make_unique>("x", "C"))); } TEST(ForEachDescendant, BindsMultipleNodes) { @@ -4001,7 +4004,7 @@ "class C { class D { int x; int y; }; " " class E { class F { int y; int z; }; }; };", recordDecl(hasName("C"), forEachDescendant(fieldDecl().bind("f"))), - new VerifyIdIsBoundTo("f", 4))); + llvm::make_unique>("f", 4))); } TEST(ForEachDescendant, BindsRecursiveCombinations) { @@ -4010,7 +4013,7 @@ " class E { class F { class G { int y; int z; }; }; }; }; };", recordDecl(hasName("C"), forEachDescendant(recordDecl( forEachDescendant(fieldDecl().bind("f"))))), - new VerifyIdIsBoundTo("f", 8))); + llvm::make_unique>("f", 8))); } TEST(ForEachDescendant, BindsCombinations) { @@ -4019,13 +4022,13 @@ "(true) {} }", compoundStmt(forEachDescendant(ifStmt().bind("if")), forEachDescendant(whileStmt().bind("while"))), - new VerifyIdIsBoundTo("if", 6))); + llvm::make_unique>("if", 6))); } TEST(Has, DoesNotDeleteBindings) { EXPECT_TRUE(matchAndVerifyResultTrue( "class X { int a; };", recordDecl(decl().bind("x"), has(fieldDecl())), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); } TEST(LoopingMatchers, DoNotOverwritePreviousMatchResultOnFailure) { @@ -4053,100 +4056,100 @@ recordDecl( recordDecl().bind("x"), hasName("::X"), anyOf(forEachDescendant(recordDecl(hasName("Y"))), anything())), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "class X {};", recordDecl(recordDecl().bind("x"), hasName("::X"), anyOf(unless(anything()), anything())), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "template class X {}; X x;", classTemplateSpecializationDecl( decl().bind("x"), hasAnyTemplateArgument(refersToType(asString("int")))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "class X { void f(); void g(); };", cxxRecordDecl(decl().bind("x"), hasMethod(hasName("g"))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "class X { X() : a(1), b(2) {} double a; int b; };", recordDecl(decl().bind("x"), has(cxxConstructorDecl( hasAnyConstructorInitializer(forField(hasName("b")))))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "void x(int, int) { x(0, 42); }", callExpr(expr().bind("x"), hasAnyArgument(integerLiteral(equals(42)))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "void x(int, int y) {}", functionDecl(decl().bind("x"), hasAnyParameter(hasName("y"))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "void x() { return; if (true) {} }", functionDecl(decl().bind("x"), has(compoundStmt(hasAnySubstatement(ifStmt())))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "namespace X { void b(int); void b(); }" "using X::b;", usingDecl(decl().bind("x"), hasAnyUsingShadowDecl(hasTargetDecl( functionDecl(parameterCountIs(1))))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "class A{}; class B{}; class C : B, A {};", cxxRecordDecl(decl().bind("x"), isDerivedFrom("::A")), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "class A{}; typedef A B; typedef A C; typedef A D;" "class E : A {};", cxxRecordDecl(decl().bind("x"), isDerivedFrom("C")), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "class A { class B { void f() {} }; };", functionDecl(decl().bind("x"), hasAncestor(recordDecl(hasName("::A")))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "template struct A { struct B {" " void f() { if(true) {} }" "}; };" "void t() { A::B b; b.f(); }", ifStmt(stmt().bind("x"), hasAncestor(recordDecl(hasName("::A")))), - new VerifyIdIsBoundTo("x", 2))); + llvm::make_unique>("x", 2))); EXPECT_TRUE(matchAndVerifyResultTrue( "class A {};", recordDecl(hasName("::A"), decl().bind("x"), unless(hasName("fooble"))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "class A { A() : s(), i(42) {} const char *s; int i; };", cxxConstructorDecl(hasName("::A::A"), decl().bind("x"), forEachConstructorInitializer(forField(hasName("i")))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); } TEST(ForEachDescendant, BindsCorrectNodes) { EXPECT_TRUE(matchAndVerifyResultTrue( "class C { void f(); int i; };", recordDecl(hasName("C"), forEachDescendant(decl().bind("decl"))), - new VerifyIdIsBoundTo("decl", 1))); + llvm::make_unique>("decl", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "class C { void f() {} int i; };", recordDecl(hasName("C"), forEachDescendant(decl().bind("decl"))), - new VerifyIdIsBoundTo("decl", 1))); + llvm::make_unique>("decl", 1))); } TEST(FindAll, BindsNodeOnMatch) { EXPECT_TRUE(matchAndVerifyResultTrue( "class A {};", recordDecl(hasName("::A"), findAll(recordDecl(hasName("::A")).bind("v"))), - new VerifyIdIsBoundTo("v", 1))); + llvm::make_unique>("v", 1))); } TEST(FindAll, BindsDescendantNodeOnMatch) { EXPECT_TRUE(matchAndVerifyResultTrue( "class A { int a; int b; };", recordDecl(hasName("::A"), findAll(fieldDecl().bind("v"))), - new VerifyIdIsBoundTo("v", 2))); + llvm::make_unique>("v", 2))); } TEST(FindAll, BindsNodeAndDescendantNodesOnOneMatch) { @@ -4155,12 +4158,12 @@ recordDecl(hasName("::A"), findAll(decl(anyOf(recordDecl(hasName("::A")).bind("v"), fieldDecl().bind("v"))))), - new VerifyIdIsBoundTo("v", 3))); + llvm::make_unique>("v", 3))); EXPECT_TRUE(matchAndVerifyResultTrue( "class A { class B {}; class C {}; };", recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("v"))), - new VerifyIdIsBoundTo("v", 3))); + llvm::make_unique>("v", 3))); } TEST(EachOf, TriggersForEachMatch) { @@ -4168,7 +4171,7 @@ "class A { int a; int b; };", recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), has(fieldDecl(hasName("b")).bind("v")))), - new VerifyIdIsBoundTo("v", 2))); + llvm::make_unique>("v", 2))); } TEST(EachOf, BehavesLikeAnyOfUnlessBothMatch) { @@ -4176,12 +4179,12 @@ "class A { int a; int c; };", recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), has(fieldDecl(hasName("b")).bind("v")))), - new VerifyIdIsBoundTo("v", 1))); + llvm::make_unique>("v", 1))); EXPECT_TRUE(matchAndVerifyResultTrue( "class A { int c; int b; };", recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), has(fieldDecl(hasName("b")).bind("v")))), - new VerifyIdIsBoundTo("v", 1))); + llvm::make_unique>("v", 1))); EXPECT_TRUE(notMatches( "class A { int c; int d; };", recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), @@ -4397,7 +4400,7 @@ EXPECT_TRUE(matchAndVerifyResultTrue( "class C { class D { class E { class F { int y; }; }; }; };", fieldDecl(hasAncestor(recordDecl(hasAncestor(recordDecl().bind("r"))))), - new VerifyIdIsBoundTo("r", 1))); + llvm::make_unique>("r", 1))); } TEST(HasAncestor, BindsCombinationsWithHasDescendant) { @@ -4409,7 +4412,7 @@ hasAncestor(recordDecl()))) ).bind("d") )), - new VerifyIdIsBoundTo("d", "E"))); + llvm::make_unique>("d", "E"))); } TEST(HasAncestor, MatchesClosestAncestor) { @@ -4423,7 +4426,7 @@ varDecl(hasName("x"), hasAncestor(functionDecl(hasParameter( 0, varDecl(hasType(asString("int"))))).bind("f"))).bind("v"), - new VerifyIdIsBoundTo("f", "g", 2))); + llvm::make_unique>("f", "g", 2))); } TEST(HasAncestor, MatchesInTemplateInstantiations) { @@ -4561,7 +4564,7 @@ EXPECT_FALSE(matchAndVerifyResultTrue( "template int Foo() { return 1 + 2; }\n" "int x = Foo() + Foo();", - stmt().bind("node"), new HasDuplicateParents())); + stmt().bind("node"), llvm::make_unique())); } TEST(TypeMatching, MatchesTypes) { @@ -4736,11 +4739,11 @@ //EXPECT_TRUE(matchAndVerifyResultTrue( // "int* a;", // pointerTypeLoc(pointeeLoc(typeLoc().bind("loc"))), - // new VerifyIdIsBoundTo("loc", 1))); + // llvm::make_unique>("loc", 1))); //EXPECT_TRUE(matchAndVerifyResultTrue( // "int* a;", // pointerTypeLoc().bind("loc"), - // new VerifyIdIsBoundTo("loc", 1))); + // llvm::make_unique>("loc", 1))); EXPECT_TRUE(matches( "int** a;", loc(pointerType(pointee(qualType()))))); @@ -4998,14 +5001,15 @@ EXPECT_TRUE(matchAndVerifyResultTrue( "namespace ns { struct E { struct B {}; }; } ns::E::B b;", nestedNameSpecifier(specifiesType(asString("struct ns::E"))).bind("nns"), - new VerifyIdIsBoundTo("nns", "ns::struct E::"))); + llvm::make_unique>( + "nns", "ns::struct E::"))); } TEST(NNS, BindsNestedNameSpecifierLocs) { EXPECT_TRUE(matchAndVerifyResultTrue( "namespace ns { struct B {}; } ns::B b;", loc(nestedNameSpecifier()).bind("loc"), - new VerifyIdIsBoundTo("loc", 1))); + llvm::make_unique>("loc", 1))); } TEST(NNS, MatchesNestedNameSpecifierPrefixes) { @@ -5044,7 +5048,7 @@ Fragment, nestedNameSpecifier(specifiesType(asString("struct a::A::B")), forEach(nestedNameSpecifier().bind("x"))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); } TEST(NNS, NestedNameSpecifiersAsDescendants) { @@ -5060,7 +5064,7 @@ functionDecl(hasName("f"), forEachDescendant(nestedNameSpecifier().bind("x"))), // Nested names: a, a::A and a::A::B. - new VerifyIdIsBoundTo("x", 3))); + llvm::make_unique>("x", 3))); } TEST(NNSLoc, DescendantsOfNestedNameSpecifierLocs) { @@ -5087,7 +5091,7 @@ Fragment, nestedNameSpecifierLoc(loc(specifiesType(asString("struct a::A::B"))), forEach(nestedNameSpecifierLoc().bind("x"))), - new VerifyIdIsBoundTo("x", 1))); + llvm::make_unique>("x", 1))); } TEST(NNSLoc, NestedNameSpecifierLocsAsDescendants) { @@ -5103,7 +5107,7 @@ functionDecl(hasName("f"), forEachDescendant(nestedNameSpecifierLoc().bind("x"))), // Nested names: a, a::A and a::A::B. - new VerifyIdIsBoundTo("x", 3))); + llvm::make_unique>("x", 3))); } template class VerifyMatchOnNode : public BoundNodesCallback { @@ -5129,12 +5133,12 @@ TEST(MatchFinder, CanMatchDeclarationsRecursively) { EXPECT_TRUE(matchAndVerifyResultTrue( "class X { class Y {}; };", recordDecl(hasName("::X")).bind("X"), - new VerifyMatchOnNode( + llvm::make_unique>( "X", decl(hasDescendant(recordDecl(hasName("X::Y")).bind("Y"))), "Y"))); EXPECT_TRUE(matchAndVerifyResultFalse( "class X { class Y {}; };", recordDecl(hasName("::X")).bind("X"), - new VerifyMatchOnNode( + llvm::make_unique>( "X", decl(hasDescendant(recordDecl(hasName("X::Z")).bind("Z"))), "Z"))); } @@ -5142,22 +5146,22 @@ TEST(MatchFinder, CanMatchStatementsRecursively) { EXPECT_TRUE(matchAndVerifyResultTrue( "void f() { if (1) { for (;;) { } } }", ifStmt().bind("if"), - new VerifyMatchOnNode( + llvm::make_unique>( "if", stmt(hasDescendant(forStmt().bind("for"))), "for"))); EXPECT_TRUE(matchAndVerifyResultFalse( "void f() { if (1) { for (;;) { } } }", ifStmt().bind("if"), - new VerifyMatchOnNode( + llvm::make_unique>( "if", stmt(hasDescendant(declStmt().bind("decl"))), "decl"))); } TEST(MatchFinder, CanMatchSingleNodesRecursively) { EXPECT_TRUE(matchAndVerifyResultTrue( "class X { class Y {}; };", recordDecl(hasName("::X")).bind("X"), - new VerifyMatchOnNode( + llvm::make_unique>( "X", recordDecl(has(recordDecl(hasName("X::Y")).bind("Y"))), "Y"))); EXPECT_TRUE(matchAndVerifyResultFalse( "class X { class Y {}; };", recordDecl(hasName("::X")).bind("X"), - new VerifyMatchOnNode( + llvm::make_unique>( "X", recordDecl(has(recordDecl(hasName("X::Z")).bind("Z"))), "Z"))); } @@ -5204,14 +5208,14 @@ TEST(IsEqualTo, MatchesNodesByIdentity) { EXPECT_TRUE(matchAndVerifyResultTrue( "class X { class Y {}; };", recordDecl(hasName("::X::Y")).bind(""), - new VerifyAncestorHasChildIsEqual())); + llvm::make_unique>())); EXPECT_TRUE(matchAndVerifyResultTrue( "void f() { if (true) if(true) {} }", ifStmt().bind(""), - new VerifyAncestorHasChildIsEqual())); + llvm::make_unique>())); EXPECT_TRUE(matchAndVerifyResultTrue( "class X { class Y {} y; };", fieldDecl(hasName("y"), hasType(type().bind(""))).bind("decl"), - new VerifyAncestorHasChildIsEqual())); + llvm::make_unique>())); } TEST(MatchFinder, CheckProfiling) { @@ -5366,7 +5370,7 @@ forEachDescendant(varDecl(hasType( qualType(equalsBoundNode("type")))).bind("decl"))), // Only i and j should match, not k. - new VerifyIdIsBoundTo("decl", 2))); + llvm::make_unique>("decl", 2))); } TEST(EqualsBoundNodeMatcher, FiltersMatchedCombinations) { @@ -5379,7 +5383,7 @@ functionDecl( hasName("f"), forEachDescendant(varDecl().bind("d")), forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))), - new VerifyIdIsBoundTo("d", 5))); + llvm::make_unique>("d", 5))); } TEST(EqualsBoundNodeMatcher, UnlessDescendantsOfAncestorsMatch) { @@ -5396,7 +5400,7 @@ callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))), on(declRefExpr(to(varDecl(equalsBoundNode("var"))))))))))) .bind("data"), - new VerifyIdIsBoundTo("data", 1))); + llvm::make_unique>("data", 1))); EXPECT_FALSE(matches( "struct StringRef { int size() const; const char* data() const; };"