From 9fb2c586fbafade3660092f8c12462708c737b46 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 24 Apr 2014 03:48:09 +0000 Subject: [PATCH] Fix four more test-only leaks found by LSan. 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 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/unittests/Tooling/ToolingTest.cpp b/unittests/Tooling/ToolingTest.cpp index 1eff6d064f..ebc647ddad 100644 --- a/unittests/Tooling/ToolingTest.cpp +++ b/unittests/Tooling/ToolingTest.cpp @@ -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 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(1, "/a.cc")); Tool.mapVirtualFile("/a.cc", "void a() {}"); + std::unique_ptr Action( + newFrontendActionFactory()); + bool Found = false; bool Ran = false; Tool.appendArgumentsAdjuster(new CheckSyntaxOnlyAdjuster(Found, Ran)); - Tool.run(newFrontendActionFactory()); + 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()); + 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()); + std::unique_ptr Action( + newFrontendActionFactory()); + Tool.run(Action.get()); EXPECT_EQ(1u, Consumer.NumDiagnosticsSeen); } -- 2.40.0