]> granicus.if.org Git - clang/commitdiff
Fix four more test-only leaks found by LSan.
authorNico Weber <nicolasweber@gmx.de>
Thu, 24 Apr 2014 03:48:09 +0000 (03:48 +0000)
committerNico Weber <nicolasweber@gmx.de>
Thu, 24 Apr 2014 03:48:09 +0000 (03:48 +0000)
Tool::run() doesn't take ownership of the passed action.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207071 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Tooling/ToolingTest.cpp

index 1eff6d064fcd3f57d773376e6e2a16e4439aea2b..ebc647ddade4f5635b3f01b0383fc4e4d4ae0738 100644 (file)
@@ -206,7 +206,9 @@ TEST(newFrontendActionFactory, InjectsSourceFileCallbacks) {
   Tool.mapVirtualFile("/a.cc", "void a() {}");
   Tool.mapVirtualFile("/b.cc", "void b() {}");
 
-  Tool.run(newFrontendActionFactory(&EndCallback, &EndCallback));
+  std::unique_ptr<FrontendActionFactory> Action(
+      newFrontendActionFactory(&EndCallback, &EndCallback));
+  Tool.run(Action.get());
 
   EXPECT_TRUE(EndCallback.Matched);
   EXPECT_EQ(2u, EndCallback.BeginCalled);
@@ -277,10 +279,13 @@ TEST(ClangToolTest, ArgumentAdjusters) {
   ClangTool Tool(Compilations, std::vector<std::string>(1, "/a.cc"));
   Tool.mapVirtualFile("/a.cc", "void a() {}");
 
+  std::unique_ptr<FrontendActionFactory> Action(
+      newFrontendActionFactory<SyntaxOnlyAction>());
+
   bool Found = false;
   bool Ran = false;
   Tool.appendArgumentsAdjuster(new CheckSyntaxOnlyAdjuster(Found, Ran));
-  Tool.run(newFrontendActionFactory<SyntaxOnlyAction>());
+  Tool.run(Action.get());
   EXPECT_TRUE(Ran);
   EXPECT_TRUE(Found);
 
@@ -288,7 +293,7 @@ TEST(ClangToolTest, ArgumentAdjusters) {
   Tool.clearArgumentsAdjusters();
   Tool.appendArgumentsAdjuster(new CheckSyntaxOnlyAdjuster(Found, Ran));
   Tool.appendArgumentsAdjuster(new ClangSyntaxOnlyAdjuster());
-  Tool.run(newFrontendActionFactory<SyntaxOnlyAction>());
+  Tool.run(Action.get());
   EXPECT_TRUE(Ran);
   EXPECT_FALSE(Found);
 }
@@ -327,7 +332,9 @@ TEST(ClangToolTest, InjectDiagnosticConsumer) {
   Tool.mapVirtualFile("/a.cc", "int x = undeclared;");
   TestDiagnosticConsumer Consumer;
   Tool.setDiagnosticConsumer(&Consumer);
-  Tool.run(newFrontendActionFactory<SyntaxOnlyAction>());
+  std::unique_ptr<FrontendActionFactory> Action(
+      newFrontendActionFactory<SyntaxOnlyAction>());
+  Tool.run(Action.get());
   EXPECT_EQ(1u, Consumer.NumDiagnosticsSeen);
 }