r207068 - Fix 3 test-only leaks found by LSan.

Nico Weber nicolasweber at gmx.de
Wed Apr 23 20:30:22 PDT 2014


Author: nico
Date: Wed Apr 23 22:30:22 2014
New Revision: 207068

URL: http://llvm.org/viewvc/llvm-project?rev=207068&view=rev
Log:
Fix 3 test-only leaks found by LSan.

Modified:
    cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h?rev=207068&r1=207067&r2=207068&view=diff
==============================================================================
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h Wed Apr 23 22:30:22 2014
@@ -64,8 +64,10 @@ testing::AssertionResult matchesConditio
                                               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::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.





More information about the cfe-commits mailing list