]> granicus.if.org Git - clang/commitdiff
Fix 3 test-only leaks found by LSan.
authorNico Weber <nicolasweber@gmx.de>
Thu, 24 Apr 2014 03:30:22 +0000 (03:30 +0000)
committerNico Weber <nicolasweber@gmx.de>
Thu, 24 Apr 2014 03:30:22 +0000 (03:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207068 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/ASTMatchers/ASTMatchersTest.h

index e224722e9649808cb2cd1f25445d77fdd0362c33..8e243cf078056ef9a4bc4a153a56c31f19bef4b6 100644 (file)
@@ -64,8 +64,10 @@ testing::AssertionResult matchesConditionally(const std::string &Code,
                                               llvm::StringRef CompileArg) {
   bool Found = false, DynamicFound = false;
   MatchFinder Finder;
-  Finder.addMatcher(AMatcher, new VerifyMatch(0, &Found));
-  if (!Finder.addDynamicMatcher(AMatcher, new VerifyMatch(0, &DynamicFound)))
+  VerifyMatch VerifyFound(0, &Found);
+  Finder.addMatcher(AMatcher, &VerifyFound);
+  VerifyMatch VerifyDynamicFound(0, &DynamicFound);
+  if (!Finder.addDynamicMatcher(AMatcher, &VerifyDynamicFound))
     return testing::AssertionFailure() << "Could not add dynamic matcher";
   std::unique_ptr<FrontendActionFactory> Factory(
       newFrontendActionFactory(&Finder));
@@ -109,8 +111,8 @@ matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher,
   std::unique_ptr<BoundNodesCallback> ScopedVerifier(FindResultVerifier);
   bool VerifiedResult = false;
   MatchFinder Finder;
-  Finder.addMatcher(
-      AMatcher, new VerifyMatch(FindResultVerifier, &VerifiedResult));
+  VerifyMatch VerifyVerifiedResult(FindResultVerifier, &VerifiedResult);
+  Finder.addMatcher(AMatcher, &VerifyVerifiedResult);
   std::unique_ptr<FrontendActionFactory> Factory(
       newFrontendActionFactory(&Finder));
   // Some tests use typeof, which is a gnu extension.