courbet created this revision.
courbet added a reviewer: aaron.ballman.
courbet added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Statically specify ownership of verifiers in tests. NFC

http://reviews.llvm.org/D19362

Files:
  unittests/ASTMatchers/ASTMatchersTest.cpp
  unittests/ASTMatchers/ASTMatchersTest.h

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<BoundNodesCallback> 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<BoundNodesCallback> FindResultReviewer;
 };
 
 template <typename T>
@@ -222,12 +222,11 @@
 template <typename T>
 testing::AssertionResult
 matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher,
-                                  BoundNodesCallback *FindResultVerifier,
+                                  std::unique_ptr<BoundNodesCallback> FindResultVerifier,
                                   bool ExpectResult) {
-  std::unique_ptr<BoundNodesCallback> ScopedVerifier(FindResultVerifier);
   bool VerifiedResult = false;
   MatchFinder Finder;
-  VerifyMatch VerifyVerifiedResult(FindResultVerifier, &VerifiedResult);
+  VerifyMatch VerifyVerifiedResult(std::move(FindResultVerifier), &VerifiedResult);
   Finder.addMatcher(AMatcher, &VerifyVerifiedResult);
   std::unique_ptr<FrontendActionFactory> Factory(
       newFrontendActionFactory(&Finder));
@@ -266,17 +265,17 @@
 template <typename T>
 testing::AssertionResult
 matchAndVerifyResultTrue(const std::string &Code, const T &AMatcher,
-                         BoundNodesCallback *FindResultVerifier) {
+                         std::unique_ptr<BoundNodesCallback> FindResultVerifier) {
   return matchAndVerifyResultConditionally(
-      Code, AMatcher, FindResultVerifier, true);
+      Code, AMatcher, std::move(FindResultVerifier), true);
 }
 
 template <typename T>
 testing::AssertionResult
 matchAndVerifyResultFalse(const std::string &Code, const T &AMatcher,
-                          BoundNodesCallback *FindResultVerifier) {
+                          std::unique_ptr<BoundNodesCallback> 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<Decl>("x", 3)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("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<Type>("x", 2)));
+      llvm::make_unique<VerifyIdIsBoundTo<Type>>("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<QualType>("x", 2)));
+      llvm::make_unique<VerifyIdIsBoundTo<QualType>>("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<CXXRecordDecl>("x")));
+      ClassX, llvm::make_unique<VerifyIdIsBoundTo<CXXRecordDecl>>("x")));
 
   EXPECT_TRUE(matchAndVerifyResultFalse("class X {};",
-      ClassX, new VerifyIdIsBoundTo<CXXRecordDecl>("other-id")));
+      ClassX, llvm::make_unique<VerifyIdIsBoundTo<CXXRecordDecl>>("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<Decl>("b")));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("b")));
 
   StatementMatcher MethodX =
       callExpr(callee(cxxMethodDecl(hasName("x")))).bind("x");
 
   EXPECT_TRUE(matchAndVerifyResultTrue("class A { void x() { x(); } };",
       MethodX,
-      new VerifyIdIsBoundTo<CXXMemberCallExpr>("x")));
+      llvm::make_unique<VerifyIdIsBoundTo<CXXMemberCallExpr>>("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<CallExpr>("x")));
+      llvm::make_unique<VerifyIdIsBoundTo<CallExpr>>("x")));
 }
 
 TEST(Matcher, BindsIDForMemoizedResults) {
@@ -1022,7 +1022,7 @@
       DeclarationMatcher(anyOf(
           recordDecl(hasName("A"), hasDescendant(ClassX)),
           recordDecl(hasName("B"), hasDescendant(ClassX)))),
-      new VerifyIdIsBoundTo<Decl>("x", 2)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("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<CXXOperatorCallExpr>("x", 2)));
+      llvm::make_unique<VerifyIdIsBoundTo<CXXOperatorCallExpr>>("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<ParmVarDecl>("param", 1)));
+      CallExpr, llvm::make_unique<VerifyIdIsBoundTo<ParmVarDecl>>("param", 1)));
 
   StatementMatcher CallExpr2 =
       callExpr(forEachArgumentWithParam(ArgumentY, IntParam));
@@ -1693,7 +1693,7 @@
       "  int y = 1;"
       "  S::g(y);"
       "}",
-      CallExpr2, new VerifyIdIsBoundTo<ParmVarDecl>("param", 1)));
+      CallExpr2, llvm::make_unique<VerifyIdIsBoundTo<ParmVarDecl>>("param", 1)));
 }
 
 TEST(ForEachArgumentWithParam, MatchesCallExpr) {
@@ -1705,17 +1705,19 @@
 
   EXPECT_TRUE(
       matchAndVerifyResultTrue("void f(int i) { int y; f(y); }", CallExpr,
-                               new VerifyIdIsBoundTo<ParmVarDecl>("param")));
+                               llvm::make_unique<VerifyIdIsBoundTo<ParmVarDecl>>(
+                                   "param")));
   EXPECT_TRUE(
       matchAndVerifyResultTrue("void f(int i) { int y; f(y); }", CallExpr,
-                               new VerifyIdIsBoundTo<DeclRefExpr>("arg")));
+                               llvm::make_unique<VerifyIdIsBoundTo<DeclRefExpr>>(
+                                   "arg")));
 
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "void f(int i, int j) { int y; f(y, y); }", CallExpr,
-      new VerifyIdIsBoundTo<ParmVarDecl>("param", 2)));
+      llvm::make_unique<VerifyIdIsBoundTo<ParmVarDecl>>("param", 2)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "void f(int i, int j) { int y; f(y, y); }", CallExpr,
-      new VerifyIdIsBoundTo<DeclRefExpr>("arg", 2)));
+      llvm::make_unique<VerifyIdIsBoundTo<DeclRefExpr>>("arg", 2)));
 }
 
 TEST(ForEachArgumentWithParam, MatchesConstructExpr) {
@@ -1731,7 +1733,8 @@
       "};"
       "int y = 0;"
       "C Obj(y);",
-      ConstructExpr, new VerifyIdIsBoundTo<ParmVarDecl>("param")));
+      ConstructExpr,
+      llvm::make_unique<VerifyIdIsBoundTo<ParmVarDecl>>("param")));
 }
 
 TEST(ForEachArgumentWithParam, HandlesBoundNodesForNonMatches) {
@@ -1748,7 +1751,7 @@
           forEachDescendant(varDecl().bind("v")),
           forEachDescendant(callExpr(forEachArgumentWithParam(
               declRefExpr(to(decl(equalsBoundNode("v")))), parmVarDecl())))),
-      new VerifyIdIsBoundTo<VarDecl>("v", 4)));
+      llvm::make_unique<VerifyIdIsBoundTo<VarDecl>>("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<Decl>("b")));
+      HasClassB, llvm::make_unique<VerifyIdIsBoundTo<Decl>>("b")));
 
   EXPECT_TRUE(matchAndVerifyResultFalse("class A { class B {}; };",
-      HasClassB, new VerifyIdIsBoundTo<Decl>("a")));
+      HasClassB, llvm::make_unique<VerifyIdIsBoundTo<Decl>>("a")));
 
   EXPECT_TRUE(matchAndVerifyResultFalse("class A { class C {}; };",
-      HasClassB, new VerifyIdIsBoundTo<Decl>("b")));
+      HasClassB, llvm::make_unique<VerifyIdIsBoundTo<Decl>>("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<Decl>("b")));
+      HasClassB, llvm::make_unique<VerifyIdIsBoundTo<Decl>>("b")));
 
   EXPECT_TRUE(matchAndVerifyResultFalse("class A { class B {}; };",
-      HasClassB, new VerifyIdIsBoundTo<Decl>("a")));
+      HasClassB, llvm::make_unique<VerifyIdIsBoundTo<Decl>>("a")));
 
   EXPECT_TRUE(matchAndVerifyResultFalse("class A { class C {}; };",
-      HasClassB, new VerifyIdIsBoundTo<Decl>("b")));
+      HasClassB, llvm::make_unique<VerifyIdIsBoundTo<Decl>>("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<CaseStmt>("x", 3)));
+      llvm::make_unique<VerifyIdIsBoundTo<CaseStmt>>("x", 3)));
 }
 
 TEST(ForEachConstructorInitializer, MatchesInitializers) {
@@ -3955,77 +3958,77 @@
 TEST(ForEach, BindsOneNode) {
   EXPECT_TRUE(matchAndVerifyResultTrue("class C { int x; };",
       recordDecl(hasName("C"), forEach(fieldDecl(hasName("x")).bind("x"))),
-      new VerifyIdIsBoundTo<FieldDecl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<FieldDecl>>("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<FieldDecl>("f", 3)));
+      llvm::make_unique<VerifyIdIsBoundTo<FieldDecl>>("f", 3)));
 }
 
 TEST(ForEach, BindsRecursiveCombinations) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "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<FieldDecl>("f", 4)));
+      llvm::make_unique<VerifyIdIsBoundTo<FieldDecl>>("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<FieldDecl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<FieldDecl>>("x", 1)));
 }
 
 TEST(ForEachDescendant, NestedForEachDescendant) {
   DeclarationMatcher m = recordDecl(
       isDefinition(), decl().bind("x"), hasName("C"));
   EXPECT_TRUE(matchAndVerifyResultTrue(
     "class A { class B { class C {}; }; };",
     recordDecl(hasName("A"), anyOf(m, forEachDescendant(m))),
-    new VerifyIdIsBoundTo<Decl>("x", "C")));
+    llvm::make_unique<VerifyIdIsBoundTo<Decl>>("x", "C")));
 
   // Check that a partial match of 'm' that binds 'x' in the
   // first part of anyOf(m, anything()) will not overwrite the
   // binding created by the earlier binding in the hasDescendant.
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class A { class B { class C {}; }; };",
       recordDecl(hasName("A"), allOf(hasDescendant(m), anyOf(m, anything()))),
-      new VerifyIdIsBoundTo<Decl>("x", "C")));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("x", "C")));
 }
 
 TEST(ForEachDescendant, BindsMultipleNodes) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "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<FieldDecl>("f", 4)));
+      llvm::make_unique<VerifyIdIsBoundTo<FieldDecl>>("f", 4)));
 }
 
 TEST(ForEachDescendant, BindsRecursiveCombinations) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class C { class D { "
       "          class E { class F { class G { int y; int z; }; }; }; }; };",
       recordDecl(hasName("C"), forEachDescendant(recordDecl(
           forEachDescendant(fieldDecl().bind("f"))))),
-      new VerifyIdIsBoundTo<FieldDecl>("f", 8)));
+      llvm::make_unique<VerifyIdIsBoundTo<FieldDecl>>("f", 8)));
 }
 
 TEST(ForEachDescendant, BindsCombinations) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "void f() { if(true) {} if (true) {} while (true) {} if (true) {} while "
       "(true) {} }",
       compoundStmt(forEachDescendant(ifStmt().bind("if")),
                    forEachDescendant(whileStmt().bind("while"))),
-      new VerifyIdIsBoundTo<IfStmt>("if", 6)));
+      llvm::make_unique<VerifyIdIsBoundTo<IfStmt>>("if", 6)));
 }
 
 TEST(Has, DoesNotDeleteBindings) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class X { int a; };", recordDecl(decl().bind("x"), has(fieldDecl())),
-      new VerifyIdIsBoundTo<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("x", 1)));
 }
 
 TEST(LoopingMatchers, DoNotOverwritePreviousMatchResultOnFailure) {
@@ -4053,135 +4056,135 @@
       recordDecl(
           recordDecl().bind("x"), hasName("::X"),
           anyOf(forEachDescendant(recordDecl(hasName("Y"))), anything())),
-      new VerifyIdIsBoundTo<CXXRecordDecl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<CXXRecordDecl>>("x", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class X {};", recordDecl(recordDecl().bind("x"), hasName("::X"),
                                 anyOf(unless(anything()), anything())),
-      new VerifyIdIsBoundTo<CXXRecordDecl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<CXXRecordDecl>>("x", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "template<typename T1, typename T2> class X {}; X<float, int> x;",
       classTemplateSpecializationDecl(
           decl().bind("x"),
           hasAnyTemplateArgument(refersToType(asString("int")))),
-      new VerifyIdIsBoundTo<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("x", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class X { void f(); void g(); };",
       cxxRecordDecl(decl().bind("x"), hasMethod(hasName("g"))),
-      new VerifyIdIsBoundTo<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("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<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("x", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "void x(int, int) { x(0, 42); }",
       callExpr(expr().bind("x"), hasAnyArgument(integerLiteral(equals(42)))),
-      new VerifyIdIsBoundTo<Expr>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Expr>>("x", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "void x(int, int y) {}",
       functionDecl(decl().bind("x"), hasAnyParameter(hasName("y"))),
-      new VerifyIdIsBoundTo<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("x", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "void x() { return; if (true) {} }",
       functionDecl(decl().bind("x"),
                    has(compoundStmt(hasAnySubstatement(ifStmt())))),
-      new VerifyIdIsBoundTo<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("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<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("x", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class A{}; class B{}; class C : B, A {};",
       cxxRecordDecl(decl().bind("x"), isDerivedFrom("::A")),
-      new VerifyIdIsBoundTo<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("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<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("x", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class A { class B { void f() {} }; };",
       functionDecl(decl().bind("x"), hasAncestor(recordDecl(hasName("::A")))),
-      new VerifyIdIsBoundTo<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("x", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "template <typename T> struct A { struct B {"
       "  void f() { if(true) {} }"
       "}; };"
       "void t() { A<int>::B b; b.f(); }",
       ifStmt(stmt().bind("x"), hasAncestor(recordDecl(hasName("::A")))),
-      new VerifyIdIsBoundTo<Stmt>("x", 2)));
+      llvm::make_unique<VerifyIdIsBoundTo<Stmt>>("x", 2)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class A {};",
       recordDecl(hasName("::A"), decl().bind("x"), unless(hasName("fooble"))),
-      new VerifyIdIsBoundTo<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("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<Decl>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("x", 1)));
 }
 
 TEST(ForEachDescendant, BindsCorrectNodes) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class C { void f(); int i; };",
       recordDecl(hasName("C"), forEachDescendant(decl().bind("decl"))),
-      new VerifyIdIsBoundTo<FieldDecl>("decl", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<FieldDecl>>("decl", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class C { void f() {} int i; };",
       recordDecl(hasName("C"), forEachDescendant(decl().bind("decl"))),
-      new VerifyIdIsBoundTo<FunctionDecl>("decl", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<FunctionDecl>>("decl", 1)));
 }
 
 TEST(FindAll, BindsNodeOnMatch) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class A {};",
       recordDecl(hasName("::A"), findAll(recordDecl(hasName("::A")).bind("v"))),
-      new VerifyIdIsBoundTo<CXXRecordDecl>("v", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<CXXRecordDecl>>("v", 1)));
 }
 
 TEST(FindAll, BindsDescendantNodeOnMatch) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class A { int a; int b; };",
       recordDecl(hasName("::A"), findAll(fieldDecl().bind("v"))),
-      new VerifyIdIsBoundTo<FieldDecl>("v", 2)));
+      llvm::make_unique<VerifyIdIsBoundTo<FieldDecl>>("v", 2)));
 }
 
 TEST(FindAll, BindsNodeAndDescendantNodesOnOneMatch) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class A { int a; int b; };",
       recordDecl(hasName("::A"),
                  findAll(decl(anyOf(recordDecl(hasName("::A")).bind("v"),
                                     fieldDecl().bind("v"))))),
-      new VerifyIdIsBoundTo<Decl>("v", 3)));
+      llvm::make_unique<VerifyIdIsBoundTo<Decl>>("v", 3)));
 
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class A { class B {}; class C {}; };",
       recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("v"))),
-      new VerifyIdIsBoundTo<CXXRecordDecl>("v", 3)));
+      llvm::make_unique<VerifyIdIsBoundTo<CXXRecordDecl>>("v", 3)));
 }
 
 TEST(EachOf, TriggersForEachMatch) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class A { int a; int b; };",
       recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
                         has(fieldDecl(hasName("b")).bind("v")))),
-      new VerifyIdIsBoundTo<FieldDecl>("v", 2)));
+      llvm::make_unique<VerifyIdIsBoundTo<FieldDecl>>("v", 2)));
 }
 
 TEST(EachOf, BehavesLikeAnyOfUnlessBothMatch) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class A { int a; int c; };",
       recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
                         has(fieldDecl(hasName("b")).bind("v")))),
-      new VerifyIdIsBoundTo<FieldDecl>("v", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<FieldDecl>>("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<FieldDecl>("v", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<FieldDecl>>("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<CXXRecordDecl>("r", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<CXXRecordDecl>>("r", 1)));
 }
 
 TEST(HasAncestor, BindsCombinationsWithHasDescendant) {
@@ -4409,7 +4412,7 @@
                                      hasAncestor(recordDecl())))
           ).bind("d")
       )),
-      new VerifyIdIsBoundTo<CXXRecordDecl>("d", "E")));
+      llvm::make_unique<VerifyIdIsBoundTo<CXXRecordDecl>>("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<FunctionDecl>("f", "g", 2)));
+      llvm::make_unique<VerifyIdIsBoundTo<FunctionDecl>>("f", "g", 2)));
 }
 
 TEST(HasAncestor, MatchesInTemplateInstantiations) {
@@ -4561,7 +4564,7 @@
   EXPECT_FALSE(matchAndVerifyResultTrue(
       "template <typename T> int Foo() { return 1 + 2; }\n"
       "int x = Foo<int>() + Foo<unsigned>();",
-      stmt().bind("node"), new HasDuplicateParents()));
+      stmt().bind("node"), llvm::make_unique<HasDuplicateParents>()));
 }
 
 TEST(TypeMatching, MatchesTypes) {
@@ -4736,11 +4739,11 @@
   //EXPECT_TRUE(matchAndVerifyResultTrue(
   //    "int* a;",
   //    pointerTypeLoc(pointeeLoc(typeLoc().bind("loc"))),
-  //    new VerifyIdIsBoundTo<TypeLoc>("loc", 1)));
+  //    llvm::make_unique<VerifyIdIsBoundTo<TypeLoc>>("loc", 1)));
   //EXPECT_TRUE(matchAndVerifyResultTrue(
   //    "int* a;",
   //    pointerTypeLoc().bind("loc"),
-  //    new VerifyIdIsBoundTo<TypeLoc>("loc", 1)));
+  //    llvm::make_unique<VerifyIdIsBoundTo<TypeLoc>>("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<NestedNameSpecifier>("nns", "ns::struct E::")));
+      llvm::make_unique<VerifyIdIsBoundTo<NestedNameSpecifier>>(
+          "nns", "ns::struct E::")));
 }
 
 TEST(NNS, BindsNestedNameSpecifierLocs) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "namespace ns { struct B {}; } ns::B b;",
       loc(nestedNameSpecifier()).bind("loc"),
-      new VerifyIdIsBoundTo<NestedNameSpecifierLoc>("loc", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<NestedNameSpecifierLoc>>("loc", 1)));
 }
 
 TEST(NNS, MatchesNestedNameSpecifierPrefixes) {
@@ -5044,7 +5048,7 @@
       Fragment,
       nestedNameSpecifier(specifiesType(asString("struct a::A::B")),
                           forEach(nestedNameSpecifier().bind("x"))),
-      new VerifyIdIsBoundTo<NestedNameSpecifier>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<NestedNameSpecifier>>("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<NestedNameSpecifier>("x", 3)));
+      llvm::make_unique<VerifyIdIsBoundTo<NestedNameSpecifier>>("x", 3)));
 }
 
 TEST(NNSLoc, DescendantsOfNestedNameSpecifierLocs) {
@@ -5087,7 +5091,7 @@
       Fragment,
       nestedNameSpecifierLoc(loc(specifiesType(asString("struct a::A::B"))),
                              forEach(nestedNameSpecifierLoc().bind("x"))),
-      new VerifyIdIsBoundTo<NestedNameSpecifierLoc>("x", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<NestedNameSpecifierLoc>>("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<NestedNameSpecifierLoc>("x", 3)));
+      llvm::make_unique<VerifyIdIsBoundTo<NestedNameSpecifierLoc>>("x", 3)));
 }
 
 template <typename T> class VerifyMatchOnNode : public BoundNodesCallback {
@@ -5129,35 +5133,35 @@
 TEST(MatchFinder, CanMatchDeclarationsRecursively) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class X { class Y {}; };", recordDecl(hasName("::X")).bind("X"),
-      new VerifyMatchOnNode<clang::Decl>(
+      llvm::make_unique<VerifyMatchOnNode<Decl>>(
           "X", decl(hasDescendant(recordDecl(hasName("X::Y")).bind("Y"))),
           "Y")));
   EXPECT_TRUE(matchAndVerifyResultFalse(
       "class X { class Y {}; };", recordDecl(hasName("::X")).bind("X"),
-      new VerifyMatchOnNode<clang::Decl>(
+      llvm::make_unique<VerifyMatchOnNode<Decl>>(
           "X", decl(hasDescendant(recordDecl(hasName("X::Z")).bind("Z"))),
           "Z")));
 }
 
 TEST(MatchFinder, CanMatchStatementsRecursively) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "void f() { if (1) { for (;;) { } } }", ifStmt().bind("if"),
-      new VerifyMatchOnNode<clang::Stmt>(
+      llvm::make_unique<VerifyMatchOnNode<Stmt>>(
           "if", stmt(hasDescendant(forStmt().bind("for"))), "for")));
   EXPECT_TRUE(matchAndVerifyResultFalse(
       "void f() { if (1) { for (;;) { } } }", ifStmt().bind("if"),
-      new VerifyMatchOnNode<clang::Stmt>(
+      llvm::make_unique<VerifyMatchOnNode<Stmt>>(
           "if", stmt(hasDescendant(declStmt().bind("decl"))), "decl")));
 }
 
 TEST(MatchFinder, CanMatchSingleNodesRecursively) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class X { class Y {}; };", recordDecl(hasName("::X")).bind("X"),
-      new VerifyMatchOnNode<clang::Decl>(
+      llvm::make_unique<VerifyMatchOnNode<Decl>>(
           "X", recordDecl(has(recordDecl(hasName("X::Y")).bind("Y"))), "Y")));
   EXPECT_TRUE(matchAndVerifyResultFalse(
       "class X { class Y {}; };", recordDecl(hasName("::X")).bind("X"),
-      new VerifyMatchOnNode<clang::Decl>(
+      llvm::make_unique<VerifyMatchOnNode<Decl>>(
           "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<CXXRecordDecl>()));
+      llvm::make_unique<VerifyAncestorHasChildIsEqual<CXXRecordDecl>>()));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "void f() { if (true) if(true) {} }", ifStmt().bind(""),
-      new VerifyAncestorHasChildIsEqual<IfStmt>()));
+      llvm::make_unique<VerifyAncestorHasChildIsEqual<IfStmt>>()));
   EXPECT_TRUE(matchAndVerifyResultTrue(
       "class X { class Y {} y; };",
       fieldDecl(hasName("y"), hasType(type().bind(""))).bind("decl"),
-      new VerifyAncestorHasChildIsEqual<Type>()));
+      llvm::make_unique<VerifyAncestorHasChildIsEqual<Type>>()));
 }
 
 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<VarDecl>("decl", 2)));
+      llvm::make_unique<VerifyIdIsBoundTo<VarDecl>>("decl", 2)));
 }
 
 TEST(EqualsBoundNodeMatcher, FiltersMatchedCombinations) {
@@ -5379,7 +5383,7 @@
       functionDecl(
           hasName("f"), forEachDescendant(varDecl().bind("d")),
           forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))),
-      new VerifyIdIsBoundTo<VarDecl>("d", 5)));
+      llvm::make_unique<VerifyIdIsBoundTo<VarDecl>>("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<Expr>("data", 1)));
+      llvm::make_unique<VerifyIdIsBoundTo<Expr>>("data", 1)));
 
   EXPECT_FALSE(matches(
       "struct StringRef { int size() const; const char* data() const; };"
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to